context stringlengths 11 9.12k | question stringlengths 0 1.06k | SQL stringlengths 2 4.44k | source stringclasses 28 values |
|---|---|---|---|
CREATE TABLE if not exists regions (id INT, name VARCHAR(20)); INSERT INTO regions (id, name) VALUES (1, 'North Africa'), (2, 'West Africa'), (3, 'Central Africa'), (4, 'East Africa'), (5, 'Southern Africa'); CREATE TABLE if not exists visitors (id INT, region_id INT, year INT, visitors INT); | What is the total number of international visitors to each region in Africa in 2019 and 2020? | SELECT r.name, v.year, SUM(v.visitors) FROM visitors v JOIN regions r ON v.region_id = r.id WHERE r.name IN ('North Africa', 'West Africa', 'Central Africa', 'East Africa', 'Southern Africa') AND v.year IN (2019, 2020) GROUP BY r.name, v.year; | gretelai_synthetic_text_to_sql |
CREATE TABLE volunteer_history (id INT, volunteer_id INT, year INT, num_hours INT); INSERT INTO volunteer_history (id, volunteer_id, year, num_hours) VALUES (1, 1, 2019, 100), (2, 1, 2020, 150), (3, 2, 2019, 75), (4, 2, 2020, 200), (5, 3, 2019, 125), (6, 3, 2020, 175), (7, 4, 2019, 50), (8, 4, 2020, 75); | Which volunteers have not volunteered in the last 6 months? | SELECT volunteer_id FROM volunteer_history WHERE YEAR(NOW()) - year > 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE temperature_anomalies (year INT, ocean_basin VARCHAR(50), temperature_anomaly FLOAT); INSERT INTO temperature_anomalies (year, ocean_basin, temperature_anomaly) VALUES (2010, 'Pacific Ocean', 1.2); INSERT INTO temperature_anomalies (year, ocean_basin, temperature_anomaly) VALUES (2010, 'Atlantic Ocean', 1.4); | What is the average temperature anomaly for each ocean basin, segmented by year? | SELECT ocean_basin, AVG(temperature_anomaly) FROM temperature_anomalies GROUP BY ocean_basin, year; | gretelai_synthetic_text_to_sql |
CREATE TABLE ota_adoptions (id INT, quarter TEXT, region TEXT, hotel_adoptions INT); INSERT INTO ota_adoptions (id, quarter, region, hotel_adoptions) VALUES (1, 'Q1 2022', 'APAC', 50), (2, 'Q2 2022', 'APAC', 75), (3, 'Q1 2022', 'North America', 60); | How many hotels were adopted by OTAs in the last quarter in the APAC region? | SELECT region, hotel_adoptions FROM ota_adoptions WHERE quarter = 'Q2 2022' AND region = 'APAC'; | gretelai_synthetic_text_to_sql |
CREATE TABLE clients (client_id INT, name TEXT, investment_type TEXT, investment FLOAT); INSERT INTO clients (client_id, name, investment_type, investment) VALUES (1, 'Jamal Johnson', 'Stocks', 3000.00), (1, 'Jamal Johnson', 'Bonds', 2000.00), (2, 'Priya Patel', 'Stocks', 5000.00); | What is the total investment for each client? | SELECT client_id, name, SUM(investment) OVER (PARTITION BY client_id ORDER BY client_id) as total_investment FROM clients; | gretelai_synthetic_text_to_sql |
CREATE TABLE digital_wallets (id INT, name VARCHAR(50), daily_tx_volume INT); INSERT INTO digital_wallets (id, name, daily_tx_volume) VALUES (1, 'Wallet1', 1000), (2, 'Wallet2', 2000), (3, 'Wallet3', 3000), (4, 'Wallet4', 4000), (5, 'Wallet5', 5000), (6, 'Wallet6', 6000), (7, 'Wallet7', 7000), (8, 'Wallet8', 8000), (9, 'Wallet9', 9000), (10, 'Wallet10', 10000), (11, 'Wallet11', 11000); | What is the average daily transaction volume for the top 10 most active digital wallets in Africa? | SELECT name, AVG(daily_tx_volume) as avg_daily_tx_volume FROM (SELECT name, daily_tx_volume, RANK() OVER (ORDER BY daily_tx_volume DESC) as rank FROM digital_wallets WHERE region = 'Africa') x WHERE rank <= 10 GROUP BY name; | gretelai_synthetic_text_to_sql |
CREATE TABLE co2_emissions (brand VARCHAR(50), reduction INT, date DATE); INSERT INTO co2_emissions (brand, reduction, date) VALUES ('Ethical Brand A', 1000, '2023-01-01'), ('Ethical Brand B', 1500, '2023-01-01'), ('Ethical Brand C', 500, '2023-01-01'), ('Ethical Brand A', 800, '2023-02-01'), ('Ethical Brand D', 1200, '2023-01-01'); | What is the total CO2 emission reduction in the last 6 months for each ethical fashion brand? | SELECT brand, SUM(reduction) FROM co2_emissions WHERE date >= DATEADD(month, -6, CURRENT_DATE) GROUP BY brand; | gretelai_synthetic_text_to_sql |
CREATE TABLE electric_vehicle_stats (country VARCHAR(50), adoption_rate DECIMAL(3,1), year INT); | What is the adoption rate of electric vehicles by year? | SELECT year, AVG(adoption_rate) FROM electric_vehicle_stats GROUP BY year; | gretelai_synthetic_text_to_sql |
CREATE TABLE timber (id INT, name VARCHAR(255), area FLOAT, region_id INT); INSERT INTO timber (id, name, area, region_id) VALUES (1, 'Timber1', 123.45, 1); INSERT INTO timber (id, name, area, region_id) VALUES (2, 'Timber2', 234.56, 2); CREATE TABLE region (id INT, name VARCHAR(255)); INSERT INTO region (id, name) VALUES (1, 'Region1'); INSERT INTO region (id, name) VALUES (2, 'Region2'); | What is the average area of timber production sites by region? | SELECT r.name, AVG(t.area) FROM timber t JOIN region r ON t.region_id = r.id GROUP BY r.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE attorneys (attorney_id INT, office VARCHAR(50)); INSERT INTO attorneys VALUES (1, 'Boston'); CREATE TABLE cases (case_id INT, attorney_id INT, case_outcome VARCHAR(10)); | What is the percentage of cases won by attorneys in the 'Boston' office? | SELECT 100.0 * COUNT(*) / (SELECT COUNT(*) FROM cases INNER JOIN attorneys ON cases.attorney_id = attorneys.attorney_id) AS percentage_won FROM cases INNER JOIN attorneys ON cases.attorney_id = attorneys.attorney_id WHERE attorneys.office = 'Boston' AND case_outcome = 'won'; | gretelai_synthetic_text_to_sql |
CREATE TABLE humanitarian_assistance (program_name VARCHAR(255), start_date DATE, end_date DATE, assistance_type VARCHAR(255), total_funding FLOAT); | Create a new table named 'humanitarian_assistance' with columns 'program_name', 'start_date', 'end_date', 'assistance_type', and 'total_funding' | CREATE TABLE humanitarian_assistance (program_name VARCHAR(255), start_date DATE, end_date DATE, assistance_type VARCHAR(255), total_funding FLOAT); | gretelai_synthetic_text_to_sql |
CREATE TABLE norwegian_farms (farmer_id INT, fish_species TEXT, stocking_density FLOAT); INSERT INTO norwegian_farms (farmer_id, fish_species, stocking_density) VALUES (1, 'Cod', 1.2), (2, 'Haddock', 1.8), (3, 'Cod', 1.5); | What is the minimum stocking density of Cod in Norwegian farms? | SELECT MIN(stocking_density) FROM norwegian_farms WHERE fish_species = 'Cod'; | gretelai_synthetic_text_to_sql |
CREATE TABLE aircraft_models (model VARCHAR(50), manufacturer VARCHAR(50), first_flight YEAR, production_status VARCHAR(50)); INSERT INTO aircraft_models (model, manufacturer, first_flight, production_status) VALUES ('A320', 'Airbus', 1988, 'In Production'), ('A330', 'Airbus', 1994, 'In Production'), ('A340', 'Airbus', 1993, 'Out of Production'), ('A350', 'Airbus', 2015, 'In Production'), ('A380', 'Airbus', 2007, 'In Production'); | Update the production_status of the aircraft model 'A380' in the 'aircraft_models' table to 'Out of Production' | UPDATE aircraft_models SET production_status = 'Out of Production' WHERE model = 'A380'; | gretelai_synthetic_text_to_sql |
CREATE TABLE studio (studio_id INT, studio_name VARCHAR(50), country VARCHAR(50)); INSERT INTO studio (studio_id, studio_name, country) VALUES (1, 'Studio A', 'USA'), (2, 'Studio B', 'Canada'); CREATE TABLE movie (movie_id INT, title VARCHAR(50), release_year INT, revenue INT, studio_id INT); INSERT INTO movie (movie_id, title, release_year, revenue, studio_id) VALUES (1, 'Movie 1', 2019, 100000, 1), (2, 'Movie 2', 2020, 200000, 1), (3, 'Movie 3', 2018, 150000, 2); | What's the total revenue generated by movies produced by a specific studio? | SELECT SUM(revenue) FROM movie JOIN studio ON movie.studio_id = studio.studio_id WHERE studio.studio_name = 'Studio A'; | gretelai_synthetic_text_to_sql |
CREATE TABLE users (id INT, country VARCHAR(255), last_update DATE, posts_count INT); | What is the total number of users from Brazil who have updated their profile information in the last month, and what is the average number of posts they have made? | SELECT COUNT(*), AVG(users.posts_count) FROM users WHERE country = 'Brazil' AND last_update >= DATE_SUB(CURDATE(), INTERVAL 1 MONTH); | gretelai_synthetic_text_to_sql |
CREATE TABLE intelligence_operations (id INT, operation_name TEXT, success BOOLEAN); | What is the total number of successful intelligence operations in the 'intelligence_operations' table? | SELECT SUM(success) FROM intelligence_operations WHERE success = true; | gretelai_synthetic_text_to_sql |
CREATE TABLE Bridge (id INT, name VARCHAR(255), state VARCHAR(255)); INSERT INTO Bridge (id, name, state) VALUES (1, 'Bridge A', 'California'), (2, 'Bridge B', 'Texas'); CREATE TABLE Tunnel (id INT, name VARCHAR(255), state VARCHAR(255)); INSERT INTO Tunnel (id, name, state) VALUES (1, 'Tunnel A', 'New York'), (2, 'Tunnel B', 'California'); | Find the number of bridges and tunnels in California | SELECT COUNT(*) FROM (SELECT * FROM Bridge WHERE state = 'California' UNION ALL SELECT * FROM Tunnel WHERE state = 'California') AS combined; | gretelai_synthetic_text_to_sql |
CREATE TABLE population_growth (id INT, community_name VARCHAR, year INT, population INT, growth_rate FLOAT); INSERT INTO population_growth VALUES (1, 'First Nations', 2010, 637000, 0.03); | What is the population growth rate of indigenous communities in the Arctic? | SELECT community_name, AVG(growth_rate) FROM population_growth GROUP BY community_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE forestry.harvest (year INT, country VARCHAR(50), volume FLOAT); INSERT INTO forestry.harvest (year, country, volume) VALUES (2020, 'Canada', 1200000), (2020, 'USA', 1500000); | What is the total volume of timber harvested in 2020 for each country? | SELECT country, SUM(volume) FROM forestry.harvest WHERE year = 2020 GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE songs (id INT, name TEXT, genre TEXT, release_year INT, rating FLOAT); INSERT INTO songs (id, name, genre, release_year, rating) VALUES (1, 'Dynamite', 'K-pop', 2020, 4.7), (2, 'Butter', 'K-pop', 2021, 4.9), (3, 'Permission to Dance', 'K-pop', 2021, 4.6); CREATE VIEW kpop_songs_2021 AS SELECT * FROM songs WHERE genre = 'K-pop' AND release_year = 2021; | What is the average rating of K-pop songs released in 2021? | SELECT AVG(rating) FROM kpop_songs_2021; | gretelai_synthetic_text_to_sql |
CREATE TABLE vessels (id INT, name TEXT, last_inspection DATE); INSERT INTO vessels (id, name, last_inspection) VALUES (1, 'Vessel A', '2022-01-01'); INSERT INTO vessels (id, name, last_inspection) VALUES (2, 'Vessel B', '2022-05-15'); | Which vessels have not been inspected in the past 6 months? | SELECT * FROM vessels WHERE last_inspection < DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH); | gretelai_synthetic_text_to_sql |
CREATE TABLE facilities (facility_id INT, condition VARCHAR(50)); | List unique mental health conditions treated in each facility. | SELECT facility_id, STRING_AGG(DISTINCT condition, ', ') as conditions FROM facilities GROUP BY facility_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE sa_compounds (compound_id INT, compound_name TEXT, region TEXT, production_quantity INT); INSERT INTO sa_compounds (compound_id, compound_name, region, production_quantity) VALUES (1, 'Compound L', 'South America', 3000), (2, 'Compound M', 'South America', 2000), (3, 'Compound N', 'South America', 5000), (4, 'Compound O', 'South America', 4000); | What are the production quantities (in kg) for all chemical compounds in the South America region, ordered by production quantity in ascending order? | SELECT compound_name, production_quantity FROM sa_compounds WHERE region = 'South America' ORDER BY production_quantity ASC; | gretelai_synthetic_text_to_sql |
CREATE TABLE patients (id INT, age INT, gender TEXT, state TEXT, alternative_therapy TEXT); INSERT INTO patients (id, age, gender, state, alternative_therapy) VALUES (1, 35, 'Female', 'California', 'No'); INSERT INTO patients (id, age, gender, state, alternative_therapy) VALUES (2, 42, 'Male', 'Texas', 'Yes'); | What is the average age of patients in Texas who have tried alternative therapies like meditation? | SELECT AVG(patients.age) FROM patients WHERE patients.state = 'Texas' AND patients.alternative_therapy = 'Yes'; | gretelai_synthetic_text_to_sql |
CREATE TABLE COVIDCountry (Country VARCHAR(50), Cases INT); INSERT INTO COVIDCountry (Country, Cases) VALUES ('Canada', 20000), ('USA', 30000), ('Mexico', 15000); | What is the total number of COVID-19 cases in each country? | SELECT Country, SUM(Cases) FROM COVIDCountry GROUP BY Country; | gretelai_synthetic_text_to_sql |
CREATE TABLE ClinicalTrials (clinical_trial_id TEXT, drug_name TEXT, laboratory TEXT, year INTEGER); | Insert a new clinical trial for 'DrugH' by 'GlobalPharm' in '2023'. | INSERT INTO ClinicalTrials (clinical_trial_id, drug_name, laboratory, year) VALUES ('Trial003', 'DrugH', 'GlobalPharm', 2023); | gretelai_synthetic_text_to_sql |
CREATE TABLE donors (id INT, name VARCHAR(30), cause_area VARCHAR(20)); CREATE TABLE donations (id INT, donor_id INT, amount INT); INSERT INTO donors (id, name, cause_area) VALUES (1, 'John Doe', 'education'), (2, 'Jane Smith', 'education'); INSERT INTO donations (id, donor_id, amount) VALUES (1, 1, 5000), (2, 1, 5000), (3, 2, 7000); | List the names and total donations of top 3 donors in the 'education' cause area, excluding any duplicates. | SELECT donors.name, SUM(donations.amount) FROM donors INNER JOIN donations ON donors.id = donations.donor_id WHERE donors.cause_area = 'education' GROUP BY donors.name ORDER BY SUM(donations.amount) DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE sales (sale_id INT, product_id INT, category VARCHAR(20), revenue DECIMAL(5,2), is_ethical BOOLEAN); INSERT INTO sales (sale_id, product_id, category, revenue, is_ethical) VALUES (1, 1, 'footwear', 150.00, true), (2, 2, 'footwear', 120.00, false), (3, 3, 'footwear', 175.00, true); | What is the total revenue generated from ethical labor practices in the 'footwear' category? | SELECT SUM(revenue) FROM sales WHERE category = 'footwear' AND is_ethical = true; | gretelai_synthetic_text_to_sql |
CREATE TABLE USLandfillData (landfill VARCHAR(50), capacity_m3 FLOAT); INSERT INTO USLandfillData (landfill, capacity_m3) VALUES ('Freedom Landfill', 18400000), ('Casella Landfill', 14000000), ('Puente Hills Landfill', 9800000), ('BFI Waste Systems Landfill', 12500000), ('WM Disposal Services Landfill', 11000000); | What is the maximum landfill capacity available in the United States? | SELECT MAX(capacity_m3) FROM USLandfillData; | gretelai_synthetic_text_to_sql |
CREATE TABLE SustainableFood (ItemID INT, FarmID INT, ItemName VARCHAR(50), IsSustainable BOOLEAN); INSERT INTO SustainableFood (ItemID, FarmID, ItemName, IsSustainable) VALUES (1, 1, 'Carrots', TRUE), (2, 2, 'Potatoes', FALSE), (3, 3, 'Cabbages', TRUE); | Sustainable food items that failed inspection | SELECT f.ItemName FROM SustainableFood f INNER JOIN InspectionResult i ON f.FarmID = i.FarmID WHERE f.IsSustainable = TRUE AND i.Result = 'Fail'; | gretelai_synthetic_text_to_sql |
CREATE TABLE AsianArtMuseum(id INT, type VARCHAR(20), artist VARCHAR(30)); INSERT INTO AsianArtMuseum(id, type, artist) VALUES (1, 'Painting', 'Hokusai'), (2, 'Sculpture', 'Hokusai'), (3, 'Calligraphy', 'Xu Bing'), (4, 'Print', 'Xu Bing'); | Find artists who have created more than one type of artwork in the Asian Art Museum. | SELECT artist FROM (SELECT artist, COUNT(DISTINCT type) as type_count FROM AsianArtMuseum GROUP BY artist) AS subquery WHERE type_count > 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE customer_data_canada (customer_id INT, data_usage FLOAT, province VARCHAR(50)); INSERT INTO customer_data_canada (customer_id, data_usage, province) VALUES (1, 3.5, 'Ontario'); INSERT INTO customer_data_canada (customer_id, data_usage, province) VALUES (2, 4.2, 'Ontario'); INSERT INTO customer_data_canada (customer_id, data_usage, province) VALUES (3, 2.8, 'Ontario'); INSERT INTO customer_data_canada (customer_id, data_usage, province) VALUES (4, 3.9, 'Quebec'); | What is the average data usage for customers in 'Ontario'? | SELECT AVG(data_usage) FROM customer_data_canada WHERE province = 'Ontario'; | gretelai_synthetic_text_to_sql |
CREATE TABLE operator_stats (operator_id INT, operator_name TEXT, eco_certified BOOLEAN, continent TEXT, year INT, visitors INT); INSERT INTO operator_stats (operator_id, operator_name, eco_certified, continent, year, visitors) VALUES (1, 'Operator A', TRUE, 'Europe', 2021, 1000), (2, 'Operator B', FALSE, 'Europe', 2021, 1200), (3, 'Operator C', TRUE, 'Europe', 2021, 1500), (4, 'Operator D', FALSE, 'Europe', 2021, 2000), (5, 'Operator E', TRUE, 'Europe', 2021, 800); | Identify the top 3 eco-certified tour operators with the most international visitors in Europe in 2021. | SELECT operator_name, ROW_NUMBER() OVER (PARTITION BY eco_certified ORDER BY visitors DESC) as ranking FROM operator_stats WHERE continent = 'Europe' AND year = 2021 AND eco_certified = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE if not exists event_attendees (id INT, name VARCHAR(50), age INT, program VARCHAR(50)); INSERT INTO event_attendees (id, name, age, program) VALUES (1, 'John Doe', 35, 'Artistic Explorers'), (2, 'Jane Smith', 42, 'Artistic Explorers'), (3, 'Mike Johnson', 28, 'Dance Education'); | Find the average age of attendees for 'Artistic Explorers' and 'Dance Education' programs combined. | SELECT AVG(age) FROM (SELECT age FROM event_attendees WHERE program = 'Artistic Explorers' UNION ALL SELECT age FROM event_attendees WHERE program = 'Dance Education') as attendees; | 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, 'Country'); INSERT INTO artists VALUES (2, 'Artist B', 28, 'Country'); INSERT INTO artists VALUES (3, 'Artist C', 45, 'Pop'); | What is the minimum age of all country artists in the database? | SELECT MIN(artist_age) FROM artists WHERE genre = 'Country'; | gretelai_synthetic_text_to_sql |
CREATE TABLE professors (id INT, name VARCHAR(50)); INSERT INTO professors (id, name) VALUES (1, 'John Smith'), (2, 'Jane Doe'); CREATE TABLE grants (id INT, professor_id INT, year INT, amount FLOAT); INSERT INTO grants (id, professor_id, year, amount) VALUES (1, 1, 2021, 5000.0), (2, 2, 2020, 7000.0); | What are the names of all professors who have received grants in the past year? | SELECT professors.name FROM professors INNER JOIN grants ON professors.id = grants.professor_id WHERE grants.year = YEAR(CURRENT_DATE()) - 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE Programs (city VARCHAR(50), program VARCHAR(50), attendees INT); INSERT INTO Programs (city, program, attendees) VALUES ('Chicago', 'Art', 120), ('Chicago', 'Music', 15), ('Chicago', 'Dance', 180), ('Chicago', 'Art', 5), ('Chicago', 'Music', 150), ('Chicago', 'Dance', 20); | Which programs had the most attendees for each type of program, excluding any programs with less than 10 attendees, in the city of Chicago? | SELECT program, MAX(attendees) FROM Programs WHERE attendees >= 10 AND city = 'Chicago' GROUP BY program; | gretelai_synthetic_text_to_sql |
CREATE TABLE Warehouse (id INT, region VARCHAR(20), order_priority VARCHAR(20), pallets INT); INSERT INTO Warehouse (id, region, order_priority, pallets) VALUES (1, 'East', 'High', 20), (2, 'East', 'Medium', 15); | How many pallets were moved in the East region for high-priority orders? | SELECT SUM(pallets) FROM Warehouse WHERE region = 'East' AND order_priority = 'High'; | gretelai_synthetic_text_to_sql |
CREATE TABLE athletes (id INT, name VARCHAR(50), age INT, sport VARCHAR(50)); INSERT INTO athletes (id, name, age, sport) VALUES (1, 'John Doe', 30, 'Basketball'), (2, 'Jane Smith', 28, 'Soccer'); CREATE TABLE teams (id INT, name VARCHAR(50), sport VARCHAR(50)); INSERT INTO teams (id, name, sport) VALUES (1, 'Warriors', 'Basketball'), (2, 'Real Madrid', 'Soccer'); | Delete all records related to the given sport | DELETE FROM athletes, teams WHERE athletes.sport = teams.sport AND sport = 'Basketball'; | gretelai_synthetic_text_to_sql |
CREATE TABLE DonationCauses (DonationCauseID int, DonationCause varchar(50), DonationAmount decimal(10,2)); INSERT INTO DonationCauses (DonationCauseID, DonationCause, DonationAmount) VALUES (1, 'Education', 5000.00), (2, 'Healthcare', 7000.00), (3, 'Environment', 3000.00), (4, 'Education', 2500.00), (5, 'Healthcare', 1000.00), (6, 'Poverty Alleviation', 6000.00), (7, 'Education', 4000.00), (8, 'Healthcare', 8000.00), (9, 'Environment', 1500.00); | Show the top 5 most common causes donated to, along with their respective total donation amounts. | SELECT DonationCause, SUM(DonationAmount) as TotalDonation, RANK() OVER (ORDER BY SUM(DonationAmount) DESC) as DonationRank FROM DonationCauses GROUP BY DonationCause ORDER BY DonationRank ASC; | gretelai_synthetic_text_to_sql |
CREATE TABLE production (year INT, element TEXT, quantity INT); INSERT INTO production (year, element, quantity) VALUES (2015, 'Dysprosium', 100), (2016, 'Dysprosium', 150), (2017, 'Dysprosium', 200), (2018, 'Dysprosium', 250), (2019, 'Dysprosium', 300), (2020, 'Dysprosium', 350), (2015, 'Neodymium', 500), (2016, 'Neodymium', 600), (2017, 'Neodymium', 700), (2018, 'Neodymium', 800), (2019, 'Neodymium', 900), (2020, 'Neodymium', 1000); | What was the total REE production in 2016? | SELECT SUM(quantity) FROM production WHERE year = 2016 AND element IN ('Dysprosium', 'Neodymium'); | gretelai_synthetic_text_to_sql |
CREATE TABLE Mining_Operations (id INT, operation_name VARCHAR(50), location VARCHAR(50), cost FLOAT, year INT); INSERT INTO Mining_Operations (id, operation_name, location, cost, year) VALUES (1, 'Operation A', 'USA', 100000.00, 2020), (2, 'Operation B', 'Canada', 120000.00, 2019), (3, 'Operation C', 'Mexico', 90000.00, 2020), (4, 'Operation D', 'USA', 80000.00, 2019); | What is the total amount spent on mining operations in the years 2019 and 2020? | SELECT SUM(cost) FROM Mining_Operations WHERE year IN (2019, 2020); | gretelai_synthetic_text_to_sql |
CREATE TABLE Regions (RegionID INT, Region VARCHAR(20)); INSERT INTO Regions (RegionID, Region) VALUES (1, 'Northeast'), (2, 'Southeast'), (3, 'Midwest'), (4, 'Southwest'), (5, 'West'); CREATE TABLE Cases (CaseID INT, RegionID INT, BillingAmount DECIMAL(10,2)); INSERT INTO Cases (CaseID, RegionID, BillingAmount) VALUES (1, 1, 5000.00), (2, 2, 4000.00), (3, 3, 6000.00), (4, 1, 5500.00), (5, 2, 4500.00); | What is the maximum billing amount for cases in the region with the highest average billing amount? | SELECT MAX(BillingAmount) FROM Cases INNER JOIN (SELECT RegionID, AVG(BillingAmount) AS AvgBillingAmount FROM Cases GROUP BY RegionID ORDER BY AvgBillingAmount DESC LIMIT 1) AS Subquery ON Cases.RegionID = Subquery.RegionID; | gretelai_synthetic_text_to_sql |
CREATE TABLE EthicalBrands (id INT, brand VARCHAR, waste_kg INT); CREATE TABLE BrandWasteData (brand VARCHAR, year INT, waste_kg INT); | What is the total waste generated by each ethical fashion brand in the past year? | SELECT e.brand, SUM(bw.waste_kg) as total_waste FROM EthicalBrands e JOIN BrandWasteData bw ON e.brand = bw.brand WHERE bw.year = YEAR(CURRENT_DATE()) - 1 GROUP BY e.brand; | gretelai_synthetic_text_to_sql |
CREATE TABLE hobbies (id INT, hobby VARCHAR(50), visitors INT); INSERT INTO hobbies (id, hobby, visitors) VALUES (1, 'Art', 1200), (2, 'Music', 800), (3, 'Science', 1000); | Get the top 3 most popular hobbies among visitors. | SELECT hobby, visitors FROM hobbies ORDER BY visitors DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE MiningSites (site_id INT, site_name VARCHAR(50), location VARCHAR(50), water_consumed DECIMAL(10, 2)); INSERT INTO MiningSites (site_id, site_name, location, water_consumed) VALUES (1, 'Site A', 'California', 1000), (2, 'Site B', 'Nevada', 1500); | What is the total amount of water consumed by each mining site? | SELECT site_name, water_consumed FROM MiningSites; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA if not exists sigint_max_budget AUTHORIZATION defsec;CREATE TABLE if not exists sigint_max_budget.info (id INT, name VARCHAR(100), budget INT);INSERT INTO sigint_max_budget.info (id, name, budget) VALUES (1, 'NSA', 15000000000);INSERT INTO sigint_max_budget.info (id, name, budget) VALUES (2, 'GCHQ', 8000000000);INSERT INTO sigint_max_budget.info (id, name, budget) VALUES (3, 'DGSE', 5000000000); | What is the maximum budget of a SIGINT agency? | SELECT MAX(budget) as max_budget FROM sigint_max_budget.info WHERE name LIKE '%SIGINT%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE posts (id INT, user_id INT, content TEXT, shares INT, hashtags TEXT); | Find the maximum number of shares for posts with the hashtag #sustainability in the "green_network" schema. | SELECT MAX(shares) FROM posts WHERE hashtags LIKE '%#sustainability%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE carbon_prices (id INT PRIMARY KEY, year INT, price FLOAT); | Delete all records in the 'carbon_prices' table that are older than 2020 | DELETE FROM carbon_prices WHERE year < 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE Field4_Rainfall (station_id INT, measurement_time TIMESTAMP, rainfall DECIMAL(4,1)); INSERT INTO Field4_Rainfall (station_id, measurement_time, rainfall) VALUES (5, '2022-06-15 12:30:00', 25.6), (5, '2022-06-30 18:45:00', 30.1); | What is the total amount of rainfall recorded in millimeters for 'Field4' by the automatic weather station in the month of June in 2022? | SELECT SUM(rainfall) FROM Field4_Rainfall WHERE EXTRACT(MONTH FROM measurement_time) = 6 AND EXTRACT(YEAR FROM measurement_time) = 2022 AND station_id = 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE veteran_employment (id INT PRIMARY KEY, name VARCHAR(255), position VARCHAR(255), years_of_service INT, salary NUMERIC(10, 2)); | Drop the salary column from the veteran_employment table | ALTER TABLE veteran_employment DROP COLUMN salary; | gretelai_synthetic_text_to_sql |
CREATE TABLE public_transportation_users (user_id INT, start_date DATE, city VARCHAR(255)); | How many users have used public transportation in Sydney for more than 30 days? | SELECT COUNT(DISTINCT user_id) FROM public_transportation_users WHERE city = 'Sydney' GROUP BY user_id HAVING DATEDIFF('2022-06-30', start_date) >= 30; | gretelai_synthetic_text_to_sql |
CREATE TABLE SafetyTesting (Id INT, Name VARCHAR(50), Year INT, SafetyRating INT); INSERT INTO SafetyTesting (Id, Name, Year, SafetyRating) VALUES (1, 'Corvette', 2018, 5), (2, '911 Turbo', 2017, 5), (3, 'M4 GTS', 2016, 4); | What is the average safety rating for vehicles released in 2018? | SELECT AVG(SafetyRating) FROM SafetyTesting WHERE Year = 2018; | gretelai_synthetic_text_to_sql |
CREATE TABLE Employees (EmployeeID int, Department varchar(50), Salary decimal(10,2)); INSERT INTO Employees (EmployeeID, Department, Salary) VALUES (1, 'Engineering', 80000.00), (2, 'Marketing', 70000.00), (3, 'Sales', 75000.00); | What is the total salary expense for each department, and what is the average salary for each department? | SELECT e.Department, SUM(e.Salary) as SalaryExpense, AVG(e.Salary) as AverageSalary FROM Employees e GROUP BY e.Department; | gretelai_synthetic_text_to_sql |
CREATE TABLE RegionLandfillData (RegionID INT, Region VARCHAR(255), LandfillID INT, Capacity DECIMAL(10,2)); INSERT INTO RegionLandfillData (RegionID, Region, LandfillID, Capacity) VALUES (1, 'North', 1, 120000), (2, 'South', 2, 80000), (3, 'North', 3, 150000); | What is the maximum landfill capacity (in cubic meters) for each region and the corresponding region name? | SELECT Region, MAX(Capacity) AS MaxCapacity FROM RegionLandfillData GROUP BY Region; | gretelai_synthetic_text_to_sql |
CREATE TABLE coal_plants (country VARCHAR(50), operational BOOLEAN, year INT); INSERT INTO coal_plants (country, operational, year) VALUES ('Australia', true, 2019), ('United States', true, 2019), ('China', true, 2019), ('India', true, 2019); | How many coal power plants were operational in Australia as of 2019? | SELECT COUNT(*) FROM coal_plants WHERE country = 'Australia' AND operational = true AND year = 2019; | gretelai_synthetic_text_to_sql |
CREATE TABLE LaborAdvocacy (id INT, org_name VARCHAR, location VARCHAR, budget FLOAT); CREATE TABLE AdvocacyEvents (id INT, labor_advocacy_id INT, event_name VARCHAR, date DATE, attendees INT); | What is the maximum number of attendees at labor advocacy events in Ohio? | SELECT MAX(ae.attendees) as max_attendees FROM AdvocacyEvents ae JOIN LaborAdvocacy la ON ae.labor_advocacy_id = la.id WHERE la.location = 'Ohio'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Donations (id INT, region VARCHAR(20), amount FLOAT); INSERT INTO Donations (id, region, amount) VALUES (1, 'Northeast', 25000.00), (2, 'Southeast', 30000.00), (3, 'Midwest', 20000.00), (4, 'Southwest', 15000.00), (5, 'Northwest', 35000.00); | What is the total donation amount? | SELECT SUM(amount) as total_donations FROM Donations; | gretelai_synthetic_text_to_sql |
CREATE TABLE Operations (OperationID INT, MineID INT, Year INT, EnvironmentalImpactScore FLOAT); INSERT INTO Operations (OperationID, MineID, Year, EnvironmentalImpactScore) VALUES (1, 1, 2019, 50); INSERT INTO Operations (OperationID, MineID, Year, EnvironmentalImpactScore) VALUES (2, 1, 2018, 55); INSERT INTO Operations (OperationID, MineID, Year, EnvironmentalImpactScore) VALUES (3, 2, 2019, 60); INSERT INTO Operations (OperationID, MineID, Year, EnvironmentalImpactScore) VALUES (4, 2, 2018, 65); | What is the maximum environmental impact score for mining operations in the Russian Federation? | SELECT MAX(o.EnvironmentalImpactScore) as MaxImpactScore FROM Operations o INNER JOIN Mines m ON o.MineID = m.MineID WHERE m.Country = 'Russian Federation'; | gretelai_synthetic_text_to_sql |
CREATE TABLE TheaterPerformances (performanceID INT, performanceDate DATE); INSERT INTO TheaterPerformances (performanceID, performanceDate) VALUES (1, '2022-03-01'), (2, '2022-02-15'), (3, '2021-12-20'); | How many theater performances were held in each month of the last year? | SELECT YEAR(performanceDate) AS Year, MONTH(performanceDate) AS Month, COUNT(*) AS Count FROM TheaterPerformances WHERE performanceDate >= DATEADD(year, -1, GETDATE()) GROUP BY YEAR(performanceDate), MONTH(performanceDate); | gretelai_synthetic_text_to_sql |
CREATE TABLE ads (ad_id INT, company VARCHAR(50), ad_spend DECIMAL(10,2), ad_date DATE); INSERT INTO ads (ad_id, company, ad_spend, ad_date) VALUES (1, 'Company X', 500, '2022-07-01'), (2, 'Company Y', 800, '2022-08-01'), (3, 'Company X', 700, '2022-09-01'); | What is the total ad spend for company X in Q3 of 2022? | SELECT SUM(ad_spend) FROM ads WHERE company = 'Company X' AND QUARTER(ad_date) = 3 AND YEAR(ad_date) = 2022; | gretelai_synthetic_text_to_sql |
CREATE TABLE streams (id INT, artist VARCHAR(255), country VARCHAR(255), streams INT); INSERT INTO streams (id, artist, country, streams) VALUES (1, 'Artist1', 'Canada', 1000000), (2, 'Artist2', 'Germany', 800000), (3, 'Artist1', 'Canada', 1200000), (4, 'Artist3', 'Germany', 900000); | What is the total number of streams for each artist in Canada and Germany? | SELECT artist, SUM(streams) AS total_streams FROM streams WHERE country IN ('Canada', 'Germany') GROUP BY artist; | gretelai_synthetic_text_to_sql |
CREATE TABLE faculty (id INT, name VARCHAR(50), department VARCHAR(50), gender VARCHAR(50), grant_amount DECIMAL(10,2)); INSERT INTO faculty (id, name, department, gender, grant_amount) VALUES (1, 'Alice', 'Computer Science', 'Female', 15000.00), (2, 'Bob', 'Computer Science', 'Male', 20000.00), (3, 'Charlie', 'Computer Science', 'Female', 12000.00); | What is the average amount of research grants received by female faculty members in the Computer Science department? | SELECT AVG(grant_amount) FROM faculty WHERE department = 'Computer Science' AND gender = 'Female'; | gretelai_synthetic_text_to_sql |
CREATE TABLE infectious_diseases (id INT, case_number INT, report_date DATE); INSERT INTO infectious_diseases (id, case_number, report_date) VALUES (1, 123, '2022-01-01'); INSERT INTO infectious_diseases (id, case_number, report_date) VALUES (2, 456, '2022-01-10'); | How many infectious disease cases were reported in New York City in the past month? | SELECT COUNT(*) FROM infectious_diseases WHERE report_date >= DATEADD(day, -30, CURRENT_DATE) AND city = 'New York'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Sales (event TEXT, item TEXT, price NUMERIC); INSERT INTO Sales (event, item, price) VALUES ('Art Auction', 'Painting', 10000); INSERT INTO Sales (event, item, price) VALUES ('Art Auction', 'Sculpture', 8000); INSERT INTO Sales (event, item, price) VALUES ('Art Auction', 'Photograph', 2000); CREATE TABLE Inventory (item TEXT, category TEXT); INSERT INTO Inventory (item, category) VALUES ('Painting', 'Art'); INSERT INTO Inventory (item, category) VALUES ('Sculpture', 'Art'); INSERT INTO Inventory (item, category) VALUES ('Photograph', 'Art'); | What is the total revenue for the 'Art Auction' event? | SELECT SUM(price) FROM Sales WHERE event = 'Art Auction'; | gretelai_synthetic_text_to_sql |
CREATE TABLE countries (id INT, name VARCHAR(255)); INSERT INTO countries (id, name) VALUES (1, 'US'); CREATE TABLE schools (id INT, country_id INT, name VARCHAR(255), num_students INT, num_teachers INT); INSERT INTO schools (id, country_id, name, num_students, num_teachers) VALUES (1, 1, 'School 1', 500, 30), (2, 1, 'School 2', 600, 40); | What is the total number of public schools in the US and what is the average student-teacher ratio in those schools? | SELECT COUNT(schools.id) AS total_schools, AVG(schools.num_students / schools.num_teachers) AS avg_student_teacher_ratio FROM schools WHERE schools.country_id = 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE psychology_accommodations (student_id INT, semester VARCHAR(10));CREATE TABLE social_work_accommodations (student_id INT, semester VARCHAR(10));CREATE TABLE counseling_accommodations (student_id INT, semester VARCHAR(10)); INSERT INTO psychology_accommodations VALUES (8, 'spring 2022'), (9, 'spring 2022'), (10, 'spring 2022'); INSERT INTO social_work_accommodations VALUES (9, 'fall 2022'), (10, 'fall 2022'), (11, 'fall 2022'); INSERT INTO counseling_accommodations VALUES (10, 'fall 2022'), (11, 'fall 2022'); | Find the number of students who received accommodations in the psychology department during the spring 2022 semester, but did not receive any accommodations in any department during the fall 2022 semester. | SELECT COUNT(*) FROM (SELECT student_id FROM psychology_accommodations WHERE semester = 'spring 2022' EXCEPT SELECT student_id FROM social_work_accommodations WHERE semester = 'fall 2022' EXCEPT SELECT student_id FROM counseling_accommodations WHERE semester = 'fall 2022') AS subquery; | gretelai_synthetic_text_to_sql |
CREATE TABLE building_stats (building_id INT, building_type VARCHAR(50), energy_efficiency_rating FLOAT); INSERT INTO building_stats (building_id, building_type, energy_efficiency_rating) VALUES (1, 'Residential', 80.5), (2, 'Commercial', 65.3), (3, 'Industrial', 72.9); | What is the average energy efficiency rating for residential buildings in the 'building_stats' table? | SELECT AVG(energy_efficiency_rating) FROM building_stats WHERE building_type = 'Residential'; | gretelai_synthetic_text_to_sql |
CREATE TABLE company_profiles (company_name VARCHAR(255), founding_year INT, diversity_metric FLOAT); | Update the diversity metric for "Acme Corp" to 0.7 in the "company_profiles" table | UPDATE company_profiles SET diversity_metric = 0.7 WHERE company_name = 'Acme Corp'; | gretelai_synthetic_text_to_sql |
CREATE TABLE tennis_players (player_id INT, player_name VARCHAR(50), surface VARCHAR(10), matches_played INT, matches_won INT); INSERT INTO tennis_players (player_id, player_name, surface, matches_played, matches_won) VALUES (1, 'Novak Djokovic', 'Hard', 120, 90), (2, 'Roger Federer', 'Grass', 100, 80); | What is the average number of matches won by tennis players in the Grand Slam tournaments, by surface? | SELECT surface, AVG(matches_won) FROM tennis_players GROUP BY surface; | gretelai_synthetic_text_to_sql |
CREATE TABLE decentralized_exchanges (exchange_name TEXT, country TEXT, daily_transaction_value INTEGER); INSERT INTO decentralized_exchanges (exchange_name, country, daily_transaction_value) VALUES ('Uniswap', 'Germany', 5000000), ('Sushiswap', 'Germany', 3000000); | What is the average daily transaction value for decentralized exchanges in Germany? | SELECT AVG(daily_transaction_value) FROM decentralized_exchanges WHERE country = 'Germany'; | gretelai_synthetic_text_to_sql |
CREATE TABLE city_energy_consumption (city_name TEXT, year INTEGER, energy_consumption FLOAT); INSERT INTO city_energy_consumption VALUES ('CityA', 2020, 500.0), ('CityA', 2021, 550.0), ('CityB', 2020, 700.0), ('CityB', 2021, 730.0); | What is the change in energy consumption for each smart city compared to the previous year? | SELECT a.city_name, a.year, a.energy_consumption, b.energy_consumption, a.energy_consumption - b.energy_consumption AS difference FROM city_energy_consumption a INNER JOIN city_energy_consumption b ON a.city_name = b.city_name AND a.year - 1 = b.year; | gretelai_synthetic_text_to_sql |
CREATE TABLE spacecraft (id INT, name VARCHAR(255), launch_date DATE); INSERT INTO spacecraft (id, name, launch_date) VALUES (1, 'Voyager 1', '1977-09-05'), (2, 'Voyager 2', '1977-08-20'), (3, 'Spirit', '2004-01-04'); | Which spacecraft were launched before '2000-01-01'? | SELECT name FROM spacecraft WHERE launch_date < '2000-01-01' ORDER BY launch_date; | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_protected_areas (name VARCHAR(255), location VARCHAR(255)); INSERT INTO marine_protected_areas (name, location) VALUES ('Protected Area A', 'Indian Ocean'), ('Protected Area B', 'Atlantic Ocean'); | List all marine protected areas in the Indian Ocean. | SELECT name FROM marine_protected_areas WHERE location = 'Indian Ocean'; | gretelai_synthetic_text_to_sql |
CREATE TABLE events (id INT, name VARCHAR(255), city VARCHAR(255), is_virtual BOOLEAN); INSERT INTO events (id, name, city, is_virtual) VALUES (1, 'Virtual Cultural Heritage', 'Amsterdam', TRUE), (2, 'Sustainable Architecture Tour', 'Barcelona', FALSE); | How many virtual events are there in total in Amsterdam and Barcelona? | SELECT COUNT(*) FROM events WHERE city IN ('Amsterdam', 'Barcelona') AND is_virtual = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE Donations (DonorID INT, DonationDate DATE); INSERT INTO Donations (DonorID, DonationDate) VALUES (1, '2022-01-01'), (2, '2022-02-15'), (1, '2022-04-05'), (3, '2022-07-10'), (4, '2022-10-25'); | How many donors made donations in each quarter of 2022? | SELECT DATE_FORMAT(DonationDate, '%Y-%m') as Quarter, COUNT(DISTINCT DonorID) as DonorCount FROM Donations WHERE YEAR(DonationDate) = 2022 GROUP BY Quarter; | gretelai_synthetic_text_to_sql |
CREATE TABLE waste_types (type TEXT, id INTEGER); INSERT INTO waste_types (type, id) VALUES ('Plastic', 1), ('Paper', 2), ('Glass', 3), ('Metal', 4); CREATE TABLE circular_economy_initiatives (waste_type_id INTEGER); INSERT INTO circular_economy_initiatives (waste_type_id) VALUES (1), (2), (3); | Which waste types are not included in the circular economy initiatives? | SELECT wt.type FROM waste_types wt LEFT JOIN circular_economy_initiatives cei ON wt.id = cei.waste_type_id WHERE cei.waste_type_id IS NULL; | gretelai_synthetic_text_to_sql |
CREATE TABLE suppliers (supplier_id INT, supplier_name VARCHAR(50));CREATE TABLE sales (sale_id INT, product_id INT, sale_quantity INT, sale_price DECIMAL(10,2), supplier_id INT); | List all suppliers and the total revenue generated from each | SELECT s.supplier_id, s.supplier_name, SUM(sales.sale_quantity * sales.sale_price) as total_revenue FROM sales JOIN suppliers ON sales.supplier_id = suppliers.supplier_id GROUP BY s.supplier_id, s.supplier_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE permit (id INT, state VARCHAR(20), type VARCHAR(20), permit_number INT); INSERT INTO permit (id, state, type, permit_number) VALUES (1, 'Washington', 'Commercial', 100), (2, 'Washington', 'Residential', 150), (3, 'California', 'Commercial', 80); | List all building permits issued for commercial buildings in the state of Washington. | SELECT permit_number FROM permit WHERE state = 'Washington' AND type = 'Commercial'; | gretelai_synthetic_text_to_sql |
CREATE TABLE programs (program_id INT, program_type VARCHAR(20), introduction_date DATE); INSERT INTO programs (program_id, program_type, introduction_date) VALUES (1, 'Restorative Justice', '2020-01-01'); INSERT INTO programs (program_id, program_type, introduction_date) VALUES (2, 'Traditional', '2019-01-01'); | List all restorative justice programs introduced in New Zealand in 2020. | SELECT program_id, program_type FROM programs WHERE program_type = 'Restorative Justice' AND introduction_date BETWEEN '2020-01-01' AND '2020-12-31'; | gretelai_synthetic_text_to_sql |
CREATE TABLE renewable_energy_sources (id INT, country VARCHAR(255), source VARCHAR(255), installed_capacity INT); INSERT INTO renewable_energy_sources (id, country, source, installed_capacity) VALUES (1, 'Egypt', 'Wind', 250), (2, 'South Africa', 'Solar', 300), (3, 'Morocco', 'Wind', 150); | What is the total installed capacity of wind energy in Africa? | SELECT SUM(installed_capacity) FROM renewable_energy_sources WHERE country IN ('Egypt', 'South Africa', 'Morocco') AND source = 'Wind'; | gretelai_synthetic_text_to_sql |
CREATE TABLE ExcavationSites (SiteID int, Name varchar(50), Country varchar(50), StartDate date); | Update the name of an excavation site | UPDATE ExcavationSites SET Name = 'Site G' WHERE SiteID = 6; | gretelai_synthetic_text_to_sql |
CREATE TABLE articles (id INT, title VARCHAR(50), category VARCHAR(20), author_id INT, publish_date DATE, word_count INT); INSERT INTO articles (id, title, category, author_id, publish_date, word_count) VALUES (1, 'Oil Prices Rising', 'politics', 1, '2021-04-15', 1200), (2, 'Government Corruption', 'politics', 2, '2021-03-10', 1500), (3, 'Baseball Game', 'sports', 3, '2021-02-01', 800), (4, 'Football Match', 'sports', 1, '2021-01-01', 1000); | What is the average word count for articles about politics and sports in the last 3 months? | SELECT AVG(word_count) FROM articles WHERE category IN ('politics', 'sports') AND publish_date >= DATE_SUB(CURRENT_DATE, INTERVAL 3 MONTH); | gretelai_synthetic_text_to_sql |
CREATE TABLE hindu (author_id INT, author_name VARCHAR(50), article_date DATE); INSERT INTO hindu (author_id, author_name, article_date) VALUES (1, 'Rajesh Patel', '2021-05-01'), (2, 'Priya Gupta', '2021-05-02'); CREATE TABLE ndtv (author_id INT, author_name VARCHAR(50), article_date DATE); INSERT INTO ndtv (author_id, author_name, article_date) VALUES (3, 'Meera Kapoor', '2021-05-01'), (4, 'Rajesh Patel', '2021-05-03'); | Identify unique authors who have written for 'The Hindu' and 'NDTV' in May 2021. | SELECT author_name FROM hindu WHERE article_date BETWEEN '2021-05-01' AND '2021-05-31' INTERSECT SELECT author_name FROM ndtv WHERE article_date BETWEEN '2021-05-01' AND '2021-05-31'; | gretelai_synthetic_text_to_sql |
CREATE TABLE authors (id INT, name VARCHAR(255), country VARCHAR(255)); INSERT INTO authors (id, name, country) VALUES (1, 'Alice', 'USA'), (2, 'Bob', 'Canada'); CREATE TABLE papers (id INT, title VARCHAR(255), published_date DATE, author_id INT); INSERT INTO papers (id, title, published_date, author_id) VALUES (1, 'Paper1', '2021-06-01', 1), (2, 'Paper2', '2020-12-25', 2); CREATE TABLE topics (id INT, paper_id INT, title VARCHAR(255)); INSERT INTO topics (id, paper_id, title) VALUES (1, 1, 'Algorithmic Fairness'), (2, 2, 'AI Safety'); | How many papers on algorithmic fairness were published in the past year by authors from each country, in the AI Research database? | SELECT authors.country, COUNT(*) FROM papers JOIN authors ON papers.author_id = authors.id JOIN topics ON papers.id = topics.paper_id WHERE topics.title = 'Algorithmic Fairness' AND YEAR(papers.published_date) = YEAR(CURRENT_DATE()) GROUP BY authors.country; | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_species (species_name TEXT, region TEXT); INSERT INTO marine_species (species_name, region) VALUES ('Narwhal', 'Arctic'), ('Beluga Whale', 'Arctic'), ('Walrus', 'Arctic'); | Find the total number of marine species in the Arctic region. | SELECT COUNT(*) FROM marine_species WHERE region = 'Arctic'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Policies (PolicyID INT, IssueDate DATE, State VARCHAR(20)); INSERT INTO Policies (PolicyID, IssueDate, State) VALUES (1, '2021-01-01', 'California'), (2, '2021-02-15', 'Texas'), (3, '2020-12-30', 'New York'); | How many policies were issued in each state last year? | SELECT State, COUNT(PolicyID) FROM Policies WHERE YEAR(IssueDate) = YEAR(CURRENT_DATE()) - 1 GROUP BY State; | gretelai_synthetic_text_to_sql |
CREATE TABLE traffic_violations (violation_id INT, violation_date DATE, violation_type VARCHAR(255)); INSERT INTO traffic_violations (violation_id, violation_date, violation_type) VALUES (1, '2022-01-01', 'Speeding'), (2, '2023-02-03', 'Running Red Light'); | How many traffic violations were recorded in 2022 and 2023? | SELECT SUM(violation_id) FROM traffic_violations WHERE violation_date BETWEEN '2022-01-01' AND '2023-12-31'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Countries (ID INT PRIMARY KEY, Name TEXT); CREATE TABLE Research_Facilities (ID INT PRIMARY KEY, Country_ID INT, Name TEXT, Type TEXT); | Which countries have no space research facilities? | SELECT c.Name FROM Countries c LEFT JOIN Research_Facilities rf ON c.ID = rf.Country_ID WHERE rf.ID IS NULL; | gretelai_synthetic_text_to_sql |
CREATE TABLE sales (id INT, item_id INT, country TEXT, quantity INT); INSERT INTO sales (id, item_id, country, quantity) VALUES (1, 1, 'Germany', 100), (2, 2, 'France', 50); CREATE TABLE products (id INT, name TEXT, material TEXT, vegan BOOLEAN); INSERT INTO products (id, name, material, vegan) VALUES (1, 'Dress', 'Organic Cotton', 1), (2, 'Skirt', 'Polyester', 0); | What is the total quantity of items sold in the EU that are made of sustainable materials? | SELECT SUM(quantity) FROM sales JOIN products ON sales.item_id = products.id WHERE (products.material IN ('Organic Cotton', 'Linen', 'Recycled Polyester') OR products.vegan = 1) AND country LIKE 'EU%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE mobile_subscribers (subscriber_id INT, technology VARCHAR(20), region VARCHAR(50), complete_data BOOLEAN); INSERT INTO mobile_subscribers (subscriber_id, technology, region, complete_data) VALUES (1, '4G', 'North', true), (2, '5G', 'North', false), (3, '3G', 'South', true), (4, '5G', 'East', true), (5, '5G', 'North', true), (6, '3G', 'South', true), (7, '4G', 'West', true); | Identify the number of mobile subscribers using 4G technology in each region, excluding subscribers with incomplete data. | SELECT technology, region, COUNT(*) AS subscribers FROM mobile_subscribers WHERE complete_data = true AND technology = '4G' GROUP BY technology, region; | gretelai_synthetic_text_to_sql |
CREATE TABLE Volunteers (VolunteerID INT, SignUpDate DATE); | What is the total number of volunteers in the 'Volunteers' table who signed up before and after June 2022? | SELECT SUM(CASE WHEN SignUpDate < '2022-06-01' THEN 1 ELSE 0 END) AS BeforeJune, SUM(CASE WHEN SignUpDate >= '2022-06-01' THEN 1 ELSE 0 END) AS AfterJune FROM Volunteers; | gretelai_synthetic_text_to_sql |
CREATE TABLE emergency_calls (id INT, state VARCHAR(20), response_time INT); | What is the maximum response time for emergency calls in the state of New York? | SELECT MAX(response_time) FROM emergency_calls WHERE state = 'New York'; | gretelai_synthetic_text_to_sql |
CREATE TABLE japan_renewable_energy_projects (id INT, country VARCHAR(20), completion_year INT); INSERT INTO japan_renewable_energy_projects (id, country, completion_year) VALUES (1, 'Japan', 2018), (2, 'Japan', 2021); | Identify the number of renewable energy projects in Japan with a completion year greater than 2019. | SELECT COUNT(*) FROM japan_renewable_energy_projects WHERE country = 'Japan' AND completion_year > 2019; | gretelai_synthetic_text_to_sql |
CREATE TABLE AIModels (id INT, model_name VARCHAR(50), organization VARCHAR(50), application_type VARCHAR(50), safety_rating INT); INSERT INTO AIModels (id, model_name, organization, application_type, safety_rating) VALUES (1, 'AI4Welfare', 'Microsoft', 'Social Welfare', 85), (2, 'AI4Empowerment', 'Google', 'Social Welfare', 90), (3, 'AI4Assistance', 'IBM', 'Social Welfare', 88), (4, 'AI4Support', 'Alibaba', 'Social Welfare', 92), (5, 'AI4Access', 'Tencent', 'Social Welfare', 80), (6, 'AI4Education', 'Baidu', 'Education', 95); | What is the total number of AI models developed by organizations based in the Asia-Pacific region, and what is the maximum safety rating among these models? | SELECT organization, COUNT(model_name) as model_count FROM AIModels WHERE organization IN (SELECT DISTINCT organization FROM AIModels WHERE country IN (SELECT country FROM AIContinents WHERE continent = 'Asia-Pacific')) GROUP BY organization ORDER BY model_count DESC LIMIT 1; SELECT MAX(safety_rating) as max_safety_rating FROM AIModels WHERE organization IN (SELECT DISTINCT organization FROM AIModels WHERE country IN (SELECT country FROM AIContinents WHERE continent = 'Asia-Pacific')); | gretelai_synthetic_text_to_sql |
CREATE TABLE digital_assets (asset_id INT, asset_name VARCHAR(50), region VARCHAR(50)); INSERT INTO digital_assets (asset_id, asset_name, region) VALUES (1, 'Bitcoin', 'North America'), (2, 'Ethereum', 'North America'); | What is the total number of digital assets issued in the North American region? | SELECT COUNT(*) FROM digital_assets WHERE region = 'North America'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Cosmetics (product_id INT, name VARCHAR(50), price DECIMAL(5,2), has_matte_finish BOOLEAN, type VARCHAR(50)); | What is the total price of eyeshadows with matte finish? | SELECT SUM(price) FROM Cosmetics WHERE type = 'Eyeshadow' AND has_matte_finish = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE donations (id INT, donation_amount DECIMAL, country TEXT); INSERT INTO donations (id, donation_amount, country) VALUES (1, 150.00, 'Germany'), (2, 250.00, 'Germany'), (3, 300.00, 'Canada'), (4, 50.00, 'India'), (5, 100.00, 'India'); | What's the minimum donation amount for donors from India? | SELECT MIN(donation_amount) FROM donations WHERE country = 'India'; | gretelai_synthetic_text_to_sql |
CREATE TABLE shariah_compliant_loans (id INT, region VARCHAR(20), amount DECIMAL(10,2)); INSERT INTO shariah_compliant_loans (id, region, amount) VALUES (1, 'Middle East', 8000.00), (2, 'Africa', 9000.00), (3, 'South Asia', 7000.00); | What is the average Shariah-compliant loan amount in the Middle East, Africa, and South Asia? | SELECT AVG(amount) FROM shariah_compliant_loans WHERE region IN ('Middle East', 'Africa', 'South Asia'); | gretelai_synthetic_text_to_sql |
CREATE VIEW super_donors AS SELECT id, name, organization, SUM(amount) AS total_donation FROM donors GROUP BY id; | What is the maximum amount donated by a donor in the super_donors view? | SELECT MAX(total_donation) FROM super_donors; | 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.