context stringlengths 11 9.12k | question stringlengths 0 1.06k | SQL stringlengths 2 4.44k | source stringclasses 28
values |
|---|---|---|---|
CREATE TABLE tracks (id INT, title TEXT, length FLOAT, album_id INT); CREATE TABLE albums (id INT, title TEXT, genre TEXT); INSERT INTO tracks (id, title, length, album_id) VALUES (1, 'Track1', 5.2, 1), (2, 'Track2', 3.8, 1), (3, 'Track3', 4.5, 2); INSERT INTO albums (id, title, genre) VALUES (1, 'Album1', 'classical')... | Find the total duration of classical music in the database. | SELECT SUM(tracks.length) FROM tracks JOIN albums ON tracks.album_id = albums.id WHERE albums.genre = 'classical'; | gretelai_synthetic_text_to_sql |
CREATE TABLE suppliers (id INT, name TEXT, local BOOLEAN); INSERT INTO suppliers (id, name, local) VALUES (1, 'Green Earth Farms', true), (2, 'Smith Wholesale', false), (3, 'Health Food Inc.', false); CREATE TABLE purchases (supplier_id INT, weight FLOAT); INSERT INTO purchases (supplier_id, weight) VALUES (1, 100.5), ... | What is the total weight of ingredients sourced from local suppliers? | SELECT SUM(purchases.weight) FROM purchases JOIN suppliers ON purchases.supplier_id = suppliers.id WHERE suppliers.local = true; | gretelai_synthetic_text_to_sql |
CREATE TABLE NON_ORGANIC_FOOD (id INT, name VARCHAR(50), category VARCHAR(50)); INSERT INTO NON_ORGANIC_FOOD (id, name, category) VALUES (1, 'Chicken Nuggets', 'Meat'), (2, 'Potato Chips', 'Snacks'); | How many unique non-organic product categories exist in the NON_ORGANIC_FOOD table? | SELECT COUNT(DISTINCT category) FROM NON_ORGANIC_FOOD WHERE is_organic = false; | gretelai_synthetic_text_to_sql |
CREATE TABLE CreativeSafetyMeasures (id INT, measure VARCHAR(255), transparency_rating DECIMAL(5,2)); INSERT INTO CreativeSafetyMeasures (id, measure, transparency_rating) VALUES (1, 'AI Risk Assessment', 8.50), (2, 'AI Incident Response', 9.25), (3, 'AI Monitoring', 8.75); | What is the maximum transparency rating for each AI safety measure in the creative AI domain? | SELECT measure, MAX(transparency_rating) as max_transparency_rating FROM CreativeSafetyMeasures GROUP BY measure; | gretelai_synthetic_text_to_sql |
CREATE TABLE workforce_development ( id INT PRIMARY KEY, employee_name VARCHAR(255), department VARCHAR(64), safety_training_hours INT ); | Insert a new record into the "workforce_development" table with "employee_name" as "Richard Roe", "department" as "warehouse", and "safety_training_hours" as 8 | INSERT INTO workforce_development (employee_name, department, safety_training_hours) VALUES ('Richard Roe', 'warehouse', 8); | gretelai_synthetic_text_to_sql |
CREATE TABLE Products (id INT PRIMARY KEY, name VARCHAR(255), category VARCHAR(255), supplier_id INT, FOREIGN KEY (supplier_id) REFERENCES Suppliers(id)); CREATE TABLE Trends (id INT PRIMARY KEY, product_id INT, trend VARCHAR(255), popularity INT); INSERT INTO Products (id, name, category, supplier_id) VALUES (1, 'Prod... | What are the product trends with the highest popularity? | SELECT Trends.product_id, Trends.trend FROM Trends INNER JOIN (SELECT product_id, MAX(popularity) as max_popularity FROM Trends GROUP BY product_id) as MaxTrends ON Trends.product_id = MaxTrends.product_id AND Trends.popularity = MaxTrends.max_popularity | gretelai_synthetic_text_to_sql |
CREATE TABLE Donors (DonorID INT, DonorName TEXT, Country TEXT, DateOfLastDonation DATE); INSERT INTO Donors (DonorID, DonorName, Country, DateOfLastDonation) VALUES (1, 'Kate', 'Australia', '2022-02-20'), (2, 'Luke', 'New Zealand', '2022-01-05'), (3, 'Mia', 'Fiji', '2021-12-10'); | Which donors from Oceania have not donated in the last 6 months? | SELECT Donors.DonorID, Donors.DonorName, Donors.Country FROM Donors WHERE Donors.Country LIKE 'Oceania%' AND Donors.DateOfLastDonation < DATE_SUB(CURDATE(), INTERVAL 6 MONTH); | gretelai_synthetic_text_to_sql |
CREATE TABLE Aircraft (Id INT, Name VARCHAR(50), Manufacturer VARCHAR(50), FlightHours INT); INSERT INTO Aircraft (Id, Name, Manufacturer, FlightHours) VALUES (1, 'A300', 'Airbus', 35000), (2, 'A310', 'Airbus', 45000), (3, 'A320', 'Airbus', 55000), (4, 'A330', 'Airbus', 65000), (5, 'A340', 'Airbus', 75000), (6, 'A350',... | What is the total number of flight hours for all Airbus aircraft? | SELECT SUM(FlightHours) FROM Aircraft WHERE Manufacturer = 'Airbus'; | gretelai_synthetic_text_to_sql |
CREATE TABLE donors (donor_id INT, name TEXT, amount_donated DECIMAL(10, 2)); INSERT INTO donors VALUES (1, 'John Doe', 500.00), (2, 'Jane Smith', 350.00); | What is the total amount donated by each donor in the 'donors' table? | SELECT donor_id, SUM(amount_donated) FROM donors GROUP BY donor_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE Menus (id INT, restaurant_name VARCHAR(50), item_name VARCHAR(50), category VARCHAR(20), price DECIMAL(5,2)); INSERT INTO Menus VALUES (1, 'Green Garden', 'Veggie Delight', 'Sandwich', 6.50), (2, 'Green Garden', 'Quinoa Salad', 'Salad', 8.99), (3, 'Green Garden', 'BBQ Chicken', 'Pizza', 12.49), (4, 'Green ... | What is the average price of vegan dishes at 'Green Garden'? | SELECT AVG(price) FROM Menus WHERE restaurant_name = 'Green Garden' AND category = 'Vegan'; | gretelai_synthetic_text_to_sql |
CREATE TABLE historical_sites (name TEXT, state TEXT, year_established INTEGER); INSERT INTO historical_sites (name, state, year_established) VALUES ('Site 1', 'NY', 1850), ('Site 2', 'NY', 1900), ('Site 3', 'NY', 1930); | List all the historical sites located in the state of New York and their year of establishment. | SELECT name, year_established FROM historical_sites WHERE state = 'NY'; | gretelai_synthetic_text_to_sql |
CREATE TABLE GameSessions (PlayerID int, PlayerName varchar(50), Country varchar(50), GameType varchar(50), HoursPlayed decimal(5,2)); INSERT INTO GameSessions (PlayerID, PlayerName, Country, GameType, HoursPlayed) VALUES (1, 'John Doe', 'USA', 'RPG', 25.5), (2, 'Jane Smith', 'Canada', 'RPG', 30.2), (3, 'Alice Johnson'... | What is the total number of hours played by North American players in the 'RPG' genre? | SELECT SUM(HoursPlayed) FROM GameSessions WHERE Country IN ('USA', 'Canada', 'Mexico') AND GameType = 'RPG'; | gretelai_synthetic_text_to_sql |
CREATE TABLE patients (id INT, age INT, diagnosis VARCHAR(20), residence VARCHAR(10)); INSERT INTO patients (id, age, diagnosis, residence) VALUES (1, 65, 'diabetes', 'rural'), (2, 45, 'asthma', 'urban'), (3, 70, 'diabetes', 'rural'); | What is the average age of patients in rural areas who were diagnosed with diabetes in the last year? | SELECT AVG(age) FROM patients WHERE diagnosis = 'diabetes' AND residence = 'rural' AND diagnosis_date >= DATEADD(year, -1, GETDATE()); | gretelai_synthetic_text_to_sql |
CREATE TABLE MiningSites (SiteID INT, SiteName VARCHAR(50), Location VARCHAR(50), WaterConsumption DECIMAL(10,2), OreTons DECIMAL(10,2), ExtractionDate DATE);CREATE VIEW SiteWaterConsumption AS SELECT SiteID, SiteName, ROW_NUMBER() OVER (PARTITION BY SiteID ORDER BY ExtractionDate DESC) AS ExtractionRank, WaterConsumpt... | Which mining site has the lowest water consumption per ton of ore extracted, and what is the water consumption ratio? | SELECT SiteName, WaterConsumptionRatio FROM SiteWaterConsumption WHERE ExtractionRank = 1 ORDER BY WaterConsumptionRatio ASC FETCH FIRST 1 ROW ONLY; | gretelai_synthetic_text_to_sql |
CREATE TABLE CrimeStats (district VARCHAR(20), crimeType VARCHAR(20), number INT); | What are the total numbers of crimes reported for 'Theft' and 'Burglary' categories, in the 'Central' and 'Downtown' districts, in 'CrimeStats' table? | SELECT SUM(number) FROM CrimeStats WHERE (crimeType IN ('Theft', 'Burglary') AND district IN ('Central', 'Downtown')); | gretelai_synthetic_text_to_sql |
CREATE TABLE tour_packages (package_id INT, package_name VARCHAR(50), price DECIMAL(4,2), PRIMARY KEY (package_id)); | Delete records in the "tour_packages" table with a "package_id" of 302 and a "price" greater than 1500 | DELETE FROM tour_packages WHERE package_id = 302 AND price > 1500; | gretelai_synthetic_text_to_sql |
CREATE TABLE Labor (id INT, country VARCHAR, hours INT); CREATE TABLE GarmentLaborData (country VARCHAR, garment_id INT); CREATE TABLE Garments (id INT, production_hours INT); | What is the total number of labor hours spent on producing garments from different countries? | SELECT l.country, SUM(g.production_hours) as total_hours FROM Labor l JOIN GarmentLaborData gld ON l.country = gld.country JOIN Garments g ON gld.garment_id = g.id GROUP BY l.country; | gretelai_synthetic_text_to_sql |
CREATE TABLE vulnerabilities (vulnerability_id INT PRIMARY KEY, vulnerability_name VARCHAR(255), cvss_score INT, last_detected TIMESTAMP); | Which vulnerabilities have been detected in the last 30 days and have a CVSS score higher than 7? | SELECT vulnerability_name, cvss_score FROM vulnerabilities WHERE last_detected >= NOW() - INTERVAL 30 DAY AND cvss_score > 7; | gretelai_synthetic_text_to_sql |
CREATE TABLE company (id INT, name VARCHAR(255), region VARCHAR(255), num_employees INT, avg_salary DECIMAL(10,2));CREATE VIEW mining_companies AS SELECT * FROM company WHERE industry = 'Mining'; | What is the average salary of employees in mining companies in the Asia-Pacific region? | SELECT AVG(c.avg_salary) as avg_salary FROM mining_companies c WHERE c.region = 'Asia-Pacific'; | gretelai_synthetic_text_to_sql |
CREATE TABLE hospitalizations (hospitalization_id INT, reported_date DATE, state VARCHAR(255), cause VARCHAR(255)); INSERT INTO hospitalizations VALUES (1, '2021-12-01', 'California', 'Flu'); INSERT INTO hospitalizations VALUES (2, '2021-12-03', 'California', 'Pneumonia'); | What is the total number of hospitalizations for flu and pneumonia in the last 12 months in California? | SELECT COUNT(*) FROM hospitalizations WHERE state = 'California' AND (cause = 'Flu' OR cause = 'Pneumonia') AND reported_date >= CURDATE() - INTERVAL 12 MONTH; | gretelai_synthetic_text_to_sql |
CREATE TABLE employees (id INT, name VARCHAR(50), join_date DATE); INSERT INTO employees (id, name, join_date) VALUES (1, 'Anna Smith', '2017-01-01'), (2, 'John Doe', '2018-01-01'), (3, 'Sara Connor', '2017-01-01'), (4, 'Mike Johnson', '2016-01-01'), (5, 'Emma White', '2019-01-01'), (6, 'Alex Brown', '2018-01-01'); | Show the total number of employees who joined the company before 2018-01-01 in the "employees" table. | SELECT COUNT(*) FROM employees WHERE join_date < '2018-01-01'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Donations (DonationID int, Amount decimal, OrganizationType text, Country text); INSERT INTO Donations (DonationID, Amount, OrganizationType, Country) VALUES (1, 5000, 'Health', 'Japan'); INSERT INTO Donations (DonationID, Amount, OrganizationType, Country) VALUES (2, 7000, 'Environment', 'China'); INSERT ... | What is the average donation amount to healthcare organizations in Asia? | SELECT AVG(Amount) FROM Donations WHERE OrganizationType = 'Health' AND Country LIKE 'Asia%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE fairness_issues (issue_id INT, model_name TEXT, country TEXT, reported_date DATE); INSERT INTO fairness_issues (issue_id, model_name, country, reported_date) VALUES (1, 'ModelA', 'Japan', '2021-01-01'), (2, 'ModelB', 'Japan', '2021-02-01'), (3, 'ModelC', 'Japan', '2021-03-01'), (4, 'ModelD', 'Japan', '2021... | What is the average number of fairness issues reported per month in Japan? | SELECT AVG(number_of_issues) FROM (SELECT COUNT(*)/COUNT(DISTINCT MONTH(reported_date)) AS number_of_issues FROM fairness_issues WHERE country = 'Japan' GROUP BY YEAR(reported_date), MONTH(reported_date)); | gretelai_synthetic_text_to_sql |
CREATE TABLE programs (id INT, name TEXT, launch_date DATE, region TEXT); INSERT INTO programs (id, name, launch_date, region) VALUES (1, 'Education Program', '2020-01-10', 'Asia'); INSERT INTO programs (id, name, launch_date, region) VALUES (2, 'Healthcare Program', '2019-05-15', 'Asia'); INSERT INTO programs (id, nam... | How many unique programs were launched in Asia in the last 3 years? | SELECT COUNT(DISTINCT id) FROM programs WHERE region = 'Asia' AND launch_date >= DATE_SUB(CURDATE(), INTERVAL 3 YEAR); | gretelai_synthetic_text_to_sql |
CREATE TABLE country (country_code VARCHAR(5), country_name VARCHAR(50)); INSERT INTO country (country_code, country_name) VALUES ('USA', 'United States'); CREATE TABLE city (city_id INT, city_name VARCHAR(50), country_code VARCHAR(5)); INSERT INTO city (city_id, city_name, country_code) VALUES (1, 'New York', 'USA'), ... | What is the total number of disability accommodations provided in each city in the United States? | SELECT C.city_name, COUNT(A.accommodation_id) as total_accommodations FROM accommodation A JOIN city C ON A.city_id = C.city_id WHERE C.country_code = 'USA' GROUP BY C.city_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE animal_population (animal_id INT, animal_name VARCHAR(50), population INT); INSERT INTO animal_population (animal_id, animal_name, population) VALUES (1, 'Tiger', 2000), (2, 'Elephant', 5000), (3, 'Lion', 3000); | Which animal species has the lowest population in the 'animal_population' table? | SELECT animal_name, MIN(population) FROM animal_population GROUP BY animal_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE beauty_products (product_name TEXT, price DECIMAL(5,2), has_ingredient BOOLEAN); INSERT INTO beauty_products (product_name, price, has_ingredient) VALUES ('Cleanser', 15.99, true), ('Moisturizer', 24.99, false), ('Serum', 39.99, true); | What is the average price of beauty products that contain a specific ingredient? | SELECT AVG(price) FROM beauty_products WHERE has_ingredient = true; | gretelai_synthetic_text_to_sql |
CREATE TABLE ticket_sales_team (id INT, team VARCHAR(50), revenue INT); INSERT INTO ticket_sales_team (id, team, revenue) VALUES (1, 'TeamA', 50000), (2, 'TeamB', 75000), (3, 'TeamC', 60000); | What is the total revenue from ticket sales for each team? | SELECT team, SUM(revenue) as total_revenue FROM ticket_sales_team GROUP BY team; | gretelai_synthetic_text_to_sql |
CREATE TABLE RecyclingRates (city VARCHAR(255), year INT, material VARCHAR(255), recycling_rate DECIMAL(5,2)); INSERT INTO RecyclingRates (city, year, material, recycling_rate) VALUES ('CityX', 2021, 'Plastic', 0.35), ('CityX', 2021, 'Paper', 0.65), ('CityX', 2021, 'Glass', 0.55); | What is the recycling rate for each material type in CityX in 2021? | SELECT material, AVG(recycling_rate) FROM RecyclingRates WHERE city = 'CityX' AND year = 2021 GROUP BY material; | gretelai_synthetic_text_to_sql |
CREATE TABLE athletes (id INT, name TEXT, sport TEXT); CREATE TABLE medals (id INT, athlete INT, event TEXT, medal TEXT); | List all the athletes who have won a gold medal in both the Olympics and Commonwealth Games. | SELECT a.name FROM athletes a INNER JOIN medals m1 ON a.id = m1.athlete INNER JOIN medals m2 ON a.id = m2.athlete WHERE m1.event = 'Olympics' AND m2.event = 'Commonwealth Games' AND m1.medal = 'gold' AND m2.medal = 'gold'; | gretelai_synthetic_text_to_sql |
CREATE TABLE art_performances (performance_id INT, name VARCHAR(50), location VARCHAR(50), date DATE, type VARCHAR(50)); | How many traditional art performances have there been in each country, and rank them by the number of performances? | SELECT location, COUNT(*) AS performance_count FROM art_performances GROUP BY location ORDER BY performance_count DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE facilities (name TEXT, location TEXT, distance INTEGER); INSERT INTO facilities (name, location, distance) VALUES ('Facility X', 'Rural South Africa', 100), ('Facility Y', 'Rural Kenya', 80); | What is the average distance from rural healthcare facilities to the nearest urban center in South Africa and Kenya? | SELECT AVG(distance) FROM facilities WHERE location LIKE 'Rural%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE emergencies (emergency_id INT, emergency_type VARCHAR(50), responded_date DATE, response_time INT, target_response_time INT); INSERT INTO emergencies (emergency_id, emergency_type, responded_date, response_time, target_response_time) VALUES (1, 'Fire', '2021-01-01', 15, 10), (2, 'Medical', '2021-02-01', 20... | What is the percentage of emergency responses that exceeded the target response time for each emergency type? | SELECT emergency_type, AVG(CASE WHEN response_time > target_response_time THEN 1 ELSE 0 END) * 100 AS excess_percentage FROM emergencies GROUP BY emergency_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE PeacekeepingOperations (ID INT, Country TEXT, Spending DECIMAL(10, 2), Year INT); INSERT INTO PeacekeepingOperations VALUES (1, 'China', 1500000, 2020); CREATE VIEW AsiaPacific AS SELECT Country FROM PeacekeepingOperations WHERE Country IN ('China', 'Japan', 'India', 'Australia', 'South Korea'); | What is the total spending on peacekeeping operations in the Asia-Pacific region in the last 3 years, along with the spending trend? | SELECT m.Country, m.Year, m.Spending, m.Spending - ISNULL(p.Spending, 0) as SpendingChange FROM PeacekeepingOperations m LEFT JOIN PeacekeepingOperations p ON m.Country = p.Country AND YEAR(m.Year) = YEAR(p.Year) + 1 JOIN AsiaPacific ap ON m.Country = ap.Country WHERE m.Year BETWEEN DATEADD(year, -3, GETDATE()) AND GET... | gretelai_synthetic_text_to_sql |
CREATE TABLE port(port_id INT, name VARCHAR(255), country VARCHAR(255));CREATE TABLE handling(handling_id INT, port_id INT, cargo_id INT);CREATE TABLE cargo(cargo_id INT, cargo_type VARCHAR(255)); | List all ports, their respective countries, and the number of unique cargo types handled | SELECT p.name AS port_name, p.country, COUNT(DISTINCT c.cargo_type) AS number_of_cargo_types FROM port p JOIN handling h ON p.port_id = h.port_id JOIN cargo c ON h.cargo_id = c.cargo_id GROUP BY p.port_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE Projects (ProjectID int, ProjectName varchar(50), ProjectType varchar(50), StartDate date, EndDate date); INSERT INTO Projects (ProjectID, ProjectName, ProjectType, StartDate, EndDate) VALUES (1, 'School Construction', 'Education', '2020-06-01', '2021-12-31'), (2, 'Library Renovation', 'Education', '2019-0... | How many education projects were completed in the last 24 months in the Middle East? | SELECT COUNT(ProjectID) as CompletedProjects FROM Projects WHERE ProjectType = 'Education' AND EndDate >= DATE_SUB(CURRENT_DATE, INTERVAL 24 MONTH) AND EndDate IS NOT NULL; | gretelai_synthetic_text_to_sql |
CREATE TABLE if not exists VehicleSafetyRating (Id int, Vehicle varchar(100), Country varchar(50), SafetyRating float); INSERT INTO VehicleSafetyRating (Id, Vehicle, Country, SafetyRating) VALUES (1, 'Tesla Model 3', 'USA', 5.3), (2, 'Tesla Model S', 'USA', 5.4), (3, 'Nissan Leaf', 'Japan', 4.8), (4, 'BMW i3', 'Germany... | Update the safety rating of the Tesla Model 3 to 5.5 in the USA. | UPDATE VehicleSafetyRating SET SafetyRating = 5.5 WHERE Vehicle = 'Tesla Model 3' AND Country = 'USA'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Accommodations (student_id INT, accommodation_type VARCHAR(255), cost FLOAT, year INT); | What is the total cost of accommodations for students with dyslexia in the current year? | SELECT SUM(cost) FROM Accommodations WHERE accommodation_type = 'Dyslexia' AND year = YEAR(NOW()); | gretelai_synthetic_text_to_sql |
CREATE TABLE Buildings (id INT, name TEXT, year_built INT, co2_emission FLOAT); INSERT INTO Buildings (id, name, year_built, co2_emission) VALUES (1, 'GreenHeights', 2020, 120.5), (2, 'EcoTowers', 2018, 150.0), (3, 'SolarHills', 2020, 90.3), (4, 'WindHaven', 2022, 80.0), (5, 'RainbowVista', 2019, 105.6), (6, 'BreezePal... | Update the name of the building with ID 4 to 'WindHaven2022' and CO2 emission to 75.0. | UPDATE Buildings SET name = 'WindHaven2022', co2_emission = 75.0 WHERE id = 4; | gretelai_synthetic_text_to_sql |
CREATE TABLE reverse_logistics (id INT, item_id INT, warehouse_location VARCHAR(50), quantity INT, return_date DATE); INSERT INTO reverse_logistics (id, item_id, warehouse_location, quantity, return_date) VALUES (1, 2001, 'Location X', 40, '2022-04-04'); INSERT INTO reverse_logistics (id, item_id, warehouse_location, q... | List the item IDs and quantities of items returned to warehouses in India in April 2022. | SELECT item_id, quantity FROM reverse_logistics WHERE warehouse_location = 'India' AND return_date >= '2022-04-01' AND return_date < '2022-05-01'; | gretelai_synthetic_text_to_sql |
CREATE TABLE research_papers (id INT, title VARCHAR(100), publication_year INT, abstract TEXT); INSERT INTO research_papers (id, title, publication_year, abstract) VALUES (1, 'Deep Learning for Autonomous Driving', 2021, 'In this paper, we propose a deep learning approach for autonomous driving...'), (2, 'Motion Planni... | What is the total number of autonomous driving research papers published in the research_papers table? | SELECT COUNT(*) FROM research_papers; | gretelai_synthetic_text_to_sql |
CREATE TABLE FlightLogs (flight_id INT, aircraft_model VARCHAR(50), country VARCHAR(50), flight_speed FLOAT, flight_date DATE); INSERT INTO FlightLogs (flight_id, aircraft_model, country, flight_speed, flight_date) VALUES (1, 'B747', 'USA', 850.0, '2022-01-01'), (2, 'A320', 'France', 800.0, '2021-05-01'), (3, 'B747', '... | Which countries have the highest and lowest average flight speed in the FlightLogs table? | SELECT country, AVG(flight_speed) AS avg_flight_speed FROM (SELECT country, flight_speed, ROW_NUMBER() OVER (PARTITION BY country ORDER BY flight_speed DESC) AS high_avg, ROW_NUMBER() OVER (PARTITION BY country ORDER BY flight_speed ASC) AS low_avg FROM FlightLogs) AS subquery WHERE high_avg = 1 OR low_avg = 1 GROUP BY... | gretelai_synthetic_text_to_sql |
CREATE TABLE events (event_id INT, event_name VARCHAR(50), event_type VARCHAR(50), visitor_count INT, gender VARCHAR(50)); | How many visitors identify as non-binary at music festivals? | SELECT SUM(CASE WHEN gender = 'Non-binary' THEN visitor_count ELSE 0 END) AS non_binary_visitors FROM events WHERE event_type = 'Music Festival'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Investors (InvestorID INT, InvestorName VARCHAR(50), Country VARCHAR(20)); CREATE TABLE Investments (InvestmentID INT, InvestorID INT, CompanyID INT, InvestmentAmount DECIMAL(10, 2)); | List all investments made by investors based in the US? | SELECT I.InvestorName, I.InvestmentAmount FROM Investments I JOIN Investors ON I.InvestorID = Investors.InvestorID WHERE Investors.Country = 'USA'; | gretelai_synthetic_text_to_sql |
CREATE TABLE orders (id INT PRIMARY KEY, product_id INT, quantity INT, order_date DATETIME, category VARCHAR(255), FOREIGN KEY (product_id) REFERENCES products(id)); INSERT INTO orders (id, product_id, quantity, order_date, category) VALUES (1, 1, 10, '2022-07-01 10:00:00', 'Category A'), (2, 2, 20, '2022-07-02 15:00:0... | What is the number of products sold in each category in the past week, ordered by the number of products sold in descending order? | SELECT o.category, COUNT(o.product_id) as num_products FROM orders o WHERE o.order_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 WEEK) GROUP BY o.category ORDER BY num_products DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE donors (id INT PRIMARY KEY, donor_name VARCHAR(50), donation_date DATE, donation_amount DECIMAL(10,2)); INSERT INTO donors (id, donor_name, donation_date, donation_amount) VALUES (1, 'John Doe', '2022-01-01', 100.00), (2, 'Jane Smith', '2022-02-01', 200.00), (3, 'Mike Johnson', '2021-12-31', 50.00); | What is the total amount of donations for each donor in the last year? | SELECT donor_name, SUM(donation_amount) as total_donations FROM donors WHERE donation_date >= DATE_SUB(NOW(), INTERVAL 1 YEAR) GROUP BY donor_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE funding (funding_id INT, company_id INT, amount DECIMAL(10,2)); CREATE TABLE companies (company_id INT, founding_year INT, underrepresented_minority BOOLEAN); INSERT INTO funding (funding_id, company_id, amount) VALUES (1, 1, 150000.00), (2, 2, 200000.00), (3, 3, 250000.00); INSERT INTO companies (company_... | What is the total funding amount for companies founded by underrepresented minorities each year? | SELECT founding_year, SUM(funding.amount) as total_funding_underrepresented_minorities FROM funding JOIN companies ON funding.company_id = companies.company_id WHERE companies.underrepresented_minority = true GROUP BY founding_year; | gretelai_synthetic_text_to_sql |
CREATE TABLE fabrics (id INT PRIMARY KEY, name VARCHAR(255), country VARCHAR(255), sustainability_score INT); INSERT INTO fabrics (id, name, country, sustainability_score) VALUES (1, 'Fabric A', 'Country C', 60); INSERT INTO fabrics (id, name, country, sustainability_score) VALUES (2, 'Fabric B', 'Country D', 65); CREA... | Which countries have the lowest average sustainability scores for fabrics and what are their corresponding manufacturing costs? | SELECT f.country, AVG(f.sustainability_score) AS avg_sustainability_score, m.manufacturing_cost FROM fabrics f CROSS JOIN (SELECT '2022-01-01' AS date, SUM(cost) AS manufacturing_cost FROM manufacturing WHERE fabric_id = f.id) m GROUP BY f.country HAVING AVG(f.sustainability_score) = (SELECT MIN(avg_sustainability_scor... | gretelai_synthetic_text_to_sql |
CREATE TABLE HealthEquityMetrics (MetricID INT PRIMARY KEY, MetricName TEXT, MetricGoal INT, MetricCurrent INT); | Delete health equity metrics table if it exists | DROP TABLE IF EXISTS HealthEquityMetrics; | gretelai_synthetic_text_to_sql |
CREATE TABLE facilities (id INT, name TEXT, type TEXT, location TEXT); INSERT INTO facilities (id, name, type, location) VALUES (1, 'recycling plant', 'recycling', 'Japan'), (2, 'waste treatment plant', 'waste', 'Japan'), (3, 'recycling plant', 'recycling', 'China'); | What is the total number of 'recycling' facilities in 'Japan'? | SELECT COUNT(*) FROM facilities WHERE type = 'recycling' AND location = 'Japan'; | gretelai_synthetic_text_to_sql |
CREATE TABLE community_education (id INT, center_name VARCHAR(50), location VARCHAR(50), num_participants INT); | Insert a new record into the 'community_education' table for the 'Polar Bear Conservation Initiative' | INSERT INTO community_education (id, center_name, location, num_participants) VALUES (1, 'Polar Bear Conservation Initiative', 'Canada', NULL); | gretelai_synthetic_text_to_sql |
CREATE TABLE vessel_performance (id INT PRIMARY KEY, vessel_id INT, max_speed FLOAT, avg_speed FLOAT, fuel_efficiency FLOAT); | Show the total fuel efficiency for vessels with IDs "VT-123" and "VT-456" from the "vessel_performance" table. | SELECT SUM(fuel_efficiency) FROM vessel_performance WHERE vessel_id IN (123, 456); | gretelai_synthetic_text_to_sql |
CREATE TABLE menu_items (menu_item_id INT, name VARCHAR(50), description TEXT, price DECIMAL(5,2), category VARCHAR(20), is_vegan BOOLEAN); | Update the price column to increase the price of all vegan entrees by $1.50 | UPDATE menu_items SET price = price + 1.50 WHERE category = 'entree' AND is_vegan = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE electric_vehicles ( id INT PRIMARY KEY, manufacturer VARCHAR(255), model VARCHAR(255), year INT, battery_range INT ); | Insert a new record in the 'electric_vehicles' table for a new electric car from 'EcoCar' | INSERT INTO electric_vehicles (id, manufacturer, model, year, battery_range) VALUES ((SELECT COALESCE(MAX(id), 0) + 1 FROM electric_vehicles), 'EcoCar', 'EcoCar X', 2022, 300); | gretelai_synthetic_text_to_sql |
CREATE TABLE autonomous_driving_research (id INT, vehicle_name VARCHAR(50), research_topic VARCHAR(50)); | Update the research_topic of 'TuSimple' to 'Computer Vision' in the 'autonomous_driving_research' table | UPDATE autonomous_driving_research SET research_topic = 'Computer Vision' WHERE vehicle_name = 'TuSimple'; | gretelai_synthetic_text_to_sql |
CREATE TABLE companies (id INT, name TEXT, industry TEXT, founding_date DATE, founder_status TEXT); INSERT INTO companies (id, name, industry, founding_date, founder_status) VALUES (1, 'MedicalInnovations', 'Biotech', '2017-01-01', 'Veteran'); | What is the minimum funding amount received by a company founded by a veteran in the biotech industry? | SELECT MIN(funding_amount) FROM funding_records JOIN companies ON funding_records.company_id = companies.id WHERE companies.industry = 'Biotech' AND companies.founder_status = 'Veteran'; | 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', 'John Doe', 500, 'Politics'); | What is the maximum word count for articles by 'John Doe'? | SELECT MAX(word_count) FROM news WHERE author = 'John Doe'; | gretelai_synthetic_text_to_sql |
CREATE TABLE player_daily_playtime (player_id INT, play_date DATE, playtime INT); INSERT INTO player_daily_playtime (player_id, play_date, playtime) VALUES (1, '2021-01-01', 100), (1, '2021-01-02', 200), (1, '2021-01-03', 300), (2, '2021-01-01', 400), (2, '2021-01-02', 500), (2, '2021-01-03', 600); | What is the maximum playtime for each player on a single day? | SELECT player_id, MAX(playtime) FROM player_daily_playtime GROUP BY player_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE top_beaches (country VARCHAR(30), beach VARCHAR(50), visitors INT, year INT); INSERT INTO top_beaches (country, beach, visitors, year) VALUES ('Bahamas', 'Pink Sands Beach', 500000, 2021), ('Jamaica', 'Seven Mile Beach', 700000, 2021), ('Barbados', 'Crane Beach', 400000, 2021); | How many tourists visited each Caribbean country's top beach in 2021? | SELECT country, SUM(visitors) as total_visitors FROM top_beaches WHERE year = 2021 GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE housing_affordability (property_id INT, size FLOAT, owner_id INT, location VARCHAR(255)); INSERT INTO housing_affordability (property_id, size, owner_id, location) VALUES (1, 800, 1, 'City A'), (2, 900, 1, 'City A'), (3, 1000, 2, 'City B'); | Which property in the housing_affordability table has the largest size? | SELECT property_id, size FROM housing_affordability ORDER BY size DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE defense_contracts (contract_id INT, contract_amount FLOAT, award_date DATE); | Delete records in the 'defense_contracts' table where the 'contract_amount' is zero | DELETE FROM defense_contracts WHERE contract_amount = 0; | gretelai_synthetic_text_to_sql |
CREATE TABLE circular_initiatives_eu (initiative TEXT, budget INTEGER, people_impacted INTEGER, start_date DATE); | What are the circular economy initiatives in the EU, including their budgets and the number of people they have impacted, as of 2021? | SELECT initiative, budget, people_impacted FROM circular_initiatives_eu WHERE country = 'EU' AND start_date <= '2021-12-31'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Company (id INT, name VARCHAR(50)); INSERT INTO Company (id, name) VALUES (1, 'Acme Inc'); INSERT INTO Company (id, name) VALUES (2, 'Beta Corp'); INSERT INTO Company (id, name) VALUES (3, 'Gamma Startup'); CREATE TABLE Innovation (company_id INT, innovation_type VARCHAR(50), launch_date DATE); INSERT INTO... | Which company launched the most recent innovation? | SELECT c.name, MAX(launch_date) as max_launch_date FROM Company c JOIN Innovation i ON c.id = i.company_id GROUP BY c.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_life_research_stations (id INT, station_name TEXT, country TEXT, depth FLOAT); | What is the average depth of marine life research stations in each country, sorted by the average depth? | SELECT country, AVG(depth) AS avg_depth FROM marine_life_research_stations GROUP BY country ORDER BY avg_depth DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE menu_items (item_id INT, item_name VARCHAR(50), uses_local BOOLEAN); INSERT INTO menu_items (item_id, item_name, uses_local) VALUES (1, 'Chicken Caesar Salad', false), (2, 'Margherita Pizza', true), (3, 'Beef Tacos', false); | What is the percentage of locally sourced ingredients used in menu items? | SELECT COUNT(*) * 100.0 / (SELECT COUNT(*) FROM menu_items) AS percentage FROM menu_items WHERE uses_local = true; | gretelai_synthetic_text_to_sql |
CREATE TABLE accessibility (accessibility_id INT, station_id INT, wheelchair_accessibility VARCHAR(10)); CREATE TABLE stations (station_id INT, station_name VARCHAR(50), station_type VARCHAR(20)); INSERT INTO stations (station_id, station_name, station_type) VALUES (1, 'StationA', 'Underground'), (2, 'StationB', 'Overg... | Delete all records from the 'accessibility' table where the 'station_id' is not present in the 'stations' table | DELETE FROM accessibility WHERE station_id NOT IN (SELECT station_id FROM stations); | gretelai_synthetic_text_to_sql |
CREATE TABLE case_outcomes (case_id INT, mediator_id INT, case_status VARCHAR(20)); | What is the success rate of each mediator in the 'case_outcomes' table? | SELECT mediator_id, (SUM(CASE WHEN case_status = 'Success' THEN 1 ELSE 0 END) / COUNT(*)) * 100.0 AS success_rate FROM case_outcomes GROUP BY mediator_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE restaurants (restaurant_id INT, cuisine VARCHAR(255), revenue INT); INSERT INTO restaurants (restaurant_id, cuisine, revenue) VALUES (1, 'Italian', 5000), (2, 'Mexican', 7000), (3, 'Italian', 8000); | What is the percentage of revenue that comes from each cuisine type? | SELECT cuisine, (SUM(revenue) OVER (PARTITION BY cuisine) * 100.0 / SUM(revenue) OVER ()) AS percentage_of_revenue FROM restaurants; | gretelai_synthetic_text_to_sql |
CREATE TABLE renewable_projects (id INT, project_name VARCHAR(100), country VARCHAR(50)); INSERT INTO renewable_projects (id, project_name, country) VALUES (1, 'Renewable Project 1', 'Germany'), (2, 'Renewable Project 2', 'Sweden'); | Which countries have no renewable energy projects in the renewable_projects table? | SELECT rp.country FROM renewable_projects rp GROUP BY rp.country HAVING COUNT(*) = 0; | gretelai_synthetic_text_to_sql |
CREATE TABLE government_departments (dept_name TEXT, city TEXT); INSERT INTO government_departments (dept_name, city) VALUES ('Human Services Department', 'CityA'), ('Education Department', 'CityB'), ('Health Department', 'CityA'), ('Library Department', 'CityC'), ('Transportation Department', 'CityD'); | How many unique cities are represented in the government departments dataset? | SELECT COUNT(DISTINCT city) FROM government_departments; | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_protected_areas (name TEXT, avg_depth REAL, ocean TEXT); INSERT INTO marine_protected_areas (name, avg_depth, ocean) VALUES ('Ross Sea Marine Protected Area', 1900, 'Southern'), ('Kerguelen Islands Marine Reserve', 1000, 'Southern'); | What is the number of marine protected areas in the Southern Ocean? | SELECT COUNT(*) FROM marine_protected_areas WHERE ocean = 'Southern'; | gretelai_synthetic_text_to_sql |
CREATE TABLE eco_hotels (hotel_id INT, name TEXT, city TEXT, rating FLOAT); INSERT INTO eco_hotels (hotel_id, name, city, rating) VALUES (1, 'Eco Hotel Amsterdam', 'Amsterdam', 4.7), (2, 'Green Haven Amsterdam', 'Amsterdam', 4.5), (3, 'Eco Lodge Amsterdam', 'Amsterdam', 4.8); | What is the highest rated eco-friendly hotel in Amsterdam? | SELECT name FROM eco_hotels WHERE city = 'Amsterdam' ORDER BY rating DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE Feed (FeedID INT, FeedType VARCHAR(50), FeedCost DECIMAL(5,2), FarmID INT); INSERT INTO Feed (FeedID, FeedType, FeedCost, FarmID) VALUES (1, 'Pellets', 1.25, 1); INSERT INTO Feed (FeedID, FeedType, FeedCost, FarmID) VALUES (2, 'Granules', 1.15, 2); CREATE TABLE FeedStock (FeedStockID INT, FeedType VARCHAR(... | What is the total quantity of each feed type? | SELECT Feed.FeedType, SUM(FeedStock.Quantity) FROM Feed INNER JOIN FeedStock ON Feed.FeedID = FeedStock.FeedID GROUP BY Feed.FeedType; | gretelai_synthetic_text_to_sql |
CREATE TABLE Menu (item_id INT, name VARCHAR(50), is_vegan BOOLEAN, is_gluten_free BOOLEAN, price DECIMAL(5,2)); INSERT INTO Menu (item_id, name, is_vegan, is_gluten_free, price) VALUES (1, 'Vegan Burger', true, false, 12.99), (2, 'Vegan Pizza', true, true, 14.99); | What is the minimum price of dishes that are both vegan and gluten-free? | SELECT MIN(price) FROM Menu WHERE is_vegan = true AND is_gluten_free = true; | gretelai_synthetic_text_to_sql |
CREATE TABLE crops (id INT, name VARCHAR(20), growing_season VARCHAR(10), farming_system VARCHAR(20)); | How many crops have been grown in the 'indigenous' farming systems in the 'rainy' season? | SELECT COUNT(*) FROM crops WHERE farming_system = 'indigenous' AND growing_season = 'rainy'; | gretelai_synthetic_text_to_sql |
CREATE TABLE sales (id INT, salesperson VARCHAR(255), sales_amount DECIMAL(10, 2)); INSERT INTO sales (id, salesperson, sales_amount) VALUES (1, 'Alex', 55000.00), (2, 'Taylor', 40000.00), (3, 'Alex', 75000.00), (4, 'Jamie', 30000.00); | Find the total sales for each salesperson who has made sales over $50,000. | SELECT salesperson, SUM(sales_amount) FROM sales WHERE sales_amount > 50000 GROUP BY salesperson; | gretelai_synthetic_text_to_sql |
CREATE TABLE if not exists VisitorContinents (Continent VARCHAR(50), Country VARCHAR(50), Visitors INT); INSERT INTO VisitorContinents (Continent, Country, Visitors) VALUES ('North America', 'Canada', 150000), ('Asia', 'Japan', 200000), ('Europe', 'France', 300000), ('Oceania', 'Australia', 250000), ('Africa', 'Egypt',... | What was the total number of visitors from each continent in 2021? | SELECT a.Continent, SUM(a.Visitors) AS TotalVisitors FROM VisitorContinents a WHERE a.Year = 2021 GROUP BY a.Continent; | gretelai_synthetic_text_to_sql |
CREATE TABLE Employees (EmployeeID int, Department varchar(50)); CREATE TABLE TrainingPrograms (TrainingProgramID int, TrainingProgram varchar(50), Department varchar(50), Mandatory boolean); CREATE TABLE EmployeeTrainings (EmployeeID int, TrainingProgramID int, Cost int, TrainingDate date); | What is the total training cost for each department, including only mandatory training programs? | SELECT e.Department, SUM(et.Cost) as TotalCost FROM Employees e JOIN TrainingPrograms tp ON e.Department = tp.Department JOIN EmployeeTrainings et ON tp.TrainingProgramID = et.TrainingProgramID WHERE tp.Mandatory = TRUE GROUP BY e.Department; | gretelai_synthetic_text_to_sql |
CREATE TABLE SatelliteLaunches (SatelliteName TEXT, LaunchCountry TEXT);CREATE TABLE ISSMissions (AstronautName TEXT, MissionCountry TEXT); | List all countries that have launched satellites, but have not launched any missions to the International Space Station. | (SELECT LaunchCountry FROM SatelliteLaunches EXCEPT SELECT MissionCountry FROM ISSMissions) EXCEPT (SELECT NULL); | gretelai_synthetic_text_to_sql |
CREATE TABLE movies (id INT, title VARCHAR(50), genre VARCHAR(20), revenue DECIMAL(10,2)); INSERT INTO movies (id, title, genre, revenue) VALUES (1, 'MovieC', 'Horror', 15000000), (2, 'MovieD', 'Romance', 12000000); | Find the total revenue of horror and romance movies. | SELECT SUM(revenue) FROM movies WHERE genre IN ('Horror', 'Romance'); | gretelai_synthetic_text_to_sql |
CREATE TABLE ProjectParticipation (ParticipationID INT, Contractor VARCHAR(255), ProjectID INT); INSERT INTO ProjectParticipation (ParticipationID, Contractor, ProjectID) VALUES (1, 'Contractor Z', 1), (2, 'Contractor W', 1); | List the defense projects that Contractor Z has in common with Contractor W. | SELECT pp1.ProjectID FROM ProjectParticipation pp1 INNER JOIN ProjectParticipation pp2 ON pp1.ProjectID = pp2.ProjectID WHERE pp1.Contractor = 'Contractor Z' AND pp2.Contractor = 'Contractor W'; | gretelai_synthetic_text_to_sql |
CREATE TABLE model (model_id INT, name VARCHAR(50), organization_id INT, explainability_score INT, country VARCHAR(50)); INSERT INTO model VALUES (1, 'ModelA', 1, 8, 'United States'), (2, 'ModelB', 2, 7, 'Canada'), (3, 'ModelC', 3, 6, 'United Kingdom'), (4, 'ModelD', 1, 9, 'United States'), (5, 'ModelE', 3, 5, 'Canada'... | What is the average explainability score of models developed by organizations based in the United States? | SELECT AVG(model.explainability_score) FROM model JOIN organization ON model.organization_id = organization.organization_id WHERE model.country = 'United States'; | gretelai_synthetic_text_to_sql |
CREATE TABLE states (state_id INT, state_name VARCHAR(255), region VARCHAR(255)); CREATE TABLE flu_cases (case_id INT, state_id INT, case_date DATE); INSERT INTO states (state_id, state_name, region) VALUES (1, 'California', 'West'), (2, 'Texas', 'South'), (3, 'New York', 'East'), (4, 'Alaska', 'North'); INSERT INTO fl... | What is the number of flu cases reported, by state, in the last week? | SELECT states.state_name, COUNT(flu_cases.case_id) as flu_cases_count FROM states JOIN flu_cases ON states.state_id = flu_cases.state_id WHERE flu_cases.case_date BETWEEN DATE_SUB(CURRENT_DATE, INTERVAL 1 WEEK) AND CURRENT_DATE GROUP BY states.state_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE vessel_types (type_id INT, type_name VARCHAR(50)); CREATE TABLE vessels (vessel_id INT, type_id INT, vessel_name VARCHAR(50)); CREATE TABLE safety_incidents (incident_id INT, vessel_id INT, incident_date DATE); | What is the total number of safety incidents for each vessel type, including types with no incidents? | SELECT vt.type_name, COALESCE(COUNT(si.incident_id), 0) as total_incidents FROM vessel_types vt LEFT JOIN vessels v ON vt.type_id = v.type_id LEFT JOIN safety_incidents si ON v.vessel_id = si.vessel_id GROUP BY vt.type_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE Safety_Tests (id INT, vehicle_id INT, test_date DATE, test_result VARCHAR(255)); INSERT INTO Safety_Tests (id, vehicle_id, test_date, test_result) VALUES (1, 1, '2022-01-01', 'Pass'); INSERT INTO Safety_Tests (id, vehicle_id, test_date, test_result) VALUES (2, 2, '2022-02-01', 'Fail'); CREATE TABLE Vehicle... | What is the total number of safety tests conducted for vehicles manufactured in Japan? | SELECT COUNT(st.id) FROM Safety_Tests st JOIN Vehicles_Manufactured vm ON st.vehicle_id = vm.vehicle_id WHERE vm.manufacturing_country = 'Japan'; | gretelai_synthetic_text_to_sql |
CREATE TABLE regions (id INT, name VARCHAR(255), games_hosted INT); INSERT INTO regions (id, name, games_hosted) VALUES (1, 'Northeast', 10); INSERT INTO regions (id, name, games_hosted) VALUES (2, 'Southeast', 8); | What is the total number of tickets sold for games in the Northeast region? | SELECT COUNT(*) FROM tickets t JOIN games g ON t.game_id = g.id JOIN regions r ON g.region_id = r.id WHERE r.name = 'Northeast'; | gretelai_synthetic_text_to_sql |
CREATE TABLE players(id INT, name VARCHAR(50), gender VARCHAR(50), age INT, last_login DATETIME); CREATE TABLE game_sessions(id INT, player_id INT, game_name VARCHAR(50), start_time DATETIME); | Show the number of players who played a specific game in the last year, grouped by gender and age. | SELECT game_name, gender, age, COUNT(DISTINCT players.id) as num_players FROM game_sessions JOIN players ON game_sessions.player_id = players.id WHERE start_time >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR) GROUP BY game_name, gender, age; | gretelai_synthetic_text_to_sql |
CREATE TABLE monthly_temperature (month TEXT, temperature FLOAT, other_data TEXT); | What are the names and average temperatures of the top 3 coldest months in the 'monthly_temperature' table? | SELECT mt1.month, AVG(mt1.temperature) as avg_temp FROM monthly_temperature mt1 JOIN (SELECT month, MIN(temperature) as min_temp FROM monthly_temperature GROUP BY month LIMIT 3) mt2 ON mt1.month = mt2.month GROUP BY mt1.month ORDER BY avg_temp ASC; | gretelai_synthetic_text_to_sql |
CREATE TABLE fares (id INT, route_id INT, fare DECIMAL(5,2), date DATE); INSERT INTO fares (id, route_id, fare, date) VALUES (1, 1, 2.5, '2022-03-01'), (2, 2, 1.8, '2022-03-01'), (3, 3, 5.0, '2022-03-01'), (4, 1, 2.5, '2022-03-02'), (5, 2, 1.8, '2022-03-02'), (6, 3, 5.0, '2022-03-02'); CREATE TABLE fare_types (id INT, ... | What is the total fare collected for each type of public transportation? | SELECT f.type, SUM(fares.fare) FROM fares JOIN fare_types f ON fares.route_id = f.id GROUP BY f.type; | gretelai_synthetic_text_to_sql |
CREATE TABLE funding (id INT, program VARCHAR(50), country VARCHAR(50), year INT, amount INT); INSERT INTO funding (id, program, country, year, amount) VALUES (1, 'Cultural Heritage Program 1', 'Nigeria', 2020, 25000), (2, 'Cultural Heritage Program 2', 'Nigeria', 2020, 30000); | What is the total amount of funding received by each cultural heritage program in Nigeria in 2020? | SELECT program, SUM(amount) AS total_amount FROM funding WHERE country = 'Nigeria' AND year = 2020 GROUP BY program; | gretelai_synthetic_text_to_sql |
CREATE TABLE Restaurants (id INT, name VARCHAR, category VARCHAR, revenue INT); INSERT INTO Restaurants (id, name, category, revenue) VALUES (1, 'Bistro', 'French', 500000); INSERT INTO Restaurants (id, name, category, revenue) VALUES (2, 'Pizzeria', 'Italian', 600000); INSERT INTO Restaurants (id, name, category, reve... | What is the total revenue for all restaurants that serve seafood? | SELECT SUM(revenue) FROM Restaurants WHERE category = 'Seafood'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Fields (FieldID varchar(5), FieldName varchar(10), PestIssue bool, PesticideTreatment timestamp); INSERT INTO Fields (FieldID, FieldName, PestIssue, PesticideTreatment) VALUES ('A', 'Field A', true, '2022-06-15 11:30:00'), ('B', 'Field B', false, null), ('C', 'Field C', true, '2022-06-27 14:15:00'); | Which fields have experienced pest issues but have not yet received any pesticide treatment? | SELECT FieldName FROM Fields WHERE PestIssue = true AND PesticideTreatment IS NULL; | gretelai_synthetic_text_to_sql |
CREATE TABLE users (id INT, country VARCHAR(2)); INSERT INTO users (id, country) VALUES (1, 'US'), (2, 'CA'); CREATE TABLE post_likes (user_id INT, post_id INT); INSERT INTO post_likes (user_id, post_id) VALUES (1, 1001), (3, 1001), (4, 1002); | How many users from country 'US' liked post ID 1001? | SELECT COUNT(*) FROM users JOIN post_likes ON users.id = post_likes.user_id WHERE users.country = 'US' AND post_likes.post_id = 1001; | gretelai_synthetic_text_to_sql |
CREATE TABLE treatment_facilities (name VARCHAR(50), state VARCHAR(20), capacity INT); INSERT INTO treatment_facilities (name, state, capacity) VALUES ('Facility1', 'Texas', 5000), ('Facility2', 'Texas', 7000); | List the wastewater treatment facilities in Texas and their capacities? | SELECT name, capacity FROM treatment_facilities WHERE state = 'Texas'; | gretelai_synthetic_text_to_sql |
CREATE TABLE trees (id INT, region VARCHAR(255), carbon_sequestered DECIMAL(10,2), year INT); | What is the total carbon sequestered by trees in each region in 2019? | SELECT region, SUM(carbon_sequestered) as total_carbon_sequestered FROM trees WHERE year = 2019 GROUP BY region; | gretelai_synthetic_text_to_sql |
CREATE TABLE games (id INT PRIMARY KEY, name VARCHAR(50), genre VARCHAR(50)); INSERT INTO games (id, name, genre) VALUES (1, 'Starcraft', 'Strategy'); INSERT INTO games (id, name, genre) VALUES (2, 'Civilization', 'Strategy'); | Delete all games from the genre 'Strategy' | DELETE FROM games WHERE genre = 'Strategy'; | gretelai_synthetic_text_to_sql |
CREATE TABLE gas_wells (well_id INT, location VARCHAR(20), daily_production FLOAT); INSERT INTO gas_wells (well_id, location, daily_production) VALUES (1, 'Urengoy gas field', 3500.1), (2, 'Urengoy gas field', 3300.2), (3, 'Urengoy gas field', 3200.3); | Count the number of gas wells in the Urengoy gas field and their total daily production | SELECT location, COUNT(*), SUM(daily_production) FROM gas_wells WHERE location = 'Urengoy gas field' GROUP BY location; | gretelai_synthetic_text_to_sql |
CREATE TABLE vendors(vendor_id INT, vendor_name TEXT, green_supply_chain BOOLEAN); INSERT INTO vendors(vendor_id, vendor_name, green_supply_chain) VALUES (1, 'VendorA', TRUE), (2, 'VendorB', FALSE), (3, 'VendorC', TRUE); CREATE TABLE products(product_id INT, product_name TEXT, rating INT); INSERT INTO products(product_... | What is the maximum rating of a product sold by vendors with a green supply chain? | SELECT MAX(products.rating) FROM products JOIN vendors ON products.vendor_id = vendors.vendor_id WHERE vendors.green_supply_chain = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE Auto_Shows (id INT PRIMARY KEY, show_name VARCHAR(50), location VARCHAR(50), start_date DATE, end_date DATE); CREATE TABLE Exhibitors (id INT PRIMARY KEY, auto_show_id INT, exhibitor_name VARCHAR(50), booth_number INT); CREATE TABLE Vehicles (id INT PRIMARY KEY, make VARCHAR(50), model VARCHAR(50), year IN... | Who are the exhibitors at auto shows in Tokyo that showcase electric vehicles? | SELECT a.show_name, e.exhibitor_name, v.make, v.model FROM Auto_Shows a INNER JOIN Exhibitors e ON a.id = e.auto_show_id INNER JOIN Vehicles v ON e.exhibitor_name = v.make WHERE a.location = 'Tokyo' AND v.type = 'Electric'; | gretelai_synthetic_text_to_sql |
CREATE TABLE intelligence_ops (id INT, operation_type VARCHAR(30), operation_date DATE); INSERT INTO intelligence_ops (id, operation_type, operation_date) VALUES (1, 'Counterintelligence', '2021-06-15'); INSERT INTO intelligence_ops (id, operation_type, operation_date) VALUES (2, 'Cybersecurity', '2022-02-03'); | Show the total number of intelligence operations per type in 2021. | SELECT operation_type, COUNT(*) FROM intelligence_ops WHERE YEAR(operation_date) = 2021 GROUP BY operation_type; | 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.