context stringlengths 11 9.12k | question stringlengths 0 1.06k | SQL stringlengths 2 4.44k | source stringclasses 28
values |
|---|---|---|---|
CREATE TABLE sales (collection VARCHAR(20), revenue INT); INSERT INTO sales (collection, revenue) VALUES ('Spring 2021', 500000); | What was the total revenue for the 'Spring 2021' collection? | SELECT revenue FROM sales WHERE collection = 'Spring 2021'; | gretelai_synthetic_text_to_sql |
CREATE TABLE users (id INT, region VARCHAR(255), messages INT, post_date DATE); INSERT INTO users (id, region, messages, post_date) VALUES (1, 'France', 120, '2022-03-20'), (2, 'Germany', 80, '2022-03-21'), (3, 'Spain', 150, '2022-03-22'); | Show the total number of users from Europe who have posted more than 100 messages in the last 30 days. | SELECT SUM(messages) AS total_messages, region FROM users WHERE region LIKE 'Europe%' AND post_date >= DATE(NOW()) - INTERVAL 30 DAY GROUP BY region HAVING total_messages > 100; | gretelai_synthetic_text_to_sql |
CREATE TABLE Routes (RouteID int, RouteName varchar(255), Region varchar(255)); INSERT INTO Routes (RouteID, RouteName, Region) VALUES (1, 'North', 'East'), (2, 'South', 'Central'), (3, 'West', 'West'), (4, 'Red Line', 'East'), (5, 'Green Line', 'North'); CREATE TABLE Trips (TripID int, RouteID int, Fare double, TripDa... | What is the total fare collected on the 'Green Line' route in the 'North' region for the last month? | SELECT SUM(Fare) FROM Routes JOIN Trips ON Routes.RouteID = Trips.RouteID WHERE Routes.RouteName = 'Green Line' AND Routes.Region = 'North' AND Trips.TripDateTime >= DATEADD(month, -1, GETDATE()); | gretelai_synthetic_text_to_sql |
CREATE TABLE open_records_requests (request_id INT, state VARCHAR(20), year INT, requests_open INT, request_status VARCHAR(20)); INSERT INTO open_records_requests (request_id, state, year, requests_open, request_status) VALUES (1, 'Texas', 2020, 1500, 'open'); | Find the number of open records requests and their status for the state of Texas in the year 2020 | SELECT requests_open, request_status FROM open_records_requests WHERE state = 'Texas' AND year = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE workforce (workforce_id INT, mine_id INT, employee_name VARCHAR(50), gender VARCHAR(10), country VARCHAR(20)); INSERT INTO workforce (workforce_id, mine_id, employee_name, gender, country) VALUES (1, 1, 'Juan Lopez', 'Male', 'Mexico'), (2, 1, 'Maria Rodriguez', 'Female', 'Mexico'), (3, 2, 'Peter Jackson', ... | How many employees of each gender work in mining operations, for operations with less than 50 employees, per country? | SELECT country, gender, COUNT(*) as employee_count FROM workforce WHERE (SELECT COUNT(*) FROM workforce w WHERE w.mine_id = workforce.mine_id) < 50 GROUP BY country, gender; | gretelai_synthetic_text_to_sql |
CREATE TABLE investments (id INT, company_id INT, investor TEXT, investment_amount FLOAT); INSERT INTO investments (id, company_id, investor, investment_amount) VALUES (1, 3, 'Green Ventures', 5000000.0); INSERT INTO investments (id, company_id, investor, investment_amount) VALUES (2, 4, 'Solar Angels', 3000000.0); | List all investors who have participated in funding rounds with companies in the 'Renewable Energy' sector. | SELECT investor FROM investments JOIN companies ON investments.company_id = companies.id WHERE companies.industry = 'Renewable Energy'; | gretelai_synthetic_text_to_sql |
CREATE TABLE student_mental_health (student_id INT, school_id INT, mental_health_score INT, date DATE); INSERT INTO student_mental_health (student_id, school_id, mental_health_score, date) VALUES (1, 101, 75, '2021-09-01'); INSERT INTO student_mental_health (student_id, school_id, mental_health_score, date) VALUES (2, ... | What is the average mental health score of students per school in the last year? | SELECT school_id, AVG(mental_health_score) as avg_mental_health_score FROM student_mental_health WHERE date >= DATEADD(year, -1, GETDATE()) GROUP BY school_id ORDER BY avg_mental_health_score DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE reservoirs (reservoir_id INT PRIMARY KEY, reservoir_name VARCHAR(100), max_water_depth FLOAT, country VARCHAR(50)); | List the names and maximum water depths of all reservoirs in 'reservoirs' table that are deeper than 200 meters | SELECT reservoir_name, max_water_depth FROM reservoirs WHERE max_water_depth > 200; | gretelai_synthetic_text_to_sql |
CREATE TABLE Shipments(id INT, mode VARCHAR(50), source VARCHAR(50), destination VARCHAR(50), delivery_time DATE); INSERT INTO Shipments(id, mode, source, destination, delivery_time) VALUES (1, 'sea', 'Canada', 'Brazil', '2022-04-01'); | List the names and delivery times of all shipments that were sent by sea from Canada to Brazil. | SELECT Shipments.mode, Shipments.source, Shipments.destination, Shipments.delivery_time FROM Shipments WHERE Shipments.mode = 'sea' AND Shipments.source = 'Canada' AND Shipments.destination = 'Brazil'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Menu_Items (Item_ID INT, Item_Name TEXT, Item_Revenue DECIMAL); INSERT INTO Menu_Items (Item_ID, Item_Name, Item_Revenue) VALUES (1, 'Burger', 500.00), (2, 'Pizza', 700.00); CREATE TABLE Locations (Location_ID INT, Location_Name TEXT); INSERT INTO Locations (Location_ID, Location_Name) VALUES (1, 'Location... | What is the total revenue for each menu item across all locations? | SELECT Item_Name, SUM(Revenue) as Total_Revenue FROM Revenue_By_Item RBI JOIN Menu_Items MI ON RBI.Item_ID = MI.Item_ID GROUP BY Item_Name; | gretelai_synthetic_text_to_sql |
CREATE TABLE CargoLoads (LoadID INT, VesselID INT, LoadLocation VARCHAR(50), LoadDate DATE, CargoWeight INT); INSERT INTO CargoLoads (LoadID, VesselID, LoadLocation, LoadDate, CargoWeight) VALUES (1, 1, 'Brazil', '2021-01-01', 15000), (2, 2, 'Argentina', '2021-02-01', 12000), (3, 3, 'Colombia', '2021-03-01', 8000), (4,... | What are the top 3 heaviest cargo loads in South American ports? | SELECT LoadLocation, MAX(CargoWeight) AS MaxCargoWeight FROM CargoLoads WHERE LoadLocation LIKE 'South%' GROUP BY LoadLocation ORDER BY MaxCargoWeight DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE healthcare_facilities_ambulances (facility_id INT, region VARCHAR(10), num_of_ambulances INT); INSERT INTO healthcare_facilities_ambulances (facility_id, region, num_of_ambulances) VALUES (1, 'Oceania', 3), (2, 'North America', 5), (3, 'Oceania', 2), (4, 'South America', 4); | What is the minimum number of ambulances in rural healthcare facilities in Oceania? | SELECT MIN(num_of_ambulances) FROM healthcare_facilities_ambulances WHERE region = 'Oceania'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Auto (policyholder_id INT, car_make VARCHAR(20)); CREATE TABLE Policy (policy_id INT, policyholder_id INT); | How many policy records exist for policyholders with a car make of 'Toyota'? | SELECT COUNT(*) FROM Policy INNER JOIN Auto ON Policy.policyholder_id = Auto.policyholder_id WHERE car_make = 'Toyota'; | gretelai_synthetic_text_to_sql |
CREATE TABLE if not exists education_programs (id INT, program VARCHAR(255), location VARCHAR(255)); INSERT INTO education_programs (id, program, location) VALUES (1, 'Animal Protection 101', 'New York'), (2, 'Wildlife Conservation Basics', 'London'), (3, 'Habitat Restoration Workshop', 'Tokyo'), (4, 'Endangered Specie... | List all community education programs | SELECT * FROM education_programs; | gretelai_synthetic_text_to_sql |
CREATE TABLE drug_approval (id INT, drug_id INT, year INT); INSERT INTO drug_approval (id, drug_id, year) VALUES (1, 1, 2015), (2, 2, 2016), (3, 3, 2017); | Which drugs have been approved in a specific year? | SELECT da.drug_id, da.year FROM drug_approval da WHERE da.year = 2016; | gretelai_synthetic_text_to_sql |
CREATE TABLE social_media_posts (id INT, text VARCHAR(50), post_date DATE, gender VARCHAR(50), region VARCHAR(50)); INSERT INTO social_media_posts (id, text, post_date, gender, region) VALUES (1, 'Post1', '2022-01-01', 'Female', 'Middle East'), (2, 'Post2', '2022-01-02', 'Male', 'North Africa'), (3, 'Post3', '2022-01-0... | What is the percentage of social media posts from women in the Middle East and North Africa, in the last week? | SELECT region, 100.0 * COUNT(CASE WHEN gender = 'Female' THEN 1 END) / COUNT(*) as pct FROM social_media_posts WHERE region IN ('Middle East', 'North Africa') AND post_date >= NOW() - INTERVAL 7 DAY GROUP BY region; | gretelai_synthetic_text_to_sql |
CREATE TABLE ProductVulnerabilities (id INT, product VARCHAR(255), severity INT); INSERT INTO ProductVulnerabilities (id, product, severity) VALUES (1, 'Microsoft Office', 4), (2, 'Adobe Reader', 6), (3, 'Microsoft Office', 2); | What is the minimum severity of vulnerabilities for each product? | SELECT ProductVulnerabilities.product AS Product, MIN(ProductVulnerabilities.severity) AS Min_Severity FROM ProductVulnerabilities GROUP BY ProductVulnerabilities.product; | gretelai_synthetic_text_to_sql |
CREATE TABLE HabitatPreservation (AnimalID int, HabitatSize int); INSERT INTO HabitatPreservation (AnimalID, HabitatSize) VALUES (1, 350), (2, 450); | Update the 'HabitatSize' column in the 'HabitatPreservation' table with new data. | UPDATE HabitatPreservation SET HabitatSize = CASE AnimalID WHEN 1 THEN 400 WHEN 2 THEN 500 END; | gretelai_synthetic_text_to_sql |
CREATE TABLE PlantsByMonth (month VARCHAR(255), plants INT); INSERT INTO PlantsByMonth (month, plants) VALUES ('Jan', 1000), ('Feb', 1200), ('Mar', 1500), ('Apr', 1800), ('May', 2000), ('Jun', 2200), ('Jul', 2500), ('Aug', 2800), ('Sep', 3000), ('Oct', 3200), ('Nov', 3500), ('Dec', 3800); | What is the total number of cannabis plants that were grown in the past year, broken down by month? | SELECT month, SUM(plants) as total_plants FROM PlantsByMonth GROUP BY month; | gretelai_synthetic_text_to_sql |
CREATE TABLE green_buildings.buildings (city VARCHAR(255), building_type VARCHAR(255), building_count INT); INSERT INTO green_buildings.buildings (city, building_type, building_count) VALUES ('CityA', 'Residential', 50), ('CityA', 'Commercial', 30), ('CityB', 'Residential', 60), ('CityB', 'Commercial', 40); | What is the total number of green buildings in the 'green_buildings' schema, by city and building type? | SELECT city, building_type, SUM(building_count) FROM green_buildings.buildings GROUP BY city, building_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE Artifacts (ArtifactID INT, Name VARCHAR(100), CreationDate DATETIME, HistoricalSignificance TEXT); INSERT INTO Artifacts (ArtifactID, Name, CreationDate, HistoricalSignificance) VALUES (1, 'Ancient Dagger', '1500-01-01', 'Ceremonial weapon of ancient civilization'); | What is the name and historical significance of the artifact with the earliest creation date? | SELECT Name, HistoricalSignificance FROM (SELECT Name, CreationDate, HistoricalSignificance, ROW_NUMBER() OVER (ORDER BY CreationDate) as RowNum FROM Artifacts) as ArtifactRank WHERE RowNum = 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE tax (id INT, amount FLOAT, property_type VARCHAR(20), city VARCHAR(20)); INSERT INTO tax (id, amount, property_type, city) VALUES (1, 5000, 'sustainable urbanism', 'Austin'), (2, 6000, 'traditional', 'Austin'); | What is the maximum property tax for sustainable urbanism properties in Austin? | SELECT MAX(amount) FROM tax WHERE property_type = 'sustainable urbanism' AND city = 'Austin'; | gretelai_synthetic_text_to_sql |
CREATE TABLE philippine_plate (trench_name TEXT, location TEXT, average_depth FLOAT); INSERT INTO philippine_plate (trench_name, location, average_depth) VALUES ('Galathea Depth', 'Philippines', 10641.0), ('Mindanao Trench', 'Philippines', 10540.0); | Identify the top 2 deepest oceanic trenches in the Philippine plate. | SELECT trench_name, average_depth FROM philippine_plate ORDER BY average_depth DESC LIMIT 2; | gretelai_synthetic_text_to_sql |
CREATE TABLE DonorFrequency (DonationID int, DonorID int, DonationDate date); | Identify the most frequent donors in the last month. | SELECT DonorID, COUNT(*) as Frequency FROM DonorFrequency WHERE DonationDate >= DATEADD(MONTH, -1, GETDATE()) GROUP BY DonorID ORDER BY Frequency DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE ThreatIntelligence (report_id INT, region VARCHAR(255), report_date DATE); INSERT INTO ThreatIntelligence (report_id, region, report_date) VALUES (1, 'Middle East', '2020-01-05'), (2, 'Asia', '2020-02-10'); | How many threat intelligence reports were generated for the Middle East in 2020? | SELECT COUNT(*) FROM ThreatIntelligence WHERE region = 'Middle East' AND report_date BETWEEN '2020-01-01' AND '2020-12-31'; | gretelai_synthetic_text_to_sql |
CREATE TABLE labor_stats (state VARCHAR(20), occupation VARCHAR(20), number_of_employees INT); INSERT INTO labor_stats (state, occupation, number_of_employees) VALUES ('Arizona', 'Construction laborer', 8000); INSERT INTO labor_stats (state, occupation, number_of_employees) VALUES ('New Mexico', 'Construction laborer',... | What is the total number of construction laborers in Arizona, New Mexico, and Nevada combined? | SELECT SUM(number_of_employees) FROM labor_stats WHERE state IN ('Arizona', 'New Mexico', 'Nevada') AND occupation = 'Construction laborer'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Port (port_id INT, port_name TEXT, country TEXT); INSERT INTO Port (port_id, port_name, country) VALUES (1, 'Port of Santos', 'Brazil'); INSERT INTO Port (port_id, port_name, country) VALUES (2, 'Port of Havana', 'Cuba'); CREATE TABLE Shipment (shipment_id INT, container_id INT, port_id INT, shipping_date ... | How many containers were shipped from the Port of Santos to Cuba in the past 6 months? | SELECT COUNT(*) FROM Container c JOIN Shipment s ON c.container_id = s.container_id WHERE s.port_id = (SELECT port_id FROM Port WHERE port_name = 'Port of Santos') AND s.shipping_date >= NOW() - INTERVAL '6 months' AND (SELECT country FROM Port WHERE port_id = s.port_id) = 'Cuba'; | gretelai_synthetic_text_to_sql |
CREATE TABLE volunteers (id INT, name VARCHAR(100), country VARCHAR(50)); INSERT INTO volunteers (id, name, country) VALUES (1, 'Alice Johnson', 'USA'), (2, 'Bob Brown', 'Canada'), (3, 'Charlie Green', 'USA'), (4, 'David White', 'UK'); | How many volunteers from each country have signed up for our organization? | SELECT country, COUNT(*) AS num_volunteers FROM volunteers GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE north_america_weather (date TEXT, rainfall INTEGER); INSERT INTO north_america_weather (date, rainfall) VALUES ('2022-08-01', 20), ('2022-08-02', 15), ('2022-08-03', 18); | What is the minimum rainfall in 'north_america' in August? | SELECT MIN(rainfall) FROM north_america_weather WHERE date LIKE '2022-08-%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Utility_Projects (Project_ID INT, Project_Name VARCHAR(50), Project_Type VARCHAR(50), Cost FLOAT); INSERT INTO Utility_Projects (Project_ID, Project_Name, Project_Type, Cost) VALUES (1, 'Water_Main_Replacement', 'Utility', 4000000.00), (2, 'Sewer_System_Upgrade', 'Utility', 6000000.00), (3, 'Gas_Line_Exten... | What is the maximum cost of utility projects in the infrastructure database? | SELECT MAX(Cost) FROM Utility_Projects WHERE Project_Type = 'Utility'; | gretelai_synthetic_text_to_sql |
CREATE TABLE CityK_ScooterRides (ride_id INT, vehicle_type VARCHAR(20), is_electric BOOLEAN, trip_distance FLOAT); INSERT INTO CityK_ScooterRides (ride_id, vehicle_type, is_electric, trip_distance) VALUES (5, 'Scooter', true, 2.3), (6, 'Scooter', true, 1.8), (7, 'Bike', false, 4.5), (8, 'Scooter', false, 3.0); | What is the total number of electric scooter rides in CityK? | SELECT COUNT(*) FROM CityK_ScooterRides WHERE is_electric = true; | gretelai_synthetic_text_to_sql |
CREATE TABLE investigative_projects (project_id INT, project_name VARCHAR(255), status VARCHAR(20), assigned_to INT); | Insert new records in the 'investigative_projects' table | INSERT INTO investigative_projects (project_id, project_name, status, assigned_to) VALUES (1, 'Missing City Funds', 'In Progress', (SELECT employee_id FROM employees WHERE name = 'Jane Smith')), (2, 'Local Election Corruption', 'Open', (SELECT employee_id FROM employees WHERE name = 'Mike Johnson')); | gretelai_synthetic_text_to_sql |
CREATE TABLE GameLibrary (GameID INT, PlayerID INT); INSERT INTO GameLibrary (GameID, PlayerID) VALUES (1, 1), (1, 2), (1, 3), (2, 1), (2, 2), (3, 2), (3, 3), (4, 1), (4, 5), (5, 1), (5, 2), (5, 3), (5, 4), (5, 5), (5, 6), (5, 7), (5, 8), (5, 9); | List the names of games that are not played by any player and their respective game IDs. | SELECT GameTitle, GameID FROM GameDesign WHERE GameID NOT IN (SELECT GameID FROM GameLibrary); | gretelai_synthetic_text_to_sql |
CREATE TABLE product_ingredients (product_id INT, ingredient VARCHAR(255), percentage FLOAT, PRIMARY KEY (product_id, ingredient)); | What is the average percentage of natural ingredients in products? | SELECT AVG(percentage) FROM product_ingredients WHERE ingredient LIKE 'natural%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Volunteers (id INT PRIMARY KEY, volunteer_name VARCHAR(255), hours_volunteered DECIMAL(10,2)); | Insert a new record into the 'Volunteers' table for a volunteer named 'Bob Johnson' with 5 hours of volunteered time | INSERT INTO Volunteers (volunteer_name, hours_volunteered) VALUES ('Bob Johnson', 5.00); | gretelai_synthetic_text_to_sql |
CREATE TABLE recycling_rates (id INT PRIMARY KEY, location VARCHAR(255), recycling_type VARCHAR(255), rate DECIMAL(5,4), date DATE); | Delete records in recycling_rates table where recycling_type is 'Glass' | DELETE FROM recycling_rates WHERE recycling_type = 'Glass'; | gretelai_synthetic_text_to_sql |
CREATE TABLE landfill_capacity (country VARCHAR(50), continent VARCHAR(50), capacity FLOAT); INSERT INTO landfill_capacity (country, continent, capacity) VALUES ('Germany', 'Europe', 2000000), ('France', 'Europe', 2500000), ('Italy', 'Europe', 1800000); | What is the maximum landfill capacity in cubic meters for European countries? | SELECT MAX(capacity) FROM landfill_capacity WHERE continent = 'Europe'; | gretelai_synthetic_text_to_sql |
CREATE TABLE DiversionPrograms (ProgramID INT, ProgramType TEXT, StartDate DATE, EndDate DATE, Outcome TEXT, State TEXT); INSERT INTO DiversionPrograms (ProgramID, ProgramType, StartDate, EndDate, Outcome, State) VALUES (1, 'Diversion Program', '2021-01-01', '2021-03-15', 'Successful', 'Georgia'); | What is the percentage of successful diversion programs in Georgia in 2021? | SELECT ROUND(COUNT(*) * 100.0 / (SELECT COUNT(*) FROM DiversionPrograms WHERE State = 'Georgia' AND YEAR(StartDate) = 2021), 2) as SuccessPercentage FROM DiversionPrograms WHERE State = 'Georgia' AND YEAR(StartDate) = 2021 AND Outcome = 'Successful'; | gretelai_synthetic_text_to_sql |
CREATE TABLE brands (id INT, name TEXT); INSERT INTO brands (id, name) VALUES (1, 'EcoBrand'), (2, 'GreenGarments'), (3, 'SustainableFashion'); CREATE TABLE fabrics (id INT, brand_id INT, type TEXT, quantity INT); INSERT INTO fabrics (id, brand_id, type, quantity) VALUES (1, 1, 'Organic Cotton', 500), (2, 1, 'Recycled ... | What is the average quantity of sustainable fabrics used in the production of garments for each brand? | SELECT brand_name, AVG(quantity) AS avg_quantity FROM (SELECT brands.name AS brand_name, SUM(fabrics.quantity) AS quantity FROM fabrics JOIN brands ON fabrics.brand_id = brands.id WHERE fabrics.type IN ('Organic Cotton', 'Recycled Polyester', 'Tencel', 'Hemp') GROUP BY brands.name) AS subquery GROUP BY brand_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE Hotels (HotelID int, HotelName varchar(50), Country varchar(50), Revenue float); INSERT INTO Hotels (HotelID, HotelName, Country, Revenue) VALUES (1, 'Eco Hotel New York', 'USA', 800000); INSERT INTO Hotels (HotelID, HotelName, Country, Revenue) VALUES (2, 'Eco Hotel Toronto', 'Canada', 900000); | Identify the total revenue of eco-friendly hotels in the United States and Canada. | SELECT Revenue FROM Hotels WHERE Country IN ('USA', 'Canada') AND HotelName LIKE '%Eco%' | gretelai_synthetic_text_to_sql |
CREATE TABLE ChemicalBatches (id INT, pH FLOAT, production_date DATE); INSERT INTO ChemicalBatches (id, pH, production_date) VALUES (1, 9.2, '2021-02-12'), (2, 8.5, '2021-03-04'), (3, 7.4, '2022-08-20'); | List all chemical batches with a production date in 2022 and a pH level between 6 and 8, along with their production dates. | SELECT id, pH, production_date FROM ChemicalBatches WHERE pH BETWEEN 6 AND 8 AND production_date >= '2022-01-01' AND production_date < '2023-01-01'; | gretelai_synthetic_text_to_sql |
CREATE TABLE startups(name VARCHAR(50), founder_gender VARCHAR(10), location VARCHAR(20));INSERT INTO startups(name, founder_gender, location) VALUES('StartupA', 'Female', 'France'), ('StartupB', 'Female', 'Germany'), ('StartupC', 'Male', 'France'); | How many biotech startups were founded by women in France? | SELECT COUNT(*) FROM startups WHERE founder_gender = 'Female' AND location = 'France'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Cases (CaseID INT, AttorneyID INT, CloseDate DATE); INSERT INTO Cases (CaseID, AttorneyID, CloseDate) VALUES (1, 2, '2022-03-01'), (2, 2, '2022-06-15'); | What is the average duration of cases handled by attorney Jane Smith? | SELECT AVG(DATEDIFF(day, OpenDate, CloseDate)) FROM Cases WHERE AttorneyID = (SELECT AttorneyID FROM Attorneys WHERE Name = 'Jane Smith'); | gretelai_synthetic_text_to_sql |
CREATE TABLE cases (case_id INT, case_type VARCHAR(20), location VARCHAR(20), year INT, fine INT); INSERT INTO cases (case_id, case_type, location, year, fine) VALUES (1, 'criminal', 'Texas', 2019, 5000); | What is the maximum amount of fine imposed in criminal cases heard in Texas in the year 2019? | SELECT MAX(fine) FROM cases WHERE case_type = 'criminal' AND location = 'Texas' AND year = 2019; | gretelai_synthetic_text_to_sql |
CREATE TABLE BuildingPermits (id INT, state VARCHAR(50), permit_number INT, issued_date DATE); INSERT INTO BuildingPermits VALUES (1, 'California', 1001, '2021-01-01'); INSERT INTO BuildingPermits VALUES (2, 'California', 1002, '2021-02-15'); CREATE TABLE ProjectTimelines (id INT, permit_number INT, start_date DATE, en... | List the building permits issued in California and their corresponding project timelines. | SELECT bp.permit_number, bp.issued_date, pt.start_date, pt.end_date FROM BuildingPermits bp JOIN ProjectTimelines pt ON bp.permit_number = pt.permit_number WHERE bp.state = 'California'; | gretelai_synthetic_text_to_sql |
CREATE TABLE tournament_2022 (player_id INT, player_name TEXT, score INT, country TEXT); | What was the minimum score of players from Canada in the 'tournament_2022' table? | SELECT MIN(score) FROM tournament_2022 WHERE country = 'Canada'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Emergency_Aid (aid_type VARCHAR(255), cost INT); INSERT INTO Emergency_Aid (aid_type, cost) VALUES ('Medical Aid', 25000), ('Food Aid', 30000), ('Shelter Aid', 20000); | List all the unique types of 'Emergency Aid' and their corresponding total costs. | SELECT aid_type, SUM(cost) FROM Emergency_Aid GROUP BY aid_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE wells (well_id INT, well_name VARCHAR(255), well_type VARCHAR(255), location VARCHAR(255)); INSERT INTO wells VALUES (1, 'Well A', 'Offshore', 'North Sea'); INSERT INTO wells VALUES (2, 'Well B', 'Onshore', 'Texas'); | What is the total production volume for the top 5 producing wells in the North Sea? | SELECT SUM(production_volume) FROM (SELECT well_id, production_volume FROM well_production WHERE location = 'North Sea' ORDER BY production_volume DESC FETCH NEXT 5 ROWS ONLY); | gretelai_synthetic_text_to_sql |
CREATE TABLE drought_impact (id INT, area VARCHAR(50), year INT, PRIMARY KEY(id, year)); INSERT INTO drought_impact (id, area, year) VALUES (1, 'California', 2015), (1, 'California', 2016), (1, 'California', 2017), (2, 'Texas', 2015), (2, 'Texas', 2016), (2, 'Texas', 2017), (3, 'Australia', 2015), (3, 'Australia', 2016... | What is the average water usage per capita in drought-impacted areas since 2015? | SELECT AVG(wu.usage) as avg_usage FROM drought_impact di JOIN water_usage wu ON di.id = wu.id WHERE di.year >= 2015; | gretelai_synthetic_text_to_sql |
CREATE TABLE Artwork (ArtworkID INT, CreationDate DATE); INSERT INTO Artwork (ArtworkID, CreationDate) VALUES (1, '1905-01-01'), (2, '1910-05-15'); | What is the total selling price of artwork for each decade since 1900? | SELECT EXTRACT(YEAR FROM CreationDate) AS Year, SUM(SellingPrice) as TotalSellingPrice FROM Artwork INNER JOIN Sales ON ArtworkID = ArtworkID GROUP BY EXTRACT(YEAR FROM CreationDate) ORDER BY EXTRACT(YEAR FROM CreationDate); | gretelai_synthetic_text_to_sql |
CREATE TABLE Habitat5(animal_id INT, species VARCHAR(20), population INT, habitat VARCHAR(20)); INSERT INTO Habitat5 VALUES (1, 'Eagle', 50, 'Habitat5'), (2, 'Hawk', 60, 'Habitat5'), (3, 'Osprey', 70, 'Habitat5'); | What is the population size of 'Birds' species in 'Habitat 5'? | SELECT SUM(population) FROM Habitat5 WHERE species IN (SELECT species FROM AnimalData3 WHERE order_class = 'Birds') AND habitat = 'Habitat5'; | gretelai_synthetic_text_to_sql |
CREATE TABLE landfill_capacity (id INT, year INT, location VARCHAR(255), capacity INT, unit VARCHAR(10)); | What is the minimum landfill capacity in cubic meters in 2022? | SELECT MIN(capacity) as min_landfill_capacity FROM landfill_capacity WHERE year = 2022 AND unit = 'cubic meters'; | gretelai_synthetic_text_to_sql |
CREATE TABLE employees (id INT PRIMARY KEY, first_name VARCHAR(50), last_name VARCHAR(50), department VARCHAR(50), hire_date DATE); INSERT INTO employees (id, first_name, last_name, department, hire_date) VALUES (1, 'John', 'Doe', 'IT', '2021-01-01'), (2, 'Jane', 'Doe', 'HR', '2021-02-15'); | Insert data into the 'employees' table | INSERT INTO employees (id, first_name, last_name, department, hire_date) VALUES (1, 'John', 'Doe', 'IT', '2021-01-01'), (2, 'Jane', 'Doe', 'HR', '2021-02-15'); | gretelai_synthetic_text_to_sql |
CREATE TABLE Sales (SaleID INT, ProductID INT, SaleAmount DECIMAL(10,2)); INSERT INTO Sales (SaleID, ProductID, SaleAmount) VALUES (1, 1, 50), (2, 2, 75), (3, 3, 100); CREATE TABLE Products (ProductID INT, IsCrueltyFree BOOLEAN); INSERT INTO Products (ProductID, IsCrueltyFree) VALUES (1, true), (2, false), (3, true); | What percentage of sales comes from cruelty-free products? | SELECT 100.0 * SUM(SaleAmount) / (SELECT SUM(SaleAmount) FROM Sales) FROM Products WHERE IsCrueltyFree = true; | gretelai_synthetic_text_to_sql |
CREATE TABLE Oil_Production (well text, production_date date, quantity real); INSERT INTO Oil_Production (well, production_date, quantity) VALUES ('W009', '2021-03-01', 150.5), ('W009', '2021-03-02', 160.3), ('W009', '2021-03-03', 170.0); | What was the production quantity for well 'W009' on '2021-03-03' in the Oil_Production table? | SELECT quantity FROM Oil_Production WHERE well = 'W009' AND production_date = '2021-03-03'; | gretelai_synthetic_text_to_sql |
CREATE TABLE brazil_sustainable_footwear (footwear_type VARCHAR(255), sales_amount DECIMAL(10,2), half_year INT, year INT); INSERT INTO brazil_sustainable_footwear (footwear_type, sales_amount, half_year, year) VALUES ('Sneakers', 500.00, 2, 2020), ('Sandals', 600.00, 2, 2020); | What was the average sales amount for sustainable footwear in Brazil in H2 2020? | SELECT AVG(sales_amount) FROM brazil_sustainable_footwear WHERE half_year = 2 AND year = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE accessibility_initiatives (initiative_id INT, initiative_name VARCHAR(50), region VARCHAR(50), launch_year INT); INSERT INTO accessibility_initiatives (initiative_id, initiative_name, region, launch_year) VALUES (1, 'AccessInit1', 'Africa', 2017), (2, 'AccessInit2', 'Africa', 2018), (3, 'AccessInit3', 'Afr... | How many accessible technology initiatives were launched in Africa per year? | SELECT launch_year, COUNT(*) as count FROM accessibility_initiatives WHERE region = 'Africa' GROUP BY launch_year; | gretelai_synthetic_text_to_sql |
CREATE TABLE policy (policy_number INT, policy_type VARCHAR(255), effective_date DATE); | Insert a new policy record into the policy table for policy number 10 with a policy type of 'Auto' and effective date of '2022-01-01' | INSERT INTO policy (policy_number, policy_type, effective_date) VALUES (10, 'Auto', '2022-01-01'); | gretelai_synthetic_text_to_sql |
CREATE TABLE Organic_Farms (farm_name VARCHAR(50), region VARCHAR(20), year INT); CREATE TABLE Pest_Report (report_id INT, farm_name VARCHAR(50), pest VARCHAR(30), year INT); INSERT INTO Organic_Farms (farm_name, region, year) VALUES ('Farm1', 'Pacific Northwest', 2020), ('Farm2', 'Pacific Northwest', 2020); INSE... | Which organic farms in the 'Pacific Northwest' region have reported the 'Codling Moth' pest in 2020? | SELECT DISTINCT of.farm_name as farm_names FROM Organic_Farms of JOIN Pest_Report pr ON of.farm_name = pr.farm_name WHERE of.region = 'Pacific Northwest' AND pr.pest = 'Codling Moth' AND of.year = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE products (product_id INT, product_name TEXT, price DECIMAL(5,2), is_fair_trade BOOLEAN); INSERT INTO products (product_id, product_name, price, is_fair_trade) VALUES (1, 'Fair Trade Coffee', 9.99, true); INSERT INTO products (product_id, product_name, price, is_fair_trade) VALUES (2, 'Regular Coffee', 7.99... | What is the minimum selling price of fair trade products? | SELECT MIN(price) FROM products WHERE is_fair_trade = true; | gretelai_synthetic_text_to_sql |
CREATE TABLE concert_events (event_id INT, artist_id INT, event_date DATE, event_location VARCHAR(255), attendance INT, revenue DECIMAL(10,2)); INSERT INTO concert_events (event_id, artist_id, event_date, event_location, attendance, revenue) VALUES (1, 1, '2022-01-01', 'NYC', 15000, 500000.00); CREATE TABLE artist_demo... | What is the total revenue for concerts with attendance greater than 10000 for Latin artists in 2022? | SELECT SUM(revenue) FROM concert_events ce JOIN artist_demographics ad ON ce.artist_id = ad.artist_id WHERE ce.attendance > 10000 AND ad.ethnicity = 'Latin' AND ce.event_date BETWEEN '2022-01-01' AND '2022-12-31'; | gretelai_synthetic_text_to_sql |
CREATE TABLE artworks (id INT, artwork VARCHAR(50), medium VARCHAR(50)); INSERT INTO artworks (id, artwork, medium) VALUES (1, 'Painting', 'Painting'), (2, 'Sculpture', 'Sculpture'), (3, 'Print', 'Print'); | What is the distribution of artworks by medium category, pivoted to display each artwork as a separate row? | SELECT id, artwork, CASE medium WHEN 'Painting' THEN 'Visual Art' WHEN 'Sculpture' THEN 'Visual Art' ELSE 'Print' END as medium FROM artworks; | gretelai_synthetic_text_to_sql |
CREATE TABLE Volunteers (VolunteerID INT PRIMARY KEY, FirstName VARCHAR(50), LastName VARCHAR(50), Email VARCHAR(100)); | Delete a record from the 'Volunteers' table | DELETE FROM Volunteers WHERE VolunteerID = 201; | gretelai_synthetic_text_to_sql |
CREATE TABLE timber_production (region VARCHAR(255), year INT, volume INT); INSERT INTO timber_production (region, year, volume) VALUES ('North', 2020, 1200), ('North', 2021, 1800), ('South', 2020, 800), ('South', 2021, 1200), ('East', 2020, 1700), ('East', 2021, 2000), ('West', 2020, 1100), ('West', 2021, 1500); | Which regions have the highest and lowest timber production in 2021? | SELECT region, volume as timber_volume FROM (SELECT region, volume, ROW_NUMBER() OVER (ORDER BY volume DESC) as rank FROM timber_production WHERE year = 2021) as ranked_regions WHERE rank = 1 OR rank = 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE Restaurants (RestaurantID int, RestaurantName varchar(255), SustainableMenu bit, LastInspectionDate date); CREATE TABLE Menu (MenuID int, RestaurantID int, MenuItem varchar(255), Price decimal(5,2), IsSustainable bit); CREATE TABLE Inspections (InspectionID int, RestaurantID int, InspectionDate date, Viola... | What is the average price of sustainable menu items in restaurants that passed their last food safety inspection? | SELECT AVG(M.Price) as AveragePriceOfSustainableMenuItems FROM Menu M INNER JOIN Restaurants R ON M.RestaurantID = R.RestaurantID INNER JOIN (SELECT RestaurantID, MAX(InspectionDate) as LastInspectionDate FROM Inspections GROUP BY RestaurantID) I ON R.RestaurantID = I.RestaurantID WHERE M.IsSustainable = 1 AND R.LastIn... | gretelai_synthetic_text_to_sql |
CREATE TABLE circular_economy_initiatives (region VARCHAR(20), year INT, spending INT); INSERT INTO circular_economy_initiatives (region, year, spending) VALUES ('Southeast', 2020, 800000), ('Southeast', 2021, 850000), ('Northeast', 2020, 700000), ('Northeast', 2021, 750000); | What was the total circular economy initiative spending in the 'Southeast' region in 2021? | SELECT SUM(spending) FROM circular_economy_initiatives WHERE region = 'Southeast' AND year = 2021; | gretelai_synthetic_text_to_sql |
CREATE TABLE hotels (hotel_id INT, hotel_name TEXT, country TEXT, ai_concierge BOOLEAN); INSERT INTO hotels (hotel_id, hotel_name, country, ai_concierge) VALUES (1, 'Hotel X', 'USA', true), (2, 'Hotel Y', 'Canada', false); | What is the average rating of hotels in the US that have an AI concierge? | SELECT AVG(hotel_rating) FROM hotels WHERE country = 'USA' AND ai_concierge = true; | gretelai_synthetic_text_to_sql |
CREATE TABLE mobile_revenue (revenue_id INT, revenue_date DATE, revenue_amount FLOAT, revenue_type VARCHAR(20)); INSERT INTO mobile_revenue (revenue_id, revenue_date, revenue_amount, revenue_type) VALUES (1, '2022-03-12', 50000, 'Mobile'), (2, '2022-03-28', 75000, 'Broadband'); CREATE TABLE broadband_revenue (revenue_i... | What is the total revenue from mobile and broadband services for the month of March 2022? | SELECT SUM(revenue_amount) FROM mobile_revenue WHERE revenue_date BETWEEN '2022-03-01' AND '2022-03-31' UNION ALL SELECT SUM(revenue_amount) FROM broadband_revenue WHERE revenue_date BETWEEN '2022-03-01' AND '2022-03-31'; | gretelai_synthetic_text_to_sql |
CREATE TABLE threat_actors (threat_actor_id INT, threat_actor_name VARCHAR(255), attack_count INT); INSERT INTO threat_actors (threat_actor_id, threat_actor_name, attack_count) VALUES (1, 'APT28', 15), (2, 'APT33', 10), (3, 'APT34', 12), (4, 'APT35', 8), (5, 'APT36', 5), (6, 'APT37', 7), (7, 'APT38', 9), (8, 'APT39', 6... | Who are the top 3 threat actors by the number of attacks in the last month? | SELECT threat_actor_name, attack_count FROM threat_actors ORDER BY attack_count DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE items (id INT, name VARCHAR(255), material VARCHAR(255)); INSERT INTO items (id, name, material) VALUES (1, 'Jacket', 'recycled polyester'), (2, 'Hat', 'recycled paper'), (3, 'Shirt', 'cotton'); | Get the number of items made of recycled materials | SELECT COUNT(*) FROM items WHERE material LIKE '%recycled%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE IF NOT EXISTS military_aid (id INT PRIMARY KEY, provider_country VARCHAR(255), recipient_country VARCHAR(255), amount INT); | Which countries provided military aid to which countries? | SELECT DISTINCT provider_country, recipient_country FROM military_aid; | gretelai_synthetic_text_to_sql |
CREATE TABLE DroughtImpactByLocationMonth (id INT, location VARCHAR(50), impact_level VARCHAR(50), affected_area INT, impact_month DATE); INSERT INTO DroughtImpactByLocationMonth (id, location, impact_level, affected_area, impact_month) VALUES (1, 'City A', 'High', 1200, '2022-01-01'); INSERT INTO DroughtImpactByLocati... | What is the total impact of drought by location and month? | SELECT location, EXTRACT(MONTH FROM impact_month) AS impact_month, SUM(affected_area) AS total_impact FROM DroughtImpactByLocationMonth GROUP BY location, impact_month; | gretelai_synthetic_text_to_sql |
CREATE TABLE climate_mitigation_min (project_id INT, project_name TEXT, allocation DECIMAL(10, 2), year INT); INSERT INTO climate_mitigation_min (project_id, project_name, allocation, year) VALUES (13, 'Green Roofs M', 900000, 2019), (14, 'Public Transport N', 800000, 2019), (15, 'Carbon Capture O', 700000, 2019); | What is the minimum allocation for a climate mitigation project in the year 2019? | SELECT MIN(allocation) FROM climate_mitigation_min WHERE year = 2019; | gretelai_synthetic_text_to_sql |
CREATE TABLE digital_assets (id INT, name VARCHAR(255), network VARCHAR(255)); INSERT INTO digital_assets (id, name, network) VALUES (1, 'Bitcoin', 'Bitcoin'), (2, 'Ethereum', 'Ethereum'), (3, 'USDT', 'Ethereum'), (4, 'BNB', 'Binance Smart Chain'), (5, 'ADA', 'Cardano'), (6, 'SOL', 'Solana'); | What is the total number of unique digital assets by network? | SELECT network, COUNT(DISTINCT name) as unique_assets FROM digital_assets GROUP BY network; | gretelai_synthetic_text_to_sql |
CREATE TABLE ocean_acidification (location TEXT, level FLOAT); INSERT INTO ocean_acidification (location, level) VALUES ('Atlantic Ocean', 8.2), ('Pacific Ocean', 7.9), ('Indian Ocean', 8.1); | What is the minimum ocean acidification level recorded in the Indian Ocean? | SELECT MIN(level) FROM ocean_acidification WHERE location = 'Indian Ocean'; | gretelai_synthetic_text_to_sql |
CREATE TABLE smart_projects (project_id INT, project_name VARCHAR(100), state VARCHAR(50), budget FLOAT); CREATE TABLE states (state VARCHAR(50), country VARCHAR(50)); | Identify the number of smart city projects in each state with the highest budget allocation. | SELECT s.state, COUNT(sp.project_id) FROM smart_projects sp INNER JOIN states s ON sp.state = s.state JOIN (SELECT state, MAX(budget) AS max_budget FROM smart_projects GROUP BY state) AS sm ON s.state = sm.state AND sp.budget = sm.max_budget GROUP BY s.state; | gretelai_synthetic_text_to_sql |
CREATE TABLE mining_operations (operation_id INT, operation_name VARCHAR(50)); CREATE TABLE waste_generated (operation_id INT, waste_type VARCHAR(50), quantity_generated INT); INSERT INTO mining_operations (operation_id, operation_name) VALUES (1, 'Operation A'), (2, 'Operation B'), (3, 'Operation C'); INSERT INTO wast... | What is the total waste generated by each mining operation, categorized by waste type? | SELECT mining_operations.operation_name, waste_generated.waste_type, SUM(waste_generated.quantity_generated) AS total_waste_generated FROM mining_operations INNER JOIN waste_generated ON mining_operations.operation_id = waste_generated.operation_id GROUP BY mining_operations.operation_name, waste_generated.waste_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE Ships (ship_id INT, ship_name VARCHAR(50), ship_type VARCHAR(50), region VARCHAR(50)); CREATE TABLE FuelConsumption (fuel_id INT, ship_id INT, consumption FLOAT, consumption_date DATE); | What is the average fuel consumption per day for container ships in the North Atlantic in Q1 2023? | SELECT AVG(fc.consumption) as avg_daily_consumption FROM FuelConsumption fc JOIN Ships s ON fc.ship_id = s.ship_id WHERE s.ship_type = 'Container Ship' AND s.region = 'North Atlantic' AND fc.consumption_date >= '2023-01-01' AND fc.consumption_date < '2023-04-01' GROUP BY fc.ship_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE mining_operation (id INT PRIMARY KEY, material VARCHAR(50), extraction_date DATE, quantity INT); INSERT INTO mining_operation (id, material, extraction_date, quantity) VALUES (1, 'Gold', '2016-01-01', 500), (2, 'Silver', '2017-03-15', 1000), (3, 'Gold', '2018-05-05', 800); | What's the total amount of gold and silver extracted in the last 7 years, by month? | SELECT YEAR(extraction_date) as year, MONTH(extraction_date) as month, SUM(quantity) as total_material FROM mining_operation WHERE material IN ('Gold', 'Silver') AND extraction_date >= DATEADD(year, -7, GETDATE()) GROUP BY YEAR(extraction_date), MONTH(extraction_date); | gretelai_synthetic_text_to_sql |
CREATE TABLE indigenous_communities (community_id INT, community_name VARCHAR(255), population INT, region VARCHAR(255)); | Find the total number of communities and total population in the 'indigenous_communities' table, excluding communities with a population of less than 100. | SELECT COUNT(*) AS community_count, SUM(population) AS total_population FROM indigenous_communities WHERE population >= 100; | gretelai_synthetic_text_to_sql |
CREATE TABLE Network (network_id INT, network_name VARCHAR(50), city VARCHAR(50)); INSERT INTO Network (network_id, network_name, city) VALUES (1, 'HBO', 'New York'), (2, 'NBC', 'New York'); CREATE TABLE Show (show_id INT, title VARCHAR(50), rating DECIMAL(2,1), network_id INT); INSERT INTO Show (show_id, title, rating... | What is the average rating of TV shows produced by networks located in 'New York'? | SELECT AVG(s.rating) FROM Show s JOIN Network n ON s.network_id = n.network_id WHERE n.city = 'New York'; | gretelai_synthetic_text_to_sql |
CREATE TABLE oil_production (well_id INT, location VARCHAR(20), daily_production FLOAT); INSERT INTO oil_production (well_id, location, daily_production) VALUES (1, 'Gulf of Mexico', 180.2), (2, 'Strait of Hormuz', 200.1); | Find the daily production of oil wells in the Gulf of Mexico and the Strait of Hormuz | SELECT location, daily_production FROM oil_production WHERE location IN ('Gulf of Mexico', 'Strait of Hormuz'); | gretelai_synthetic_text_to_sql |
CREATE TABLE FarmLocation (LocationID INT, FarmName VARCHAR(50), Country VARCHAR(50)); CREATE TABLE Transactions (TransactionID INT, FarmID INT, QuantitySold INT); INSERT INTO FarmLocation (LocationID, FarmName, Country) VALUES (1, 'Piranha Plantation', 'Brazil'); INSERT INTO Transactions (TransactionID, FarmID, Quanti... | What is the total quantity of fish sold in 'Brazil'? | SELECT SUM(QuantitySold) FROM Transactions JOIN FarmLocation ON Transactions.FarmID = FarmLocation.LocationID WHERE FarmLocation.Country = 'Brazil'; | gretelai_synthetic_text_to_sql |
CREATE TABLE users (id INT, name VARCHAR(50), country VARCHAR(50)); INSERT INTO users (id, name, country) VALUES (1, 'Olga', 'Ukraine'), (2, 'Pavel', 'Russia'), (3, 'Ivan', 'Poland'); CREATE TABLE tokens (id INT, user_id INT, name VARCHAR(50), type VARCHAR(50), market_cap DECIMAL(10, 2)); INSERT INTO tokens (id, user_i... | What is the total market capitalization of centralized exchange tokens (CEX) owned by users in Eastern Europe? | SELECT SUM(market_cap) FROM tokens WHERE type = 'CEX' AND user_id IN (SELECT id FROM users WHERE country IN ('Ukraine', 'Russia', 'Poland')); | gretelai_synthetic_text_to_sql |
CREATE TABLE cricket_overs (bowler VARCHAR(50), team VARCHAR(50), overs FLOAT, runs INT); INSERT INTO cricket_overs (bowler, team, overs, runs) VALUES ('Jasprit Bumrah', 'India', 10, 25), ('Mitchell Starc', 'Australia', 9.3, 32), ('James Anderson', 'England', 15, 40); | What is the minimum number of runs conceded by a bowler in a single cricket match in the 'cricket_overs' table? | SELECT MIN(runs) FROM cricket_overs; | gretelai_synthetic_text_to_sql |
CREATE TABLE Organizations (OrgID INT, OrgName TEXT); CREATE TABLE Grants (GrantID INT, OrgID INT, Amount DECIMAL); | Find the 10 organizations that have received the most grants? | SELECT OrgName, COUNT(*) OVER (PARTITION BY OrgID ORDER BY COUNT(*) DESC) AS NumGrants FROM Organizations JOIN Grants ON Organizations.OrgID = Grants.OrgID GROUP BY OrgID ORDER BY NumGrants LIMIT 10; | gretelai_synthetic_text_to_sql |
CREATE TABLE ExcavationSite (SiteID INT, SiteName TEXT, Country TEXT, NumArtifacts INT); | Add a new excavation site 'Palenque' in Mexico. | INSERT INTO ExcavationSite (SiteID, SiteName, Country, NumArtifacts) VALUES (6, 'Palenque', 'Mexico', 0); | gretelai_synthetic_text_to_sql |
CREATE TABLE teams (team_id INT, team_name VARCHAR(50)); INSERT INTO teams (team_id, team_name) VALUES (1, 'NY Knicks'); CREATE TABLE games (game_id INT, home_team_id INT, attendance INT); INSERT INTO games (game_id, home_team_id, attendance) VALUES (1, 1, 19000), (2, 1, 19500), (3, 1, 20000); | What is the average home game attendance for the NY Knicks? | SELECT AVG(attendance) FROM games WHERE home_team_id = (SELECT team_id FROM teams WHERE team_name = 'NY Knicks'); | gretelai_synthetic_text_to_sql |
CREATE TABLE Donors (id INT, name TEXT, country TEXT, donation_amount DECIMAL(10, 2), donation_frequency TEXT, donation_date DATE); | What was the average donation amount for recurring donors from the United Kingdom compared to one-time donors? | SELECT AVG(donation_amount) FROM Donors WHERE country = 'United Kingdom' AND donation_frequency = 'Recurring'; SELECT AVG(donation_amount) FROM Donors WHERE country = 'United Kingdom' AND donation_frequency = 'One-time'; | gretelai_synthetic_text_to_sql |
CREATE TABLE SupplyChainViolations (country TEXT, num_violations INT); INSERT INTO SupplyChainViolations (country, num_violations) VALUES ('Bangladesh', 50), ('Cambodia', 30), ('Vietnam', 20), ('India', 10); CREATE TABLE RecycledMaterials (product_id INT, country TEXT, recycled_materials BOOLEAN); INSERT INTO RecycledM... | Which countries have supply chain violations and produce more than 20 products made from recycled materials? | SELECT country FROM RecycledMaterials R1 INNER JOIN SupplyChainViolations S1 ON R1.country = S1.country GROUP BY country HAVING COUNT(*) > 20; | gretelai_synthetic_text_to_sql |
CREATE TABLE SiteEmployees (SiteID INT, EmployeeID INT, FirstName VARCHAR(50), LastName VARCHAR(50), JobTitle VARCHAR(50)); INSERT INTO SiteEmployees (SiteID, EmployeeID, FirstName, LastName, JobTitle) VALUES (1, 1, 'John', 'Doe', 'Manager'), (1, 2, 'Jane', 'Doe', 'Engineer'), (2, 3, 'Bob', 'Smith', 'Manager'); | List all the mining sites, their locations and the number of employees working at each site | SELECT s.SiteName, s.Location, COUNT(e.EmployeeID) as EmployeeCount FROM SiteEmployees e INNER JOIN MiningSites s ON e.SiteID = s.SiteID GROUP BY e.SiteID; | gretelai_synthetic_text_to_sql |
CREATE TABLE justice_data.court_hearings (id INT, case_number INT, hearing_date DATE); | What is the maximum number of court hearings for a single case in the justice_data schema's court_hearings table? | SELECT MAX(COUNT(*)) FROM justice_data.court_hearings GROUP BY case_number; | gretelai_synthetic_text_to_sql |
CREATE TABLE security_incidents (id INT, incident_date DATE); | Show the distribution of security incidents by day of the week | SELECT DATEPART(dw, incident_date) as day_of_week, COUNT(*) as num_incidents FROM security_incidents GROUP BY DATEPART(dw, incident_date); | gretelai_synthetic_text_to_sql |
CREATE TABLE attorney_time_tracking (attorney TEXT, billable_hours DECIMAL(5,2)); INSERT INTO attorney_time_tracking (attorney, billable_hours) VALUES ('Smith', 10.00), ('Johnson', 12.00), ('Williams', 15.00), ('Brown', 20.00); CREATE TABLE attorney_cases (attorney TEXT, cases INT); INSERT INTO attorney_cases (attorney... | What is the average billable hours per case for each attorney? | SELECT attorney, AVG(billable_hours/cases) as avg_billable_hours FROM attorney_time_tracking JOIN attorney_cases ON attorney_time_tracking.attorney = attorney_cases.attorney GROUP BY attorney; | gretelai_synthetic_text_to_sql |
CREATE TABLE MediaConsumers (ConsumerID INT PRIMARY KEY, ConsumerName VARCHAR(50), Age INT, Gender VARCHAR(10), GeoLocation VARCHAR(30)); INSERT INTO MediaConsumers (ConsumerID, ConsumerName, Age, Gender, GeoLocation) VALUES (1, 'Consumer 1', 25, 'Female', 'Location A'), (2, 'Consumer 2', 30, 'Male', 'Location B'); CRE... | Find consumers aged between 18 and 25 who have viewed or liked any media content. | SELECT * FROM MediaConsumers WHERE Age BETWEEN 18 AND 25 AND ConsumerID IN (SELECT ConsumerID FROM MediaRepresentation); | gretelai_synthetic_text_to_sql |
CREATE TABLE Donations (DonationID INT, DonorID INT, DonationAmount DECIMAL(10,2), DonationDate DATE); | What is the average number of donations per day in the 'Donations' table for each month in 2021? | SELECT DATE_FORMAT(DonationDate, '%Y-%m') AS Month, AVG(COUNT(*)) AS AverageDonationsPerDay FROM Donations WHERE YEAR(DonationDate) = 2021 GROUP BY Month; | gretelai_synthetic_text_to_sql |
CREATE TABLE articles (article_id INT, author VARCHAR(50), title VARCHAR(100), category VARCHAR(50), publication_date DATE); | What is the distribution of article publication dates by month for a specific year? | SELECT EXTRACT(MONTH FROM publication_date) AS month, COUNT(article_id) AS articles_in_month FROM articles WHERE EXTRACT(YEAR FROM publication_date) = 2022 GROUP BY month ORDER BY month; | gretelai_synthetic_text_to_sql |
CREATE TABLE volunteer_programs (id INT, city TEXT, program TEXT, volunteers INT); INSERT INTO volunteer_programs (id, city, program, volunteers) VALUES (1, 'NYC', 'Green City', 50); INSERT INTO volunteer_programs (id, city, program, volunteers) VALUES (2, 'LA', 'Green City', 30); INSERT INTO volunteer_programs (id, ci... | What is the maximum number of volunteers for a single program in 'NYC'? | SELECT MAX(volunteers) FROM volunteer_programs WHERE city = 'NYC'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Exhibitions (ExhibitionID INT, Title VARCHAR(50), StartDate DATE, EndDate DATE, Theme VARCHAR(50)); INSERT INTO Exhibitions (ExhibitionID, Title, StartDate, EndDate, Theme) VALUES (1, 'Surrealism: The Dream World', '1936-11-12', '1937-02-28', 'Surrealism'); | Retrieve all exhibitions with a Surrealist theme. | SELECT Title FROM Exhibitions WHERE Theme = 'Surrealism'; | gretelai_synthetic_text_to_sql |
CREATE TABLE orders (dish VARCHAR(255), order_date DATE, vegetarian BOOLEAN); INSERT INTO orders (dish, order_date, vegetarian) VALUES ('Pizza', '2022-01-01', FALSE), ('Pasta', '2022-01-02', TRUE), ('Burger', '2022-01-03', FALSE), ('Pizza', '2022-01-04', TRUE), ('Salad', '2022-01-05', TRUE); | List the top 3 most preferred vegetarian dishes by customers in the last 60 days? | SELECT dish, COUNT(dish) AS count FROM orders WHERE order_date >= DATEADD(day, -60, GETDATE()) AND vegetarian = TRUE GROUP BY dish ORDER BY count DESC LIMIT 3; | 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.