context stringlengths 11 9.12k | question stringlengths 0 1.06k | SQL stringlengths 2 4.44k | source stringclasses 28 values |
|---|---|---|---|
CREATE TABLE SpeciesBiomass (species VARCHAR(255), biomass FLOAT); INSERT INTO SpeciesBiomass (species, biomass) VALUES ('Seahorse', 120.5), ('Whale', 600.0), ('Plankton', 50.0); CREATE TABLE MarineResearchArea (species VARCHAR(255), area VARCHAR(255)); INSERT INTO MarineResearchArea (species, area) VALUES ('Seahorse', 'MarineResearchAreaC'), ('Whale', 'MarineResearchAreaC'), ('Squid', 'MarineResearchAreaD'); | Calculate the total biomass of marine species in 'MarineResearchAreaC' and 'MarineResearchAreaD' | SELECT SUM(biomass) FROM SpeciesBiomass INNER JOIN MarineResearchArea ON SpeciesBiomass.species = MarineResearchArea.species WHERE MarineResearchArea.area IN ('MarineResearchAreaC', 'MarineResearchAreaD'); | gretelai_synthetic_text_to_sql |
CREATE TABLE sales (id INT, item_id INT, sales_channel VARCHAR(255), quantity INT); INSERT INTO sales (id, item_id, sales_channel, quantity) VALUES (1, 101, 'online', 50), (2, 102, 'retail', 75), (3, 103, 'online', 80), (4, 104, 'retail', 60), (5, 105, 'online', 90); | How many items have been sold through each sales channel? | SELECT sales_channel, COUNT(DISTINCT item_id) FROM sales GROUP BY sales_channel; | gretelai_synthetic_text_to_sql |
CREATE TABLE crops (id INT, name VARCHAR(100), yield INT, country VARCHAR(50)); INSERT INTO crops (id, name, yield, country) VALUES (1, 'rice', 50, 'Indonesia'); | What is the average yield of a specific crop in each country? | SELECT country, AVG(yield) FROM crops WHERE name = 'rice' GROUP BY country | gretelai_synthetic_text_to_sql |
CREATE TABLE donors (donor_id INT PRIMARY KEY, donor_name TEXT, status TEXT); INSERT INTO donors (donor_id, donor_name, status) VALUES (1, 'John Doe', 'active'), (2, 'Jane Smith', 'inactive'); CREATE TABLE donations (donation_id INT PRIMARY KEY, donor_id INT, donation_amount DECIMAL); INSERT INTO donations (donation_id, donor_id, donation_amount) VALUES (1, 1, 100.00), (2, 2, 200.00); | Delete donations from inactive donors | WITH inactive_donors AS (DELETE FROM donors WHERE status = 'inactive' RETURNING donor_id) DELETE FROM donations WHERE donor_id IN (SELECT * FROM inactive_donors); | gretelai_synthetic_text_to_sql |
CREATE TABLE Exhibitions (id INT, city VARCHAR(20), visitors INT, exhibition_date DATE); INSERT INTO Exhibitions (id, city, visitors, exhibition_date) VALUES (1, 'Tokyo', 50, '2021-07-01'), (2, 'Tokyo', 60, '2021-07-05'); | How many exhibitions were held in Tokyo in July 2021? | SELECT COUNT(*) FROM Exhibitions WHERE city = 'Tokyo' AND exhibition_date BETWEEN '2021-07-01' AND '2021-07-31' | gretelai_synthetic_text_to_sql |
CREATE TABLE programs (id INT, name VARCHAR(255)); INSERT INTO programs (id, name) VALUES (1, 'Education'), (2, 'Health'); CREATE TABLE donations (id INT, program_id INT); | List all programs that have no donors | SELECT p.name FROM programs p LEFT JOIN donations d ON p.id = d.program_id WHERE d.program_id IS NULL; | gretelai_synthetic_text_to_sql |
CREATE TABLE wastewater_treatment_plants (plant_id INT, state VARCHAR(20), water_usage FLOAT); INSERT INTO wastewater_treatment_plants (plant_id, state, water_usage) VALUES (1, 'New York', 10000), (2, 'New York', 12000), (3, 'Albany', 9000); | What is the average water consumption by wastewater treatment plants in the state of New York? | SELECT AVG(water_usage) FROM wastewater_treatment_plants WHERE state = 'New York'; | gretelai_synthetic_text_to_sql |
CREATE TABLE vessels (vessel_id INT, vessel_name VARCHAR(50), status VARCHAR(50)); CREATE TABLE deliveries (delivery_id INT, vessel_id INT, delivery_time INT); | What is the average delivery time for each vessel? | SELECT V.vessel_name, AVG(delivery_time) AS avg_delivery_time FROM deliveries D JOIN vessels V ON D.vessel_id = V.vessel_id GROUP BY vessel_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE Sightings (Species VARCHAR(25), Ocean VARCHAR(25), Sightings INT); INSERT INTO Sightings (Species, Ocean, Sightings) VALUES ('Dolphin', 'Atlantic Ocean', 200), ('Sea Turtle', 'Atlantic Ocean', 150), ('Shark', 'Indian Ocean', 150), ('Whale', 'Pacific Ocean', 400); | Delete the record of 'Sea Turtle' sighting in the 'Atlantic Ocean'. | DELETE FROM Sightings WHERE Species = 'Sea Turtle' AND Ocean = 'Atlantic Ocean'; | gretelai_synthetic_text_to_sql |
CREATE TABLE WasteGeneration (Country VARCHAR(50), WasteQuantity INT); INSERT INTO WasteGeneration (Country, WasteQuantity) VALUES ('Japan', 20000), ('India', 30000), ('China', 50000), ('Indonesia', 15000), ('Vietnam', 10000); | What are the total waste generation metrics for each country in the Asia region, excluding China? | SELECT Country, SUM(WasteQuantity) FROM WasteGeneration WHERE Region = 'Asia' AND Country != 'China' GROUP BY Country; | gretelai_synthetic_text_to_sql |
CREATE TABLE companies (id INT, name TEXT, industry TEXT, founders_underrepresented_communities BOOLEAN, founding_date DATE); | How many companies were founded by people from underrepresented communities in the healthcare sector in 2019? | SELECT COUNT(*) FROM companies WHERE founders_underrepresented_communities = true AND industry = 'healthcare' AND YEAR(founding_date) = 2019; | gretelai_synthetic_text_to_sql |
CREATE TABLE songs (id INT, title TEXT, release_date DATE, genre TEXT, artist_id INT, streams INT); INSERT INTO songs (id, title, release_date, genre, artist_id, streams) VALUES (1, 'Song1', '2022-01-01', 'Jazz', 1, 100000); INSERT INTO songs (id, title, release_date, genre, artist_id, streams) VALUES (2, 'Song2', '2022-01-02', 'Jazz', 2, 120000); CREATE TABLE artists (id INT, artist_name TEXT); | What is the average number of streams per day for each artist in the Jazz genre? | SELECT artist_id, AVG(streams/NULLIF(DATEDIFF(day, release_date, LEAD(release_date) OVER (PARTITION BY artist_id ORDER BY release_date)),0)) AS avg_daily_streams FROM songs WHERE genre = 'Jazz'; | gretelai_synthetic_text_to_sql |
CREATE TABLE PoliceDepartment (id INT, name VARCHAR(50), city_id INT, type VARCHAR(50)); INSERT INTO PoliceDepartment (id, name, city_id, type) VALUES (1, 'Los Angeles PD', 3, 'Police'); INSERT INTO PoliceDepartment (id, name, city_id, type) VALUES (2, 'San Francisco PD', 4, 'Police'); INSERT INTO PoliceDepartment (id, name, city_id, type) VALUES (3, 'Oakland PD', 5, 'Police'); CREATE TABLE Budget (id INT, agency_id INT, year INT, amount INT); INSERT INTO Budget (id, agency_id, year, amount) VALUES (1, 1, 2020, 500000); INSERT INTO Budget (id, agency_id, year, amount) VALUES (2, 2, 2020, 450000); INSERT INTO Budget (id, agency_id, year, amount) VALUES (3, 1, 2021, 550000); INSERT INTO Budget (id, agency_id, year, amount) VALUES (4, 2, 2021, 475000); INSERT INTO Budget (id, agency_id, year, amount) VALUES (5, 3, 2021, 350000); | What is the total budget for each police department in 2021? | SELECT PoliceDepartment.name, SUM(Budget.amount) FROM PoliceDepartment INNER JOIN Budget ON PoliceDepartment.id = Budget.agency_id WHERE PoliceDepartment.type = 'Police' AND Budget.year = 2021 GROUP BY PoliceDepartment.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE Faculty (FacultyID INT, Name VARCHAR(50), Department VARCHAR(50), Gender VARCHAR(10), GrantAmt FLOAT); | What is the maximum amount of research grants received by a faculty member in the Engineering department? | SELECT MAX(GrantAmt) FROM Faculty WHERE Department = 'Engineering'; | gretelai_synthetic_text_to_sql |
CREATE VIEW SustainableUrbanismView AS SELECT * FROM SustainableUrbanism WHERE state IN ('WA', 'TX'); | Drop the SustainableUrbanismView | DROP VIEW SustainableUrbanismView; | gretelai_synthetic_text_to_sql |
CREATE TABLE InfectiousDiseaseData (ID INT, DiseaseName TEXT, ReportDate DATE, Cases INT, County TEXT); INSERT INTO InfectiousDiseaseData (ID, DiseaseName, ReportDate, Cases, County) VALUES (1, 'Measles', '2019-12-31', 5, 'LA'), (2, 'Flu', '2020-02-01', 20, 'NY'); | delete records from the InfectiousDiseaseData table where the DiseaseName is 'Measles' and the ReportDate is before '2020-01-01' | DELETE FROM InfectiousDiseaseData WHERE DiseaseName = 'Measles' AND ReportDate < '2020-01-01'; | gretelai_synthetic_text_to_sql |
CREATE TABLE soccer_players (player_id INT, name VARCHAR(50), position VARCHAR(50), jersey_number INT); INSERT INTO soccer_players (player_id, name, position, jersey_number) VALUES (1, 'Sarah Johnson', 'Forward', 9), (2, 'Robert Brown', 'Midfielder', 8), (3, 'Emily White', 'Defender', 5); | Update the jersey number of a specific soccer player in the soccer_players table | UPDATE soccer_players SET jersey_number = 7 WHERE player_id = 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE Prices (hotel_id INT, ota TEXT, city TEXT, hotel_class TEXT, price_per_night FLOAT); INSERT INTO Prices (hotel_id, ota, city, hotel_class, price_per_night) VALUES (1, 'Agoda', 'Rome', 'luxury', 200), (2, 'Agoda', 'Rome', 'luxury', 220), (3, 'Agoda', 'Rome', 'non-luxury', 150); | What is the average price per night for 'luxury' hotels in 'Rome' on 'Agoda'? | SELECT AVG(price_per_night) FROM Prices WHERE ota = 'Agoda' AND city = 'Rome' AND hotel_class = 'luxury'; | gretelai_synthetic_text_to_sql |
CREATE TABLE vessels (vessel_name TEXT, last_inspection_date DATE); CREATE TABLE safety_violations (vessel_name TEXT, violation_date DATE); INSERT INTO vessels (vessel_name, last_inspection_date) VALUES ('Ocean Titan', '2022-01-01'), ('Sea Serpent', '2022-06-15'); INSERT INTO safety_violations (vessel_name, violation_date) VALUES ('Ocean Titan', '2022-05-01'), ('Sea Serpent', '2022-07-01'); | List all vessels with maritime safety violations in the last 6 months. | SELECT vessels.vessel_name FROM vessels INNER JOIN safety_violations ON vessels.vessel_name = safety_violations.vessel_name WHERE safety_violations.violation_date >= vessels.last_inspection_date AND vessels.last_inspection_date >= DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH); | gretelai_synthetic_text_to_sql |
CREATE TABLE workout_sessions (workout_id INT, user_id INT, duration INT, avg_heart_rate INT); | Find the total duration and average heart rate for each workout session of user 0001 | SELECT user_id, SUM(duration) as total_duration, AVG(avg_heart_rate) as avg_heart_rate FROM workout_sessions WHERE user_id = 0001 GROUP BY user_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE Trips (Year INT, Quarter INT, Service TEXT, Trips INT); INSERT INTO Trips (Year, Quarter, Service, Trips) VALUES (2022, 1, 'Bus', 12000), (2022, 1, 'Train', 15000), (2022, 1, 'Subway', 18000); | How many public transportation trips were taken in the first quarter of 2022, by service type? | SELECT Service, SUM(Trips) FROM Trips WHERE Year = 2022 AND Quarter = 1 GROUP BY Service; | gretelai_synthetic_text_to_sql |
CREATE TABLE employees (id INT, name VARCHAR(50), department VARCHAR(50)); INSERT INTO employees (id, name, department) VALUES (1, 'John Doe', 'Compliance'), (2, 'Jane Smith', 'Risk Management'); CREATE TABLE transactions (employee_id INT, transaction_amount DECIMAL(10,2)); INSERT INTO transactions (employee_id, transaction_amount) VALUES (1, 200.00), (1, 300.00), (2, 100.00), (2, 400.00); | What is the total transaction amount for each employee in the Compliance department? | SELECT e.name, SUM(t.transaction_amount) as total_transaction_amount FROM employees e JOIN transactions t ON e.id = t.employee_id WHERE e.department = 'Compliance' GROUP BY e.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE brands (brand_id INT, uses_sustainable_materials BOOLEAN);CREATE TABLE market_share (brand_id INT, market_share DECIMAL(10,2)); | What is the market share of brands that use sustainable materials in their products? | SELECT brand_id, market_share FROM market_share WHERE brand_id IN (SELECT brand_id FROM brands WHERE uses_sustainable_materials = TRUE); | gretelai_synthetic_text_to_sql |
CREATE TABLE city (id INT, name VARCHAR(255)); INSERT INTO city (id, name) VALUES (1, 'New York'); CREATE TABLE restaurant_inspections (id INT, restaurant_id INT, inspection_date DATE, rating VARCHAR(1)); | List all inspections for restaurants with 'A' rating in 'New York' | SELECT r.name, i.inspection_date, i.rating FROM restaurant_inspections i JOIN restaurant r ON i.restaurant_id = r.id JOIN city c ON r.city_id = c.id WHERE c.name = 'New York' AND i.rating = 'A'; | gretelai_synthetic_text_to_sql |
CREATE TABLE faculty (id INT, gender TEXT, publications INT); | What is the average number of publications per faculty member by gender? | SELECT f.gender, AVG(f.publications) FROM faculty f GROUP BY f.gender; | gretelai_synthetic_text_to_sql |
CREATE TABLE campaigns (id INT, patient_id INT, participation BOOLEAN); | How many patients have participated in public awareness campaigns? | SELECT COUNT(*) FROM campaigns WHERE participation = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE lab_data (id INT, lab_name TEXT, country TEXT, genes INT, sequencing_cost FLOAT); INSERT INTO lab_data (id, lab_name, country, genes, sequencing_cost) VALUES (1, 'LabA', 'Canada', 300, 45000.0), (2, 'LabB', 'Canada', 400, 50000.0), (3, 'LabC', 'USA', 250, 60000.0); | Identify the total number of genes and average sequencing cost for each lab in Canada. | SELECT lab_name, COUNT(genes) as total_genes, AVG(sequencing_cost) as avg_sequencing_cost FROM lab_data WHERE country = 'Canada' GROUP BY lab_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE animal_population (year INT, animal_name VARCHAR(255), population INT, region VARCHAR(255)); INSERT INTO animal_population (year, animal_name, population, region) VALUES (2019, 'Tiger', 200, 'Asia'), (2020, 'Tiger', 180, 'Asia'), (2021, 'Tiger', 160, 'Asia'), (2019, 'Elephant', 300, 'Africa'), (2020, 'Elephant', 280, 'Africa'), (2021, 'Elephant', 260, 'Africa'), (2019, 'Crane', 150, 'Asia'), (2020, 'Crane', 140, 'Asia'), (2021, 'Crane', 130, 'Asia'); | List animal populations with decreasing trends in Asian regions over the last 3 years | SELECT animal_name, population, LAG(population) OVER (PARTITION BY animal_name ORDER BY year) as previous_population FROM animal_population WHERE year > 2019 AND region = 'Asia' AND population < previous_population; | gretelai_synthetic_text_to_sql |
CREATE TABLE fairness_scores (model_id INT, model_type VARCHAR(20), fairness_score INT); INSERT INTO fairness_scores (model_id, model_type, fairness_score) VALUES (1, 'Generative', 90), (2, 'Transformer', 88), (3, 'Reinforcement', 92), (4, 'Generative2', 85); | What is the maximum fairness score for each AI model, ordered by fairness score in descending order? | SELECT model_type, fairness_score FROM fairness_scores WHERE fairness_score = (SELECT MAX(fairness_score) FROM fairness_scores) ORDER BY fairness_score DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE salaries (id INT, name VARCHAR(50), salary INT, department VARCHAR(20)); INSERT INTO salaries (id, name, salary, department) VALUES (1, 'Anna Smith', 70000, 'News'), (2, 'John Doe', 75000, 'News'), (3, 'Sara Connor', 60000, 'News'); | Find the names and salaries of employees who earn more than the average salary in the "salaries" table. | SELECT name, salary FROM salaries WHERE salary > (SELECT AVG(salary) FROM salaries); | gretelai_synthetic_text_to_sql |
CREATE TABLE physician (physician_id INT, name VARCHAR(50), specialty VARCHAR(30)); CREATE TABLE visit (visit_id INT, physician_id INT, rural BOOLEAN); | What is the name of the specialist who treats the most rural patients? | SELECT physician.name FROM physician JOIN (SELECT physician_id FROM visit WHERE rural = TRUE GROUP BY physician_id ORDER BY COUNT(*) DESC LIMIT 1) AS subquery ON physician.physician_id = subquery.physician_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE species_research (id INT, species_id INT, year INT, location VARCHAR(50), observations INT); INSERT INTO species_research (id, species_id, year, location, observations) VALUES (1, 1, 2015, 'Arctic', 350), (2, 1, 2016, 'Antarctic', 400), (3, 2, 2016, 'Arctic', 500); | How many total observations were made in 2016? | SELECT SUM(observations) FROM species_research WHERE year = 2016; | gretelai_synthetic_text_to_sql |
CREATE TABLE employees (employee_id INT, department VARCHAR(255), salary INT); INSERT INTO employees (employee_id, department, salary) VALUES (1, 'Finance', 50000), (2, 'HR', 60000), (3, 'Finance', 55000), (4, 'Finance', 70000); CREATE TABLE training_programs (program_id INT, department VARCHAR(255)); INSERT INTO training_programs (program_id, department) VALUES (1, 'IT'), (2, 'HR'), (3, 'Finance'); CREATE TABLE completed_training (employee_id INT, program_id INT); INSERT INTO completed_training (employee_id, program_id) VALUES (1, 3), (2, 2), (3, 3); | What is the minimum salary for employees who have completed training programs in the Finance department? | SELECT MIN(salary) FROM employees e JOIN completed_training ct ON e.employee_id = ct.employee_id JOIN training_programs tp ON ct.program_id = tp.program_id WHERE e.department = 'Finance'; | gretelai_synthetic_text_to_sql |
CREATE TABLE species_counts (id INT, type TEXT, species_count INT); INSERT INTO species_counts (id, type, species_count) VALUES (1, 'Trench', 50), (2, 'Abyssal', 75), (3, 'Trench', 30); | What is the percentage of marine species in each type of marine life zone? | SELECT type, ROUND(100.0 * species_count / SUM(species_count) OVER (), 2) AS percentage FROM species_counts; | gretelai_synthetic_text_to_sql |
CREATE TABLE WasteGeneration (year INT, sector VARCHAR(20), amount INT); INSERT INTO WasteGeneration (year, sector, amount) VALUES (2018, 'residential', 5000), (2018, 'commercial', 7000), (2019, 'residential', NULL), (2019, 'commercial', NULL), (2020, 'residential', 6000), (2020, 'commercial', 8000); | What was the total waste generation in the residential sector in 2019? | SELECT amount FROM WasteGeneration WHERE year = 2019 AND sector = 'residential'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Concerts (id INT, state VARCHAR(20), sold_out BOOLEAN); INSERT INTO Concerts (id, state, sold_out) VALUES (1, 'Texas', TRUE), (2, 'Texas', FALSE); | How many concerts were sold out in Texas? | SELECT COUNT(*) FROM Concerts WHERE state = 'Texas' AND sold_out = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE hospitals (id INT, name TEXT, state TEXT); INSERT INTO hospitals (id, name, state) VALUES (1, 'Hospital A', 'California'), (2, 'Hospital B', 'Texas'); CREATE TABLE patients (id INT, name TEXT, age INT, hospital_id INT); INSERT INTO patients (id, name, age, hospital_id) VALUES (1, 'John Doe', 65, 1), (2, 'Jane Smith', 45, 1), (3, 'Bob Johnson', 35, 2); | How many patients are there in each hospital, and what is the average age of those patients? | SELECT hospitals.name, COUNT(patients.id), AVG(patients.age) FROM patients INNER JOIN hospitals ON patients.hospital_id = hospitals.id GROUP BY hospitals.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE donations (id INT, donor_id INT, donation_amount DECIMAL(10,2), donation_date DATE); INSERT INTO donations (id, donor_id, donation_amount, donation_date) VALUES (1, 1, 50.00, '2020-01-01'); INSERT INTO donations (id, donor_id, donation_amount, donation_date) VALUES (2, 2, 75.00, '2020-02-15'); | What was the average donation amount per month in 2020, for donors from the United Kingdom? | SELECT AVG(donation_amount) FROM donations WHERE EXTRACT(YEAR FROM donation_date) = 2020 AND EXTRACT(MONTH FROM donation_date) BETWEEN 1 AND 12 AND donor_id IN (SELECT id FROM donors WHERE country = 'UK'); | gretelai_synthetic_text_to_sql |
CREATE TABLE TraditionalArts (Region VARCHAR(50), Budget DECIMAL(10,2)); INSERT INTO TraditionalArts (Region, Budget) VALUES ('North America', 750000), ('South America', 600000); | What is the total budget allocated for traditional arts programs in North and South America? | SELECT SUM(Budget) FROM TraditionalArts WHERE Region IN ('North America', 'South America'); | gretelai_synthetic_text_to_sql |
CREATE TABLE artists (id INT, name VARCHAR(50)); INSERT INTO artists (id, name) VALUES (1, 'Jane Smith'), (2, 'John Smith'), (3, 'Jim Smith'); | Update the artist name 'John Smith' to 'Jon Smith'. | UPDATE artists SET name = 'Jon Smith' WHERE id = 2; | gretelai_synthetic_text_to_sql |
CREATE TABLE hotel_tech (hotel_id INT, hotel_name TEXT, country TEXT, chatbot BOOLEAN); | What is the total number of hotels in the APAC region that adopted AI chatbots? | SELECT COUNT(*) FROM hotel_tech WHERE country IN ('China', 'Japan', 'South Korea', 'India', 'Australia') AND chatbot = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE City (id INT PRIMARY KEY, country_id INT, name VARCHAR(100), population INT, latitude DECIMAL(10,8), longitude DECIMAL(11,8)); INSERT INTO City (id, country_id, name, population, latitude, longitude) VALUES (1, 1, 'Nairobi', 4000000, 34.0522, -118.2437); | What are the names and populations of cities in Africa with a population greater than the average city population in their respective countries? | SELECT c.name, c.population FROM City c INNER JOIN Country ct ON c.country_id = ct.id WHERE ct.continent = 'Africa' AND c.population > (SELECT AVG(population) FROM City WHERE country_id = c.country_id); | gretelai_synthetic_text_to_sql |
CREATE TABLE Concerts (id INT, genre VARCHAR(20), price DECIMAL(5,2)); INSERT INTO Concerts (id, genre, price) VALUES (1, 'Blues', 150.00), (2, 'Jazz', 100.00), (3, 'Blues', 200.00); | What is the maximum ticket price for Blues concerts in June? | SELECT MAX(price) FROM Concerts WHERE genre = 'Blues' AND date BETWEEN '2022-06-01' AND '2022-06-30'; | gretelai_synthetic_text_to_sql |
CREATE TABLE community_health_workers (worker_id INT, name VARCHAR(50), state VARCHAR(2), training VARCHAR(50)); INSERT INTO community_health_workers (worker_id, name, state, training) VALUES (1, 'Jane Doe', 'NY', 'Cultural Competency'), (2, 'John Smith', 'CA', 'Cultural Competency'), (3, 'Maria Garcia', 'TX', 'Cultural Competency'); | What is the total number of community health workers who have received cultural competency training in each state? | SELECT state, COUNT(*) FROM community_health_workers WHERE training = 'Cultural Competency' GROUP BY state; | gretelai_synthetic_text_to_sql |
CREATE TABLE TBData (Year INT, Region VARCHAR(20), Cases INT); INSERT INTO TBData (Year, Region, Cases) VALUES (2019, 'Southeast Asia', 15000); INSERT INTO TBData (Year, Region, Cases) VALUES (2017, 'Europe', 10000); | How many Tuberculosis cases were reported in Southeast Asia in 2019? | SELECT SUM(Cases) FROM TBData WHERE Region = 'Southeast Asia' AND Year = 2019; | gretelai_synthetic_text_to_sql |
CREATE TABLE climate_finance (project_id INT, project_name TEXT, location TEXT, funded_year INT, funding_amount FLOAT); INSERT INTO climate_finance (project_id, project_name, location, funded_year, funding_amount) VALUES (1, 'Mitigation 1', 'Nigeria', 2015, 6000000.0), (2, 'Adaptation 1', 'Egypt', 2012, 8000000.0), (3, 'Communication 1', 'South Africa', 2018, 4000000.0); | What is the average funding per climate adaptation project in Africa since 2010? | SELECT AVG(funding_amount) FROM climate_finance WHERE funded_year >= 2010 AND project_type = 'climate adaptation' AND location LIKE 'Africa%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE co2_emissions (emission_id INT, garment_category VARCHAR(30), year INT, co2_emission DECIMAL(10,2)); | What is the CO2 emission per garment category in 2022? | SELECT garment_category, AVG(co2_emission) AS avg_co2_emission FROM co2_emissions WHERE year = 2022 GROUP BY garment_category; | gretelai_synthetic_text_to_sql |
CREATE TABLE landfill_capacity(city VARCHAR(20), year INT, population INT, capacity FLOAT); INSERT INTO landfill_capacity(city, year, population, capacity) VALUES ('Tokyo', 2020, 37, 18500000), ('Delhi', 2020, 30, 15000000), ('Shanghai', 2020, 26, 20000000), ('Mumbai', 2020, 21, 12000000), ('Beijing', 2020, 21, 19000000), ('Shenzhen', 2020, 17, 8000000), ('Bangkok', 2020, 10, 7000000), ('Seoul', 2020, 10, 9000000), ('Jakarta', 2020, 10, 6000000), ('Manila', 2020, 9, 5000000); | What is the maximum landfill capacity in cubic meters for the year 2020 for cities in Asia with a population greater than 5 million? | SELECT MAX(capacity) FROM landfill_capacity WHERE year = 2020 AND population > 5000000 GROUP BY year; | gretelai_synthetic_text_to_sql |
CREATE TABLE green_building_certifications (id INT, name VARCHAR(255), region VARCHAR(255)); | How many green building certifications are in Europe? | SELECT COUNT(*) FROM green_building_certifications WHERE region = 'Europe'; | gretelai_synthetic_text_to_sql |
CREATE TABLE attorneys (id INT, name TEXT); INSERT INTO attorneys (id, name) VALUES (1, 'Johnny Cochran'), (2, 'Denny Crane'); CREATE TABLE cases (id INT, attorney_id INT, result TEXT); INSERT INTO cases (id, attorney_id, result) VALUES (1, 1, 'won'), (2, 1, 'lost'), (3, 2, 'won'); | How many cases were there in total for each attorney? | SELECT attorneys.name, COUNT(cases.id) FROM attorneys LEFT JOIN cases ON attorneys.id = cases.attorney_id GROUP BY attorneys.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE Refugees (RefugeeID INT, FirstName VARCHAR(50), LastName VARCHAR(50), Gender VARCHAR(10)); INSERT INTO Refugees (RefugeeID, FirstName, LastName, Gender) VALUES (1, 'John', 'Doe', 'Male'), (2, 'Jane', 'Doe', 'Female'); | List the top 3 most common last names for refugees by gender? | SELECT LastName, Gender, ROW_NUMBER() OVER (PARTITION BY Gender ORDER BY COUNT(*) DESC) as Rank FROM Refugees GROUP BY LastName, Gender HAVING COUNT(*) > 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE Practice_Timber_Production (Practice VARCHAR(50), Year INT, Volume FLOAT); INSERT INTO Practice_Timber_Production (Practice, Year, Volume) VALUES ('Practice1', 2005, 150), ('Practice1', 2010, 180), ('Practice2', 2005, 200), ('Practice2', 2010, 250); | What is the total volume of timber produced by each practice? | SELECT Practice, SUM(Volume) FROM Practice_Timber_Production GROUP BY Practice; | gretelai_synthetic_text_to_sql |
CREATE TABLE donors (id INT, name VARCHAR(50), ethnicity VARCHAR(50), state VARCHAR(50)); CREATE TABLE donations (id INT, donor_id INT, amount DECIMAL(10,2)); INSERT INTO donors (id, name, ethnicity, state) VALUES (1, 'Le Thi', 'Vietnamese', 'California'), (2, 'Kim Lee', 'Korean', 'New York'), (3, 'Juan Garcia', 'Mexican', 'Texas'); INSERT INTO donations (id, donor_id, amount) VALUES (1, 1, 100.00), (2, 1, 200.00), (3, 2, 50.00), (4, 3, 75.00); | What is the average donation in the Asian demographic? | SELECT AVG(d.amount) FROM donations d INNER JOIN donors dd ON d.donor_id = dd.id WHERE dd.ethnicity LIKE 'Asian%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE spacecraft(id INT, name VARCHAR(50), manufacturer VARCHAR(50), mass FLOAT, manufacture_year INT); INSERT INTO spacecraft VALUES(1, 'Artemis 1', 'Cosmic Corp.', 25000., 2022), (2, 'Artemis 2', 'Cosmic Corp.', 26000., 2023); | What is the total mass of spacecraft manufactured by 'Cosmic Corp.' in 2022? | SELECT SUM(mass) FROM spacecraft WHERE manufacturer = 'Cosmic Corp.' AND manufacture_year = 2022; | gretelai_synthetic_text_to_sql |
CREATE TABLE posts (id INT, user_id INT, content TEXT, hashtags TEXT, post_date DATE); INSERT INTO posts (id, user_id, content, hashtags, post_date) VALUES (1, 1, 'Hello World', '#datascience', '2022-06-01'), (2, 1, 'I love data', '#ai', '2022-06-02'), (3, 2, 'Namaste', '#india', '2022-06-03'); CREATE TABLE users (id INT, name VARCHAR(100), country VARCHAR(50)); INSERT INTO users (id, name, country) VALUES (1, 'Akshay', 'India'), (2, 'Bhavna', 'India'); | What is the most common hashtag used in posts made by users from India? | SELECT SUBSTRING_INDEX(SUBSTRING_INDEX(hashtags, ' ', n.n), ' ', -1) hashtag, COUNT(*) count FROM posts JOIN users ON posts.user_id = users.id CROSS JOIN (SELECT 1 n UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5) n WHERE users.country = 'India' GROUP BY hashtag ORDER BY count DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE NeodymiumProduction (Miner VARCHAR(50), Year INT, Production FLOAT); INSERT INTO NeodymiumProduction(Miner, Year, Production) VALUES ('MinerA', 2017, 521.3), ('MinerA', 2018, 550.7), ('MinerA', 2019, 582.1), ('MinerB', 2017, 463.9), ('MinerB', 2018, 481.5), ('MinerB', 2019, 503.8), ('MinerC', 2017, 604.4), ('MinerC', 2018, 622.2), ('MinerC', 2019, 639.6); | What is the average annual neodymium production for each miner from 2017 to 2019? | SELECT Miner, AVG(Production) as Avg_Production FROM NeodymiumProduction WHERE Year IN (2017, 2018, 2019) GROUP BY Miner; | gretelai_synthetic_text_to_sql |
CREATE TABLE public_parks (park_id INT, park_name TEXT, city TEXT, state TEXT, area INT, budget INT); INSERT INTO public_parks (park_id, park_name, city, state, area, budget) VALUES (1, 'Griffith Park', 'Los Angeles', 'California', 4100, 5000000); INSERT INTO public_parks (park_id, park_name, city, state, area, budget) VALUES (2, 'Elysian Park', 'Los Angeles', 'California', 600, 2000000); INSERT INTO public_parks (park_id, park_name, city, state, area, budget) VALUES (3, 'Runyon Canyon Park', 'Los Angeles', 'California', 160, 1500000); | What is the total budget allocated for public parks in Los Angeles, excluding the parks with an area smaller than 100 acres? | SELECT SUM(budget) FROM public_parks WHERE city = 'Los Angeles' AND area >= 100; | gretelai_synthetic_text_to_sql |
CREATE TABLE Suppliers (id INT, name TEXT, region TEXT); | Insert new record for supplier 'Fair Trade Supplier' in 'Seattle' region | INSERT INTO Suppliers (id, name, region) VALUES ((SELECT COALESCE(MAX(id), 0) + 1 FROM Suppliers), 'Fair Trade Supplier', 'Seattle'); | gretelai_synthetic_text_to_sql |
CREATE TABLE representatives (id INT PRIMARY KEY, first_name VARCHAR(255), last_name VARCHAR(255), state VARCHAR(255));CREATE TABLE bills (id INT PRIMARY KEY, title VARCHAR(255), sponsor_id INT, FOREIGN KEY (sponsor_id) REFERENCES representatives(id)); INSERT INTO representatives (id, first_name, last_name, state) VALUES (1, 'John', 'Smith', 'Texas'); INSERT INTO representatives (id, first_name, last_name, state) VALUES (2, 'Jane', 'Doe', 'California'); | List all the bills sponsored by representatives from Texas in the 'congress' database. | SELECT bills.title FROM bills INNER JOIN representatives ON bills.sponsor_id = representatives.id WHERE representatives.state = 'Texas'; | gretelai_synthetic_text_to_sql |
CREATE TABLE sales (drug_class TEXT, id INTEGER); CREATE TABLE drug_info (drug_class TEXT, drug_category TEXT); | Which CNS drugs had more than 500 sales records? | SELECT sales.drug_class FROM sales INNER JOIN drug_info ON sales.drug_class = drug_info.drug_class GROUP BY sales.drug_class HAVING COUNT(sales.id) > 500 WHERE drug_info.drug_category = 'CNS'; | gretelai_synthetic_text_to_sql |
CREATE TABLE athletes (athlete_id INT, name VARCHAR(50), gender VARCHAR(10), sport VARCHAR(50), age INT); INSERT INTO athletes (athlete_id, name, gender, sport, age) VALUES (1, 'Chris Tucker', 'Male', 'Basketball', 50), (2, 'Anna Wintour', 'Female', 'Tennis', 71), (3, 'Stephen Curry', 'Male', 'Basketball', 33); | What is the average age of female athletes who have participated in the NBA All-Star Celebrity Game? | SELECT AVG(age) FROM athletes WHERE gender = 'Female' AND sport = 'Basketball'; | gretelai_synthetic_text_to_sql |
CREATE TABLE open_pedagogy_projects (id INT PRIMARY KEY, project_id INT, title VARCHAR(255), description TEXT, submission_date DATE); | Insert records for 3 open pedagogy projects in the open_pedagogy_projects table | INSERT INTO open_pedagogy_projects (id, project_id, title, description, submission_date) VALUES (1, 301, 'Project 1', 'This is project 1 description.', '2021-01-15'), (2, 302, 'Project 2', 'This is project 2 description.', '2021-02-12'), (3, 303, 'Project 3', 'This is project 3 description.', '2021-03-18'); | gretelai_synthetic_text_to_sql |
CREATE TABLE Cheetahs (id INT, name VARCHAR(50), age INT, reserve VARCHAR(50), rehabilitated BOOLEAN); INSERT INTO Cheetahs (id, name, age, reserve, rehabilitated) VALUES (1, 'Cheetah1', 3, 'AfricanReserve', true), (2, 'Cheetah2', 5, 'AfricanReserve', false), (3, 'Cheetah3', 4, 'AsianReserve', true); | What is the minimum age of all cheetahs in the "AfricanReserve" that have been rehabilitated? | SELECT MIN(age) FROM Cheetahs WHERE rehabilitated = true AND reserve = 'AfricanReserve'; | gretelai_synthetic_text_to_sql |
CREATE TABLE teams (team_id INT, team_name VARCHAR(255)); INSERT INTO teams (team_id, team_name) VALUES (1, 'Royals'), (2, 'Stars'), (3, 'Hawks'); CREATE TABLE events (event_id INT, team_id INT, num_tickets_sold INT, total_seats INT); INSERT INTO events (event_id, team_id, num_tickets_sold, total_seats) VALUES (1, 1, 500, 1000), (2, 1, 700, 1000), (3, 2, 600, 1200), (4, 3, 800, 1500), (5, 3, 900, 1500); | What are the total ticket sales for each team's events, excluding events with less than 500 seats? | SELECT t.team_name, SUM(e.num_tickets_sold) as total_ticket_sales FROM teams t JOIN events e ON t.team_id = e.team_id WHERE e.total_seats >= 500 GROUP BY t.team_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE CaseDates (CaseID INT, Date DATE); INSERT INTO CaseDates (CaseID, Date) VALUES (1, '2022-01-01'), (2, '2022-02-01'), (3, '2022-03-01'); | How many cases were opened in January and February of 2022? | SELECT COUNT(*) FROM CaseDates WHERE DATE_FORMAT(CaseDates.Date, '%Y-%m') IN ('2022-01', '2022-02'); | gretelai_synthetic_text_to_sql |
CREATE TABLE travel_advisories (advisory_id INT, country TEXT, issue_date DATE); INSERT INTO travel_advisories (advisory_id, country, issue_date) VALUES (1, 'Canada', '2021-06-01'), (2, 'Mexico', '2021-07-01'), (3, 'Brazil', '2021-08-01'), (4, 'Argentina', '2021-09-01'), (5, 'United States', '2021-10-01'), (6, 'Canada', '2022-01-01'); | How many travel advisories have been issued for Canada in the last year? | SELECT COUNT(*) FROM travel_advisories WHERE country = 'Canada' AND issue_date >= DATE('now', '-1 year'); | gretelai_synthetic_text_to_sql |
CREATE TABLE ny_menu_items (menu_item_id INT, restaurant_id INT, dish_type VARCHAR(255), food_cost DECIMAL(5,2)); INSERT INTO ny_menu_items (menu_item_id, restaurant_id, dish_type, food_cost) VALUES (1, 1, 'Vegetarian', 3.50), (2, 2, 'Vegetarian', 4.50), (3, 3, 'Vegetarian', 5.50); | Which menu items have the highest food cost for vegetarian dishes in NY? | SELECT dish_type, MAX(food_cost) FROM ny_menu_items WHERE dish_type = 'Vegetarian' GROUP BY dish_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE SpaceMissions (mission_id INT, mission_name VARCHAR(50), launch_date DATE, accident BOOLEAN); INSERT INTO SpaceMissions (mission_id, mission_name, launch_date, accident) VALUES (1, 'MissionA', '2019-12-12', FALSE), (2, 'MissionB', '2020-03-15', TRUE), (3, 'MissionC', '2020-08-28', FALSE), (4, 'MissionD', '2021-06-01', FALSE); | List all the space missions that had accidents in the year 2020. | SELECT mission_name, launch_date FROM SpaceMissions WHERE EXTRACT(YEAR FROM launch_date) = 2020 AND accident = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE ProductIngredients (ProductID INT, Ingredient VARCHAR(50), Label VARCHAR(50)); INSERT INTO ProductIngredients (ProductID, Ingredient, Label) VALUES (201, 'Aloe Vera', 'Natural'), (202, 'Parabens', 'Synthetic'), (203, 'Shea Butter', 'Natural'), (204, 'Fragrance', 'Synthetic'), (205, 'Coconut Oil', 'Natural'); | What is the percentage of cosmetic products in the United Kingdom that have a 'natural' ingredient label? | SELECT (COUNT(*) * 100.0 / (SELECT COUNT(*) FROM ProductIngredients WHERE Country = 'UK')) AS Percentage FROM ProductIngredients WHERE Label = 'Natural' AND Country = 'UK'; | gretelai_synthetic_text_to_sql |
CREATE TABLE rural_innovation (id INT, project_name VARCHAR(255), sector VARCHAR(255), location VARCHAR(255), start_date DATE, end_date DATE); INSERT INTO rural_innovation (id, project_name, sector, location, start_date, end_date) VALUES (1, 'Precision Agriculture', 'Agriculture', 'Village A, Country W', '2020-01-01', '2022-12-31'); | List all agricultural innovation projects in 'rural_innovation' table for Country W? | SELECT * FROM rural_innovation WHERE location LIKE '%Country W%' AND sector = 'Agriculture'; | gretelai_synthetic_text_to_sql |
CREATE TABLE team_stats (team VARCHAR(50), wins INT, losses INT); | List the teams with their total wins and losses | INSERT INTO team_stats (team, wins, losses) SELECT t.team, SUM(CASE WHEN s.result = 'win' THEN 1 ELSE 0 END) AS wins, SUM(CASE WHEN s.result = 'loss' THEN 1 ELSE 0 END) AS losses FROM team_roster tr JOIN team_data t ON tr.team_id = t.team_id JOIN game_stats s ON tr.team_id = s.team_id GROUP BY t.team; | gretelai_synthetic_text_to_sql |
CREATE TABLE deep_sea_exploration (location VARCHAR(50), depth INT, date DATE); | Insert a new record in the table "deep_sea_exploration" with values 'Atlantic Ocean', 4000, '2022-03-01' | INSERT INTO deep_sea_exploration (location, depth, date) VALUES ('Atlantic Ocean', 4000, '2022-03-01'); | gretelai_synthetic_text_to_sql |
CREATE TABLE investors(id INT, name TEXT, type TEXT); CREATE VIEW seed_investors AS SELECT * FROM investors WHERE type = 'Seed Investor'; CREATE TABLE investments(id INT, investor_id INT, startup_id INT, investment_amount FLOAT); INSERT INTO investors (id, name, type) VALUES (1, 'Jamie Lee', 'Seed Investor'); INSERT INTO investors (id, name, type) VALUES (2, 'Jordan Cruz', 'VC'); INSERT INTO investors (id, name, type) VALUES (3, 'Kimberly Chen', 'Seed Investor'); INSERT INTO investments (id, investor_id, startup_id, investment_amount) VALUES (1, 1, 1, 250000); INSERT INTO investments (id, investor_id, startup_id, investment_amount) VALUES (2, 2, 3, 1000000); INSERT INTO investments (id, investor_id, startup_id, investment_amount) VALUES (3, 3, 2, 500000); | Show the maximum investment amount made by seed investors | SELECT MAX(investment_amount) FROM investments i JOIN seed_investors s ON i.investor_id = s.id; | gretelai_synthetic_text_to_sql |
CREATE TABLE Artworks (id INT, name VARCHAR(100), type VARCHAR(50), price DECIMAL(10,2)); INSERT INTO Artworks (id, name, type, price) VALUES (1, 'Sculpture 1', 'Sculpture', 1000.00), (2, 'Painting 2', 'Painting', 2000.00), (3, 'Sculpture 3', 'Sculpture', 1500.00); | Find the minimum price of a sculpture. | SELECT MIN(price) FROM Artworks WHERE type = 'Sculpture'; | gretelai_synthetic_text_to_sql |
CREATE TABLE zambia_districts (id INT, name VARCHAR(255)); CREATE TABLE malaria_cases (id INT, district_id INT, cases INT); INSERT INTO zambia_districts (id, name) VALUES (1, 'Lusaka'), (2, 'Copperbelt'), (3, 'Northern'), (4, 'Muchinga'), (5, 'Luapula'); | What is the number of malaria cases reported in each district of Zambia? | SELECT d.name, SUM(m.cases) FROM malaria_cases m JOIN zambia_districts d ON m.district_id = d.id GROUP BY d.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE GarmentCategories (CategoryID INT, CategoryName VARCHAR(50), AverageSustainabilityRating INT); | Update the sustainability rating of a specific category of garments. | UPDATE GarmentCategories SET AverageSustainabilityRating = 8 WHERE CategoryName = 'Tops'; | gretelai_synthetic_text_to_sql |
CREATE TABLE dallas_ambulance_responses (id INT, response_time INT, location VARCHAR(20)); INSERT INTO dallas_ambulance_responses (id, response_time, location) VALUES (1, 180, 'Dallas'), (2, 150, 'Dallas'); | What is the average response time for ambulances in Dallas? | SELECT AVG(response_time) FROM dallas_ambulance_responses WHERE location = 'Dallas'; | gretelai_synthetic_text_to_sql |
CREATE TABLE MilitaryExpenditure(id INT PRIMARY KEY, country VARCHAR(50), expenditure INT, year INT);INSERT INTO MilitaryExpenditure(id, country, expenditure, year) VALUES (1, 'USA', 770, 2021), (2, 'China', 260, 2021), (3, 'Russia', 65, 2021); | Who are the top 3 countries with the highest military technology expenditure in 2021? | SELECT country, expenditure FROM MilitaryExpenditure WHERE year = 2021 ORDER BY expenditure DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE ProjectTimeline (TimelineID INT, Practice TEXT, State TEXT, Duration INT); INSERT INTO ProjectTimeline VALUES (1, 'Green Roofs', 'California', 90), (2, 'Solar Panels', 'California', 120), (3, 'Insulation', 'California', 60); | What is the maximum project timeline for sustainable building practices in California? | SELECT MAX(Duration) FROM ProjectTimeline WHERE Practice = 'Green Roofs' AND State = 'California'; | gretelai_synthetic_text_to_sql |
CREATE TABLE teams (team_id INT, team_name VARCHAR(255)); CREATE TABLE games (game_id INT, team_id INT, stadium_id INT); CREATE TABLE attendance (attendance_id INT, game_id INT, total_attendance INT); | Calculate the average attendance for each team, ordered from highest to lowest from the teams, games, and attendance tables. | SELECT t.team_name, AVG(a.total_attendance) AS avg_attendance FROM teams t JOIN games g ON t.team_id = g.team_id JOIN attendance a ON g.game_id = a.game_id GROUP BY t.team_name ORDER BY avg_attendance DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE resources (id INT, resource_name VARCHAR(255)); INSERT INTO resources (id, resource_name) VALUES (1, 'Resource A'), (2, 'Resource B'), (3, 'Resource C'); CREATE TABLE resource_depletion (id INT, operation_id INT, resource_id INT, depletion INT); INSERT INTO resource_depletion (id, operation_id, resource_id, depletion) VALUES (1, 1, 1, 20), (2, 1, 2, 30), (3, 2, 1, 15), (4, 2, 3, 25), (5, 3, 2, 10), (6, 3, 3, 18); | What is the total resource depletion for each mining operation? | SELECT o.operation_name, r.resource_name, SUM(rd.depletion) as total_depletion FROM mining_operations o INNER JOIN resource_depletion rd ON o.id = rd.operation_id INNER JOIN resources r ON rd.resource_id = r.id GROUP BY o.id, r.id; | gretelai_synthetic_text_to_sql |
CREATE TABLE chemical_storage_units (id INT, temperature FLOAT, last_inspection DATE); | What is the average temperature reading for all chemical storage units in the past month? | SELECT AVG(temperature) FROM chemical_storage_units WHERE last_inspection >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH); | gretelai_synthetic_text_to_sql |
CREATE TABLE tv_shows (title VARCHAR(255), genre VARCHAR(50), rating DECIMAL(3,2)); | Find the top 5 genres with the highest average rating of TV shows. | SELECT genre, AVG(rating) FROM tv_shows GROUP BY genre ORDER BY AVG(rating) DESC LIMIT 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE hepatitis_tests (id INT, patient_id INT, test_date DATE); CREATE VIEW hepatitis_c_tests AS SELECT * FROM hepatitis_tests WHERE test_type = 'Hepatitis C'; | How many people have been tested for Hepatitis C in 2020? | SELECT COUNT(*) FROM hepatitis_c_tests WHERE YEAR(test_date) = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE founders (id INT, name TEXT, company_id INT); INSERT INTO founders (id, name, company_id) VALUES (1, 'Alice', 1), (2, 'Bob', 1), (3, 'Charlie', 2), (4, 'David', 2), (5, 'Eve', 3); CREATE TABLE teams (id INT, founder_id INT, gender TEXT, ethnicity TEXT); INSERT INTO teams (id, founder_id, gender, ethnicity) VALUES (1, 1, 'Female', 'Asian'), (2, 1, 'Male', 'Hispanic'), (3, 2, 'Male', 'African'), (4, 3, 'Female', 'Caucasian'), (5, 4, 'Female', 'Asian'), (6, 5, 'Non-binary', 'African'); | Who are the top 3 founders with the most diverse teams? | SELECT founder_id, COUNT(DISTINCT gender) as num_genders, COUNT(DISTINCT ethnicity) as num_ethnicities FROM teams GROUP BY founder_id ORDER BY num_genders + num_ethnicities DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE sf_buses (id INT, trip_duration INT, is_wheelchair_accessible BOOLEAN); INSERT INTO sf_buses (id, trip_duration, is_wheelchair_accessible) VALUES (1, 30, TRUE), (2, 25, FALSE); | What is the average trip duration for wheelchair-accessible bus rides in San Francisco? | SELECT AVG(trip_duration) FROM sf_buses WHERE is_wheelchair_accessible = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE veteran_employment (employment_id INT, employment_date DATE, state VARCHAR(255), employment_rate FLOAT); INSERT INTO veteran_employment (employment_id, employment_date, state, employment_rate) VALUES (4, '2020-12-31', 'Texas', 75.3), (5, '2021-04-04', 'California', 70.1), (6, '2022-06-15', 'Texas', 72.5); | Find the average veteran employment rate in Texas for the last 2 years. | SELECT AVG(employment_rate) FROM veteran_employment WHERE state = 'Texas' AND employment_date >= DATE_SUB(CURRENT_DATE, INTERVAL 2 YEAR); | gretelai_synthetic_text_to_sql |
CREATE TABLE students (id INT, name VARCHAR(50), department VARCHAR(50)); CREATE TABLE papers (id INT, student_id INT, title VARCHAR(100)); INSERT INTO students VALUES (1, 'Judy', 'Education'), (2, 'Kevin', 'Education'), (3, 'Lara', 'Education'); INSERT INTO papers VALUES (1, 1, 'Paper with inclusion'), (2, 1, 'Paper without inclusion'), (3, 2, 'Another paper with inclusion'), (4, 3, 'Paper without inclusion'); | List the graduate students in the College of Education who have published papers with the word 'inclusion' in the title. | SELECT students.id, students.name FROM students INNER JOIN papers ON students.id = papers.student_id WHERE title LIKE '%inclusion%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE CrimeStats (id INT, crimeType VARCHAR(20), number INT); | What are the total numbers of crimes reported for both 'Theft' and 'Vandalism' categories in the 'CrimeStats' table? | SELECT SUM(number) FROM CrimeStats WHERE crimeType IN ('Theft', 'Vandalism'); | gretelai_synthetic_text_to_sql |
CREATE TABLE movies (id INT, title VARCHAR(255), release_year INT, production_budget DECIMAL(10,2), genre VARCHAR(100), viewership INT); | What's the viewership trend for action movies over the last decade? | SELECT release_year, AVG(viewership) as avg_viewership FROM movies WHERE genre = 'action' GROUP BY release_year ORDER BY release_year DESC LIMIT 10; | gretelai_synthetic_text_to_sql |
CREATE TABLE defense_diplomacy (id INT PRIMARY KEY, event_name VARCHAR(50), event_type VARCHAR(50), country VARCHAR(50)); INSERT INTO defense_diplomacy (id, event_name, event_type, country) VALUES (7, 'Military Exercise', 'Joint Operations', 'Brazil'), (8, 'Defense Summit', 'Political', 'Brazil'); | Insert new records of defense diplomacy events for a specific country in the defense_diplomacy table. | INSERT INTO defense_diplomacy (id, event_name, event_type, country) VALUES (7, 'Military Exercise', 'Joint Operations', 'Brazil'), (8, 'Defense Summit', 'Political', 'Brazil'); | gretelai_synthetic_text_to_sql |
CREATE TABLE BrandSales (sale_id INT, brand TEXT, sale_amount FLOAT, sale_date DATE, country TEXT); INSERT INTO BrandSales (sale_id, brand, sale_amount, sale_date, country) VALUES (1, 'Brand X', 100.00, '2021-03-25', 'India'); INSERT INTO BrandSales (sale_id, brand, sale_amount, sale_date, country) VALUES (2, 'Brand Y', 120.00, '2021-04-10', 'Australia'); INSERT INTO BrandSales (sale_id, brand, sale_amount, sale_date, country) VALUES (3, 'Brand Z', 80.00, '2021-05-15', 'India'); | List the top 3 beauty brands by total sales in India and Australia in 2021 | SELECT brand, SUM(sale_amount) AS total_sales FROM BrandSales WHERE country IN ('India', 'Australia') AND YEAR(sale_date) = 2021 GROUP BY brand ORDER BY total_sales DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE highways (highway_id INT PRIMARY KEY, highway_name VARCHAR(100), number_of_lanes INT, country VARCHAR(50)); | List the names and number of lanes of all highways in 'highways' table | SELECT highway_name, number_of_lanes FROM highways; | gretelai_synthetic_text_to_sql |
CREATE TABLE Warehouse (id INT, city VARCHAR(50), country VARCHAR(50), quantity INT); INSERT INTO Warehouse (id, city, country, quantity) VALUES (1, 'Mumbai', 'India', 500), (2, 'Delhi', 'India', 200); | Which warehouses are located in India and have more than 300 items in stock? | SELECT * FROM Warehouse WHERE country = 'India' AND quantity > 300; | gretelai_synthetic_text_to_sql |
CREATE TABLE mental_health_treatment_approaches (id INT PRIMARY KEY, name VARCHAR(255), description TEXT); | Add a record for CBT to the mental health treatment approaches table | INSERT INTO mental_health_treatment_approaches (id, name, description) VALUES (1, 'CBT', 'Cognitive Behavioral Therapy, a type of psychotherapeutic treatment that helps patients understand the thoughts and feelings that influence behaviors.'); | gretelai_synthetic_text_to_sql |
CREATE TABLE EnvironmentalImpact (IncidentID INT, IncidentDate DATE, IncidentType VARCHAR(20)); INSERT INTO EnvironmentalImpact (IncidentID, IncidentDate, IncidentType) VALUES (1, '2022-01-01', 'Violation'), (2, '2021-12-15', 'Warning'), (3, '2022-03-04', 'Violation'); | How many environmental violations occurred in 2022? | SELECT COUNT(*) FROM EnvironmentalImpact WHERE YEAR(IncidentDate) = 2022 AND IncidentType = 'Violation'; | gretelai_synthetic_text_to_sql |
CREATE TABLE exhibitions (id INT, name VARCHAR(255), type VARCHAR(255)); INSERT INTO exhibitions (id, name, type) VALUES (1, 'Impressionism', 'Classic'), (2, 'Surrealism', 'Modern'), (3, 'Renaissance', 'Classic'), (4, 'Asian Art: Landscapes', 'Asian'), (5, 'Asian Art: Ceramics', 'Asian'); | How many exhibitions are there in the 'Asian Art' category? | SELECT COUNT(*) FROM exhibitions WHERE type = 'Asian'; | gretelai_synthetic_text_to_sql |
CREATE TABLE habitat (id INT, animal_species TEXT, size FLOAT); | What is the average size of habitats (in square kilometers) for each animal species? | SELECT animal_species, AVG(size) FROM habitat GROUP BY animal_species; | gretelai_synthetic_text_to_sql |
CREATE TABLE community_development (id INT, project_type VARCHAR(50), location VARCHAR(50), start_date DATE, end_date DATE); INSERT INTO community_development (id, project_type, location, start_date, end_date) VALUES (1, 'Education', 'Afghanistan', '2020-01-01', '2020-12-31'), (2, 'Health', 'Nigeria', '2020-01-01', '2020-12-31'); | What is the total number of community development projects carried out in 'community_development' table? | SELECT COUNT(*) FROM community_development; | gretelai_synthetic_text_to_sql |
CREATE TABLE countries (name VARCHAR(255), universities_count INT); CREATE TABLE university (name VARCHAR(255), country VARCHAR(255), enrollment INT); INSERT INTO countries (name) VALUES ('United States'), ('Canada'), ('Mexico'), ('Brazil'), ('Germany'); INSERT INTO university (name, country, enrollment) VALUES ('University A', 'United States', 50000), ('University B', 'Canada', 20000), ('University C', 'Mexico', 30000); | What is the maximum number of students enrolled in a university in each country? | SELECT country, MAX(enrollment) FROM university GROUP BY country; | 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.