context stringlengths 11 9.12k | question stringlengths 0 1.06k | SQL stringlengths 2 4.44k | source stringclasses 28
values |
|---|---|---|---|
CREATE TABLE athlete_stats (athlete_id INT, name VARCHAR(100), team VARCHAR(50), position VARCHAR(50), games_played INT, goals_scored INT); CREATE TABLE team_performances (team VARCHAR(50), games_played INT, goals_scored INT); INSERT INTO athlete_stats (athlete_id, name, team, position, games_played, goals_scored) VALU... | Show athlete performance data, joining the 'athlete_stats' and 'team_performances' tables | SELECT athlete_stats.name, team_performances.games_played, athlete_stats.goals_scored FROM athlete_stats INNER JOIN team_performances ON athlete_stats.team = team_performances.team; | gretelai_synthetic_text_to_sql |
CREATE TABLE region_recycling (region VARCHAR(255), material VARCHAR(255), recycling_rate DECIMAL(5,2)); INSERT INTO region_recycling (region, material, recycling_rate) VALUES ('Region 1', 'plastic', 0.30), ('Region 1', 'paper', 0.40), ('Region 1', 'metal', 0.25); | What are the recycling rates for each material in 'Region 1'? | SELECT material, recycling_rate FROM region_recycling WHERE region = 'Region 1'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Player (PlayerID INT, RegistrationDate DATE); INSERT INTO Player (PlayerID, RegistrationDate) VALUES (1, '2022-02-01'); INSERT INTO Player (PlayerID, RegistrationDate) VALUES (2, '2022-02-03'); | How many new players registered per day, for the past week? | SELECT RegistrationDate, COUNT(*) as NewPlayers FROM Player WHERE RegistrationDate >= '2022-02-01' AND RegistrationDate <= '2022-02-07' GROUP BY RegistrationDate | gretelai_synthetic_text_to_sql |
CREATE TABLE students (student_id INT, student_name VARCHAR(255)); INSERT INTO students VALUES (1, 'Student A'), (2, 'Student B'), (3, 'Student C'), (4, 'Student D'); CREATE TABLE student_courses (student_id INT, course_id INT); INSERT INTO student_courses VALUES (1, 1), (1, 2), (2, 1), (3, 2), (3, 3), (4, 1); CREATE T... | What is the number of students who have never taken an open pedagogy course? | SELECT COUNT(s.student_id) as no_open_pedagogy_courses FROM students s LEFT JOIN student_courses sc ON s.student_id = sc.student_id LEFT JOIN open_pedagogy_courses opc ON sc.course_id = opc.course_id WHERE opc.course_id IS NULL; | gretelai_synthetic_text_to_sql |
CREATE TABLE LanguagePreservation (id INT, language VARCHAR(255), speakers INT, region VARCHAR(255)); INSERT INTO LanguagePreservation (id, language, speakers, region) VALUES (1, 'Hindi', 341000000, 'India'); INSERT INTO LanguagePreservation (id, language, speakers, region) VALUES (2, 'Bengali', 228000000, 'India'); | Which languages are spoken in India and have more than 100,000 speakers? | SELECT language FROM LanguagePreservation WHERE speakers > 100000 AND region = 'India'; | gretelai_synthetic_text_to_sql |
CREATE TABLE equipment_sales (equipment_type VARCHAR(255), sale_date DATE, revenue INT); INSERT INTO equipment_sales (equipment_type, sale_date, revenue) VALUES ('Tank', '2021-04-01', 5000000), ('Tank', '2021-07-01', 6000000), ('Jet', '2021-05-01', 8000000), ('Jet', '2021-08-01', 9000000); | Calculate the total sales revenue for each military equipment type in Q2 2021 | SELECT equipment_type, SUM(revenue) as total_revenue FROM equipment_sales WHERE sale_date BETWEEN '2021-04-01' AND '2021-06-30' GROUP BY equipment_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE MedicalData (Id INT, Astronaut VARCHAR(50), Mission VARCHAR(50), DataPoint FLOAT); INSERT INTO MedicalData (Id, Astronaut, Mission, DataPoint) VALUES (1, 'Mark Watney', 'Ares 3', 120), (2, 'Mark Watney', 'Ares 3', 130), (3, 'Mark Watney', 'Ares 3', 110); | What is the average medical data points recorded for each astronaut during the mission 'Ares 3'? | SELECT AVG(DataPoint) FROM MedicalData WHERE Mission = 'Ares 3' GROUP BY Astronaut | gretelai_synthetic_text_to_sql |
CREATE TABLE hotels (hotel_id INT, hotel_name TEXT, country TEXT, ai_adoption BOOLEAN); INSERT INTO hotels (hotel_id, hotel_name, country, ai_adoption) VALUES (1, 'The Nile Hotel', 'Egypt', true), (2, 'The Sahara Resort', 'Tunisia', false), (3, 'The African Palace', 'South Africa', true); | What is the percentage of hotels in Africa that have adopted AI technology? | SELECT (COUNT(*) FILTER (WHERE ai_adoption = true) * 100.0 / COUNT(*)) FROM hotels WHERE country = 'Africa'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Port (id INT, name TEXT, registration_date DATE); INSERT INTO Port (id, name, registration_date) VALUES (1, 'A', '2021-01-01'), (2, 'B', '2022-01-01'), (3, 'C', '2020-01-01'); CREATE TABLE Vessel (id INT, name TEXT, registration_date DATE, port_id INT); INSERT INTO Vessel (id, name, registration_date, port... | How many vessels were there in the maritime domain as of 2022-01-01? | SELECT COUNT(DISTINCT name) FROM Vessel WHERE registration_date <= '2022-01-01'; | gretelai_synthetic_text_to_sql |
CREATE TABLE landfill_capacity (region VARCHAR(255), year INT, capacity FLOAT); INSERT INTO landfill_capacity (region, year, capacity) VALUES ('North America', 2018, 5000000.0), ('South America', 2018, 3000000.0), ('Europe', 2018, 4000000.0); | What is the total landfill capacity in cubic meters for each region in 2018? | SELECT lc.region, SUM(lc.capacity) as total_capacity FROM landfill_capacity lc WHERE lc.year = 2018 GROUP BY lc.region; | gretelai_synthetic_text_to_sql |
CREATE TABLE incident_types (id INT, name VARCHAR, description TEXT); INSERT INTO incident_types (id, name, description) VALUES (1, 'Malware Attack', 'Attack using malicious software'); | Update the description of the 'Malware Attack' incident type to 'Attack using malicious software' in the 'incident_types' table | UPDATE incident_types SET description='Attack using malicious software' WHERE name='Malware Attack'; | gretelai_synthetic_text_to_sql |
CREATE TABLE posts (id INT, user_id INT, post_date DATE); INSERT INTO posts (id, user_id, post_date) VALUES (1, 1, '2022-01-01'), (2, 2, '2022-01-10'), (3, 1, '2022-02-01'), (4, 3, '2022-03-01'); CREATE TABLE users (id INT, country VARCHAR(255)); INSERT INTO users (id, country) VALUES (1, 'France'), (2, 'Canada'), (3, ... | How many users have created a post in the last week in each country? | SELECT users.country, COUNT(DISTINCT users.id) FROM posts INNER JOIN users ON posts.user_id = users.id WHERE posts.post_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 WEEK) GROUP BY users.country; | gretelai_synthetic_text_to_sql |
CREATE TABLE Menu (MenuID INT, Name VARCHAR(50), Type VARCHAR(50), Price DECIMAL(5,2), VendorID INT); INSERT INTO Menu (MenuID, Name, Type, Price, VendorID) VALUES (1, 'Veggie Burger', 'Vegan', 7.50, 1), (2, 'Falafel Wrap', 'Vegan', 6.99, 1), (3, 'Breadless Sandwich', 'Gluten-free', 8.99, 2); | What is the average price of menu items that are both 'Vegan' and 'Gluten-free'? | SELECT AVG(Price) FROM Menu WHERE Type IN ('Vegan', 'Gluten-free') GROUP BY Type HAVING COUNT(DISTINCT Type) = 2; | gretelai_synthetic_text_to_sql |
CREATE TABLE cargo_data(id INT, vessel_name VARCHAR(50), destination VARCHAR(50), cargo_weight DECIMAL(5,2)); INSERT INTO cargo_data(id, vessel_name, destination, cargo_weight) VALUES (1, 'Vessel E', 'Port A', 200.0), (2, 'Vessel E', 'Port B', 250.0); | What is the total cargo weight transported by Vessel E for each destination? | SELECT destination, SUM(cargo_weight) FROM cargo_data WHERE vessel_name = 'Vessel E' GROUP BY destination; | gretelai_synthetic_text_to_sql |
CREATE TABLE Artworks (artwork_id INTEGER, title TEXT, artist_name TEXT, genre TEXT, type TEXT); INSERT INTO Artworks (artwork_id, title, artist_name, genre, type) VALUES (1, 'Artwork 1', 'Alice', 'Ancient Art', 'Painting'), (2, 'Artwork 2', 'Bob', 'Ancient Art', 'Sculpture'), (3, 'Artwork 3', 'Charlotte', 'Ancient Art... | What is the most common type of artwork in the 'Ancient Art' genre? | SELECT type, COUNT(*) as count FROM Artworks WHERE genre = 'Ancient Art' GROUP BY type ORDER BY count DESC LIMIT 1 | gretelai_synthetic_text_to_sql |
CREATE TABLE Spacecraft (ID INT, Orbit VARCHAR(50), Status VARCHAR(50), Total INT); INSERT INTO Spacecraft (ID, Orbit, Status, Total) VALUES (1, 'Low Earth Orbit', 'Operational', 800), (2, 'Low Earth Orbit', 'Non-Operational', 200), (3, 'Medium Earth Orbit', 'Operational', 300), (4, 'Medium Earth Orbit', 'Non-Operation... | What is the total number of operational spacecraft in Low Earth Orbit? | SELECT Total FROM Spacecraft WHERE Orbit = 'Low Earth Orbit' AND Status = 'Operational'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Volunteers (VolunteerID INT, VolunteerName TEXT); INSERT INTO Volunteers (VolunteerID, VolunteerName) VALUES (1, 'Juan'), (2, 'Maria'), (3, 'Pedro'), (4, 'Jose'), (5, 'Carlos'); CREATE TABLE VolunteerHours (VolunteerHourID INT, VolunteerID INT, Hours DECIMAL, Program TEXT); INSERT INTO VolunteerHours (Volu... | Who are the top 3 volunteers by total hours for a specific program? | SELECT V.VolunteerName, SUM(VH.Hours) AS TotalVolunteerHours FROM Volunteers V JOIN VolunteerHours VH ON V.VolunteerID = VH.VolunteerID WHERE VH.Program = 'Feeding Program' GROUP BY V.VolunteerName ORDER BY TotalVolunteerHours DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE Patients (PatientID INT, PneumoniaShot DATE, State TEXT); INSERT INTO Patients (PatientID, PneumoniaShot, State) VALUES (1, '2021-11-01', 'Texas'); | What is the total number of patients who have had a pneumonia shot in the last year in Texas? | SELECT COUNT(*) FROM Patients WHERE PneumoniaShot >= DATEADD(year, -1, GETDATE()) AND State = 'Texas'; | gretelai_synthetic_text_to_sql |
CREATE TABLE player (player_id INT, name VARCHAR(50), rank INT, game VARCHAR(50)); INSERT INTO player (player_id, name, rank, game) VALUES (1, 'Jessica Kim', 4000, 'Overwatch'); INSERT INTO player (player_id, name, rank, game) VALUES (2, 'Kevin Nguyen', 3500, 'Fortnite'); INSERT INTO player (player_id, name, rank, game... | What is the name of the player with the highest rank in the game 'Overwatch'? | SELECT name FROM player WHERE game = 'Overwatch' AND rank = (SELECT MAX(rank) FROM player WHERE game = 'Overwatch'); | gretelai_synthetic_text_to_sql |
CREATE TABLE Wearable (DeviceID INT PRIMARY KEY, MemberID INT, Steps INT, Date DATE); CREATE TABLE Member (MemberID INT PRIMARY KEY, Age INT, Gender VARCHAR(10), MembershipStart DATE); | What is the average number of steps taken by members who joined in 2020, grouped by gender? | SELECT Member.Gender, AVG(Wearable.Steps) FROM Wearable INNER JOIN Member ON Wearable.MemberID = Member.MemberID WHERE Member.MembershipStart BETWEEN '2020-01-01' AND '2020-12-31' GROUP BY Member.Gender; | gretelai_synthetic_text_to_sql |
CREATE TABLE Neighborhoods (NeighborhoodID INT, NeighborhoodName VARCHAR(255)); CREATE TABLE Properties (PropertyID INT, PropertyTax FLOAT, NeighborhoodID INT); INSERT INTO Neighborhoods VALUES (1, 'Bronx'); INSERT INTO Properties VALUES (1, 5000, 1); | What is the sum of property taxes for all properties in the 'Bronx' neighborhood? | SELECT SUM(PropertyTax) FROM Properties p JOIN Neighborhoods n ON p.NeighborhoodID = n.NeighborhoodID WHERE n.NeighborhoodName = 'Bronx'; | gretelai_synthetic_text_to_sql |
CREATE TABLE refugee_support(id INT, people INT, location VARCHAR(255)); INSERT INTO refugee_support(id, people, location) VALUES (1, 10, 'Syria'), (2, 25, 'Iraq'), (3, 12, 'Syria'), (4, 50, 'Iraq'); | What is the total number of people served in 'refugee_support' table for 'Syria' and 'Iraq'? | SELECT SUM(people) FROM refugee_support WHERE location IN ('Syria', 'Iraq'); | gretelai_synthetic_text_to_sql |
CREATE TABLE Game_Design (GameID INT, GameName VARCHAR(100), Genre VARCHAR(50), Platform VARCHAR(50)); INSERT INTO Game_Design (GameID, GameName, Genre, Platform) VALUES (1, 'GameA', 'Action', 'PC'), (2, 'GameB', 'Adventure', 'Console'), (3, 'GameC', 'Action', 'Console'), (4, 'GameD', 'Simulation', 'VR'); | List all unique platforms from the 'Game Design' table, excluding 'PC'. | SELECT DISTINCT Platform FROM Game_Design WHERE Platform <> 'PC'; | gretelai_synthetic_text_to_sql |
CREATE TABLE GreenDefenceSales(id INT, contractor VARCHAR(255), region VARCHAR(255), equipment VARCHAR(255), quantity INT);INSERT INTO GreenDefenceSales(id, contractor, region, equipment, quantity) VALUES (1, 'Green Defence', 'Asia', 'Radar Systems', 100); | Calculate the average sale quantity for 'Green Defence' in each region. | SELECT region, AVG(quantity) FROM GreenDefenceSales GROUP BY region; | gretelai_synthetic_text_to_sql |
CREATE TABLE disasters (disaster_id INT, disaster_name TEXT, location TEXT, disaster_date DATE); | Insert a new disaster record for 'Hurricane Maria' in 'Puerto Rico' with a date of '2017-09-20'. | INSERT INTO disasters (disaster_id, disaster_name, location, disaster_date) SELECT NULL, 'Hurricane Maria', 'Puerto Rico', '2017-09-20'; | gretelai_synthetic_text_to_sql |
CREATE TABLE gas_production (well_id INT, location VARCHAR(20), daily_production FLOAT); INSERT INTO gas_production (well_id, location, daily_production) VALUES (1, 'Shtokman field', 2500.1), (2, 'Troll gas field', 2200.2); | Find the daily production of gas wells in the Shtokman field and the Troll gas field | SELECT location, daily_production FROM gas_production WHERE location IN ('Shtokman field', 'Troll gas field'); | gretelai_synthetic_text_to_sql |
CREATE TABLE soccer_stats (player VARCHAR(50), team VARCHAR(50), position VARCHAR(50), saves INT); INSERT INTO soccer_stats (player, team, position, saves) VALUES ('David de Gea', 'Manchester United', 'Goalkeeper', 8), ('Thibaut Courtois', 'Real Madrid', 'Goalkeeper', 6), ('Alisson Becker', 'Liverpool', 'Goalkeeper', 7... | What is the average number of saves made by goalkeepers in the 'soccer_stats' table? | SELECT AVG(saves) FROM soccer_stats WHERE position = 'Goalkeeper'; | gretelai_synthetic_text_to_sql |
CREATE TABLE cities (id INT, name VARCHAR(255));CREATE TABLE cultural_events (id INT, title VARCHAR(255), city_id INT, start_date DATE, end_date DATE, attendees INT); | How many cultural events were held in Paris, and what was the total attendance? | SELECT SUM(attendees) as total_attendance FROM cultural_events WHERE city_id = (SELECT id FROM cities WHERE name = 'Paris'); | gretelai_synthetic_text_to_sql |
CREATE TABLE suppliers (id INT, name TEXT, country TEXT);CREATE TABLE supplier_factories (supplier_id INT, factory_id INT); | Delete records from 'suppliers' table that are not present in 'supplier_factories' table | DELETE FROM suppliers WHERE id NOT IN (SELECT supplier_id FROM supplier_factories); | gretelai_synthetic_text_to_sql |
CREATE TABLE country (country_code VARCHAR(3), country_name VARCHAR(50)); INSERT INTO country VALUES ('USA', 'United States'), ('CHN', 'China'), ('IND', 'India'); CREATE TABLE project (project_id INT, project_name VARCHAR(50), country_code VARCHAR(3), mitigation BOOLEAN); INSERT INTO project VALUES (1, 'Solar Farm', ... | What is the total amount of climate finance committed by each country for mitigation projects in 2020? | SELECT c.country_name, SUM(f.amount) FROM country c JOIN project p ON c.country_code = p.country_code JOIN finance f ON p.project_id = f.project_id WHERE p.mitigation = true AND f.year = 2020 GROUP BY c.country_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE VehicleCO2Emissions (vehicle_id INT, model VARCHAR(100), co2_emissions DECIMAL(5,2), country VARCHAR(50), year INT); INSERT INTO VehicleCO2Emissions (vehicle_id, model, co2_emissions, country, year) VALUES (1, 'Model S', 150, 'Japan', 2020), (2, 'Leaf', 0, 'Japan', 2020); | What is the total CO2 emission of vehicles sold in Japan in 2020? | SELECT SUM(co2_emissions) FROM VehicleCO2Emissions WHERE country = 'Japan' AND year = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE suppliers (id INT, name TEXT); CREATE TABLE products (id INT, supplier_id INT, name TEXT, is_fair_trade BOOLEAN, category TEXT); INSERT INTO suppliers (id, name) VALUES (1, 'Supplier A'), (2, 'Supplier B'), (3, 'Supplier C'), (4, 'Supplier D'); INSERT INTO products (id, supplier_id, name, is_fair_trade, ca... | Which suppliers provide the most diverse selection of fair trade products? | SELECT supplier_id, COUNT(*) FROM products WHERE is_fair_trade = true GROUP BY supplier_id ORDER BY COUNT(*) DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE gymnastics_athletes (athlete_name VARCHAR(100), age INT, total_gold INT, total_silver INT, total_bronze INT); INSERT INTO gymnastics_athletes VALUES ('Dominique Moceanu', 14, 1, 0, 1), ('Simone Biles', 19, 4, 1, 1), ('Gabby Douglas', 16, 2, 0, 1), ('Nadia Comăneci', 14, 5, 3, 1); | Who is the youngest athlete to win a gold medal in gymnastics? | SELECT athlete_name, age, total_gold FROM gymnastics_athletes WHERE total_gold > 0 ORDER BY age ASC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE bills (customer_id INT, plan_type VARCHAR(10), region VARCHAR(20), bill FLOAT); INSERT INTO bills (customer_id, plan_type, region, bill) VALUES (1, 'postpaid', 'Chicago', 100), (2, 'prepaid', 'Chicago', 50); CREATE TABLE customer_demographics (customer_id INT, plan_type VARCHAR(10), region VARCHAR(20)); IN... | What is the average monthly bill for customers with the same plan type and region? | SELECT AVG(b.bill) FROM bills b JOIN customer_demographics cd ON b.customer_id = cd.customer_id WHERE b.plan_type = cd.plan_type AND b.region = cd.region; | gretelai_synthetic_text_to_sql |
CREATE TABLE production (country VARCHAR(255), year INT, amount INT); INSERT INTO production (country, year, amount) VALUES ('China', 2019, 120000), ('China', 2020, 140000), ('USA', 2019, 36000), ('USA', 2020, 38000), ('Australia', 2019, 18000), ('Australia', 2020, 20000), ('India', 2019, 4000), ('India', 2020, 5000); | What was the production trend for all countries from 2019 to 2020? | SELECT country, year, amount, LAG(amount, 1) OVER (PARTITION BY country ORDER BY year) AS previous_year_production FROM production; | gretelai_synthetic_text_to_sql |
CREATE TABLE users (id INT, city VARCHAR(20)); INSERT INTO users (id, city) VALUES (1, 'Paris'), (2, 'London'), (3, 'Paris'); CREATE TABLE user_virtual_tours (user_id INT, tour_count INT); INSERT INTO user_virtual_tours (user_id, tour_count) VALUES (1, 5), (1, 3), (2, 2), (3, 4), (3, 4); | Who are the top 3 users in Paris with the most virtual tours? | SELECT user_id, SUM(tour_count) AS total_tours FROM user_virtual_tours GROUP BY user_id ORDER BY total_tours DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE Artists (ArtistID int, Name varchar(50), Nationality varchar(50)); INSERT INTO Artists VALUES (1, 'Pablo Picasso', 'Spanish'); INSERT INTO Artists VALUES (2, 'Andy Warhol', 'American'); INSERT INTO Artists VALUES (3, 'Mohammed Ali', 'Egyptian'); INSERT INTO Artists VALUES (4, 'Anju Jain', 'Indian'); CREATE... | What is the average sales of artwork created by artists from Asia? | SELECT AVG(Artworks.Sales) FROM Artworks JOIN Artists ON Artworks.ArtistID = Artists.ArtistID WHERE Artists.Nationality = 'Indian'; | gretelai_synthetic_text_to_sql |
CREATE TABLE air_force_recruits (recruit_id INT, name VARCHAR(50), rank VARCHAR(50), join_date DATE); | Insert records of new recruits who joined the air force in 2022 into the air_force_recruits table | INSERT INTO air_force_recruits (recruit_id, name, rank, join_date) VALUES (1, 'Fatima Al-Khalifa', 'Second Lieutenant', '2022-02-14'), (2, 'Raul Garcia', 'Airman', '2022-06-01'), (3, 'Hana Khan', 'Airman', '2022-10-15'); | gretelai_synthetic_text_to_sql |
CREATE TABLE coowners (coowner_id INT, coowner_name VARCHAR(255), coowner_contact_details VARCHAR(255)); | Create a table named "coowners" with columns "coowner_id", "coowner_name", and "coowner_contact_details" | CREATE TABLE coowners (coowner_id INT, coowner_name VARCHAR(255), coowner_contact_details VARCHAR(255)); | gretelai_synthetic_text_to_sql |
CREATE TABLE industrial_facilities (id INT, province VARCHAR(20), water_usage FLOAT); INSERT INTO industrial_facilities (id, province, water_usage) VALUES (1, 'Ontario', 450), (2, 'Ontario', 400), (3, 'Ontario', 500); | What is the minimum water usage in industrial facilities in Ontario? | SELECT MIN(water_usage) FROM industrial_facilities WHERE province = 'Ontario'; | gretelai_synthetic_text_to_sql |
CREATE TABLE RestaurantInfo(restaurant_id INT, state VARCHAR(255), food_safety_score INT); | What is the minimum food safety score for restaurants located in Texas? | SELECT MIN(food_safety_score) FROM RestaurantInfo WHERE state = 'Texas'; | gretelai_synthetic_text_to_sql |
CREATE TABLE clinical_trials (id INT, trial_name VARCHAR(255), country VARCHAR(255)); INSERT INTO clinical_trials (id, trial_name, country) VALUES (1, 'TrialA', 'USA'), (2, 'TrialB', 'Germany'), (3, 'TrialC', 'Kenya'), (4, 'TrialD', 'Nigeria'); | Which clinical trials were conducted in Africa? | SELECT trial_name FROM clinical_trials WHERE country IN ('Kenya', 'Nigeria'); | gretelai_synthetic_text_to_sql |
CREATE TABLE gold_mines (id INT, name TEXT, location TEXT, production_rate INT); INSERT INTO gold_mines (id, name, location, production_rate) VALUES (1, 'Barrick Goldstrike', 'USA', 1500), (2, 'Nevada Gold Mines', 'USA', 2000), (3, 'Grasberg', 'Indonesia', 500); | Delete mines from the gold_mines table that have a production rate less than 1000. | DELETE FROM gold_mines WHERE production_rate < 1000; | gretelai_synthetic_text_to_sql |
CREATE TABLE Tournaments (TournamentID INT, TournamentName VARCHAR(20), Position INT, PlayerID INT); INSERT INTO Tournaments (TournamentID, TournamentName, Position, PlayerID) VALUES (1, 'Evo', 1, 101); INSERT INTO Tournaments (TournamentID, TournamentName, Position, PlayerID) VALUES (2, 'Dreamhack', 3, 102); | How many players won or placed in the top 3 in each esports tournament? | SELECT TournamentName, COUNT(*) as TopThree FROM Tournaments WHERE Position <= 3 GROUP BY TournamentName | gretelai_synthetic_text_to_sql |
CREATE TABLE fans (id INT, name VARCHAR(50)); CREATE TABLE events (id INT, event_type VARCHAR(20), tickets_bought INT); INSERT INTO fans (id, name) VALUES (1, 'John Doe'), (2, 'Jane Smith'), (3, 'Richard Roe'); INSERT INTO events (id, event_type, tickets_bought) VALUES (1, 'Concert', 2), (1, 'Sports', 1), (2, 'Concert'... | Find the total number of fans who have attended sports events and concerts separately. | SELECT SUM(CASE WHEN event_type = 'Concert' THEN tickets_bought ELSE 0 END) + SUM(CASE WHEN event_type = 'Sports' THEN tickets_bought ELSE 0 END) FROM events INNER JOIN fans ON events.id = fans.id; | gretelai_synthetic_text_to_sql |
CREATE TABLE products (product_id INT, category VARCHAR(20), is_ethically_sourced BOOLEAN, price DECIMAL(5,2)); INSERT INTO products (product_id, category, is_ethically_sourced, price) VALUES (1, 'accessories', true, 50.99), (2, 'accessories', false, 45.00); | What is the average price of ethically sourced products in the 'accessories' category? | SELECT AVG(price) FROM products WHERE category = 'accessories' AND is_ethically_sourced = true; | gretelai_synthetic_text_to_sql |
CREATE TABLE excavation_sites (id INT, country VARCHAR(50), num_artifacts INT, total_weight INT); | What was the average weight of pottery artifacts found in each country? | SELECT country, AVG(total_weight / num_artifacts) as avg_weight FROM excavation_sites | gretelai_synthetic_text_to_sql |
CREATE TABLE LuxuryElectricVehicles (id INT, make VARCHAR(50), model VARCHAR(50), safetyrating INT, electric BOOLEAN, autonomous BOOLEAN); | What is the average safety rating for luxury electric vehicles in the luxuryelectricvehicles schema? | SELECT AVG(safetyrating) FROM luxuryelectricvehicles.LuxuryElectricVehicles WHERE electric = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE Properties (PropertyID int, Price int, Borough varchar(255), SustainabilityRating int); INSERT INTO Properties (PropertyID, Price, Borough, SustainabilityRating) VALUES (1, 350000, 'Manhattan', 2); | How many properties in each borough have a SustainabilityRating of at least 2? | SELECT Borough, COUNT(*) as PropertyCount FROM Properties WHERE SustainabilityRating >= 2 GROUP BY Borough; | gretelai_synthetic_text_to_sql |
CREATE TABLE vulnerabilities (id INT, sector TEXT, country TEXT, severity_score INT); INSERT INTO vulnerabilities (id, sector, country, severity_score) VALUES (1, 'Education', 'Canada', 5); INSERT INTO vulnerabilities (id, sector, country, severity_score) VALUES (2, 'Education', 'USA', 7); INSERT INTO vulnerabilities (... | What is the minimum severity score for vulnerabilities in the education sector in Canada? | SELECT MIN(severity_score) FROM vulnerabilities WHERE sector = 'Education' AND country = 'Canada'; | gretelai_synthetic_text_to_sql |
CREATE TABLE urban_farms (id INT, name VARCHAR(255), year INT, production INT); | Which urban farms have produced more than 100 tons of food in 2022? | SELECT name, production FROM urban_farms WHERE year = 2022 AND production > 100000; | gretelai_synthetic_text_to_sql |
CREATE TABLE drilling_rigs (rig_id INT, rig_name VARCHAR(50), region VARCHAR(50), commission_date DATE); INSERT INTO drilling_rigs VALUES (1, 'Rig A', 'Gulf of Mexico', '2016-01-01'); INSERT INTO drilling_rigs VALUES (2, 'Rig B', 'North Sea', '2014-01-01'); INSERT INTO drilling_rigs VALUES (3, 'Rig C', 'Gulf of Mexico'... | What are the names of all drilling rigs in the 'Gulf of Mexico' that were commissioned after 2015? | SELECT rig_name FROM drilling_rigs WHERE region = 'Gulf of Mexico' AND commission_date > '2015-01-01'; | gretelai_synthetic_text_to_sql |
CREATE TABLE strains (id INT, name TEXT, origin TEXT); INSERT INTO strains (id, name, origin) VALUES (1, 'Strain A', 'Oregon'); INSERT INTO strains (id, name, origin) VALUES (2, 'Strain B', 'Oregon'); CREATE TABLE inventory (dispensary_id INT, strain_id INT, quantity INT, availability_date DATE); INSERT INTO inventory ... | How many unique strains were available in Oregon dispensaries in 2021? | SELECT COUNT(DISTINCT s.id) as unique_strains FROM strains s JOIN inventory i ON s.id = i.strain_id WHERE i.availability_date BETWEEN '2021-01-01' AND '2021-12-31' AND s.origin = 'Oregon'; | gretelai_synthetic_text_to_sql |
CREATE TABLE public_transportation (id INT, system_name VARCHAR(255), location VARCHAR(255), daily_passengers INT); | How many public transportation systems in the 'public_transportation' table serve more than 1,000,000 passengers daily? | SELECT COUNT(*) FROM public_transportation WHERE daily_passengers > 1000000; | gretelai_synthetic_text_to_sql |
CREATE TABLE patient_treatment (patient_id INT, age INT, treatment_type VARCHAR(255), condition VARCHAR(255)); | What is the average age of patients who have received treatment for depression or anxiety in the patient_treatment table, grouped by the type of treatment? | SELECT treatment_type, AVG(age) FROM patient_treatment WHERE condition IN ('depression', 'anxiety') GROUP BY treatment_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE hospitals (id INT, name TEXT, location TEXT, num_staff INT, province TEXT); INSERT INTO hospitals (id, name, location, num_staff, province) VALUES (1, 'Hospital A', 'Rural Quebec', 100, 'Quebec'), (2, 'Hospital B', 'Rural Ontario', 150, 'Ontario'); CREATE TABLE clinics (id INT, name TEXT, location TEXT, nu... | What is the number of rural hospitals and clinics in each province, and the number of healthcare professionals working in each? | SELECT p.province, COUNT(h.id) AS num_hospitals, SUM(h.num_staff) AS hospital_staff, COUNT(c.id) AS num_clinics, SUM(c.num_staff) AS clinic_staff FROM hospitals h INNER JOIN clinics c ON p.province = c.province GROUP BY p.province; | gretelai_synthetic_text_to_sql |
CREATE TABLE Exhibitions (id INT, museum_id INT, name VARCHAR(255), visitor_count INT); CREATE TABLE Museums (id INT, name VARCHAR(255), region VARCHAR(255)); INSERT INTO Exhibitions (id, museum_id, name, visitor_count) VALUES (1, 1, 'African Art', 500), (2, 2, 'Egyptian Antiquities', 800), (3, 3, 'Modern Art', 300); I... | List all exhibitions with their visitor count for museums in Africa. | SELECT e.name, e.visitor_count FROM Exhibitions e JOIN Museums m ON e.museum_id = m.id WHERE m.region = 'Africa'; | gretelai_synthetic_text_to_sql |
CREATE TABLE blue_line_fares (fare int); INSERT INTO blue_line_fares (fare) VALUES (2), (3), (4); | What is the maximum fare for 'Blue' line rides? | SELECT MAX(fare) FROM blue_line_fares; | gretelai_synthetic_text_to_sql |
CREATE TABLE african_improvements (id INT, condition TEXT, approach TEXT, region TEXT, improvement FLOAT); INSERT INTO african_improvements (id, condition, approach, region, improvement) VALUES (1, 'Depression', 'CBT', 'Africa', 0.6), (2, 'Anxiety', 'DBT', 'Africa', 0.5), (3, 'PTSD', 'EMDR', 'Africa', 0.7), (4, 'Depres... | Identify the mental health condition with the lowest improvement rate for patients in Africa, along with the associated treatment approach. | SELECT condition, approach, MIN(improvement) as min_improvement FROM african_improvements WHERE region = 'Africa' GROUP BY condition, approach; | gretelai_synthetic_text_to_sql |
CREATE TABLE traditional_arts_centers_country (id INT, center_name VARCHAR(100), size INT, country VARCHAR(50)); INSERT INTO traditional_arts_centers_country (id, center_name, size, country) VALUES (1, 'Folk Arts Center', 2000, 'USA'), (2, 'Western Arts Center', 3000, 'Canada'); | What is the average size of traditional arts centers by country? | SELECT country, AVG(size) as avg_size FROM traditional_arts_centers_country GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE volunteers (volunteer_id INT, volunteer_name TEXT, volunteer_region TEXT, volunteer_join_date DATE); INSERT INTO volunteers (volunteer_id, volunteer_name, volunteer_region, volunteer_join_date) VALUES (1, 'Bob Doe', 'North America', '2020-01-01'); | List the number of volunteers who joined per month in 'North America' in the year 2020? | SELECT EXTRACT(MONTH FROM volunteer_join_date) AS month, COUNT(*) AS volunteers_joined FROM volunteers WHERE volunteer_region = 'North America' AND EXTRACT(YEAR FROM volunteer_join_date) = 2020 GROUP BY month ORDER BY month; | gretelai_synthetic_text_to_sql |
CREATE TABLE Economic_Diversification(farmer_id INT, farmer_name VARCHAR(50), country VARCHAR(50), funding FLOAT); INSERT INTO Economic_Diversification(farmer_id, farmer_name, country, funding) VALUES (1, 'John Doe', 'Canada', 8000), (2, 'Jane Smith', 'Mexico', 11000); | What is the minimum, maximum, and average amount of funding received per farmer in the 'Economic Diversification' program in 'North America'? | SELECT MIN(funding) as min_funding, MAX(funding) as max_funding, AVG(funding) as avg_funding FROM Economic_Diversification WHERE country = 'North America'; | gretelai_synthetic_text_to_sql |
CREATE TABLE revenue (transaction_id INT, region TEXT, revenue FLOAT); INSERT INTO revenue (transaction_id, region, revenue) VALUES (1, 'Asia', 1200), (2, 'Europe', 800); | What is the revenue impact of virtual tours in Asia? | SELECT SUM(revenue) FROM revenue WHERE region = 'Asia'; | gretelai_synthetic_text_to_sql |
CREATE TABLE country_incident_duration (id INT, country VARCHAR(255), incident_time TIMESTAMP, duration INT); | What are the top 3 countries with the longest average duration of security incidents in the last quarter? | SELECT country, AVG(duration) as average_duration FROM country_incident_duration WHERE incident_time >= DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 3 MONTH) GROUP BY country ORDER BY average_duration DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE regulatory_frameworks (framework_id INT PRIMARY KEY, name VARCHAR(255), description TEXT, country VARCHAR(255), enforcement_date DATE); | Update the 'description' of regulatory framework 'GDPR' in the 'regulatory_frameworks' table | UPDATE regulatory_frameworks SET description = 'General Data Protection Regulation' WHERE name = 'GDPR'; | gretelai_synthetic_text_to_sql |
CREATE TABLE crime_stats (id INT, year INT, month INT, type VARCHAR(255), PRIMARY KEY(id)); | Update 'crime_stats' table to set all 'theft' records for '2020' to 'burglary' | UPDATE crime_stats SET type = 'burglary' WHERE year = 2020 AND type = 'theft'; | gretelai_synthetic_text_to_sql |
CREATE TABLE JobRoles (EmployeeID INT, FirstName VARCHAR(50), LastName VARCHAR(50), Age INT, JobRole VARCHAR(50), MineName VARCHAR(50), Salary DECIMAL(10,2)); INSERT INTO JobRoles (EmployeeID, FirstName, LastName, Age, JobRole, MineName, Salary) VALUES (1, 'David', 'Lee', 45, 'Mining Engineer', 'ABC Mine', 75000.00); I... | What is the average salary for each job role, along with the number of employees in that job role? | SELECT JobRole, AVG(Salary) as 'AvgSalary', COUNT(*) as 'EmployeeCount' FROM JobRoles GROUP BY JobRole; | gretelai_synthetic_text_to_sql |
CREATE TABLE Military_Equipment_Sales (sale_id INT, year INT, country VARCHAR(50), value FLOAT); INSERT INTO Military_Equipment_Sales (sale_id, year, country, value) VALUES (1, 2015, 'India', 3000000), (2, 2016, 'India', 4000000), (3, 2017, 'India', 5000000); | What is the maximum value of military equipment sales to India in any year? | SELECT MAX(value) FROM Military_Equipment_Sales WHERE country = 'India'; | gretelai_synthetic_text_to_sql |
CREATE TABLE SatelliteLaunches (id INT PRIMARY KEY, country VARCHAR(255), launch_date DATE); CREATE TABLE Satellites (id INT PRIMARY KEY, name VARCHAR(255), launch_id INT, FOREIGN KEY (launch_id) REFERENCES SatelliteLaunches(id)); | Which country launched the fewest satellites? | SELECT country, COUNT(s.id) as num_satellites FROM SatelliteLaunches l LEFT JOIN Satellites s ON l.id = s.launch_id GROUP BY country ORDER BY num_satellites ASC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE PlayerDemographics (PlayerID INT, Gender VARCHAR(10), VRTechnology BOOLEAN); INSERT INTO PlayerDemographics (PlayerID, Gender, VRTechnology) VALUES (1, 'Female', TRUE), (2, 'Male', FALSE), (3, 'Female', TRUE); CREATE TABLE Playtime (PlayerID INT, Playtime INT); INSERT INTO Playtime (PlayerID, Playtime) VAL... | What is the average playtime for female players who use VR technology? | SELECT AVG(Playtime) FROM PlayerDemographics INNER JOIN Playtime ON PlayerDemographics.PlayerID = Playtime.PlayerID WHERE Gender = 'Female' AND VRTechnology = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE posts (id INT, content TEXT, likes INT, timestamp DATETIME); INSERT INTO posts (id, content, likes, timestamp) VALUES (1, 'This is a post about sustainability', 100, '2022-03-01 10:00:00'), (2, 'Another post about sustainability', 150, '2022-03-03 14:30:00'); | What is the average number of likes on posts containing the hashtag #sustainability, per day, for the past week? | SELECT AVG(likes) FROM posts WHERE content LIKE '%#sustainability%' AND timestamp BETWEEN DATE_SUB(NOW(), INTERVAL 1 WEEK) AND NOW(); | gretelai_synthetic_text_to_sql |
CREATE TABLE wind_projects (id INT, name VARCHAR(255), location VARCHAR(255), annual_energy_savings INT); | What is the average annual energy savings per project for wind power initiatives? | SELECT AVG(annual_energy_savings) FROM wind_projects WHERE location LIKE '%United States%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE threat_intelligence (id INT PRIMARY KEY, threat_category TEXT, threat_subcategory TEXT, indicator TEXT); | What is the total number of threat indicators in the 'threat_intelligence' table for each threat category and subcategory? | SELECT threat_category, threat_subcategory, COUNT(*) FROM threat_intelligence GROUP BY threat_category, threat_subcategory; | gretelai_synthetic_text_to_sql |
CREATE TABLE Donations (donation_id INT, donor_id INT, cause TEXT, amount DECIMAL); CREATE TABLE Donors (donor_id INT, donor_name TEXT, country TEXT); | Who is the top donor to education initiatives in India? | SELECT donor_name, SUM(amount) as total_donated FROM Donations JOIN Donors ON Donations.donor_id = Donors.donor_id WHERE cause = 'education' AND country = 'India' GROUP BY donor_id ORDER BY total_donated DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE donations (id INT, donor_id INT, program_id INT, donation_amount DECIMAL, donation_date DATE); | What is the maximum donation amount for each program? | SELECT programs.name as program_name, MAX(donations.donation_amount) as max_donation_amount FROM donations INNER JOIN programs ON donations.program_id = programs.id GROUP BY programs.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE temperature_anomaly (region varchar(255), year int, anomaly decimal(10,2)); INSERT INTO temperature_anomaly (region, year, anomaly) VALUES ('Indian Ocean', 2017, 1.10), ('Indian Ocean', 2018, 1.30), ('Indian Ocean', 2019, 1.40); | What is the average temperature anomaly in the Indian Ocean in 2019? | SELECT AVG(anomaly) FROM temperature_anomaly WHERE region = 'Indian Ocean' AND year = 2019; | gretelai_synthetic_text_to_sql |
CREATE TABLE users (id INT, country VARCHAR(255), category VARCHAR(255), followers INT); INSERT INTO users (id, country, category, followers) VALUES (1, 'Australia', 'art', 200); | How many users from Australia in the art category have less than 500 followers? | SELECT COUNT(DISTINCT users.id) FROM users WHERE users.country = 'Australia' AND users.category = 'art' AND users.followers < 500; | gretelai_synthetic_text_to_sql |
CREATE TABLE community_development (id INT, country VARCHAR(255), initiative VARCHAR(255), cost FLOAT, year INT); INSERT INTO community_development (id, country, initiative, cost, year) VALUES (1, 'India', 'Education Program', 250000, 2019), (2, 'India', 'Healthcare Program', 300000, 2020), (3, 'India', 'Clean Water Ac... | Which community development initiatives had the highest average cost in India between 2019 and 2021? | SELECT initiative, AVG(cost) as avg_cost FROM community_development WHERE country = 'India' AND year BETWEEN 2019 AND 2021 GROUP BY initiative ORDER BY avg_cost DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE programs (program_id INT, program_type VARCHAR(20)); CREATE TABLE participants (participant_id INT, program_id INT, role VARCHAR(20), country VARCHAR(20)); INSERT INTO programs (program_id, program_type) VALUES (1, 'Restorative Justice'); INSERT INTO participants (participant_id, program_id, role, country)... | What is the count of victims who participated in restorative justice programs in Canada? | SELECT COUNT(*) FROM participants WHERE program_id = 1 AND country = 'Canada' AND role = 'Victim'; | gretelai_synthetic_text_to_sql |
CREATE TABLE indigenous_communities (name TEXT, location TEXT); | List the names of all indigenous communities in the arctic research area. | SELECT name FROM indigenous_communities; | gretelai_synthetic_text_to_sql |
CREATE TABLE Buildings (BuildingID INT, BuildingType VARCHAR(50), EnergyConsumption FLOAT); INSERT INTO Buildings (BuildingID, BuildingType, EnergyConsumption) VALUES (1, 'Residential', 12000), (2, 'Commercial', 25000); | What is the total energy consumption for each building type? | SELECT BuildingType, SUM(EnergyConsumption) AS TotalEnergyConsumption FROM Buildings GROUP BY BuildingType; | gretelai_synthetic_text_to_sql |
CREATE TABLE Donors (DonorID INT, DonorType VARCHAR(10), DonorName VARCHAR(50), Amount DECIMAL(10,2)); INSERT INTO Donors (DonorID, DonorType, DonorName, Amount) VALUES (1, 'Individual', 'John Doe', 150.00), (2, 'Organization', 'ABC Corp', 5000.00), (3, 'Individual', 'Jane Smith', 250.00), (4, 'Individual', 'Mary Johns... | Who are the top 3 individual donors based on the total amount donated? | SELECT DonorName FROM Donors WHERE DonorType = 'Individual' ORDER BY Amount DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE Hospitals (HospitalID INT, Name VARCHAR(50), City VARCHAR(30), State VARCHAR(20), TotalBeds INT); INSERT INTO Hospitals (HospitalID, Name, City, State, TotalBeds) VALUES (1, 'Mount Sinai', 'New York City', 'New York', 700); INSERT INTO Hospitals (HospitalID, Name, City, State, TotalBeds) VALUES (2, 'NYU La... | What is the total number of hospital beds available in hospitals in New York City? | SELECT SUM(TotalBeds) FROM Hospitals WHERE City = 'New York City'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Farmers (FarmerID INT, FarmerName TEXT, Location TEXT); INSERT INTO Farmers (FarmerID, FarmerName, Location) VALUES (1, 'Juan Apaza', 'Andean Region'); CREATE TABLE Production (ProductID INT, FarmerID INT, Product TEXT, Quantity INT); INSERT INTO Production (ProductID, FarmerID, Product, Quantity) VALUES (... | What is the total production of 'Quinoa' by each farmer in 'Andean Region'? | SELECT Farmers.FarmerName, SUM(Production.Quantity) as TotalQuinoaProduction FROM Farmers INNER JOIN Production ON Farmers.FarmerID = Production.FarmerID WHERE Production.Product = 'Quinoa' AND Farmers.Location = 'Andean Region' GROUP BY Farmers.FarmerName; | gretelai_synthetic_text_to_sql |
CREATE TABLE hospitals (id INT, name TEXT, city TEXT, state TEXT); INSERT INTO hospitals (id, name, city, state) VALUES (1, 'Hospital A', 'New York', 'NY'); INSERT INTO hospitals (id, name, city, state) VALUES (2, 'Hospital B', 'Los Angeles', 'CA'); INSERT INTO hospitals (id, name, city, state) VALUES (3, 'Hospital C',... | Find the number of hospitals in each city and state. | SELECT city, state, COUNT(*) FROM hospitals GROUP BY city, state; | gretelai_synthetic_text_to_sql |
CREATE TABLE concert_ticket_sales (concert_name VARCHAR(255), num_tickets_sold INT); | What is the maximum number of tickets sold for a single concert in the 'concert_ticket_sales' table? | SELECT MAX(num_tickets_sold) as max_tickets_sold FROM concert_ticket_sales; | gretelai_synthetic_text_to_sql |
CREATE TABLE sensor_data (sensor_id INT, temperature FLOAT, reading_time TIMESTAMP); INSERT INTO sensor_data (sensor_id, temperature, reading_time) VALUES (1, 23.5, '2022-01-01 10:00:00'), (2, 25.3, '2022-01-01 10:00:00'); | What is the average temperature reading for each sensor in the 'sensor_data' table? | SELECT sensor_id, AVG(temperature) OVER (PARTITION BY sensor_id) FROM sensor_data; | gretelai_synthetic_text_to_sql |
CREATE TABLE Brands (id INT, brand VARCHAR(255), region VARCHAR(255)); INSERT INTO Brands (id, brand, region) VALUES (1, 'EcoBrandA', 'North America'), (2, 'EcoBrandB', 'Europe'), (3, 'EcoBrandC', 'Asia'); CREATE TABLE Sales (id INT, brand_id INT, product VARCHAR(255), quantity INT, region VARCHAR(255)); INSERT INTO Sa... | What is the total quantity of eco-friendly products sold, by brand and region? | SELECT s.region, b.brand, SUM(s.quantity) AS total_quantity FROM Sales s JOIN Brands b ON s.brand_id = b.id JOIN Products p ON s.product = p.id WHERE p.eco_friendly = true GROUP BY s.region, b.brand; | gretelai_synthetic_text_to_sql |
CREATE TABLE tickets (ticket_id INT, game_id INT, price INT, sale_date DATE); INSERT INTO tickets (ticket_id, game_id, price, sale_date) VALUES (1, 1, 50, '2021-09-01'), (2, 2, 60, '2021-10-01'); CREATE TABLE games (game_id INT, sport VARCHAR(20), city VARCHAR(20), game_date DATE); INSERT INTO games (game_id, sport, ci... | What is the total revenue from ticket sales for football games in Texas and California in the last year? | SELECT SUM(tickets.price) FROM tickets INNER JOIN games ON tickets.game_id = games.game_id WHERE games.sport = 'Football' AND (games.city = 'Texas' OR games.city = 'California') AND tickets.sale_date >= DATEADD(year, -1, GETDATE()); | gretelai_synthetic_text_to_sql |
CREATE TABLE Ports (PortID INT, Name VARCHAR(255), Country VARCHAR(255)); CREATE TABLE Cargo (CargoID INT, PortID INT, Weight INT); INSERT INTO Ports (PortID, Name, Country) VALUES (1, 'Shanghai', 'China'), (2, 'Singapore', 'Singapore'), (3, 'Hong Kong', 'Hong Kong'); INSERT INTO Cargo (CargoID, PortID, Weight) VALUES ... | What is the total cargo weight handled by each port in Asia excluding ports in China? | SELECT Ports.Name, SUM(Cargo.Weight) FROM Ports INNER JOIN Cargo ON Ports.PortID = Cargo.PortID WHERE Ports.Country NOT LIKE 'China%' GROUP BY Ports.Name; | gretelai_synthetic_text_to_sql |
CREATE TABLE court_cases (court_type VARCHAR(20), year INT, num_cases INT); INSERT INTO court_cases (court_type, year, num_cases) VALUES ('Supreme Court', 2021, 1200), ('District Court', 2021, 4500), ('Appellate Court', 2021, 800); | What was the total number of cases heard in each court type last year? | SELECT court_type, SUM(num_cases) as total_cases FROM court_cases WHERE year = 2021 GROUP BY court_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE animal_data (sanctuary_id INT, animal_type VARCHAR(255), animal_count INT, endangered BOOLEAN); INSERT INTO animal_data (sanctuary_id, animal_type, animal_count, endangered) VALUES (1, 'Tiger', 25, TRUE), (1, 'Elephant', 30, FALSE), (2, 'Tiger', 35, FALSE), (2, 'Elephant', 20, TRUE), (3, 'Tiger', 15, TRUE)... | What is the total number of animals in each sanctuary, excluding those that are endangered? | SELECT sanctuary_id, SUM(animal_count) AS total_animals FROM animal_data WHERE NOT endangered GROUP BY sanctuary_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE articles (id INT, title VARCHAR(255), topic VARCHAR(50), publication_year INT); INSERT INTO articles (id, title, topic, publication_year) VALUES (1, 'Article1', 'Culture', 2020), (2, 'Article2', 'Politics', 2019), (3, 'Article3', 'Culture', 2018), (4, 'Article4', 'Science', 2020), (5, 'Article5', 'Culture'... | What is the distribution of articles by topic in 2020? | SELECT topic, COUNT(*) as count FROM articles WHERE publication_year = 2020 GROUP BY topic ORDER BY count DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE mining_sites(id INT, site VARCHAR(50), accidents INT); INSERT INTO mining_sites (id, site, accidents) VALUES (1, 'Surface', 5), (2, 'Underground', 3); | How many accidents occurred at the 'Surface' and 'Underground' mining sites? | SELECT SUM(accidents) FROM mining_sites WHERE site IN ('Surface', 'Underground'); | gretelai_synthetic_text_to_sql |
CREATE TABLE WindFarms ( FarmID INT, Name VARCHAR(255), Country VARCHAR(255), InstalledCapacity FLOAT ); | What is the total installed capacity of Wind Farms in GW? | SELECT SUM(InstalledCapacity) FROM WindFarms WHERE Country = 'Germany'; | gretelai_synthetic_text_to_sql |
CREATE TABLE restaurants (id INT, name VARCHAR(255), category VARCHAR(255), food_safety_score INT); INSERT INTO restaurants (id, name, category, food_safety_score) VALUES (1, 'Fast Food Frenzy', 'Quick Service', 90), (2, 'Bistro Bites', 'Fine Dining', 95), (3, 'Green Garden', 'Quick Service', 80); | Which restaurants have a food safety score below 85? | SELECT name FROM restaurants WHERE food_safety_score < 85; | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_species (name VARCHAR(255), region VARCHAR(255), affected_by_ocean_acidification BOOLEAN); INSERT INTO marine_species (name, region, affected_by_ocean_acidification) VALUES ('Polar Bear', 'Arctic', true), ('Narwhal', 'Arctic', true), ('Arctic Fox', 'Arctic', false); | List all marine species that are affected by ocean acidification in the Arctic region. | SELECT name FROM marine_species WHERE region = 'Arctic' AND affected_by_ocean_acidification = true; | gretelai_synthetic_text_to_sql |
CREATE TABLE OnlineStore (id INT, date DATE, revenue DECIMAL(10, 2)); INSERT INTO OnlineStore (id, date, revenue) VALUES (1, '2022-01-01', 500.00); INSERT INTO OnlineStore (id, date, revenue) VALUES (2, '2022-01-02', 750.00); | Calculate total revenue for the museum's online store for the last quarter | SELECT SUM(revenue) FROM OnlineStore WHERE date BETWEEN DATE_SUB(CURRENT_DATE, INTERVAL 90 DAY) AND CURRENT_DATE; | gretelai_synthetic_text_to_sql |
CREATE TABLE mining_companies (id INT, name VARCHAR(50), region VARCHAR(50)); INSERT INTO mining_companies (id, name, region) VALUES (1, 'Alpha Coal', 'Western'), (2, 'Beta Mining', 'Eastern'); CREATE TABLE coal_production (company_id INT, amount INT, year INT); INSERT INTO coal_production (company_id, amount, year) VA... | What is the total amount of coal mined by each mining company in the Western region? | SELECT mc.name, SUM(cp.amount) as total_coal_mined FROM mining_companies mc INNER JOIN coal_production cp ON mc.id = cp.company_id WHERE mc.region = 'Western' GROUP BY mc.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE ota_data (hotel_id INT, location VARCHAR(20), ota VARCHAR(20), commission DECIMAL(5,2)); | Show online travel agency (OTA) commission rates for hotels in Africa. | SELECT ota, AVG(commission) as avg_commission FROM ota_data WHERE location = 'Africa' GROUP BY ota | 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.