context
stringlengths 11
9.12k
| question
stringlengths 0
1.06k
| SQL
stringlengths 2
4.44k
| source
stringclasses 28
values |
|---|---|---|---|
CREATE TABLE carbon_emissions (year INT, region VARCHAR(255), emissions_reduction FLOAT); INSERT INTO carbon_emissions (year, region, emissions_reduction) VALUES (2021, 'South America', 320), (2021, 'Europe', 280), (2022, 'South America', 360);
|
What was the total carbon emissions reduction due to energy efficiency measures in South America in 2021?
|
SELECT emissions_reduction FROM carbon_emissions WHERE year = 2021 AND region = 'South America'
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE USHealthInsurance (State VARCHAR(50), Population INT, Insured INT); INSERT INTO USHealthInsurance (State, Population, Insured) VALUES ('California', 40000000, 32000000), ('Texas', 30000000, 24000000), ('New York', 20000000, 16000000), ('Florida', 22000000, 17000000);
|
What is the percentage of the population with health insurance in each state of the USA?
|
SELECT State, (SUM(Insured) / SUM(Population)) * 100 AS HealthInsurancePercentage FROM USHealthInsurance GROUP BY State;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE international_visitors (visitor_id INT, visitor_name VARCHAR(50), passport_number VARCHAR(50), entry_year INT, exit_year INT, country_of_origin_id INT, PRIMARY KEY (visitor_id), FOREIGN KEY (country_of_origin_id) REFERENCES countries(country_id));CREATE TABLE countries (country_id INT, country_name VARCHAR(50), region_id INT, PRIMARY KEY (country_id));CREATE TABLE regions (region_id INT, region_name VARCHAR(50), PRIMARY KEY (region_id));
|
What is the percentage change in international visitors from the previous year for each country?
|
SELECT c.country_name, (COUNT(CASE WHEN iv.entry_year = YEAR(CURRENT_DATE()) - 1 THEN iv.visitor_id END) - COUNT(CASE WHEN iv.entry_year = YEAR(CURRENT_DATE()) - 2 THEN iv.visitor_id END)) * 100.0 / COUNT(CASE WHEN iv.entry_year = YEAR(CURRENT_DATE()) - 2 THEN iv.visitor_id END) as percentage_change FROM international_visitors iv JOIN countries c ON iv.country_of_origin_id = c.country_id GROUP BY c.country_name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE teams (team_id INT, team_name VARCHAR(50)); CREATE TABLE games (game_id INT, team_id INT, won INT);
|
Calculate the percentage of games won by each MLB team.
|
SELECT team_id, AVG(won) * 100.0 / (SELECT COUNT(*) FROM games WHERE team_id = teams.team_id) AS win_percentage FROM games JOIN teams ON games.team_id = teams.team_id GROUP BY team_id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE salesperson (id INT, name VARCHAR(50), commission DECIMAL(5,2));CREATE TABLE tickets (id INT, salesperson_id INT, sale_date DATE, quantity INT);
|
What is the total number of tickets sold by each salesperson, and their corresponding commission, for the last 3 months?
|
SELECT s.name, SUM(t.quantity) * 50 AS total_tickets_sold, SUM(t.quantity) * 0.05 AS commission FROM salesperson s JOIN tickets t ON s.id = t.salesperson_id WHERE t.sale_date BETWEEN DATE_SUB(CURDATE(), INTERVAL 3 MONTH) AND CURDATE() GROUP BY s.id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE vulnerabilities (id INT, severity TEXT, severity_score INT, discovered_at TIMESTAMP); INSERT INTO vulnerabilities (id, severity, severity_score, discovered_at) VALUES (1, 'medium', 5, '2021-01-01 12:00:00'), (2, 'high', 8, '2021-01-15 14:30:00'), (3, 'critical', 10, '2021-02-01 10:15:00');
|
What is the average severity score of vulnerabilities discovered this week?
|
SELECT AVG(severity_score) FROM vulnerabilities WHERE discovered_at >= NOW() - INTERVAL '1 week';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE OceanPollution (year INTEGER, location TEXT, incidents INTEGER); INSERT INTO OceanPollution (year, location, incidents) VALUES (2020, 'Indian Ocean', 15), (2021, 'Indian Ocean', 12);
|
How many pollution incidents were recorded in the Indian Ocean in 2020 and 2021?
|
SELECT SUM(incidents) FROM OceanPollution WHERE location = 'Indian Ocean' AND year IN (2020, 2021);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE TeacherProfessionalDevelopment (id INT, name TEXT, subject TEXT, hours_trained INT); INSERT INTO TeacherProfessionalDevelopment (id, name, subject, hours_trained) VALUES (1, 'Pam', 'English', 15), (2, 'Sam', 'STEM', 30), (3, 'Terry', 'History', 22);
|
What is the maximum number of hours of professional development for teachers who specialize in STEM education in the 'TeacherProfessionalDevelopment' table?
|
SELECT MAX(hours_trained) FROM TeacherProfessionalDevelopment WHERE subject = 'STEM';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE farmers (id INT PRIMARY KEY, name VARCHAR(100), age INT, gender VARCHAR(10), location VARCHAR(50));
|
Alter the 'farmers' table by adding a column 'phone'
|
ALTER TABLE farmers ADD COLUMN phone VARCHAR(20);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE smart_cities.building_energy_consumption (city VARCHAR(50), consumption FLOAT); INSERT INTO smart_cities.building_energy_consumption (city, consumption) VALUES ('San Francisco', 1234.5), ('Seattle', 2345.6), ('New York', 3456.7), ('Los Angeles', 1500.0), ('Chicago', 2500.0);
|
What is the average energy consumption of buildings in the 'smart_cities' schema, grouped by city, and only for buildings with consumption > 2000?
|
SELECT city, AVG(consumption) FROM smart_cities.building_energy_consumption WHERE consumption > 2000 GROUP BY city;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Routes (RouteID int, RouteType varchar(10), StartingLocation varchar(20)); INSERT INTO Routes VALUES (1, 'Bus', 'City Center'), (2, 'Tram', 'City Center'); CREATE TABLE Fares (RouteID int, Fare float); INSERT INTO Fares VALUES (1, 2.5), (2, 3.0);
|
What is the average fare for buses and trams in the city center?
|
SELECT AVG(Fares.Fare) FROM Fares INNER JOIN Routes ON Fares.RouteID = Routes.RouteID WHERE Routes.StartingLocation = 'City Center' AND (Routes.RouteType = 'Bus' OR Routes.RouteType = 'Tram');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE anadarko_production (well text, date text, production real); INSERT INTO anadarko_production VALUES ('Well1', '2021-01-01', 1200), ('Well1', '2021-01-02', 1400), ('Well2', '2021-01-01', 2200), ('Well2', '2021-01-02', 1500);
|
List all the wells in the 'Anadarko' shale play that produced more than 1300 barrels in a day.
|
SELECT well FROM anadarko_production WHERE production > 1300;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE otas (ota_id INT, ota_name TEXT, region TEXT); CREATE TABLE bookings (booking_id INT, ota_id INT, hotel_id INT, bookings_count INT); INSERT INTO otas (ota_id, ota_name, region) VALUES (1, 'OTA 1', 'Middle East'), (2, 'OTA 2', 'Europe'), (3, 'OTA 3', 'Asia'); INSERT INTO bookings (booking_id, ota_id, hotel_id, bookings_count) VALUES (1, 1, 100, 500), (2, 2, 101, 300), (3, 3, 102, 700), (4, 1, 103, 800);
|
What is the total number of hotel bookings through online travel agencies in the Middle East?
|
SELECT SUM(bookings_count) FROM bookings JOIN otas ON bookings.ota_id = otas.ota_id WHERE region = 'Middle East';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE satellite_deployment (id INT, satellite_name VARCHAR(255), satellite_type VARCHAR(255), country VARCHAR(255), launch_date DATE);
|
Delete all records in the satellite_deployment table where satellite_type is not 'GEO'
|
DELETE FROM satellite_deployment WHERE satellite_type != 'GEO';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE transportation.vehicle_sales (month DATE, total_vehicle_sales INT, electric_vehicle_sales INT);
|
Create a view that shows the percentage of electric vehicle sales out of total vehicle sales per month
|
CREATE VIEW transportation.electric_vehicle_sales_percentage AS SELECT month, (electric_vehicle_sales * 100.0 / total_vehicle_sales) AS percentage FROM transportation.vehicle_sales;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE CommunityHealthWorkers (WorkerID INT, Age INT, Gender VARCHAR(255)); INSERT INTO CommunityHealthWorkers (WorkerID, Age, Gender) VALUES (1, 45, 'Female'), (2, 34, 'Male'), (3, 50, 'Non-binary'), (4, 40, 'Prefer not to say');
|
What is the average age of community health workers by their gender?
|
SELECT Gender, AVG(Age) as AvgAge FROM CommunityHealthWorkers GROUP BY Gender;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Accommodations (student_id INT, program_name VARCHAR(255), accommodation_type VARCHAR(255)); INSERT INTO Accommodations (student_id, program_name, accommodation_type) VALUES (1, 'Program A', 'Sign Language Interpreter'); INSERT INTO Accommodations (student_id, program_name, accommodation_type) VALUES (2, 'Program B', 'Assistive Technology');
|
What is the total number of students who received accommodations in each program?
|
SELECT program_name, COUNT(DISTINCT student_id) as total_students FROM Accommodations GROUP BY program_name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Cities (City_Name VARCHAR(50), Population INT, Country VARCHAR(50)); INSERT INTO Cities (City_Name, Population, Country) VALUES ('New York', 8500000, 'USA'); INSERT INTO Cities (City_Name, Population, Country) VALUES ('Los Angeles', 4000000, 'USA'); INSERT INTO Cities (City_Name, Population, Country) VALUES ('Tokyo', 9000000, 'Japan');
|
What is the average population of cities in Singapore and Japan?
|
SELECT AVG(Population) FROM Cities WHERE Country IN ('Singapore', 'Japan');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE penn_labor (trade TEXT, state TEXT, hours INT); INSERT INTO penn_labor (trade, state, hours) VALUES ('Carpentry', 'Pennsylvania', 8000), ('Electrical', 'Pennsylvania', 10000), ('Plumbing', 'Pennsylvania', 6000);
|
What is the difference in the total number of labor hours worked between the construction trades with the most and least labor hours worked in the state of Pennsylvania?
|
SELECT MAX(hours) - MIN(hours) FROM penn_labor WHERE state = 'Pennsylvania';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE meals (id INT, name VARCHAR(255), country VARCHAR(255), calories INT); INSERT INTO meals (id, name, country, calories) VALUES (1, 'Steak', 'USA', 800), (2, 'Poutine', 'Canada', 700), (3, 'Bangers and Mash', 'UK', 600);
|
Which countries have the highest and lowest calorie intake per meal?
|
SELECT country, AVG(calories) as avg_calories FROM meals GROUP BY country ORDER BY avg_calories DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Donors (DonorID int, DonorName text, Country text, City text); INSERT INTO Donors (DonorID, DonorName, Country, City) VALUES (1, 'John Doe', 'United States', 'New York'); INSERT INTO Donors (DonorID, DonorName, Country, City) VALUES (2, 'Jane Smith', 'Canada', 'Toronto'); INSERT INTO Donors (DonorID, DonorName, Country, City) VALUES (3, 'Mike Johnson', 'United States', 'Los Angeles');
|
How many donors are there from each city in the United States?
|
SELECT Country, City, COUNT(*) as NumberOfDonors FROM Donors GROUP BY Country, City;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE rovers(name TEXT, launch_date TEXT, max_speed REAL); INSERT INTO rovers(name, launch_date, max_speed) VALUES('Curiosity', '2011-11-26', 90);
|
What is the average speed of the Mars Rover Curiosity?
|
SELECT AVG(max_speed) FROM rovers WHERE name = 'Curiosity';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE crime_trend (id INT, crime VARCHAR(20), city VARCHAR(20), year INT, count INT); INSERT INTO crime_trend (id, crime, city, year, count) VALUES (1, 'Murder', 'Houston', 2016, 120), (2, 'Robbery', 'Houston', 2016, 350), (3, 'Assault', 'Houston', 2016, 600), (4, 'Murder', 'Houston', 2017, 130), (5, 'Robbery', 'Houston', 2017, 360), (6, 'Assault', 'Houston', 2017, 610), (7, 'Murder', 'Houston', 2018, 140), (8, 'Robbery', 'Houston', 2018, 370), (9, 'Assault', 'Houston', 2018, 620), (10, 'Murder', 'Houston', 2019, 150), (11, 'Robbery', 'Houston', 2019, 380), (12, 'Assault', 'Houston', 2019, 630);
|
What is the 5-year trend for crime in Houston?
|
SELECT year, (count - LAG(count, 1) OVER (ORDER BY year)) as trend FROM crime_trend WHERE city = 'Houston';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE state_info (state VARCHAR(20), population INT); INSERT INTO state_info (state, population) VALUES ('StateP', 5000000), ('StateQ', 3500000), ('StateR', 4500000), ('StateS', 7000000); CREATE TABLE state_budget (state VARCHAR(20), service VARCHAR(20), allocation INT); INSERT INTO state_budget (state, service, allocation) VALUES ('StateP', 'Education', 2000000), ('StateQ', 'Education', 1500000), ('StateR', 'Education', 1750000), ('StateS', 'Education', 2500000);
|
What is the average budget allocation for education services in states with a population between 3 and 6 million?
|
SELECT AVG(allocation) FROM state_budget sb JOIN state_info si ON sb.state = si.state WHERE sb.service = 'Education' AND si.population BETWEEN 3000000 AND 6000000;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE voyages (id INT, vessel_name VARCHAR(255), port VARCHAR(255), departure_date DATE); INSERT INTO voyages (id, vessel_name, port, departure_date) VALUES (1, 'VesselA', 'Kingston', '2022-01-18');
|
Which vessels visited the ports of the Caribbean Sea more than 3 times?
|
SELECT vessel_name FROM voyages WHERE port IN ('Kingston', 'Havana', 'Oranjestad', 'Willemstad', 'Philipsburg', 'Charlotte Amalie', 'San Juan') GROUP BY vessel_name HAVING COUNT(*) > 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ticket_sales (team_name VARCHAR(50), tickets_sold INT, revenue DECIMAL(10,2)); INSERT INTO ticket_sales (team_name, tickets_sold, revenue) VALUES ('Team A Stadium', 1000, 25000.00), ('Team B Arena', 800, 20000.00), ('Stadium City FC', 1200, 32000.00), ('Team D Field', 900, 21000.00);
|
What is the total number of tickets sold and the total revenue for teams that have 'Stadium' in their name?
|
SELECT SUM(tickets_sold) AS total_tickets_sold, SUM(revenue) AS total_revenue FROM ticket_sales WHERE team_name LIKE '%Stadium%';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE SupportPrograms (Id INT, Name VARCHAR(100), Description TEXT, DateAdded DATETIME); INSERT INTO SupportPrograms (Id, Name, Description, DateAdded) VALUES (1, 'Bridge Program', 'Assists students with disabilities transition to college', '2021-07-01 10:30:00');
|
Which support programs were added in Q3 2021?
|
SELECT * FROM SupportPrograms WHERE DateAdded BETWEEN '2021-07-01' AND '2021-09-30';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE climate_data (id INT PRIMARY KEY, temperature FLOAT, humidity FLOAT, pressure FLOAT, location VARCHAR(255), date DATE); INSERT INTO climate_data (id, temperature, humidity, pressure, location, date) VALUES (1, -15.3, 80.5, 1013.2, 'Svalbard', '2023-03-01'), (2, -12.1, 85.3, 1015.6, 'Svalbard', '2023-03-02'), (3, -10.8, 78.9, 1012.1, 'Greenland', '2023-03-01'), (4, -14.5, 82.7, 1016.8, 'Greenland', '2023-03-02');
|
What is the maximum pressure recorded at each location in the climate_data table?
|
SELECT c.location, MAX(c.pressure) AS max_pressure FROM climate_data c GROUP BY c.location;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE vehicle_sales (id INT PRIMARY KEY, vehicle_type VARCHAR(255), sales_quantity INT);
|
Create a table named 'vehicle_sales'
|
CREATE TABLE vehicle_sales (id INT PRIMARY KEY, vehicle_type VARCHAR(255), sales_quantity INT);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE education_programs (id INT, name VARCHAR(255), animal_id INT); INSERT INTO education_programs (id, name, animal_id) VALUES (1, 'Wildlife Wonders', 2), (2, 'Animal Buddies', 3), (3, 'Conservation Champions', 4); CREATE TABLE animals (id INT, name VARCHAR(20), species VARCHAR(20)); INSERT INTO animals (id, name, species) VALUES (2, 'Daisy', 'Elephant'), (3, 'Buck', 'Hippo'), (4, 'Sasha', 'Tiger');
|
List all the community education programs and their corresponding animal ambassadors
|
SELECT e.name as program_name, a.name as animal_name FROM education_programs e JOIN animals a ON e.animal_id = a.id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Researchers (id INT PRIMARY KEY, name VARCHAR(50), expertise VARCHAR(50), country VARCHAR(50)); INSERT INTO Researchers (id, name, expertise, country) VALUES (1, 'Karen', 'Climate Change', 'Greenland'), (2, 'Ole', 'Biodiversity', 'Denmark');
|
Which climate change researchers are from Greenland?
|
SELECT name, country FROM Researchers WHERE expertise = 'Climate Change' AND country = 'Greenland';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Trends (id INT, category VARCHAR(20), season VARCHAR(20), sales INT); INSERT INTO Trends (id, category, season, sales) VALUES (1, 'Tops', 'Spring', 500), (2, 'Bottoms', 'Summer', 600), (3, 'Dresses', 'Fall', 700), (4, 'Outerwear', 'Winter', 800), (5, 'Accessories', 'Spring', 400), (6, 'Tops', 'Summer', 650), (7, 'Bottoms', 'Fall', 750), (8, 'Outerwear', 'Winter', 900), (9, 'Accessories', 'Fall', 500);
|
What are the total sales for each category, with a separate column for each season's sales?
|
SELECT category, SUM(CASE WHEN season = 'Spring' THEN sales ELSE 0 END) AS spring_sales, SUM(CASE WHEN season = 'Summer' THEN sales ELSE 0 END) AS summer_sales, SUM(CASE WHEN season = 'Fall' THEN sales ELSE 0 END) AS fall_sales, SUM(CASE WHEN season = 'Winter' THEN sales ELSE 0 END) AS winter_sales FROM Trends GROUP BY category;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Ratings (id INT, movie_id INT, actor_id INT, rating DECIMAL(3,2)); INSERT INTO Ratings (id, movie_id, actor_id, rating) VALUES (1, 1, 1, 8.5), (2, 2, 2, 7.8), (3, 3, 3, 9.0), (4, 4, 1, 8.8); CREATE TABLE Actors (id INT, name VARCHAR(255)); INSERT INTO Actors (id, name) VALUES (1, 'Actor1'), (2, 'Actor2'), (3, 'Actor3');
|
Who are the top 2 actors with the most number of highly rated movies?
|
SELECT a.name, COUNT(*) FROM Actors a JOIN Ratings r ON a.id = r.actor_id GROUP BY a.id ORDER BY COUNT(*) DESC LIMIT 2;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE marine_species (id INT, name VARCHAR(255), type VARCHAR(255), population INT, depth FLOAT); INSERT INTO marine_species (id, name, type, population, depth) VALUES (1, 'Bottlenose Dolphin', 'Mammal', 600000, 50.0), (2, 'Humpback Whale', 'Mammal', 40000, 200.0), (3, 'Sperm Whale', 'Mammal', 80000, 3000.0), (4, 'Sea Otter', 'Mammal', 2500, 100.0);
|
Update the depth of all marine mammals in the Pacific Ocean by 5%.
|
UPDATE marine_species SET depth = depth * 1.05 WHERE type = 'Mammal' AND location = 'Pacific Ocean';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE shariah_compliant_finance (id INT, country VARCHAR(255), rate DECIMAL(4,2)); INSERT INTO shariah_compliant_finance (id, country, rate) VALUES (1, 'Saudi Arabia', 3.50), (2, 'UAE', 4.00), (3, 'Qatar', 3.75);
|
What is the maximum Shariah-compliant finance rate in the Middle East?
|
SELECT MAX(rate) FROM shariah_compliant_finance WHERE country IN ('Saudi Arabia', 'UAE', 'Qatar');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE military_vehicles(id INT, type VARCHAR(255), status VARCHAR(255), date DATE);
|
Show the number of military vehicles, by type, that were maintained in the past month and the percentage of total vehicles each type represents.
|
SELECT type, COUNT(*) as count, ROUND(100 * COUNT(*) / (SELECT COUNT(*) FROM military_vehicles WHERE date > DATE_SUB(NOW(), INTERVAL 1 MONTH)), 2) as percent FROM military_vehicles WHERE date > DATE_SUB(NOW(), INTERVAL 1 MONTH) GROUP BY type;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE garments (id INT PRIMARY KEY, name VARCHAR(255), category VARCHAR(255), rating INT); INSERT INTO garments (id, name, category, rating) VALUES (1, 'T-Shirt', 'Women', 4);
|
What is the average rating of garments in the 'Women' category?
|
SELECT AVG(rating) FROM garments WHERE category = 'Women';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE properties (property_id INT, energy_efficiency_rating VARCHAR(10), property_tax FLOAT);
|
What is the total property tax for properties with energy efficiency ratings of A or B?
|
SELECT SUM(property_tax) as total_property_tax FROM properties WHERE energy_efficiency_rating IN ('A', 'B');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Dishes (dish_id INT, dish_name VARCHAR(50)); CREATE TABLE Ingredients (ingredient_id INT, dish_id INT, cost DECIMAL(5,2)); INSERT INTO Dishes (dish_id, dish_name) VALUES (1, 'Quinoa Salad'), (2, 'Cheeseburger'), (3, 'Veggie Burger'); INSERT INTO Ingredients (ingredient_id, dish_id, cost) VALUES (1, 1, 1.50), (2, 1, 0.75), (3, 1, 2.00), (4, 2, 1.00), (5, 2, 2.50), (6, 3, 1.00), (7, 3, 1.50);
|
Which dish has the most expensive ingredient in the inventory?
|
SELECT D.dish_name, MAX(I.cost) as most_expensive_ingredient_cost FROM Dishes D JOIN Ingredients I ON D.dish_id = I.dish_id GROUP BY D.dish_name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE criminal_cases_tx (id INT, case_id INT, appearance_date DATE); INSERT INTO criminal_cases_tx (id, case_id, appearance_date) VALUES (1, 1001, '2019-01-01'), (2, 1001, '2019-02-01'), (3, 1002, '2019-03-01');
|
What is the minimum number of court appearances required for criminal cases in Texas in 2019?
|
SELECT MIN(id) FROM criminal_cases_tx WHERE case_id = 1001 AND appearance_date LIKE '2019%';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ElectricVehicles (id INT, country VARCHAR(50), year INT, sales INT); INSERT INTO ElectricVehicles (id, country, year, sales) VALUES (1, 'Germany', 2020, 385), (2, 'Germany', 2019, 320), (3, 'Germany', 2018, 210), (4, 'France', 2020, 410);
|
What is the total number of electric vehicles (in thousands) sold in Germany since 2018?
|
SELECT COUNT(*)/1000 FROM ElectricVehicles WHERE country = 'Germany' AND year >= 2018;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE waste_generation (city VARCHAR(20), year INT, material VARCHAR(20), weight FLOAT); INSERT INTO waste_generation (city, year, material, weight) VALUES ('Seattle', 2020, 'Plastic', 1200), ('Seattle', 2020, 'Paper', 2000), ('Seattle', 2020, 'Glass', 1500);
|
What is the total waste generation by material type in the city of Seattle in 2020?
|
SELECT material, SUM(weight) as total_weight FROM waste_generation WHERE city = 'Seattle' AND year = 2020 GROUP BY material;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE mining_operation (id INT, name VARCHAR(50), environmental_impact_score INT); INSERT INTO mining_operation (id, name, environmental_impact_score) VALUES (1, 'Operation A', 80); INSERT INTO mining_operation (id, name, environmental_impact_score) VALUES (2, 'Operation B', 60); INSERT INTO mining_operation (id, name, environmental_impact_score) VALUES (3, 'Operation C', 90);
|
What are the names of the mining operations with the highest environmental impact scores?
|
SELECT name FROM mining_operation ORDER BY environmental_impact_score DESC LIMIT 5;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE streams (song_id INT, genre VARCHAR(10), stream_count BIGINT);
|
List all jazz and blues songs that have been streamed more than 1 million times, sorted by stream count in descending order.
|
SELECT genre, song_id, stream_count FROM streams WHERE genre IN ('jazz', 'blues') AND stream_count > 1000000 ORDER BY stream_count DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE green_buildings (building_id INT, city VARCHAR(100), state VARCHAR(50)); INSERT INTO green_buildings (building_id, city, state) VALUES (1, 'New York', 'New York');
|
What is the number of green buildings in each city?
|
SELECT city, COUNT(*) as green_buildings_count FROM green_buildings GROUP BY city;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE events (id INT, team_id INT, event_date DATE, attendance INT); INSERT INTO events (id, team_id, event_date, attendance) VALUES (1, 1, '2021-09-01', 1000), (2, 1, '2021-10-01', 2000), (3, 2, '2021-11-01', 1500);
|
Delete the row with the lowest attendance from the events table
|
DELETE FROM events WHERE id = (SELECT id FROM (SELECT id, @row_number:= IF(@prev_value=attendance, @row_number, @row_number+1) AS row_number, @prev_value:=attendance FROM events, (SELECT @row_number:=0, @prev_value:=0) var_init WHERE @prev_value IS NULL OR @prev_value != attendance ORDER BY attendance, id LIMIT 1));
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE wind_projects (id INT PRIMARY KEY, project_name VARCHAR(255), location VARCHAR(255), capacity_mw FLOAT, completion_date DATE);
|
How many wind projects were completed before 2010?
|
SELECT COUNT(*) FROM wind_projects WHERE completion_date < '2010-01-01';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE renewable_energy_investment (project_name TEXT, country TEXT, investment INTEGER); INSERT INTO renewable_energy_investment (project_name, country, investment) VALUES ('Solar Farm 2', 'Germany', 1000000);
|
What is the total investment in renewable energy projects in the country of Germany?
|
SELECT SUM(investment) FROM renewable_energy_investment WHERE country = 'Germany';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE PolicyProjects (ProjectID INT, ProjectDate DATE); INSERT INTO PolicyProjects (ProjectID, ProjectDate) VALUES (1, '2021-02-01'), (2, '2021-03-15'), (3, '2021-04-05');
|
How many evidence-based policy making projects were submitted per month in the last year?
|
SELECT EXTRACT(MONTH FROM ProjectDate), EXTRACT(YEAR FROM ProjectDate), COUNT(*) FROM PolicyProjects WHERE ProjectDate >= '2021-01-01' GROUP BY EXTRACT(MONTH FROM ProjectDate), EXTRACT(YEAR FROM ProjectDate);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE hospitals (id INT, region VARCHAR(255), name VARCHAR(255)); INSERT INTO hospitals (id, region, name) VALUES (1, 'Northeast', 'Hospital A'), (2, 'West', 'Hospital B'), (3, 'South', 'Hospital C');
|
What is the number of hospitals in each region, ordered by the number of hospitals?
|
SELECT region, COUNT(*) as hospital_count FROM hospitals GROUP BY region ORDER BY hospital_count DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE MenuItems (item TEXT, category TEXT, price INT, cost INT); INSERT INTO MenuItems (item, category, price, cost) VALUES ('Sushi Roll', 'Appetizer', 8, 2), ('Pizza Margherita', 'Entree', 12, 5), ('Churros', 'Dessert', 6, 1);
|
Which menu items have the highest markup percentages?
|
SELECT item, category, ROUND(100.0 * (price - cost) / cost, 2) as markup_percentage FROM MenuItems ORDER BY markup_percentage DESC LIMIT 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE cities (city_id INT, name VARCHAR(255), green_policy BOOLEAN);CREATE TABLE properties (property_id INT, city_id INT, price INT); INSERT INTO cities (city_id, name, green_policy) VALUES (1, 'New York', true), (2, 'Los Angeles', false), (3, 'San Francisco', true); INSERT INTO properties (property_id, city_id, price) VALUES (1, 1, 500000), (2, 1, 600000), (3, 2, 800000), (4, 3, 900000);
|
What is the total number of properties and their summed price in each city with a green housing policy?
|
SELECT cities.name, COUNT(properties.property_id) as total_properties, SUM(properties.price) as total_price FROM properties JOIN cities ON properties.city_id = cities.city_id WHERE cities.green_policy = true GROUP BY cities.name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Justice (FarmerID INT, Country VARCHAR(20), Initiative VARCHAR(20)); INSERT INTO Justice (FarmerID, Country, Initiative) VALUES (1, 'Canada', 'Food Justice'), (2, 'USA', 'Food Justice'), (3, 'Mexico', 'Conventional Agriculture');
|
How many farmers are involved in food justice initiatives in Canada and the USA?
|
SELECT COUNT(*) FROM Justice WHERE Country IN ('Canada', 'USA') AND Initiative = 'Food Justice';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE employees (id INT PRIMARY KEY, first_name VARCHAR(50), last_name VARCHAR(50), job_title VARCHAR(50), salary INT); INSERT INTO employees (id, first_name, last_name, job_title, salary) VALUES (1, 'Alex', 'Smith', 'Engineer', 50000), (2, 'John', 'Doe', 'Manager', 70000);
|
Update the salary of the employee with id 1 in the "employees" table to 60000
|
UPDATE employees SET salary = 60000 WHERE id = 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE africa_cities (id INT, city VARCHAR(255), population INT); INSERT INTO africa_cities (id, city, population) VALUES (1, 'Cairo', 20500000);
|
List all cities in Africa with a population between 5,000,000 and 10,000,000, ordered by population size.
|
SELECT city, population FROM africa_cities WHERE population BETWEEN 5000000 AND 10000000 ORDER BY population DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE chemicals (id INT, name TEXT, production_volume INT); CREATE TABLE plant_chemicals (plant_id INT, chemical_id INT, production_volume INT); INSERT INTO chemicals (id, name, production_volume) VALUES (1, 'Chemical A', 500), (2, 'Chemical B', 300), (3, 'Chemical C', 700); INSERT INTO plant_chemicals (plant_id, chemical_id, production_volume) VALUES (1, 1, 200), (1, 2, 150), (1, 3, 300), (2, 1, 300), (2, 2, 150), (2, 3, 400);
|
What is the total production volume for each chemical by plant?
|
SELECT p.name AS plant_name, c.name AS chemical_name, SUM(pc.production_volume) FROM plant_chemicals pc INNER JOIN chemicals c ON pc.chemical_id = c.id INNER JOIN chemical_plants p ON pc.plant_id = p.id GROUP BY p.name, c.name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE poverty_alleviation (donor_id INT, donation_amount DECIMAL(10,2), donation_date DATE); INSERT INTO poverty_alleviation VALUES (1, 100000, '2020-01-01'), (2, 80000, '2020-02-01'), (3, 60000, '2020-03-01'), (4, 50000, '2020-04-01'), (5, 40000, '2020-05-01'), (6, 30000, '2020-06-01');
|
Display the top 5 donors who have made the largest total donations in the poverty alleviation sector.
|
SELECT donor_id, SUM(donation_amount) as total_donation FROM poverty_alleviation GROUP BY donor_id ORDER BY total_donation DESC LIMIT 5;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Donors (DonorID INT, DonorName TEXT, DonorRegion TEXT, DonationAmount FLOAT, DonationDate DATE); INSERT INTO Donors (DonorID, DonorName, DonorRegion, DonationAmount, DonationDate) VALUES (1, 'John Doe', 'North', 500.00, '2021-01-01'), (2, 'Jane Smith', 'South', 350.00, '2021-02-14'), (3, 'Bob Johnson', 'East', 1000.00, '2021-12-31');
|
What was the average donation amount per region, per month in 2021, and the total donation amount per region for the year?
|
SELECT DonorRegion, AVG(DonationAmount) as AvgDonationPerMonth, SUM(DonationAmount) as TotalDonationPerYear FROM Donors WHERE YEAR(DonationDate) = 2021 GROUP BY DonorRegion;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE users (id INT, country VARCHAR(255), category VARCHAR(255)); INSERT INTO users (id, country, category) VALUES (1, 'Brazil', 'sports'); CREATE TABLE posts (id INT, user_id INT, likes INT);
|
What is the maximum number of likes on posts by users from Brazil in the sports category?
|
SELECT MAX(posts.likes) FROM posts INNER JOIN users ON posts.user_id = users.id WHERE users.country = 'Brazil' AND users.category = 'sports';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE EventDates (EventID INT, EventDate DATE); INSERT INTO EventDates (EventID, EventDate) VALUES (1, '2022-01-01'), (2, '2022-02-01'), (3, '2022-01-15');
|
Find the number of players who joined esports events in each country, per month, and the number of unique virtual reality devices they use.
|
SELECT E.EventCountry, EXTRACT(MONTH FROM E.EventDate) AS Month, COUNT(DISTINCT P.PlayerID) AS PlayersJoined, COUNT(DISTINCT VR.VRDevice) AS VRDevices FROM Players P JOIN EventParticipation EP ON P.PlayerID = EP.PlayerID JOIN VRAdoption VR ON P.PlayerID = VR.PlayerID JOIN EventDates E ON EP.EventID = E.EventID GROUP BY E.EventCountry, EXTRACT(MONTH FROM E.EventDate)
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE organizations (id INT, sector VARCHAR(20), ESG_rating FLOAT); INSERT INTO organizations (id, sector, ESG_rating) VALUES (1, 'Healthcare', 7.5), (2, 'Technology', 8.2), (3, 'Healthcare', 8.0); CREATE TABLE investments (id INT, organization_id INT); INSERT INTO investments (id, organization_id) VALUES (1, 1), (2, 2), (3, 3);
|
What's the average ESG rating for organizations in the healthcare sector?
|
SELECT AVG(organizations.ESG_rating) FROM organizations JOIN investments ON organizations.id = investments.organization_id WHERE organizations.sector = 'Healthcare';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE investment (id INT, company_id INT, investment_round_size REAL, investment_round_date DATE); CREATE TABLE startup (id INT, name TEXT, founding_year INT, founder_gender TEXT);
|
Find the total investment raised by companies founded in 2015
|
SELECT SUM(investment_round_size) FROM investment JOIN startup ON investment.company_id = startup.id WHERE startup.founding_year = 2015;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE SecurityIncidents (IncidentID INT, Region VARCHAR(255), Year INT, IncidentCount INT); INSERT INTO SecurityIncidents (IncidentID, Region, Year, IncidentCount) VALUES (1, 'APAC', 2021, 45); INSERT INTO SecurityIncidents (IncidentID, Region, Year, IncidentCount) VALUES (2, 'EMEA', 2021, 35);
|
How many security incidents were reported in the Asia-Pacific region in 2021?
|
SELECT SUM(IncidentCount) FROM SecurityIncidents WHERE Region = 'APAC' AND Year = 2021;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE coral_reefs (id INTEGER, name TEXT, biomass FLOAT);
|
Find the total biomass of coral reefs in the 'Great Barrier Reef'?
|
SELECT SUM(biomass) FROM coral_reefs WHERE name = 'Great Barrier Reef';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE employee_data (employee_id INT, first_name VARCHAR(50), last_name VARCHAR(50), department_name VARCHAR(50), gender VARCHAR(10)); INSERT INTO employee_data (employee_id, first_name, last_name, department_name, gender) VALUES (1, 'Jane', 'Smith', 'Engineering', 'Female'), (2, 'John', 'Doe', 'Engineering', 'Male'), (3, 'Jessica', 'Johnson', 'Human Resources', 'Female'), (4, 'Michael', 'Brown', 'Human Resources', 'Male'), (5, 'David', 'Williams', 'Operations', 'Male'), (6, 'Sarah', 'Jones', 'Operations', 'Female');
|
How many employees in the workforce identify as male, by department?
|
SELECT department_name, COUNT(*) as male_employee_count FROM employee_data WHERE gender = 'Male' GROUP BY department_name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE marine_species (id INT, name VARCHAR(255), habitat VARCHAR(255)); INSERT INTO marine_species (id, name, habitat) VALUES (1, 'Dolphin', 'Mediterranean Sea'), (2, 'Tuna', 'Atlantic Ocean');
|
Which marine species have been observed in the Mediterranean Sea?
|
SELECT name FROM marine_species WHERE habitat = 'Mediterranean Sea';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE tennis_tournaments (player_name VARCHAR(50), tournament VARCHAR(50), appearances INT); INSERT INTO tennis_tournaments (player_name, tournament, appearances) VALUES ('Serena Williams', 'US Open', 23);
|
What are the total number of appearances made by Serena Williams in the US Open?
|
SELECT appearances FROM tennis_tournaments WHERE player_name = 'Serena Williams' AND tournament = 'US Open';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE patients (id INT, name TEXT, age INT, country TEXT); CREATE TABLE therapy_sessions (id INT, patient_id INT, session_date DATE); INSERT INTO patients (id, name, age, country) VALUES (1, 'Aamir Khan', 35, 'India'); INSERT INTO patients (id, name, age, country) VALUES (2, 'Fatima Ali', 28, 'Pakistan'); INSERT INTO patients (id, name, age, country) VALUES (3, 'Ravi Shankar', 42, 'India'); INSERT INTO therapy_sessions (id, patient_id) VALUES (1, 1); INSERT INTO therapy_sessions (id, patient_id) VALUES (2, 2); INSERT INTO therapy_sessions (id, patient_id) VALUES (3, 3);
|
What is the average age of patients who received therapy in India and Pakistan?
|
SELECT AVG(patients.age) FROM patients INNER JOIN therapy_sessions ON patients.id = therapy_sessions.patient_id WHERE patients.country IN ('India', 'Pakistan');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE carbon_offset_programs (id INT, program_name VARCHAR(255), organization_name VARCHAR(255), country VARCHAR(255), start_date DATE, end_date DATE, total_offset_tons INT, description TEXT);
|
Insert records for the new "carbon_offset_programs" table based on the following data: (1, "Clean Cities", "EPA", "USA", "2020-01-01", "2025-12-31", 1000000, "Reducing transportation emissions in urban areas."); (2, "Tropical Forest Conservation", "World Wildlife Fund", "Brazil", "2015-01-01", "2030-12-31", 5000000, "Protecting and restoring the Amazon rainforest.");
|
INSERT INTO carbon_offset_programs (id, program_name, organization_name, country, start_date, end_date, total_offset_tons, description) VALUES (1, 'Clean Cities', 'EPA', 'USA', '2020-01-01', '2025-12-31', 1000000, 'Reducing transportation emissions in urban areas.'), (2, 'Tropical Forest Conservation', 'World Wildlife Fund', 'Brazil', '2015-01-01', '2030-12-31', 5000000, 'Protecting and restoring the Amazon rainforest.');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE renewable_projects (project_id INT, project_name TEXT, location TEXT); INSERT INTO renewable_projects (project_id, project_name, location) VALUES (1, 'Solar Farm A', 'Rural Region Y'), (2, 'Wind Farm B', 'Rural Region X'), (3, 'Hydro Plant C', 'Rural Region Y');
|
Delete all renewable energy projects in 'Rural Region Y'
|
DELETE FROM renewable_projects WHERE location = 'Rural Region Y';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE fishing_regulations(region VARCHAR(255), vessel_limit INT);INSERT INTO fishing_regulations(region, vessel_limit) VALUES ('Mediterranean Sea', 12000), ('Black Sea', 5000);
|
What is the maximum number of fishing vessels allowed in the Mediterranean and Black Seas?
|
SELECT MAX(vessel_limit) FROM fishing_regulations WHERE region IN ('Mediterranean Sea', 'Black Sea');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Volunteers (volunteer_id INT, program_id INT, volunteer_hours INT, volunteer_date DATE); INSERT INTO Volunteers (volunteer_id, program_id, volunteer_hours, volunteer_date) VALUES (1, 1, 5, '2021-06-05'), (2, 2, 8, '2021-04-12'), (3, 1, 3, '2021-06-05'), (1, 3, 6, '2021-12-25');
|
How many hours did each volunteer contribute to programs in total?
|
SELECT volunteer_id, SUM(volunteer_hours) as total_hours_contributed FROM Volunteers GROUP BY volunteer_id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE individuals (ind_id INT, ind_name TEXT, program_id INT);CREATE TABLE programs (program_id INT, program_name TEXT);
|
How many individuals with disabilities are enrolled in each program?
|
SELECT p.program_name, COUNT(i.ind_id) AS enrolled_individuals FROM individuals i INNER JOIN programs p ON i.program_id = p.program_id GROUP BY p.program_name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Genre (id INT, genre VARCHAR(255)); CREATE TABLE Song (id INT, genre_id INT, title VARCHAR(255), playtime INT);
|
Calculate the average playtime for each genre of music
|
SELECT G.genre, AVG(S.playtime) as avg_playtime FROM Genre G INNER JOIN Song S ON G.id = S.genre_id GROUP BY G.genre;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE artworks (id INT, artist_id INT, title VARCHAR(50)); CREATE TABLE artists (id INT, name VARCHAR(50), country VARCHAR(20)); INSERT INTO artworks (id, artist_id, title) VALUES (1, 1, 'Artwork 1'), (2, 2, 'Artwork 2'), (3, 3, 'Artwork 3'); INSERT INTO artists (id, name, country) VALUES (1, 'Artist 1', 'USA'), (2, 'Artist 2', 'Canada'), (3, 'Artist 3', 'Mexico');
|
Delete all artworks by artists who are not from the United States or Canada.
|
DELETE FROM artworks WHERE artist_id NOT IN (SELECT id FROM artists WHERE country IN ('USA', 'Canada'));
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE threat_intelligence (intelligence_id INT, update_date DATE, threat_type TEXT, region_id INT, threat_level INT); INSERT INTO threat_intelligence (intelligence_id, update_date, threat_type, region_id, threat_level) VALUES (1, '2022-01-01', 'Cyber threat', 501, 3); INSERT INTO threat_intelligence (intelligence_id, update_date, threat_type, region_id, threat_level) VALUES (2, '2022-01-10', 'Physical threat', 502, 5);
|
What is the average time between threat intelligence data updates for each region?
|
SELECT region_id, AVG(DATEDIFF(day, LAG(update_date) OVER (PARTITION BY region_id ORDER BY update_date), update_date)) as average_days_between_updates FROM threat_intelligence GROUP BY region_id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Farmland (region VARCHAR(20), crop VARCHAR(20), area FLOAT);
|
Calculate the total area of farmland for each crop type in the 'South' region.
|
SELECT crop, SUM(area) FROM Farmland WHERE region = 'South' GROUP BY crop;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE sales (sale_id INT, product_id INT, price DECIMAL(10,2), quantity INT);CREATE TABLE circular_supply_chain (product_id INT, source VARCHAR(255), quantity INT);CREATE TABLE sustainable_products (product_id INT, category VARCHAR(255), price DECIMAL(10,2), recycled BOOLEAN);
|
What is the total revenue generated from sales in the 'sales' table for products in the 'sustainable_products' table that are sourced from recycled materials?
|
SELECT SUM(s.price * s.quantity) FROM sales s JOIN circular_supply_chain c ON s.product_id = c.product_id JOIN sustainable_products sp ON s.product_id = sp.product_id WHERE sp.recycled = TRUE;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE startup (id INT, name VARCHAR(100), industry VARCHAR(50), founder_disability VARCHAR(3), investment_round INT); INSERT INTO startup VALUES (1, 'StartupA', 'AI', 'Yes', 2); INSERT INTO startup VALUES (2, 'StartupB', 'Tech', 'No', 1); INSERT INTO startup VALUES (3, 'StartupC', 'AI', 'Yes', 3);
|
List the number of startups founded by individuals with disabilities in the AI sector that have had at least two investment rounds.
|
SELECT COUNT(*) FROM startup WHERE founder_disability = 'Yes' AND industry = 'AI' AND investment_round >= 2;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE PublicWorks (ProjectID INT, Name TEXT, Location TEXT, StartYear INT, Country TEXT); INSERT INTO PublicWorks (ProjectID, Name, Location, StartYear, Country) VALUES (1, 'Waterfront Revitalization', 'Toronto, Canada', 2010, 'Canada');
|
What is the total number of public works projects in the city of Toronto, Canada since 2010?
|
SELECT COUNT(PublicWorks.ProjectID) FROM PublicWorks WHERE PublicWorks.Location = 'Toronto, Canada' AND PublicWorks.StartYear >= 2010
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE tourists (tourist_id INT, name TEXT, country TEXT, visited_year INT, destination TEXT); INSERT INTO tourists (tourist_id, name, country, visited_year, destination) VALUES (1, 'John Doe', 'USA', 2019, 'Paris'), (2, 'Jane Smith', 'Brazil', 2019, 'Rome'); CREATE TABLE destinations (destination TEXT, popularity INT); INSERT INTO destinations (destination, popularity) VALUES ('Paris', 5), ('Rome', 4), ('Barcelona', 3), ('Amsterdam', 2), ('New York', 1);
|
How many tourists visited the top 5 most popular destinations in 2019?
|
SELECT COUNT(*) FROM tourists t JOIN destinations d ON t.destination = d.destination WHERE visited_year = 2019 AND d.popularity BETWEEN 1 AND 5;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE greenhouse_gas_emissions (id INT, transport_mode VARCHAR(255), country VARCHAR(255), total_emissions INT); INSERT INTO greenhouse_gas_emissions (id, transport_mode, country, total_emissions) VALUES (1, 'Road', 'Germany', 150000), (2, 'Rail', 'Germany', 50000), (3, 'Air', 'Germany', 200000), (4, 'Road', 'France', 200000), (5, 'Rail', 'France', 75000), (6, 'Air', 'France', 300000);
|
What are the total greenhouse gas emissions for each mode of transportation in the European Union?
|
SELECT transport_mode, country, SUM(total_emissions) FROM greenhouse_gas_emissions GROUP BY transport_mode, country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE shipments (shipment_id INT, package_id INT, country VARCHAR(20)); INSERT INTO shipments (shipment_id, package_id, country) VALUES (1, 1, 'USA'), (2, 1, 'Canada'), (3, 2, 'USA'), (4, 3, 'Mexico'), (5, 4, 'USA'), (6, 4, 'Canada'), (7, 5, 'USA'); CREATE TABLE packages (package_id INT, country VARCHAR(20)); INSERT INTO packages (package_id, country) VALUES (1, 'USA'), (2, 'USA'), (3, 'Mexico'), (4, 'USA'), (5, 'Canada');
|
How many packages were shipped to each country?
|
SELECT p.country, COUNT(s.package_id) FROM shipments s INNER JOIN packages p ON s.package_id = p.package_id GROUP BY p.country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE climate_mitigation_projects (id INT PRIMARY KEY, name VARCHAR(50), location VARCHAR(50), start_date DATE, end_date DATE, budget FLOAT); CREATE VIEW completed_projects AS SELECT * FROM climate_mitigation_projects WHERE end_date < CURDATE();
|
Show all records from 'completed_projects' view
|
SELECT * FROM completed_projects;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Archaeologists (ArchaeologistID INT, Archaeologist TEXT, Country TEXT, ArtifactCount INT); INSERT INTO Archaeologists (ArchaeologistID, Archaeologist, Country, ArtifactCount) VALUES (1, 'Zahi Hawass', 'Egypt', 100), (2, 'Howard Carter', 'UK', 75), (3, 'Hassan Fathy', 'Egypt', 50);
|
Who are the archaeologists that have discovered the most artifacts?
|
SELECT Archaeologist, ArtifactCount FROM Archaeologists ORDER BY ArtifactCount DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE building_permits (id INT, applicant TEXT, city TEXT, state TEXT); INSERT INTO building_permits (id, applicant, city, state) VALUES (1, 'ABC Construction', 'New York', 'New York'); INSERT INTO building_permits (id, applicant, city, state) VALUES (2, 'XYZ Construction', 'Los Angeles', 'California'); INSERT INTO building_permits (id, applicant, city, state) VALUES (3, '123 Construction', 'New York', 'New York');
|
Who has obtained the most building permits in New York?
|
SELECT applicant, COUNT(*) as permit_count FROM building_permits WHERE state = 'New York' GROUP BY applicant ORDER BY permit_count DESC LIMIT 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE smart_homes (id INT, name VARCHAR(255), energy_savings FLOAT);
|
Avg. energy savings for smart home installations
|
SELECT AVG(energy_savings) FROM smart_homes;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Dishes (DishID INT, DishName VARCHAR(50), Category VARCHAR(50), IngredientID INT, IngredientQTY INT, Price DECIMAL(5,2)); INSERT INTO Dishes (DishID, DishName, Category, IngredientID, IngredientQTY, Price) VALUES (1, 'Veggie Pizza', 'Pizza', 1, 500, 12.99), (2, 'Margherita Pizza', 'Pizza', 2, 300, 10.99), (3, 'Chicken Caesar Salad', 'Salad', 3, 250, 15.49), (4, 'Garden Salad', 'Salad', 4, 400, 11.99); CREATE TABLE Ingredients (IngredientID INT, IngredientType VARCHAR(50)); INSERT INTO Ingredients (IngredientID, IngredientType) VALUES (1, 'Vegetables'), (2, 'Cheese'), (3, 'Meat'), (4, 'Salad');
|
What is the total sales of dishes in each category, broken down by ingredient type?
|
SELECT Category, IngredientType, SUM(IngredientQTY * Price) as TotalSales FROM Dishes JOIN Ingredients ON Dishes.IngredientID = Ingredients.IngredientID GROUP BY Category, IngredientType;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE rd_expenditure (drug_id VARCHAR(10), approval_year INT, expenditure NUMERIC(12,2));
|
What is the maximum R&D expenditure for drugs approved between 2016 and 2019?
|
SELECT MAX(expenditure) FROM rd_expenditure WHERE approval_year BETWEEN 2016 AND 2019;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Mars_Missions (Mission_ID INT, Mission_Name VARCHAR(50), Country VARCHAR(50), Year INT, PRIMARY KEY (Mission_ID)); INSERT INTO Mars_Missions (Mission_ID, Mission_Name, Country, Year) VALUES (1, 'Phoenix', 'United States', 2007), (2, 'Curiosity', 'United States', 2012), (3, 'ExoMars Trace Gas Orbiter', 'Russia', 2016);
|
Which countries participated in Mars missions in the 2010s?
|
SELECT DISTINCT Country FROM Mars_Missions WHERE Year BETWEEN 2010 AND 2019;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE investments (fund_name VARCHAR(20), company_id INT, investment_amount FLOAT); CREATE TABLE companies (id INT, company_name VARCHAR(20), sector VARCHAR(20), ESG_rating FLOAT); INSERT INTO investments (fund_name, company_id, investment_amount) VALUES ('Impact Fund 1', 1, 50000,), ('Impact Fund 2', 2, 75000); INSERT INTO companies (id, company_name, sector, ESG_rating) VALUES (1, 'Tech Innovations', 'technology', 8.1), (2, 'Finance Group', 'finance', 6.5);
|
Find all investments made by 'Impact Fund 1' and their associated ESG ratings?
|
SELECT investments.fund_name, companies.company_name, companies.ESG_rating FROM investments INNER JOIN companies ON investments.company_id = companies.id WHERE investments.fund_name = 'Impact Fund 1';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE vegan_ingredients (product_id INT, ingredient_id INT, ingredient_name TEXT, is_vegan BOOLEAN, source_country TEXT); INSERT INTO vegan_ingredients VALUES (1, 1, 'IngredientX', true, 'Canada'), (2, 2, 'IngredientY', true, 'Kenya'), (3, 3, 'IngredientZ', false, 'US'), (4, 4, 'IngredientW', true, 'Nepal'), (5, 1, 'IngredientX', true, 'India');
|
What are the product IDs and their sourcing countries for vegan ingredients?
|
SELECT vegan_ingredients.product_id, vegan_ingredients.source_country FROM vegan_ingredients WHERE vegan_ingredients.is_vegan = true
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE posts (id INT, hashtags VARCHAR(255), comments INT); INSERT INTO posts (id, hashtags, comments) VALUES (1, '#mentalhealthawareness, #wellness', 10), (2, '#mentalhealthawareness', 20), (3, '#fitness, #wellness', 30), (4, '#gaming, #tech', 40), (5, '#mentalhealthawareness', 50), (6, '#fitness, #mentalhealthawareness', 60);
|
What is the total number of comments for posts with the hashtag #mentalhealthawareness?
|
SELECT SUM(posts.comments) AS total_comments FROM posts WHERE posts.hashtags LIKE '%#mentalhealthawareness%';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE articles (id INT, title VARCHAR(50), publish_date DATE); INSERT INTO articles (id, title, publish_date) VALUES (1, 'Article1', '2022-01-01'), (2, 'Article2', '2022-02-01');
|
How many articles were published per month in 2022?
|
SELECT MONTH(publish_date) as month, COUNT(*) as articles_count FROM articles WHERE YEAR(publish_date) = 2022 GROUP BY month;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Events (id INT, state VARCHAR(2), city VARCHAR(20), attendees INT, event_date DATE); INSERT INTO Events (id, state, city, attendees, event_date) VALUES (1, 'NY', 'New York', 500, '2022-01-01'), (2, 'IL', 'Chicago', 300, '2022-02-01'), (3, 'NY', 'Buffalo', 400, '2022-03-01'); CREATE TABLE Audience (id INT, state VARCHAR(2), zip INT, age INT); INSERT INTO Audience (id, state, zip, age) VALUES (1, 'NY', 10000, 30), (2, 'IL', 60000, 40), (3, 'NY', 11000, 35); CREATE TABLE Zipcodes (zip INT, city VARCHAR(20), urban VARCHAR(5)); INSERT INTO Zipcodes (zip, city, urban) VALUES (10000, 'New York', 'yes'), (60000, 'Chicago', 'yes'), (11000, 'Buffalo', 'yes');
|
What is the average age of audience members who attended events in urban areas in New York and Illinois?
|
SELECT AVG(Audience.age) FROM Events INNER JOIN Audience ON Events.state = Audience.state INNER JOIN Zipcodes ON Audience.zip = Zipcodes.zip WHERE urban = 'yes' AND Events.state IN ('NY', 'IL');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE team_salaries (team VARCHAR(50), total_salary DECIMAL(10,2));
|
Show the top 5 teams with the highest total salaries for their athletes
|
INSERT INTO team_salaries (team, total_salary) SELECT t.team, SUM(base_salary + bonus) FROM athlete_salaries AS asal JOIN team_roster tr ON asal.athlete_id = tr.athlete_id JOIN team_data t ON tr.team_id = t.team_id GROUP BY t.team ORDER BY total_salary DESC LIMIT 5;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE accounts (account_id INT, account_type VARCHAR(50), open_date DATE); INSERT INTO accounts (account_id, account_type, open_date) VALUES (1, 'Checking', '2022-01-01'), (2, 'Savings', '2022-02-01'), (3, 'Brokerage', '2022-03-01'), (4, 'Checking', '2022-04-01');
|
Determine the number of new accounts opened in the last week.
|
SELECT COUNT(*) FROM accounts WHERE open_date >= DATE_SUB(NOW(), INTERVAL 1 WEEK);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE landfill_capacity (id INT, name VARCHAR(50), year INT, capacity INT); INSERT INTO landfill_capacity (id, name, year, capacity) VALUES (1, 'Landfill A', 2018, 5000000), (2, 'Landfill A', 2019, 5200000), (3, 'Landfill A', 2020, 5500000), (4, 'Landfill B', 2018, 4000000), (5, 'Landfill B', 2019, 4200000), (6, 'Landfill B', 2020, 4500000);
|
What is the capacity of the largest landfill in 2020?
|
SELECT MAX(capacity) FROM landfill_capacity WHERE year = 2020;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE marine_species (species_name TEXT, population INTEGER, ocean TEXT);
|
How many marine species are present in each ocean basin, and what is their total population?
|
SELECT ocean, COUNT(DISTINCT species_name) AS species_count, SUM(population) AS total_population FROM marine_species GROUP BY ocean;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Policies (PolicyID INT, PolicyholderID INT, Provider VARCHAR(50), StartDate DATE, EndDate DATE); INSERT INTO Policies (PolicyID, PolicyholderID, Provider, StartDate, EndDate) VALUES (1, 1, 'ABC Insurance', '2021-01-01', '2021-12-31'); INSERT INTO Policies (PolicyID, PolicyholderID, Provider, StartDate, EndDate) VALUES (2, 1, 'XYZ Insurance', '2022-01-01', '2022-12-31'); INSERT INTO Policies (PolicyID, PolicyholderID, Provider, StartDate, EndDate) VALUES (3, 2, 'DEF Insurance', '2021-05-01', '2021-11-30'); INSERT INTO Policies (PolicyID, PolicyholderID, Provider, StartDate, EndDate) VALUES (4, 2, 'GHI Insurance', '2022-01-01', '2022-12-31'); CREATE TABLE Policyholders (PolicyholderID INT, PolicyholderName VARCHAR(50), State VARCHAR(2)); INSERT INTO Policyholders (PolicyholderID, PolicyholderName, State) VALUES (1, 'John Doe', 'Michigan'); INSERT INTO Policyholders (PolicyholderID, PolicyholderName, State) VALUES (2, 'Jane Smith', 'Michigan');
|
Find policyholders in Michigan who have switched insurance providers in the last 6 months.
|
SELECT PolicyholderName FROM Policies JOIN Policyholders ON Policies.PolicyholderID = Policyholders.PolicyholderID WHERE Policyholders.State = 'Michigan' AND EndDate >= DATEADD(month, -6, CURRENT_DATE);
|
gretelai_synthetic_text_to_sql
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.