context stringlengths 11 9.12k | question stringlengths 0 1.06k | SQL stringlengths 2 4.44k | source stringclasses 28 values |
|---|---|---|---|
CREATE TABLE tech4good (id INT, volunteer_id INT, tech_for_social_good_date DATE, tech_for_social_good_hours INT); INSERT INTO tech4good (id, volunteer_id, tech_for_social_good_date, tech_for_social_good_hours) VALUES (1, 1001, '2022-01-01', 6); INSERT INTO tech4good (id, volunteer_id, tech_for_social_good_date, tech_for_social_good_hours) VALUES (2, 1001, '2022-01-03', 9); INSERT INTO tech4good (id, volunteer_id, tech_for_social_good_date, tech_for_social_good_hours) VALUES (3, 1002, '2022-01-02', 4); | What is the running total of 'tech_for_social_good_hours' for each volunteer, for the 'tech4good' database, ordered by volunteer_id and date? | SELECT volunteer_id, tech_for_social_good_date, tech_for_social_good_hours, SUM(tech_for_social_good_hours) OVER (PARTITION BY volunteer_id ORDER BY tech_for_social_good_date) as running_total FROM tech4good; | gretelai_synthetic_text_to_sql |
CREATE TABLE astronauts (badge_id INT, first_name VARCHAR(50), last_name VARCHAR(50), dob DATE, gender VARCHAR(10), missions INT); CREATE TABLE space_missions (mission_id INT, mission_name VARCHAR(50), launch_date DATE, return_date DATE, astronaut_badge_id INT); | How many astronauts have flown more than three missions? | SELECT COUNT(*) FROM astronauts WHERE missions > 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE excavation_sites (id INT, site_name VARCHAR(50), location VARCHAR(50), num_artifacts INT, total_funding DECIMAL(10,2)); | What was the total weight of artifacts made of bone, per country? | SELECT country, SUM(CASE WHEN artifact_type = 'bone' THEN weight ELSE 0 END) as total_weight FROM excavation_sites GROUP BY country | gretelai_synthetic_text_to_sql |
CREATE TABLE sales_data_4 (sale_id INT, product_id INT, sale_date DATE, price DECIMAL(5,2), quantity INT); INSERT INTO sales_data_4 (sale_id, product_id, sale_date, price, quantity) VALUES (16, 1, '2022-01-01', 12.50, 10), (17, 2, '2022-02-02', 13.00, 15), (18, 3, '2022-03-03', 12.75, 12), (19, 4, '2022-04-04', 45.00, 5), (20, 5, '2022-05-05', 35.00, 3); | Calculate the total sales revenue and quantity sold for each product category in a specific year | SELECT category, YEAR(sale_date) AS year, SUM(price * quantity) AS total_sales_revenue, SUM(quantity) AS total_quantity_sold FROM sales_data_4 JOIN products ON sales_data_4.product_id = products.product_id GROUP BY category, year; | gretelai_synthetic_text_to_sql |
CREATE TABLE AttorneyIdentity (AttorneyID INT, Identity VARCHAR(20)); INSERT INTO AttorneyIdentity (AttorneyID, Identity) VALUES (1, 'Straight'), (2, 'LGBTQ+'), (3, 'Straight'); | What is the maximum billing amount for cases handled by attorneys who identify as LGBTQ+? | SELECT MAX(BillingAmount) FROM AttorneyBilling JOIN AttorneyIdentity ON AttorneyBilling.AttorneyID = AttorneyIdentity.AttorneyID WHERE Identity = 'LGBTQ+'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Yield (Year int, CropName varchar(50), Yield int); INSERT INTO Yield (Year, CropName, Yield) VALUES (2020, 'Corn', 180), (2021, 'Corn', 200), (2022, 'Corn', 220), (2020, 'Soybeans', 160), (2021, 'Soybeans', 180), (2022, 'Soybeans', 200), (2020, 'Wheat', 140), (2021, 'Wheat', 150), (2022, 'Wheat', 160); | Calculate the moving average of crop yield for each crop over the last 3 years. | SELECT Year, CropName, AVG(Yield) OVER (PARTITION BY CropName ORDER BY Year ROWS BETWEEN 2 PRECEDING AND CURRENT ROW) as MovingAvg FROM Yield; | gretelai_synthetic_text_to_sql |
CREATE TABLE arts (id INT, name VARCHAR); INSERT INTO arts (id, name) VALUES (1, 'Art A'), (2, 'Art B'); CREATE TABLE art_practitioners (id INT, site_id INT, art_id INT); INSERT INTO art_practitioners (id, site_id, art_id) VALUES (1, 1, 1), (2, 2, 2); | How many traditional arts are practiced in each heritage site? | SELECT heritage_sites.name, COUNT(DISTINCT arts.id) AS total_arts FROM heritage_sites INNER JOIN art_practitioners ON heritage_sites.id = art_practitioners.site_id INNER JOIN arts ON art_practitioners.art_id = arts.id GROUP BY heritage_sites.id; | gretelai_synthetic_text_to_sql |
CREATE TABLE Employee (EmployeeID INT PRIMARY KEY, FirstName VARCHAR(50), LastName VARCHAR(50), Position VARCHAR(50), Department VARCHAR(50), Salary DECIMAL(10, 2)); | Add a new employee to the 'Engineering' department | INSERT INTO Employee (EmployeeID, FirstName, LastName, Position, Department, Salary) VALUES (3, 'Mike', 'Smith', 'Mechanical Engineer', 'Engineering', 60000.00); | gretelai_synthetic_text_to_sql |
CREATE TABLE AutoShows (Show VARCHAR(255), EVModel VARCHAR(255)); INSERT INTO AutoShows (Show, EVModel) VALUES ('LA Auto Show', 'Model S'), ('LA Auto Show', 'Model 3'), ('LA Auto Show', 'Prius'), ('Detroit Auto Show', 'Model S'), ('Detroit Auto Show', 'Model X'), ('Tokyo Auto Show', 'Leaf'), ('Tokyo Auto Show', 'Model 3'), ('Tokyo Auto Show', 'Prius'); | Which auto show had the most number of electric vehicle models displayed? | SELECT Show, COUNT(*) FROM AutoShows GROUP BY Show ORDER BY COUNT(*) DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE Policyholders (PolicyNumber VARCHAR(20), PolicyholderName VARCHAR(50), Community VARCHAR(50)); | Insert a new policyholder record for 'Maria Garcia' with policy number 'P003' and community 'Hispanic'. | INSERT INTO Policyholders (PolicyNumber, PolicyholderName, Community) VALUES ('P003', 'Maria Garcia', 'Hispanic'); | gretelai_synthetic_text_to_sql |
CREATE TABLE farms (farm_id INT, name VARCHAR(50), location VARCHAR(50)); | Insert a new farm with the ID 501 | INSERT INTO farms (farm_id, name, location) VALUES (501, 'Maplewood Farm', 'California'); | gretelai_synthetic_text_to_sql |
CREATE TABLE rural_infrastructure (project_id INT, project_name VARCHAR(255), budget INT, implementation_date DATE); | List all rural infrastructure projects that were implemented in a specific year (e.g. 2019). | select project_name, budget from rural_infrastructure where extract(year from implementation_date) = 2019; | gretelai_synthetic_text_to_sql |
CREATE TABLE unions (id INT, name TEXT, industry TEXT, members INT); INSERT INTO unions (id, name, industry, members) VALUES (1, 'SEIU', 'Public Service', 2000000), (2, 'AFSCME', 'Public Service', 1500000), (3, 'United Auto Workers', 'Manufacturing', 400000); | What is the union with the most members in the public service sector? | SELECT name FROM unions WHERE industry = 'Public Service' ORDER BY members DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE hotels (id INT PRIMARY KEY, name VARCHAR(255), address VARCHAR(255), city VARCHAR(255), country VARCHAR(255), stars DECIMAL(2,1)); | Insert new records into the hotels table for a hotel in Tokyo, Japan | INSERT INTO hotels (name, address, city, country, stars) VALUES ('Hotel Granvia Tokyo', '2 Chome-7-1 Narita, Tokyo', 'Tokyo', 'Japan', 4.5); | gretelai_synthetic_text_to_sql |
CREATE TABLE temp_data (id INT, field_id VARCHAR(10), temperature FLOAT, timestamp TIMESTAMP); INSERT INTO temp_data (id, field_id, temperature, timestamp) VALUES (1, 'Field006', 10.2, '2022-02-01 10:00:00'), (2, 'Field006', 8.0, '2022-02-03 10:00:00'); | What is the minimum temperature recorded in 'Field006' in the past week? | SELECT MIN(temperature) FROM temp_data WHERE field_id = 'Field006' AND timestamp BETWEEN DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 7 DAY) AND CURRENT_TIMESTAMP; | gretelai_synthetic_text_to_sql |
CREATE TABLE hotels (id INT, name TEXT, country TEXT, rating FLOAT, reviews INT); | What is the minimum rating of hotels in the UK that have more than 50 reviews? | SELECT MIN(rating) FROM hotels WHERE country = 'United Kingdom' AND reviews > 50; | gretelai_synthetic_text_to_sql |
CREATE TABLE community_health_workers (worker_id INT, age INT, state VARCHAR(20)); INSERT INTO community_health_workers (worker_id, age, state) VALUES (1, 45, 'California'), (2, 35, 'Texas'), (3, 50, 'California'), (4, 40, 'Texas'); | What is the total number of community health workers in all states? | SELECT COUNT(*) FROM community_health_workers | gretelai_synthetic_text_to_sql |
CREATE TABLE smart_contracts (id INT, gas_price DECIMAL(10, 2), country VARCHAR(255)); INSERT INTO smart_contracts (id, gas_price, country) VALUES (1, 20.5, 'USA'), (2, 25.0, 'Canada'), (3, 18.7, 'USA'), (4, 30.2, 'Mexico'), (5, 22.9, 'USA'); | What's the average gas price for smart contracts in the US? | SELECT AVG(gas_price) FROM smart_contracts WHERE country = 'USA'; | gretelai_synthetic_text_to_sql |
CREATE TABLE initiatives_2 (id INT, name TEXT, location TEXT); INSERT INTO initiatives_2 (id, name, location) VALUES (6, 'Neighborhood Watch', 'Queens'); | Insert a new community policing initiative 'Neighborhood Watch' in 'Queens'. | INSERT INTO initiatives (name, location) VALUES ('Neighborhood Watch', 'Queens'); | gretelai_synthetic_text_to_sql |
CREATE TABLE CarbonOffset (id INT, project_name VARCHAR(20), project_type VARCHAR(20), amount INT); INSERT INTO CarbonOffset (id, project_name, project_type, amount) VALUES (1, 'ForestryProject1', 'forestry', 5000), (2, 'RenewableEnergyProject1', 'renewable', 6000), (3, 'EnergyEfficiencyProject1', 'energy_efficiency', 4000); | Update the "amount" of the "ForestryProject1" in the "CarbonOffset" table to 6000 | UPDATE CarbonOffset SET amount = 6000 WHERE project_name = 'ForestryProject1'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Countries (id INT, name VARCHAR(255)); INSERT INTO Countries (id, name) VALUES (1, 'USA'), (2, 'Canada'), (3, 'Mexico'), (4, 'Brazil'); CREATE TABLE CountryHarvest (country_id INT, volume INT); INSERT INTO CountryHarvest (country_id, volume) VALUES (1, 5000), (2, 7000), (3, 3000), (1, 4500), (4, 8000), (2, 6000); | What is the total volume of timber harvested in each country? | SELECT Ch.country_id, SUM(Ch.volume) as total_volume FROM CountryHarvest Ch GROUP BY Ch.country_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE carbon_offset_programs (id INT, name VARCHAR(255), location VARCHAR(255), start_date DATE); | How many carbon offset programs were initiated in Africa in the last 5 years? | SELECT COUNT(*) FROM carbon_offset_programs WHERE location LIKE '%Africa%' AND start_date >= DATE_SUB(CURDATE(), INTERVAL 5 YEAR); | gretelai_synthetic_text_to_sql |
CREATE TABLE facilities (facility_id INT, facility_name TEXT, num_beds INT, location TEXT); INSERT INTO facilities (facility_id, facility_name, num_beds, location) VALUES (1, 'Alabama Rural Hospital', 15, 'Alabama'); | List the healthcare facilities in rural Alabama that have less than 20 beds. | SELECT facility_name FROM facilities WHERE location = 'Alabama' AND num_beds < 20; | gretelai_synthetic_text_to_sql |
CREATE TABLE health_interventions (region VARCHAR(255), agency VARCHAR(255), num_interventions INT, year INT); | List the top 3 regions with the highest number of health interventions by Save the Children in 2018. | SELECT region, SUM(num_interventions) as total_interventions FROM health_interventions WHERE agency = 'Save the Children' GROUP BY region ORDER BY total_interventions DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA clinical;CREATE TABLE clinical.trials (id INT, drug_id INT, disease_id INT, start_year INT, end_year INT);CREATE TABLE clinical.drugs (id INT, name VARCHAR(50));CREATE TABLE clinical.diseases (id INT, name VARCHAR(50)); INSERT INTO clinical.drugs (id, name) VALUES (1, 'DrugA'), (2, 'DrugB'); INSERT INTO clinical.diseases (id, name) VALUES (1, 'Cancer'), (2, 'Heart Disease'); INSERT INTO clinical.trials (id, drug_id, disease_id, start_year, end_year) VALUES (1, 1, 1, 2015, 2017), (2, 1, 2, 2018, 2020), (3, 2, 1, 2016, 2018), (4, 2, 2, 2019, 2021); | How many clinical trials were conducted between 2015 and 2019 for drugs targeting cancer? | SELECT COUNT(*) FROM clinical.trials t JOIN clinical.drugs d ON t.drug_id = d.id JOIN clinical.diseases ds ON t.disease_id = ds.id WHERE ds.name = 'Cancer' AND t.start_year BETWEEN 2015 AND 2019; | gretelai_synthetic_text_to_sql |
CREATE TABLE satellites (id INT, name VARCHAR(50), launch_date DATE, orbit_type VARCHAR(50), company VARCHAR(50)); | What are the names and types of all satellites launched by SpaceX? | SELECT name, orbit_type FROM satellites WHERE company = 'SpaceX'; | gretelai_synthetic_text_to_sql |
CREATE TABLE hotel_ai (hotel_id INT, ai_type VARCHAR(20), adoption_date DATE); | Create a table named 'hotel_ai' to store data about AI adoption in hotels | CREATE TABLE hotel_ai (hotel_id INT, ai_type VARCHAR(20), adoption_date DATE); | gretelai_synthetic_text_to_sql |
CREATE TABLE hospitals (id INT, country VARCHAR(255), name VARCHAR(255)); INSERT INTO hospitals (id, country, name) VALUES (1, 'USA', 'Hospital A'), (2, 'Canada', 'Hospital B'), (3, 'Mexico', 'Hospital C'); | What is the number of hospitals in each country, ordered by the number of hospitals? | SELECT country, COUNT(*) as hospital_count FROM hospitals GROUP BY country ORDER BY hospital_count DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE states (state_id INT, state_name VARCHAR(50));CREATE TABLE ev_sales (sale_id INT, ev_type VARCHAR(50), sale_state INT);INSERT INTO states (state_id, state_name) VALUES (1, 'California'), (2, 'Texas'), (3, 'Florida');INSERT INTO ev_sales (sale_id, ev_type, sale_state) VALUES (1, 'Tesla Car', 1), (2, 'Nissan Leaf', 2), (3, 'Chevy Bolt', 3); | Count the number of electric cars in each state in the USA | SELECT s.state_name, COUNT(es.ev_type) as num_ecars FROM states s JOIN ev_sales es ON s.state_id = es.sale_state WHERE es.ev_type NOT LIKE '%Bus' GROUP BY s.state_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE donors (id INT, name VARCHAR(50), last_donation_year INT); | Delete records of donors who have not donated since 2020 in the "donors" table. | DELETE FROM donors WHERE last_donation_year < 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE student_mental_health_history (student_id INT, mental_health_score INT, pd_date DATE); INSERT INTO student_mental_health_history (student_id, mental_health_score, pd_date) VALUES (1, 80, '2010-01-01'), (1, 85, '2010-02-01'), (2, 90, '2015-01-01'), (2, 95, '2015-02-01'), (3, 70, '2005-01-01'), (3, 75, '2005-02-01'); | What is the change in mental health score for each student over time, with a new row for each month? | SELECT h1.student_id, h1.pd_date, h1.mental_health_score - LAG(h1.mental_health_score) OVER (PARTITION BY h1.student_id ORDER BY h1.pd_date) as change FROM student_mental_health_history h1 ORDER BY h1.student_id, h1.pd_date; | gretelai_synthetic_text_to_sql |
CREATE TABLE landfill_capacity (name VARCHAR(30), state VARCHAR(20), year INT, capacity INT); INSERT INTO landfill_capacity (name, state, year, capacity) VALUES ('Sunshine Landfill', 'California', 2019, 1000000), ('East Bay Landfill', 'California', 2019, 800000), ('Golden Gate Landfill', 'California', 2019, 900000); | What was the capacity of the largest landfill in the state of California in 2019? | SELECT MAX(capacity) AS max_capacity FROM landfill_capacity WHERE state = 'California' AND year = 2019; | gretelai_synthetic_text_to_sql |
CREATE TABLE salaries (id INT, employee_id INT, salary INT); INSERT INTO salaries (id, employee_id, salary) VALUES (1, 1, 50000), (2, 2, 55000), (3, 3, 60000); | What is the average salary of employees in the 'manufacturing' and 'engineering' departments? | SELECT AVG(salary) FROM salaries JOIN employees ON salaries.employee_id = employees.id WHERE employees.department IN ('manufacturing', 'engineering'); | gretelai_synthetic_text_to_sql |
CREATE TABLE Violations (Month INT, City VARCHAR(255), ViolationCount INT); INSERT INTO Violations (Month, City, ViolationCount) VALUES (7, 'Capital', 3000), (8, 'Capital', 3500), (7, 'Suburban', 2000), (8, 'Suburban', 2200); | How many traffic violations were recorded in the suburban areas in the month of August? | SELECT SUM(ViolationCount) FROM Violations WHERE Month = 8 AND City = 'Suburban'; | gretelai_synthetic_text_to_sql |
CREATE TABLE artists (id INT, name VARCHAR(50), country VARCHAR(50)); INSERT INTO artists (id, name, country) VALUES (1, 'John Doe', 'Australia'), (2, 'Jane Smith', 'New Zealand'), (3, 'Alice Johnson', 'Canada'); | How many artists are from Oceania? | SELECT COUNT(*) FROM artists WHERE country IN ('Australia', 'New Zealand'); | gretelai_synthetic_text_to_sql |
CREATE TABLE materials (material varchar(20), quantity int); INSERT INTO materials (material, quantity) VALUES ('organic cotton', 500), ('recycled polyester', 300), ('sustainable silk', 200); | What is the total quantity of sustainable materials used in the production of all products? | SELECT SUM(quantity) FROM materials WHERE material in ('organic cotton', 'recycled polyester', 'sustainable silk'); | gretelai_synthetic_text_to_sql |
CREATE TABLE policy_info (policy_id INT, premium FLOAT, sum_insured INT); INSERT INTO policy_info (policy_id, premium, sum_insured) VALUES (1, 1200.50, 60000), (2, 2500.00, 70000), (3, 1800.00, 90000); | What is the average premium for policies with sum insured greater than 60000? | SELECT AVG(premium) FROM policy_info WHERE sum_insured > 60000; | gretelai_synthetic_text_to_sql |
CREATE TABLE mobile_subscribers (id INT, name VARCHAR(50), data_usage FLOAT, plan_type VARCHAR(10), region VARCHAR(15)); INSERT INTO mobile_subscribers (id, name, data_usage, plan_type, region) VALUES (1, 'Laura González', 4.2, 'postpaid', 'Latin America'); INSERT INTO mobile_subscribers (id, name, data_usage, plan_type, region) VALUES (2, 'Carlos Gómez', 5.1, 'postpaid', 'Latin America'); | What is the minimum mobile data usage for postpaid customers in the 'Latin America' region? | SELECT MIN(data_usage) FROM mobile_subscribers WHERE plan_type = 'postpaid' AND region = 'Latin America'; | gretelai_synthetic_text_to_sql |
CREATE TABLE network_towers (tower_id INT, location VARCHAR(100), longitude DECIMAL(9,6), latitude DECIMAL(9,6), height INT, installed_at TIMESTAMP); | Insert a new network tower into the network_towers table | INSERT INTO network_towers (tower_id, location, longitude, latitude, height, installed_at) VALUES (4001, 'Downtown LA', -118.243683, 34.052235, 50, '2022-01-04 14:40:00'); | gretelai_synthetic_text_to_sql |
CREATE TABLE cosmetics_sales (sale_id INT, product_id INT, sale_date DATE, sale_amount FLOAT, country VARCHAR(255)); | What is the total revenue for cosmetics sold in the US, Canada, and the UK in Q1 2022? | SELECT SUM(sale_amount) FROM cosmetics_sales WHERE sale_date BETWEEN '2022-01-01' AND '2022-03-31' AND country IN ('USA', 'Canada', 'UK'); | gretelai_synthetic_text_to_sql |
CREATE TABLE EventSessions (SessionID INT, EventID INT, Duration INT); INSERT INTO EventSessions (SessionID, EventID, Duration) VALUES (1, 1, 300); INSERT INTO EventSessions (SessionID, EventID, Duration) VALUES (2, 2, 400); INSERT INTO EventSessions (SessionID, EventID, Duration) VALUES (3, 3, 500); | How many hours were spent on esports events in total in 2020 and 2021? | SELECT SUM(Duration) FROM EventSessions INNER JOIN EsportsEvents ON EventSessions.EventID = EsportsEvents.EventID WHERE Year IN (2020, 2021); | gretelai_synthetic_text_to_sql |
CREATE TABLE employees (id INT, name VARCHAR(50), gender VARCHAR(10), salary FLOAT, department_id INT); CREATE TABLE departments (id INT, department_name VARCHAR(50), budget FLOAT); INSERT INTO employees (id, name, gender, salary, department_id) VALUES (1, 'John Doe', 'Male', 60000, 1), (2, 'Jane Smith', 'Female', 65000, 1), (3, 'Mike Johnson', 'Male', 50000, 2), (4, 'Emily Davis', 'Female', 52000, 2); INSERT INTO departments (id, department_name, budget) VALUES (1, 'Human Resources', 200000), (2, 'IT', 500000); | What is the total number of male and female employees in each department in the 'employees' and 'departments' tables? | SELECT d.department_name, e.gender, COUNT(e.id) as total_employees FROM employees e JOIN departments d ON e.department_id = d.id GROUP BY d.department_name, e.gender; | gretelai_synthetic_text_to_sql |
CREATE TABLE Feedback(service VARCHAR(20), region VARCHAR(20), feedback_id INT); INSERT INTO Feedback VALUES ('ServiceA', 'RegionC', 1001), ('ServiceA', 'RegionC', 1002), ('ServiceB', 'RegionD', 2001), ('ServiceB', 'RegionD', 2002), ('ServiceC', 'RegionE', 3001); | How many citizen feedback records are there for 'ServiceB' in 'RegionD'? | SELECT COUNT(*) FROM Feedback WHERE service = 'ServiceB' AND region = 'RegionD'; | gretelai_synthetic_text_to_sql |
CREATE TABLE mines (mine_id INT, mine_type VARCHAR(20)); INSERT INTO mines (mine_id, mine_type) VALUES (1, 'Underground'), (2, 'Open-pit'), (3, 'Underground'), (4, 'Open-pit'); CREATE TABLE mine_production (mine_id INT, year INT, volume INT); INSERT INTO mine_production (mine_id, year, volume) VALUES (1, 2020, 1000), (1, 2021, 1200), (2, 2022, 1500), (3, 2020, 800), (4, 2021, 1800); | Find the total production volume for each mine in the "mine_production" and "mines" tables, grouped by mine type | SELECT m.mine_type, SUM(mp.volume) as total_volume FROM mines m JOIN mine_production mp ON m.mine_id = mp.mine_id GROUP BY m.mine_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE ConstructionLabor (LaborID INT, ContractorID INT, City TEXT, Hours INT); INSERT INTO ConstructionLabor (LaborID, ContractorID, City, Hours) VALUES (101, 1, 'Los Angeles', 400), (102, 2, 'San Francisco', 750), (103, 3, 'Los Angeles', 800); | What is the maximum number of labor hours worked by a single contractor in the city of Los Angeles, CA? | SELECT ContractorID, MAX(Hours) FROM ConstructionLabor WHERE City = 'Los Angeles' GROUP BY ContractorID; | gretelai_synthetic_text_to_sql |
CREATE TABLE security_incidents (id INT, incident_type VARCHAR(255), description TEXT, occurred TIMESTAMP); INSERT INTO security_incidents (id, incident_type, description, occurred) VALUES (1, 'Phishing', '...', '2021-01-01 10:00:00'); | How many security incidents were recorded in the last quarter? | SELECT COUNT(*) FROM security_incidents WHERE occurred >= NOW() - INTERVAL '3 months'; | gretelai_synthetic_text_to_sql |
CREATE TABLE company_funding (company_id INT, funding_year INT, amount FLOAT); INSERT INTO company_funding (company_id, funding_year, amount) VALUES (1, 2010, 1500000.0), (2, 2012, 2000000.0), (3, 2010, 500000.0); | What is the total funding amount for companies founded in 2010? | SELECT SUM(amount) FROM company_funding WHERE funding_year = 2010; | gretelai_synthetic_text_to_sql |
CREATE TABLE military_technologies (id INT, name TEXT, category TEXT); INSERT INTO military_technologies (id, name, category) VALUES (1, 'Tech1', 'Category1'), (2, 'Tech2', 'Category2'), (3, 'Tech3', 'Category1'), (4, 'Tech4', 'Category3'), (5, 'Tech5', 'Category1'), (6, 'Tech6', 'Category4'); | What are the distinct military technologies associated with national security categories 'Category1' and 'Category3'? | SELECT DISTINCT name FROM military_technologies WHERE category IN ('Category1', 'Category3'); | gretelai_synthetic_text_to_sql |
CREATE SCHEMA nation; CREATE SCHEMA province; CREATE SCHEMA territory; CREATE TABLE nation.immigration_data (id INT, name VARCHAR(255), is_open BOOLEAN); CREATE TABLE province.immigration_data (id INT, name VARCHAR(255), is_open BOOLEAN); CREATE TABLE territory.immigration_data (id INT, name VARCHAR(255), is_open BOOLEAN); INSERT INTO nation.immigration_data (id, name, is_open) VALUES (1, 'policies', true), (2, 'statistics', true); INSERT INTO province.immigration_data (id, name, is_open) VALUES (1, 'policies', true), (2, 'statistics', true); INSERT INTO territory.immigration_data (id, name, is_open) VALUES (1, 'policies', true), (2, 'statistics', true), (3, 'programs', true); | Find the intersection of open data sets related to immigration in 'nation', 'province', and 'territory' schemas. | SELECT * FROM ( (SELECT * FROM nation.immigration_data WHERE is_open = true) INTERSECT (SELECT * FROM province.immigration_data WHERE is_open = true) INTERSECT (SELECT * FROM territory.immigration_data WHERE is_open = true) ) AS intersected_data; | gretelai_synthetic_text_to_sql |
CREATE TABLE manufacturers (id INT, name VARCHAR(255), country VARCHAR(255), production_capacity INT); | What is the total production capacity per country for garment manufacturers? | SELECT country, SUM(production_capacity) as total_capacity FROM manufacturers GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE ships (id INT, name VARCHAR(255), capacity INT); INSERT INTO ships (id, name, capacity) VALUES (1, 'Caribbean1', 6000), (2, 'Caribbean2', 8000); | Increase the capacity of all cargo ships owned by Caribbean Shipping by 15% | UPDATE ships SET capacity = capacity * 1.15 WHERE name LIKE 'Caribbean%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE donors (donor_id INTEGER, last_donation_date DATE); INSERT INTO donors (donor_id, last_donation_date) VALUES (1, '2021-06-01'), (2, '2021-01-15'), (3, NULL); | Which donors have not made a donation in the last 6 months? | SELECT donor_id FROM donors WHERE last_donation_date IS NULL OR last_donation_date < DATE('now', '-6 months'); | gretelai_synthetic_text_to_sql |
CREATE TABLE media_library (id INT, title TEXT, genre TEXT, underrepresented_community TEXT); INSERT INTO media_library (id, title, genre, underrepresented_community) VALUES (1, 'Media1', 'Drama', 'CommunityA'), (2, 'Media2', 'Comedy', 'CommunityB'); | How many underrepresented communities are represented in the media library? | SELECT COUNT(DISTINCT underrepresented_community) FROM media_library; | gretelai_synthetic_text_to_sql |
CREATE TABLE genre_festival (festival_id INT, genre VARCHAR(255)); | What is the total revenue generated from concert ticket sales for each music festival genre? | SELECT g.genre, SUM(t.ticket_price) as total_revenue FROM concert_ticket_sales t JOIN festival_performances f ON t.artist_id = f.artist_id JOIN genre_festival g ON f.festival_id = g.festival_id GROUP BY g.genre; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA if not exists military_equipment_sales;CREATE TABLE if not exists military_equipment_sales_table(supplier text, purchaser text, sale_count integer, sale_year integer);INSERT INTO military_equipment_sales_table(supplier, purchaser, sale_count, sale_year) VALUES('General Dynamics', 'Egypt', 15, 2020), ('General Dynamics', 'Nigeria', 10, 2020), ('General Dynamics', 'South Africa', 8, 2020); | What is the total number of military equipment sales by General Dynamics to African countries? | SELECT SUM(sale_count) FROM military_equipment_sales_table WHERE supplier = 'General Dynamics' AND purchaser LIKE 'Africa%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE companies (id INT, name TEXT, sector TEXT, ESG_score FLOAT); INSERT INTO companies (id, name, sector, ESG_score) VALUES (1, 'TechCo', 'Technology', 75), (2, 'GreenEnergy', 'Renewable Energy', 85), (3, 'FinServ', 'Financial Services', 65), (4, 'TechInc', 'Technology', 80), (5, 'MiningCorp', 'Mining', 55); | Determine the average ESG score for investments in the technology sector. | SELECT AVG(ESG_score) FROM companies WHERE sector = 'Technology'; | gretelai_synthetic_text_to_sql |
CREATE TABLE biodiversity (id INT, species VARCHAR(255), population INT); INSERT INTO biodiversity (id, species, population) VALUES (1, 'Polar Bear', 5000), (2, 'Arctic Fox', 10000), (3, 'Caribou', 20000); | How many species are recorded in the 'biodiversity' table? | SELECT COUNT(DISTINCT species) FROM biodiversity; | gretelai_synthetic_text_to_sql |
CREATE TABLE if not exists Projects (id INT, name VARCHAR(50), type VARCHAR(50), budget DECIMAL(10,2), completion_date DATE); INSERT INTO Projects (id, name, type, budget, completion_date) VALUES (1, 'Seawall', 'Resilience', 5000000.00, '2023-01-01'), (2, 'Floodgate', 'Resilience', 3000000.00, '2023-02-01'), (3, 'Bridge', 'Transportation', 8000000.00, '2023-12-01'), (4, 'Highway', 'Transportation', 12000000.00, '2024-03-15'), (5, 'Levee', 'Resilience', 4000000.00, '2023-06-15'), (6, 'Pump Station', 'Resilience', 2500000.00, '2023-09-30'); CREATE TABLE if not exists States (id INT, name VARCHAR(50)); INSERT INTO States (id, name) VALUES (1, 'California'), (2, 'Texas'), (3, 'New York'); | List all resilience projects in the state of California, along with their budgets and completion dates. | SELECT name, budget, completion_date FROM Projects INNER JOIN States ON Projects.id = 1 AND States.name = 'California' WHERE type = 'Resilience'; | gretelai_synthetic_text_to_sql |
CREATE TABLE algorithmic_fairness (method TEXT, technique TEXT, dataset TEXT, impact TEXT); INSERT INTO algorithmic_fairness (method, technique, dataset, impact) VALUES ('Bias Mitigation', 'Reweighing', 'Adult Income', 'Significant reduction in bias'), ('Bias Mitigation', 'Optimized Preprocessing', 'German Credit', 'Not specified'), ('Bias Mitigation', 'Disparate Impact Removal', 'COMPAS', 'Reduction in disparate impact'); | Delete records in the 'algorithmic_fairness' table where the 'impact' column is 'Not Specified' | DELETE FROM algorithmic_fairness WHERE impact = 'Not Specified'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Satellites (satellite_id INT, deployment_year INT, cost FLOAT); INSERT INTO Satellites (satellite_id, deployment_year, cost) VALUES (1, 2022, 20000000.0), (2, 2021, 18000000.0), (3, 2019, 10000000.0), (4, 2018, 8000000.0), (5, 2020, 12000000.0), (6, 2022, 22000000.0); | What is the total cost of satellites deployed in 2021? | SELECT SUM(cost) FROM Satellites WHERE deployment_year = 2021; | gretelai_synthetic_text_to_sql |
CREATE TABLE violation_data (culture VARCHAR(50), violations INT); INSERT INTO violation_data (culture, violations) VALUES ('Hispanic', 10), ('African American', 15), ('Asian', 5); | How many mental health parity violations are recorded per cultural group? | SELECT culture, SUM(violations) FROM violation_data GROUP BY culture; | gretelai_synthetic_text_to_sql |
CREATE TABLE genes (gene_id INT PRIMARY KEY, species TEXT); CREATE TABLE mutations (gene_id INT PRIMARY KEY); | Get the 'gene_id' of all genes that are not present in the 'mutations' table | SELECT g.gene_id FROM genes g LEFT JOIN mutations m ON g.gene_id = m.gene_id WHERE m.gene_id IS NULL; | gretelai_synthetic_text_to_sql |
CREATE TABLE Restaurants (restaurant_id INT, name TEXT, location TEXT); CREATE TABLE Inspections (inspection_id INT, restaurant_id INT, safety_score INT, FOREIGN KEY (restaurant_id) REFERENCES Restaurants(restaurant_id)); INSERT INTO Restaurants (restaurant_id, name, location) VALUES (1, 'Bobs Diner', 'New York'), (2, 'Marys Cafe', 'Los Angeles'), (3, 'Pizzas R Us', 'Chicago'); INSERT INTO Inspections (inspection_id, restaurant_id, safety_score) VALUES (1, 1, 85), (2, 2, 92), (3, 1, 78), (4, 3, 88); | What is the average food safety score for restaurants in New York? | SELECT AVG(safety_score) as avg_score FROM Inspections INNER JOIN Restaurants ON Inspections.restaurant_id = Restaurants.restaurant_id WHERE Restaurants.location = 'New York'; | gretelai_synthetic_text_to_sql |
CREATE TABLE hotels (id INT, country VARCHAR(255), stars DECIMAL(2,1), sustainable BOOLEAN); INSERT INTO hotels (id, country, stars, sustainable) VALUES (1, 'France', 4.2, true), (2, 'France', 3.8, false), (3, 'Germany', 4.5, true), (4, 'Germany', 2.5, false), (5, 'Spain', 4.8, true), (6, 'Spain', 4.0, true), (7, 'Italy', 3.2, false), (8, 'Italy', 3.9, false); | Find the average hotel star rating and the total number of sustainable hotels for each country in the 'hotels' table. | SELECT country, AVG(stars) AS avg_star_rating, SUM(sustainable) AS total_sustainable_hotels FROM hotels GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE Exhibitions (ExhibitionID INT, Title VARCHAR(50), StartDate DATE, EndDate DATE); CREATE TABLE ExhibitionArtists (ExhibitionID INT, ArtistID INT); CREATE TABLE Artists (ArtistID INT, Name VARCHAR(50), BirthDate DATE, DeathDate DATE, Movement VARCHAR(50)); INSERT INTO Artists (ArtistID, Name, BirthDate, DeathDate, Movement) VALUES (1, 'Pablo Picasso', '1881-10-25', '1973-04-08', 'Cubism'); INSERT INTO Exhibitions (ExhibitionID, Title, StartDate, EndDate) VALUES (1, 'Cubism: The Revolutionary Art', '1931-06-01', '1931-08-31'); INSERT INTO ExhibitionArtists (ExhibitionID, ArtistID) VALUES (1, 1); | List all exhibitions featuring artists from the Cubism movement. | SELECT Exhibitions.Title FROM Exhibitions JOIN ExhibitionArtists ON Exhibitions.ExhibitionID = ExhibitionArtists.ExhibitionID JOIN Artists ON ExhibitionArtists.ArtistID = Artists.ArtistID WHERE Artists.Movement = 'Cubism'; | gretelai_synthetic_text_to_sql |
CREATE TABLE CYBER_STRATEGIES (id INT PRIMARY KEY, country VARCHAR(255), strategy VARCHAR(255), year INT); | Which cybersecurity strategies were implemented in 'Country1' in the CYBER_STRATEGIES table? | SELECT strategy FROM CYBER_STRATEGIES WHERE country = 'Country1' AND year = (SELECT MAX(year) FROM CYBER_STRATEGIES WHERE country = 'Country1'); | gretelai_synthetic_text_to_sql |
CREATE TABLE FleetMaintenance (FleetID int, FleetName varchar(255), MaintenanceCost decimal(5,2)); INSERT INTO FleetMaintenance (FleetID, FleetName, MaintenanceCost) VALUES (1, 'Blue', 1200), (2, 'Yellow', 1500), (3, 'Red', 1000), (4, 'Green', 1300); | What is the average maintenance cost for vehicles in the 'Red' fleet? | SELECT AVG(MaintenanceCost) FROM FleetMaintenance WHERE FleetName = 'Red'; | gretelai_synthetic_text_to_sql |
CREATE TABLE safety_protocols (year INT, protocol VARCHAR(20)); INSERT INTO safety_protocols (year, protocol) VALUES (2018, 'Safety Goggles'), (2018, 'Lab Coats'), (2019, 'Gloves'), (2019, 'Safety Training'), (2020, 'Fire Extinguishers'), (2020, 'Emergency Exits'); | Count the number of new safety protocols added each year | SELECT year, COUNT(protocol) FROM safety_protocols GROUP BY year; | gretelai_synthetic_text_to_sql |
CREATE TABLE school_data (state VARCHAR(255), school_type VARCHAR(255), count INT); INSERT INTO school_data (state, school_type, count) VALUES ('California', 'Public', 10000), ('California', 'Private', 2000); | How many public schools are there in the state of 'California'? | SELECT SUM(count) FROM school_data WHERE state = 'California' AND school_type = 'Public'; | gretelai_synthetic_text_to_sql |
CREATE TABLE solar_plants (id INT, name TEXT, state TEXT, capacity FLOAT, year INT); INSERT INTO solar_plants (id, name, state, capacity, year) VALUES (1, 'Solar Star', 'California', 579, 2015), (2, 'Desert Sunlight', 'California', 550, 2016), (3, 'Topaz Solar Farms', 'California', 550, 2017); | How many solar power plants were installed in California between 2015 and 2017? | SELECT COUNT(*) FROM solar_plants WHERE state = 'California' AND year BETWEEN 2015 AND 2017; | gretelai_synthetic_text_to_sql |
CREATE TABLE broadband_customers (customer_id INT, net_neutrality_compliant BOOLEAN, state VARCHAR(20)); INSERT INTO broadband_customers (customer_id, net_neutrality_compliant, state) VALUES (1, FALSE, 'California'), (2, TRUE, 'California'); | Which broadband customers have been non-compliant with net neutrality regulations in the state of California? | SELECT customer_id FROM broadband_customers WHERE net_neutrality_compliant = FALSE AND state = 'California'; | gretelai_synthetic_text_to_sql |
CREATE TABLE mobile_customers (customer_id INT, plan_type VARCHAR(10), data_usage FLOAT, region VARCHAR(20)); INSERT INTO mobile_customers (customer_id, plan_type, data_usage, region) VALUES (1, 'postpaid', 3.5, 'Chicago'), (2, 'prepaid', 2.0, 'Chicago'), (3, 'postpaid', 5.0, 'New York'); CREATE TABLE regions (region VARCHAR(20)); INSERT INTO regions (region) VALUES ('Chicago'), ('New York'); | What is the number of mobile customers in each region, sorted by number of customers in descending order? | SELECT r.region, COUNT(mc.customer_id) AS customer_count FROM mobile_customers mc JOIN regions r ON mc.region = r.region GROUP BY r.region ORDER BY customer_count DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE carbon_prices (date text, eu_ets real); INSERT INTO carbon_prices (date, eu_ets) VALUES ('2022-03-01', 36), ('2022-03-02', 37), ('2022-03-03', 38), ('2022-02-01', 33), ('2022-02-02', 34), ('2022-02-03', 35), ('2022-01-01', 30), ('2022-01-02', 31), ('2022-01-03', 32); | What is the monthly carbon price trend in the EU ETS for the last year? | SELECT date, eu_ets FROM carbon_prices WHERE date >= DATEADD(month, -12, CURRENT_DATE) AND date < CURRENT_DATE ORDER BY date; | gretelai_synthetic_text_to_sql |
CREATE TABLE mines (id INT, name VARCHAR(255), location VARCHAR(255), mineral VARCHAR(255), production_volume INT); INSERT INTO mines (id, name, location, mineral, production_volume) VALUES (5, 'Mine E', 'Country5', 'Gold', 2000); INSERT INTO mines (id, name, location, mineral, production_volume) VALUES (6, 'Mine F', 'Country6', 'Gold', 1800); | What is the maximum hourly wage for each country where gold is mined? | SELECT m.location, MAX(l.hourly_wage) AS max_wage FROM mines m JOIN labor l ON m.id = l.mine_id WHERE m.mineral = 'Gold' GROUP BY m.location; | gretelai_synthetic_text_to_sql |
CREATE TABLE ArtistHistory (ArtistID int, Genre varchar(50), StartYear int, EndYear int); INSERT INTO ArtistHistory VALUES (1, 'Rock', 1980, 1990); INSERT INTO ArtistHistory VALUES (1, 'Pop', 1991, 2000); INSERT INTO ArtistHistory VALUES (2, 'HipHop', 1995, 2005); INSERT INTO ArtistHistory VALUES (2, 'RnB', 2006, 2010); | List the artists who have changed their primary genre over time. | SELECT ArtistID FROM ArtistHistory WHERE Genre = 'Rock' AND EndYear IS NOT NULL INTERSECT SELECT ArtistID FROM ArtistHistory WHERE Genre <> 'Rock'; | gretelai_synthetic_text_to_sql |
CREATE TABLE rural_hospitals( hospital_id INT PRIMARY KEY, name VARCHAR(255), bed_count INT, rural_population_served INT); | Delete the table 'rural_hospitals' | DROP TABLE rural_hospitals; | gretelai_synthetic_text_to_sql |
CREATE TABLE member_categories (member_category VARCHAR(20), member_id INT, heart_rate INT); INSERT INTO member_categories (member_category, member_id, heart_rate) VALUES ('Gold', 1, 75), ('Gold', 2, 80), ('Silver', 3, 65), ('Bronze', 4, 70), ('Bronze', 5, 72); | What is the average heart rate for each member category? | SELECT pivot_col, AVG(heart_rate) as avg_heart_rate FROM (SELECT member_category AS pivot_col, heart_rate FROM member_categories) GROUP BY pivot_col; | gretelai_synthetic_text_to_sql |
CREATE TABLE intel_ops (id INT, operation VARCHAR, budget INT); INSERT INTO intel_ops (id, operation, budget) VALUES (1, 'Operation Red Folder', 5000000), (2, 'Operation Black Vault', 7000000), (3, 'Operation Blue Sail', 6000000); | List the intelligence operations with their corresponding budgets, ordered from highest to lowest budget. | SELECT operation, budget FROM intel_ops ORDER BY budget DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE Neighborhoods (NeighborhoodID INT, NeighborhoodName VARCHAR(255)); CREATE TABLE CrimeTypes (CrimeTypeID INT, CrimeType VARCHAR(255)); CREATE TABLE Crimes (CrimeID INT, CrimeTypeID INT, NeighborhoodID INT, CrimeDate DATE); | How many crimes of each type were reported in each neighborhood in the last month? | SELECT n.NeighborhoodName, ct.CrimeType, COUNT(c.CrimeID) as CrimesCount FROM Crimes c JOIN Neighborhoods n ON c.NeighborhoodID = n.NeighborhoodID JOIN CrimeTypes ct ON c.CrimeTypeID = ct.CrimeTypeID WHERE c.CrimeDate >= DATEADD(month, -1, GETDATE()) GROUP BY n.NeighborhoodName, ct.CrimeType; | gretelai_synthetic_text_to_sql |
CREATE TABLE ProductIngredients (product_id INT, product_name VARCHAR(20), transparency_score INT); INSERT INTO ProductIngredients (product_id, product_name, transparency_score) VALUES (1, 'lipstick', 80), (2, 'mascara', 70), (3, 'foundation', 90); | Update the ingredient transparency score for a specific product in the database | UPDATE ProductIngredients SET transparency_score = 85 WHERE product_id = 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE artists (artist_id INT, artist_name VARCHAR(100), artist_age INT, genre VARCHAR(50)); INSERT INTO artists VALUES (1, 'Artist A', 35, 'Hip-Hop'); INSERT INTO artists VALUES (2, 'Artist B', 28, 'Hip-Hop'); CREATE TABLE festivals (festival_id INT, festival_name VARCHAR(100), artist_id INT); INSERT INTO festivals VALUES (1, 'Festival X', 1); INSERT INTO festivals VALUES (2, 'Festival Y', 2); | What is the average age of all hip-hop artists who have performed at music festivals? | SELECT AVG(artists.artist_age) FROM artists INNER JOIN festivals ON artists.artist_id = festivals.artist_id WHERE artists.genre = 'Hip-Hop'; | gretelai_synthetic_text_to_sql |
CREATE TABLE ocean_health_metrics (country VARCHAR(50), metric1 DECIMAL(5,2), metric2 DECIMAL(5,2), metric3 DECIMAL(5,2)); | Identify the top 3 countries with the highest ocean health metrics. | SELECT country, MAX(metric1 + metric2 + metric3) as top_metric FROM ocean_health_metrics GROUP BY country ORDER BY top_metric DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE multimodal_trips (trip_id INT, trip_duration FLOAT, start_speed FLOAT, end_speed FLOAT, start_time TIMESTAMP, end_time TIMESTAMP, trip_type VARCHAR(50), city VARCHAR(50)); INSERT INTO multimodal_trips (trip_id, trip_duration, start_speed, end_speed, start_time, end_time, trip_type, city) VALUES (1, 120.0, 0.0, 10.0, '2021-01-01 00:00:00', '2021-01-01 01:00:00', 'public_transportation', 'Madrid'), (2, 180.0, 0.0, 20.0, '2021-01-02 08:00:00', '2021-01-02 10:00:00', 'shared_bike', 'Madrid'); | What is the total number of multimodal trips in Madrid involving public transportation and shared bikes? | SELECT COUNT(*) FROM multimodal_trips WHERE (trip_type = 'public_transportation' OR trip_type = 'shared_bike') AND city = 'Madrid'; | gretelai_synthetic_text_to_sql |
CREATE TABLE movies (id INT, title TEXT, country TEXT, year INT, runtime INT); INSERT INTO movies (id, title, country, year, runtime) VALUES (1, 'MovieA', 'India', 2018, 125), (2, 'MovieB', 'India', 2019, 135), (3, 'MovieC', 'USA', 2020, 105); | What is the average runtime of Indian movies produced in 2018? | SELECT AVG(runtime) FROM movies WHERE country = 'India' AND year = 2018; | gretelai_synthetic_text_to_sql |
CREATE TABLE providers (provider_id INT, first_name VARCHAR(50), last_name VARCHAR(50), specialty VARCHAR(50), city VARCHAR(50), state VARCHAR(2)); CREATE TABLE patients (patient_id INT, provider_id INT, first_name VARCHAR(50), last_name VARCHAR(50), city VARCHAR(50), state VARCHAR(2)); | List the first name, last name, and city for all providers who have 'therapist' in their specialty and are located in New York, NY, along with the number of patients assigned to each provider | SELECT p.first_name, p.last_name, p.city, COUNT(pa.patient_id) AS patient_count FROM providers p JOIN patients pa ON p.provider_id = pa.provider_id WHERE p.specialty LIKE '%therapist%' AND p.city = 'New York' AND p.state = 'NY' GROUP BY p.provider_id, p.first_name, p.last_name, p.city ORDER BY patient_count DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE production (year INT, element VARCHAR(10), quantity INT); INSERT INTO production (year, element, quantity) VALUES (2015, 'Dysprosium', 1200), (2016, 'Dysprosium', 1400), (2017, 'Dysprosium', 1500), (2018, 'Dysprosium', 1700), (2019, 'Dysprosium', 1800), (2020, 'Dysprosium', 2000), (2021, 'Dysprosium', 2200); | What was the total production of Dysprosium in 2018 and 2019? | SELECT SUM(quantity) FROM production WHERE element = 'Dysprosium' AND year IN (2018, 2019); | gretelai_synthetic_text_to_sql |
CREATE TABLE events (id INT, name VARCHAR(255), category VARCHAR(255), tickets_sold INT, event_date DATE); INSERT INTO events (id, name, category, tickets_sold, event_date) VALUES (1, 'Concert in the Park', 'Music', 300, '2021-06-12'); INSERT INTO events (id, name, category, tickets_sold, event_date) VALUES (2, 'Jazz Night', 'Music', 250, '2021-07-23'); | What was the total number of tickets sold for events in the 'Music' category last year? | SELECT SUM(tickets_sold) FROM events WHERE category = 'Music' AND event_date BETWEEN '2021-01-01' AND '2021-12-31'; | gretelai_synthetic_text_to_sql |
CREATE TABLE landfill_capacity (id INT, country VARCHAR(20), year INT, capacity INT); | Delete records in landfill_capacity where country is 'Germany' | WITH data_to_delete AS (DELETE FROM landfill_capacity WHERE country = 'Germany' RETURNING *) DELETE FROM landfill_capacity WHERE id IN (SELECT id FROM data_to_delete); | gretelai_synthetic_text_to_sql |
CREATE TABLE Players (PlayerID INT, Game VARCHAR(50), Continent VARCHAR(50)); INSERT INTO Players (PlayerID, Game, Continent) VALUES (1, 'Rocket League', 'North America'); INSERT INTO Players (PlayerID, Game, Continent) VALUES (2, 'Rocket League', 'Europe'); INSERT INTO Players (PlayerID, Game, Continent) VALUES (3, 'Rocket League', 'South America'); INSERT INTO Players (PlayerID, Game, Continent) VALUES (4, 'Rocket League', 'Asia'); | How many players have played Rocket League in each continent? | SELECT Continent, COUNT(PlayerID) as PlayerCount FROM Players WHERE Game = 'Rocket League' GROUP BY Continent; | gretelai_synthetic_text_to_sql |
CREATE TABLE crime_incidents (id INT, date DATE, type VARCHAR(20)); INSERT INTO crime_incidents (id, date, type) VALUES (1, '2022-01-01', 'theft'), (2, '2022-01-02', 'burglary'); | How many crime incidents were reported in the last week for each type of crime? | SELECT type, COUNT(*) FROM crime_incidents WHERE date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 WEEK) GROUP BY type; | gretelai_synthetic_text_to_sql |
CREATE TABLE factories (factory_id INT, factory_name VARCHAR(50), country VARCHAR(50), co2_emission INT); CREATE TABLE country_regions (country VARCHAR(50), region VARCHAR(50)); | What is the total CO2 emission for each factory in the Northern region by country? | SELECT country, SUM(co2_emission) FROM factories JOIN country_regions ON factories.country = country_regions.country WHERE region = 'Northern' GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE VIEW defense_contracts AS SELECT contractor_name, contract_type, contract_value FROM military_contracts; | Show the number of defense contracts awarded to each contractor for the 'Radar Systems' contract type in the defense_contracts view. | SELECT contractor_name, COUNT(*) FROM defense_contracts WHERE contract_type = 'Radar Systems' GROUP BY contractor_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE ArtifactTypes (id INT, name VARCHAR(255), category VARCHAR(255)); INSERT INTO ArtifactTypes (id, name, category) VALUES (1, 'Pottery', 'Artifact'); CREATE TABLE Artifacts (id INT, artifactTypeId INT, name VARCHAR(255), weight FLOAT); INSERT INTO Artifacts (id, artifactTypeId, weight) VALUES (1, 1, 1.5), (2, 1, 2.2), (3, 1, 1.8); | What is the average weight of pottery artifacts? | SELECT AVG(weight) FROM Artifacts WHERE artifactTypeId = (SELECT id FROM ArtifactTypes WHERE name = 'Pottery'); | gretelai_synthetic_text_to_sql |
CREATE TABLE article_dates (title text, topic text, publish_date date); INSERT INTO article_dates (title, topic, publish_date) VALUES ('Article 3', 'media ethics', '2022-01-01'); INSERT INTO article_dates (title, topic, publish_date) VALUES ('Article 4', 'media ethics', '2022-02-15'); | How many articles were published per month on the topic of 'media ethics'? | SELECT EXTRACT(MONTH FROM publish_date) as month, COUNT(*) as count FROM article_dates WHERE topic = 'media ethics' GROUP BY month; | gretelai_synthetic_text_to_sql |
CREATE TABLE workplace_safety (id INT, sector VARCHAR(50), num_incidents INT); INSERT INTO workplace_safety (id, sector, num_incidents) VALUES (1, 'healthcare', 6); INSERT INTO workplace_safety (id, sector, num_incidents) VALUES (2, 'technology', 3); INSERT INTO workplace_safety (id, sector, num_incidents) VALUES (3, 'manufacturing', 4); | What is the average number of workplace safety incidents reported in the 'technology' sector? | SELECT AVG(num_incidents) FROM workplace_safety WHERE sector = 'technology'; | gretelai_synthetic_text_to_sql |
CREATE TABLE yearly_visitor_count (destination VARCHAR(50), year INT, visitor_count INT); | Identify destinations that experienced a continuous increase in visitor count for at least 2 years, starting from 2015? | SELECT a.destination FROM yearly_visitor_count a JOIN yearly_visitor_count b ON a.destination = b.destination AND a.year = b.year + 1 WHERE a.visitor_count > b.visitor_count GROUP BY a.destination HAVING COUNT(DISTINCT a.year) >= 2 AND MIN(a.year) = 2015; | gretelai_synthetic_text_to_sql |
CREATE TABLE sales_data (sale_id INT, dish_id INT, sale_date DATE); INSERT INTO sales_data (sale_id, dish_id, sale_date) VALUES (1, 1, '2022-01-01'), (2, 2, '2022-01-05'), (3, 1, '2022-01-10'), (4, 3, '2022-01-15'); CREATE TABLE menu (dish_id INT, dish_name VARCHAR(255), dish_type VARCHAR(255)); INSERT INTO menu (dish_id, dish_name, dish_type) VALUES (1, 'Quinoa Salad', 'Vegetarian'), (2, 'Chicken Sandwich', 'Non-Vegetarian'), (3, 'Pumpkin Soup', 'Vegetarian'), (4, 'Beef Stew', 'Non-Vegetarian'); | Determine the dishes that have not been sold in the last 60 days | SELECT m.dish_id, m.dish_name FROM menu m LEFT JOIN sales_data s ON m.dish_id = s.dish_id WHERE s.sale_date < DATE_SUB(CURDATE(), INTERVAL 60 DAY) IS NULL; | gretelai_synthetic_text_to_sql |
CREATE TABLE drivers (id INT, name VARCHAR(50), salary DECIMAL(10, 2), is_union_member BOOLEAN); INSERT INTO drivers (id, name, salary, is_union_member) VALUES (1, 'Larry', 60000.00, false), (2, 'Lisa', 65000.00, true), (3, 'Luke', 55000.00, false); | What is the minimum salary for workers in the 'transportation_database' database who are not members of a union? | SELECT MIN(salary) FROM drivers WHERE is_union_member = false; | gretelai_synthetic_text_to_sql |
CREATE TABLE workouts (id INT, user_id INT, workout_time TIMESTAMP, heart_rate INT); INSERT INTO workouts (id, user_id, workout_time, heart_rate) VALUES (1, 1, '2022-01-01 06:00:00', 120), (2, 2, '2022-01-02 07:30:00', 115); | What is the average heart rate of users during their morning workouts in the last week? | SELECT AVG(heart_rate) FROM (SELECT heart_rate FROM workouts WHERE DATE(workout_time) BETWEEN DATE_SUB(CURRENT_DATE(), INTERVAL 7 DAY) AND CURRENT_DATE() AND HOUR(workout_time) BETWEEN 6 AND 11) AS subquery; | gretelai_synthetic_text_to_sql |
CREATE TABLE vaccinations (id INT PRIMARY KEY, patient_id INT, vaccine VARCHAR(255), date DATE); INSERT INTO vaccinations (id, patient_id, vaccine, date) VALUES (1, 12345, 'Pfizer-BioNTech', '2021-01-05'); INSERT INTO vaccinations (id, patient_id, vaccine, date) VALUES (2, 67890, 'Moderna', '2021-01-10'); INSERT INTO vaccinations (id, patient_id, vaccine, date) VALUES (3, 12345, 'Pfizer-BioNTech', '2021-01-15'); | What is the total number of vaccinations administered before January 15, 2021? | SELECT COUNT(*) FROM vaccinations WHERE date < '2021-01-15'; | 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.