context stringlengths 11 9.12k | question stringlengths 0 1.06k | SQL stringlengths 2 4.44k | source stringclasses 28 values |
|---|---|---|---|
CREATE TABLE foundations (id INT PRIMARY KEY, name VARCHAR(255), focus_area VARCHAR(255)); INSERT INTO foundations (id, name, focus_area) VALUES (1, 'Health Foundation', 'Health'); INSERT INTO foundations (id, name, focus_area) VALUES (2, 'Sustainable Development Foundation', 'Sustainable Development'); | Which foundations have granted more than $20,000 to organizations in the Health focus area? | SELECT f.name as foundation_name, g.grant_amount FROM grants g JOIN foundations f ON g.foundation_id = f.id WHERE f.focus_area = 'Health' AND g.grant_amount > 20000.00; | gretelai_synthetic_text_to_sql |
CREATE TABLE songs (song_id INT, title TEXT, length FLOAT, genre TEXT); | What is the average length of the top 3 longest songs per genre? | SELECT AVG(length) FROM (SELECT genre, length FROM songs WHERE row_number() OVER (PARTITION BY genre ORDER BY length DESC) <= 3) subquery; | gretelai_synthetic_text_to_sql |
CREATE TABLE albums (album_id INT, album_name VARCHAR(100), release_year INT, artist_id INT, country VARCHAR(50)); CREATE TABLE artists (artist_id INT, artist_name VARCHAR(100), country VARCHAR(50)); INSERT INTO albums (album_id, album_name, release_year, artist_id, country) VALUES (1, 'AlbumA', 2010, 1, 'USA'), (2, 'AlbumB', 2011, 2, 'Canada'), (3, 'AlbumC', 2010, 3, 'Mexico'), (4, 'AlbumD', 2012, 1, 'USA'), (5, 'AlbumE', 2011, 3, 'Mexico'); INSERT INTO artists (artist_id, artist_name, country) VALUES (1, 'Artist1', 'USA'), (2, 'Artist2', 'Canada'), (3, 'Artist3', 'Mexico'); | How many albums were released in each country? | SELECT country, COUNT(*) FROM albums GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE shared_mobility (id INT, city TEXT, vehicle_type TEXT, fuel_type TEXT, total_vehicles INT); INSERT INTO shared_mobility (id, city, vehicle_type, fuel_type, total_vehicles) VALUES (1, 'Toronto', 'Scooter', 'Electric', 300), (2, 'Vancouver', 'Bike', 'Manual', 200), (3, 'Toronto', 'Scooter', 'Electric', 400); | How many shared electric scooters were deployed in 'Toronto' and 'Vancouver' in the shared_mobility table? | SELECT city, fuel_type, SUM(total_vehicles) as total_shared_electric_scooters FROM shared_mobility WHERE city IN ('Toronto', 'Vancouver') AND vehicle_type = 'Scooter' AND fuel_type = 'Electric' GROUP BY city; | gretelai_synthetic_text_to_sql |
CREATE TABLE Players (PlayerID INT, Age INT, Gender VARCHAR(10), Country VARCHAR(50)); INSERT INTO Players (PlayerID, Age, Gender, Country) VALUES (1, 25, 'Male', 'USA'); INSERT INTO Players (PlayerID, Age, Gender, Country) VALUES (2, 30, 'Female', 'Canada'); CREATE TABLE EsportsEvents (EventID INT, PlayerID INT); INSERT INTO EsportsEvents (EventID, PlayerID) VALUES (1, 1); INSERT INTO EsportsEvents (EventID, PlayerID) VALUES (2, 2); | How many players from each country played in esports events? | SELECT Players.Country, COUNT(Players.PlayerID) FROM Players INNER JOIN EsportsEvents ON Players.PlayerID = EsportsEvents.PlayerID GROUP BY Players.Country; | gretelai_synthetic_text_to_sql |
CREATE TABLE volunteer_programs (id INT, program_name VARCHAR(50), region VARCHAR(20), volunteers_participated INT); INSERT INTO volunteer_programs (id, program_name, region, volunteers_participated) VALUES (1, 'Education for All', 'Latin America', 200), (2, 'Clean Water Access', 'Asia', 150), (3, 'Women Empowerment', 'Africa', 180), (4, 'Sustainable Agriculture', 'Latin America', 250); | How many volunteers participated in community development programs in Latin America? | SELECT SUM(volunteers_participated) FROM volunteer_programs WHERE region = 'Latin America'; | gretelai_synthetic_text_to_sql |
CREATE TABLE hospitals_au (id INT, name TEXT, cancer_treatment BOOLEAN); INSERT INTO hospitals_au VALUES (1, 'Rural Hospital A', TRUE); INSERT INTO hospitals_au VALUES (2, 'Rural Hospital B', FALSE); CREATE TABLE clinics_au (id INT, name TEXT, cancer_treatment BOOLEAN); INSERT INTO clinics_au VALUES (1, 'Rural Clinic A', TRUE); INSERT INTO clinics_au VALUES (2, 'Rural Clinic B', TRUE); CREATE TABLE hospitals_in (id INT, name TEXT, cancer_treatment BOOLEAN); INSERT INTO hospitals_in VALUES (1, 'Rural Hospital A', TRUE); INSERT INTO hospitals_in VALUES (2, 'Rural Hospital B', FALSE); CREATE TABLE clinics_in (id INT, name TEXT, cancer_treatment BOOLEAN); INSERT INTO clinics_in VALUES (1, 'Rural Clinic A', TRUE); INSERT INTO clinics_in VALUES (2, 'Rural Clinic B', FALSE); | Find the number of rural hospitals and clinics that offer cancer treatment in Australia and India. | SELECT COUNT(*) FROM hospitals_au WHERE cancer_treatment = TRUE UNION SELECT COUNT(*) FROM clinics_au WHERE cancer_treatment = TRUE UNION SELECT COUNT(*) FROM hospitals_in WHERE cancer_treatment = TRUE UNION SELECT COUNT(*) FROM clinics_in WHERE cancer_treatment = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE case_filings (case_id INT, filing_date DATE, court_location VARCHAR(50)); INSERT INTO case_filings (case_id, filing_date, court_location) VALUES (1, '2020-01-01', 'Southern District of New York'), (2, '2019-02-01', 'Central District of California'), (3, '2018-03-01', 'Eastern District of Virginia'); | What is the total number of cases filed in each court location in the US in the last 10 years? | SELECT court_location, COUNT(*) FILTER (WHERE filing_date >= NOW() - INTERVAL '10 years') AS total_cases FROM case_filings GROUP BY court_location; | gretelai_synthetic_text_to_sql |
CREATE TABLE carbon_offset.offset_initiatives (country VARCHAR(20), co2_reduction_tons INT); | What is the maximum CO2 emission reduction (in metric tons) achieved by carbon offset initiatives in the 'carbon_offset' schema, per country? | SELECT country, MAX(co2_reduction_tons) FROM carbon_offset.offset_initiatives GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE contract_negotiations(id INT, contract_name VARCHAR(50), region VARCHAR(20), negotiation_duration INT); | What is the average negotiation duration for contracts in the Middle East? | SELECT AVG(negotiation_duration) FROM contract_negotiations WHERE region = 'Middle East'; | gretelai_synthetic_text_to_sql |
CREATE TABLE crops (id INT, name VARCHAR(255), yield_per_hectare DECIMAL(5,2), country VARCHAR(255)); INSERT INTO crops (id, name, yield_per_hectare, country) VALUES (1, 'Corn', 5.00, 'Mexico'); | What is the average yield per hectare for corn in Mexico? | SELECT AVG(yield_per_hectare) FROM crops WHERE name = 'Corn' AND country = 'Mexico'; | gretelai_synthetic_text_to_sql |
CREATE TABLE hospitals (id INT, name TEXT, heart_disease_treatment BOOLEAN); INSERT INTO hospitals VALUES (1, 'Rural Hospital A', TRUE); INSERT INTO hospitals VALUES (2, 'Rural Hospital B', TRUE); CREATE TABLE clinics (id INT, name TEXT, heart_disease_treatment BOOLEAN); INSERT INTO clinics VALUES (1, 'Rural Clinic A', TRUE); INSERT INTO clinics VALUES (2, 'Rural Clinic B', FALSE); | Find the number of rural hospitals and clinics that offer heart disease treatment. | SELECT COUNT(*) FROM hospitals WHERE heart_disease_treatment = TRUE UNION SELECT COUNT(*) FROM clinics WHERE heart_disease_treatment = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE personal_injury_cases (case_id INT, case_open_date DATE); | Count the number of personal injury cases opened in January 2020. | SELECT COUNT(*) FROM personal_injury_cases WHERE case_open_date BETWEEN '2020-01-01' AND '2020-01-31'; | gretelai_synthetic_text_to_sql |
CREATE TABLE country_missions (id INT, country VARCHAR(50), launch_date DATE, mission_name VARCHAR(50)); | List the number of space missions launched by each country in the last 5 years? | SELECT country, COUNT(*) AS num_missions, RANK() OVER (ORDER BY COUNT(*) DESC) AS country_rank FROM country_missions WHERE launch_date BETWEEN (CURRENT_DATE - INTERVAL 5 YEAR) AND CURRENT_DATE GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE water_usage ( date DATE, usage_category VARCHAR(20), region VARCHAR(20), usage_amount INT ); INSERT INTO water_usage (date, usage_category, region, usage_amount) VALUES ( '2022-07-01', 'Residential', 'Northeast', 15000), ('2022-07-02', 'Industrial', 'Midwest', 200000), ('2022-07-03', 'Agricultural', 'West', 800000); | Insert a new record in the water_usage table with the following values: '2022-08-01', 'Residential', 'West', 12000 | INSERT INTO water_usage (date, usage_category, region, usage_amount) VALUES ('2022-08-01', 'Residential', 'West', 12000); | gretelai_synthetic_text_to_sql |
CREATE TABLE hotel_ratings (hotel_id INT, hotel_name TEXT, guest_rating FLOAT); | Show the names and ratings of the top 3 hotels | SELECT hotel_name, guest_rating FROM hotel_ratings ORDER BY guest_rating DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE cybersecurity_vulnerabilities_healthcare (id INT, sector TEXT, vulnerability TEXT, discovery_date DATE); INSERT INTO cybersecurity_vulnerabilities_healthcare (id, sector, vulnerability, discovery_date) VALUES (1, 'Healthcare', 'Phishing', '2021-09-01'), (2, 'Finance', 'SQL Injection', '2021-02-15'); | Identify the cybersecurity vulnerabilities in the healthcare sector that were discovered in the last 3 months. | SELECT c.sector, c.vulnerability FROM cybersecurity_vulnerabilities_healthcare c WHERE c.discovery_date >= DATE_SUB(CURRENT_DATE, INTERVAL 3 MONTH) AND c.sector = 'Healthcare'; | gretelai_synthetic_text_to_sql |
CREATE TABLE cybersecurity_incidents(id INT, category VARCHAR(255), date DATE); | What is the total number of cybersecurity incidents, by category, for the defense industry, in the last year? | SELECT category, COUNT(*) as count FROM cybersecurity_incidents WHERE date > DATE_SUB(NOW(), INTERVAL 1 YEAR) GROUP BY category; | gretelai_synthetic_text_to_sql |
CREATE TABLE climate_finance (project_id INT, project_name VARCHAR(255), location VARCHAR(255), start_date DATE, end_date DATE, total_cost DECIMAL(10,2)); | What is the average cost of all climate finance projects in 'Asia'? | SELECT AVG(total_cost) FROM climate_finance WHERE location = 'Asia'; | gretelai_synthetic_text_to_sql |
CREATE TABLE ports (id INT, name TEXT); INSERT INTO ports (id, name) VALUES (1, 'Port of Oakland'); CREATE TABLE vessel_arrivals (id INT, port_id INT, arrival_date DATE); INSERT INTO vessel_arrivals (id, port_id, arrival_date) VALUES (1, 1, '2022-01-01'), (2, 1, '2022-01-05'); | What are the names of vessels that arrived in the Port of Oakland in the last week? | SELECT v.vessel_name FROM vessels v JOIN vessel_arrivals va ON v.id = va.vessel_id WHERE va.arrival_date BETWEEN DATEADD(day, -7, CURRENT_DATE) AND CURRENT_DATE AND va.port_id = (SELECT id FROM ports WHERE name = 'Port of Oakland'); | gretelai_synthetic_text_to_sql |
CREATE TABLE Accidents (AccidentID INT, CompanyID INT, AccidentDate DATE); INSERT INTO Accidents (AccidentID, CompanyID, AccidentDate) VALUES (1, 1, '2021-01-01'), (2, 2, '2020-12-15'), (3, 3, '2019-05-23'), (4, 4, '2018-09-04'), (5, 1, '2017-02-10'); | How many mining accidents were reported in Africa in the last 3 years? | SELECT COUNT(*) FROM Accidents WHERE YEAR(AccidentDate) >= YEAR(CURRENT_DATE) - 3 AND Country IN ('Algeria', 'South Africa', 'Ghana'); | gretelai_synthetic_text_to_sql |
CREATE TABLE districts (id INT PRIMARY KEY, name TEXT, city TEXT); INSERT INTO districts (id, name, city) VALUES (1, 'Downtown', 'Chicago'), (2, 'West Side', 'Chicago'), (3, 'South Side', 'Chicago'); CREATE TABLE crimes (id INT PRIMARY KEY, district_id INT, crime_type TEXT, committed INT); INSERT INTO crimes (id, district_id, crime_type, committed) VALUES (1, 1, 'Murder', 10), (2, 1, 'Robbery', 20), (3, 2, 'Murder', 15), (4, 2, 'Robbery', 25), (5, 3, 'Murder', 20), (6, 3, 'Robbery', 30); | What is the total number of crimes committed in each district in the city of Chicago, grouped by district and ordered by total number of crimes in descending order? | SELECT d.name, SUM(c.committed) FROM districts d JOIN crimes c ON d.id = c.district_id WHERE d.city = 'Chicago' GROUP BY d.name ORDER BY SUM(c.committed) DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE departments (id INT, name VARCHAR(255)); INSERT INTO departments (id, name) VALUES (1, 'Human Resources'), (2, 'Public Works'), (3, 'Education'); CREATE TABLE budgets (id INT, department_id INT, year INT, amount INT); INSERT INTO budgets (id, department_id, year, amount) VALUES (1, 1, 2022, 90000), (2, 2, 2022, 180000), (3, 3, 2022, 270000), (4, 1, 2023, 110000), (5, 2, 2023, 220000), (6, 3, 2023, 330000); | Show the total budget for each department in the 2022 fiscal year | SELECT d.name, SUM(b.amount) as total_budget FROM departments d JOIN budgets b ON d.id = b.department_id WHERE b.year = 2022 GROUP BY d.id; | gretelai_synthetic_text_to_sql |
CREATE TABLE consumers (consumer_id INT, is_vegan BOOLEAN); INSERT INTO consumers (consumer_id, is_vegan) VALUES (1, true), (2, false), (3, true), (4, false); CREATE TABLE preferences (preference_id INT, consumer_id INT, product_id INT); INSERT INTO preferences (preference_id, consumer_id, product_id) VALUES (1, 1, 1), (2, 2, 2), (3, 3, 3), (4, 4, 1); CREATE TABLE products (product_id INT, is_vegan BOOLEAN); INSERT INTO products (product_id, is_vegan) VALUES (1, true), (2, false), (3, true); | What percentage of consumer preferences are for vegan cosmetics? | SELECT (COUNT(DISTINCT preferences.consumer_id) * 100.0 / (SELECT COUNT(DISTINCT consumers.consumer_id) FROM consumers)) AS percentage FROM preferences INNER JOIN consumers ON preferences.consumer_id = consumers.consumer_id INNER JOIN products ON preferences.product_id = products.product_id WHERE products.is_vegan = true; | gretelai_synthetic_text_to_sql |
CREATE TABLE RuralRoads(RoadID INT, RoadName VARCHAR(50), RoadLength INT, RoadCondition VARCHAR(10)); INSERT INTO RuralRoads(RoadID, RoadName, RoadLength, RoadCondition) VALUES (1, 'Main Road', 7, 'Fair'), (2, 'Branch Road', 3, 'Poor'), (3, 'Access Road', 6, 'Good'); | Update the 'RuralRoads' table, setting 'RoadCondition' to 'Good' for all records with a 'RoadLength' greater than 5 | UPDATE RuralRoads SET RoadCondition = 'Good' WHERE RoadLength > 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE policies (id INT, issue_date DATE); INSERT INTO policies (id, issue_date) VALUES (1, '2020-01-15'), (2, '2019-12-31'), (3, '2020-06-01'); | How many policies were issued in New York between 2020-01-01 and 2020-12-31? | SELECT COUNT(*) FROM policies WHERE issue_date BETWEEN '2020-01-01' AND '2020-12-31'; | gretelai_synthetic_text_to_sql |
CREATE TABLE VisitorDemographicsAfrica (visitor_id INT, country VARCHAR(50), num_visits INT); INSERT INTO VisitorDemographicsAfrica (visitor_id, country, num_visits) VALUES (1001, 'Egypt', 2), (1002, 'South Africa', 5), (1003, 'Nigeria', 3), (1004, 'Morocco', 4); | What is the total number of visitors from African countries? | SELECT SUM(num_visits) FROM VisitorDemographicsAfrica WHERE country IN ('Egypt', 'South Africa', 'Nigeria', 'Morocco', 'Algeria'); | gretelai_synthetic_text_to_sql |
CREATE TABLE material_costs (material_id INT, state VARCHAR(2), material_type VARCHAR(20), cost DECIMAL(5,2)); INSERT INTO material_costs (material_id, state, material_type, cost) VALUES (1, 'IL', 'Concrete', 1000.00), (2, 'IL', 'Steel', 2000.50), (3, 'IL', 'Concrete', 1200.00); | What is the total cost of sustainable construction materials used in Illinois, grouped by material type? | SELECT material_type, SUM(cost) FROM material_costs WHERE state = 'IL' GROUP BY material_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE COMMUNITY_ENGAGEMENT (id INT PRIMARY KEY, name VARCHAR(255), region VARCHAR(255), type VARCHAR(255)); INSERT INTO COMMUNITY_ENGAGEMENT (id, name, region, type) VALUES (1, 'Italian Heritage Festival', 'Europe', 'Cultural'), (2, 'Polish Language Exchange', 'Europe', 'Educational'); | What community engagement programs exist in Europe and their types? | SELECT name, type FROM COMMUNITY_ENGAGEMENT WHERE region = 'Europe'; | gretelai_synthetic_text_to_sql |
CREATE TABLE MobileSubscribers (SubscriberID int, Region varchar(10)); CREATE TABLE BroadbandSubscribers (SubscriberID int, Region varchar(10)); INSERT INTO MobileSubscribers (SubscriberID, Region) VALUES (1, 'North'), (2, 'North'), (3, 'South'); INSERT INTO BroadbandSubscribers (SubscriberID, Region) VALUES (1, 'East'), (2, 'East'), (3, 'West'); | Identify the number of mobile and broadband subscribers per region, and their respective percentage contributions to total subscribers. | SELECT M.Region, COUNT(M.SubscriberID) AS MobileCount, COUNT(B.SubscriberID) AS BroadbandCount, (COUNT(M.SubscriberID)::float / (COUNT(M.SubscriberID) + COUNT(B.SubscriberID))) * 100 AS MobilePercent, (COUNT(B.SubscriberID)::float / (COUNT(M.SubscriberID) + COUNT(B.SubscriberID))) * 100 AS BroadbandPercent FROM MobileSubscribers M FULL OUTER JOIN BroadbandSubscribers B ON M.Region = B.Region GROUP BY M.Region, B.Region; | gretelai_synthetic_text_to_sql |
CREATE TABLE drug_revenues (drug_name VARCHAR(100), revenue FLOAT, year INT); INSERT INTO drug_revenues (drug_name, revenue, year) VALUES ('DrugA', 1500000, 2022), ('DrugB', 2000000, 2022), ('DrugC', 1200000, 2022), ('DrugD', 2200000, 2022); | What was the minimum revenue in 2022 across all drugs? | SELECT MIN(revenue) FROM drug_revenues WHERE year = 2022; | gretelai_synthetic_text_to_sql |
CREATE TABLE products (product_id VARCHAR(10), expiration_date DATE); INSERT INTO products (product_id, expiration_date) VALUES ('P001', '2022-06-01'), ('P002', '2022-07-01'), ('P003', '2022-08-01'), ('P004', '2022-09-01'), ('P005', '2022-10-01'), ('P006', '2022-11-01'); | Update the expiration date for product 'P006' to 2023-05-01. | UPDATE products SET expiration_date = '2023-05-01' WHERE product_id = 'P006'; | gretelai_synthetic_text_to_sql |
CREATE TABLE agricultural_innovation (country VARCHAR(50), project_name VARCHAR(50), project_start_date DATE, budget DECIMAL(10,2)); | Calculate the total budget for agricultural innovation projects in each country and compare the results, excluding projects that were started after 2018. | SELECT country, SUM(budget) as total_budget FROM agricultural_innovation WHERE project_start_date < '2019-01-01' GROUP BY country ORDER BY total_budget DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE state_budget (state VARCHAR(20), service VARCHAR(20), allocation INT); INSERT INTO state_budget (state, service, allocation) VALUES ('StateT', 'Transportation', 2000000), ('StateT', 'Education', 1500000), ('StateU', 'Transportation', 1800000), ('StateU', 'Education', 2200000), ('StateV', 'Transportation', 2500000), ('StateV', 'Education', 1700000); | Identify the states that have a higher budget allocation for transportation services than for education services. | SELECT state FROM state_budget WHERE service = 'Transportation' AND allocation > (SELECT allocation FROM state_budget sb WHERE sb.state = state_budget.state AND sb.service = 'Education') GROUP BY state; | gretelai_synthetic_text_to_sql |
CREATE TABLE MentalHealthProviders (ProviderID INT, Age INT, Gender VARCHAR(10), CulturalCompetencyTraining DATE, CommunityHealthWorker VARCHAR(5), LGBTQCompetency VARCHAR(5)); CREATE TABLE PatientHealthIssues (PatientID INT, Age INT, HealthIssue VARCHAR(20), ProviderID INT, DateSeen DATE); INSERT INTO MentalHealthProviders (ProviderID, Age, Gender, CulturalCompetencyTraining, CommunityHealthWorker, LGBTQCompetency) VALUES (1, 50, 'Male', '2022-01-01', 'No', 'Yes'); INSERT INTO PatientHealthIssues (PatientID, Age, HealthIssue, ProviderID, DateSeen) VALUES (1, 30, 'Anxiety', 1, '2022-01-15'); | What is the average age of patients with anxiety who have received mental health services from providers who have completed cultural competency training for LGBTQ+ populations? | SELECT AVG(PatientHealthIssues.Age) FROM MentalHealthProviders INNER JOIN PatientHealthIssues ON MentalHealthProviders.ProviderID = PatientHealthIssues.ProviderID WHERE PatientHealthIssues.HealthIssue = 'Anxiety' AND MentalHealthProviders.LGBTQCompetency = 'Yes'; | gretelai_synthetic_text_to_sql |
CREATE TABLE programs (id INT, program_name VARCHAR(50), program_type VARCHAR(20), org_id INT, start_date DATE, end_date DATE, budget DECIMAL(10,2)); | What is the average budget for humanitarian aid programs in the Middle East? | SELECT AVG(budget) FROM programs WHERE program_type = 'Humanitarian Aid' AND country_code = 'ME'; | gretelai_synthetic_text_to_sql |
CREATE TABLE AgriInnov (id INT, metric VARCHAR(255), crop VARCHAR(255), country VARCHAR(255)); INSERT INTO AgriInnov (id, metric, crop, country) VALUES (1, 'Yield', 'Corn', 'Mexico'), (2, 'Harvest Time', 'Corn', 'Mexico'); | Delete all agricultural innovation metrics related to corn in Mexico. | DELETE FROM AgriInnov WHERE crop = 'Corn' AND country = 'Mexico'; | gretelai_synthetic_text_to_sql |
CREATE TABLE MenuItems (restaurant_id INT, menu_item_id INT, cost DECIMAL(10,2), price DECIMAL(10,2)); INSERT INTO MenuItems (restaurant_id, menu_item_id, cost, price) VALUES (1, 101, 5.00, 12.00), (1, 102, 6.00, 15.00), (1, 103, 4.50, 11.00), (2, 101, 4.00, 10.00), (2, 102, 5.50, 14.00); | Find the top 3 menu items with the highest profit margin in each restaurant. | SELECT restaurant_id, menu_item_id, cost, price, (price - cost) as profit_margin FROM menuitems WHERE profit_margin IN (SELECT MAX(profit_margin) FROM menuitems GROUP BY restaurant_id, FLOOR((ROW_NUMBER() OVER (PARTITION BY restaurant_id ORDER BY profit_margin DESC)) / 3)) ORDER BY restaurant_id, profit_margin DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE athletes (id INT PRIMARY KEY, name VARCHAR(100), age INT, sport VARCHAR(50)); CREATE TABLE teams (id INT PRIMARY KEY, name VARCHAR(100), sport VARCHAR(50)); INSERT INTO teams (id, name, sport) VALUES (1, 'TeamA', 'Basketball'), (2, 'TeamB', 'Soccer'), (3, 'TeamC', 'Basketball'), (4, 'TeamD', 'Hockey'), (5, 'TeamE', 'Soccer'), (6, 'TeamF', 'Basketball'); INSERT INTO athletes (id, name, age, sport) VALUES (1, 'Athlete1', 25, 'Basketball'), (2, 'Athlete2', 30, 'Soccer'), (3, 'Athlete3', 22, 'Basketball'), (4, 'Athlete4', 28, 'Hockey'), (5, 'Athlete5', 35, 'Soccer'), (6, 'Athlete6', 20, 'Basketball'); | List the top 3 sports with the most athletes in descending order. | SELECT sport, COUNT(*) as athlete_count FROM athletes a JOIN teams t ON a.sport = t.sport GROUP BY sport ORDER BY athlete_count DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE MiningWaterUsage (Operation VARCHAR(50), Location VARCHAR(50), WaterUsage FLOAT); INSERT INTO MiningWaterUsage(Operation, Location, WaterUsage) VALUES ('Operation A', 'Western US', 1200000), ('Operation B', 'Western US', 1000000), ('Operation C', 'Western US', 1400000), ('Operation D', 'Central US', 1600000), ('Operation E', 'Eastern US', 900000); | Insert a new mining operation 'Operation F' in the Western US with 1,300,000 water usage. | INSERT INTO MiningWaterUsage(Operation, Location, WaterUsage) VALUES ('Operation F', 'Western US', 1300000); | gretelai_synthetic_text_to_sql |
CREATE TABLE treatment (patient_id INT, treatment_type TEXT); INSERT INTO treatment (patient_id, treatment_type) VALUES (1, 'Cognitive Behavioral Therapy'); INSERT INTO treatment (patient_id, treatment_type) VALUES (3, 'Medication'); | How many patients were treated using cognitive behavioral therapy (CBT)? | SELECT COUNT(*) FROM treatment WHERE treatment_type = 'Cognitive Behavioral Therapy'; | gretelai_synthetic_text_to_sql |
CREATE TABLE wind_turbines (turbine_id INT, country VARCHAR(50), energy_production FLOAT); INSERT INTO wind_turbines (turbine_id, country, energy_production) VALUES (1, 'USA', 2.3), (2, 'Canada', 2.5), (3, 'USA', 2.8); | What is the average energy production of wind turbines installed in the USA? | SELECT AVG(energy_production) FROM wind_turbines WHERE country = 'USA' | gretelai_synthetic_text_to_sql |
CREATE TABLE app_database (id INT, name TEXT, application_type TEXT); INSERT INTO app_database (id, name, application_type) VALUES (1, 'appA', 'creative'), (2, 'appB', 'non_creative'); | Show all 'creative' applications in the 'app_database'. | SELECT name FROM app_database WHERE application_type = 'creative'; | gretelai_synthetic_text_to_sql |
CREATE TABLE platform (platform_id INT, platform_name TEXT, location TEXT); INSERT INTO platform (platform_id, platform_name, location) VALUES (1, 'Alpha', 'North Sea'), (2, 'Bravo', 'Gulf of Mexico'); | Which platforms are located in the Gulf of Mexico? | SELECT platform_name FROM platform WHERE location = 'Gulf of Mexico'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Vehicles (vehicle_id INT, vehicle_type VARCHAR(20), max_weight INT); INSERT INTO Vehicles (vehicle_id, vehicle_type, max_weight) VALUES (1, 'AutonomousTruck', 20000), (2, 'ManualTruck', 25000), (3, 'AutonomousTruck', 22000), (4, 'AutonomousTruck', 23000); | Calculate the average 'max_weight' for 'AutonomousTrucks' in the 'Vehicles' table | SELECT AVG(max_weight) FROM Vehicles WHERE vehicle_type = 'AutonomousTruck'; | gretelai_synthetic_text_to_sql |
CREATE TABLE customers (customer_id INT, age INT, name VARCHAR(255), country VARCHAR(50)); CREATE TABLE transactions (transaction_id INT, customer_id INT, product_id INT, category_id INT, transaction_date DATE, amount DECIMAL(10,2), currency VARCHAR(10)); | What is the total transaction value for each customer in the past week, split by currency, for customers in the United States? | SELECT c.country, c.name, t.currency, SUM(t.amount) as total_transaction_value FROM customers c INNER JOIN transactions t ON c.customer_id = t.customer_id WHERE c.country = 'United States' AND t.transaction_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 WEEK) GROUP BY c.country, c.name, t.currency; | gretelai_synthetic_text_to_sql |
CREATE TABLE hydro_generation (country VARCHAR(30), generation FLOAT); INSERT INTO hydro_generation (country, generation) VALUES ('Australia', 22000), ('Australia', 23000), ('New Zealand', 10000), ('New Zealand', 11000); | What is the average hydroelectric power generation in Australia and New Zealand? | SELECT AVG(generation) FROM hydro_generation WHERE country IN ('Australia', 'New Zealand') GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE mental_health_facilities (facility_id INT, name VARCHAR(50), state VARCHAR(20)); INSERT INTO mental_health_facilities (facility_id, name, state) VALUES (1, 'Happy Minds', 'New York'); INSERT INTO mental_health_facilities (facility_id, name, state) VALUES (2, 'California Care', 'California'); | How many mental health facilities are there in New York and California? | SELECT state, COUNT(*) FROM mental_health_facilities WHERE state IN ('New York', 'California') GROUP BY state; | gretelai_synthetic_text_to_sql |
CREATE TABLE port (port_id VARCHAR(10), port_name VARCHAR(20)); INSERT INTO port VALUES ('P1', 'A'), ('P2', 'B'); CREATE TABLE handling (handling_id INT, port_id VARCHAR(10), cargo_weight INT, handling_date DATE); INSERT INTO handling VALUES (1, 'P1', 5000, '2022-01-01'), (2, 'P1', 6000, '2022-02-01'), (3, 'P1', 7000, '2022-03-01'), (4, 'P2', 8000, '2022-01-01'); | What was the total cargo weight handled by port 'A' in Q1 2022? | SELECT SUM(cargo_weight) FROM handling INNER JOIN port ON handling.port_id = port.port_id WHERE port.port_name = 'A' AND handling_date BETWEEN '2022-01-01' AND '2022-03-31'; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA if not exists music_schema;CREATE TABLE if not exists concerts (id INT, name VARCHAR, city VARCHAR, genre VARCHAR, revenue FLOAT);INSERT INTO concerts (id, name, city, genre, revenue) VALUES (1, 'Music Festival', 'New York', 'Pop', 50000.00), (2, 'Rock Concert', 'Chicago', 'Rock', 75000.00), (3, 'Jazz Festival', 'Los Angeles', 'Jazz', 125000.00), (4, 'Hip Hop Concert', 'Miami', 'Hip Hop', 60000.00); | Delete all concerts that are not in the 'Pop', 'Rock', or 'Jazz' genres. | DELETE FROM music_schema.concerts WHERE genre NOT IN ('Pop', 'Rock', 'Jazz'); | gretelai_synthetic_text_to_sql |
CREATE TABLE education_programs (id INT, name VARCHAR(255), animal_species_id INT); INSERT INTO education_programs (id, name, animal_species_id) VALUES (1, 'Animal Lovers', 2), (2, 'Nature Explorers', 3), (3, 'Wildlife Adventurers', 1), (4, 'Ocean Guardians', 5), (5, 'Forest Friends', 4); CREATE TABLE animal_species (id INT, name VARCHAR(20)); INSERT INTO animal_species (id, name) VALUES (1, 'Eagle'), (2, 'Lion'), (3, 'Hippo'), (4, 'Sloth'), (5, 'Seal'); | Identify the community education programs and their associated animal species | SELECT e.name as program_name, a.name as species_name FROM education_programs e JOIN animal_species a ON e.animal_species_id = a.id; | gretelai_synthetic_text_to_sql |
CREATE TABLE company (id INT, name VARCHAR(255)); INSERT INTO company (id, name) VALUES (1, 'OceanServe'); CREATE TABLE vessel (id INT, company_id INT, capacity INT, build_year INT); INSERT INTO vessel (id, company_id, capacity, build_year) VALUES (1, 1, 5000, 2012), (2, 1, 6000, 2015), (3, 1, 4000, 2008); | What is the total capacity of all vessels owned by company "OceanServe" that were built after 2010? | SELECT SUM(vessel.capacity) FROM vessel INNER JOIN company ON vessel.company_id = company.id WHERE company.name = 'OceanServe' AND vessel.build_year > 2010; | gretelai_synthetic_text_to_sql |
CREATE TABLE tours (id INT, name TEXT, country TEXT, type TEXT, revenue INT, year INT); INSERT INTO tours (id, name, country, type, revenue, year) VALUES (1, 'Virtual Rome', 'Italy', 'virtual', 25000, 2023); INSERT INTO tours (id, name, country, type, revenue, year) VALUES (2, 'Virtual Florence', 'Italy', 'virtual', 30000, 2023); | What is the total revenue of virtual tours in Italy for 2023? | SELECT SUM(revenue) FROM tours WHERE type = 'virtual' AND country = 'Italy' AND year = 2023; | gretelai_synthetic_text_to_sql |
CREATE TABLE hydro_power_plants (name VARCHAR(50), location VARCHAR(50), capacity FLOAT, country VARCHAR(50)); INSERT INTO hydro_power_plants (name, location, capacity, country) VALUES ('Plant A', 'USA', 1500, 'United States'), ('Plant B', 'Brazil', 2000, 'Brazil'), ('Plant C', 'China', 1200, 'China'), ('Plant D', 'Canada', 1800, 'Canada'); | What is the average daily energy storage capacity (in MWh) for hydroelectric power plants, grouped by country? | SELECT country, AVG(capacity) as avg_capacity FROM hydro_power_plants GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE Labor_Violations (violation_id INT, violation_date DATE, region TEXT, violation_type TEXT); | What is the number of ethical labor violations in the last year in the Latin America region? | SELECT COUNT(*) FROM Labor_Violations WHERE violation_date BETWEEN DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR) AND CURRENT_DATE AND region = 'Latin America' AND violation_type = 'Ethical Labor Violation'; | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_species (species_id INT, species_name VARCHAR(255), PRIMARY KEY(species_id)); INSERT INTO marine_species (species_id, species_name) VALUES (1, 'Blue Whale'); CREATE TABLE marine_protected_areas (mpa_id INT, name VARCHAR(255), location VARCHAR(255), PRIMARY KEY(mpa_id)); INSERT INTO marine_protected_areas (mpa_id, name, location) VALUES (1, 'Great Barrier Reef', 'Australia'); CREATE TABLE species_conservation (species_id INT, mpa_id INT, conservation_status VARCHAR(255), PRIMARY KEY(species_id, mpa_id), FOREIGN KEY (species_id) REFERENCES marine_species(species_id), FOREIGN KEY (mpa_id) REFERENCES marine_protected_areas(mpa_id)); INSERT INTO species_conservation (species_id, mpa_id, conservation_status) VALUES (1, 1, 'Vulnerable'); | List all marine species and their conservation status in marine protected areas in the Indian Ocean. | SELECT marine_species.species_name, species_conservation.conservation_status FROM marine_species INNER JOIN species_conservation ON marine_species.species_id = species_conservation.species_id INNER JOIN marine_protected_areas ON species_conservation.mpa_id = marine_protected_areas.mpa_id WHERE marine_protected_areas.location = 'Indian Ocean'; | gretelai_synthetic_text_to_sql |
CREATE TABLE diversity (company_name VARCHAR(255), gender_distribution VARCHAR(50), ethnicity_distribution VARCHAR(50)); INSERT INTO diversity (company_name, gender_distribution, ethnicity_distribution) VALUES ('Tech Titan Inc', '50/50', 'Diverse'), ('Innovate Inc', '60/40', 'Not Diverse'), ('GreenTech LLC', NULL, NULL), ('Delta Co', '40/60', 'Diverse'); | Identify companies that have not reported diversity metrics for ethnicity | SELECT company_name FROM diversity WHERE ethnicity_distribution IS NULL; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA if not exists higher_ed;CREATE TABLE if not exists higher_ed.faculty(id INT, name VARCHAR(255), department VARCHAR(255), grant_amount DECIMAL(10,2), grant_date DATE); | How many research grants were awarded to faculty members in the Arts department in the last 5 years? | SELECT COUNT(*) FROM higher_ed.faculty WHERE department = 'Arts' AND grant_date >= DATE_SUB(CURRENT_DATE, INTERVAL 5 YEAR); | gretelai_synthetic_text_to_sql |
CREATE TABLE graduate_students (id INT, name VARCHAR(50), program VARCHAR(50), gender VARCHAR(50), enrollment_status VARCHAR(50)); INSERT INTO graduate_students (id, name, program, gender, enrollment_status) VALUES (1, 'Charlie Davis', 'Computer Science', 'Male', 'Enrolled'); INSERT INTO graduate_students (id, name, program, gender, enrollment_status) VALUES (2, 'Diana Smith', 'Mathematics', 'Female', 'Enrolled'); INSERT INTO graduate_students (id, name, program, gender, enrollment_status) VALUES (3, 'Eli Jones', 'Physics', 'Male', 'Not Enrolled'); INSERT INTO graduate_students (id, name, program, gender, enrollment_status) VALUES (4, 'Fiona Kim', 'Chemistry', 'Female', 'Enrolled'); | How many graduate students are enrolled in STEM fields, broken down by gender? | SELECT gender, COUNT(*) as count FROM graduate_students WHERE program IN ('Computer Science', 'Mathematics', 'Physics', 'Chemistry') AND enrollment_status = 'Enrolled' GROUP BY gender; | gretelai_synthetic_text_to_sql |
CREATE TABLE machines ( id INT PRIMARY KEY, name VARCHAR(255), manufacturing_country VARCHAR(64) ); INSERT INTO machines (id, name, manufacturing_country) VALUES (1, 'CNC Milling Machine', 'Germany'); INSERT INTO machines (id, name, manufacturing_country) VALUES (2, 'Injection Molding Machine', 'China'); | Delete all records from the "machines" table where the "manufacturing_country" is "Germany" | DELETE FROM machines WHERE manufacturing_country = 'Germany'; | gretelai_synthetic_text_to_sql |
CREATE TABLE construction_labor (id INT, worker_name VARCHAR(50), hours_worked INT, project_type VARCHAR(20), state VARCHAR(20)); INSERT INTO construction_labor (id, worker_name, hours_worked, project_type, state) VALUES (1, 'Juan Garcia', 120, 'Non-Sustainable', 'Texas'); INSERT INTO construction_labor (id, worker_name, hours_worked, project_type, state) VALUES (2, 'Maria Rodriguez', 90, 'Sustainable', 'Texas'); | Delete records of labor hours worked on non-sustainable projects in Texas. | DELETE FROM construction_labor WHERE project_type = 'Non-Sustainable' AND state = 'Texas'; | gretelai_synthetic_text_to_sql |
CREATE TABLE MunicipalityH (Month INT, RecyclingQuantity INT); INSERT INTO MunicipalityH (Month, RecyclingQuantity) VALUES (1, 250), (2, 300), (3, 350), (4, 400), (5, 450), (6, 500); | What is the maximum recycling rate in 'MunicipalityH' in the second half of the year? | SELECT MAX(RecyclingQuantity) FROM MunicipalityH WHERE Month BETWEEN 7 AND 12 AND Month % 2 = 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE Cost (id INT, name VARCHAR(50), year INT, cost INT); INSERT INTO Cost (id, name, year, cost) VALUES (1, 'Operation A', 2005, 1000000); INSERT INTO Cost (id, name, year, cost) VALUES (2, 'Operation B', 2008, 1500000); | What is the name and year of the most expensive cybersecurity operation in the 'Cost' table? | SELECT name, year, MAX(cost) FROM Cost; | gretelai_synthetic_text_to_sql |
CREATE TABLE PrecisionAgriculture.FieldDetails (FieldID INT, FieldSize FLOAT, Location VARCHAR(255)); | Select the details of the fields that have a size greater than 5000 square meters | SELECT FieldID, FieldSize, Location FROM PrecisionAgriculture.FieldDetails WHERE FieldSize > 5000; | gretelai_synthetic_text_to_sql |
CREATE TABLE consumption (id INT, region VARCHAR(20), type VARCHAR(20), consumption INT); INSERT INTO consumption (id, region, type, consumption) VALUES (1, 'Southern', 'Green', 1000); INSERT INTO consumption (id, region, type, consumption) VALUES (2, 'Northern', 'Regular', 2000); | What is the minimum energy consumption of green buildings in the Southern region? | SELECT MIN(consumption) FROM consumption WHERE region = 'Southern' AND type = 'Green'; | gretelai_synthetic_text_to_sql |
CREATE TABLE EV_Specs (id INT, vehicle_model VARCHAR(255), manufacturing_country VARCHAR(255), range FLOAT); INSERT INTO EV_Specs (id, vehicle_model, manufacturing_country, range) VALUES (1, 'Hyundai Kona Electric', 'South Korea', 258.0); INSERT INTO EV_Specs (id, vehicle_model, manufacturing_country, range) VALUES (2, 'Kia Niro EV', 'South Korea', 239.0); INSERT INTO EV_Specs (id, vehicle_model, manufacturing_country, range) VALUES (3, 'Hyundai Ioniq Electric', 'South Korea', 170.0); | What is the average range of electric vehicles manufactured in South Korea? | SELECT AVG(range) FROM EV_Specs WHERE manufacturing_country = 'South Korea'; | gretelai_synthetic_text_to_sql |
CREATE TABLE astronauts (badge_id INT, first_name VARCHAR(50), last_name VARCHAR(50), dob DATE, gender VARCHAR(10), missions INT); CREATE TABLE space_missions (mission_id INT, mission_name VARCHAR(50), launch_date DATE, return_date DATE, astronaut_badge_id INT); | How many astronauts have flown missions before the age of 30? | SELECT COUNT(*) FROM astronauts WHERE DATEDIFF('1970-01-01', dob) / 365.25 < 30 AND missions > 0; | gretelai_synthetic_text_to_sql |
CREATE TABLE volunteer_hours (id INT, volunteer_name VARCHAR(50), project_name VARCHAR(50), hours_spent DECIMAL(5, 2)); INSERT INTO volunteer_hours (id, volunteer_name, project_name, hours_spent) VALUES (1, 'Maria Rodriguez', 'Habitat Restoration', 5); INSERT INTO volunteer_hours (id, volunteer_name, project_name, hours_spent) VALUES (2, 'Ali Baba', 'Community Education', 3); | What is the average number of hours spent by volunteers on 'Community Education' programs?; | SELECT AVG(hours_spent) FROM volunteer_hours WHERE project_name = 'Community Education'; | gretelai_synthetic_text_to_sql |
CREATE TABLE brands (brand_id INT, brand_name TEXT); INSERT INTO brands (brand_id, brand_name) VALUES (1, 'Patagonia'), (2, 'Eileen Fisher'), (3, 'Veja'); CREATE TABLE products (product_id INT, product_name TEXT, brand_id INT, retail_price DECIMAL(5,2)); INSERT INTO products (product_id, product_name, brand_id, retail_price) VALUES (1, 'Hemp Shirt', 1, 80.00), (2, 'Hemp Dress', 2, 130.00), (3, 'Hemp Sneakers', 3, 100.00); | What is the average retail price of hemp garments for each brand? | SELECT brands.brand_name, AVG(products.retail_price) FROM brands JOIN products ON brands.brand_id = products.brand_id WHERE product_name LIKE '%Hemp%' GROUP BY brands.brand_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE security_incidents (id INT, country VARCHAR(255), incident_date DATE); INSERT INTO security_incidents (id, country, incident_date) VALUES (1, 'United States', '2022-06-01'), (2, 'United Kingdom', '2022-06-03'), (3, 'Canada', '2022-06-05'), (4, 'United States', '2022-06-07'), (5, 'Australia', '2022-06-09'); | List the top 3 countries with the highest number of security incidents in the last month, along with the total number of incidents. | SELECT country, COUNT(id) as total_incidents FROM security_incidents WHERE incident_date >= DATEADD(month, -1, GETDATE()) GROUP BY country ORDER BY total_incidents DESC, country ASC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE dairy_farms (id INT, farm_name TEXT, region TEXT, is_organic BOOLEAN); INSERT INTO dairy_farms (id, farm_name, region, is_organic) VALUES (1, 'Harmony Dairy', 'North America', true), (2, 'Dairy Dreams', 'Europe', false); | Which region has the least number of organic dairy farms? | SELECT region, MIN(COUNT(*)) FROM dairy_farms WHERE is_organic = true GROUP BY region; | gretelai_synthetic_text_to_sql |
CREATE TABLE media_content (id INT, title VARCHAR(255), release_year INT, runtime INT, genre VARCHAR(255), format VARCHAR(50), country VARCHAR(255)); | What is the average runtime of movies and TV shows in each genre, and the number of entries for each genre? | SELECT genre, AVG(runtime) AS avg_runtime, COUNT(*) AS entries FROM media_content GROUP BY genre; | gretelai_synthetic_text_to_sql |
CREATE TABLE explainable_ai_models (model_id INT, model_name TEXT, region TEXT, fairness_score FLOAT); INSERT INTO explainable_ai_models (model_id, model_name, region, fairness_score) VALUES (1, 'Lime', 'South America', 0.92), (2, 'Shap', 'South America', 0.95), (3, 'Skater', 'South America', 0.97); | Which explainable AI models have the highest fairness scores in South America? | SELECT model_name, fairness_score FROM explainable_ai_models WHERE region = 'South America' ORDER BY fairness_score DESC; | 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, certified_by INT);CREATE TABLE certified_products (certification_id INT, name VARCHAR(255)); | What is the total revenue generated from sales in the 'sales' table for products in the 'sustainable_products' table that are made from recycled materials and certified by the 'certified_products' table? | 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 JOIN certified_products cp ON sp.certified_by = cp.certification_id WHERE sp.recycled = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE speeds (id INT, vessel_name VARCHAR(50), type VARCHAR(50), region VARCHAR(50), speed DECIMAL(5,2)); | What is the maximum and minimum speed of vessels in the South Pacific, grouped by their type? | SELECT type, MIN(speed) AS min_speed, MAX(speed) AS max_speed FROM speeds WHERE region = 'South Pacific' GROUP BY type; | gretelai_synthetic_text_to_sql |
CREATE TABLE VolleyballMatches (match_id INTEGER, team_A TEXT, team_B TEXT, attendance INTEGER); INSERT INTO VolleyballMatches (match_id, team_A, team_B, attendance) VALUES (1, 'Team A', 'Team B', 5000), (2, 'Team C', 'Team D', 6000), (3, 'Team E', 'Team F', 7000); | Delete the volleyball match with the highest attendance. | DELETE FROM VolleyballMatches WHERE attendance = (SELECT MAX(attendance) FROM VolleyballMatches); | gretelai_synthetic_text_to_sql |
CREATE TABLE mental_health_parity (id INT PRIMARY KEY, state VARCHAR(2), year INT, accessibility FLOAT, quality FLOAT); | Create a table for mental health parity data | CREATE TABLE if not exists mental_health_parity_new AS SELECT * FROM mental_health_parity WHERE FALSE; | gretelai_synthetic_text_to_sql |
CREATE TABLE provincial_waste (province VARCHAR(255), year INT, waste_generation INT); INSERT INTO provincial_waste (province, year, waste_generation) VALUES ('Quebec', 2020, 5000000); | What is the total waste generation in the province of Quebec for the year 2020? | SELECT waste_generation FROM provincial_waste WHERE province='Quebec' AND year=2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE Crop (id INT, name VARCHAR(255), minimum_temperature INT); INSERT INTO Crop (id, name, minimum_temperature) VALUES (1, 'Rice', 20), (2, 'Wheat', 5), (3, 'Corn', 10); | What is the minimum temperature required for growing rice? | SELECT Crop.name, Crop.minimum_temperature FROM Crop WHERE Crop.name = 'Rice'; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA fitness; CREATE TABLE memberships (id INT, member_name VARCHAR(255), city VARCHAR(255), state VARCHAR(255), join_date DATE, membership_type VARCHAR(255), price DECIMAL(10, 2)); | What is the total revenue generated from memberships in the city of Seattle for the year 2022? | SELECT SUM(price) FROM fitness.memberships WHERE city = 'Seattle' AND YEAR(join_date) = 2022; | gretelai_synthetic_text_to_sql |
CREATE TABLE interactions (user_id INT, post_id INT, timestamp TIMESTAMP); CREATE TABLE posts (id INT, content TEXT); | Display the number of unique users who interacted with posts about 'music' in each month of 2021. | SELECT DATE_FORMAT(timestamp, '%Y-%m') as interaction_month, COUNT(DISTINCT user_id) as monthly_unique_users FROM interactions i JOIN posts p ON i.post_id = p.id WHERE p.content LIKE '%music%' AND YEAR(timestamp) = 2021 GROUP BY interaction_month; | gretelai_synthetic_text_to_sql |
CREATE TABLE orders (order_id INT, customer_id INT, sustainable BOOLEAN);CREATE TABLE customers (customer_id INT, name VARCHAR(50)); | What is the percentage of sustainable fabric orders for the top 3 customers in the past year? | SELECT name, PERCENTAGE(COUNT(*) FILTER (WHERE sustainable)) OVER (PARTITION BY name) FROM orders INNER JOIN customers ON orders.customer_id = customers.customer_id WHERE order_date >= DATEADD(year, -1, CURRENT_DATE) GROUP BY name ORDER BY COUNT(*) DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE fish_farms (id INT, name VARCHAR(255), region VARCHAR(255), water_temperature FLOAT, water_depth FLOAT, water_dissolved_oxygen FLOAT); INSERT INTO fish_farms (id, name, region, water_temperature, water_depth, water_dissolved_oxygen) VALUES (1, 'Farm A', 'Europe', 16.5, 9.3, 7.1), (2, 'Farm B', 'Europe', 14.2, 7.8, 6.8), (3, 'Farm C', 'Europe', 17.3, 10.1, 7.5); | What is the total water dissolved oxygen (in mg/L) in fish farms located in Europe, having a water temperature above 15 degrees Celsius and a water depth greater than 8 meters? | SELECT SUM(water_dissolved_oxygen) FROM fish_farms WHERE region = 'Europe' AND water_temperature > 15 AND water_depth > 8; | gretelai_synthetic_text_to_sql |
CREATE TABLE Stores (store_id INT, store_name VARCHAR(50), state VARCHAR(50)); INSERT INTO Stores (store_id, store_name, state) VALUES (1, 'Eco-Market', 'Washington'), (2, 'Green Vista', 'Oregon'); CREATE TABLE Inventory (inventory_id INT, product_id INT, product_name VARCHAR(50), store_id INT, last_sale_date DATE); INSERT INTO Inventory (inventory_id, product_id, product_name, store_id, last_sale_date) VALUES (1, 1, 'Almond Milk', 1, '2022-03-15'), (2, 2, 'Quinoa', 2, '2022-05-01'); | Delete records for products that have not been sold for the last 6 months in stores located in 'Washington' and 'Oregon' | DELETE FROM Inventory WHERE last_sale_date < DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH) AND store_id IN (SELECT store_id FROM Stores WHERE state IN ('Washington', 'Oregon')); | gretelai_synthetic_text_to_sql |
CREATE TABLE districts (id INT, name TEXT);CREATE TABLE emergencies (id INT, district_id INT, response_time INT, date DATE); | What is the minimum response time for emergency calls in each district in the last year? | SELECT d.name, MIN(e.response_time) FROM districts d JOIN emergencies e ON d.id = e.district_id WHERE e.date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR) GROUP BY d.id; | gretelai_synthetic_text_to_sql |
CREATE TABLE volunteers (volunteer_id INT, total_hours INT, volunteer_status VARCHAR(20)); INSERT INTO volunteers (volunteer_id, total_hours, volunteer_status) VALUES (1, 50, 'inactive'), (2, 150, 'inactive'), (3, 80, 'active'), (4, 200, 'active'); | Update the volunteer records for volunteers who have volunteered more than 100 hours in total to have a volunteer_status of 'active'. | UPDATE volunteers SET volunteer_status = 'active' WHERE total_hours > 100; | gretelai_synthetic_text_to_sql |
CREATE TABLE individuals (individual_id INT, individual_name TEXT, num_donations INT, num_investments INT); | Insert records for a new individual donor with the ID 1001, name 'Aarav Patel', and a total of 2 donations and 1 investment in the 'individuals' table. | INSERT INTO individuals VALUES (1001, 'Aarav Patel', 2, 1); | gretelai_synthetic_text_to_sql |
CREATE TABLE LaborDisputes (id INT, Sector TEXT, DisputeType TEXT, WorkdaysLost INT, DisputeStartDate DATE, DisputeEndDate DATE); | What is the total number of workdays lost due to labor disputes in the 'Technology' sector in 2020? | SELECT SUM(WorkdaysLost) FROM LaborDisputes WHERE Sector = 'Technology' AND YEAR(DisputeStartDate) = 2020 AND YEAR(DisputeEndDate) = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE comm_dev (initiative_id INT, completion_year INT); INSERT INTO comm_dev (initiative_id, completion_year) VALUES (1, 2017), (2, 2018), (3, 2019), (4, 2020), (5, 2022); | How many community development initiatives were completed before 2020? | SELECT COUNT(*) FROM comm_dev WHERE completion_year < 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE posts (post_id INT, user_id INT, post_date DATE); INSERT INTO posts (post_id, user_id, post_date) VALUES (1, 1, '2021-01-01'), (2, 1, '2021-01-02'), (3, 2, '2021-01-01'), (4, 3, '2021-01-02'), (5, 3, '2021-01-03'), (6, 4, '2021-01-01'), (7, 5, '2021-01-04'), (8, 5, '2021-01-05'), (9, 6, '2021-01-04'), (10, 6, '2021-01-05'), (11, 7, '2021-01-06'), (12, 7, '2021-01-07'), (13, 8, '2021-01-06'), (14, 8, '2021-01-07'), (15, 9, '2021-01-06'), (16, 9, '2021-01-07'), (17, 10, '2021-01-01'), (18, 10, '2021-01-02'); | Determine the number of users who have posted at least once per day for the last 7 days in the 'social_media' database. | SELECT COUNT(DISTINCT user_id) FROM (SELECT user_id, post_date FROM posts WHERE post_date >= DATEADD(day, -7, CURRENT_TIMESTAMP) GROUP BY user_id, post_date HAVING COUNT(*) = 1) AS subquery; | gretelai_synthetic_text_to_sql |
CREATE TABLE heritagesites (name VARCHAR(255), location VARCHAR(255), designation_date DATE); INSERT INTO heritagesites (name, location, designation_date) VALUES ('Angkor Wat', 'Cambodia', '1992-12-07'); INSERT INTO heritagesites (name, location, designation_date) VALUES ('Prambanan', 'Indonesia', '1991-08-31'); | What is the earliest designation date for UNESCO World Heritage sites in Southeast Asia? | SELECT MIN(designation_date) FROM heritagesites WHERE location = (SELECT location FROM heritagesites WHERE region = 'Southeast Asia' AND designation_date = (SELECT MIN(designation_date) FROM heritagesites WHERE region = 'Southeast Asia')); | gretelai_synthetic_text_to_sql |
CREATE TABLE supplier (id INT, supplier VARCHAR(255), product_type VARCHAR(255), product_count INT); INSERT INTO supplier (id, supplier, product_type, product_count) VALUES (1, 'Supplier A', 'Electronics', 200), (2, 'Supplier B', 'Clothing', 150), (3, 'Supplier C', 'Electronics', 300), (4, 'Supplier D', 'Clothing', 250), (5, 'Supplier A', 'Books', 100), (6, 'Supplier B', 'Toys', 200); | How many products are there in each supplier's inventory, by type? | SELECT supplier, product_type, SUM(product_count) FROM supplier GROUP BY supplier, product_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE Employees (EmployeeID INT, Gender VARCHAR(10), Position VARCHAR(20), PromotionDate DATE); | How many female employees have been promoted to managerial positions in the last 3 years? | SELECT COUNT(*) as FemaleManagers FROM Employees WHERE Gender = 'Female' AND Position LIKE '%Manager%' AND PromotionDate BETWEEN DATEADD(YEAR, -3, GETDATE()) AND GETDATE(); | gretelai_synthetic_text_to_sql |
CREATE TABLE users (id INT, name VARCHAR(100), country VARCHAR(50)); INSERT INTO users (id, name, country) VALUES (1, 'John Doe', 'USA'), (2, 'Jane Smith', 'Canada'); CREATE TABLE posts (id INT, user_id INT, content TEXT); INSERT INTO posts (id, user_id, content) VALUES (1, 1, 'Hello World'), (2, 1, 'I love data'); | What is the total number of posts made by users from the United States? | SELECT COUNT(*) FROM posts JOIN users ON posts.user_id = users.id WHERE users.country = 'USA'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Artists (ArtistID INT PRIMARY KEY, ArtistName VARCHAR(255)); INSERT INTO Artists (ArtistID, ArtistName) VALUES (1, 'O''Keeffe'); CREATE TABLE Events (EventID INT PRIMARY KEY, EventName VARCHAR(255), Attendance INT, ArtistID INT, FOREIGN KEY (ArtistID) REFERENCES Artists(ArtistID)); INSERT INTO Events (EventID, EventName, Attendance, ArtistID) VALUES (1, 'Flowers Exhibit', 600, 1); | What is the average age of attendees for events by artist 'O'Keeffe'? | SELECT AVG(Audience.Age) FROM Audience INNER JOIN Events ON Audience.EventID = Events.EventID INNER JOIN Artists ON Events.ArtistID = Artists.ArtistID WHERE Artists.ArtistName = 'O''Keeffe'; | gretelai_synthetic_text_to_sql |
CREATE TABLE brands(brand_id INT, brand_name TEXT); INSERT INTO brands(brand_id, brand_name) VALUES (1, 'BrandA'), (2, 'BrandB'), (3, 'BrandC'); CREATE TABLE products(product_id INT, brand_id INT, material TEXT, quantity INT); INSERT INTO products(product_id, brand_id, material, quantity) VALUES (1, 1, 'hemp', 10), (2, 1, 'hemp', 20), (3, 1, 'hemp', 30), (4, 2, 'hemp', 40), (5, 2, 'hemp', 50), (6, 2, 'hemp', 60), (7, 3, 'hemp', 70), (8, 3, 'hemp', 80), (9, 3, 'hemp', 90); | What is the difference between the maximum and minimum quantities of 'hemp' used in products for each brand? | SELECT brand_id, brand_name, MAX(quantity) - MIN(quantity) as difference FROM brands b JOIN products p ON b.brand_id = p.brand_id WHERE material = 'hemp' GROUP BY brand_id, brand_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE Excavation_Sites (Site_ID INT, Site_Name TEXT, Country TEXT, Number_of_Artifacts INT);INSERT INTO Excavation_Sites (Site_ID, Site_Name, Country, Number_of_Artifacts) VALUES (1, 'Pompeii', 'Italy', 10000);INSERT INTO Excavation_Sites (Site_ID, Site_Name, Country, Number_of_Artifacts) VALUES (2, 'Tutankhamun', 'Egypt', 5000);INSERT INTO Excavation_Sites (Site_ID, Site_Name, Country, Number_of_Artifacts) VALUES (3, 'Machu Picchu', 'Peru', 3000); | Which excavation sites have the most artifacts? | SELECT Site_Name, Number_of_Artifacts FROM Excavation_Sites ORDER BY Number_of_Artifacts DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE flood_control_projects (id INT, name VARCHAR(50), location VARCHAR(50), budget DECIMAL(10,2)); INSERT INTO flood_control_projects (id, name, location, budget) VALUES (1, 'Montreal Flood Control', 'Quebec', 2000000.00); | Find the total budget for flood control projects in 'Quebec' | SELECT SUM(budget) FROM flood_control_projects WHERE location = 'Quebec'; | gretelai_synthetic_text_to_sql |
CREATE TABLE NGOs (NGOID int, NGOName varchar(50)); INSERT INTO NGOs (NGOID, NGOName) VALUES (1, 'World Vision'), (2, 'Catholic Relief Services'); CREATE TABLE RefugeeSupport (SupportID int, NGOID int, FamilyID int, SupportDate date); INSERT INTO RefugeeSupport (SupportID, NGOID, FamilyID, SupportDate) VALUES (1, 1, 1, '2022-05-01'), (2, 1, 2, '2022-06-01'), (3, 2, 1, '2022-07-01'); | What is the total number of refugee families supported by each organization in the last 3 months? | SELECT NGOName, COUNT(DISTINCT FamilyID) as SupportedFamilies FROM NGOs INNER JOIN RefugeeSupport ON NGOs.NGOID = RefugeeSupport.NGOID WHERE SupportDate >= DATE_SUB(CURRENT_DATE, INTERVAL 3 MONTH) GROUP BY NGOName; | gretelai_synthetic_text_to_sql |
CREATE TABLE teams (id INT, name VARCHAR(50), sport VARCHAR(20)); CREATE TABLE games (id INT, home_team_id INT, away_team_id INT, sport VARCHAR(20)); | Display the basketball teams that have not played against the LA Lakers | SELECT teams.name FROM teams LEFT JOIN games ON teams.id = home_team_id OR teams.id = away_team_id WHERE sport = 'Basketball' AND (home_team_id IS NULL OR away_team_id IS NULL OR (home_team_id != (SELECT id FROM teams WHERE name = 'LA Lakers' AND sport = 'Basketball') AND away_team_id != (SELECT id FROM teams WHERE name = 'LA Lakers' AND sport = 'Basketball'))); | 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.