context stringlengths 11 9.12k | question stringlengths 0 1.06k | SQL stringlengths 2 4.44k | source stringclasses 28
values |
|---|---|---|---|
CREATE TABLE hospital (hospital_id INT, hospital_name TEXT, location TEXT, num_beds INT); INSERT INTO hospital (hospital_id, hospital_name, location, num_beds) VALUES (1, 'Rural Hospital A', 'Texas', 75); | How many hospitals in the rural areas of "Texas" and "Oklahoma" have less than 100 beds? | SELECT COUNT(*) FROM hospital WHERE num_beds < 100 AND location IN ('Texas', 'Oklahoma'); | gretelai_synthetic_text_to_sql |
CREATE TABLE rural_infrastructure (id INT, project_name VARCHAR(100), location VARCHAR(50), start_date DATE, end_date DATE, duration INT); INSERT INTO rural_infrastructure (id, project_name, location, start_date, end_date, duration) VALUES (1, 'Rural Bridge Construction', 'Guatemala', '2018-04-01', '2023-03-31', 60); I... | Delete all rural infrastructure projects in Guatemala that have a duration of more than 48 months. | DELETE FROM rural_infrastructure WHERE location = 'Guatemala' AND duration > 48; | gretelai_synthetic_text_to_sql |
CREATE TABLE field_temperature (field_id INT, temperature DECIMAL(5,2), measurement_date DATE); | Insert a new record in the field_temperature table for field 4 with a temperature of 25 degrees and a measurement date of 2023-03-01 | INSERT INTO field_temperature (field_id, temperature, measurement_date) VALUES (4, 25.0, '2023-03-01'); | gretelai_synthetic_text_to_sql |
CREATE TABLE innovation_projects (id INT, project_status TEXT, start_date DATE, end_date DATE, country TEXT); INSERT INTO innovation_projects (id, project_status, start_date, end_date, country) VALUES (1, 'successful', '2018-01-01', '2019-01-01', 'Argentina'), (2, 'unsuccessful', '2017-01-01', '2017-12-31', 'Chile'), (... | What is the average duration of successful agricultural innovation projects in South America, rounded to the nearest day? | SELECT ROUND(AVG(DATEDIFF(end_date, start_date))) FROM innovation_projects WHERE project_status = 'successful' AND country IN ('South America'); | gretelai_synthetic_text_to_sql |
CREATE TABLE Songs (id INT, title VARCHAR(100), release_year INT, genre VARCHAR(50), streams INT); | What is the average number of streams for songs in the 'Jazz' genre? | SELECT AVG(streams) FROM Songs WHERE genre = 'Jazz'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Language_Preservation_Programs (id INT, program VARCHAR(100), establishment_year INT); INSERT INTO Language_Preservation_Programs (id, program, establishment_year) VALUES (1, 'Breath of Life', 1992), (2, 'Rising Voices', 2007), (3, 'Living Tongues Institute', 2006); | Display the language preservation programs that have been active for more than 10 years, along with the year they were established. | SELECT program, establishment_year FROM Language_Preservation_Programs WHERE establishment_year <= YEAR(CURRENT_DATE) - 10; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA MaritimeLaw; CREATE TABLE Vessels (vessel_id INT, compliance_status VARCHAR(10)); INSERT INTO Vessels (vessel_id, compliance_status) VALUES (1, 'Compliant'), (2, 'Non-Compliant'), (3, 'Compliant'), (4, 'Compliant'), (5, 'Non-Compliant'); | List the maritime law compliance status for all vessels in the 'MaritimeLaw' schema. | SELECT vessel_id, compliance_status FROM MaritimeLaw.Vessels; | gretelai_synthetic_text_to_sql |
CREATE TABLE subway_stations (station_id INT, station_name VARCHAR(50), city VARCHAR(50), time_between_arrivals TIME, rush_hour BOOLEAN); INSERT INTO subway_stations (station_id, station_name, city, time_between_arrivals, rush_hour) VALUES (1, 'Shinjuku', 'Tokyo', '3:00', true), (2, 'Shibuya', 'Tokyo', '4:00', true), (... | What is the average time between subway train arrivals in Tokyo during rush hour? | SELECT AVG(TIME_TO_SEC(time_between_arrivals))/60.0 FROM subway_stations WHERE city = 'Tokyo' AND rush_hour = true; | gretelai_synthetic_text_to_sql |
CREATE TABLE energy_consumption (id INT, city VARCHAR(50), source VARCHAR(50), consumption FLOAT, timestamp TIMESTAMP); INSERT INTO energy_consumption (id, city, source, consumption, timestamp) VALUES (1, 'New York City', 'Solar', 300.1, '2022-05-01 10:00:00'); INSERT INTO energy_consumption (id, city, source, consumpt... | What is the total energy consumption in New York City from renewable sources on a day with temperature above 80 degrees Fahrenheit? | SELECT SUM(e.consumption) as total_consumption FROM energy_consumption e JOIN (SELECT city FROM weather WHERE city = 'New York City' AND temperature > 80) w ON e.city = w.city WHERE e.source IN ('Solar', 'Wind'); | gretelai_synthetic_text_to_sql |
CREATE TABLE economic_diversification (id INT, location VARCHAR(50), cost FLOAT, initiative_type VARCHAR(50), start_date DATE); INSERT INTO economic_diversification (id, location, cost, initiative_type, start_date) VALUES (1, 'Mekong Delta', 15000.00, 'Eco-tourism', '2016-01-01'); | What was the minimum cost of an economic diversification effort in the Mekong Delta in 2016? | SELECT MIN(cost) FROM economic_diversification WHERE location = 'Mekong Delta' AND start_date >= '2016-01-01' AND start_date < '2017-01-01' AND initiative_type = 'Eco-tourism'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Stock (id INT, product VARCHAR(20), quantity INT, sustainable BOOLEAN); INSERT INTO Stock (id, product, quantity, sustainable) VALUES (1, 'dress', 100, true), (2, 'top', 150, false), (3, 'pant', 200, true); | What is the total quantity of sustainable fashion items in stock? | SELECT SUM(quantity) FROM Stock WHERE sustainable = true; | gretelai_synthetic_text_to_sql |
CREATE TABLE ocean_floor_mapping(id INT, region VARCHAR(20), depth FLOAT); INSERT INTO ocean_floor_mapping(id, region, depth) VALUES (1, 'Pacific', 5000.5), (2, 'Atlantic', 4500.3), (3, 'Pacific', 6200.7), (4, 'Indian', 4200.0); | What is the maximum depth of ocean floor mapping projects in the Indian region? | SELECT MAX(depth) FROM ocean_floor_mapping WHERE region = 'Indian'; | gretelai_synthetic_text_to_sql |
CREATE TABLE california_conservation_budget (year INT, budget INT); INSERT INTO california_conservation_budget (year, budget) VALUES (2022, 3000000); | What is the total water conservation budget for the state of California in the year 2022? | SELECT SUM(california_conservation_budget.budget) as total_conservation_budget FROM california_conservation_budget WHERE california_conservation_budget.year = 2022; | gretelai_synthetic_text_to_sql |
CREATE TABLE startup (id INT, name TEXT, industry TEXT, founder_region TEXT, exit_strategy TEXT); INSERT INTO startup (id, name, industry, founder_region, exit_strategy) VALUES (1, 'EcomSoutheast', 'E-commerce', 'Southeast Asia', 'Acquisition'); | What is the total funding amount for startups founded by individuals from Southeast Asia who have successfully exited via an acquisition in the e-commerce sector? | SELECT SUM(investment_rounds.funding_amount) FROM startup INNER JOIN investment_rounds ON startup.id = investment_rounds.startup_id WHERE startup.industry = 'E-commerce' AND startup.founder_region = 'Southeast Asia' AND startup.exit_strategy = 'Acquisition'; | gretelai_synthetic_text_to_sql |
CREATE TABLE StreamingPlatforms (PlatformID INT, Name VARCHAR(50)); INSERT INTO StreamingPlatforms (PlatformID, Name) VALUES (1, 'Spotify'), (2, 'Apple Music'); CREATE TABLE Streams (StreamID INT, SongID INT, PlatformID INT, StreamCount INT); INSERT INTO Streams (StreamID, SongID, PlatformID, StreamCount) VALUES (1, 3,... | How many times has the song 'Bad Guy' by Billie Eilish been streamed on Spotify? | SELECT SUM(StreamCount) FROM Streams WHERE SongID = 3 AND PlatformID = 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE subscribers (id INT, region VARCHAR(10), monthly_data_usage DECIMAL(5,2), date DATE); INSERT INTO subscribers (id, region, monthly_data_usage, date) VALUES (1, 'urban', 3.5, '2022-01-01'), (2, 'rural', 2.2, '2022-01-05'), (3, 'urban', 4.1, '2022-01-15'), (4, 'rural', 1.9, '2022-01-20'), (5, 'urban', 3.9, '... | What is the monthly data usage distribution for customers in the 'urban' region, grouped by the day of the month? | SELECT EXTRACT(DAY FROM date) AS day_of_month, AVG(monthly_data_usage) FROM subscribers WHERE region = 'urban' GROUP BY day_of_month; | gretelai_synthetic_text_to_sql |
CREATE TABLE excavation_sites (site_id INT, site_name VARCHAR(255)); INSERT INTO excavation_sites (site_id, site_name) VALUES (1, 'Site A'), (2, 'Site B'), (3, 'Site C'); CREATE TABLE artifacts (artifact_id INT, site_id INT, artifact_weight DECIMAL(5,2), artifact_type VARCHAR(255)); INSERT INTO artifacts (artifact_id, ... | What are the maximum and minimum weights of artifacts from each excavation site? | SELECT s.site_name, MAX(a.artifact_weight) AS max_weight, MIN(a.artifact_weight) AS min_weight FROM excavation_sites s JOIN artifacts a ON s.site_id = a.site_id GROUP BY s.site_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE brand_sustainability (id INT, brand_name VARCHAR(255), category VARCHAR(255), sustainability_score INT); INSERT INTO brand_sustainability (id, brand_name, category, sustainability_score) VALUES (1, 'GreenThreads', 'accessories', 80); | Calculate the percentile rank of sustainable fashion brands by sustainability score, for accessories. | SELECT brand_name, category, sustainability_score, PERCENT_RANK() OVER (PARTITION BY category ORDER BY sustainability_score DESC) as percentile FROM brand_sustainability WHERE category = 'accessories'; | gretelai_synthetic_text_to_sql |
CREATE TABLE open_pedagogy_projects (id INT, project_name VARCHAR(50), school_id INT, student_id INT, hours_spent INT); CREATE TABLE students (id INT, name VARCHAR(50), age INT, school_id INT); CREATE TABLE schools (id INT, school_name VARCHAR(50), PRIMARY KEY(id)); | What is the total number of hours spent on open pedagogy projects by students in each school? | SELECT s.school_name, SUM(opp.hours_spent) as total_hours_spent FROM open_pedagogy_projects opp JOIN students st ON opp.student_id = st.id JOIN schools s ON st.school_id = s.id GROUP BY s.school_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE drugs (id INT, name VARCHAR(50), department VARCHAR(50), sales FLOAT); INSERT INTO drugs (id, name, department, sales) VALUES (1, 'DrugA', 'Oncology', 1000000), (2, 'DrugB', 'Oncology', 1500000), (3, 'DrugC', 'Cardiology', 1800000), (4, 'DrugD', 'Cardiology', 1600000), (5, 'DrugE', 'Cardiology', 1400000); | List the top 3 drugs by sales in the cardiology department. | SELECT name, sales FROM drugs WHERE department = 'Cardiology' GROUP BY name, sales ORDER BY sales DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE government_expenditures (id INT PRIMARY KEY AUTO_INCREMENT, category VARCHAR(255), amount DECIMAL(10,2), date DATE); | Insert new records of government expenditures | INSERT INTO government_expenditures (category, amount, date) VALUES ('Education', 12000.50, '2021-12-01'); INSERT INTO government_expenditures (category, amount, date) VALUES ('Healthcare', 35000.00, '2021-11-15'); INSERT INTO government_expenditures (category, amount, date) VALUES ('Transportation', 22000.00, '2021-1... | gretelai_synthetic_text_to_sql |
CREATE TABLE production (id INT, region VARCHAR(255), year INT, oil_production INT, gas_production INT); INSERT INTO production (id, region, year, oil_production, gas_production) VALUES (1, 'Caspian Sea', 2016, 120000, 230000); INSERT INTO production (id, region, year, oil_production, gas_production) VALUES (2, 'Caspia... | Display total production of oil and gas in the Caspian Sea for the last 5 years | SELECT region, SUM(oil_production) + SUM(gas_production) as total_production FROM production WHERE region = 'Caspian Sea' AND year BETWEEN (YEAR(CURDATE()) - 5) AND YEAR(CURDATE()) GROUP BY region; | gretelai_synthetic_text_to_sql |
CREATE TABLE athlete_wellbeing (athlete_id INT, wellbeing_score INT); INSERT INTO athlete_wellbeing (athlete_id, wellbeing_score) VALUES (1, 75), (2, 60), (3, 45), (4, 80); | Update 'athlete_wellbeing' table to set 'wellbeing_score' to 60 where 'athlete_id' is 2 | UPDATE athlete_wellbeing SET wellbeing_score = 60 WHERE athlete_id = 2; | gretelai_synthetic_text_to_sql |
CREATE TABLE Digital_Events (id INT, location VARCHAR(20), attendees INT); INSERT INTO Digital_Events (id, location, attendees) VALUES (1, 'Mumbai', 25), (2, 'Delhi', 30); | How many visitors attended digital events in Mumbai? | SELECT SUM(attendees) FROM Digital_Events WHERE location = 'Mumbai' | gretelai_synthetic_text_to_sql |
CREATE TABLE Employees (EmployeeID INT, FirstName VARCHAR(50), LastName VARCHAR(50), Department VARCHAR(50), Salary DECIMAL(10,2), LeftCompany BOOLEAN); | Display the average salary of employees by department | SELECT Department, AVG(Salary) FROM Employees WHERE LeftCompany = FALSE GROUP BY Department; | gretelai_synthetic_text_to_sql |
CREATE TABLE budget (budget_id INT, sector VARCHAR(255), amount FLOAT); INSERT INTO budget (budget_id, sector, amount) VALUES (1, 'education', 50000.00), (2, 'healthcare', 75000.00), (3, 'education', 25000.00), (4, 'infrastructure', 100000.00); | What is the total budget allocated for programs in the education sector? | SELECT SUM(amount) FROM budget WHERE sector = 'education'; | gretelai_synthetic_text_to_sql |
CREATE TABLE projects_company_location (project_id INT, completion_year INT, company_location VARCHAR(50)); INSERT INTO projects_company_location (project_id, completion_year, company_location) VALUES (1, 2019, 'US'), (2, 2018, 'Canada'), (3, 2019, 'Mexico'), (4, 2017, 'US'), (5, 2019, 'US'), (6, 2016, 'Germany'); | What percentage of renewable energy projects in 2019 were completed by companies based in the US? | SELECT (COUNT(*) FILTER (WHERE company_location = 'US' AND completion_year = 2019)) * 100.0 / COUNT(*) FROM projects_company_location; | gretelai_synthetic_text_to_sql |
CREATE TABLE peacekeeping_ops (operation_id INT, num_personnel INT); | What is the minimum number of peacekeeping personnel in a single operation? | SELECT MIN(num_personnel) FROM peacekeeping_ops; | gretelai_synthetic_text_to_sql |
CREATE TABLE Community_Investment (investment_id INT, project_name TEXT, investment_year INT, investment_amount INT); INSERT INTO Community_Investment (investment_id, project_name, investment_year, investment_amount) VALUES (1, 'Youth Education Program', 2022, 100000), (2, 'Senior Health Care', 2023, 120000), (3, 'Wome... | What was the total investment in community development projects in 2022? | SELECT SUM(investment_amount) FROM Community_Investment WHERE investment_year = 2022; | gretelai_synthetic_text_to_sql |
CREATE TABLE categories (category_id INT, category_name VARCHAR(255)); CREATE TABLE dishes (dish_id INT, dish_name VARCHAR(255), category_id INT, rating DECIMAL(2,1), review_count INT); INSERT INTO categories VALUES (1, 'Pasta'); INSERT INTO dishes VALUES (1, 'Spaghetti Bolognese', 1, 4.2, 15); INSERT INTO dishes VALUE... | What is the average rating and total number of reviews for dishes in each category, excluding categories with fewer than 3 dishes? | SELECT c.category_name, AVG(rating) as avg_rating, SUM(review_count) as total_reviews FROM categories c JOIN dishes d ON c.category_id = d.category_id GROUP BY category_id HAVING COUNT(dish_id) >= 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE protected_areas (area_id INT, area_name VARCHAR(100), country_id INT, year INT); INSERT INTO protected_areas (area_id, area_name, country_id, year) VALUES (1, 'Banff National Park', 1, 2000), (2, 'Jasper National Park', 1, 2000), (3, 'Yosemite National Park', 2, 2000), (4, 'Yellowstone National Park', 2, 2... | What is the total carbon sequestration potential by protected area and year? | SELECT pa.area_name, pa.year, SUM(cs.sequestration_rate) as total_sequestration_rate FROM carbon_sequestration cs JOIN protected_areas pa ON cs.area_id = pa.area_id GROUP BY pa.area_name, pa.year; | gretelai_synthetic_text_to_sql |
CREATE TABLE productivity (date DATE, location VARCHAR(50), material VARCHAR(50), productivity FLOAT); INSERT INTO productivity (date, location, material, productivity) VALUES ('2021-01-01', 'Peru', 'Copper', 1.2), ('2021-02-01', 'Peru', 'Copper', 1.3), ('2021-03-01', 'Peru', 'Copper', 1.4), ('2021-04-01', 'Peru', 'Cop... | What are the monthly labor productivity averages for copper extraction in Peru? | SELECT EXTRACT(MONTH FROM date) as month, AVG(productivity) as avg_monthly_productivity FROM productivity WHERE location = 'Peru' AND material = 'Copper' GROUP BY month; | gretelai_synthetic_text_to_sql |
CREATE TABLE sales (drug VARCHAR(50), quarter VARCHAR(5), year INT, revenue INT); INSERT INTO sales (drug, quarter, year, revenue) VALUES ('DrugX', 'Q1', 2019, 50000), ('DrugY', 'Q1', 2019, 60000), ('DrugZ', 'Q1', 2019, 40000); | What is the combined sales revenue for the drugs 'DrugX' and 'DrugY' in Q1 2019? | SELECT SUM(revenue) FROM sales WHERE drug IN ('DrugX', 'DrugY') AND quarter = 'Q1' AND year = 2019; | gretelai_synthetic_text_to_sql |
CREATE TABLE eco_hotels (hotel_id INT, name TEXT, country TEXT, revenue FLOAT); INSERT INTO eco_hotels VALUES (1, 'Green Hotel', 'Germany', 250000), (2, 'Eco Lodge', 'Italy', 300000), (3, 'Sustainable Resort', 'Germany', 400000); | Identify the total revenue generated by eco-friendly hotels in Germany and Italy. | SELECT country, SUM(revenue) FROM eco_hotels WHERE country IN ('Germany', 'Italy') GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE incidents (id INT, date DATE, type TEXT); | How many AI safety incidents were reported per month in the last year? | SELECT EXTRACT(MONTH FROM date) as month, COUNT(*) as num_incidents FROM incidents WHERE date >= (CURRENT_DATE - INTERVAL '1 year') GROUP BY month ORDER BY month; | gretelai_synthetic_text_to_sql |
CREATE TABLE Sales (sale_id INT, garment_id INT, location_id INT, sale_date DATE);CREATE TABLE Garments (garment_id INT, trend_id INT, fabric_source_id INT, size VARCHAR(50), style VARCHAR(255));CREATE TABLE FabricSources (source_id INT, fabric_type VARCHAR(255), country_of_origin VARCHAR(255), ethical_rating DECIMAL(3... | What is the total sales volume for Cultural Print garments in Mumbai during 2020 from ethical sources with a rating above 8? | SELECT SUM(sales_volume) FROM MumbaiEthicalCulturalPrints WHERE sale_date BETWEEN '2020-01-01' AND '2020-12-31'; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA if not exists genetics; CREATE TABLE if not exists genetics.projects (id INT, name VARCHAR(100), start_date DATE, end_date DATE); INSERT INTO genetics.projects (id, name, start_date, end_date) VALUES (1, 'ProjectX', '2020-01-01', '2021-01-01'), (2, 'ProjectY', '2019-01-01', '2020-01-01'), (3, 'ProjectZ', ... | List the names of genetic research projects and their respective end dates, if available, for projects that started after 2020. | SELECT name, end_date FROM genetics.projects WHERE start_date > '2020-01-01'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Employees (EmployeeID INT, EmployeeName VARCHAR(50), Department VARCHAR(50), Salary DECIMAL(10,2)); INSERT INTO Employees (EmployeeID, EmployeeName, Department, Salary) VALUES (1, 'John Doe', 'IT', 70000), (2, 'Jane Smith', 'IT', 85000), (3, 'Mike Johnson', 'HR', 60000), (4, 'Sara Brown', 'HR', 65000); | Identify the top 3 employees with the highest salaries in each department. | SELECT Department, EmployeeName, Salary, RANK() OVER (PARTITION BY Department ORDER BY Salary DESC) AS EmployeeRank FROM Employees; | gretelai_synthetic_text_to_sql |
CREATE TABLE Company (id INT, name VARCHAR(50), HQ VARCHAR(50), diversity_score FLOAT); INSERT INTO Company (id, name, HQ, diversity_score) VALUES (3, 'Gamma Ltd', 'UK', 85.6); | What is the average diversity score for companies with HQ in the UK? | SELECT HQ, AVG(diversity_score) as avg_diversity FROM Company WHERE HQ = 'UK' GROUP BY HQ; | gretelai_synthetic_text_to_sql |
CREATE TABLE Infrastructure_All (Type VARCHAR(50), Country VARCHAR(50), Cost FLOAT); INSERT INTO Infrastructure_All (Type, Country, Cost) VALUES ('Road', 'Canada', 5000000), ('Bridge', 'Canada', 10000000), ('Highway', 'Canada', 8000000), ('Road', 'USA', 6000000), ('Bridge', 'USA', 12000000), ('Highway', 'USA', 9000000)... | What is the total cost of infrastructure projects for each country, ranked from highest to lowest? | SELECT Country, SUM(Cost) as Total_Cost, ROW_NUMBER() OVER (ORDER BY SUM(Cost) DESC) as Rank FROM Infrastructure_All GROUP BY Country; | gretelai_synthetic_text_to_sql |
CREATE TABLE Models (ModelId INT, Name TEXT, ExplainabilityScore FLOAT, Year INT, Country TEXT); INSERT INTO Models (ModelId, Name, ExplainabilityScore, Year, Country) VALUES (1, 'ModelX', 0.8, 2018, 'Australia'), (2, 'ModelY', 0.9, 2020, 'New Zealand'), (3, 'ModelZ', 0.7, 2021, 'Fiji'); | What is the minimum explainability score of all models created in Oceania after 2019? | SELECT MIN(ExplainabilityScore) FROM Models WHERE Country = 'Oceania' AND Year > 2019; | gretelai_synthetic_text_to_sql |
CREATE TABLE broadband_subscribers (subscriber_id INT, name VARCHAR(50), plan VARCHAR(50), speed FLOAT, data_limit FLOAT, data_usage FLOAT, region VARCHAR(50)); INSERT INTO broadband_subscribers (subscriber_id, name, plan, speed, data_limit, data_usage, region) VALUES (1, 'Samantha Armytage', '250 Mbps', 300.0, 500.0, ... | List all broadband subscribers in the Sydney region who have speeds greater than 200 Mbps and have used more than 75% of their data limit. | SELECT subscriber_id, name, plan, speed FROM broadband_subscribers WHERE region = 'Sydney' AND speed > 200 AND data_usage > (data_limit * 0.75); | gretelai_synthetic_text_to_sql |
CREATE TABLE products (product_id INT, product_name VARCHAR(255), category_id INT, price DECIMAL(5,2)); | Update the 'price' column for all records in the 'products' table with a 'category_id' of 3 to 50% off the original price | UPDATE products SET price = price * 0.5 WHERE category_id = 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE well_production_figures (well_id INT, production_date DATE, gas_production FLOAT); | List the top 5 wells with the highest gas production in 2019 | SELECT well_id, gas_production FROM (SELECT well_id, gas_production, ROW_NUMBER() OVER (ORDER BY gas_production DESC) as ranking FROM well_production_figures WHERE production_date BETWEEN '2019-01-01' AND '2019-12-31') subquery WHERE ranking <= 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE Airports (id INT, name VARCHAR(100), location VARCHAR(100), annual_passengers INT, state VARCHAR(50)); INSERT INTO Airports (id, name, location, annual_passengers, state) VALUES (1, 'Dallas/Fort Worth International Airport', 'DFW', 69000000, 'Texas'); | What is the name and location of all airports in the state of Texas with more than 100,000 annual passengers? | SELECT name, location FROM Airports WHERE state = 'Texas' AND annual_passengers > 100000; | gretelai_synthetic_text_to_sql |
CREATE TABLE aircraft_production (id INT, manufacturer VARCHAR(255), production_rate INT); | What is the distribution of aircraft production rates by manufacturer? | SELECT manufacturer, AVG(production_rate) as avg_production_rate, STDDEV(production_rate) as stddev_production_rate FROM aircraft_production GROUP BY manufacturer; | gretelai_synthetic_text_to_sql |
CREATE TABLE Climate (id INT PRIMARY KEY, year INT, location VARCHAR(255), temperature FLOAT); INSERT INTO Climate (id, year, location, temperature) VALUES (1, 2000, 'Arctic Ocean', -1.5); INSERT INTO Climate (id, year, location, temperature) VALUES (2, 2001, 'Arctic Ocean', -1.8); | Find the average temperature in the Arctic Ocean for each year between 2000 and 2005. | SELECT year, AVG(temperature) as avg_temperature FROM Climate WHERE location = 'Arctic Ocean' AND year BETWEEN 2000 AND 2005 GROUP BY year; | gretelai_synthetic_text_to_sql |
CREATE TABLE autonomous_vehicles (id INT PRIMARY KEY, manufacturer VARCHAR(255), model VARCHAR(255), year INT, type VARCHAR(255)); | Alter the 'autonomous_vehicles' table to add a new column 'price' | ALTER TABLE autonomous_vehicles ADD COLUMN price FLOAT; | gretelai_synthetic_text_to_sql |
CREATE TABLE mining_operations (id INT PRIMARY KEY, mine_name VARCHAR(255), location VARCHAR(255), resource VARCHAR(255), close_date DATE); | Delete the record of the copper mine that was closed in 2018 from the "mining_operations" table | DELETE FROM mining_operations WHERE id = 2 AND close_date = '2018-01-01'; | gretelai_synthetic_text_to_sql |
CREATE TABLE risk_assessments (id INT, region VARCHAR(255), risk_score INT); INSERT INTO risk_assessments (id, region, risk_score) VALUES (1, 'Middle East', 75); INSERT INTO risk_assessments (id, region, risk_score) VALUES (2, 'Asia', 50); INSERT INTO risk_assessments (id, region, risk_score) VALUES (3, 'Asia', 55); | Calculate the average geopolitical risk score for the 'Asia' region in the 'risk_assessments' table | SELECT AVG(risk_score) FROM risk_assessments WHERE region = 'Asia'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Hiring (HireID INT, HireDate DATE, Ethnicity VARCHAR(30)); INSERT INTO Hiring (HireID, HireDate, Ethnicity) VALUES (1, '2021-09-15', 'Latinx'), (2, '2021-10-05', 'African American'); | How many employees were hired in Q3 2021 from underrepresented racial or ethnic groups? | SELECT COUNT(*) FROM Hiring WHERE HireDate BETWEEN '2021-07-01' AND '2021-09-30' AND Ethnicity IN ('Latinx', 'African American', 'Native American', 'Pacific Islander'); | gretelai_synthetic_text_to_sql |
CREATE TABLE railways (railway_id INT, railway_name VARCHAR(50), length DECIMAL(10,2)); | What is the maximum length of a railway in the 'railways' table? | SELECT MAX(length) FROM railways; | gretelai_synthetic_text_to_sql |
CREATE TABLE org_roles (role VARCHAR(10), count INT); INSERT INTO org_roles (role, count) VALUES ('Volunteer', 30), ('Staff', 40); | What is the total number of volunteers and staff in the organization by role? | SELECT role, SUM(count) FROM org_roles GROUP BY role; | gretelai_synthetic_text_to_sql |
CREATE TABLE districts (id INT, name VARCHAR(50), country VARCHAR(50)); INSERT INTO districts (id, name, country) VALUES (1, 'Mukono', 'Uganda'); CREATE TABLE rural_water_supply_systems (id INT, num_beneficiaries INT, district_id INT); INSERT INTO rural_water_supply_systems (id, num_beneficiaries, district_id) VALUES (... | How many rural water supply systems are there in each district of Uganda, and what is the average number of beneficiaries per system? | SELECT d.name, COUNT(r.id) as num_systems, AVG(r.num_beneficiaries) as avg_beneficiaries FROM rural_water_supply_systems r INNER JOIN districts d ON r.district_id = d.id GROUP BY d.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE meals (user_id INT, meal_date DATE); INSERT INTO meals (user_id, meal_date) VALUES (1, '2022-01-01'), (1, '2022-01-02'), (2, '2022-01-01'); CREATE TABLE users (user_id INT, country VARCHAR(255)); INSERT INTO users (user_id, country) VALUES (1, 'Spain'), (2, 'USA'); | Identify users who had meals on more than one day in Spain. | SELECT user_id FROM meals JOIN users ON meals.user_id = users.user_id WHERE users.country = 'Spain' GROUP BY user_id HAVING COUNT(DISTINCT meal_date) > 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE ports (port_id INT, port_country VARCHAR(50), number_of_ports INT); INSERT INTO ports (port_id, port_country, number_of_ports) VALUES (1, 'CountryA', 3), (2, 'CountryB', 4), (3, 'CountryC', 5); | What is the total number of ports in each country? | SELECT port_country, SUM(number_of_ports) FROM ports GROUP BY port_country; | gretelai_synthetic_text_to_sql |
CREATE TABLE humanitarian_assistance (id INT, year INT, quarter INT, amount FLOAT); INSERT INTO humanitarian_assistance (id, year, quarter, amount) VALUES (1, 2018, 1, 125000), (2, 2018, 2, 137500), (3, 2019, 3, 150000), (4, 2019, 4, 162500), (5, 2020, 1, 175000), (6, 2020, 2, 187500); | What was the total amount of humanitarian assistance provided in the first half of 2020 and the second half of 2019? | SELECT SUM(amount) FROM humanitarian_assistance WHERE (quarter <= 2 AND year = 2020) OR (quarter >= 3 AND year = 2019); | gretelai_synthetic_text_to_sql |
CREATE TABLE community_health_workers (region VARCHAR(255), workers INT); INSERT INTO community_health_workers (region, workers) VALUES ('Northeast', 200), ('Southeast', 250), ('Midwest', 180), ('West', 300); | What is the minimum number of community health workers by region? | SELECT region, MIN(workers) FROM community_health_workers GROUP BY region; | gretelai_synthetic_text_to_sql |
CREATE TABLE gyms (gym_id INT, name TEXT, city TEXT); | Insert a new record into the gyms table with gym_id 5, name 'Sydney Sports Club', city 'Sydney' | INSERT INTO gyms (gym_id, name, city) VALUES (5, 'Sydney Sports Club', 'Sydney'); | gretelai_synthetic_text_to_sql |
CREATE TABLE road_projects (id INT, project_name VARCHAR(255), location VARCHAR(255), actual_cost INT, budgeted_cost INT, completion_year INT); INSERT INTO road_projects (id, project_name, location, actual_cost, budgeted_cost, completion_year) VALUES (1, 'Highway Expansion', 'Texas', 12000000, 10000000, 2011), (2, 'Int... | Calculate the percentage of road projects in Texas that had a cost overrun, along with the average cost overrun amount, for projects completed since 2010. | SELECT AVG(CASE WHEN actual_cost > budgeted_cost THEN actual_cost - budgeted_cost END) AS avg_cost_overrun, AVG(CASE WHEN actual_cost > budgeted_cost THEN 100.0 * (actual_cost - budgeted_cost) / budgeted_cost END) AS avg_percentage_overrun FROM road_projects WHERE location = 'Texas' AND completion_year >= 2010; | gretelai_synthetic_text_to_sql |
CREATE TABLE articles (article_id INT, publication_date DATE); INSERT INTO articles (article_id, publication_date) VALUES (1, '2021-01-01'), (2, '2021-02-01'), (3, '2021-03-01'), (4, '2021-04-01'), (5, '2021-05-01'), (6, '2021-06-01'), (7, '2021-07-01'), (8, '2021-08-01'), (9, '2021-09-01'), (10, '2021-10-01'), (11, '2... | How many articles were published per month in the articles table in 2021? | SELECT DATE_FORMAT(publication_date, '%Y-%m') AS month, COUNT(*) AS num_articles FROM articles WHERE YEAR(publication_date) = 2021 GROUP BY month ORDER BY MONTH(publication_date); | gretelai_synthetic_text_to_sql |
CREATE TABLE ResearchGrants ( GrantID INT, GrantName NVARCHAR(50), Amount FLOAT, IssueDate DATETIME); INSERT INTO ResearchGrants (GrantID, GrantName, Amount, IssueDate) VALUES (1, 'Marine Life Conservation', 500000, '2021-01-10 11:00:00'); INSERT INTO ResearchGrants (GrantID, GrantName, Amount, IssueDate) VALUES (2, 'O... | What is the ranking of marine research grants based on their amounts, with quartile distribution? | SELECT GrantID, GrantName, NTILE(4) OVER (ORDER BY Amount DESC) as QuartileRanking FROM ResearchGrants | gretelai_synthetic_text_to_sql |
CREATE TABLE energy_storage (date DATE, region VARCHAR(255), capacity INT, usage INT); INSERT INTO energy_storage (date, region, capacity, usage) VALUES ('2022-01-01', 'West Coast', 1000, 600), ('2022-01-01', 'East Coast', 800, 400); | Calculate the difference between the maximum and minimum energy storage usage in 2022 for each region | SELECT region, MAX(usage) - MIN(usage) FROM energy_storage WHERE EXTRACT(YEAR FROM date) = 2022 GROUP BY region; | gretelai_synthetic_text_to_sql |
CREATE TABLE electronic_waste (country VARCHAR(50), year INT, recycling_rate DECIMAL(5,2)); INSERT INTO electronic_waste (country, year, recycling_rate) VALUES ('China', 2021, 0.50), ('USA', 2021, 0.45); | What is the recycling rate of electronic waste in the top 2 contributing countries in 2021?' | SELECT country, AVG(recycling_rate) as avg_recycling_rate FROM electronic_waste WHERE year = 2021 AND country IN ('China', 'USA') GROUP BY country ORDER BY avg_recycling_rate DESC LIMIT 2; | gretelai_synthetic_text_to_sql |
CREATE TABLE public_schools (school_name VARCHAR(255), spending DECIMAL(10,2), state VARCHAR(255)); INSERT INTO public_schools (school_name, spending, state) VALUES ('School A', 10000, 'California'), ('School B', 12000, 'California'); CREATE TABLE states (state VARCHAR(255), region VARCHAR(255)); INSERT INTO states (st... | What is the total number of public schools and their average spending per student in California? | SELECT AVG(spending), COUNT(*) FROM public_schools WHERE state = 'California'; | gretelai_synthetic_text_to_sql |
CREATE TABLE group_tours (tour_id INT, name VARCHAR(50), historical_site_id INT, group_size INT); CREATE TABLE historical_sites (historical_site_id INT, name VARCHAR(50), city VARCHAR(50)); CREATE TABLE historical_site_visitors (visitor_id INT, historical_site_id INT, visit_count INT); INSERT INTO historical_sites (his... | Delete records of attendees who visited a historical site in Beijing with a group size greater than 10. | DELETE FROM historical_site_visitors WHERE historical_site_id = 1 AND visitor_id IN (SELECT v.visitor_id FROM historical_site_visitors v JOIN group_tours gt ON v.historical_site_id = gt.historical_site_id WHERE gt.group_size > 10); | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_protected_areas (id INTEGER, name TEXT, location TEXT); | How many marine protected areas are there in the 'Caribbean Sea'? | SELECT COUNT(*) FROM marine_protected_areas WHERE location = 'Caribbean Sea'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Artists (ArtistID INT, ArtistName VARCHAR(50), BirthYear INT);CREATE TABLE Paintings (PaintingID INT, PaintingName VARCHAR(50), ArtistID INT, CreationYear INT); INSERT INTO Artists VALUES (1, 'Pablo Picasso', 1881); INSERT INTO Paintings VALUES (1, 'Guernica', 1, 1937); | Find the artist with the greatest difference between the earliest and latest creation years. | SELECT ArtistName, MAX(CreationYear) - MIN(CreationYear) as YearsSpanned FROM Artists a JOIN Paintings p ON a.ArtistID = p.ArtistID GROUP BY ArtistName ORDER BY YearsSpanned DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE sustainable_buildings (project_id INT, project_name TEXT, material_cost FLOAT); | What is the average cost of materials for projects in the 'sustainable_buildings' table? | SELECT AVG(material_cost) FROM sustainable_buildings; | gretelai_synthetic_text_to_sql |
CREATE TABLE workforce (employee_id INT, manufacturer_id INT, role VARCHAR(255), years_of_experience INT); INSERT INTO workforce (employee_id, manufacturer_id, role, years_of_experience) VALUES (1, 1, 'Engineer', 7), (2, 2, 'Manager', 10), (3, 3, 'Technician', 5), (4, 4, 'Designer', 6), (5, 5, 'Assembler', 4); CREATE T... | What is the average years of experience for employees working in manufacturers located in Germany? | SELECT AVG(w.years_of_experience) FROM workforce w INNER JOIN manufacturers m ON w.manufacturer_id = m.manufacturer_id WHERE m.location = 'Germany'; | gretelai_synthetic_text_to_sql |
CREATE TABLE MarineResearchers (ResearcherID INT, Researcher VARCHAR(255), Affiliation VARCHAR(255), Country VARCHAR(255)); | Delete all records from the 'MarineResearchers' table where the 'Researcher' is 'Dr. John Doe' | DELETE FROM MarineResearchers WHERE Researcher = 'Dr. John Doe'; | gretelai_synthetic_text_to_sql |
CREATE TABLE drug_revenues (drug_name VARCHAR(100), revenue FLOAT, quarter INT, year INT); INSERT INTO drug_revenues (drug_name, revenue, quarter, year) VALUES ('DrugA', 1500000, 1, 2022), ('DrugB', 2000000, 1, 2022), ('DrugC', 1200000, 1, 2022), ('DrugD', 2200000, 2, 2022); | Which drug had the highest revenue in Q1 2022? | SELECT drug_name, revenue FROM drug_revenues WHERE year = 2022 AND quarter = 1 AND revenue = (SELECT MAX(revenue) FROM drug_revenues WHERE year = 2022 AND quarter = 1); | gretelai_synthetic_text_to_sql |
CREATE TABLE CulturalCompetency (IssueID INT, Issue VARCHAR(255), ReportedBy VARCHAR(255)); | Find the top 5 most common cultural competency issues reported by community health workers in the 'CulturalCompetency' table. | SELECT Issue, COUNT(*) as CountOfIssues FROM CulturalCompetency WHERE ReportedBy = 'Community Health Worker' GROUP BY Issue ORDER BY CountOfIssues DESC LIMIT 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE employees (id INT PRIMARY KEY, name VARCHAR(50), position VARCHAR(50), department VARCHAR(50), salary DECIMAL(5,2)); CREATE TABLE departments (id INT PRIMARY KEY, name VARCHAR(50), manager_id INT, FOREIGN KEY (manager_id) REFERENCES employees(id)); | What is the average salary of employees in the marketing department? | SELECT AVG(employees.salary) AS avg_salary FROM employees INNER JOIN departments ON employees.department = departments.name WHERE departments.name = 'Marketing'; | gretelai_synthetic_text_to_sql |
CREATE TABLE professors (professor_id INT, name TEXT, research_interest TEXT);CREATE TABLE grants (grant_id INT, professor_id INT, funding_source TEXT, grant_date DATE); INSERT INTO professors (professor_id, name, research_interest) VALUES (1, 'Alice', 'Machine Learning'); INSERT INTO grants (grant_id, professor_id, fu... | What are the names and research interests of professors who have received grants from the 'NSF' in the last 5 years? | SELECT professors.name, professors.research_interest FROM professors INNER JOIN grants ON professors.professor_id = grants.professor_id WHERE grants.funding_source = 'NSF' AND grants.grant_date >= DATEADD(year, -5, CURRENT_DATE); | gretelai_synthetic_text_to_sql |
CREATE TABLE financial_wellbeing_over_time (id INT, date DATE, score FLOAT); INSERT INTO financial_wellbeing_over_time (id, date, score) VALUES (1, '2021-01-01', 7.2), (2, '2021-02-01', 7.5), (3, '2021-03-01', 7.3), (4, '2021-01-01', 7.0), (5, '2021-02-01', 7.4), (6, '2021-03-01', 7.6); | What is the trend of financial wellbeing scores over the last year? | SELECT DATE_FORMAT(date, '%Y-%m') as month, AVG(score) as avg_score FROM financial_wellbeing_over_time GROUP BY month ORDER BY month; | gretelai_synthetic_text_to_sql |
CREATE TABLE basketball_stats (team VARCHAR(50), games_played INT, games_won INT); INSERT INTO basketball_stats (team, games_played, games_won) VALUES ('Golden State Warriors', 82, 54); INSERT INTO basketball_stats (team, games_played, games_won) VALUES ('Brooklyn Nets', 82, 48); | What is the total number of games won by the Warriors in the 'basketball_stats' table? | SELECT SUM(games_won) FROM basketball_stats WHERE team = 'Golden State Warriors'; | gretelai_synthetic_text_to_sql |
CREATE TABLE temperature_data (region VARCHAR(255), temperature INT, date DATE); INSERT INTO temperature_data (region, temperature, date) VALUES ('North', 25, '2022-01-01'), ('South', 10, '2022-01-01'), ('East', 15, '2022-01-01'), ('West', 30, '2022-01-01'); | What is the difference in average temperature between the hottest and coldest regions for each month, in a given year? | SELECT hottest.region, hottest.max_temp - coldest.min_temp as temp_diff FROM (SELECT region, MAX(temperature) as max_temp FROM temperature_data GROUP BY region) hottest INNER JOIN (SELECT region, MIN(temperature) as min_temp FROM temperature_data GROUP BY region) coldest ON hottest.region = coldest.region; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA rural; CREATE TABLE rural.hospitals (id INT, hospital_name TEXT); | Delete all records from the 'hospitals' table where the hospital_name is 'St. Luke's'. | DELETE FROM rural.hospitals WHERE hospital_name = 'St. Luke''s'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Transactions (id INT, customer_id INT, items_sold INT); INSERT INTO Transactions (id, customer_id, items_sold) VALUES (1, 1, 3), (2, 2, 1), (3, 3, 2), (4, 4, 4), (5, 5, 5), (6, 6, 1); | What is the minimum number of sustainable clothing items sold in any transaction? | SELECT MIN(items_sold) FROM Transactions WHERE EXISTS (SELECT 1 FROM Sales WHERE Transactions.customer_id = Sales.id AND material IN ('Organic Cotton', 'Hemp', 'Recycled Polyester', 'Tencel', 'Bamboo')); | gretelai_synthetic_text_to_sql |
CREATE TABLE articles (title text, category text, user_location text); INSERT INTO articles (title, category, user_location) VALUES ('Article 1', 'climate change', 'USA'); INSERT INTO articles (title, category, user_location) VALUES ('Article 2', 'climate change', 'Canada'); | What is the distribution of user locations for articles about climate change? | SELECT user_location, COUNT(*) as count FROM articles WHERE category = 'climate change' GROUP BY user_location; | gretelai_synthetic_text_to_sql |
CREATE TABLE SpaceExploration (mission_id INT, spacecraft VARCHAR(50), flight_duration INT); | What is the maximum flight duration for SpaceX missions? | SELECT MAX(flight_duration) FROM SpaceExploration WHERE spacecraft = 'SpaceX'; | gretelai_synthetic_text_to_sql |
CREATE TABLE funding (company_name VARCHAR(255), funding_round INT); INSERT INTO funding (company_name, funding_round) VALUES ('Acme Inc', 1), ('Beta Corp', 1), ('Charlie LLC', 2), ('Delta Co', 1); | List companies with more than one funding round | SELECT company_name FROM funding WHERE funding_round > (SELECT AVG(funding_round) FROM funding); | gretelai_synthetic_text_to_sql |
CREATE TABLE Policies (PolicyID INT, ZipCode VARCHAR(10)); CREATE TABLE Claims (PolicyID INT, ClaimAmount DECIMAL(10,2)); INSERT INTO Policies (PolicyID, ZipCode) VALUES (1, '90001'), (2, '90001'), (3, '77001'), (4, '77001'), (5, '33101'); INSERT INTO Claims (PolicyID, ClaimAmount) VALUES (1, 500), (2, 1200), (3, 800),... | What is the total claim amount for policies issued in each zip code, in ascending order? | SELECT P.ZipCode, SUM(C.ClaimAmount) AS TotalClaimAmount FROM Policies P INNER JOIN Claims C ON P.PolicyID = C.PolicyID GROUP BY P.ZipCode ORDER BY TotalClaimAmount ASC; | gretelai_synthetic_text_to_sql |
CREATE TABLE healthcare_projects (project VARCHAR(50), budget INT); INSERT INTO healthcare_projects (project, budget) VALUES ('Hospital Building', 4000000); INSERT INTO healthcare_projects (project, budget) VALUES ('Medical Equipment', 1000000); INSERT INTO healthcare_projects (project, budget) VALUES ('Clinic Expansio... | How many healthcare projects in the 'healthcare_projects' table have a budget over 2 million dollars? | SELECT COUNT(*) FROM healthcare_projects WHERE budget > 2000000; | gretelai_synthetic_text_to_sql |
CREATE TABLE ProviderRegions (ProviderID int, RegionID int);CREATE TABLE CulturalCompetency (CCID int, ProviderID int, Score int); | What is the cultural competency score of each healthcare provider in each region? | SELECT ProviderRegions.RegionID, ProviderName, AVG(Score) as AvgScore FROM ProviderRegions JOIN Providers ON ProviderRegions.ProviderID = Providers.ProviderID JOIN CulturalCompetency ON ProviderRegions.ProviderID = CulturalCompetency.ProviderID GROUP BY ProviderRegions.RegionID, ProviderName; | gretelai_synthetic_text_to_sql |
CREATE TABLE security_incidents (id INT, date DATE, department VARCHAR(255)); INSERT INTO security_incidents (id, date, department) VALUES (1, '2022-02-01', 'IT'), (2, '2022-02-05', 'HR'), (3, '2022-01-07', 'IT'); | What is the total number of security incidents reported in the last month? | SELECT COUNT(*) FROM security_incidents WHERE date >= DATEADD(month, -1, GETDATE()); | gretelai_synthetic_text_to_sql |
CREATE TABLE donations (id INT, donation_date DATE, amount DECIMAL(10,2)); | What is the total donation amount per month? | SELECT DATE_FORMAT(donation_date, '%Y-%m') as month, SUM(amount) as total_donation FROM donations GROUP BY month; | gretelai_synthetic_text_to_sql |
CREATE TABLE crop_water_data (state VARCHAR(255), crop_type VARCHAR(255), water_consumption INT, measurement_date DATE); INSERT INTO crop_water_data (state, crop_type, water_consumption, measurement_date) VALUES ('Punjab', 'Rice', 1200, '2022-05-01'), ('Punjab', 'Wheat', 1000, '2022-05-01'), ('Maharashtra', 'Sugarcane'... | Which crop type in each state of India has the highest total water consumption in the past 60 days? | SELECT state, crop_type, water_consumption FROM (SELECT state, crop_type, water_consumption, RANK() OVER (PARTITION BY state ORDER BY water_consumption DESC) as water_rank FROM crop_water_data WHERE measurement_date BETWEEN '2022-04-01' AND '2022-05-01' GROUP BY state, crop_type) subquery WHERE water_rank = 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE CommunityEvents (id INT, city_department VARCHAR(50), event_type VARCHAR(50), budget DECIMAL(10,2)); INSERT INTO CommunityEvents (id, city_department, event_type, budget) VALUES (1, 'Parks and Recreation', 'Festival', 60000), (2, 'Parks and Recreation', 'Concert', 45000), (3, 'Education', 'Science Fair', 7... | What is the average number of community events organized by each city department, with a budget over $50,000? | SELECT city_department, AVG(budget) as avg_budget FROM CommunityEvents WHERE budget > 50000 GROUP BY city_department; | gretelai_synthetic_text_to_sql |
CREATE TABLE accommodations (id INT, student_id INT, accommodation_type VARCHAR(50), cost FLOAT, accommodation_date DATE); INSERT INTO accommodations (id, student_id, accommodation_type, cost, accommodation_date) VALUES (1, 2, 'Sign Language Interpreter', 50.00, '2020-07-01'), (2, 3, 'Assistive Listening Devices', 300.... | Delete records of accommodations provided to student 5 in 2021 | DELETE FROM accommodations WHERE student_id = 5 AND YEAR(accommodation_date) = 2021; | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_protected_areas (name VARCHAR(255), location VARCHAR(255), species_count INT); INSERT INTO marine_protected_areas (name, location, species_count) VALUES ('Great Barrier Reef', 'Australia', 1500); | Update the species count for the 'Great Barrier Reef' marine protected area. | UPDATE marine_protected_areas SET species_count = 1600 WHERE name = 'Great Barrier Reef'; | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_pollution_incidents (id INT, region VARCHAR(50), type VARCHAR(50), date DATE); INSERT INTO marine_pollution_incidents (id, region, type, date) VALUES (1, 'Mediterranean Sea', 'Oil Spill', '2021-05-01'); INSERT INTO marine_pollution_incidents (id, region, type, date) VALUES (2, 'Mediterranean Sea', '... | What are the top 5 most common types of marine pollution incidents in the Mediterranean Sea in the last decade? | SELECT type, COUNT(*) AS total_incidents FROM marine_pollution_incidents WHERE region = 'Mediterranean Sea' AND date >= DATE_SUB(CURRENT_DATE, INTERVAL 10 YEAR) GROUP BY type ORDER BY total_incidents DESC LIMIT 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE MilitarySatellites (Id INT, Country VARCHAR(50), SatelliteName VARCHAR(50), LaunchYear INT, Function VARCHAR(50));INSERT INTO MilitarySatellites (Id, Country, SatelliteName, LaunchYear, Function) VALUES (1, 'France', 'CERES', 2015, 'Earth Observation'), (2, 'Germany', 'SARah-1', 2020, 'Communication'); | What is the latest launch year for military satellites in the European region? | SELECT MAX(LaunchYear) AS LatestLaunchYear FROM MilitarySatellites WHERE Country IN ('France', 'Germany'); | gretelai_synthetic_text_to_sql |
CREATE TABLE cargo (cargo_id INT, cargo_type VARCHAR(50)); INSERT INTO cargo (cargo_id, cargo_type) VALUES (1, 'Electronics'), (2, 'Clothing'); CREATE TABLE port (port_id INT, port_name VARCHAR(50)); INSERT INTO port (port_id, port_name) VALUES (1, 'Port of Rotterdam'); CREATE TABLE transport (transport_id INT, cargo_i... | List all vessels that have transported 'Electronics' but not 'Clothing' to the Port of Rotterdam. | SELECT DISTINCT vessel_id FROM transport WHERE cargo_id = (SELECT cargo_id FROM cargo WHERE cargo_type = 'Electronics') AND port_id = 1 AND vessel_id NOT IN (SELECT vessel_id FROM transport WHERE cargo_id = (SELECT cargo_id FROM cargo WHERE cargo_type = 'Clothing') AND port_id = 1); | gretelai_synthetic_text_to_sql |
CREATE TABLE Warehouses (WarehouseID int, WarehouseName varchar(255), Region varchar(255));CREATE TABLE Shipments (ShipmentID int, WarehouseID int, Pallets int, ShippedDate datetime); INSERT INTO Warehouses (WarehouseID, WarehouseName, Region) VALUES (1, 'W1', 'Europe'); INSERT INTO Shipments (ShipmentID, WarehouseID, ... | How many pallets have been shipped to each warehouse in the Europe region in the past month? | SELECT w.WarehouseName, SUM(s.Pallets) as TotalPallets FROM Warehouses w INNER JOIN Shipments s ON w.WarehouseID = s.WarehouseID WHERE w.Region = 'Europe' AND s.ShippedDate >= DATEADD(month, -1, GETDATE()) GROUP BY w.WarehouseName; | gretelai_synthetic_text_to_sql |
CREATE TABLE EquipmentSalesByCountry (equipmentName VARCHAR(255), country VARCHAR(255)); INSERT INTO EquipmentSalesByCountry (equipmentName, country) VALUES ('M1 Abrams Tank', 'United States'); INSERT INTO EquipmentSalesByCountry (equipmentName, country) VALUES ('M1 Abrams Tank', 'Iraq'); | Which military equipment has been sold to the most countries? | SELECT equipmentName, COUNT(DISTINCT country) AS country_count FROM EquipmentSalesByCountry GROUP BY equipmentName ORDER BY country_count DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE fan_purchases (purchase_id INT, fan_id INT, team VARCHAR(50), event_date DATE, amount DECIMAL(5, 2)); INSERT INTO fan_purchases (purchase_id, fan_id, team, event_date, amount) VALUES (1, 1, 'Basketball', '2022-03-01', 100.00), (2, 2, 'Basketball', '2022-03-15', 150.00); | Delete all records of purchases made by fans at a specific event | DELETE FROM fan_purchases WHERE event_date = '2022-03-01'; | gretelai_synthetic_text_to_sql |
CREATE TABLE DepartmentTrainings(Department VARCHAR(255), TrainingProgram VARCHAR(255), EmployeeCount INT); | What is the total number of employees who have completed a training program in each department? | SELECT Department, SUM(EmployeeCount) FROM DepartmentTrainings GROUP BY Department; | gretelai_synthetic_text_to_sql |
CREATE TABLE oceans (ocean_id INT, name VARCHAR(50)); INSERT INTO oceans VALUES (1, 'Arctic'), (2, 'Indian'); CREATE TABLE countries (country_id INT, name VARCHAR(50), ocean_id INT); INSERT INTO countries VALUES (1, 'Canada', 1), (2, 'Norway', 1), (3, 'India', 2), (4, 'Australia', 2); CREATE TABLE conservation_efforts ... | List all countries involved in marine conservation efforts in the Arctic and Indian oceans. | SELECT DISTINCT c.name FROM countries c JOIN conservation_efforts ce ON c.country_id = ce.country_id WHERE c.ocean_id IN (SELECT ocean_id FROM oceans WHERE name IN ('Arctic', 'Indian')); | 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.