context stringlengths 11 9.12k | question stringlengths 0 1.06k | SQL stringlengths 2 4.44k | source stringclasses 28
values |
|---|---|---|---|
CREATE TABLE game_sessions (user_id INT, game_name VARCHAR(10), login_date DATE); INSERT INTO game_sessions (user_id, game_name, login_date) VALUES (1, 'A', '2021-01-01'), (2, 'B', '2021-01-02'), (3, 'B', '2021-01-03'), (4, 'C', '2021-01-04'); | List all unique users who played game 'B' between January 1, 2021 and January 7, 2021 | SELECT DISTINCT user_id FROM game_sessions WHERE game_name = 'B' AND login_date BETWEEN '2021-01-01' AND '2021-01-07'; | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_life_sightings (sighting_id INTEGER, species TEXT, sighting_date DATE); INSERT INTO marine_life_sightings (sighting_id, species, sighting_date) VALUES (1, 'Blue Whale', '2022-01-01'), (2, 'Humpback Whale', '2022-01-02'), (3, 'Blue Whale', '2022-01-03'); | How many whale sightings were recorded in the 'marine_life_sightings' table for each type of whale? | SELECT species, COUNT(*) FROM marine_life_sightings WHERE species IN ('Blue Whale', 'Humpback Whale') GROUP BY species; | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_farms_biomass (farm_id INT, species VARCHAR(20), biomass FLOAT); INSERT INTO marine_farms_biomass (farm_id, species, biomass) VALUES (1, 'Tuna', 1200.5), (2, 'Swordfish', 800.3), (3, 'Shrimp', 1500.2); | Find the percentage of total biomass for each species in marine farms. | SELECT species, SUM(biomass) total_biomass, 100.0 * SUM(biomass) / (SELECT SUM(biomass) FROM marine_farms_biomass) percentage FROM marine_farms_biomass GROUP BY species; | gretelai_synthetic_text_to_sql |
CREATE TABLE concerts (concert_id INT PRIMARY KEY, artist_name VARCHAR(100), concert_date DATE, location VARCHAR(100), tickets_sold INT, genre VARCHAR(50)); INSERT INTO concerts (concert_id, artist_name, concert_date, location, tickets_sold, genre) VALUES (1, 'Eminem', '2023-06-15', 'New York City', 15000, 'Hip-Hop'); ... | Find total tickets sold for all hip-hop concerts | SELECT SUM(tickets_sold) FROM concerts WHERE genre = 'Hip-Hop'; | gretelai_synthetic_text_to_sql |
CREATE TABLE donors (id INT, name VARCHAR(50), continent VARCHAR(50), donation DECIMAL(10, 2)); | What is the maximum donation amount for donors from Africa? | SELECT MAX(donation) FROM donors WHERE continent = 'Africa'; | gretelai_synthetic_text_to_sql |
CREATE TABLE GovernmentEmployees (EmployeeID INT, Salary DECIMAL(10,2), State VARCHAR(100)); INSERT INTO GovernmentEmployees (EmployeeID, Salary, State) VALUES (1, 45000.00, 'Texas'), (2, 50000.00, 'Texas'), (3, 55000.00, 'Texas'), (4, 60000.00, 'Texas'), (5, 65000.00, 'Texas'); | What is the average salary of government employees in the state of Texas, and what is the mode salary? | SELECT AVG(Salary) as AverageSalary, MAX(Salary) as ModeSalary FROM GovernmentEmployees WHERE State = 'Texas' GROUP BY Salary HAVING COUNT(*) > 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE Stores (store_id INT, store_name VARCHAR(50), state VARCHAR(50)); INSERT INTO Stores (store_id, store_name, state) VALUES (1, 'Eco-Market', 'Utah'), (2, 'Green Vista', 'Arizona'); CREATE TABLE Inventory (inventory_id INT, product_id INT, product_name VARCHAR(50), store_id INT, last_sale_date DATE); INSERT ... | Delete records for products that have not been sold for the last 4 months in stores located in 'Utah' and 'Arizona' | DELETE FROM Inventory WHERE last_sale_date < DATE_SUB(CURRENT_DATE, INTERVAL 4 MONTH) AND store_id IN (SELECT store_id FROM Stores WHERE state IN ('Utah', 'Arizona')); | gretelai_synthetic_text_to_sql |
CREATE TABLE Readers (ReaderID INT, Age INT, Country VARCHAR(50), SubscriptionType VARCHAR(50)); INSERT INTO Readers (ReaderID, Age, Country, SubscriptionType) VALUES (1, 35, 'USA', 'Digital'), (2, 45, 'Canada', 'Print'), (3, 25, 'Mexico', 'Digital'); | What is the average age of readers who prefer digital subscriptions, grouped by their country of residence? | SELECT Country, AVG(Age) as AvgAge FROM Readers WHERE SubscriptionType = 'Digital' GROUP BY Country; | gretelai_synthetic_text_to_sql |
CREATE TABLE sales (sale_id INT, product_type VARCHAR(50), country VARCHAR(50), revenue DECIMAL(10,2)); INSERT INTO sales (sale_id, product_type, country, revenue) VALUES (1, 'sustainable', 'France', 500.00), (2, 'non-sustainable', 'Nigeria', 400.00), (3, 'sustainable', 'Germany', 600.00), (4, 'sustainable', 'Kenya', 5... | What is the total revenue generated from the sales of sustainable products in Europe and Africa for the last quarter? | SELECT SUM(sales.revenue) FROM sales WHERE sales.product_type = 'sustainable' AND sales.country IN ('Europe', 'Africa') AND sales.date BETWEEN '2022-01-01' AND '2022-03-31'; | gretelai_synthetic_text_to_sql |
CREATE TABLE drought_areas (id INT, area VARCHAR(50), event_date DATE, water_consumption FLOAT); INSERT INTO drought_areas (id, area, event_date, water_consumption) VALUES (1, 'Area1', '2020-01-01', 1200), (2, 'Area2', '2020-02-01', 1500), (3, 'Area3', '2020-03-01', 1800); | How many drought-affected areas were there in the year 2020 and what was the average water consumption in those areas? | SELECT area, AVG(water_consumption) as avg_water_consumption FROM drought_areas WHERE YEAR(event_date) = 2020 GROUP BY area; | gretelai_synthetic_text_to_sql |
CREATE TABLE clinical_trials (country TEXT, drug_class TEXT, trial_count INTEGER); | How many clinical trials were conducted in Asia for vaccines? | SELECT SUM(trial_count) FROM clinical_trials WHERE country = 'Asia' AND drug_class = 'vaccines'; | gretelai_synthetic_text_to_sql |
CREATE TABLE revenue_data (year INT, country VARCHAR(15), network VARCHAR(15), revenue FLOAT); INSERT INTO revenue_data (year, country, network, revenue) VALUES (2021, 'Japan', 'NTT Docomo', 15000000), (2021, 'Japan', 'Softbank', 12000000), (2021, 'Japan', 'KDDI', 13000000); | What is the total revenue generated by each mobile network in Japan for the year 2021? | SELECT network, SUM(revenue) as total_revenue FROM revenue_data WHERE country = 'Japan' AND year = 2021 GROUP BY network; | gretelai_synthetic_text_to_sql |
CREATE TABLE network_nodes (node_id INT, network VARCHAR(50), nodes_count INT); INSERT INTO network_nodes (node_id, network, nodes_count) VALUES (1, 'Algorand', 1234); | What is the number of nodes in the Algorand network? | SELECT nodes_count FROM network_nodes WHERE network = 'Algorand'; | gretelai_synthetic_text_to_sql |
CREATE TABLE crop_temperature (crop_type TEXT, temperature INTEGER, timestamp TIMESTAMP);CREATE TABLE crop_humidity (crop_type TEXT, humidity INTEGER, timestamp TIMESTAMP); | What is the minimum temperature and humidity for each crop type in the past month? | SELECT ct.crop_type, MIN(ct.temperature) as min_temp, MIN(ch.humidity) as min_humidity FROM crop_temperature ct JOIN crop_humidity ch ON ct.timestamp = ch.timestamp WHERE ct.timestamp BETWEEN DATEADD(month, -1, CURRENT_TIMESTAMP) AND CURRENT_TIMESTAMP GROUP BY ct.crop_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE Shipments (id INT, WarehouseId INT, Product VARCHAR(50), Quantity INT, Destination VARCHAR(50), ShippedDate DATE); INSERT INTO Shipments (id, WarehouseId, Product, Quantity, Destination, ShippedDate) VALUES (1, 1, 'Laptop', 50, 'New York', '2022-01-01'); INSERT INTO Shipments (id, WarehouseId, Product, Qua... | What is the total quantity of electronics shipped from each warehouse per country? | SELECT WarehouseId, Country, SUM(Quantity) AS TotalQuantity FROM (SELECT WarehouseId, Product, Quantity, Destination, SUBSTRING(Destination, 1, INSTR(Destination, ',') - 1) AS Country FROM Shipments) AS ShippedData GROUP BY WarehouseId, Country; | gretelai_synthetic_text_to_sql |
CREATE TABLE DELIVERY (id INT, supplier_id INT, product_id INT, is_organic BOOLEAN, quantity INT); | What is the maximum quantity of a single organic product delivered in the DELIVERY table? | SELECT MAX(quantity) FROM DELIVERY WHERE is_organic = true; | gretelai_synthetic_text_to_sql |
CREATE TABLE manufacturers (manufacturer_id INT, manufacturer_name VARCHAR(50), country VARCHAR(50), founding_date DATE); INSERT INTO manufacturers (manufacturer_id, manufacturer_name, country, founding_date) VALUES (1, 'ABC Chemicals', 'USA', '1950-01-01'), (2, 'XYZ Chemicals', 'Canada', '1980-01-01'), (3, 'DEF Chemic... | Identify the top 3 manufacturers with the highest total weight of chemicals produced, and rank them based on the date of their founding (earliest to latest) | SELECT manufacturer_id, manufacturer_name, SUM(weight) as total_weight, RANK() OVER (ORDER BY SUM(weight) DESC) as rank FROM chemicals JOIN manufacturers ON chemicals.manufacturer_id = manufacturers.manufacturer_id GROUP BY manufacturer_id, manufacturer_name ORDER BY rank ASC, founding_date ASC; | gretelai_synthetic_text_to_sql |
CREATE TABLE memberships (id INT, member_type VARCHAR(50), region VARCHAR(50)); CREATE TABLE workout_data (member_id INT, workout_type VARCHAR(50), duration INT, heart_rate_avg INT, calories_burned INT, workout_date DATE); | Which members in the North region have completed a workout of type 'Spin' with a duration of more than 60 minutes? | SELECT m.id FROM memberships m JOIN workout_data w ON m.id = w.member_id WHERE m.region = 'North' AND w.workout_type = 'Spin' AND w.duration > 60 GROUP BY m.id; | gretelai_synthetic_text_to_sql |
CREATE TABLE personnel_by_region(personnel_id INT, assignment VARCHAR(255), region VARCHAR(255)); INSERT INTO personnel_by_region(personnel_id, assignment, region) VALUES (1, 'Cybersecurity', 'Europe'), (2, 'Intelligence', 'Asia-Pacific'), (3, 'Logistics', 'North America'), (4, 'Cybersecurity', 'Europe'), (5, 'Cybersec... | What is the total number of military personnel assigned to cybersecurity operations in Europe? | SELECT COUNT(*) FROM personnel_by_region WHERE assignment = 'Cybersecurity' AND region = 'Europe'; | gretelai_synthetic_text_to_sql |
CREATE TABLE therapists (therapist_id INT, therapist_name TEXT, state TEXT); CREATE TABLE therapy_sessions (session_id INT, patient_age INT, therapist_id INT); INSERT INTO therapists (therapist_id, therapist_name, state) VALUES (1, 'Alice Johnson', 'California'); INSERT INTO therapy_sessions (session_id, patient_age, t... | What is the average age of patients who have received therapy sessions in the state of California? | SELECT AVG(therapy_sessions.patient_age) FROM therapy_sessions JOIN therapists ON therapy_sessions.therapist_id = therapists.therapist_id WHERE therapists.state = 'California'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Vessel (id INT, name VARCHAR(50), type VARCHAR(50), length FLOAT); CREATE TABLE Captain (id INT, name VARCHAR(50), age INT, license_number VARCHAR(50), VesselId INT); CREATE TABLE Route (id INT, departure_port VARCHAR(50), arrival_port VARCHAR(50), distance FLOAT, VesselId INT); | Delete all routes associated with vessels that have a license_number of a captain who is under 30 years old. | DELETE FROM Route WHERE VesselId IN (SELECT VesselId FROM Captain WHERE age < 30); | gretelai_synthetic_text_to_sql |
CREATE TABLE Initiatives (id INT, name VARCHAR(255), plant_id INT, employees INT); INSERT INTO Initiatives (id, name, plant_id, employees) VALUES (4, 'Ethical Manufacturing', 7, 50); CREATE TABLE Plants (id INT, name VARCHAR(255)); INSERT INTO Plants (id, name) VALUES (7, 'Responsible Production'); | What is the number of employees working on ethical manufacturing initiatives at the 'Responsible Production' plant? | SELECT employees FROM Initiatives WHERE name = 'Ethical Manufacturing' AND plant_id = 7; | gretelai_synthetic_text_to_sql |
CREATE TABLE regions (region_id INT, region_name VARCHAR(50)); INSERT INTO regions (region_id, region_name) VALUES (1, 'Northeast'), (2, 'Southeast'), (3, 'Midwest'), (4, 'Southwest'), (5, 'West'); CREATE TABLE providers (provider_id INT, provider_name VARCHAR(50), region_id INT); INSERT INTO providers (provider_id, pr... | What is the average number of mental health conditions treated by providers in each region? | SELECT p.region_id, AVG(pp.condition_count) as avg_conditions FROM providers p JOIN (SELECT provider_id, COUNT(DISTINCT condition_id) as condition_count FROM provider_patients GROUP BY provider_id) pp ON p.provider_id = pp.provider_id GROUP BY p.region_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE carbon_prices (country VARCHAR(255) PRIMARY KEY, price_usd_per_ton FLOAT); | Delete records in the 'carbon_prices' table where the 'price_usd_per_ton' is greater than 50 | DELETE FROM carbon_prices WHERE price_usd_per_ton > 50; | gretelai_synthetic_text_to_sql |
CREATE TABLE community_engagement (engagement_id INT, engagement_type VARCHAR(10), total_shares INT); | Update the record in the 'community_engagement' table with an engagement ID of 7 to reflect a total of 150 social media shares | UPDATE community_engagement SET total_shares = 150 WHERE engagement_id = 7; | gretelai_synthetic_text_to_sql |
CREATE TABLE Policyholders (PolicyholderID INT, Age INT, PolicyType VARCHAR(20)); INSERT INTO Policyholders (PolicyholderID, Age, PolicyType) VALUES (1, 25, 'Auto'), (2, 32, 'Home'), (3, 19, 'Life'); | What is the total number of policies and their corresponding policy types for policyholders aged 30 or younger? | SELECT COUNT(*) as TotalPolicies, PolicyType FROM Policyholders WHERE Age <= 30 GROUP BY PolicyType; | gretelai_synthetic_text_to_sql |
CREATE TABLE DonorDisaster (DonorID INT, DisasterType VARCHAR(25), Amount DECIMAL(10,2)); INSERT INTO DonorDisaster (DonorID, DisasterType, Amount) VALUES (1, 'Earthquake', 100.00), (1, 'Flood', 50.00); | Find the total donations and number of donors for each disaster type. | SELECT DisasterType, SUM(Amount) as TotalDonations, COUNT(DISTINCT DonorID) as NumDonors FROM DonorDisaster GROUP BY DisasterType; | gretelai_synthetic_text_to_sql |
CREATE TABLE shariah_compliant_finance(customer_id INT, name VARCHAR(50), account_balance DECIMAL(10, 2)); INSERT INTO shariah_compliant_finance VALUES (1, 'Hassan Ahmed', 10000), (2, 'Aisha Bibi', 12000), (3, 'Muhammad Ali', 15000), (4, 'Fatima Khan', 11000); | Find the third highest account balance for Shariah-compliant finance customers, and identify the customer's name. | SELECT name, account_balance FROM (SELECT customer_id, name, account_balance, ROW_NUMBER() OVER (ORDER BY account_balance DESC) AS rn FROM shariah_compliant_finance) t WHERE rn = 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE dam_info (dam_id INT, dam_name VARCHAR(50)); CREATE TABLE dam_heights (dam_id INT, dam_height INT); INSERT INTO dam_info (dam_id, dam_name) VALUES (1, 'Hoover Dam'), (2, 'Grand Coulee Dam'), (3, 'Oroville Dam'); INSERT INTO dam_heights (dam_id, dam_height) VALUES (1, 726), (2, 550), (3, 770); | List all the dams along with their heights from the 'dam_info' and 'dam_heights' tables. | SELECT dam_info.dam_name, dam_heights.dam_height FROM dam_info INNER JOIN dam_heights ON dam_info.dam_id = dam_heights.dam_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE drugs (drug_id INT, drug_name TEXT); INSERT INTO drugs (drug_id, drug_name) VALUES (1001, 'Ibuprofen'), (1002, 'Paracetamol'), (1003, 'Aspirin'); CREATE TABLE sales (sale_id INT, drug_id INT, sale_date DATE, revenue FLOAT); INSERT INTO sales (sale_id, drug_id, sale_date, revenue) VALUES (1, 1001, '2020-01-... | What are the total sales for each drug in Q1 2020? | SELECT drug_name, SUM(revenue) as total_sales FROM sales JOIN drugs ON sales.drug_id = drugs.drug_id WHERE sale_date BETWEEN '2020-01-01' AND '2020-03-31' GROUP BY drug_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE students (student_id INT PRIMARY KEY, name VARCHAR(50), department VARCHAR(50), grant_recipient BOOLEAN); INSERT INTO students (student_id, name, department, grant_recipient) VALUES (1, 'David', 'Humanities', TRUE); CREATE TABLE grants (grant_id INT PRIMARY KEY, student_id INT, amount FLOAT); INSERT INTO g... | How many research grants have been awarded to graduate students in the Humanities department? | SELECT COUNT(*) FROM grants g INNER JOIN students s ON g.student_id = s.student_id WHERE s.department = 'Humanities' AND s.grant_recipient = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE donors (donor_id INT, donor_name TEXT, donation_amount DECIMAL, city_id INT); CREATE TABLE cities (city_id INT, city_name TEXT); | What is the total amount donated by each donor in the 'donors' table, joined with their corresponding city information from the 'cities' table? | SELECT donors.donor_name, SUM(donation_amount) FROM donors INNER JOIN cities ON donors.city_id = cities.city_id GROUP BY donor_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE water_treatment_plants (id INT, name TEXT, water_usage FLOAT); INSERT INTO water_treatment_plants (id, name, water_usage) VALUES (1, 'Plant A', 1000000), (2, 'Plant B', 1500000), (3, 'Plant C', 800000); | Which water treatment plants have water usage above the average? | SELECT name FROM water_treatment_plants WHERE water_usage > (SELECT AVG(water_usage) FROM water_treatment_plants); | gretelai_synthetic_text_to_sql |
CREATE TABLE broadband_speeds (location VARCHAR(20), speed FLOAT, country VARCHAR(20)); INSERT INTO broadband_speeds (location, speed, country) VALUES ('Madrid', 120.4, 'Spain'); INSERT INTO broadband_speeds (location, speed, country) VALUES ('Barcelona', 150.6, 'Spain'); | What is the average broadband speed in each country in Europe? | SELECT country, AVG(speed) FROM broadband_speeds GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE renewable_projects (project_name VARCHAR(255), project_type VARCHAR(255), city VARCHAR(255)); | What are the names and types of renewable energy projects in the city of Seattle? | SELECT project_name, project_type FROM renewable_projects WHERE city = 'Seattle'; | gretelai_synthetic_text_to_sql |
CREATE TABLE city_data (city VARCHAR(50), median_home_price FLOAT, first_time_buyer_friendly INT); INSERT INTO city_data (city, median_home_price, first_time_buyer_friendly) VALUES ('CityA', 200000, 1), ('CityB', 300000, 0), ('CityC', 150000, 1), ('CityD', 400000, 1), ('CityE', 250000, 0); | List the top 3 most affordable cities for first-time home buyers. | SELECT city, median_home_price FROM (SELECT city, median_home_price, RANK() OVER (ORDER BY median_home_price ASC) AS rank FROM city_data WHERE first_time_buyer_friendly = 1) AS subquery WHERE rank <= 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE donor_emails (id INT, donor_id INT, email VARCHAR(50)); INSERT INTO donor_emails (id, donor_id, email) VALUES (1, 1, 'johndoe'), (2, 2, 'janesmith'), (3, 3, 'alicej'); | Update the email addresses for donors with missing domain information ('@' symbol is missing). | UPDATE donor_emails SET email = CONCAT(email, '@example.org') WHERE email NOT LIKE '%@%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE ElectricVehicles (Id INT, Make VARCHAR(50), Model VARCHAR(50), MaxSpeed FLOAT); INSERT INTO ElectricVehicles (Id, Make, Model, MaxSpeed) VALUES (1, 'Tesla', 'Model S', 261), (2, 'Tesla', 'Model 3', 225), (3, 'Tesla', 'Model X', 250), (4, 'Tesla', 'Model Y', 217); | What is the maximum speed of electric vehicles produced by Tesla? | SELECT MAX(MaxSpeed) FROM ElectricVehicles WHERE Make = 'Tesla' AND Model LIKE 'Model%' | gretelai_synthetic_text_to_sql |
CREATE TABLE WarehouseTemperature (id INT, temperature FLOAT, location VARCHAR(20)); INSERT INTO WarehouseTemperature (id, temperature, location) VALUES (1, 35, 'Asia'), (2, 20, 'Europe'); | What is the total number of pallets with a temperature above 30 degrees Celsius stored in warehouses located in Asia? | SELECT COUNT(*) FROM WarehouseTemperature WHERE location LIKE '%Asia%' AND temperature > 30; | gretelai_synthetic_text_to_sql |
CREATE TABLE animal_habitat (habitat_id INT, habitat_name VARCHAR(50), animal_name VARCHAR(50), acres FLOAT); INSERT INTO animal_habitat (habitat_id, habitat_name, animal_name, acres) VALUES (1, 'African Savannah', 'Lion', 5000.0), (2, 'Asian Rainforest', 'Tiger', 2000.0), (3, 'African Rainforest', 'Elephant', 3000.0); | How many animals are there in the 'animal_habitat' table? | SELECT COUNT(*) FROM animal_habitat; | gretelai_synthetic_text_to_sql |
CREATE TABLE energy_storage (state TEXT, num_projects INTEGER); INSERT INTO energy_storage (state, num_projects) VALUES ('California', 563), ('Texas', 357), ('New York', 256), ('Florida', 152), ('Illinois', 140), ('Pennsylvania', 137), ('Ohio', 128), ('North Carolina', 127), ('Michigan', 122), ('New Jersey', 118); | How many energy storage projects are there in California, Texas, and New York? | SELECT num_projects FROM energy_storage WHERE state IN ('California', 'Texas', 'New York') | gretelai_synthetic_text_to_sql |
CREATE TABLE users (id INT PRIMARY KEY, name VARCHAR(50), country VARCHAR(50), ai_familiarity INT); INSERT INTO users (id, name, country, ai_familiarity) VALUES (1, 'John Doe', 'Canada', 3); INSERT INTO users (id, name, country, ai_familiarity) VALUES (2, 'Jane Smith', 'USA', 5); | Delete records from the "users" table where the country is "Canada" and the "ai_familiarity" score is less than 4 | DELETE FROM users WHERE country = 'Canada' AND ai_familiarity < 4; | gretelai_synthetic_text_to_sql |
CREATE TABLE artist (artist_id INT, artist_name VARCHAR(50), num_followers INT, primary_genre VARCHAR(30)); INSERT INTO artist (artist_id, artist_name, num_followers, primary_genre) VALUES (1, 'DJ Khalid', 3500000, 'Hip Hop'); INSERT INTO artist (artist_id, artist_name, num_followers, primary_genre) VALUES (2, 'Taylor ... | What are the primary genres and the number of artists for each, for artists with more than 5 million followers? | SELECT primary_genre, COUNT(artist_id) as num_artists FROM artist WHERE num_followers > 5000000 GROUP BY primary_genre; | gretelai_synthetic_text_to_sql |
CREATE TABLE Games (GameID INT, GameName VARCHAR(100), Genre VARCHAR(50), AdoptionRevenue DECIMAL(10,2), Country VARCHAR(50)); INSERT INTO Games (GameID, GameName, Genre, AdoptionRevenue, Country) VALUES (1, 'Racing Game A', 'racing', 300.00, 'USA'), (2, 'RPG Game B', 'RPG', 400.00, 'Canada'), (3, 'Strategy Game C', 's... | What is the total revenue of games with a "racing" genre in North America? | SELECT SUM(AdoptionRevenue) FROM Games WHERE Genre = 'racing' AND Country = 'North America'; | gretelai_synthetic_text_to_sql |
CREATE TABLE communities_indigenous (community_id INT, community_name VARCHAR(100), region VARCHAR(50)); INSERT INTO communities_indigenous VALUES (1, 'Indigenous Australian STEM', 'Oceania'), (2, 'Maori AI Learners', 'Oceania'); CREATE TABLE university_programs (program_id INT, program_name VARCHAR(100), community_id ... | What is the total number of hours spent by indigenous communities on AI training programs in universities in Oceania? | SELECT SUM(hours) FROM participation INNER JOIN university_programs ON participation.program_id = university_programs.program_id INNER JOIN communities_indigenous ON university_programs.community_id = communities_indigenous.community_id WHERE communities_indigenous.region = 'Oceania'; | gretelai_synthetic_text_to_sql |
CREATE TABLE HeritageSites (SiteID INT, SiteName VARCHAR(100), Country VARCHAR(50), Region VARCHAR(50), IsUNESCOWorldHeritageSite BOOLEAN, UNIQUE (SiteID)); | Provide the total number of heritage sites in the Asia-Pacific region, not including UNESCO World Heritage Sites. | SELECT COUNT(*) FROM HeritageSites WHERE Region = 'Asia-Pacific' AND IsUNESCOWorldHeritageSite = FALSE; | gretelai_synthetic_text_to_sql |
CREATE TABLE garment_manufacturing (garment_category VARCHAR(255), manufacturing_date DATE, co2_emissions INT); | Calculate the average CO2 emissions for each garment category in 2020. | SELECT garment_category, AVG(co2_emissions) FROM garment_manufacturing WHERE manufacturing_date BETWEEN '2020-01-01' AND '2020-12-31' GROUP BY garment_category; | gretelai_synthetic_text_to_sql |
CREATE TABLE AccessToJusticePetitions (id INT, petition_date DATE, petitions INT); INSERT INTO AccessToJusticePetitions (id, petition_date, petitions) VALUES (1, '2022-01-01', 1000), (2, '2022-02-01', 1500), (3, '2022-03-01', 1800), (4, '2022-04-01', 2000), (5, '2022-05-01', 2500); | What is the change in the number of access to justice petitions per month? | SELECT EXTRACT(MONTH FROM petition_date) as month, (LEAD(petitions) OVER (ORDER BY petition_date) - petitions) as change FROM AccessToJusticePetitions; | gretelai_synthetic_text_to_sql |
CREATE TABLE Donors (DonorID INT, DonorName TEXT, TotalDonation DECIMAL); | What is the total amount donated by each donor in descending order? | SELECT DonorName, SUM(TotalDonation) OVER (PARTITION BY DonorName ORDER BY SUM(TotalDonation) DESC) AS TotalDonation FROM Donors; | gretelai_synthetic_text_to_sql |
CREATE TABLE PlayerGameGenre (PlayerID INT, Age INT, GameGenre VARCHAR(30)); INSERT INTO PlayerGameGenre (PlayerID, Age, GameGenre) VALUES (1, 16, 'FPS'), (2, 20, 'RPG'), (3, 18, 'FPS'), (4, 25, 'Simulation'); | What is the most popular game genre among players aged 18 or above? | SELECT GameGenre, COUNT(*) as GameCount FROM PlayerGameGenre WHERE Age >= 18 GROUP BY GameGenre ORDER BY GameCount DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE policies (id INT, policy_name VARCHAR(255), last_updated_date DATE); INSERT INTO policies (id, policy_name, last_updated_date) VALUES (1, 'Access Control', '2022-01-01'), (2, 'Incident Response', '2022-01-15'), (3, 'Data Privacy', '2022-02-10'), (4, 'Network Security', '2022-03-05'); | Which policies have been updated in the last 30 days? Provide the output in the format: policy_name, last_updated_date. | SELECT policy_name, last_updated_date FROM policies WHERE last_updated_date >= DATE(NOW()) - INTERVAL 30 DAY; | gretelai_synthetic_text_to_sql |
CREATE TABLE donors (id INT, name TEXT, country TEXT); CREATE TABLE donations (id INT, donor_id INT, organization_id INT); CREATE TABLE organizations (id INT, name TEXT, cause_area TEXT, country TEXT); CREATE TABLE countries (id INT, name TEXT, continent TEXT); | How many unique donors have made donations to organizations focused on human rights, categorized by continent? | SELECT c.continent, COUNT(DISTINCT d.id) as num_unique_donors FROM donors d INNER JOIN donations ON d.id = donations.donor_id INNER JOIN organizations o ON donations.organization_id = o.id INNER JOIN countries ON d.country = countries.name WHERE o.cause_area = 'human rights' GROUP BY c.continent; | gretelai_synthetic_text_to_sql |
CREATE TABLE peacekeeping_operations (operation_name VARCHAR(50), country VARCHAR(50), years_participated INT); INSERT INTO peacekeeping_operations (operation_name, country, years_participated) VALUES ('MINUSTAH', 'United States', 13), ('MONUSCO', 'United States', 8), ('UNMISS', 'United States', 10), ('UNAMID', 'United... | In which peacekeeping operations did the US participate the most? | SELECT operation_name, SUM(years_participated) as total_years_participated FROM peacekeeping_operations WHERE country = 'United States' GROUP BY operation_name ORDER BY total_years_participated DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE mitigation (country VARCHAR(255), capacity INT, year INT); | What is the maximum 'renewable energy capacity' added by 'China' in a single 'year' from the 'mitigation' table? | SELECT MAX(capacity) FROM mitigation WHERE country = 'China' GROUP BY year; | gretelai_synthetic_text_to_sql |
CREATE TABLE graduate_students (student_id INT, name VARCHAR(50), country VARCHAR(50)); INSERT INTO graduate_students (student_id, name, country) VALUES (1, 'Alice', 'Egypt'), (2, 'Bob', 'Canada'), (3, 'Carlos', 'Mexico'), (4, 'Diana', 'South Africa'), (5, 'Eli', 'Nigeria'); CREATE TABLE academic_publications (publicat... | What is the number of academic publications per graduate student from Africa? | SELECT gs.country, COUNT(ap.publication_id) AS num_publications FROM graduate_students gs JOIN academic_publications ap ON gs.student_id = ap.student_id WHERE gs.country IN ('Egypt', 'South Africa', 'Nigeria') GROUP BY gs.country; | gretelai_synthetic_text_to_sql |
CREATE TABLE carbon_offset_programs (id INT, name TEXT, start_date DATE, end_date DATE); INSERT INTO carbon_offset_programs (id, name, start_date, end_date) VALUES (1, 'Trees for the Future', '2020-01-01', '2022-12-31'); INSERT INTO carbon_offset_programs (id, name, start_date, end_date) VALUES (2, 'Clean Oceans', '201... | Delete the carbon offset program with id 4 | DELETE FROM carbon_offset_programs WHERE id = 4; | gretelai_synthetic_text_to_sql |
CREATE TABLE production_costs (item_type VARCHAR(20), collection VARCHAR(20), cost NUMERIC(10,2), quantity INT); INSERT INTO production_costs (item_type, collection, cost, quantity) VALUES ('cashmere sweater', 'autumn 2021', 32.99, 100), ('cashmere scarf', 'autumn 2021', 35.99, 75), ('cotton t-shirt', 'autumn 2021', 12... | How many items were produced in the 'autumn 2021' collection with a production cost above 30? | SELECT COUNT(*) FROM production_costs WHERE collection = 'autumn 2021' AND cost > 30; | gretelai_synthetic_text_to_sql |
CREATE TABLE Music (song_id INT, title TEXT, genre TEXT); INSERT INTO Music (song_id, title, genre) VALUES (1, 'SongA', 'Rock'), (2, 'SongB', 'Jazz'), (3, 'SongC', 'Hip-Hop'), (4, 'SongD', 'Country'), (5, 'SongE', 'RnB'); | Update the music genre for 'SongE' to 'Pop' in the Music table. | UPDATE Music SET genre = 'Pop' WHERE title = 'SongE'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Artists (ArtistID INT PRIMARY KEY, Name VARCHAR(255), Nationality VARCHAR(255)); CREATE TABLE Artworks (ArtworkID INT PRIMARY KEY, Title VARCHAR(255), ArtistID INT, Year INT); CREATE TABLE Exhibitions (ExhibitionID INT PRIMARY KEY, Name VARCHAR(255), StartDate DATE, EndDate DATE, City VARCHAR(255)); CREATE... | Which artworks were exhibited in both Paris and New York? | SELECT Artworks.Title FROM Artworks INNER JOIN ExhibitionArtworks ON Artworks.ArtworkID = ExhibitionArtworks.ArtworkID INNER JOIN Exhibitions ON ExhibitionArtworks.ExhibitionID = Exhibitions.ExhibitionID WHERE Exhibitions.City IN ('Paris', 'New York') GROUP BY Artworks.Title HAVING COUNT(DISTINCT Exhibitions.City) = 2; | gretelai_synthetic_text_to_sql |
CREATE TABLE trends (id INT, trend_name VARCHAR(50), region VARCHAR(50), forecast VARCHAR(50), popularity INT); | Select all records from trends table where region='Asia' and forecast='Spring' | SELECT * FROM trends WHERE region = 'Asia' AND forecast = 'Spring'; | gretelai_synthetic_text_to_sql |
CREATE TABLE schools (school_id INT, school_name TEXT, num_students INT); CREATE TABLE projects (project_id INT, project_name TEXT, school_id INT, student_id INT, num_projects INT); INSERT INTO schools (school_id, school_name, num_students) VALUES (1, 'Innovation School', 100), (2, 'Creativity School', 120), (3, 'Disco... | What is the maximum number of open pedagogy projects completed by students in each school? | SELECT school_name, MAX(num_projects) as max_projects FROM schools JOIN projects ON schools.school_id = projects.school_id GROUP BY school_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE sales (product_id INT, region VARCHAR(255), quantity INT, ethical_source BOOLEAN); INSERT INTO sales (product_id, region, quantity, ethical_source) VALUES (1, 'North', 100, true), (2, 'South', 200, false), (3, 'East', 150, true); | What is the total quantity of ethically sourced products sold by region? | SELECT region, ethical_source, SUM(quantity) AS total_quantity FROM sales GROUP BY region, ethical_source; | gretelai_synthetic_text_to_sql |
CREATE TABLE Donations (DonationID INT, DonationDate DATE, DonationAmount DECIMAL(10,2), ProgramID INT); INSERT INTO Donations (DonationID, DonationDate, DonationAmount, ProgramID) VALUES (10, '2022-05-01', 550.00, 1), (11, '2022-05-15', 650.00, 1), (12, '2022-05-01', 750.00, 2), (13, '2022-05-15', 850.00, 2), (14, '20... | What is the total donation amount per program in the last 3 months? | SELECT ProgramID, SUM(DonationAmount) OVER (PARTITION BY ProgramID ORDER BY DonationDate ROWS BETWEEN 3 PRECEDING AND CURRENT ROW) AS TotalDonationInLast3Months FROM Donations; | gretelai_synthetic_text_to_sql |
CREATE TABLE ModelScores (model_id INT, score FLOAT, dev_region VARCHAR(255), model_year INT); INSERT INTO ModelScores (model_id, score, dev_region, model_year) VALUES (1, 8.5, 'Africa', 2020), (2, 9.2, 'Asia', 2021), (3, 8.8, 'Europe', 2022); | Find the average safety score of AI models created by African researchers since 2020. | SELECT AVG(score) FROM ModelScores WHERE dev_region = 'Africa' AND model_year >= 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE defense_contractors_3 (corp varchar(255), year int, sales int); INSERT INTO defense_contractors_3 (corp, year, sales) VALUES ('ABC Corp', 2019, 800000), ('ABC Corp', 2020, 900000), ('ABC Corp', 2021, 1000000); | What is the total military equipment sales revenue for 'ABC Corp' from 2019 to 2021? | SELECT SUM(sales) FROM defense_contractors_3 WHERE corp = 'ABC Corp' AND year BETWEEN 2019 AND 2021; | gretelai_synthetic_text_to_sql |
CREATE TABLE community_policing_interactions (id SERIAL PRIMARY KEY, neighborhood_id INTEGER, interaction_type VARCHAR(255), interaction_count INTEGER); CREATE TABLE neighborhoods (id SERIAL PRIMARY KEY, name VARCHAR(255), location POINT, radius INTEGER); INSERT INTO neighborhoods (name, location, radius) VALUES ('Down... | Find the number of community policing interactions for each interaction type in the Downtown neighborhood | SELECT interaction_type, SUM(interaction_count) as total_interactions FROM community_policing_interactions cpi JOIN neighborhoods n ON n.id = cpi.neighborhood_id WHERE n.name = 'Downtown' GROUP BY interaction_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE conservation_initiatives (region VARCHAR(50), date DATE, initiative VARCHAR(50)); INSERT INTO conservation_initiatives (region, date, initiative) VALUES ('Sydney', '2017-01-01', 'Rainwater harvesting'), ('Sydney', '2016-01-01', 'Greywater reuse'), ('Sydney', '2015-01-01', 'Smart irrigation'); | Find the number of water conservation initiatives implemented in 'Sydney' before 2018 | SELECT COUNT(*) FROM conservation_initiatives WHERE region = 'Sydney' AND date < '2018-01-01'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Donors (DonorID INT, FirstName TEXT, LastName TEXT, Country TEXT); INSERT INTO Donors (DonorID, FirstName, LastName, Country) VALUES (1, 'John', 'Doe', 'USA'), (2, 'Jane', 'Smith', 'USA'); CREATE TABLE Donations (DonationID INT, DonorID INT, Amount DECIMAL); INSERT INTO Donations (DonationID, DonorID, Amou... | What is the total amount donated by each donor from the United States, including their contact information? | SELECT D.FirstName, D.LastName, D.Country, SUM(DON.Amount) AS TotalDonated FROM Donors D INNER JOIN Donations DON ON D.DonorID = DON.DonorID WHERE D.Country = 'USA' GROUP BY D.DonorID; | gretelai_synthetic_text_to_sql |
CREATE TABLE sports_team_performance (team_name VARCHAR(20), wins INT, losses INT); INSERT INTO sports_team_performance (team_name, wins, losses) VALUES ('Los Angeles Lakers', 55, 27), ('Boston Celtics', 48, 34); | Delete all records from the 'sports_team_performance' table where the 'team_name' is 'Los Angeles Lakers' | DELETE FROM sports_team_performance WHERE team_name = 'Los Angeles Lakers'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Donors (DonorID INT, DonorName TEXT, State TEXT, Country TEXT, TotalDonation DECIMAL); CREATE TABLE Donations (DonationID INT, DonorID INT, DonationDate DATE, DonationAmount DECIMAL); | List the top 5 donors by total donation amount in the year 2019, showing their total donation amount, state, and country. | SELECT D.DonorName, SUM(D.DonationAmount) as TotalDonation, D.State, D.Country FROM Donations D JOIN Donors DON ON D.DonorID = DON.DonorID WHERE YEAR(D.DonationDate) = 2019 GROUP BY D.DonorName, D.State, D.Country ORDER BY TotalDonation DESC LIMIT 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE UNESCO_SITES (id INT PRIMARY KEY, name VARCHAR(255), region VARCHAR(255), type VARCHAR(255)); INSERT INTO UNESCO_SITES (id, name, region, type) VALUES (1, 'Colosseum', 'Europe', 'Cultural'); | What are the names of UNESCO heritage sites in Europe and their types? | SELECT name, type FROM UNESCO_SITES WHERE region = 'Europe'; | gretelai_synthetic_text_to_sql |
CREATE TABLE astronauts (astronaut_id INT, name VARCHAR(255), gender VARCHAR(255), age INT, country VARCHAR(255), missions INT); INSERT INTO astronauts (astronaut_id, name, gender, age, country, missions) VALUES (1, 'Yuri Gagarin', 'Male', 41, 'Russia', 1); | What is the total number of missions for astronauts from Russia? | SELECT country, SUM(missions) as total_missions FROM astronauts WHERE country = 'Russia' GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE ReindeerData (reindeer_name VARCHAR(50), county VARCHAR(50), population INT); INSERT INTO ReindeerData (reindeer_name, county, population) VALUES ('Finnmark Reindeer', 'Finnmark County', 15000), ('Sami Reindeer', 'Finnmark County', 20000); | What is the total number of reindeer in Norway's Finnmark County? | SELECT county, SUM(population) FROM ReindeerData WHERE reindeer_name IN ('Finnmark Reindeer', 'Sami Reindeer') GROUP BY county; | gretelai_synthetic_text_to_sql |
CREATE TABLE Students (StudentID INT, Name VARCHAR(50), Disability VARCHAR(50)); CREATE TABLE StudentAccommodations (StudentID INT, AccommodationID INT, StartDate DATE, EndDate DATE); CREATE TABLE Accommodations (AccommodationID INT, Accommodation VARCHAR(100), Description TEXT); CREATE TABLE ExamResults (ExamID INT, S... | What is the average score for students who have received extended time accommodation? | SELECT AVG(er.Score) as AverageScore FROM ExamResults er JOIN Students s ON er.StudentID = s.StudentID JOIN StudentAccommodations sa ON s.StudentID = sa.StudentID JOIN Accommodations a ON sa.AccommodationID = a.AccommodationID WHERE a.Accommodation = 'Extended time'; | gretelai_synthetic_text_to_sql |
CREATE TABLE museums (id INT, name TEXT, city TEXT);CREATE TABLE museum_visitors (id INT, visitor_id INT, museum_id INT, country TEXT);CREATE TABLE visitors (id INT, name TEXT); | Which museum has the most international visitors in the last 6 months? | SELECT m.name, COUNT(mv.visitor_id) as num_visitors FROM museums m JOIN museum_visitors mv ON m.id = mv.museum_id JOIN visitors v ON mv.visitor_id = v.id WHERE v.country != 'USA' AND mv.visit_date >= DATEADD(month, -6, GETDATE()) GROUP BY m.name ORDER BY num_visitors DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE if NOT EXISTS tours (id INT, name TEXT, rating FLOAT, vegetarian_meal BOOLEAN); INSERT INTO tours (id, name, rating, vegetarian_meal) VALUES (1, 'Mountain Biking Adventure', 4.5, true), (2, 'Historic City Tour', 4.2, false); | What is the average rating of tours in Asia with a vegetarian meal option? | SELECT AVG(rating) FROM tours WHERE vegetarian_meal = true AND country = 'Asia'; | gretelai_synthetic_text_to_sql |
CREATE TABLE user_calories (user_id INT, date DATE, calories INT, class VARCHAR(50)); INSERT INTO user_calories (user_id, date, calories, class) VALUES (1, '2022-01-01', 300, 'Zumba'), (1, '2022-01-02', 350, 'Zumba'), (2, '2022-01-01', 250, 'Yoga'), (2, '2022-01-02', 200, 'Yoga'), (1, '2022-01-03', 400, 'Zumba'); | Calculate the average calories burned per day for all users who participated in 'Zumba' classes. | SELECT AVG(calories) FROM user_calories WHERE class = 'Zumba'; | gretelai_synthetic_text_to_sql |
CREATE TABLE olympic_athletes (athlete_id INT, name VARCHAR(50), country VARCHAR(50), medals INT); INSERT INTO olympic_athletes (athlete_id, name, country, medals) VALUES (1, 'Usain Bolt', 'Jamaica', 8); | How many Olympic medals has Usain Bolt won? | SELECT medals FROM olympic_athletes WHERE name = 'Usain Bolt'; | gretelai_synthetic_text_to_sql |
CREATE TABLE equipment_sales (id INT, country VARCHAR(50), equipment_type VARCHAR(50), year INT, sales INT); INSERT INTO equipment_sales (id, country, equipment_type, year, sales) VALUES (1, 'USA', 'Tanks', 2018, 5000000), (2, 'USA', 'Aircraft', 2018, 12000000), (3, 'China', 'Tanks', 2018, 800000), (4, 'China', 'Aircra... | What is the total value of military equipment sales to each country in the current year? | SELECT country, SUM(sales) as total_sales FROM equipment_sales WHERE year = YEAR(CURRENT_TIMESTAMP) GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE property_co_ownership (id INT, property_id INT, co_owner_id INT, agreement_start_date DATE, agreement_end_date DATE); | Which properties in the 'property_co_ownership' table are co-owned by a person with id 5? | SELECT property_id FROM property_co_ownership WHERE co_owner_id = 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE Dams (ID INT, Name VARCHAR(50), Location VARCHAR(50), Length FLOAT, YearBuilt INT); INSERT INTO Dams (ID, Name, Location, Length, YearBuilt) VALUES (1, 'Hoover Dam', 'Nevada/Arizona border', 247.0, 1936); INSERT INTO Dams (ID, Name, Location, Length, YearBuilt) VALUES (2, 'Oroville Dam', 'Butte County, CA'... | What is the name and ID of the longest dam in the 'Dams' table? | SELECT Name, ID FROM Dams WHERE Length = (SELECT MAX(Length) FROM Dams); | gretelai_synthetic_text_to_sql |
CREATE TABLE SustainableTrends (id INT, trend VARCHAR(255), sustainability_score INT); INSERT INTO SustainableTrends (id, trend, sustainability_score) VALUES (1, 'Organic Cotton T-Shirt', 90), (2, 'Recycled Polyester Hoodie', 80), (3, 'Bamboo Viscose Pants', 85); CREATE TABLE CustomerSizes (id INT, size VARCHAR(255), c... | What is the most popular sustainable fashion trend among customers of different sizes in Australia? | SELECT st.trend, c.size, MAX(c.percentage) AS popularity FROM SustainableTrends st CROSS JOIN CustomerSizes c WHERE c.country = 'Australia' GROUP BY st.trend, c.size; | gretelai_synthetic_text_to_sql |
CREATE TABLE Matches (MatchID int, PlayerID int, Game varchar(255), MatchResult varchar(255)); INSERT INTO Matches VALUES (1, 1, 'CS:GO', 'Win'), (2, 2, 'CS:GO', 'Loss'), (3, 1, 'Dota 2', 'Win'), (4, 3, 'Dota 2', 'Win'); | Which players have the highest number of wins in multiplayer matches? | SELECT PlayerID, COUNT(*) as Wins FROM Matches WHERE MatchResult = 'Win' GROUP BY PlayerID ORDER BY Wins DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE Volunteers (VolunteerID int, Name varchar(50), Donation decimal(10,2)); INSERT INTO Volunteers (VolunteerID, Name, Donation) VALUES (1, 'John Doe', 100.00), (2, 'Jane Smith', 200.00), (3, 'Mike Johnson', 50.00); | Which volunteers have donated the most money? | SELECT Name, SUM(Donation) as TotalDonations FROM Volunteers GROUP BY Name ORDER BY TotalDonations DESC | gretelai_synthetic_text_to_sql |
CREATE TABLE Stores (id INT, name VARCHAR(255), region VARCHAR(255)); INSERT INTO Stores (id, name, region) VALUES (1, 'Store A', 'West'), (2, 'Store B', 'West'), (3, 'Store C', 'East'), (4, 'Store D', 'East'); CREATE TABLE Organic_Cotton_Sales (id INT, store_id INT, quarter INT, year INT, units INT); INSERT INTO Organ... | How many units of organic cotton garments were sold by each store in the 'West' region in Q3 of 2021? | SELECT s.name, SUM(o.units) FROM Organic_Cotton_Sales o JOIN Stores s ON o.store_id = s.id WHERE o.quarter = 3 AND o.year = 2021 AND s.region = 'West' GROUP BY s.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE drug (drug_code CHAR(5), drug_name VARCHAR(100)); | Insert a new drug with a given code and name into the drug table | INSERT INTO drug (drug_code, drug_name) VALUES ('DR003', 'DrugC'); | gretelai_synthetic_text_to_sql |
CREATE TABLE Departments (id INT, department_name VARCHAR(50), employee_id INT); CREATE TABLE Employees (id INT, salary DECIMAL(10, 2)); | Identify the departments with the highest and lowest number of employees | SELECT department_name, COUNT(*) AS employees_count FROM Departments JOIN Employees ON Departments.employee_id = Employees.id GROUP BY department_name ORDER BY employees_count DESC, department_name LIMIT 1; SELECT department_name, COUNT(*) AS employees_count FROM Departments JOIN Employees ON Departments.employee_id = ... | gretelai_synthetic_text_to_sql |
CREATE TABLE donations (id INT, donation_amount DECIMAL(10, 2), donation_date DATE); INSERT INTO donations (id, donation_amount, donation_date) VALUES (1, 50.00, '2021-01-01'); INSERT INTO donations (id, donation_amount, donation_date) VALUES (2, 100.00, '2021-02-01'); | What is the total donation amount per month in 2021? | SELECT DATE_FORMAT(donation_date, '%Y-%m') as month, SUM(donation_amount) as total_donations FROM donations WHERE donation_date >= '2021-01-01' AND donation_date < '2022-01-01' GROUP BY month; | gretelai_synthetic_text_to_sql |
CREATE TABLE explainability_audits (id INT, model_id INT, explanation_score INT, created_at DATETIME); INSERT INTO explainability_audits (id, model_id, explanation_score, created_at) VALUES (1, 1, 7, '2021-01-01'); INSERT INTO explainability_audits (id, model_id, explanation_score, created_at) VALUES (2, 2, 8, '2021-01... | What is the maximum explanation score for each model, and how many times does each model achieve that score? | SELECT model_id, MAX(explanation_score) as max_explanation_score, COUNT(*) as count FROM explainability_audits GROUP BY model_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE wildlife_habitats (id INT, name VARCHAR(50), area FLOAT, region VARCHAR(50)); INSERT INTO wildlife_habitats (id, name, area, region) VALUES (1, 'Habitat 1', 800.0, 'North America'), (2, 'Habitat 2', 600.0, 'South America'); | Which wildlife habitats in 'North America' have an area larger than 700? | SELECT name FROM wildlife_habitats WHERE area > 700 AND region = 'North America'; | gretelai_synthetic_text_to_sql |
CREATE TABLE renewable_projects (id INT, project_name VARCHAR(100), country VARCHAR(50), capacity FLOAT); INSERT INTO renewable_projects (id, project_name, country, capacity) VALUES (1, 'Solar Farm Canada', 'Canada', 789.12), (2, 'Wind Farm Canada', 'Canada', 1500.78), (3, 'Hydro Plant Canada', 'Canada', 450.34); | How many renewable energy projects are in Canada with an installed capacity greater than 500? | SELECT COUNT(*) FROM renewable_projects WHERE country = 'Canada' AND capacity > 500; | gretelai_synthetic_text_to_sql |
CREATE TABLE VolunteerPrograms (VolunteerID INT, ProgramID INT, VolunteerDate DATE); INSERT INTO VolunteerPrograms (VolunteerID, ProgramID, VolunteerDate) VALUES (1, 1, '2020-01-01'), (2, 1, '2020-02-01'), (3, 2, '2020-03-01'); | How many volunteers were engaged in each program in 2020, sorted by the highest number of volunteers? | SELECT Programs.ProgramName, COUNT(DISTINCT VolunteerPrograms.VolunteerID) as VolunteerCount FROM Programs INNER JOIN VolunteerPrograms ON Programs.ProgramID = VolunteerPrograms.ProgramID WHERE YEAR(VolunteerPrograms.VolunteerDate) = 2020 GROUP BY Programs.ProgramName ORDER BY VolunteerCount DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE users (id INT PRIMARY KEY, name VARCHAR(50), email VARCHAR(50), signup_date DATE, signup_source VARCHAR(20)); | List all users who signed up using email | SELECT * FROM users WHERE signup_source = 'email'; | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_species (species_id SERIAL PRIMARY KEY, species_name VARCHAR(50), ocean_name VARCHAR(50), sighting_date DATE); | Insert a new marine species 'Giant Squid' in the 'Pacific Ocean' and return the ID of the inserted record. | INSERT INTO marine_species (species_name, ocean_name, sighting_date) VALUES ('Giant Squid', 'Pacific Ocean', '2022-08-01') RETURNING species_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE DeepOceanExploration (id INT, name TEXT, latitude REAL, longitude REAL, depth REAL); INSERT INTO DeepOceanExploration (id, name, latitude, longitude, depth) VALUES (1, 'Station 1', 15.4948, -61.3704, 6000); INSERT INTO DeepOceanExploration (id, name, latitude, longitude, depth) VALUES (2, 'Station 2', 44.6... | What is the minimum depth of all stations in the Deep Ocean Exploration database? | SELECT MIN(depth) FROM DeepOceanExploration; | gretelai_synthetic_text_to_sql |
CREATE TABLE clients (client_id INT, name VARCHAR(50), total_assets DECIMAL(10,2), primary_residence VARCHAR(50));CREATE TABLE transactions (transaction_id INT, client_id INT, transaction_date DATE); | What is the maximum total assets value for clients with a primary residence in California in Q4 2022? | SELECT MAX(total_assets) FROM clients c INNER JOIN transactions t ON c.client_id = t.client_id WHERE c.primary_residence = 'California' AND t.transaction_date BETWEEN '2022-10-01' AND '2022-12-31' | gretelai_synthetic_text_to_sql |
CREATE TABLE mlb_season (team_id INT, team_name VARCHAR(50), games_played INT, runs_home INT, runs_away INT); INSERT INTO mlb_season (team_id, team_name, games_played, runs_home, runs_away) VALUES (1, 'Los Angeles Dodgers', 162, 834, 653); | What is the difference in total runs scored between the home and away games for each team in the 2021 MLB season? | SELECT team_name, (runs_home - runs_away) as diff FROM mlb_season; | gretelai_synthetic_text_to_sql |
CREATE TABLE articles (id INT, title TEXT, category TEXT, likes INT); INSERT INTO articles (id, title, category, likes) VALUES (1, 'Climate Crisis Explained', 'climate_change', 1500); CREATE TABLE users (id INT, name TEXT, age INT); INSERT INTO users (id, name, age) VALUES (1, 'John Doe', 35), (2, 'Jane Smith', 42); | What is the average age of users who liked articles related to climate change? | SELECT AVG(age) FROM users JOIN (SELECT user_id FROM article_likes WHERE article_category = 'climate_change') AS liked_articles ON users.id = liked_articles.user_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE nhl_player_positions (id INT, name VARCHAR(100), position VARCHAR(50)); INSERT INTO nhl_player_positions (id, name, position) VALUES (1, 'Alex Ovechkin', 'Left Wing'), (2, 'Connor McDavid', 'Center'), (3, 'Sidney Crosby', 'Center'), (4, 'Patrick Kane', 'Right Wing'), (5, 'Victor Hedman', 'Defenseman'), (6,... | Count the number of players in each position group in the NHL. | SELECT position, COUNT(*) FROM nhl_player_positions GROUP BY position; | gretelai_synthetic_text_to_sql |
CREATE TABLE multimodal_trips (id INT, trips INT, city VARCHAR(50)); | What is the total number of multimodal trips taken in New York City? | SELECT SUM(trips) FROM multimodal_trips WHERE city = 'New York City'; | 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.