context stringlengths 11 9.12k | question stringlengths 0 1.06k | SQL stringlengths 2 4.44k | source stringclasses 28 values |
|---|---|---|---|
CREATE TABLE company_founding (company_name VARCHAR(255), founder_country VARCHAR(50)); INSERT INTO company_founding (company_name, founder_country) VALUES ('Acme Inc', 'USA'), ('Beta Corp', 'Canada'), ('Charlie LLC', 'USA'), ('Delta Co', 'Mexico'); | Show the top 3 countries with the most companies founded | SELECT founder_country, COUNT(*) AS company_count FROM company_founding GROUP BY founder_country ORDER BY company_count DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE drug_sales (drug_name TEXT, quantity INTEGER, sale_price NUMERIC(10, 2), year INTEGER); INSERT INTO drug_sales (drug_name, quantity, sale_price, year) VALUES ('DrugA', 1200, 120.50, 2020), ('DrugA', 1500, 122.00, 2019), ('DrugB', 1400, 150.75, 2020), ('DrugB', 1600, 145.00, 2019); | What was the total sales revenue for each drug in 2020? | SELECT drug_name, SUM(quantity * sale_price) as total_sales_revenue FROM drug_sales WHERE year = 2020 GROUP BY drug_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE boroughs (borough_name VARCHAR(255)); INSERT INTO boroughs (borough_name) VALUES ('Bronx'), ('Brooklyn'), ('Manhattan'), ('Queens'), ('Staten Island'); CREATE TABLE crime_data (crime_date DATE, borough_name VARCHAR(255), crime_count INT); | What was the total number of crimes reported in each borough for each month in the past year? | SELECT b.borough_name, EXTRACT(MONTH FROM cd.crime_date) as month, SUM(cd.crime_count) as total_crimes FROM boroughs b JOIN crime_data cd ON b.borough_name = cd.borough_name WHERE cd.crime_date >= CURDATE() - INTERVAL 1 YEAR GROUP BY b.borough_name, month; | gretelai_synthetic_text_to_sql |
CREATE TABLE safety_incidents (id INT, workplace INT, employer INT, incident_date DATE); INSERT INTO safety_incidents (id, workplace, employer, incident_date) VALUES (1, 1, 1, '2022-06-15'); INSERT INTO safety_incidents (id, workplace, employer, incident_date) VALUES (2, 2, 2, '2022-07-01'); INSERT INTO safety_incidents (id, workplace, employer, incident_date) VALUES (3, 1, 1, '2022-08-10'); | Show the number of workplace safety incidents per month, for the past year, for workplaces without a union, partitioned by employer. | SELECT employer, DATE_FORMAT(incident_date, '%Y-%m') as month, COUNT(*) as num_incidents FROM safety_incidents si INNER JOIN workplaces w ON si.workplace = w.id WHERE w.union_affiliation IS NULL GROUP BY employer, month ORDER BY STR_TO_DATE(month, '%Y-%m'); | gretelai_synthetic_text_to_sql |
CREATE TABLE bridges (id INT, name TEXT, region TEXT, resilience_score FLOAT, year_built INT); INSERT INTO bridges (id, name, region, resilience_score, year_built) VALUES (1, 'Golden Gate Bridge', 'West Coast', 85.2, 1937), (2, 'Brooklyn Bridge', 'East Coast', 76.3, 1883), (3, 'Bay Bridge', 'West Coast', 90.1, 1936), (4, 'Chenab Bridge', 'South Asia', 89.6, 2010), (5, 'Maputo Bay Bridge', 'Africa', 72.8, 1982), (6, 'Sydney Harbour Bridge', 'Oceania', 87.3, 1932), (7, 'Millau Viaduct', 'Europe', 95.1, 2004); | What is the maximum 'resilience_score' of bridges in the 'Europe' region that were built after 2000? | SELECT MAX(resilience_score) FROM bridges WHERE region = 'Europe' AND year_built > 2000; | gretelai_synthetic_text_to_sql |
CREATE TABLE cybersecurity_incidents (region VARCHAR(50), year INT, num_incidents INT); INSERT INTO cybersecurity_incidents (region, year, num_incidents) VALUES ('Asia', 2019, 5000), ('Asia', 2020, 6000), ('Asia', 2021, 7000); | How many cybersecurity incidents were reported in Asia in the last 3 years? | SELECT SUM(num_incidents) FROM cybersecurity_incidents WHERE region = 'Asia' AND year BETWEEN 2019 AND 2021; | gretelai_synthetic_text_to_sql |
CREATE TABLE humanitarian_assistance (country VARCHAR(50), year INT, amount FLOAT); INSERT INTO humanitarian_assistance (country, year, amount) VALUES ('USA', 2020, 3000000000), ('China', 2020, 1000000000), ('Japan', 2020, 2000000000), ('India', 2020, 1500000000); | What is the maximum amount of humanitarian assistance provided by any country in the year 2020? | SELECT MAX(amount) FROM humanitarian_assistance WHERE year = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE istanbul_real_estate(id INT, city VARCHAR(50), price DECIMAL(10,2), co_owned BOOLEAN); INSERT INTO istanbul_real_estate VALUES (1, 'Istanbul', 700000, true); | What is the maximum price of properties in the city of Istanbul, Turkey that are co-owned? | SELECT MAX(price) FROM istanbul_real_estate WHERE city = 'Istanbul' AND co_owned = true; | gretelai_synthetic_text_to_sql |
CREATE TABLE treatments (id INT, patient_id INT, medication VARCHAR(50), start_date DATE, end_date DATE, success BOOLEAN); CREATE VIEW depression_medications AS SELECT * FROM treatments WHERE condition = 'depression'; | What is the success rate of medication treatments for patients with depression? | SELECT AVG(success) FROM depression_medications WHERE end_date IS NOT NULL; | gretelai_synthetic_text_to_sql |
CREATE TABLE Renewable_Energy_Projects (Project_ID INT, Country VARCHAR(50), Energy_Efficiency_Score FLOAT); INSERT INTO Renewable_Energy_Projects (Project_ID, Country, Energy_Efficiency_Score) VALUES (1, 'USA', 85.0), (2, 'China', 90.0), (3, 'India', 80.0), (4, 'Germany', 95.0), (5, 'Brazil', 88.0); | What is the average energy efficiency score for renewable energy projects in each country? | SELECT Country, AVG(Energy_Efficiency_Score) FROM Renewable_Energy_Projects GROUP BY Country; | gretelai_synthetic_text_to_sql |
CREATE TABLE athletes (athlete_id INT, name VARCHAR(50), sport VARCHAR(50)); INSERT INTO athletes (athlete_id, name, sport) VALUES (1, 'John Doe', 'Basketball'), (2, 'Jane Smith', 'Soccer'); CREATE TABLE games (game_id INT, athlete_id INT, points INT); INSERT INTO games (game_id, athlete_id, points) VALUES (1, 1, 20), (2, 1, 30), (3, 2, 5); | Update the points scored by athletes in specific games | UPDATE games SET points = CASE WHEN game_id = 1 THEN 25 WHEN game_id = 2 THEN 35 ELSE points END; | gretelai_synthetic_text_to_sql |
CREATE TABLE visitors (id INT, age_group TEXT, department TEXT); INSERT INTO visitors (id, age_group, department) VALUES (1, '0-17', 'Art'), (2, '18-25', 'Art'); | What is the visitor count by age group for the 'Art' department? | SELECT department, age_group, COUNT(*) FROM visitors WHERE department = 'Art' GROUP BY department, age_group; | gretelai_synthetic_text_to_sql |
CREATE TABLE PrecisionAgriculture.HarvestYield (FieldID INT, Yield FLOAT, HarvestDate DATE); | Insert a record with FieldID 101, Yield 35.6, and HarvestDate 2022-08-01 into the "HarvestYield" table | INSERT INTO PrecisionAgriculture.HarvestYield (FieldID, Yield, HarvestDate) VALUES (101, 35.6, '2022-08-01'); | gretelai_synthetic_text_to_sql |
CREATE TABLE energy_consumption (country VARCHAR(50), consumption_twh INT); INSERT INTO energy_consumption (country, consumption_twh) VALUES ('United Kingdom', 306.2), ('South Korea', 644.8); | What is the total energy consumption in terawatt-hours (TWh) for the United Kingdom and South Korea? | SELECT SUM(consumption_twh) FROM energy_consumption WHERE country IN ('United Kingdom', 'South Korea'); | gretelai_synthetic_text_to_sql |
CREATE TABLE Donations (DonationID INT, DonorID INT, DonationAmount DECIMAL(10,2)); INSERT INTO Donations (DonationID, DonorID, DonationAmount) VALUES (1, 1, 100.00), (2, 1, 200.00), (3, 2, 150.00); | Who are the top 5 donors by total donation amount? | SELECT DonorID, SUM(DonationAmount) AS TotalDonated FROM Donations GROUP BY DonorID ORDER BY TotalDonated DESC LIMIT 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE Brands (brand_id INT, brand_name VARCHAR(50)); CREATE TABLE Brand_Materials (brand_id INT, material_id INT, quantity INT); CREATE TABLE Materials (material_id INT, material_name VARCHAR(50), is_sustainable BOOLEAN); INSERT INTO Brands (brand_id, brand_name) VALUES (1, 'EcoFabric'), (2, 'GreenThreads'), (3, 'SustainableStyle'), (4, 'FairFashion'), (5, 'BambooBrand'); INSERT INTO Materials (material_id, material_name, is_sustainable) VALUES (1, 'Organic Cotton', true), (2, 'Synthetic Fiber', false), (3, 'Recycled Plastic', true), (4, 'Bamboo Fiber', true); INSERT INTO Brand_Materials (brand_id, material_id, quantity) VALUES (1, 1, 600), (1, 2, 300), (2, 1, 800), (2, 3, 700), (3, 1, 400), (3, 2, 500), (4, 4, 1000), (5, 2, 1500); | Who are the bottom 2 brands in terms of sustainable material usage? | SELECT brand_name, SUM(quantity) as total_quantity FROM Brands b INNER JOIN Brand_Materials bm ON b.brand_id = bm.brand_id INNER JOIN Materials m ON bm.material_id = m.material_id WHERE m.is_sustainable = false GROUP BY brand_name ORDER BY total_quantity ASC LIMIT 2; | gretelai_synthetic_text_to_sql |
CREATE TABLE CommunityHealthWorkerDemographics (WorkerID INT, State VARCHAR(2), Age INT, Gender VARCHAR(10)); INSERT INTO CommunityHealthWorkerDemographics (WorkerID, State, Age, Gender) VALUES (1, 'NY', 35, 'Female'), (2, 'CA', 45, 'Male'), (3, 'TX', 50, 'Female'); | What is the distribution of community health worker demographics by state? | SELECT State, COUNT(*) AS TotalWorkers, AVG(Age) AS AvgAge, COUNT(DISTINCT Gender) AS DistinctGenders FROM CommunityHealthWorkerDemographics GROUP BY State; | gretelai_synthetic_text_to_sql |
CREATE TABLE production (year INT, element VARCHAR(10), quantity INT); INSERT INTO production (year, element, quantity) VALUES (2018, 'Lanthanum', 11000); | What is the maximum production quantity of Lanthanum in 2018? | SELECT MAX(quantity) FROM production WHERE element = 'Lanthanum' AND year = 2018 | gretelai_synthetic_text_to_sql |
CREATE TABLE garments (garment_id INT, garment_type VARCHAR(30), manufacturing_cost DECIMAL(10,2)); CREATE TABLE orders (order_id INT, garment_id INT, quantity INT); | What is the total manufacturing cost for each garment type? | SELECT garment_type, SUM(manufacturing_cost * quantity) AS total_cost FROM garments INNER JOIN orders ON garments.garment_id = orders.garment_id GROUP BY garment_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE clients (client_id INT, name TEXT, country TEXT, investment_return FLOAT); INSERT INTO clients (client_id, name, country, investment_return) VALUES (1, 'John Doe', 'USA', 0.07), (2, 'Jane Smith', 'Canada', 0.05); | What is the average investment return for clients from the US and Canada? | SELECT AVG(investment_return) as avg_return FROM clients WHERE country IN ('USA', 'Canada'); | gretelai_synthetic_text_to_sql |
CREATE TABLE salary (id INT, employee_id INT, amount DECIMAL(5,2)); CREATE TABLE position (id INT, title VARCHAR(50), department_id INT, salary INT); | Calculate the average salary for each job position from the 'salary' and 'position' tables | SELECT position.title, AVG(salary.amount) FROM position INNER JOIN salary ON position.id = salary.employee_id GROUP BY position.title; | gretelai_synthetic_text_to_sql |
CREATE TABLE mine (id INT, name TEXT, location TEXT, mineral TEXT, productivity INT); INSERT INTO mine (id, name, location, mineral, productivity) VALUES (1, 'Olympic Dam', 'Australia', 'Copper', 1200), (2, 'Mount Isa', 'Australia', 'Copper', 1500); | Delete all copper mines in Australia with productivity below 1000? | DELETE FROM mine WHERE mineral = 'Copper' AND location = 'Australia' AND productivity < 1000; | gretelai_synthetic_text_to_sql |
CREATE TABLE BuildingPermits (PermitIssueDate DATE); | What is the total number of building permits issued, in each month, for the past year? | SELECT DATEPART(YEAR, PermitIssueDate) as Year, DATEPART(MONTH, PermitIssueDate) as Month, COUNT(*) as PermitCount FROM BuildingPermits WHERE PermitIssueDate >= DATEADD(YEAR, -1, GETDATE()) GROUP BY DATEPART(YEAR, PermitIssueDate), DATEPART(MONTH, PermitIssueDate) ORDER BY Year, Month; | gretelai_synthetic_text_to_sql |
CREATE TABLE weather_data (id INT, date DATE, temp FLOAT); | What is the minimum temperature recorded in the Arctic per season? | SELECT MIN(temp) FROM weather_data WHERE date >= DATE_SUB(CURDATE(), INTERVAL 12 MONTH) GROUP BY QUARTER(date); | gretelai_synthetic_text_to_sql |
CREATE TABLE mobile_subscribers (subscriber_id INT, technology VARCHAR(20), region VARCHAR(50), complete_data BOOLEAN); INSERT INTO mobile_subscribers (subscriber_id, technology, region, complete_data) VALUES (1, '4G', 'North', true), (2, '5G', 'North', false), (3, '3G', 'South', true), (4, '5G', 'East', true), (5, '5G', 'North', true); | How many mobile subscribers use each technology type in each region, excluding subscribers with incomplete data? | SELECT technology, region, COUNT(*) AS subscribers FROM mobile_subscribers WHERE complete_data = true GROUP BY technology, region; | gretelai_synthetic_text_to_sql |
CREATE TABLE reo_production (id INT PRIMARY KEY, reo_type VARCHAR(50), mine_name VARCHAR(50), production_year INT); | Get the number of REO types produced in each mine in 2022 from the reo_production table | SELECT mine_name, COUNT(DISTINCT reo_type) FROM reo_production WHERE production_year = 2022 GROUP BY mine_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE public_transportation_trips (id INT, trip_date DATE, city VARCHAR(20), trips INT); INSERT INTO public_transportation_trips (id, trip_date, city, trips) VALUES (1, '2022-01-01', 'Sydney', 500), (2, '2022-01-02', 'Sydney', 600), (3, '2022-01-03', 'Sydney', 700); | Find the total number of public transportation trips in the last month in Sydney? | SELECT SUM(trips) FROM public_transportation_trips WHERE city = 'Sydney' AND trip_date >= DATEADD(day, -30, CURRENT_TIMESTAMP); | gretelai_synthetic_text_to_sql |
CREATE TABLE cases (id INT, case_type VARCHAR(20), offender_age INT, community_service_hours INT); INSERT INTO cases (id, case_type, offender_age, community_service_hours) VALUES (1, 'Misdemeanor', 16, 50), (2, 'Misdemeanor', 17, 100), (3, 'Felony', 21, 200), (4, 'Juvenile', 14, 150); | What is the maximum community service hours imposed in a single case involving a juvenile? | SELECT MAX(community_service_hours) FROM cases WHERE case_type = 'Juvenile'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Cars (Id INT, Name VARCHAR(255), Type VARCHAR(255), Horsepower INT); INSERT INTO Cars (Id, Name, Type, Horsepower) VALUES (1, 'Model S', 'Sedan', 450), (2, 'Model X', 'SUV', 550), (3, 'Model 3', 'Sports Car', 350); | Find the average horsepower of sports cars. | SELECT AVG(Horsepower) FROM Cars WHERE Type = 'Sports Car'; | gretelai_synthetic_text_to_sql |
CREATE TABLE recycling (district TEXT, material TEXT, recycling_rate FLOAT); INSERT INTO recycling (district, material, recycling_rate) VALUES ('Region X', 'Metal', 0.35), ('Region X', 'Glass', 0.43); | What is the average recycling rate for metal and glass in region X? | SELECT AVG(recycling_rate) FROM recycling WHERE district = 'Region X' AND material IN ('Metal', 'Glass'); | gretelai_synthetic_text_to_sql |
CREATE TABLE visitor_locations (id INT, visitor_id INT, country TEXT, exhibition_id INT); INSERT INTO visitor_locations (id, visitor_id, country, exhibition_id) VALUES (1, 1, 'USA', 1), (2, 2, 'Canada', 1); | Count the number of first-time visitors from different countries by exhibition. | SELECT exhibition_id, country, COUNT(DISTINCT visitor_id) FROM visitor_locations GROUP BY exhibition_id, country; | gretelai_synthetic_text_to_sql |
CREATE TABLE supplier_scores (supplier_id INT, score INT); INSERT INTO supplier_scores (supplier_id, score) VALUES (1, 85); INSERT INTO supplier_scores (supplier_id, score) VALUES (2, 92); INSERT INTO supplier_scores (supplier_id, score) VALUES (3, 78); | What is the average sustainable sourcing score for each supplier? | SELECT AVG(score) as avg_score FROM supplier_scores; | gretelai_synthetic_text_to_sql |
CREATE TABLE menu_items (item_id INT, item_name VARCHAR(50), category VARCHAR(20), price DECIMAL(5,2)); INSERT INTO menu_items (item_id, item_name, category, price) VALUES (1, 'Cheeseburger', 'Main', 8.99), (2, 'Fried Chicken', 'Main', 9.99), (3, 'Veggie Burger', 'Main', 7.99), (4, 'Fries', 'Side', 2.99), (5, 'Salad', 'Side', 4.99); | What is the average price of menu items in each category? | SELECT category, AVG(price) AS avg_price FROM menu_items GROUP BY category; | gretelai_synthetic_text_to_sql |
CREATE TABLE Astronauts (AstronautID INT, NumberOfMissions INT); | Who are the astronauts who have been on the most space missions, and how many missions have they been on? | SELECT AstronautID, NumberOfMissions FROM (SELECT AstronautID, COUNT(*) AS NumberOfMissions FROM SpaceMissions GROUP BY AstronautID) subquery ORDER BY NumberOfMissions DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE GameA (player_id INT, country VARCHAR(20), level INT); INSERT INTO GameA (player_id, country, level) VALUES (1, 'US', 10), (2, 'CA', 9), (3, 'MX', 10), (4, 'US', 8), (5, 'CA', 10); | What are the top 5 countries with the highest number of players who reached level 10 in game 'A'? | SELECT country, COUNT(*) as player_count FROM GameA WHERE level >= 10 GROUP BY country ORDER BY player_count DESC LIMIT 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE Appointments (AppointmentID int, Date date, Location varchar(50), Type varchar(50)); INSERT INTO Appointments (AppointmentID, Date, Location, Type) VALUES (1, '2021-12-01', 'Rural France', 'Checkup'); | What is the maximum number of medical appointments in rural areas of France in the past month? | SELECT MAX(COUNT(*)) FROM Appointments WHERE Location LIKE '%Rural France%' AND Date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) GROUP BY Date; | gretelai_synthetic_text_to_sql |
CREATE TABLE hospitals (id INT, name TEXT, location TEXT, num_beds INT); INSERT INTO hospitals (id, name, location, num_beds) VALUES (1, 'General Hospital', 'City A', 500), (2, 'Rural Hospital', 'Rural Area A', 100); CREATE TABLE clinics (id INT, name TEXT, location TEXT, num_doctors INT, num_beds INT); INSERT INTO clinics (id, name, location, num_doctors, num_beds) VALUES (1, 'Downtown Clinic', 'City A', 10, 0), (2, 'Rural Clinic', 'Rural Area A', 5, 25); | What is the ratio of hospital beds to doctors in urban and rural areas? | SELECT location, h.num_beds / c.num_doctors AS bed_to_doctor_ratio FROM hospitals h JOIN clinics c ON h.location = c.location; | gretelai_synthetic_text_to_sql |
CREATE TABLE fashion_trend_data (id INT, product_name VARCHAR(30), is_sustainable BOOLEAN); INSERT INTO fashion_trend_data (id, product_name, is_sustainable) VALUES (1, 'T-shirt', true), (2, 'Jeans', false); | How many sustainable fashion items were sold in the 'fashion_trend_data' table? | SELECT COUNT(*) FROM fashion_trend_data WHERE is_sustainable = true; | gretelai_synthetic_text_to_sql |
CREATE TABLE users (id INT, name TEXT, post_count INT); INSERT INTO users (id, name, post_count) VALUES (1, 'Fiona', 50); INSERT INTO users (id, name, post_count) VALUES (2, 'George', 200); INSERT INTO users (id, name, post_count) VALUES (3, 'Hannah', 150); INSERT INTO users (id, name, post_count) VALUES (4, 'Ivan', 250); | Get top 3 users with the most posts | SELECT id, name, post_count, RANK() OVER (ORDER BY post_count DESC) as post_rank FROM users WHERE post_rank <= 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE commercial_buildings (building_id INT, building_name TEXT, state TEXT, energy_efficiency_rating FLOAT); INSERT INTO commercial_buildings (building_id, building_name, state, energy_efficiency_rating) VALUES (1, 'Commercial Building A', 'New York', 85.5), (2, 'Commercial Building B', 'California', 82.7), (3, 'Commercial Building C', 'Texas', 79.6); | Which state has the highest energy efficiency rating for commercial buildings? | SELECT state, MAX(energy_efficiency_rating) AS max_rating FROM commercial_buildings WHERE building_type = 'Commercial' GROUP BY state ORDER BY max_rating DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE sustainable_urbanism (size INT, city VARCHAR(20)); | What is the minimum size of sustainable urbanism projects in Tokyo? | SELECT MIN(size) FROM sustainable_urbanism WHERE city = 'Tokyo'; | gretelai_synthetic_text_to_sql |
CREATE TABLE location (location_id INT, location_name TEXT); INSERT INTO location (location_id, location_name) VALUES (1, 'Mediterranean Sea'); CREATE TABLE temperature (temperature_id INT, location_id INT, water_temp FLOAT); INSERT INTO temperature (temperature_id, location_id, water_temp) VALUES (1, 1, 18.3), (2, 1, 18.2), (3, 1, 18.1), (4, 1, 18.4), (5, 1, 18.5); | What is the average water temperature in the Mediterranean Sea? | SELECT AVG(water_temp) FROM temperature WHERE location_id = (SELECT location_id FROM location WHERE location_name = 'Mediterranean Sea'); | gretelai_synthetic_text_to_sql |
CREATE TABLE sustainable_fabric (id INT, fabric_type VARCHAR(20), quantity INT, country VARCHAR(20)); INSERT INTO sustainable_fabric (id, fabric_type, quantity, country) VALUES (1, 'organic_cotton', 500, 'Egypt'); INSERT INTO sustainable_fabric (id, fabric_type, quantity, country) VALUES (2, 'recycled_polyester', 300, 'South Africa'); | What is the average quantity of sustainable fabric sourced from Africa? | SELECT AVG(quantity) FROM sustainable_fabric WHERE country IN ('Egypt', 'South Africa', 'Tunisia'); | gretelai_synthetic_text_to_sql |
CREATE TABLE peacekeeping_operations (id INT, region VARCHAR(255), operation VARCHAR(255), budget DECIMAL(10,2)); | What is the total budget for peacekeeping operations for each region? | SELECT region, SUM(budget) FROM peacekeeping_operations GROUP BY region; | gretelai_synthetic_text_to_sql |
CREATE TABLE policies (policy_number INT, policy_type VARCHAR(50), coverage_amount INT, state VARCHAR(2)); INSERT INTO policies (policy_number, policy_type, coverage_amount, state) VALUES (12345, 'Auto', 50000, 'TX'); INSERT INTO policies (policy_number, policy_type, coverage_amount, state) VALUES (67890, 'Home', 300000, 'CA'); | What is the total coverage amount and number of policies for policies in the state of 'CA'? | SELECT SUM(coverage_amount) as total_coverage_amount, COUNT(*) as number_of_policies FROM policies WHERE state = 'CA'; | gretelai_synthetic_text_to_sql |
CREATE TABLE spain_stations (id INT, station_number INT);CREATE TABLE uk_stations (id INT, station_number INT);INSERT INTO spain_stations (id, station_number) VALUES (1, 5001), (2, 5002);INSERT INTO uk_stations (id, station_number) VALUES (1, 6001), (2, 6002); | How many ocean health monitoring stations are there in Spain and the United Kingdom? | SELECT COUNT(*) FROM spain_stations UNION SELECT COUNT(*) FROM uk_stations | gretelai_synthetic_text_to_sql |
CREATE TABLE BridgeWeights(bridge_id INT, max_weight FLOAT); INSERT INTO BridgeWeights VALUES(1,120.0),(2,150.0),(3,180.0),(4,100.0),(5,200.0),(6,130.0); | What is the maximum bridge weight limit in 'BridgeWeights' table? | SELECT MAX(max_weight) FROM BridgeWeights; | gretelai_synthetic_text_to_sql |
CREATE TABLE Strains (StrainID INT, StrainName VARCHAR(50)); | Insert new strain 'Purple Haze' into the Strains table with a StrainID of 105. | INSERT INTO Strains (StrainID, StrainName) VALUES (105, 'Purple Haze'); | gretelai_synthetic_text_to_sql |
CREATE TABLE defense_contracts (id INT PRIMARY KEY, department VARCHAR(50), contract_date DATE, contract_value FLOAT);INSERT INTO defense_contracts (id, department, contract_date, contract_value) VALUES (1, 'Army', '2018-01-01', 1000000), (2, 'Navy', '2018-01-15', 2000000), (3, 'Air Force', '2018-02-01', 1500000); | Generate a view 'contract_value_trends' to display the total value of defense contracts awarded by quarter | CREATE VIEW contract_value_trends AS SELECT DATE_TRUNC('quarter', contract_date) as quarter, department, SUM(contract_value) as total_contract_value FROM defense_contracts GROUP BY quarter, department; | gretelai_synthetic_text_to_sql |
CREATE TABLE users (id INT, username TEXT); CREATE TABLE posts (user_id INT, category TEXT, timestamp TIMESTAMP); | Find the top 3 most active users by post count in the 'music' category since 2021-06-01. | SELECT u.username, COUNT(p.user_id) as post_count FROM users u JOIN posts p ON u.id = p.user_id WHERE p.category = 'music' AND p.timestamp >= '2021-06-01' GROUP BY u.username ORDER BY post_count DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE member_workouts (member_id INT, country VARCHAR(50), calories_burned INT); INSERT INTO member_workouts (member_id, country, calories_burned) VALUES (1, 'USA', 300), (2, 'Canada', 400), (3, 'India', 500), (4, 'Brazil', 600), (5, 'Argentina', 700); | What is the total calories burned for members from India? | SELECT SUM(calories_burned) FROM member_workouts WHERE country = 'India'; | gretelai_synthetic_text_to_sql |
CREATE TABLE menu_item (item_id INT, item_name VARCHAR(50), category VARCHAR(20), price DECIMAL(5, 2)); | Insert a new record into the menu_item table with the following data: item_id = 205, item_name = 'Tofu Stir Fry', category = 'Entrees', price = 14.99 | INSERT INTO menu_item (item_id, item_name, category, price) VALUES (205, 'Tofu Stir Fry', 'Entrees', 14.99); | gretelai_synthetic_text_to_sql |
CREATE TABLE revenue_data (revenue_id INT, company_id INT, revenue INT, revenue_date DATE); INSERT INTO revenue_data (revenue_id, company_id, revenue, revenue_date) VALUES (1, 1, 10000, '2022-01-01'), (2, 2, 8000, '2022-02-01'), (3, 3, 12000, '2022-03-01'), (4, 4, 15000, '2022-04-01'), (5, 5, 9000, '2022-05-01'), (6, 6, 7000, '2022-06-01'); CREATE TABLE company_data (company_id INT, company_size VARCHAR(50)); INSERT INTO company_data (company_id, company_size) VALUES (1, 'Small'), (2, 'Medium'), (3, 'Large'), (4, 'Small'), (5, 'Medium'), (6, 'Small'); | What is the total revenue generated by small freight forwarding companies in the first half of the year? | SELECT SUM(revenue) FROM revenue_data JOIN company_data ON revenue_data.company_id = company_data.company_id WHERE company_data.company_size = 'Small' AND revenue_date BETWEEN '2022-01-01' AND '2022-06-30'; | gretelai_synthetic_text_to_sql |
CREATE TABLE community_projects (community_id INT, community_name TEXT, project_count INT); | What are the names of the top 5 communities with the most projects in the 'community_projects' table? | SELECT community_name, project_count FROM community_projects ORDER BY project_count DESC LIMIT 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE pollution_control (id INT, name VARCHAR(255), ocean VARCHAR(255), year INT); INSERT INTO pollution_control (id, name, ocean, year) VALUES (1, 'Project Clean Pacific', 'Pacific Ocean', 2010), (2, 'Ocean Wave Energy', 'Pacific Ocean', 2015); | How many pollution control initiatives have been conducted in the Pacific Ocean? | SELECT COUNT(*) FROM pollution_control WHERE ocean = 'Pacific Ocean'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Canals (name TEXT, length FLOAT, location TEXT); | Show canals with a length greater than 50 miles and less than 100 miles. | SELECT name FROM Canals WHERE length > 50 AND length < 100; | gretelai_synthetic_text_to_sql |
CREATE TABLE city_budget (city VARCHAR(20), project VARCHAR(20), budget INT); INSERT INTO city_budget (city, project, budget) VALUES ('Phoenix', 'Road Repair', 1000000); | What is the total budget allocated for infrastructure in the city of Phoenix, including all projects, for the fiscal year 2025? | SELECT SUM(budget) FROM city_budget WHERE city = 'Phoenix' AND project LIKE '%Infrastructure%' AND fiscal_year = 2025; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA if not exists genetics;CREATE TABLE if not exists genetics.research_data_1 (id INT PRIMARY KEY, sample_id VARCHAR(50), sample_date DATE, sample_result INT);CREATE TABLE if not exists genetics.research_data_2 (id INT PRIMARY KEY, sample_id VARCHAR(50), sample_date DATE);CREATE TABLE if not exists genetics.research_data_3 (id INT PRIMARY KEY, sample_id VARCHAR(50), sample_time TIME); | List all genetic research data tables that have a 'sample_result' column. | SELECT table_name FROM information_schema.columns WHERE table_schema = 'genetics' AND column_name = 'sample_result'; | gretelai_synthetic_text_to_sql |
CREATE TABLE education_supplies (id INT, location VARCHAR(255), distribution_date DATE); INSERT INTO education_supplies (id, location, distribution_date) VALUES (1, 'Nigeria', '2022-04-15'), (2, 'Syria', '2022-04-14'), (3, 'Nigeria', '2022-04-16'); | How many education supply distributions were made in Nigeria in the last month? | SELECT COUNT(*) FROM education_supplies WHERE location = 'Nigeria' AND distribution_date >= DATEADD(day, -30, GETDATE()); | gretelai_synthetic_text_to_sql |
CREATE TABLE Funding (funding_id INT, source VARCHAR(255), amount DECIMAL(10, 2)); CREATE TABLE Programs (program_id INT, name VARCHAR(255), funding_source VARCHAR(255)); | What is the total funding for art programs from government grants? | SELECT SUM(amount) FROM Funding F JOIN Programs P ON F.funding_id = P.funding_id WHERE F.source = 'Government Grant' AND P.name LIKE '%Art%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE vessels (id INT, name TEXT, port_id INT, speed FLOAT, cargo_weight INT); INSERT INTO vessels (id, name, port_id, speed, cargo_weight) VALUES (1, 'VesselA', 1, 20.5, 400), (2, 'VesselB', 1, 21.3, 600), (3, 'VesselC', 2, 25.0, 700); | Update the cargo weight of the vessel 'VesselB' to 800 in the table 'vessels'. | UPDATE vessels SET cargo_weight = 800 WHERE name = 'VesselB'; | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_protected_areas ( id INT PRIMARY KEY, name VARCHAR(255), year INT, location VARCHAR(255), area REAL ); INSERT INTO marine_protected_areas (id, name, year, location, area) VALUES (1, 'Great Barrier Reef Marine Park', 1975, 'Pacific Ocean', 344400), (2, 'Galapagos Marine Reserve', 1998, 'Pacific Ocean', 133000), (3, 'Sargasso Sea Protection Area', 1982, 'Atlantic Ocean', 5000000); | What is the maximum area of marine protected areas established before 1985, grouped by location and excluding locations with only one protected area? | SELECT location, MAX(area) FROM marine_protected_areas WHERE year < 1985 GROUP BY location HAVING COUNT(*) > 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE agricultural_projects (id INT, name TEXT, location TEXT, led_by TEXT); INSERT INTO agricultural_projects (id, name, location, led_by) VALUES (1, 'New Crops Research', 'Rwanda', 'Women'), (2, 'Livestock Breeding', 'Uganda', 'Men'), (3, 'Organic Farming', 'Rwanda', 'Men'); | What is the total number of agricultural innovation projects led by women in Rwanda? | SELECT COUNT(*) FROM agricultural_projects WHERE location = 'Rwanda' AND led_by = 'Women'; | gretelai_synthetic_text_to_sql |
CREATE TABLE diversification_funding (id INT, project_id INT, funding DECIMAL(10,2)); | Calculate the average amount of funding per economic diversification project from the "diversification_funding" table | SELECT AVG(funding) FROM diversification_funding; | gretelai_synthetic_text_to_sql |
CREATE TABLE conservation_initiatives (region VARCHAR(50), date DATE, initiative VARCHAR(50)); INSERT INTO conservation_initiatives (region, date, initiative) VALUES ('Hanoi', '2015-01-01', 'Rainwater harvesting'), ('Hanoi', '2016-01-01', 'Greywater reuse'), ('Hanoi', '2017-01-01', 'Smart irrigation'), ('Hanoi', '2018-01-01', 'Leak detection'), ('Hanoi', '2019-01-01', 'Water-efficient appliances'); | Find the number of water conservation initiatives implemented in 'Hanoi' for each year from 2015 to 2020 | SELECT YEAR(date) AS year, COUNT(*) FROM conservation_initiatives WHERE region = 'Hanoi' AND date BETWEEN '2015-01-01' AND '2020-12-31' GROUP BY year; | gretelai_synthetic_text_to_sql |
CREATE TABLE attorneys (id INT, name VARCHAR(50), cases_handled INT, region VARCHAR(50), billable_rate DECIMAL(10,2)); INSERT INTO attorneys (id, name, cases_handled, region, billable_rate) VALUES (1, 'John Lee', 40, 'Northeast', 200.00); INSERT INTO attorneys (id, name, cases_handled, region, billable_rate) VALUES (2, 'Jane Doe', 50, 'Southwest', 250.00); | Get the number of cases handled per attorney | SELECT name, cases_handled FROM attorneys; | gretelai_synthetic_text_to_sql |
CREATE TABLE patients (patient_id INT, age INT, gender TEXT, country TEXT); INSERT INTO patients (patient_id, age, gender, country) VALUES (1, 35, 'Male', 'USA'); INSERT INTO patients (patient_id, age, gender, country) VALUES (2, 42, 'Female', 'USA'); CREATE TABLE treatments (treatment_id INT, patient_id INT, treatment_type TEXT, treatment_date DATE); INSERT INTO treatments (treatment_id, patient_id, treatment_type, treatment_date) VALUES (1, 1, 'CBT', '2015-06-01'); INSERT INTO treatments (treatment_id, patient_id, treatment_type, treatment_date) VALUES (2, 2, 'CBT', '2015-08-15'); | Identify patients who switched treatments in the US between 2015 and 2017? | SELECT patient_id, MIN(treatment_date) AS first_treatment_date, MAX(treatment_date) AS last_treatment_date FROM treatments WHERE country = 'USA' AND treatment_date BETWEEN '2015-01-01' AND '2017-12-31' GROUP BY patient_id HAVING COUNT(DISTINCT treatment_type) > 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE articles (id INT, title VARCHAR(50), views INT, source VARCHAR(50)); INSERT INTO articles (id, title, views, source) VALUES (1, 'Article 1', 5000, 'Daily Planet'), (2, 'Article 2', 15000, 'Daily Planet'); CREATE TABLE categories (id INT, article_id INT, category VARCHAR(50)); INSERT INTO categories (id, article_id, category) VALUES (1, 1, 'investigative'), (2, 2, 'investigative'); | What is the number of investigative articles published by the "Daily Planet" that received over 10,000 views? | SELECT COUNT(articles.id) FROM articles INNER JOIN categories ON articles.id = categories.article_id WHERE articles.source = 'Daily Planet' AND articles.views > 10000 AND categories.category = 'investigative'; | gretelai_synthetic_text_to_sql |
CREATE TABLE publications (id INT PRIMARY KEY, title VARCHAR(100), author VARCHAR(50), journal VARCHAR(50), publication_date DATE); | Update the title of a publication in the "publications" table | WITH updated_publication AS (UPDATE publications SET title = 'Revolutionary Quantum Computing Advancement' WHERE id = 1 RETURNING *) SELECT * FROM updated_publication; | gretelai_synthetic_text_to_sql |
CREATE TABLE hospitals (id INT, name TEXT, location TEXT, capacity INT); INSERT INTO hospitals (id, name, location, capacity) VALUES (1, 'Hospital A', 'Rural Texas', 50); INSERT INTO hospitals (id, name, location, capacity) VALUES (4, 'Hospital D', 'Rural Louisiana', 75); | Update the capacity of Hospital D in Louisiana to 100 beds. | UPDATE hospitals SET capacity = 100 WHERE name = 'Hospital D' AND location = 'Rural Louisiana'; | gretelai_synthetic_text_to_sql |
CREATE TABLE ethereum_smart_contracts (id INT, gas_fees DECIMAL(10, 2), cross_chain_communication BOOLEAN); INSERT INTO ethereum_smart_contracts (id, gas_fees, cross_chain_communication) VALUES (1, 30, TRUE); | What is the minimum gas fee for Ethereum smart contracts involved in cross-chain communication? | SELECT MIN(gas_fees) FROM ethereum_smart_contracts WHERE cross_chain_communication = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE Restaurants (id INT, name VARCHAR, category VARCHAR, revenue INT); INSERT INTO Restaurants (id, name, category, revenue) VALUES (1, 'Bistro', 'French', 500000); INSERT INTO Restaurants (id, name, category, revenue) VALUES (2, 'Pizzeria', 'Italian', 600000); | What is the total revenue for all Italian restaurants? | SELECT SUM(revenue) FROM Restaurants WHERE category = 'Italian'; | gretelai_synthetic_text_to_sql |
CREATE TABLE MiningCompanyExtraction (year INT, company TEXT, country TEXT, mineral TEXT, quantity INT); INSERT INTO MiningCompanyExtraction (year, company, country, mineral, quantity) VALUES (2019, 'ABC Mining', 'Brazil', 'Gold', 10000), (2020, 'ABC Mining', 'Brazil', 'Gold', 12000), (2021, 'ABC Mining', 'Brazil', 'Gold', 15000), (2019, 'XYZ Mining', 'Brazil', 'Silver', 12000), (2020, 'XYZ Mining', 'Brazil', 'Silver', 14000), (2021, 'XYZ Mining', 'Brazil', 'Silver', 16000); | What is the total mineral extraction for each mining company in Brazil, by year, for the last 3 years? | SELECT context.year, context.company, SUM(context.quantity) as total_mineral_extraction FROM MiningCompanyExtraction context WHERE context.country = 'Brazil' AND context.year BETWEEN 2019 AND 2021 GROUP BY context.year, context.company; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA if not exists australia_rural_healthcare; USE australia_rural_healthcare; CREATE TABLE Doctors (id INT, name VARCHAR(100), hospital_id INT, specialty VARCHAR(50), region VARCHAR(50)); INSERT INTO Doctors VALUES (1, 'Dr. Smith', 1, 'General Practitioner', 'New South Wales'), (2, 'Dr. Johnson', 1, 'General Practitioner', 'New South Wales'), (3, 'Dr. Brown', 2, 'Specialist', 'Queensland'), (4, 'Dr. Davis', 3, 'General Practitioner', 'Victoria'), (5, 'Dr. Patel', 3, 'Specialist', 'Victoria'); | What is the total number of doctors in each region in Australia's rural healthcare system? | SELECT region, COUNT(*) FROM Doctors GROUP BY region; | gretelai_synthetic_text_to_sql |
CREATE TABLE shariah_financing(client_id INT, country VARCHAR(25), amount FLOAT);INSERT INTO shariah_financing(client_id, country, amount) VALUES (1, 'Malaysia', 5000), (2, 'UAE', 7000), (3, 'Indonesia', 6000), (4, 'Saudi Arabia', 8000), (5, 'Malaysia', 9000), (6, 'UAE', 10000); | What is the average amount of Shariah-compliant financing for clients in each country? | SELECT country, AVG(amount) as avg_financing FROM shariah_financing GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE ad_campaigns (id INT, name VARCHAR(255), start_date DATE, end_date DATE); | Insert a new ad campaign with a start date of 2023-03-01 and an end date of 2023-03-15 | INSERT INTO ad_campaigns (id, name, start_date, end_date) VALUES (1, 'Spring Sale', '2023-03-01', '2023-03-15'); | gretelai_synthetic_text_to_sql |
CREATE TABLE open_pedagogy_projects (student_id INT, mental_health_score FLOAT); INSERT INTO open_pedagogy_projects (student_id, mental_health_score) VALUES (1, 70.5), (2, 85.2), (3, 68.1); | What is the average mental health score of students who have participated in open pedagogy projects? | SELECT AVG(mental_health_score) FROM open_pedagogy_projects; | gretelai_synthetic_text_to_sql |
CREATE TABLE Warehouses (WarehouseID int, WarehouseName varchar(255), City varchar(255), Country varchar(255)); INSERT INTO Warehouses (WarehouseID, WarehouseName, City, Country) VALUES (4, 'Sydney Warehouse', 'Sydney', 'Australia'); CREATE TABLE Inventory (InventoryID int, WarehouseID int, ProductName varchar(255), Quantity int); INSERT INTO Inventory (InventoryID, WarehouseID, ProductName, Quantity) VALUES (4, 4, 'Pears', 100); | What is the total quantity of each product in the Sydney warehouse? | SELECT ProductName, SUM(Quantity) AS TotalQuantity FROM Inventory WHERE WarehouseID = 4 GROUP BY ProductName; | gretelai_synthetic_text_to_sql |
CREATE TABLE virtual_tour_stats (hotel_id INT, view_date DATE, view_duration INT); | Insert a new row into the 'virtual_tour_stats' table with hotel_id 123, view_date '2022-01-01', and view_duration 120 | INSERT INTO virtual_tour_stats (hotel_id, view_date, view_duration) VALUES (123, '2022-01-01', 120); | gretelai_synthetic_text_to_sql |
CREATE TABLE CollectiveBargaining (CBAID INT, UnionID INT, AgreementDate DATE); INSERT INTO CollectiveBargaining (CBAID, UnionID, AgreementDate) VALUES (1, 1, '2020-01-01'), (2, 2, '2019-06-15'), (3, 3, '2018-09-01'); | List the collective bargaining agreements for the 'Construction Workers Union' and 'Teachers Union'. | SELECT Unions.UnionName, CollectiveBargaining.AgreementDate FROM Unions JOIN CollectiveBargaining ON Unions.UnionID = CollectiveBargaining.UnionID WHERE Unions.UnionName IN ('Construction Workers Union', 'Teachers Union'); | gretelai_synthetic_text_to_sql |
CREATE TABLE weather (year INT, avg_temp FLOAT); INSERT INTO weather (year, avg_temp) VALUES | What is the average temperature change in the Arctic per decade? | SELECT AVG(avg_temp) FROM weather WHERE year BETWEEN 1950 AND 2020 GROUP BY (year - year % 10) / 10 HAVING COUNT(*) > 10; | gretelai_synthetic_text_to_sql |
CREATE TABLE IncidentAnalysis (id INT, incident_type VARCHAR(50), region VARCHAR(50)); INSERT INTO IncidentAnalysis (id, incident_type, region) VALUES (1, 'Phishing', 'APAC'), (2, 'Malware', 'EMEA'); | What are the common types of security incidents across all regions, according to our Incident Analysis database? | SELECT incident_type FROM IncidentAnalysis GROUP BY incident_type HAVING COUNT(DISTINCT region) = (SELECT COUNT(DISTINCT region) FROM IncidentAnalysis); | gretelai_synthetic_text_to_sql |
CREATE SCHEMA in_schema;CREATE TABLE in_schema.policy_areas (area_id INT, area_name VARCHAR(20), feedback_score INT);INSERT INTO in_schema.policy_areas (area_id, area_name, feedback_score) VALUES (1, 'Healthcare', 75), (2, 'Education', 85), (3, 'Transportation', 80), (4, 'Housing', 70); | List the policy areas and their respective feedback scores in India in 2017. | SELECT area_name, feedback_score FROM in_schema.policy_areas; | gretelai_synthetic_text_to_sql |
CREATE TABLE Month (id INT, name VARCHAR(10)); CREATE TABLE Permit (id INT, issue_date DATE); | How many permits were issued per month in 2019 and 2020? | SELECT Month.name, YEAR(Permit.issue_date) AS year, COUNT(Permit.id) AS permits_issued FROM Month INNER JOIN Permit ON Month.id = MONTH(Permit.issue_date) WHERE YEAR(Permit.issue_date) IN (2019, 2020) GROUP BY Month.name, YEAR(Permit.issue_date); | gretelai_synthetic_text_to_sql |
CREATE TABLE states (state_name TEXT, state_abbr TEXT); INSERT INTO states (state_name, state_abbr) VALUES ('Alabama', 'AL'), ('Alaska', 'AK'); CREATE TABLE crops (crop_name TEXT, state TEXT, yield INTEGER, year INTEGER); INSERT INTO crops (crop_name, state, yield, year) VALUES ('Corn', 'AL', 120, 2020), ('Corn', 'AK', 150, 2020); | What is the average yield of corn for each state in 2020, sorted by the highest yield? | SELECT state, AVG(yield) FROM crops JOIN states ON crops.state = states.state_abbr WHERE crop_name = 'Corn' AND year = 2020 GROUP BY state ORDER BY AVG(yield) DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE warehouses (warehouse_id INT, warehouse_name VARCHAR(50)); INSERT INTO warehouses (warehouse_id, warehouse_name) VALUES (1, 'New York'), (2, 'Chicago'), (3, 'Los Angeles'); | What is the total number of packages shipped by each warehouse? | SELECT warehouse_id, COUNT(*) FROM packages GROUP BY warehouse_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE WaterUsage (Id INT, HouseholdId INT, Month INT, Year INT, Usage FLOAT); INSERT INTO WaterUsage (Id, HouseholdId, Month, Year, Usage) VALUES (1, 101, 1, 2019, 12.5); INSERT INTO WaterUsage (Id, HouseholdId, Month, Year, Usage) VALUES (2, 101, 2, 2019, 15.2); INSERT INTO WaterUsage (Id, HouseholdId, Month, Year, Usage) VALUES (3, 102, 1, 2019, 18.3); INSERT INTO WaterUsage (Id, HouseholdId, Month, Year, Usage) VALUES (4, 102, 2, 2019, 19.8); | What is the average water usage for households in CityA in 2019? | SELECT AVG(Usage) FROM WaterUsage WHERE HouseholdId IN (SELECT HouseholdId FROM WaterUsage WHERE Year = 2019 AND Location = 'CityA' GROUP BY HouseholdId) AND Year = 2019; | gretelai_synthetic_text_to_sql |
CREATE TABLE vaccinations (vaccination_id INT, patient_id INT, vaccine VARCHAR(20), date DATE); INSERT INTO vaccinations (vaccination_id, patient_id, vaccine, date) VALUES (1, 3, 'Measles', '2018-01-01'); INSERT INTO vaccinations (vaccination_id, patient_id, vaccine, date) VALUES (2, 4, 'Influenza', '2020-02-01'); | How many people have been vaccinated against measles in the African region in the last 5 years? | SELECT COUNT(*) FROM vaccinations WHERE vaccine = 'Measles' AND date BETWEEN DATE_SUB(CURRENT_DATE, INTERVAL 5 YEAR) AND CURRENT_DATE AND region = 'African' | gretelai_synthetic_text_to_sql |
CREATE TABLE DisasterPreparedness (id INT, district VARCHAR(255), preparedness_score INT); INSERT INTO DisasterPreparedness (id, district, preparedness_score) VALUES (3, 'Downtown', 88); | What is the average disaster preparedness score in Downtown? | SELECT district, AVG(preparedness_score) as avg_preparedness FROM DisasterPreparedness WHERE district = 'Downtown' GROUP BY district; | gretelai_synthetic_text_to_sql |
CREATE TABLE regions (id INT, name TEXT); INSERT INTO regions (id, name) VALUES (1, 'North America'), (2, 'South America'), (3, 'Europe'), (4, 'Middle East'), (5, 'Asia'), (6, 'Africa'); CREATE TABLE assessments (id INT, region_id INT, type TEXT); INSERT INTO assessments (id, region_id, type) VALUES (1, 1, 'Safety'), (2, 4, 'Environmental'), (3, 3, 'Quality'), (4, 5, 'Sustainability'), (5, 4, 'Environmental'), (6, 6, 'Environmental'); | How many environmental impact assessments have been conducted in 'Africa'? | SELECT COUNT(assessments.id) FROM assessments JOIN regions ON assessments.region_id = regions.id WHERE regions.name = 'Africa'; | gretelai_synthetic_text_to_sql |
CREATE TABLE temperature_readings (reading_date DATE, temperature FLOAT); | What is the average temperature per day in the 'temperature_readings' table? | SELECT reading_date, AVG(temperature) FROM temperature_readings GROUP BY reading_date; | gretelai_synthetic_text_to_sql |
CREATE TABLE ad_data (platform VARCHAR(20), revenue NUMERIC(10,2));INSERT INTO ad_data VALUES ('FB',1000),('IG',2000),('TW',3000),('SN',4000),('LI',5000); | What is the total revenue by platform? | SELECT platform, SUM(revenue) FROM ad_data GROUP BY platform; | gretelai_synthetic_text_to_sql |
CREATE TABLE models (id INT, dataset VARCHAR(20), satisfaction FLOAT);CREATE TABLE regions (id INT, name VARCHAR(20)); INSERT INTO models VALUES (1, 'datasetA', 4.3), (2, 'datasetA', 4.5), (3, 'datasetB', 3.9); INSERT INTO regions VALUES (1, 'North America'), (2, 'Europe'), (3, 'Asia'), (4, 'South America'); | What is the average satisfaction score for models trained on dataset A, for all regions, excluding North America? | SELECT AVG(m.satisfaction) FROM models m JOIN regions r ON TRUE WHERE m.dataset = 'datasetA' AND r.name != 'North America'; | gretelai_synthetic_text_to_sql |
CREATE TABLE heritage_sites (id INT, name VARCHAR(255), type VARCHAR(255)); INSERT INTO heritage_sites (id, name, type) VALUES (1, 'Taj Mahal', 'Architecture'), (2, 'Great Barrier Reef', 'Natural'); | How many heritage sites are registered in the 'heritage' schema? | SELECT COUNT(*) FROM heritage.heritage_sites; | gretelai_synthetic_text_to_sql |
CREATE TABLE mining_sites (site_id INT, site_name TEXT, state TEXT, country TEXT);CREATE TABLE mineral_extraction (extraction_id INT, site_id INT, extraction_day DATE, tons_extracted INT); | What is the average amount of minerals extracted per day for each mining site in the state of Queensland, Australia, for the year 2018, and what is the overall average for all mining sites in the state? | SELECT s.site_name, AVG(me.tons_extracted / DATEDIFF('2018-12-31', me.extraction_day)) AS avg_tons_extracted_per_day FROM mining_sites s INNER JOIN mineral_extraction me ON s.site_id = me.site_id WHERE s.state = 'Queensland' AND me.extraction_day BETWEEN '2018-01-01' AND '2018-12-31' GROUP BY s.site_id, s.site_name;SELECT 'Queensland Overall Average' AS site_name, AVG(me.tons_extracted / DATEDIFF('2018-12-31', me.extraction_day)) AS avg_tons_extracted_per_day FROM mining_sites s INNER JOIN mineral_extraction me ON s.site_id = me.site_id WHERE s.state = 'Queensland' AND me.extraction_day BETWEEN '2018-01-01' AND '2018-12-31'; | gretelai_synthetic_text_to_sql |
CREATE TABLE safety_incidents ( id INT, vessel_id INT, vessel_type VARCHAR(255), incident_date DATE, region VARCHAR(255) ); INSERT INTO safety_incidents (id, vessel_id, vessel_type, incident_date, region) VALUES (7, 22, 'Icebreaker', '2022-01-15', 'Arctic'); INSERT INTO safety_incidents (id, vessel_id, vessel_type, incident_date, region) VALUES (8, 23, 'Fishing', '2022-02-18', 'Arctic'); | How many safety incidents were reported for each vessel type in the Arctic region in the last year? | SELECT vessel_type, COUNT(*) as safety_incidents_count FROM safety_incidents WHERE region = 'Arctic' AND incident_date BETWEEN '2021-01-01' AND '2022-01-01' GROUP BY vessel_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE IF NOT EXISTS military_equipment (equipment_id INT, equipment_type VARCHAR(50), acquisition_date DATE, cost FLOAT, last_maintenance_date DATE); | Which military equipment type had the greatest cost increase in maintenance from 2018 to 2019? | SELECT equipment_type, (MAX(cost) - MIN(cost)) as cost_increase FROM military_equipment WHERE last_maintenance_date BETWEEN '2018-01-01' AND '2019-12-31' GROUP BY equipment_type ORDER BY cost_increase DESC FETCH FIRST 1 ROW ONLY; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA if not exists ocean_shipping;CREATE TABLE if not exists ocean_shipping.vessels (id INT, name VARCHAR(255), status VARCHAR(255), last_maintenance DATE); | Update status to 'inactive' for vessels that have not been maintained in 9 months | UPDATE ocean_shipping.vessels SET status = 'inactive' WHERE last_maintenance < DATE_SUB(CURRENT_DATE, INTERVAL 9 MONTH); | gretelai_synthetic_text_to_sql |
CREATE TABLE Departments (id INT, name VARCHAR(50), budget DECIMAL(10,2)); | What is the total salary cost for the Sustainability department? | SELECT SUM(d.budget) FROM Departments d JOIN Employees e ON d.name = e.department WHERE d.name = 'Sustainability'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Bridges (id INT, name TEXT, province TEXT, length FLOAT); INSERT INTO Bridges (id, name, province, length) VALUES (1, 'Bloor Street Viaduct', 'Ontario', 496.0); INSERT INTO Bridges (id, name, province, length) VALUES (2, 'Prince Edward Viaduct', 'Ontario', 476.0); | What is the average length of all bridges in the province of Ontario? | SELECT AVG(length) FROM Bridges WHERE province = 'Ontario' | 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.