context stringlengths 11 9.12k | question stringlengths 0 1.06k | SQL stringlengths 2 4.44k | source stringclasses 28
values |
|---|---|---|---|
CREATE TABLE Players (PlayerID INT, PlayerName VARCHAR(50), GameType VARCHAR(50)); INSERT INTO Players (PlayerID, PlayerName, GameType) VALUES (1, 'John Doe', 'FPS'); INSERT INTO Players (PlayerID, PlayerName, GameType) VALUES (2, 'Jane Smith', 'RPG'); INSERT INTO Players (PlayerID, PlayerName, GameType) VALUES (3, 'Mi... | List all players who have played more than one game type | SELECT PlayerName FROM Players GROUP BY PlayerName HAVING COUNT(DISTINCT GameType) > 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE Properties (PropertyID int, Price int, Borough varchar(255), NumOwners int); INSERT INTO Properties (PropertyID, Price, Borough, NumOwners) VALUES (1, 250000, 'Manhattan', 2); | What is the minimum price of a property co-owned by more than one owner in Manhattan? | SELECT MIN(Price) as MinPrice FROM Properties WHERE Borough = 'Manhattan' AND NumOwners > 1; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA socialmedia;CREATE TABLE posts (id INT, user_id INT, likes INT, timestamp TIMESTAMP, region VARCHAR(255));INSERT INTO posts (id, user_id, likes, timestamp, region) VALUES (1, 1, 10, '2023-07-01 00:00:00', 'South America'), (2, 2, 15, '2023-08-01 00:00:00', 'South America'); | What was the average number of likes per post for users in South America in Q3 2023? | SELECT AVG(likes) FROM socialmedia.posts WHERE region = 'South America' AND EXTRACT(YEAR FROM timestamp) = 2023 AND EXTRACT(QUARTER FROM timestamp) = 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE events (id INT, volunteer_hours DECIMAL(10, 2)); INSERT INTO events (id, volunteer_hours) VALUES (1, 10.00), (2, 20.00), (3, 30.00); | What is the average volunteer hour contribution for each event? | SELECT AVG(volunteer_hours) FROM events; | gretelai_synthetic_text_to_sql |
CREATE TABLE customer_meals (customer_id INTEGER, restaurant_name TEXT, city TEXT, calories INTEGER, meal_date DATE); INSERT INTO customer_meals (customer_id, restaurant_name, city, calories, meal_date) VALUES (1, 'Veggies Delight', 'Sydney', 800, '2022-02-01'); INSERT INTO customer_meals (customer_id, restaurant_name,... | What are the total calories consumed by each customer for the 'Veggies Delight' restaurant in Sydney, Australia in the month of February 2022, ranked by consumption? | SELECT customer_id, SUM(calories) as total_calories FROM customer_meals WHERE restaurant_name = 'Veggies Delight' AND city = 'Sydney' AND meal_date >= '2022-02-01' AND meal_date < '2022-03-01' GROUP BY customer_id ORDER BY total_calories DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE attorneys (attorney_id INT, office VARCHAR(50)); INSERT INTO attorneys VALUES (1, 'Seoul'); CREATE TABLE cases (case_id INT, attorney_id INT, case_outcome VARCHAR(10)); | Who is the attorney with the most cases won in the 'Seoul' office? | SELECT attorneys.name, COUNT(*) AS cases_won FROM attorneys INNER JOIN cases ON attorneys.attorney_id = cases.attorney_id WHERE attorneys.office = 'Seoul' AND case_outcome = 'won' GROUP BY attorneys.name ORDER BY cases_won DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE sea_pollution (pollution_id SERIAL, location TEXT, pollution_level REAL, sea TEXT); | Report the maximum pollution level recorded in the Mediterranean sea | SELECT MAX(pollution_level) FROM sea_pollution WHERE sea = 'Mediterranean'; | gretelai_synthetic_text_to_sql |
CREATE TABLE preservation_expenditure (expenditure_id INT, project TEXT, city TEXT, country TEXT, expenditure DECIMAL(5,2)); INSERT INTO preservation_expenditure (expenditure_id, project, city, country, expenditure) VALUES (9, 'Sydney Opera House Preservation', 'Sydney', 'Australia', 15000000); | What is the total expenditure on cultural heritage preservation in Sydney? | SELECT SUM(expenditure) FROM preservation_expenditure WHERE city = 'Sydney'; | gretelai_synthetic_text_to_sql |
CREATE TABLE sales (id INT, product_id INT, size TEXT, quantity INT, sale_date DATE); INSERT INTO sales (id, product_id, size, quantity, sale_date) VALUES (1, 1001, 'XS', 25, '2021-09-01'), (2, 1002, 'XXL', 30, '2021-09-15'), (3, 1003, 'M', 40, '2021-09-20'); | What is the total quantity of clothes sold in sizes XS and XXL in the last month? | SELECT SUM(quantity) FROM sales WHERE size IN ('XS', 'XXL') AND sale_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH); | gretelai_synthetic_text_to_sql |
CREATE TABLE workers (id INT, name VARCHAR(255), industry VARCHAR(255), salary DECIMAL(10,2)); CREATE TABLE unions (id INT, worker_id INT, union VARCHAR(255)); INSERT INTO workers (id, name, industry, salary) VALUES (1, 'Ava Thompson', 'hospitality', 35000.00); | What is the total number of workers in the 'hospitality' industry who are part of a union? | SELECT COUNT(DISTINCT workers.id) FROM workers INNER JOIN unions ON workers.id = unions.worker_id WHERE workers.industry = 'hospitality' AND unions.union = 'yes'; | gretelai_synthetic_text_to_sql |
CREATE TABLE states (id INT, name VARCHAR(255)); INSERT INTO states (id, name) VALUES (1, 'California'), (2, 'New York'); CREATE TABLE libraries (id INT, name VARCHAR(255), state_id INT); INSERT INTO libraries (id, name, state_id) VALUES (1, 'Library 1', 1), (2, 'Library 2', 1); CREATE TABLE community_centers (id INT, ... | What is the total number of libraries and community centers in the state of California? | SELECT COUNT(*) FROM libraries WHERE state_id = (SELECT id FROM states WHERE name = 'California'); SELECT COUNT(*) FROM community_centers WHERE state_id = (SELECT id FROM states WHERE name = 'California'); | gretelai_synthetic_text_to_sql |
CREATE TABLE buildings (id INT, name TEXT, city TEXT, energy_efficiency FLOAT); INSERT INTO buildings (id, name, city, energy_efficiency) VALUES (1, 'First Canadian Place', 'Toronto', 0.18), (2, 'TD Centre', 'Toronto', 0.22); | What is the average energy efficiency (in kWh/m^2) of buildings in the city 'Toronto'? | SELECT AVG(energy_efficiency) FROM buildings WHERE city = 'Toronto'; | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_species (id INT, name VARCHAR(50), region VARCHAR(50), conservation_status VARCHAR(50)); INSERT INTO marine_species (id, name, region, conservation_status) VALUES (1, 'Whale Shark', 'Indian Ocean', 'Vulnerable'); CREATE TABLE conservation_status (id INT, name VARCHAR(50)); | What are the conservation statuses of marine species in the Indian Ocean? | SELECT marine_species.conservation_status FROM marine_species INNER JOIN conservation_status ON marine_species.conservation_status = conservation_status.name WHERE marine_species.region = 'Indian Ocean'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Infrastructure (id INT, name VARCHAR(255), type VARCHAR(255), location VARCHAR(255), is_public_works BOOLEAN, resilience_score INT); CREATE TABLE Maintenance (id INT, infrastructure_id INT, maintenance_date DATE); INSERT INTO Infrastructure (id, name, type, location, is_public_works, resilience_score) VALU... | Find the names and maintenance dates of public works projects in Texas with a resilience score below 60 | SELECT Infrastructure.name, Maintenance.maintenance_date FROM Infrastructure INNER JOIN Maintenance ON Infrastructure.id = Maintenance.infrastructure_id WHERE Infrastructure.location = 'Texas' AND Infrastructure.is_public_works = TRUE AND Infrastructure.resilience_score < 60; | gretelai_synthetic_text_to_sql |
CREATE TABLE cases (case_id INT, practice_area VARCHAR(20), billing_amount DECIMAL(10, 2)); INSERT INTO cases (case_id, practice_area, billing_amount) VALUES (1, 'Personal Injury', 5000), (2, 'Personal Injury', 7000), (3, 'Personal Injury', 3000); | What is the maximum billing amount for cases in the 'Personal Injury' practice area? | SELECT MAX(billing_amount) FROM cases WHERE practice_area = 'Personal Injury'; | gretelai_synthetic_text_to_sql |
CREATE TABLE autonomous_driving_research (id INT, make VARCHAR(50), model VARCHAR(50), autonomy_level INT); | What is the average autonomy level for vehicles in the autonomous_driving_research table by make? | SELECT make, AVG(autonomy_level) FROM autonomous_driving_research GROUP BY make; | gretelai_synthetic_text_to_sql |
CREATE TABLE monthly_water_consumption (id INT, state VARCHAR(20), year INT, month INT, water_consumption FLOAT); INSERT INTO monthly_water_consumption (id, state, year, month, water_consumption) VALUES (1, 'Texas', 2019, 1, 500), (2, 'Texas', 2019, 2, 600), (3, 'California', 2019, 1, 700), (4, 'California', 2019, 2, 8... | What is the total amount of water consumption in the state of Texas, broken down by month for the year 2019? | SELECT state, YEAR(date) as year, MONTH(date) as month, SUM(water_consumption) as total_water_consumption FROM monthly_water_consumption WHERE state = 'Texas' AND YEAR(date) = 2019 GROUP BY state, year, month; | gretelai_synthetic_text_to_sql |
CREATE TABLE diversity_scores (id INT, company_name VARCHAR(30), diversity_score DECIMAL(3,2), founding_date DATE); INSERT INTO diversity_scores (id, company_name, diversity_score, founding_date) VALUES (1, 'CompanyC', 3.50, '2018-03-20'); INSERT INTO diversity_scores (id, company_name, diversity_score, founding_date) ... | Calculate the average diversity score for companies founded in the last 5 years | SELECT AVG(diversity_score) FROM diversity_scores WHERE founding_date >= DATE_SUB(CURDATE(), INTERVAL 5 YEAR); | gretelai_synthetic_text_to_sql |
CREATE TABLE Visits (visitor_id INT, exhibition_id INT, visit_date DATE); INSERT INTO Visits (visitor_id, exhibition_id, visit_date) VALUES (1, 1, '2022-01-01'), (2, 2, '2021-12-15'), (3, 1, '2022-03-20'); | How many unique visitors attended exhibitions in 2022? | SELECT COUNT(DISTINCT visitor_id) FROM Visits WHERE YEAR(visit_date) = 2022; | gretelai_synthetic_text_to_sql |
CREATE TABLE rural_infra_completion_dates (id INT, project_name VARCHAR(50), completion_date DATE); INSERT INTO rural_infra_completion_dates (id, project_name, completion_date) VALUES (1, 'Water Treatment', '2019-05-01'), (2, 'Power Grid', '2021-12-31'); | Delete rural infrastructure projects that were completed before 2020 in the 'rural_infra_completion_dates' table. | DELETE FROM rural_infra_completion_dates WHERE completion_date < '2020-01-01'; | gretelai_synthetic_text_to_sql |
CREATE TABLE climate_adaptation (region VARCHAR(255), funding INT); INSERT INTO climate_adaptation VALUES ('Europe', 5000000); INSERT INTO climate_adaptation VALUES ('Asia', 7000000); INSERT INTO climate_adaptation VALUES ('Africa', 6000000); | What is the combined funding for climate adaptation projects in Europe, Asia, and Africa? | SELECT SUM(funding) FROM climate_adaptation WHERE region IN ('Europe', 'Asia', 'Africa'); | gretelai_synthetic_text_to_sql |
CREATE TABLE donations (donor_id INTEGER, donation_amount REAL, donation_date DATE); INSERT INTO donations (donor_id, donation_amount, donation_date) VALUES (1, 5000, '2020-01-01'), (2, 2500, '2020-02-15'), (1, 7500, '2020-12-31'), (3, 1000, '2020-03-01'), (3, 1500, '2020-06-15'); | Which donors have made the most donations in the last year? | SELECT donor_id, SUM(donation_amount) as total_donations FROM donations WHERE donation_date >= DATE('now', '-1 year') GROUP BY donor_id ORDER BY total_donations DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE EsportsEvents (EventName VARCHAR(50), EventLocation VARCHAR(50)); INSERT INTO EsportsEvents (EventName, EventLocation) VALUES ('Asia-Pacific Games', 'Tokyo'); INSERT INTO EsportsEvents (EventName, EventLocation) VALUES ('North American Championships', 'New York'); INSERT INTO EsportsEvents (EventName, Even... | Show the names and number of esports events hosted in the top 3 hosting countries | SELECT e.EventLocation, COUNT(*) FROM EsportsEvents e GROUP BY e.EventLocation ORDER BY COUNT(*) DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE virtual_tours (tour_id INT, name TEXT, country TEXT, revenue DECIMAL(10,2)); INSERT INTO virtual_tours (tour_id, name, country, revenue) VALUES (1, 'Mount Fuji Virtual Tour', 'Japan', 1250.00), (2, 'Hiroshima Peace Memorial Virtual Tour', 'Japan', 1500.00); | What is the total revenue generated by virtual tours in Japan last month? | SELECT SUM(revenue) FROM virtual_tours WHERE country = 'Japan' AND DATE_TRUNC('month', timestamp) = DATE_TRUNC('month', NOW() - INTERVAL '1 month'); | gretelai_synthetic_text_to_sql |
CREATE TABLE people (person_id INT, city VARCHAR(20), water_consumption FLOAT, consumption_date DATE); INSERT INTO people (person_id, city, water_consumption, consumption_date) VALUES (1, 'San Francisco', 50.0, '2022-01-01'), (2, 'San Francisco', 60.0, '2022-02-01'), (3, 'San Francisco', 55.0, '2022-03-01'); | What is the average water consumption per person in the city of San Francisco, calculated monthly? | SELECT city, AVG(water_consumption) FROM (SELECT city, person_id, AVG(water_consumption) AS water_consumption FROM people GROUP BY city, PERIOD_DIFF(consumption_date, DATE_FORMAT(consumption_date, '%Y%m')) * 100) AS monthly_consumption GROUP BY city; | gretelai_synthetic_text_to_sql |
CREATE TABLE farming_equipment_vendors (id INT, vendor VARCHAR(255), product_count INT); INSERT INTO farming_equipment_vendors (id, vendor, product_count) VALUES (1, 'ABC Corp', 12), (2, 'XYZ Inc', 7), (3, 'PrecisionTech', 20), (4, 'GreenFields', 5); | List the names of the precision farming equipment vendors that have more than 10 products. | SELECT vendor FROM farming_equipment_vendors WHERE product_count > 10; | gretelai_synthetic_text_to_sql |
CREATE TABLE Hospitals (HospitalName VARCHAR(50), State VARCHAR(50)); INSERT INTO Hospitals (HospitalName, State) VALUES ('Albany Medical Center', 'New York'), ('Eliot Hospital', 'New York'); | How many hospitals are there in New York state? | SELECT COUNT(*) FROM Hospitals WHERE State = 'New York'; | gretelai_synthetic_text_to_sql |
CREATE TABLE launch_results (agency VARCHAR(10), launch_outcome VARCHAR(10), year INT); INSERT INTO launch_results (agency, launch_outcome, year) VALUES ('NASA', 'Success', 2019), ('NASA', 'Failure', 2020), ('SpaceX', 'Success', 2018), ('SpaceX', 'Success', 2019), ('ESA', 'Failure', 2021); | What is the total number of successful and failed launches for each agency? | SELECT agency, launch_outcome, COUNT(*) FROM launch_results GROUP BY agency, launch_outcome; | gretelai_synthetic_text_to_sql |
CREATE TABLE SafetyMeasures (id INT, measure VARCHAR(255), transparency_rating DECIMAL(5,2)); INSERT INTO SafetyMeasures (id, measure, transparency_rating) VALUES (1, 'AI Risk Assessment', 8.00), (2, 'AI Incident Response', 9.00), (3, 'AI Monitoring', 8.50); | What is the transparency rating for each AI safety measure? | SELECT measure, AVG(transparency_rating) as avg_transparency_rating FROM SafetyMeasures GROUP BY measure; | gretelai_synthetic_text_to_sql |
CREATE TABLE languages (language_id INT, country_id INT, language_name VARCHAR(255), status VARCHAR(255)); INSERT INTO languages VALUES (1, 1, 'French', 'Preserved'), (2, 1, 'Occitan', 'Endangered'), (3, 2, 'English', 'Preserved'), (4, 2, 'Cherokee', 'Endangered'), (5, 3, 'Japanese', 'Preserved'), (6, 3, 'Ainu', 'Enda... | What is the total number of languages preserved? | SELECT COUNT(*) FROM languages WHERE status = 'Preserved'; | gretelai_synthetic_text_to_sql |
CREATE TABLE fire_incidents (id INT, incident_time TIMESTAMP, response_time INT); INSERT INTO fire_incidents (id, incident_time, response_time) VALUES (1, '2022-01-01 10:00:00', 8), (2, '2022-01-01 12:30:00', 12); | What is the average response time for fire incidents in Dallas? | SELECT AVG(response_time) FROM fire_incidents WHERE incident_time >= '2022-01-01' AND incident_time < '2022-01-02'; | gretelai_synthetic_text_to_sql |
CREATE TABLE word_counts (id INT PRIMARY KEY, article_id INT, language VARCHAR(50), word_count INT, FOREIGN KEY (article_id) REFERENCES articles(id)); | What is the average word count for articles in each language? | SELECT language, AVG(word_count) as avg_word_count FROM word_counts GROUP BY language; | gretelai_synthetic_text_to_sql |
CREATE TABLE companies (id INT, name VARCHAR(255), esg_score DECIMAL(3,2), sector VARCHAR(255)); | What is the maximum ESG score for companies in the technology sector? | SELECT MAX(esg_score) FROM companies WHERE sector = 'Technology'; | gretelai_synthetic_text_to_sql |
CREATE TABLE LandfillCapacity (landfill VARCHAR(255), region VARCHAR(255), capacity INT, used_capacity INT); INSERT INTO LandfillCapacity (landfill, region, capacity, used_capacity) VALUES ('LandfillA', 'RegionA', 50000, 25000), ('LandfillB', 'RegionA', 60000, 30000), ('LandfillC', 'RegionA', 40000, 15000); | What is the capacity of each landfill in the region and its remaining capacity? | SELECT landfill, region, capacity, capacity - used_capacity AS remaining_capacity FROM LandfillCapacity; | gretelai_synthetic_text_to_sql |
CREATE TABLE sales (sale_id INT, product_id INT, sale_amount DECIMAL, sale_date DATE); CREATE TABLE products (product_id INT, product_name TEXT, category TEXT); INSERT INTO sales (sale_id, product_id, sale_amount, sale_date) VALUES (1, 1, 50.00, '2022-01-01'), (2, 1, 40.00, '2022-01-15'), (3, 2, 30.00, '2022-01-30'), (... | Find the number of products in the 'Organic' category that have not been sold in the past month. | SELECT COUNT(*) FROM products WHERE category = 'Organic' AND product_id NOT IN (SELECT product_id FROM sales WHERE sale_date BETWEEN DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) AND CURRENT_DATE); | gretelai_synthetic_text_to_sql |
CREATE TABLE wells (id INT, name VARCHAR(255), location VARCHAR(255), production_quantity INT); INSERT INTO wells (id, name, location, production_quantity) VALUES (1, 'Well A', 'North Sea', 1000), (2, 'Well B', 'North Sea', 1200), (3, 'Well C', 'North Sea', 1500); | What is the total production quantity for wells in the 'North Sea'? | SELECT SUM(production_quantity) FROM wells WHERE location = 'North Sea'; | gretelai_synthetic_text_to_sql |
CREATE TABLE MilitaryEquipmentSales (id INT, equipment_name VARCHAR(50), sale_amount INT, sale_date DATE); | Insert new records into the MilitaryEquipmentSales table | INSERT INTO MilitaryEquipmentSales (id, equipment_name, sale_amount, sale_date) VALUES (3, 'Submarine', 1200000, '2021-06-01'); | gretelai_synthetic_text_to_sql |
CREATE TABLE space_agencies (agency_id INT, name VARCHAR(255), launch_date DATE); | What is the earliest launch date for each space agency in the space_agencies table? | SELECT name, MIN(launch_date) as earliest_launch_date FROM space_agencies GROUP BY name; | gretelai_synthetic_text_to_sql |
CREATE TABLE Public_Transportation (City VARCHAR(50), System_Name VARCHAR(50), Ridership INT); INSERT INTO Public_Transportation (City, System_Name, Ridership) VALUES ('Toronto', 'TTC', 54000000); INSERT INTO Public_Transportation (City, System_Name, Ridership) VALUES ('New York', 'MTA', 1500000000); INSERT INTO Public... | What is the total ridership for public transportation systems in London and Paris? | SELECT SUM(Ridership) FROM Public_Transportation WHERE City IN ('London', 'Paris'); | gretelai_synthetic_text_to_sql |
CREATE TABLE train_fares (fare_id INT, region_id INT, fare DECIMAL(5,2)); INSERT INTO train_fares (fare_id, region_id, fare) VALUES (1, 1, 3.50), (2, 2, 4.25), (3, 3, 3.75), (4, 2, 4.25); | What is the minimum fare for trains in the 'west' region? | SELECT MIN(tf.fare) FROM train_fares tf INNER JOIN regions r ON tf.region_id = r.region_id WHERE r.region_name = 'west'; | gretelai_synthetic_text_to_sql |
CREATE TABLE cosmetics_sales (sale_id INT, product_id INT, sale_amount DECIMAL, country VARCHAR(255)); CREATE TABLE products (product_id INT, product_name VARCHAR(255), is_organic BOOLEAN); INSERT INTO cosmetics_sales (sale_id, product_id, sale_amount, country) VALUES (1, 1, 50.00, 'US'), (2, 2, 75.00, 'Canada'); INSER... | What is the total revenue generated from organic cosmetics sales in the US and Canada? | SELECT SUM(cosmetics_sales.sale_amount) FROM cosmetics_sales INNER JOIN products ON cosmetics_sales.product_id = products.product_id WHERE cosmetics_sales.country IN ('US', 'Canada') AND products.is_organic = true; | gretelai_synthetic_text_to_sql |
CREATE TABLE student_demographics (student_id INT, gender VARCHAR(10), participation_rate DECIMAL(5,2)); INSERT INTO student_demographics (student_id, gender, participation_rate) VALUES (1, 'Male', 0.85), (2, 'Female', 0.90), (3, 'Non-binary', 0.75), (4, 'Male', 0.80), (5, 'Female', 0.95); | What is the average lifelong learning participation rate for students in each gender category? | SELECT gender, AVG(participation_rate) as avg_participation_rate FROM student_demographics GROUP BY gender; | gretelai_synthetic_text_to_sql |
CREATE TABLE ocean_acidification (ocean VARCHAR(255), date DATE, pH FLOAT); INSERT INTO ocean_acidification (ocean, date, pH) VALUES ('Arctic', '2017-01-01', 7.9), ('Arctic', '2017-07-01', 7.8), ('Arctic', '2018-01-01', 7.85), ('Arctic', '2018-07-01', 7.8), ('Arctic', '2019-01-01', 7.82), ('Arctic', '2019-07-01', 7.75)... | Identify the 5-year trend of ocean acidification in the Arctic Ocean. | SELECT date, pH, ROW_NUMBER() OVER (ORDER BY date) as rn, AVG(pH) OVER (ORDER BY date ROWS BETWEEN 4 PRECEDING AND CURRENT ROW) as moving_avg FROM ocean_acidification WHERE ocean = 'Arctic'; | gretelai_synthetic_text_to_sql |
CREATE TABLE menu_sustainability (id INT PRIMARY KEY, menu_item VARCHAR(255), sustainability_rating DECIMAL(3,2)); | Create a table named 'menu_sustainability' to store data about the sustainability rating of menu items | CREATE TABLE menu_sustainability (id INT PRIMARY KEY, menu_item VARCHAR(255), sustainability_rating DECIMAL(3,2)); | gretelai_synthetic_text_to_sql |
CREATE TABLE military_equipment (country VARCHAR(50), category VARCHAR(50), number INT); INSERT INTO military_equipment (country, category, number) VALUES ('USA', 'Aircraft', 13000), ('Russia', 'Aircraft', 4000), ('China', 'Aircraft', 2500); | What is the total number of military equipment in the 'aircraft' category, by country? | SELECT country, SUM(number) as total_aircraft FROM military_equipment WHERE category = 'Aircraft' GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE BrandSales (id INT, brand VARCHAR(20), country VARCHAR(10), quantity INT); INSERT INTO BrandSales (id, brand, country, quantity) VALUES (1, 'Brand A', 'USA', 300), (2, 'Brand B', 'UK', 400); | What is the number of items sold in each country for a given brand? | SELECT country, SUM(quantity) FROM BrandSales WHERE brand = 'Brand A' GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE crop_moisture (crop_type VARCHAR(20), moisture_level INT); INSERT INTO crop_moisture (crop_type, moisture_level) VALUES ('Corn', 75), ('Soybeans', 60), ('Wheat', 80); | Calculate the average moisture level for each crop type | SELECT crop_type, AVG(moisture_level) FROM crop_moisture GROUP BY crop_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE security_incidents (id INT, incident_type VARCHAR(50), incident_date DATE); INSERT INTO security_incidents (id, incident_type, incident_date) VALUES (1, 'Malware', '2022-01-01'), (2, 'Phishing', '2022-01-15'); | What are the top 3 most common types of security incidents in the last 6 months? | SELECT incident_type, COUNT(*) as num_incidents FROM security_incidents WHERE incident_date >= DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH) GROUP BY incident_type ORDER BY num_incidents DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA if not exists biosensors;CREATE TABLE if not exists biosensors.measurements (id INT PRIMARY KEY, location VARCHAR(100), temperature FLOAT); INSERT INTO biosensors.measurements (id, location, temperature) VALUES (1, 'Toronto', 20.5), (2, 'Montreal', 19.3), (3, 'Vancouver', 22.1), (4, 'Ottawa', 18.7), (5, '... | What is the minimum biosensor temperature recorded in Canada? | SELECT MIN(temperature) FROM biosensors.measurements WHERE location = 'Canada'; | gretelai_synthetic_text_to_sql |
CREATE TABLE AIRCRAFT_INFO (id INT PRIMARY KEY, name VARCHAR(255), type VARCHAR(255), cost INT, country VARCHAR(255)); | What are the names and types of the military aircraft that are not from 'CountryB' in the AIRCRAFT_INFO table? | SELECT name, type FROM AIRCRAFT_INFO WHERE country != 'CountryB'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Bridges (id INT, name TEXT, construction_date DATE); INSERT INTO Bridges (id, name, construction_date) VALUES (1, 'Bixby Creek Bridge', '1932-06-29'), (2, 'Golden Gate Bridge', '1937-05-27'); | How many bridges in the database have a construction date before 1950? | SELECT COUNT(*) FROM Bridges WHERE construction_date < '1950-01-01' | gretelai_synthetic_text_to_sql |
CREATE TABLE healthcare_access (id INT, population VARCHAR(20), insured BOOLEAN); INSERT INTO healthcare_access (id, population, insured) VALUES | What is the percentage of uninsured individuals in indigenous populations? | SELECT (COUNT(*) FILTER (WHERE insured = false) / COUNT(*)) * 100 as uninsured_percentage FROM healthcare_access WHERE population = 'Indigenous'; | gretelai_synthetic_text_to_sql |
CREATE TABLE fish_catch (id INT, species TEXT, region TEXT, weight FLOAT); INSERT INTO fish_catch (id, species, region, weight) VALUES (1, 'Tuna', 'Mediterranean Sea', 200), (2, 'Sardines', 'Mediterranean Sea', 300), (3, 'Mackerel', 'North Sea', 250); | Identify fish species that have been overfished in the 'Mediterranean Sea'? | SELECT species FROM fish_catch WHERE region = 'Mediterranean Sea' AND weight > 350; | gretelai_synthetic_text_to_sql |
CREATE TABLE sustainable_destinations (id INT, destination VARCHAR(50), num_visitors INT, sustainability_score INT); | List all destinations with sustainable tourism practices that received more than 50,000 visitors in 2020? | SELECT destination FROM sustainable_destinations WHERE num_visitors > 50000 AND sustainability_score > 6 GROUP BY destination HAVING COUNT(DISTINCT YEAR(datetime)) = 1 AND YEAR(datetime) = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE menu_items (item_name VARCHAR(50), menu_category VARCHAR(50), item_type VARCHAR(50), price DECIMAL(5,2)); INSERT INTO menu_items (item_name, menu_category, item_type, price) VALUES ('Veggie Wrap', 'Appetizers', 'Vegan', 8.50), ('Vegan Pizza', 'Entrees', 'Vegan', 12.50), ('Veggie Burger', 'Entrees', 'Vegan'... | What is the average price of vegan items in each menu category? | SELECT menu_category, AVG(price) FROM menu_items WHERE item_type = 'Vegan' GROUP BY menu_category; | gretelai_synthetic_text_to_sql |
CREATE TABLE space_missions (id INT, mission_name VARCHAR(255), launch_country VARCHAR(255), launch_date DATE); INSERT INTO space_missions (id, mission_name, launch_country, launch_date) VALUES (1, 'Sputnik 1', 'Russia', '1957-10-04'); INSERT INTO space_missions (id, mission_name, launch_country, launch_date) VALUES (2... | List the names and launch dates of all space missions launched by India or Russia. | SELECT mission_name, launch_date FROM space_missions WHERE launch_country IN ('India', 'Russia'); | gretelai_synthetic_text_to_sql |
CREATE SCHEMA mental_health; USE mental_health; CREATE TABLE treatments (treatment_id INT, patient_id INT, treatment_type VARCHAR(50), treatment_date DATE, country VARCHAR(50)); INSERT INTO treatments VALUES (10, 9, 'TMS', '2022-03-21', 'Japan'); | Delete all records of patients who were treated with 'transcranial magnetic stimulation' (TMS) in Japan | DELETE FROM treatments WHERE treatment_type = 'TMS' AND country = 'Japan'; | gretelai_synthetic_text_to_sql |
CREATE TABLE PlayerCoins (PlayerID INT, Game VARCHAR(20), Coins INT, Date DATE); INSERT INTO PlayerCoins (PlayerID, Game, Coins, Date) VALUES (1, 'Candy Crush', 500, '2022-01-01'), (2, 'Candy Crush', 600, '2022-01-08'); | What is the maximum amount of coins earned by a player in Candy Crush within a week? | SELECT MAX(Coins) FROM PlayerCoins WHERE Game = 'Candy Crush' AND Date BETWEEN '2022-01-01' AND '2022-01-08'; | gretelai_synthetic_text_to_sql |
CREATE TABLE students (student_id INT, course_id INT, mental_health_score INT); CREATE TABLE courses (course_id INT, course_name TEXT); | What is the average mental health score of students in each course, grouped by course and ordered by the average score in descending order? | SELECT c.course_name, AVG(s.mental_health_score) as avg_mental_health_score FROM students s JOIN courses c ON s.course_id = c.course_id GROUP BY c.course_name ORDER BY avg_mental_health_score DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE oceans (name varchar(255), average_depth float); INSERT INTO oceans (name, average_depth) VALUES ('Pacific Ocean', 4028), ('Atlantic Ocean', 3646), ('Indian Ocean', 3962), ('Southern Ocean', 3481); | What is the average depth of the Southern Ocean? | SELECT AVG(average_depth) FROM oceans WHERE name = 'Southern Ocean'; | gretelai_synthetic_text_to_sql |
CREATE TABLE sustainable_materials (material_id INT, material TEXT, co2_emissions FLOAT); | What is the total CO2 emissions for each material in the 'sustainable_materials' table? | SELECT material, SUM(co2_emissions) as total_emissions FROM sustainable_materials GROUP BY material; | gretelai_synthetic_text_to_sql |
CREATE TABLE pollution_control_initiatives (id INT, initiative_name TEXT, country TEXT); | What is the total number of pollution control initiatives in each country? | SELECT country, COUNT(*) FROM pollution_control_initiatives GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE transactions (transaction_id INT, customer_id INT, transaction_value DECIMAL(10, 2), transaction_date DATE); INSERT INTO transactions (transaction_id, customer_id, transaction_value, transaction_date) VALUES (1, 1, 100.00, '2022-03-01'); INSERT INTO transactions (transaction_id, customer_id, transaction_va... | Find the total transaction value for each day in March 2022 for the 'North America' region. | SELECT DATE_FORMAT(transaction_date, '%Y-%m-%d') AS transaction_date, SUM(transaction_value) AS total_value FROM transactions WHERE region = 'North America' AND transaction_date BETWEEN '2022-03-01' AND '2022-03-31' GROUP BY transaction_date; | gretelai_synthetic_text_to_sql |
CREATE TABLE Vessel_Info (ID INT, Vessel_Name VARCHAR(50), Fuel_Type VARCHAR(10)); INSERT INTO Vessel_Info (ID, Vessel_Name, Fuel_Type) VALUES (1, 'Vessel1', 'LNG'); INSERT INTO Vessel_Info (ID, Vessel_Name, Fuel_Type) VALUES (2, 'Vessel2', 'MDO'); INSERT INTO Vessel_Info (ID, Vessel_Name, Fuel_Type) VALUES (3, 'Vessel... | How many vessels have a fuel type of 'LNG'? | SELECT COUNT(*) FROM Vessel_Info WHERE Fuel_Type = 'LNG'; | gretelai_synthetic_text_to_sql |
CREATE TABLE labor_productivity (id INT, mine_id INT, year INT, productivity INT);CREATE TABLE mine (id INT, name VARCHAR(255), location VARCHAR(255)); INSERT INTO mine (id, name, location) VALUES (1, 'Ghana Gold', 'Ghana'); INSERT INTO labor_productivity (id, mine_id, year, productivity) VALUES (1, 1, 2020, 120); | Show labor productivity metrics for the last 2 years in Ghana. | SELECT year, productivity FROM labor_productivity JOIN mine ON labor_productivity.mine_id = mine.id WHERE mine.location = 'Ghana' AND year >= (SELECT MAX(year) - 2 FROM labor_productivity); | gretelai_synthetic_text_to_sql |
CREATE TABLE defense_contracts (id INT, country VARCHAR(50), year INT, contract_spending FLOAT); INSERT INTO defense_contracts (id, country, year, contract_spending) VALUES (1, 'France', 2018, 1500000); INSERT INTO defense_contracts (id, country, year, contract_spending) VALUES (2, 'France', 2019, 1700000); INSERT INTO... | What is the total spending on defense contracts in France since 2018? | SELECT SUM(contract_spending) FROM defense_contracts WHERE country = 'France' AND year >= 2018; | gretelai_synthetic_text_to_sql |
CREATE TABLE workers_dept (id INT, name VARCHAR(50), department VARCHAR(50)); INSERT INTO workers_dept (id, name, department) VALUES (1, 'John Doe', 'manufacturing'), (2, 'Jane Smith', 'engineering'), (3, 'Alice Johnson', 'engineering'), (4, 'Bob Brown', 'manufacturing'), (5, 'Charlie Green', 'manufacturing'); | List the number of workers in each department, sorted by the number of workers in descending order | SELECT department, COUNT(*) as num_workers FROM workers_dept GROUP BY department ORDER BY num_workers DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE solar_farms (name TEXT, country TEXT, capacity_mw INTEGER, year INTEGER); | Insert a new solar farm in Spain with a capacity of 200 MW in 2022. | INSERT INTO solar_farms (name, country, capacity_mw, year) VALUES ('Solarfarm C', 'Spain', 200, 2022); | gretelai_synthetic_text_to_sql |
CREATE TABLE Vessels (VesselID INT, VesselType VARCHAR(50), AvgSpeed DECIMAL(5,2)); INSERT INTO Vessels VALUES (1, 'Bulk Carrier', 12.5), (2, 'Container Ship', 18.6), (3, 'Bulk Carrier', 11.8); | What is the minimum speed of vessels in the bulk carrier category? | SELECT MIN(AvgSpeed) FROM Vessels WHERE VesselType = 'Bulk Carrier'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Volunteers (VolunteerID INT, Age INT, Gender VARCHAR(10), Program VARCHAR(20)); INSERT INTO Volunteers (VolunteerID, Age, Gender, Program) VALUES (1, 25, 'Male', 'Education'); INSERT INTO Volunteers (VolunteerID, Age, Gender, Program) VALUES (2, 30, 'Female', 'Habitat Restoration'); INSERT INTO Volunteers ... | How many female volunteers are there in the 'Habitat Restoration' program? | SELECT COUNT(*) FROM Volunteers WHERE Gender = 'Female' AND Program = 'Habitat Restoration'; | gretelai_synthetic_text_to_sql |
CREATE TABLE spacecraft (id INT, name VARCHAR(255), manufacturer VARCHAR(255), mass FLOAT); INSERT INTO spacecraft (id, name, manufacturer, mass) VALUES (1, 'Voyager 1', 'Galactic Pioneers Inc.', 770.), (2, 'Voyager 2', 'Galactic Pioneers Inc.', 780.), (3, 'New Horizons', 'Space Explorers Ltd.', 1010.); | What is the minimum mass of a spacecraft manufactured by 'Space Explorers Ltd.'? | SELECT MIN(mass) FROM spacecraft WHERE manufacturer = 'Space Explorers Ltd.'; | gretelai_synthetic_text_to_sql |
CREATE TABLE renewable_energy_sources (source_id INT, source_name VARCHAR(50), generation_capacity FLOAT, source_type VARCHAR(50)); INSERT INTO renewable_energy_sources (source_id, source_name, generation_capacity, source_type) VALUES (1, 'Solar Farm A', 100000, 'Solar'), (2, 'Wind Farm B', 200000, 'Wind'), (3, 'Hydro ... | What is the average generation capacity for each type of renewable energy source? | SELECT source_type, AVG(generation_capacity) as avg_capacity FROM renewable_energy_sources GROUP BY source_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE Diplomacy (id INT, initiative VARCHAR(255), year INT); | What is the total number of defense diplomacy initiatives in the 'Diplomacy' table that occurred in the year 2021? | SELECT COUNT(*) FROM Diplomacy WHERE year = 2021; | gretelai_synthetic_text_to_sql |
CREATE TABLE brands (brand_id INT, brand_name TEXT, is_cruelty_free BOOLEAN); INSERT INTO brands (brand_id, brand_name, is_cruelty_free) VALUES (1, 'Flawless Faced', true), (2, 'Naturally Radiant', true), (3, 'Cruelty Free Cosmetics', true), (4, 'Animal Tested Brands', false); CREATE TABLE sales (sale_id INT, brand_id ... | Which cruelty-free cosmetic brands are most popular in the US? | SELECT b.brand_name, SUM(s.sale_quantity) as total_sales_quantity FROM sales s JOIN brands b ON s.brand_id = b.brand_id WHERE b.is_cruelty_free = true AND s.sale_country = 'US' GROUP BY b.brand_name ORDER BY total_sales_quantity DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE SafetyIncidents (IncidentID INT, Industry VARCHAR(20), UnionMember BOOLEAN, IncidentDate DATE); INSERT INTO SafetyIncidents (IncidentID, Industry, UnionMember, IncidentDate) VALUES (1, 'Agriculture', true, '2021-01-15'), (2, 'Agriculture', false, '2021-02-10'), (3, 'Agriculture', true, '2021-03-01'); | How many workplace safety incidents occurred in the 'Agriculture' industry, broken down by union membership? | SELECT Industry, UnionMember, COUNT(*) FROM SafetyIncidents WHERE Industry = 'Agriculture' GROUP BY Industry, UnionMember; | gretelai_synthetic_text_to_sql |
CREATE TABLE south_korea_energy_storage (id INT PRIMARY KEY, year INT, technology VARCHAR(30), num_projects INT); INSERT INTO south_korea_energy_storage (id, year, technology, num_projects) VALUES (1, 2018, 'Batteries', 3), (2, 2018, 'Pumped Hydro', 2), (3, 2018, 'Flywheels', 1); | How many energy storage projects were completed in South Korea in 2018, by technology? | SELECT year, technology, SUM(num_projects) as total_projects FROM south_korea_energy_storage WHERE year = 2018 GROUP BY year, technology; | gretelai_synthetic_text_to_sql |
CREATE TABLE RecyclingRates (country VARCHAR(50), rate DECIMAL(5,2)); INSERT INTO RecyclingRates (country, rate) VALUES ('Nigeria', 15.5), ('Egypt', 18.7), ('South Africa', 22.3); | Which African countries have recycling rates below 20%? | SELECT country FROM RecyclingRates WHERE rate < 20; | gretelai_synthetic_text_to_sql |
CREATE TABLE factories (factory_id INT, country VARCHAR(255), co2_emission INT); INSERT INTO factories (factory_id, country, co2_emission) VALUES (1, 'India', 100), (2, 'China', 200), (3, 'Bangladesh', 150), (4, 'India', 250); | What is the total CO2 emission of each country, ordered by the highest emission first? | SELECT country, SUM(co2_emission) as total_emission FROM factories GROUP BY country ORDER BY total_emission DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE taxis (id INT, city TEXT, vehicle_type TEXT, fuel_type TEXT, total_taxis INT); INSERT INTO taxis (id, city, vehicle_type, fuel_type, total_taxis) VALUES (1, 'New York', 'Taxi', 'Gasoline', 1000), (2, 'Los Angeles', 'Taxi', 'Hybrid', 800), (3, 'Chicago', 'Taxi', 'Electric', 600); | What is the average number of electric taxis in the taxis table for each city? | SELECT city, AVG(total_taxis) as avg_electric_taxis FROM taxis WHERE vehicle_type = 'Taxi' AND fuel_type = 'Electric' GROUP BY city; | gretelai_synthetic_text_to_sql |
CREATE TABLE route (route_id INT, route_name VARCHAR(255)); INSERT INTO route (route_id, route_name) VALUES (1, 'Route 1'), (2, 'Route 2'), (3, 'Route 3'), (4, 'Route 4'); CREATE TABLE fares (fare_id INT, route_id INT, fare_amount DECIMAL, fare_date DATE); INSERT INTO fares (fare_id, route_id, fare_amount, fare_date) V... | Update the fare_amount to 4.00 for all fares in the route 4 | UPDATE fares SET fare_amount = 4.00 WHERE route_id = 4; | gretelai_synthetic_text_to_sql |
CREATE TABLE library_info (library_id INT, library_name TEXT, type TEXT, state TEXT); INSERT INTO library_info (library_id, library_name, type, state) VALUES (1, 'Library A', 'Public', 'NY'), (2, 'Library B', 'Public', 'NY'), (3, 'Library C', 'Private', 'NY'), (4, 'Library D', 'Public', 'NJ'); | What is the total number of public libraries in the state of NY? | SELECT COUNT(*) FROM library_info WHERE type = 'Public' AND state = 'NY'; | gretelai_synthetic_text_to_sql |
CREATE TABLE workplaces (id INT, country VARCHAR(50), has_lrv BOOLEAN); INSERT INTO workplaces (id, country, has_lrv) VALUES (1, 'Canada', true), (2, 'Canada', false), (3, 'Canada', false); | How many workplaces in Canada have no labor rights violations? | SELECT COUNT(*) FROM workplaces WHERE country = 'Canada' AND has_lrv = false; | gretelai_synthetic_text_to_sql |
CREATE TABLE students (student_id INT, name VARCHAR(255), major VARCHAR(255), gpa DECIMAL(3,2)); CREATE VIEW top_students AS SELECT * FROM students WHERE gpa >= 3.5; | Drop the "top_students" view. | DROP VIEW top_students; | gretelai_synthetic_text_to_sql |
CREATE TABLE oceanography_data (id INT PRIMARY KEY, location VARCHAR(255), temperature DECIMAL(5,2), salinity DECIMAL(5,2), depth DECIMAL(5,2)); | Delete the record with ID 2 from the oceanography_data table | WITH deleted_data AS (DELETE FROM oceanography_data WHERE id = 2 RETURNING *) SELECT * FROM deleted_data; | gretelai_synthetic_text_to_sql |
CREATE TABLE galleries (id INT, name TEXT, city TEXT, country TEXT); INSERT INTO galleries (id, name, city, country) VALUES (1, 'Gallery 1', 'Paris', 'France'); CREATE TABLE exhibitions (id INT, title TEXT, type TEXT, gallery_id INT); INSERT INTO exhibitions (id, title, type, gallery_id) VALUES (1, 'Exhibition 1', 'Con... | Which are the galleries that host contemporary art exhibitions in Paris, France? | SELECT g.name FROM galleries g INNER JOIN exhibitions e ON g.id = e.gallery_id WHERE e.type = 'Contemporary' AND g.city = 'Paris' AND g.country = 'France'; | gretelai_synthetic_text_to_sql |
CREATE TABLE open_pedagogy_schools (id INT, school_name VARCHAR(50), continent VARCHAR(50)); INSERT INTO open_pedagogy_schools (id, school_name, continent) VALUES (1, 'Innovate School', 'North America'), (2, 'Open Learning School', 'Europe'); | What is the distribution of open pedagogy schools by continent? | SELECT continent, COUNT(*) FROM open_pedagogy_schools GROUP BY continent; | gretelai_synthetic_text_to_sql |
CREATE TABLE infrastructure (investment_id INT, location VARCHAR(100), investment_type VARCHAR(50), investment_amount INT, investment_date DATE); | Add a new network infrastructure investment record into the infrastructure table | INSERT INTO infrastructure (investment_id, location, investment_type, investment_amount, investment_date) VALUES (2001, 'Downtown Dallas', 'Cell Tower', 500000, '2021-12-15'); | gretelai_synthetic_text_to_sql |
CREATE TABLE orders (id SERIAL PRIMARY KEY, customer_id INTEGER, product_id INTEGER); CREATE TABLE products (id INTEGER PRIMARY KEY, name VARCHAR(50), is_sustainable BOOLEAN); INSERT INTO orders (customer_id, product_id) VALUES (1, 1), (2, 2), (3, 3), (4, 1), (5, 3), (6, 4); INSERT INTO products (id, name, is_sustainab... | Show the number of customers who bought sustainable products | SELECT COUNT(DISTINCT customer_id) FROM orders JOIN products ON orders.product_id = products.id WHERE products.is_sustainable = true; | gretelai_synthetic_text_to_sql |
CREATE TABLE vessel_cargo ( id INT, vessel_id INT, departure_country VARCHAR(255), arrival_country VARCHAR(255), cargo_type VARCHAR(255), quantity INT ); INSERT INTO vessel_cargo (id, vessel_id, departure_country, arrival_country, cargo_type, quantity) VALUES (1, 10, 'Canada', 'UK', 'Coal', 15000); INSERT INTO vessel_c... | What is the total quantity of coal transported by vessels from Canada to the UK? | SELECT SUM(quantity) as total_coal_transported FROM vessel_cargo WHERE departure_country = 'Canada' AND arrival_country = 'UK' AND cargo_type = 'Coal'; | gretelai_synthetic_text_to_sql |
CREATE TABLE dishes (dish_id INT, dish_name VARCHAR(50), dish_type VARCHAR(20), cuisine VARCHAR(20), calorie_count INT); INSERT INTO dishes (dish_id, dish_name, dish_type, cuisine, calorie_count) VALUES (1, 'Lasagna', 'pasta', 'Italian', 800), (2, 'Pizza', 'pizza', 'Italian', 700), (3, 'Ramen', 'noodles', 'Japanese', 4... | List the cuisines and the average calorie count of dishes in each cuisine. | SELECT cuisine, AVG(calorie_count) FROM dishes GROUP BY cuisine; | gretelai_synthetic_text_to_sql |
CREATE TABLE restaurants (id INT, name TEXT, region TEXT, safety_score INT); INSERT INTO restaurants (id, name, region, safety_score) VALUES (1, 'Restaurant A', 'urban', 95), (2, 'Restaurant B', 'rural', 85), (3, 'Restaurant C', 'urban', 90); | What is the average food safety score for restaurants in the 'urban' region? | SELECT AVG(r.safety_score) as avg_score FROM restaurants r WHERE r.region = 'urban'; | gretelai_synthetic_text_to_sql |
CREATE TABLE wind_farms (id INT, name VARCHAR(50), location VARCHAR(50), installed_capacity FLOAT); INSERT INTO wind_farms (id, name, location, installed_capacity) VALUES (1, 'Wind Farm 1', 'Country A', 120.5); INSERT INTO wind_farms (id, name, location, installed_capacity) VALUES (2, 'Wind Farm 2', 'Country B', 250.8)... | What is the maximum installed capacity for a single wind farm in the clean_energy schema? | SELECT MAX(installed_capacity) FROM clean_energy.wind_farms; | gretelai_synthetic_text_to_sql |
CREATE TABLE military_contracts (contract_id INT, contract_type VARCHAR(255), contract_amount DECIMAL(10,2), contract_date DATE); INSERT INTO military_contracts (contract_id, contract_type, contract_amount, contract_date) VALUES (1, 'Services', 500000.00, '2020-01-01'); INSERT INTO military_contracts (contract_id, cont... | What is the total amount spent on military contracts by the US Department of Defense in Q1 2020, grouped by contract type? | SELECT contract_type, SUM(contract_amount) FROM military_contracts WHERE contract_date BETWEEN '2020-01-01' AND '2020-03-31' GROUP BY contract_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE AI_in_education (course_name VARCHAR(255), enrollment_count INT); | For the AI_in_education table, return the course_name and enrollment_count for the rows with the minimum and maximum enrollment_count values, in ascending order. | SELECT course_name, enrollment_count FROM (SELECT course_name, enrollment_count, ROW_NUMBER() OVER (ORDER BY enrollment_count) as rn, COUNT(*) OVER () as total FROM AI_in_education) tmp WHERE rn = 1 OR rn = total; | gretelai_synthetic_text_to_sql |
CREATE TABLE vehicle_inventory (inventory_id int, vehicle_type varchar(255), model varchar(255)); INSERT INTO vehicle_inventory (inventory_id, vehicle_type, model) VALUES (1, 'Bus', 'Articulated'), (2, 'Bus', 'Standard'), (3, 'Train', 'Subway'); | Show the number of vehicles of each type in the fleet | SELECT vehicle_type, COUNT(*) AS count FROM vehicle_inventory GROUP BY vehicle_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE claim (claim_id INT, claim_state VARCHAR(20), claim_status VARCHAR(20)); INSERT INTO claim VALUES (1, 'California', 'Pending'); INSERT INTO claim VALUES (2, 'Texas', 'Paid'); | Show all claim records for claim status 'Paid' as separate columns for claim ID, claim state, and a column for each claim status value | SELECT claim_id, claim_state, MAX(CASE WHEN claim_status = 'Paid' THEN claim_status END) AS Paid, MAX(CASE WHEN claim_status = 'Pending' THEN claim_status END) AS Pending FROM claim GROUP BY claim_id, claim_state; | gretelai_synthetic_text_to_sql |
CREATE TABLE artists_tokyo (artist_id INT, name VARCHAR(50), city VARCHAR(50), pieces INT); | What is the maximum number of art pieces created by a single artist in Tokyo? | SELECT MAX(pieces) FROM artists_tokyo WHERE city = 'Tokyo'; | gretelai_synthetic_text_to_sql |
CREATE TABLE teachers (teacher_id INT, years_of_experience INT, mental_health_resource_access DATE, region_code CHAR(2)); INSERT INTO teachers VALUES (1, 5, '2021-02-01', 'NE'), (2, 3, '2021-06-01', 'SE'), (3, 8, '2020-12-01', 'NW'), (4, 6, NULL, 'SW'); CREATE TABLE professional_development (teacher_id INT, hours_compl... | What is the total number of professional development hours for teachers who have not accessed mental health resources in each region? | SELECT r.region_name, SUM(pd.hours_completed) AS total_hours FROM teachers t JOIN professional_development pd ON t.teacher_id = pd.teacher_id JOIN regions r ON t.region_code = r.region_code WHERE t.mental_health_resource_access IS NULL GROUP BY r.region_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE ports (id INT, name VARCHAR(20)); INSERT INTO ports (id, name) VALUES (1, 'Mumbai'), (2, 'Delhi'); CREATE TABLE containers (id INT, weight INT, port_id INT); INSERT INTO containers (id, weight, port_id) VALUES (1, 500, 1), (2, 1500, 1), (3, 2000, 2), (4, 2500, 2), (5, 50, 1); | What is the number of containers with weight less than 1000 that were handled by port 'Mumbai'? | SELECT COUNT(*) FROM containers WHERE weight < 1000 AND port_id = (SELECT id FROM ports WHERE name = 'Mumbai'); | gretelai_synthetic_text_to_sql |
CREATE TABLE Artists (ArtistID INT, ArtistName VARCHAR(50), Nationality VARCHAR(50), ActiveYears INT, Gender VARCHAR(10));CREATE TABLE Paintings (PaintingID INT, PaintingName VARCHAR(50), ArtistID INT, DisplayStart DATE, DisplayEnd DATE);CREATE TABLE Gallery (GalleryID INT, GalleryName VARCHAR(50), City VARCHAR(50));IN... | What is the average active years of artists from Japan who have exhibited at 'Artistic Wonders' gallery, excluding those with no display end date yet? | SELECT AVG(ActiveYears) FROM Artists JOIN Paintings ON Artists.ArtistID = Paintings.ArtistID WHERE GalleryID IN (SELECT GalleryID FROM Gallery WHERE GalleryName = 'Artistic Wonders') AND Nationality = 'Japan' AND DisplayEnd IS NOT NULL; | 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.