context stringlengths 11 9.12k | question stringlengths 0 1.06k | SQL stringlengths 2 4.44k | source stringclasses 28
values |
|---|---|---|---|
CREATE TABLE music_platform (id INT, song_title VARCHAR(100), genre VARCHAR(50), length FLOAT, country VARCHAR(50)); | What is the average length of songs in the jazz genre on the music streaming platform in Japan? | SELECT AVG(length) as avg_length FROM music_platform WHERE genre = 'jazz' AND country = 'Japan'; | gretelai_synthetic_text_to_sql |
CREATE TABLE donations (donation_id INT, donation_amount DECIMAL(10,2), donation_date DATE, donor_country TEXT); | Which country had the highest average donation in 2021? | SELECT donor_country, AVG(donation_amount) as avg_donation FROM donations WHERE YEAR(donation_date) = 2021 GROUP BY donor_country ORDER BY avg_donation DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE membership (id INT, user_id INT, region VARCHAR(20), monthly_fee INT); | Total monthly revenue by region. | SELECT region, TO_CHAR(session_date, 'Month') as month, SUM(monthly_fee) as total_revenue FROM membership GROUP BY region, month ORDER BY total_revenue DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_species (species_id INT, name VARCHAR(50), habitat VARCHAR(50)); INSERT INTO marine_species (species_id, name, habitat) VALUES (1, 'Dolphin', 'Mediterranean Sea'), (2, 'Shark', 'Red Sea'), (3, 'Turtle', 'Atlantic Ocean'), (4, 'Clownfish', 'Pacific Ocean'); | Which marine species are found in both the Mediterranean Sea and the Red Sea? | SELECT name FROM marine_species WHERE habitat = 'Mediterranean Sea' INTERSECT SELECT name FROM marine_species WHERE habitat = 'Red Sea'; | gretelai_synthetic_text_to_sql |
CREATE TABLE cultural_preservation_projects (project_id INT, project_name TEXT, country TEXT, completion_date DATE); INSERT INTO cultural_preservation_projects (project_id, project_name, country, completion_date) VALUES (1, 'Ancient Ruins Conservation', 'Egypt', '2021-12-31'), (2, 'Traditional Craft Revival', 'Morocco'... | How many cultural heritage preservation projects were completed in Africa in the last 5 years? | SELECT COUNT(*) FROM cultural_preservation_projects WHERE completion_date >= DATEADD(year, -5, GETDATE()); | gretelai_synthetic_text_to_sql |
CREATE TABLE Artists (ArtistID INT, Name TEXT, Age INT, Genre TEXT); INSERT INTO Artists (ArtistID, Name, Age, Genre) VALUES (1, 'Bob Marley', 70, 'Reggae'); INSERT INTO Artists (ArtistID, Name, Age, Genre) VALUES (2, 'Peter Tosh', 65, 'Reggae'); | What is the average age of all reggae artists? | SELECT AVG(Age) FROM Artists WHERE Genre = 'Reggae'; | gretelai_synthetic_text_to_sql |
CREATE TABLE inspectors (id INT PRIMARY KEY, inspector VARCHAR(255)); INSERT INTO inspectors (id, inspector) VALUES (1, 'Alex Lee'), (2, 'Sarah Jones'); CREATE TABLE safety_inspections (id INT PRIMARY KEY, chemical_id INT, inspection_date DATE, inspector_id INT); INSERT INTO safety_inspections (id, chemical_id, inspect... | Determine the number of unique inspectors for each chemical's safety inspections. | SELECT chemical_id, COUNT(DISTINCT inspector_id) AS num_inspectors, RANK() OVER (ORDER BY COUNT(DISTINCT inspector_id) DESC) AS rank FROM safety_inspections JOIN inspectors ON safety_inspections.inspector_id = inspectors.id GROUP BY chemical_id HAVING rank <= 2; | gretelai_synthetic_text_to_sql |
CREATE TABLE news_articles (id INT, title VARCHAR(100), publication_date DATE, topic VARCHAR(50), publication_country VARCHAR(50)); INSERT INTO news_articles (id, title, publication_date, topic, publication_country) VALUES (1, 'Climate Change: A Growing Crisis', '2022-02-12', 'Climate Change', 'United States'), (2, 'Po... | What is the average number of articles published per day by each publication in the last month? | SELECT publication_country, AVG(COUNT(*)) FROM news_articles WHERE publication_date >= DATEADD(month, -1, GETDATE()) GROUP BY publication_country; | gretelai_synthetic_text_to_sql |
CREATE TABLE readers (reader_id INT PRIMARY KEY, age INT, gender VARCHAR(10), location VARCHAR(100)); | Update the name of the 'readers' table to 'audience_demographics' | ALTER TABLE readers RENAME TO audience_demographics; | gretelai_synthetic_text_to_sql |
CREATE TABLE news (title VARCHAR(255), author VARCHAR(255), word_count INT, category VARCHAR(255)); INSERT INTO news (title, author, word_count, category) VALUES ('Sample News', 'James Brown', 800, 'International'); | What is the total word count for articles in the 'international' category? | SELECT SUM(word_count) FROM news WHERE category = 'International'; | gretelai_synthetic_text_to_sql |
CREATE TABLE max_sales (contractor VARCHAR(20), year INT, sales INT); INSERT INTO max_sales (contractor, year, sales) VALUES ('Boeing', 2021, 2000), ('BAE Systems', 2021, 1500); | What is the maximum military equipment sale quantity by a defense contractor in 2021? | SELECT MAX(sales) FROM max_sales WHERE year = 2021; | gretelai_synthetic_text_to_sql |
CREATE TABLE immunization_coverage (id INT PRIMARY KEY, country VARCHAR(50), coverage FLOAT); | Create a table named 'immunization_coverage' | CREATE TABLE immunization_coverage (id INT PRIMARY KEY, country VARCHAR(50), coverage FLOAT); | gretelai_synthetic_text_to_sql |
CREATE TABLE ArtWorks (ArtWorkID INT, Title VARCHAR(100), YearCreated INT, ArtistID INT, Medium VARCHAR(50), MuseumID INT); | Delete an artwork | DELETE FROM ArtWorks WHERE ArtWorkID = 2 AND Title = 'The Two Fridas'; | gretelai_synthetic_text_to_sql |
CREATE TABLE restaurant_sales (restaurant VARCHAR(255), sale_date DATE, sales DECIMAL(10,2)); INSERT INTO restaurant_sales (restaurant, sale_date, sales) VALUES ('Restaurant A', '2022-01-01', 500.00), ('Restaurant A', '2022-01-02', 600.00), ('Restaurant B', '2022-01-01', 400.00), ('Restaurant B', '2022-01-02', 450.00); | What is the total sales for each restaurant in the last week? | SELECT restaurant, SUM(sales) FROM restaurant_sales WHERE sale_date >= DATE_SUB(CURDATE(), INTERVAL 1 WEEK) GROUP BY restaurant; | gretelai_synthetic_text_to_sql |
CREATE TABLE schema.public_transportation (system_id INT, system_name VARCHAR(50), system_type VARCHAR(50), implementation_date DATE); INSERT INTO schema.public_transportation (system_id, system_name, system_type, implementation_date) VALUES (1, 'Subway', 'Rail', '2021-04-01'), (2, 'Light Rail', 'Rail', '2021-07-01'), ... | Which public transportation systems were added in Q3 2021? | SELECT system_name FROM schema.public_transportation WHERE implementation_date BETWEEN '2021-07-01' AND '2021-09-30'; | gretelai_synthetic_text_to_sql |
CREATE TABLE climate_finance (year INT, country VARCHAR(50), project_type VARCHAR(50), amount DECIMAL(10,2)); INSERT INTO climate_finance (year, country, project_type, amount) VALUES (2020, 'Kenya', 'Solar', 500000.00), (2020, 'Nigeria', 'Wind', 750000.00); | What was the total amount of climate finance provided to African countries for renewable energy projects in 2020? | SELECT SUM(amount) FROM climate_finance WHERE year = 2020 AND country IN ('Kenya', 'Nigeria') AND project_type = 'Renewable Energy'; | gretelai_synthetic_text_to_sql |
CREATE TABLE PlayerDevices (PlayerID INT, Device VARCHAR(50), Continent VARCHAR(50)); INSERT INTO PlayerDevices (PlayerID, Device, Continent) VALUES (1, 'PC', 'Europe'), (2, 'Mobile', 'Africa'), (3, 'PC', 'Asia'), (4, 'Console', 'North America'), (5, 'Mobile', 'South America'), (6, 'PC', 'Oceania'), (7, 'Mobile', 'Euro... | What is the percentage of players who prefer using mobile devices for gaming in each continent? | SELECT Continent, COUNT(*) as TotalPlayers, COUNT(CASE WHEN Device = 'Mobile' THEN 1 END) as MobilePlayers, (COUNT(CASE WHEN Device = 'Mobile' THEN 1 END) * 100.0 / COUNT(*)) as MobilePercentage FROM PlayerDevices GROUP BY Continent | gretelai_synthetic_text_to_sql |
CREATE TABLE Artworks (id INT, creation_year INT, movement VARCHAR(20)); | Find the number of artworks created in the 'Surrealism' movement during the year 1924. | SELECT COUNT(*) FROM Artworks WHERE creation_year = 1924 AND movement = 'Surrealism'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Employee (EmployeeID INT PRIMARY KEY, FirstName VARCHAR(50), LastName VARCHAR(50), Department VARCHAR(50), JobTitle VARCHAR(50), LastActivity DATETIME); | Update the Department for employee 12 to 'Information Technology' in the Employee table | UPDATE Employee SET Department = 'Information Technology' WHERE EmployeeID = 12; | gretelai_synthetic_text_to_sql |
CREATE TABLE crops (id INT PRIMARY KEY, name VARCHAR(50), scientific_name VARCHAR(50), growth_season VARCHAR(20), family VARCHAR(25), region VARCHAR(25)); INSERT INTO crops (id, name, scientific_name, growth_season, family, region) VALUES (1, 'Tomato', 'Solanum lycopersicum', 'Warm', 'Solanaceae', 'Midwest'); INSERT IN... | Which crops in the Midwest are part of the Solanaceae family and their scientific names? | SELECT name, scientific_name FROM crops WHERE family = 'Solanaceae' AND region = 'Midwest'; | gretelai_synthetic_text_to_sql |
CREATE TABLE donors (id INT, name VARCHAR(255), country VARCHAR(255));CREATE TABLE donations (id INT, donor_id INT, cause_id INT, amount DECIMAL(10, 2));CREATE VIEW us_donors AS SELECT * FROM donors WHERE country = 'United States'; | What's the total amount of donations made by individual donors from the United States, grouped by cause? | SELECT c.name, SUM(d.amount) FROM donations d INNER JOIN us_donors dn ON d.donor_id = dn.id GROUP BY d.cause_id, c.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE Exhibitions (exhibition_id INT, museum_name VARCHAR(255), artist_id INT, artwork_id INT); INSERT INTO Exhibitions (exhibition_id, museum_name, artist_id, artwork_id) VALUES (1, 'Museum X', 101, 201), (2, 'Museum Y', 102, 202), (3, 'Museum Z', 103, 203); CREATE TABLE Artworks (artwork_id INT, artist_id INT,... | Which museums exhibited artworks by artist '103'? | SELECT DISTINCT museum_name FROM Exhibitions WHERE artist_id = 103; | gretelai_synthetic_text_to_sql |
CREATE TABLE events (id INT, name VARCHAR(50), category VARCHAR(20), attendance INT); INSERT INTO events (id, name, category, attendance) VALUES (1, 'Ballet', 'dance', 200), (2, 'Play', 'theater', 150), (3, 'Festival', 'music', 300); | What is the total attendance for cultural events in the 'dance' category? | SELECT SUM(attendance) FROM events WHERE category = 'dance'; | gretelai_synthetic_text_to_sql |
CREATE TABLE volunteers (id INT, volunteer_name VARCHAR(50), volunteer_date DATE); INSERT INTO volunteers (id, volunteer_name, volunteer_date) VALUES (1, 'James Smith', '2021-02-05'), (2, 'Grace Johnson', '2021-04-15'), (3, 'Ethan Patel', '2021-01-20'), (4, 'Ava Singh', '2021-03-01'), (5, 'Oliver White', '2021-05-10');... | List the number of new volunteers per month, who have donated in the same month, in Canada during the year 2021? | SELECT MONTH(v.volunteer_date) AS month, COUNT(DISTINCT v.volunteer_name) AS new_volunteers FROM volunteers v JOIN donations d ON v.id = d.volunteer_id WHERE YEAR(v.volunteer_date) = 2021 AND MONTH(v.volunteer_date) = MONTH(d.donation_date) AND v.volunteer_country = 'Canada' GROUP BY month; | gretelai_synthetic_text_to_sql |
CREATE TABLE programs (program_id INT, program_name VARCHAR(255)); CREATE TABLE donations (donation_id INT, donor_id INT, program_id INT, donation_date DATE); INSERT INTO programs (program_id, program_name) VALUES (1, 'Education'), (2, 'Health'), (3, 'Environment'); INSERT INTO donations (donation_id, donor_id, program... | How many unique donors are there for each program in the first quarter of 2022? | SELECT program_id, COUNT(DISTINCT donor_id) FROM donations JOIN programs ON donations.program_id = programs.program_id WHERE QUARTER(donation_date) = 1 GROUP BY program_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE teams (team_id INT, team_name VARCHAR(50), city VARCHAR(50));CREATE TABLE athletes (athlete_id INT, athlete_name VARCHAR(50), team_id INT, well_being_score INT); INSERT INTO teams (team_id, team_name, city) VALUES (1, 'Atlanta Hawks', 'Atlanta'), (2, 'Boston Celtics', 'Boston'); INSERT INTO athletes (athle... | What is the average well-being score for athletes in each city? | SELECT te.city, AVG(a.well_being_score) FROM teams te JOIN athletes a ON te.team_id = a.team_id GROUP BY te.city; | gretelai_synthetic_text_to_sql |
CREATE TABLE clients (client_id INT, name VARCHAR(100), age INT, country VARCHAR(50), savings DECIMAL(10,2)); INSERT INTO clients (client_id, name, age, country, savings) VALUES (11, 'Ahmed Khan', 35, 'Pakistan', 3000); | What is the minimum savings balance for clients in Pakistan? | SELECT MIN(savings) FROM clients WHERE country = 'Pakistan'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Budget (id INT, department VARCHAR(50), allocated_budget FLOAT); INSERT INTO Budget (id, department, allocated_budget) VALUES (1, 'Education - Primary', 1000000.0), (2, 'Education - Secondary', 1500000.0), (3, 'Healthcare', 2000000.0), (4, 'Transportation', 1200000.0), (5, 'Education - Higher', 2500000.0); | Calculate the total budget allocated to each department in the "Budget" table, where the department name contains 'Education'. | SELECT department, SUM(allocated_budget) as total_budget FROM Budget WHERE department LIKE '%Education%' GROUP BY department; | gretelai_synthetic_text_to_sql |
CREATE TABLE Spacecraft (SpacecraftID INT, SpacecraftName VARCHAR(50), Manufacturer VARCHAR(50), LaunchDate DATE, NumberOfPeople INT, FuelType VARCHAR(50)); INSERT INTO Spacecraft (SpacecraftID, SpacecraftName, Manufacturer, LaunchDate, NumberOfPeople, FuelType) VALUES (1, 'Soyuz', 'Roscosmos', '2020-01-01', 3, 'Liquid... | Get the maximum number of people on board a single spacecraft | SELECT MAX(NumberOfPeople) FROM Spacecraft; | gretelai_synthetic_text_to_sql |
CREATE TABLE SalesStore (id INT PRIMARY KEY, store_name VARCHAR(50), location VARCHAR(50), garment_type VARCHAR(50), is_eco_friendly BOOLEAN, quantity INT, sale_date DATE); INSERT INTO SalesStore (id, store_name, location, garment_type, is_eco_friendly, quantity, sale_date) VALUES (1, 'Store D', 'Australia', 'Eco-Frien... | How many 'Eco-Friendly' garments were sold in 'Australia' retail stores in Q1 of 2022? | SELECT SUM(quantity) as total_quantity FROM SalesStore WHERE location = 'Australia' AND is_eco_friendly = true AND sale_date BETWEEN '2022-01-01' AND '2022-03-31'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Games (GameID INT, Genre VARCHAR(20), Revenue INT, ReleaseYear INT); INSERT INTO Games (GameID, Genre, Revenue, ReleaseYear) VALUES (1, 'Sports', 5000000, 2021), (2, 'RPG', 7000000, 2020), (3, 'Strategy', 6000000, 2021); | What is the total revenue for each game genre in 2021? | SELECT Genre, SUM(Revenue) as TotalRevenue FROM Games WHERE ReleaseYear = 2021 GROUP BY Genre | gretelai_synthetic_text_to_sql |
CREATE TABLE attorneys (id INT, name TEXT, gender TEXT, region TEXT, title TEXT); INSERT INTO attorneys (id, name, gender, region, title) VALUES (1, 'Jane Doe', 'Female', 'New York', 'Partner'); CREATE TABLE legal_precedents (id INT, attorney_id INT, year INT); INSERT INTO legal_precedents (id, attorney_id, year) VALUE... | How many legal precedents were set by female attorneys in the 'New York' region? | SELECT COUNT(*) FROM legal_precedents JOIN attorneys ON legal_precedents.attorney_id = attorneys.id WHERE attorneys.gender = 'Female' AND attorneys.region = 'New York'; | gretelai_synthetic_text_to_sql |
CREATE TABLE menus (menu_id INT, category VARCHAR(255)); INSERT INTO menus VALUES (1, 'Appetizers'); INSERT INTO menus VALUES (2, 'Entrees'); INSERT INTO menus VALUES (3, 'Desserts'); CREATE TABLE sales (sale_id INT, menu_id INT, quantity INT, region VARCHAR(255), price DECIMAL(10, 2)); | What is the total revenue for each menu category in a specific region? | SELECT m.category, SUM(s.price * s.quantity) as total_revenue FROM menus m INNER JOIN sales s ON m.menu_id = s.menu_id WHERE s.region = 'North' GROUP BY m.category; | gretelai_synthetic_text_to_sql |
CREATE TABLE student_mental_health (student_id INT, mental_health_score INT, measurement_date DATE); INSERT INTO student_mental_health (student_id, mental_health_score, measurement_date) VALUES (1, 70, '2022-01-01'), (1, 75, '2022-01-02'), (2, 60, '2022-01-01'), (2, 65, '2022-01-02'), (3, 80, '2022-01-01'), (3, 85, '20... | What is the difference in mental health scores between the first and last measurement for each student? | SELECT student_id, mental_health_score, measurement_date, mental_health_score - LAG(mental_health_score, 1, 0) OVER (PARTITION BY student_id ORDER BY measurement_date) as score_difference FROM student_mental_health; | gretelai_synthetic_text_to_sql |
CREATE TABLE ExhibitionAttendance (id INT, city VARCHAR(50), exhibition VARCHAR(50), attendance_date DATE); | How many visitors attended exhibitions in Paris during the first quarter? | SELECT COUNT(*) FROM ExhibitionAttendance WHERE city = 'Paris' AND attendance_date >= DATE_SUB(CURRENT_DATE, INTERVAL 3 MONTH) AND attendance_date < DATE_SUB(CURRENT_DATE, INTERVAL 2 MONTH); | gretelai_synthetic_text_to_sql |
CREATE TABLE districts (id INT, name VARCHAR(255)); INSERT INTO districts (id, name) VALUES (1, 'School District 1'), (2, 'School District 2'); CREATE TABLE schools (id INT, name VARCHAR(255), district_id INT); INSERT INTO schools (id, name, district_id) VALUES (1, 'School 1', 1), (2, 'School 2', 1), (3, 'School 3', 2)... | Delete all records from the 'districts' table that have no associated schools. | DELETE FROM districts WHERE id NOT IN (SELECT district_id FROM schools); | gretelai_synthetic_text_to_sql |
CREATE TABLE Northeast_SBP (permit_id INT, location VARCHAR(20), permit_date DATE, is_sustainable INT); INSERT INTO Northeast_SBP VALUES (1001, 'ME', '2022-02-15', 1), (1002, 'NH', '2022-04-20', 1), (1003, 'VT', '2022-06-05', 0); | How many sustainable building permits have been issued in the Northeast this year? | SELECT COUNT(permit_id) FROM Northeast_SBP WHERE is_sustainable = 1 AND YEAR(permit_date) = YEAR(CURRENT_DATE()); | gretelai_synthetic_text_to_sql |
CREATE TABLE financial_education (id INT, client_id INT, country VARCHAR(50), education_type VARCHAR(50)); INSERT INTO financial_education (id, client_id, country, education_type) VALUES (1, 101, 'Indonesia', 'Financial Literacy'), (2, 102, 'Indonesia', 'Debt Management'); | How many clients received financial education in Indonesia? | SELECT country, COUNT(*) as num_clients FROM financial_education WHERE country = 'Indonesia' GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA if not exists bioprocess_engineering;CREATE TABLE if not exists bioprocess_engineering.funding (id INT, period VARCHAR(50), year INT, amount FLOAT); INSERT INTO bioprocess_engineering.funding (id, period, year, amount) VALUES (1, 'Q1', 2022, 750000.0), (2, 'Q2', 2022, 900000.0); | What is the total funding for bioprocess engineering projects in Q1 2022? | SELECT SUM(amount) FROM bioprocess_engineering.funding WHERE period = 'Q1' AND year = 2022; | gretelai_synthetic_text_to_sql |
CREATE TABLE Astronauts (AstronautId INT, Name VARCHAR(50), Age INT, Gender VARCHAR(10)); CREATE TABLE Spacecraft (SpacecraftId INT, Name VARCHAR(50), Manufacturer VARCHAR(20)); CREATE TABLE SpaceMissions (MissionId INT, Name VARCHAR(50), SpacecraftId INT, AstronautId INT); INSERT INTO Astronauts (AstronautId, Name, Ag... | How many space missions has each manufacturer been involved in? | SELECT Spacecraft.Manufacturer, COUNT(DISTINCT SpaceMissions.MissionId) as MissionCount FROM Spacecraft INNER JOIN SpaceMissions ON Spacecraft.SpacecraftId = SpaceMissions.SpacecraftId GROUP BY Spacecraft.Manufacturer; | gretelai_synthetic_text_to_sql |
CREATE TABLE Equipment (id INT, name VARCHAR(100));CREATE TABLE Maintenance (id INT, equipment_id INT, cost DECIMAL(10,2)); INSERT INTO Equipment (id, name) VALUES (1, 'Tank'), (2, 'Fighter Jet'), (3, 'Helicopter'); INSERT INTO Maintenance (id, equipment_id, cost) VALUES (1, 1, 5000), (2, 1, 6000), (3, 2, 8000), (4, 2,... | What is the average maintenance cost for military equipment, grouped by equipment type? | SELECT e.name AS equipment_type, AVG(m.cost) AS avg_cost FROM Maintenance m JOIN Equipment e ON m.equipment_id = e.id GROUP BY e.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE equipment_maintenance (equipment_type VARCHAR(50), maintenance_date DATE, maintenance_cost DECIMAL(10,2)); | Compare military equipment maintenance costs between 'Type A' and 'Type B' aircraft in 2022 | SELECT equipment_type, SUM(maintenance_cost) FROM equipment_maintenance WHERE equipment_type IN ('Type A', 'Type B') AND EXTRACT(YEAR FROM maintenance_date) = 2022 GROUP BY equipment_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE Users (User_ID INT, Age INT, Gender VARCHAR(10), Country VARCHAR(50)); INSERT INTO Users (User_ID, Age, Gender, Country) VALUES (1, 25, 'Female', 'Australia'); | Delete records of viewers from Australia. | DELETE FROM Users WHERE Country = 'Australia'; | gretelai_synthetic_text_to_sql |
CREATE TABLE MaintenanceRequests (RequestID INT, RequestDate DATE); INSERT INTO MaintenanceRequests (RequestID, RequestDate) VALUES (1, '2022-01-05'), (2, '2022-02-12'), (3, '2022-03-20'), (4, '2022-04-25'), (5, '2022-05-10'); | What is the total number of military equipment maintenance requests in Q1 2022? | SELECT COUNT(*) FROM MaintenanceRequests WHERE RequestDate BETWEEN '2022-01-01' AND '2022-03-31'; | gretelai_synthetic_text_to_sql |
CREATE TABLE policies (policy_number INT, issue_date DATE); INSERT INTO policies (policy_number, issue_date) VALUES (12345, '2021-02-01'); INSERT INTO policies (policy_number, issue_date) VALUES (67890, '2021-03-01'); CREATE TABLE claims (id INT, policy_number INT, claim_amount DECIMAL(10,2)); INSERT INTO claims (id, p... | Calculate the total claim amount for policies issued in February | SELECT SUM(claim_amount) FROM claims JOIN policies ON claims.policy_number = policies.policy_number WHERE EXTRACT(MONTH FROM issue_date) = 2; | gretelai_synthetic_text_to_sql |
CREATE TABLE shows (id INT, title VARCHAR(100), genre VARCHAR(50), country VARCHAR(50), release_year INT, runtime INT); | What is the average runtime (in minutes) of shows by genre, excluding genres with less than 5 shows? | SELECT genre, AVG(runtime) FROM shows GROUP BY genre HAVING COUNT(genre) > 4; | gretelai_synthetic_text_to_sql |
CREATE TABLE states (id INT, name VARCHAR(255)); INSERT INTO states (id, name) VALUES (1, 'New York'), (2, 'California'); CREATE TABLE water_consumption (state_id INT, consumption INT, date DATE); INSERT INTO water_consumption (state_id, consumption, date) VALUES (1, 1200, '2021-07-01'), (1, 1300, '2021-07-02'), (1, 14... | What is the average daily water consumption (in gallons) in the state of New York in July 2021? | SELECT AVG(consumption) as avg_daily_consumption FROM water_consumption WHERE state_id = 1 AND date BETWEEN '2021-07-01' AND '2021-07-31'; | gretelai_synthetic_text_to_sql |
CREATE TABLE countries (id INT, name VARCHAR(50)); CREATE TABLE public_transportation (id INT, country_id INT, usage INT); CREATE TABLE personal_vehicles (id INT, country_id INT, usage INT); INSERT INTO countries (id, name) VALUES (1, 'United States'), (2, 'Germany'), (3, 'China'); INSERT INTO public_transportation (id... | What is the ratio of public transportation usage to personal vehicle usage in each country? | SELECT c.name, (SUM(pt.usage) / SUM(pv.usage)) AS ratio FROM countries c JOIN public_transportation pt ON c.id = pt.country_id JOIN personal_vehicles pv ON c.id = pv.country_id GROUP BY c.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE districts (district_id INT, district_name TEXT); INSERT INTO districts (district_id, district_name) VALUES (1, 'Downtown'), (2, 'Uptown'), (3, 'Suburbs'); CREATE TABLE students (student_id INT, student_name TEXT, district_id INT, mental_health_score INT); INSERT INTO students (student_id, student_name, dis... | What is the maximum mental health score of students in the 'Uptown' district? | SELECT MAX(s.mental_health_score) as max_score FROM students s JOIN districts d ON s.district_id = d.district_id WHERE d.district_name = 'Uptown'; | gretelai_synthetic_text_to_sql |
CREATE TABLE fishing_vessels (id INT, location VARCHAR(50), num_vessels INT, vessel_date DATE); INSERT INTO fishing_vessels (id, location, num_vessels, vessel_date) VALUES (1, 'Mediterranean Sea', 15, '2020-01-01'); INSERT INTO fishing_vessels (id, location, num_vessels, vessel_date) VALUES (2, 'Mediterranean Sea', 12,... | What is the average number of fishing vessels in the Mediterranean Sea per month in 2020? | SELECT AVG(num_vessels) FROM fishing_vessels WHERE location = 'Mediterranean Sea' AND YEAR(vessel_date) = 2020 GROUP BY location, YEAR(vessel_date), MONTH(vessel_date); | gretelai_synthetic_text_to_sql |
CREATE TABLE MilitaryEquipmentSales (seller VARCHAR(255), buyer VARCHAR(255), equipment_model VARCHAR(255), quantity INT, sale_date DATE); | What is the total number of military equipment sold by 'ACME Corp' to the 'Government of XYZ' for the 'M1 Abrams' tank model? | SELECT SUM(quantity) FROM MilitaryEquipmentSales WHERE seller = 'ACME Corp' AND buyer = 'Government of XYZ' AND equipment_model = 'M1 Abrams'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Players (PlayerID INT, GamePreference VARCHAR(20)); INSERT INTO Players (PlayerID, GamePreference) VALUES (1, 'Shooter'), (2, 'RPG'), (3, 'Strategy'), (4, 'Shooter'), (5, 'RPG'); CREATE TABLE GameDesign (GameID INT, GameName VARCHAR(20), Genre VARCHAR(20)); INSERT INTO GameDesign (GameID, GameName, Genre) ... | What is the total number of players who play games in each genre? | SELECT GameDesign.Genre, COUNT(Players.PlayerID) as Count FROM GameDesign INNER JOIN Players ON Players.GamePreference = GameDesign.Genre GROUP BY GameDesign.Genre; | gretelai_synthetic_text_to_sql |
CREATE TABLE customers (customer_id INT, region VARCHAR(50), financially_capable BOOLEAN); | Calculate the percentage of financially capable customers in each region. | SELECT region, AVG(CAST(financially_capable AS FLOAT)) * 100 AS pct_financially_capable FROM customers GROUP BY region; | gretelai_synthetic_text_to_sql |
CREATE TABLE Branches (branch_id INT, branch_name VARCHAR(255));CREATE TABLE Menu (dish_name VARCHAR(255), branch_id INT);CREATE TABLE Sales (sale_date DATE, dish_name VARCHAR(255), quantity INT); | What is the average quantity of each dish sold per day in all branches? | SELECT Menu.dish_name, AVG(quantity) as avg_quantity FROM Sales JOIN Menu ON Sales.dish_name = Menu.dish_name GROUP BY Menu.dish_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE renewable_energy_projects (project_id INT, project_name VARCHAR(255), city VARCHAR(255), state VARCHAR(255), project_type VARCHAR(255)); INSERT INTO renewable_energy_projects (project_id, project_name, city, state, project_type) VALUES (1, 'Texas Wind Farm', 'Austin', 'TX', 'Wind'); INSERT INTO renewable_e... | What is the total number of renewable energy projects in the state of Texas? | SELECT COUNT(*) FROM renewable_energy_projects WHERE state = 'TX'; | gretelai_synthetic_text_to_sql |
CREATE TABLE WasteGeneration (Date date, Location text, Material text, Quantity integer);CREATE TABLE CircularEconomyInitiatives (Location text, Initiative text, StartDate date); | What is the total waste quantity generated and the total number of circular economy initiatives, for each location and material, for the year 2023? | SELECT wg.Location, wg.Material, SUM(wg.Quantity) as TotalWasteQuantity, COUNT(DISTINCT cei.Initiative) as NumberOfInitiatives FROM WasteGeneration wg LEFT JOIN CircularEconomyInitiatives cei ON wg.Location = cei.Location WHERE wg.Date >= '2023-01-01' AND wg.Date < '2024-01-01' GROUP BY wg.Location, wg.Material; | gretelai_synthetic_text_to_sql |
CREATE TABLE regulatory_frameworks (digital_asset VARCHAR(10), country VARCHAR(20), regulatory_status VARCHAR(30)); INSERT INTO regulatory_frameworks (digital_asset, country, regulatory_status) VALUES ('XRP', 'United States', 'Under Review'); | What is the regulatory status of XRP in the United States? | SELECT regulatory_status FROM regulatory_frameworks WHERE digital_asset = 'XRP' AND country = 'United States'; | gretelai_synthetic_text_to_sql |
CREATE TABLE consumer_awareness (region_id INT PRIMARY KEY, awareness_score INT, year INT); | Delete consumer awareness data for a specific region. | DELETE FROM consumer_awareness WHERE region_id = 456 AND year = 2021; | gretelai_synthetic_text_to_sql |
CREATE TABLE DigitalExhibitions (exhibition_id INT, exhibition_name VARCHAR(50), visitors INT); INSERT INTO DigitalExhibitions (exhibition_id, exhibition_name, visitors) VALUES (1, 'Nature', 25000), (2, 'Art', 30000), (3, 'History', 20000), (4, 'Science', 35000); | Identify the top 3 most visited exhibitions in the digital museum | SELECT exhibition_name, visitors FROM DigitalExhibitions ORDER BY visitors DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE accounts (customer_id INT, account_type VARCHAR(20), branch VARCHAR(20), balance DECIMAL(10,2), credit_limit DECIMAL(10,2)); INSERT INTO accounts (customer_id, account_type, branch, balance, credit_limit) VALUES (1, 'Savings', 'New York', 5000.00, 1000.00), (2, 'Checking', 'New York', 7000.00, 2000.00), (3... | What is the average credit card limit for customers in the Mumbai branch? | SELECT AVG(credit_limit) FROM accounts WHERE account_type = 'Credit Card' AND branch = 'Mumbai'; | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_mammals (id INT, name TEXT, iucn_status TEXT); INSERT INTO marine_mammals (id, name, iucn_status) VALUES (1, 'Blue Whale', 'Endangered'), (2, 'Dolphin', 'Least Concern'), (3, 'Manatee', 'Vulnerable'); | List all marine mammals that are endangered and their IUCN status. | SELECT name, iucn_status FROM marine_mammals WHERE iucn_status = 'Endangered'; | gretelai_synthetic_text_to_sql |
CREATE TABLE military_spending (id INT, country VARCHAR(255), amount FLOAT, year INT); INSERT INTO military_spending (id, country, amount, year) VALUES (1, 'Brazil', 25.6, 2018); INSERT INTO military_spending (id, country, amount, year) VALUES (2, 'South Africa', 30.8, 2019); | What is the military spending by country and year? | SELECT country, year, SUM(amount) as total_spending FROM military_spending GROUP BY country, year; | gretelai_synthetic_text_to_sql |
CREATE TABLE Farmers (id INT PRIMARY KEY, name VARCHAR(50), age INT, location VARCHAR(50), is_organic BOOLEAN); INSERT INTO Farmers (id, name, age, location, is_organic) VALUES (1, 'James Mwangi', 35, 'Kenya', true); INSERT INTO Farmers (id, name, age, location, is_organic) VALUES (2, 'Grace Wambui', 40, 'Tanzania', fa... | How many farmers in Kenya are certified as organic before 2018? | SELECT COUNT(*) FROM Farmers JOIN Organic_Certification ON Farmers.id = Organic_Certification.farmer_id WHERE Farmers.location = 'Kenya' AND certification_date < '2018-01-01' AND is_organic = true; | gretelai_synthetic_text_to_sql |
CREATE TABLE vessels_2021 (id INT, vessel_id INT, name VARCHAR(50), country VARCHAR(50), registration_date DATE); INSERT INTO vessels_2021 VALUES (1, 1, 'Vessel1', 'Japan', '2021-01-01'), (2, 2, 'Vessel2', 'Japan', '2021-02-15'), (3, 3, 'Vessel3', 'China', '2021-04-01'); | How many vessels were there in each country in 2021? | SELECT country, COUNT(DISTINCT vessel_id) AS num_vessels FROM vessels_2021 WHERE YEAR(registration_date) = 2021 GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE workout_sessions (id INT, user_id INT, session_type VARCHAR(20), session_duration INT, session_date DATE); INSERT INTO workout_sessions (id, user_id, session_type, session_duration, session_date) VALUES (1, 20, 'Yoga', 60, '2022-09-01'), (2, 25, 'Pilates', 45, '2022-08-15'), (3, 42, 'Yoga', 90, '2022-09-10... | What is the total duration of yoga sessions for users over 40? | SELECT SUM(session_duration) FROM workout_sessions WHERE session_type = 'Yoga' AND user_id >= 40; | gretelai_synthetic_text_to_sql |
CREATE TABLE SustainableFashion (ProductID INT, SustainableScore INT, ManufacturingDate DATE); INSERT INTO SustainableFashion (ProductID, SustainableScore, ManufacturingDate) VALUES (1, 80, '2021-01-01'), (2, 85, '2021-02-01'), (3, 90, '2021-03-01'), (4, 70, '2021-04-01'), (5, 95, '2021-05-01'), (6, 82, '2021-01-15'), ... | What is the average sustainable score for products manufactured in 'Europe' in the month of 'January'? | SELECT AVG(SustainableScore) FROM SustainableFashion WHERE ManufacturingDate BETWEEN '2021-01-01' AND '2021-01-31'; | gretelai_synthetic_text_to_sql |
CREATE TABLE news_stories (id INT, published_date DATE); INSERT INTO news_stories (id, published_date) VALUES (1, '2022-01-01'), (2, '2022-01-02'), (3, '2022-01-09'), (4, '2022-01-16') | Find the total number of news stories published per week in 2022 | SELECT WEEKOFYEAR(published_date) AS week, COUNT(*) AS total FROM news_stories WHERE YEAR(published_date) = 2022 GROUP BY week; | gretelai_synthetic_text_to_sql |
CREATE TABLE peacekeeping_operation_costs (id INT, year INT, military_branch VARCHAR(255), cost DECIMAL(10,2)); INSERT INTO peacekeeping_operation_costs (id, year, military_branch, cost) VALUES (1, 2015, 'Army', 50000), (2, 2016, 'Navy', 60000), (3, 2017, 'Air Force', 40000), (4, 2018, 'Marines', 70000), (5, 2019, 'Coa... | What is the percentage of peacekeeping operation costs covered by each military branch in each year, ordered by year and branch? | SELECT year, military_branch, ROUND(100.0 * cost / SUM(cost) OVER (PARTITION BY year), 2) AS percentage FROM peacekeeping_operation_costs ORDER BY year, military_branch; | gretelai_synthetic_text_to_sql |
CREATE TABLE new_ship_capacities (id INT PRIMARY KEY, ship_type_id INT, region_id INT, capacity INT, FOREIGN KEY (ship_type_id) REFERENCES ship_types(id), FOREIGN KEY (region_id) REFERENCES regions(id)); | Update the capacity of all 'Bulk Carrier' ships in the 'Indian' region to 150000. | UPDATE ship_capacities sc JOIN new_ship_capacities nsc ON sc.ship_type_id = nsc.ship_type_id AND sc.region_id = nsc.region_id SET sc.capacity = 150000 WHERE nsc.ship_type_id = (SELECT id FROM ship_types WHERE name = 'Bulk Carrier') AND nsc.region_id = (SELECT id FROM regions WHERE name = 'Indian'); | gretelai_synthetic_text_to_sql |
CREATE TABLE Policyholders (ID INT, ClaimAmount DECIMAL(10, 2), State VARCHAR(50)); INSERT INTO Policyholders (ID, ClaimAmount, State) VALUES (1, 1500.00, 'New York'), (2, 500.00, 'Texas'), (3, 1000.00, 'California'), (4, 2000.00, 'New York'); | What is the total claim amount for each policyholder living in New York? | SELECT State, SUM(ClaimAmount) FROM Policyholders WHERE State = 'New York' GROUP BY State; | gretelai_synthetic_text_to_sql |
CREATE TABLE menus (menu_id INT, category VARCHAR(255)); INSERT INTO menus VALUES (1, 'Appetizers'); INSERT INTO menus VALUES (2, 'Entrees'); INSERT INTO menus VALUES (3, 'Desserts'); CREATE TABLE sales (sale_id INT, menu_id INT, quantity INT, country VARCHAR(255), price DECIMAL(10, 2), region VARCHAR(255)); | What is the total revenue for each menu category in the African continent? | SELECT m.category, SUM(s.price * s.quantity) as total_revenue FROM menus m INNER JOIN sales s ON m.menu_id = s.menu_id WHERE s.region = 'African continent' GROUP BY m.category; | gretelai_synthetic_text_to_sql |
CREATE TABLE sustainable_practices (practice_id integer, practice_name text, description text); | Create a table named "sustainable_practices" with columns "practice_id", "practice_name", "description" of types integer, text, text respectively | CREATE TABLE sustainable_practices (practice_id integer, practice_name text, description text); | gretelai_synthetic_text_to_sql |
CREATE TABLE co_ownership (id INT, city VARCHAR(20), size FLOAT); INSERT INTO co_ownership (id, city, size) VALUES (1, 'Seattle', 1200.5), (2, 'Portland', 1100.75), (3, 'Seattle', 1300.25), (4, 'NYC', 800.5); | What is the total size of co-owned properties in each city? | SELECT city, SUM(size) as total_size FROM co_ownership GROUP BY city; | gretelai_synthetic_text_to_sql |
CREATE TABLE baseball_matches (match_id INT, player_name VARCHAR(100), home_runs INT); | What is the maximum number of home runs hit in a single game in the baseball_matches table? | SELECT MAX(home_runs) FROM baseball_matches WHERE location = 'home'; | gretelai_synthetic_text_to_sql |
CREATE TABLE incidents (incident_id INT PRIMARY KEY, incident_title VARCHAR(255), department_id INT); CREATE TABLE departments (department_id INT PRIMARY KEY, department_name VARCHAR(255)); INSERT INTO incidents (incident_id, incident_title, department_id) VALUES (1, 'Phishing Attack', 104), (2, 'Malware Infection', 10... | Show the total number of security incidents for each department in the 'incidents' and 'departments' tables | SELECT d.department_name, COUNT(i.incident_id) as total_incidents FROM incidents i INNER JOIN departments d ON i.department_id = d.department_id GROUP BY d.department_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE underwriting (id INT, group VARCHAR(10), name VARCHAR(20), claim_amount DECIMAL(10,2)); INSERT INTO underwriting (id, group, name, claim_amount) VALUES (1, 'High Risk', 'John Doe', 5000.00), (2, 'Medium Risk', 'Sophia Gonzalez', 6000.00), (3, 'Medium Risk', 'Javier Rodriguez', 7000.00), (4, 'Low Risk', 'Em... | Determine the average claim amount for policyholders in each underwriting group. | SELECT group, AVG(claim_amount) FROM underwriting GROUP BY group; | gretelai_synthetic_text_to_sql |
CREATE TABLE faculty (id INT PRIMARY KEY, name VARCHAR(50), department VARCHAR(50), years_of_service INT); | Insert new faculty members into the faculty table. | INSERT INTO faculty (id, name, department, years_of_service) VALUES (6, 'Dr. Maria Rodriguez', 'Mathematics', 12), (7, 'Dr. Ali Al-Khateeb', 'Computer Science', 15), (8, 'Dr. Fatima Ahmed', 'Physics', 18); | gretelai_synthetic_text_to_sql |
CREATE TABLE Employees (EmployeeID INT, Gender VARCHAR(20), Department VARCHAR(20)); INSERT INTO Employees (EmployeeID, Gender, Department) VALUES (1, 'Male', 'IT'), (2, 'Female', 'IT'), (3, 'Non-binary', 'HR'), (4, 'Gay', 'Marketing'), (5, 'Lesbian', 'Marketing'); | Count the number of employees who identify as LGBTQ+ in the Marketing department. | SELECT COUNT(*) FROM Employees WHERE Department = 'Marketing' AND Gender IN ('Lesbian', 'Gay', ' Bisexual', 'Transgender', 'Queer', 'Questioning'); | gretelai_synthetic_text_to_sql |
CREATE TABLE sales (sale_id INT, sale_date DATE, sale_channel VARCHAR(20), sale_revenue FLOAT); INSERT INTO sales (sale_id, sale_date, sale_channel, sale_revenue) VALUES (1, '2022-01-01', 'online', 100.0), (2, '2022-01-02', 'retail', 50.0), (3, '2022-01-03', 'online', 120.0); | What is the total revenue generated from online sales in Q1 2022? | SELECT SUM(sale_revenue) FROM sales WHERE sale_channel = 'online' AND sale_date BETWEEN '2022-01-01' AND '2022-03-31'; | gretelai_synthetic_text_to_sql |
CREATE TABLE athletes (id INT, name VARCHAR(50), age INT, sport VARCHAR(50)); INSERT INTO athletes (id, name, age, sport) VALUES (1, 'John Doe', 25, 'Basketball'); INSERT INTO athletes (id, name, age, sport) VALUES (2, 'Jane Smith', 30, 'Basketball'); | What is the average age of athletes who have participated in the NBA finals? | SELECT AVG(age) FROM athletes WHERE sport = 'Basketball' AND id IN (SELECT athlete_id FROM nba_finals); | gretelai_synthetic_text_to_sql |
CREATE TABLE mining_sector (country VARCHAR(50), year INT, tons_extracted INT, employees INT); INSERT INTO mining_sector (country, year, tons_extracted, employees) VALUES ('Canada', 2020, 1200000, 8000), ('Australia', 2020, 1500000, 10000), ('Chile', 2020, 1000000, 7000); | What is the average labor productivity (measured in metric tons of ore extracted per employee) in the mining sector, for each country, for the year 2020? | SELECT country, AVG(tons_extracted/employees) as avg_labor_productivity FROM mining_sector WHERE year = 2020 GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE LuxuryElectricVehicles (id INT, make VARCHAR(50), model VARCHAR(50), price DECIMAL(10,2)); | What is the average price of luxury electric vehicles in the luxuryelectricvehicles schema? | SELECT AVG(price) FROM luxuryelectricvehicles.LuxuryElectricVehicles; | gretelai_synthetic_text_to_sql |
CREATE TABLE Organizations (OrgID INT, OrgName TEXT); CREATE TABLE Volunteers (VolID INT, OrgID INT, VolunteerHours INT); INSERT INTO Organizations (OrgID, OrgName) VALUES (1, 'Habitat for Humanity'), (2, 'American Red Cross'); INSERT INTO Volunteers (VolID, OrgID, VolunteerHours) VALUES (1, 1, 100), (2, 1, 200), (3, 2... | What is the average number of volunteer hours per volunteer for each organization? | SELECT OrgName, AVG(VolunteerHours) FROM Organizations JOIN Volunteers ON Organizations.OrgID = Volunteers.OrgID GROUP BY OrgName; | gretelai_synthetic_text_to_sql |
CREATE TABLE departments (id INT, name TEXT, budget INT); INSERT INTO departments (id, name, budget) VALUES (1, 'Computer Science', 1000000), (2, 'Mathematics', 750000); CREATE TABLE research_grants (id INT, department_id INT, title TEXT, funding_amount INT); INSERT INTO research_grants (id, department_id, title, fundi... | Which departments have received grants for 'Artificial Intelligence'? | SELECT d.name FROM departments d INNER JOIN research_grants rg ON d.id = rg.department_id WHERE rg.title LIKE '%Artificial Intelligence%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE District (id INT, name VARCHAR(255)); INSERT INTO District (id, name) VALUES (1, 'North'), (2, 'South'), (3, 'East'), (4, 'West'); CREATE TABLE LegalTechnologyPatents (id INT, district_id INT, patents INT); INSERT INTO LegalTechnologyPatents (id, district_id, patents) VALUES (1, 1, 150), (2, 1, 200), (3, 2... | What is the total number of legal technology patents per district? | SELECT d.name, SUM(ltp.patents) as total_patents FROM District d JOIN LegalTechnologyPatents ltp ON d.id = ltp.district_id GROUP BY d.id; | gretelai_synthetic_text_to_sql |
CREATE TABLE fan_demographics (fan_id INT, age INT, gender VARCHAR(10), favorite_team VARCHAR(20)); | Insert records into 'fan_demographics' table for fans of 'Sports Team D' | INSERT INTO fan_demographics (fan_id, age, gender, favorite_team) VALUES (10, 25, 'Female', 'Sports Team D'), (11, 35, 'Male', 'Sports Team D'), (12, 42, 'Non-binary', 'Sports Team D'); | gretelai_synthetic_text_to_sql |
CREATE TABLE NetworkDevices (id INT, device_name VARCHAR(50), severity VARCHAR(10), discovered_date DATE); INSERT INTO NetworkDevices (id, device_name, severity, discovered_date) VALUES (1, 'Router1', 'High', '2021-08-01'), (2, 'Switch1', 'Medium', '2021-07-15'), (3, 'Firewall1', 'Low', '2021-06-01'), (4, 'Router2', 'H... | Which devices were discovered on a specific date in the 'NetworkDevices' table? | SELECT device_name FROM NetworkDevices WHERE discovered_date = '2021-08-01'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Budget (Sector VARCHAR(50), BudgetAmount NUMERIC(15,2), BudgetYear INT); INSERT INTO Budget (Sector, BudgetAmount, BudgetYear) VALUES ('Healthcare', 1500000, 2020), ('Healthcare', 200000, 2020), ('Healthcare', 750000, 2020); | What was the total budget for 'Healthcare' sector in the year 2020, excluding records with a budget less than $100,000? | SELECT SUM(BudgetAmount) FROM Budget WHERE Sector = 'Healthcare' AND BudgetYear = 2020 AND BudgetAmount >= 100000; | gretelai_synthetic_text_to_sql |
CREATE TABLE CultivationFacility (FacilityID INT, FacilityName VARCHAR(255), TotalProductionCost DECIMAL(10,2)); INSERT INTO CultivationFacility (FacilityID, FacilityName, TotalProductionCost) VALUES (1, 'Facility X', 50000.00), (2, 'Facility Y', 55000.00), (3, 'Facility Z', 45000.00); | Which cultivation facility has the highest total production cost? | SELECT FacilityName, TotalProductionCost FROM CultivationFacility ORDER BY TotalProductionCost DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE Water_Usage (id INT, year INT, water_consumption FLOAT); INSERT INTO Water_Usage (id, year, water_consumption) VALUES (1, 2018, 12000.0), (2, 2019, 13000.0), (3, 2020, 14000.0), (4, 2021, 15000.0); | What is the total water consumption in the Water_Usage table for the year 2020? | SELECT SUM(water_consumption) FROM Water_Usage WHERE year = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE sales (sale_id int, product_id int, quantity int, date date); INSERT INTO sales (sale_id, product_id, quantity, date) VALUES (1, 1, 10, '2021-01-01'), (2, 2, 15, '2021-01-02'), (3, 1, 12, '2021-01-03'), (4, 3, 20, '2021-01-04'), (5, 4, 18, '2021-02-05'), (6, 1, 8, '2021-02-06'), (7, 2, 10, '2021-02-07'); C... | What was the average price of products sold in each month? | SELECT DATE_FORMAT(s.date, '%Y-%m') as month, AVG(p.price) as avg_price FROM sales s JOIN products p ON s.product_id = p.product_id GROUP BY month; | gretelai_synthetic_text_to_sql |
CREATE TABLE streams (stream_id INT, track_id INT, genre VARCHAR(50), country VARCHAR(50), timestamp TIMESTAMP, revenue FLOAT); INSERT INTO streams (stream_id, track_id, genre, country, timestamp, revenue) VALUES (1, 1001, 'R&B', 'United States', '2022-02-01 00:00:00', 0.15), (2, 1002, 'R&B', 'United States', '2022-02-... | What is the average revenue per stream for the R&B genre in the United States over the past year? | SELECT AVG(revenue) FROM streams WHERE genre = 'R&B' AND country = 'United States' AND timestamp >= '2021-01-01' AND timestamp < '2022-01-01'; | gretelai_synthetic_text_to_sql |
CREATE TABLE platform (platform_id INT, platform_name TEXT, oil_production_q3_2021 FLOAT, oil_production_q4_2021 FLOAT); INSERT INTO platform (platform_id, platform_name, oil_production_q3_2021, oil_production_q4_2021) VALUES (1, 'A', 1000, 1200), (2, 'B', 1600, 1800), (3, 'C', 2200, 2500); | Which platform had the highest oil production increase between Q3 and Q4 2021? | SELECT platform_name, (oil_production_q4_2021 - oil_production_q3_2021) as oil_production_increase FROM platform ORDER BY oil_production_increase DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE Donations (DonationID INT, DonorID INT, DonationAmount DECIMAL(10,2), DonationDate DATE); | What is the total amount donated per month? | SELECT EXTRACT(MONTH FROM D.DonationDate) AS Month, SUM(D.DonationAmount) FROM Donations D GROUP BY Month; | gretelai_synthetic_text_to_sql |
CREATE TABLE Unions (UnionID INT, UnionName TEXT); CREATE TABLE Agreements (AgreementID INT, UnionID INT, AgreementDate DATE); | What is the total number of collective bargaining agreements signed by each union in a specific year? | SELECT u.UnionName, YEAR(a.AgreementDate) AS AgreementYear, COUNT(a.AgreementID) AS TotalAgreementsPerYear FROM Unions u INNER JOIN Agreements a ON u.UnionID = a.UnionID GROUP BY u.UnionName, AgreementYear; | gretelai_synthetic_text_to_sql |
CREATE TABLE Project_Timelines (project_id INT, project_start_date DATE, project_end_date DATE, project_region VARCHAR(50)); | What is the trend of defense project timelines in the African continent over the last 3 years? | SELECT project_region, DATEPART(year, project_start_date) as project_year, AVG(DATEDIFF(day, project_start_date, project_end_date)) as avg_project_duration FROM Project_Timelines WHERE project_region = 'African continent' AND project_start_date >= DATEADD(year, -3, GETDATE()) GROUP BY project_region, project_year; | gretelai_synthetic_text_to_sql |
CREATE TABLE vulnerabilities (id INT, system VARCHAR(20), vulnerability_type VARCHAR(20), timestamp TIMESTAMP); INSERT INTO vulnerabilities (id, system, vulnerability_type, timestamp) VALUES (1, 'Firewall', 'Configuration issue', '2022-01-01 10:00:00'), (2, 'Router', 'Unpatched software', '2022-01-02 11:00:00'); | Identify the top three most vulnerable systems based on the number of recorded vulnerabilities? | SELECT system, COUNT(*) as num_vulnerabilities FROM vulnerabilities GROUP BY system ORDER BY num_vulnerabilities DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE mobile_plans (plan_id INT, plan_type VARCHAR(50), location VARCHAR(50)); INSERT INTO mobile_plans (plan_id, plan_type, location) VALUES (1, 'postpaid', 'Chicago'); INSERT INTO mobile_plans (plan_id, plan_type, location) VALUES (2, 'prepaid', 'Chicago'); INSERT INTO mobile_plans (plan_id, plan_type, locatio... | What is the distribution of mobile plans by customer location? | SELECT plan_type, location, COUNT(*) FROM mobile_plans GROUP BY plan_type, location; | gretelai_synthetic_text_to_sql |
CREATE TABLE Budget (Year INT, Department VARCHAR(20), Amount INT); INSERT INTO Budget VALUES (2022, 'Education', 1500000), (2022, 'Healthcare', 1200000); | What is the total budget allocated to education and healthcare in 2022? | SELECT SUM(Amount) FROM Budget WHERE Year = 2022 AND Department IN ('Education', 'Healthcare'); | gretelai_synthetic_text_to_sql |
CREATE TABLE vulnerabilities (id INT, sector VARCHAR(20), vulnerability VARCHAR(50), frequency INT); | What is the total number of unique vulnerabilities in the financial sector? | SELECT COUNT(DISTINCT vulnerability) FROM vulnerabilities WHERE sector = 'financial'; | 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.