context stringlengths 11 9.12k | question stringlengths 0 1.06k | SQL stringlengths 2 4.44k | source stringclasses 28 values |
|---|---|---|---|
CREATE TABLE Production (chemical VARCHAR(255), production_date DATE, quantity INT); INSERT INTO Production (chemical, production_date, quantity) VALUES ('Ethanol', '2021-03-15', 500), ('Ethanol', '2022-01-02', 750), ('Methanol', '2020-12-31', 800); | List the production dates and quantities for batches of Ethanol produced after 2020-01-01? | SELECT chemical, production_date, quantity FROM Production WHERE chemical = 'Ethanol' AND production_date > '2020-01-01'; | gretelai_synthetic_text_to_sql |
CREATE TABLE conservation_initiatives (initiative_id INT, initiative_name VARCHAR(100), budget FLOAT); | Calculate the total budget for water conservation initiatives in the 'conservation_initiatives' table | SELECT SUM(budget) as total_budget FROM conservation_initiatives; | gretelai_synthetic_text_to_sql |
CREATE TABLE space_company (name TEXT, satellites_deployed INTEGER); INSERT INTO space_company (name, satellites_deployed) VALUES ('SpaceX', 2000); CREATE TABLE spacex_satellites (id INTEGER, name TEXT, launch_year INTEGER); INSERT INTO spacex_satellites (id, name, launch_year) VALUES (1, 'Starlink 1', 2019), (2, 'Starlink 2', 2019), (3, 'Starlink 3', 2020); | What are the names of all satellites deployed by SpaceX? | SELECT name FROM spacex_satellites; | gretelai_synthetic_text_to_sql |
CREATE TABLE environmental_assessments (id INT, assessment_date DATE, facility TEXT); INSERT INTO environmental_assessments (id, assessment_date, facility) VALUES (1, '2022-01-01', 'Facility1'), (2, '2022-03-15', 'Facility2'), (3, '2022-02-01', 'Facility3'); | List all environmental impact assessments and their corresponding facilities for the past year. | SELECT * FROM environmental_assessments WHERE assessment_date >= DATEADD(year, -1, CURRENT_DATE); | gretelai_synthetic_text_to_sql |
CREATE TABLE donors (id INT, donor_name TEXT, donation_date DATE); INSERT INTO donors (id, donor_name, donation_date) VALUES (1, 'Jim White', '2022-01-01'), (2, 'Jane Smith', '2022-04-15'), (3, 'Ahmed Doe', '2022-07-01'); | How many unique donors have there been each quarter in the last year? | SELECT EXTRACT(QUARTER FROM donation_date) as quarter, COUNT(DISTINCT donor_name) as unique_donors FROM donors WHERE donation_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR) GROUP BY quarter ORDER BY quarter; | gretelai_synthetic_text_to_sql |
CREATE TABLE products (product_id INT, product_name TEXT, rating FLOAT, manufacturer_country TEXT, product_category TEXT); INSERT INTO products (product_id, product_name, rating, manufacturer_country, product_category) VALUES (1, 'Product A', 4.5, 'USA', 'Category 1'), (2, 'Product B', 4.2, 'China', 'Category 2'), (3, 'Product C', 4.8, 'USA', 'Category 1'), (4, 'Product D', 4.6, 'India', 'Category 3'), (5, 'Product E', 4.7, 'Germany', 'Category 2'); | List the product names, manufacturers, and ratings for all products in 'Category 2'. | SELECT product_name, manufacturer_country, rating FROM products WHERE product_category = 'Category 2'; | gretelai_synthetic_text_to_sql |
CREATE TABLE City (id INT PRIMARY KEY, name VARCHAR(50), affordability_score INT); CREATE TABLE Neighborhood (id INT PRIMARY KEY, city_id INT, name VARCHAR(50)); CREATE TABLE Property (id INT PRIMARY KEY, neighborhood_id INT, type VARCHAR(50), price INT, square_footage INT, certification VARCHAR(50)); CREATE VIEW Green_Certified_Properties AS SELECT * FROM Property WHERE certification IN ('LEED', 'BREEAM'); | Which neighborhoods in cities with the lowest housing affordability scores have the highest number of green-certified properties, and their total square footage? | SELECT Neighborhood.name, SUM(Property.square_footage) as total_sq_ft FROM Neighborhood INNER JOIN Green_Certified_Properties ON Neighborhood.id = Green_Certified_Properties.neighborhood_id INNER JOIN City ON Neighborhood.city_id = City.id WHERE City.affordability_score = (SELECT MIN(affordability_score) FROM City) GROUP BY Neighborhood.name ORDER BY SUM(Property.square_footage) DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE country (id INT, name TEXT); CREATE TABLE resource (id INT, country_id INT, type TEXT, quantity INT); | What is the total amount of resources extracted from each country, categorized by type? | SELECT country.name, resource.type, SUM(resource.quantity) as total_quantity FROM country INNER JOIN resource ON country.id = resource.country_id GROUP BY country.name, resource.type; | gretelai_synthetic_text_to_sql |
CREATE TABLE donations (id INT, donor_id INT, donation_amount DECIMAL, donation_date DATE, donor_program VARCHAR); INSERT INTO donations (id, donor_id, donation_amount, donation_date, donor_program) VALUES (1, 101, '500', '2021-01-01', 'Arts & Culture'), (2, 102, '300', '2021-02-01', 'Sports'), (3, 103, '800', '2021-03-01', 'Arts & Culture'); CREATE TABLE volunteers (id INT, name VARCHAR, program VARCHAR); INSERT INTO volunteers (id, name, program) VALUES (101, 'Jamila Davis', 'Arts & Culture'), (102, 'Ricardo Silva', 'Sports'), (103, 'Xiao Liu', 'Arts & Culture'); | What is the average donation per volunteer for the 'Arts & Culture' program? | SELECT AVG(d.donation_amount) as avg_donation_amount FROM donations d JOIN volunteers v ON v.program = d.donor_program WHERE v.program = 'Arts & Culture'; | gretelai_synthetic_text_to_sql |
CREATE TABLE clean_water_access (country VARCHAR(20), percentage_access DECIMAL(5,2)); INSERT INTO clean_water_access (country, percentage_access) VALUES ('Brazil', 90.0), ('Colombia', 85.0); | What is the percentage of the population with access to clean water in Brazil and Colombia? | SELECT AVG(percentage_access) FROM clean_water_access WHERE country IN ('Brazil', 'Colombia'); | gretelai_synthetic_text_to_sql |
CREATE TABLE founders (id INT, company_id INT, disability_status VARCHAR(255)); CREATE TABLE companies (id INT, industry VARCHAR(255), funding_amount INT); INSERT INTO founders SELECT 1, 1, 'With Disability'; INSERT INTO founders SELECT 2, 2, 'Without Disability'; INSERT INTO founders SELECT 3, 3, 'With Disability'; INSERT INTO companies (id, industry, funding_amount) SELECT 2, 'Education', 3000000; INSERT INTO companies (id, industry, funding_amount) SELECT 3, 'AI', 5000000; INSERT INTO companies (id, industry, funding_amount) SELECT 4, 'Retail', 8000000; | Determine the total funding received by startups founded by individuals with disabilities in the AI industry | SELECT SUM(companies.funding_amount) FROM founders JOIN companies ON founders.company_id = companies.id WHERE companies.industry = 'AI' AND founders.disability_status = 'With Disability'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Research_Vessels ( id INT PRIMARY KEY, name VARCHAR(50), type VARCHAR(50), home_port VARCHAR(50), last_maintenance DATETIME); INSERT INTO Research_Vessels (id, name, type, home_port, last_maintenance) VALUES (1, 'Thomas G. Thompson', 'Research', 'Seattle', '2020-03-25'), (2, 'Atlantis', 'Oceanographic', 'Woods Hole', '2019-12-01'), (3, 'Southern Surveyor', 'Research', 'Sydney', '2021-06-10'), (4, 'Aurora', 'Oceanographic', 'Cape Town', '2021-02-22'); | Which marine research vessel was last maintained in the Southern Hemisphere? | SELECT name, type, home_port, last_maintenance FROM Research_Vessels WHERE last_maintenance = (SELECT MAX(last_maintenance) FROM Research_Vessels WHERE STRCMP(SUBSTRING_INDEX(home_port, ' ', 1), 'Southern', 1) = 1); | gretelai_synthetic_text_to_sql |
CREATE TABLE Programs (ProgramID INT, ProgramName TEXT, VolunteerCount INT, Category TEXT); INSERT INTO Programs (ProgramID, ProgramName, VolunteerCount, Category) VALUES (1, 'Clean Oceans', 50, 'Environment'); INSERT INTO Programs (ProgramID, ProgramName, VolunteerCount, Category) VALUES (2, 'Green Spaces', 25, 'Environment'); INSERT INTO Programs (ProgramID, ProgramName, VolunteerCount, Category) VALUES (3, 'Solar Energy', 30, 'Sustainability'); | What is the average number of volunteers for programs in the environment and sustainability category? | SELECT AVG(VolunteerCount) FROM Programs WHERE Category = 'Environment'; | gretelai_synthetic_text_to_sql |
CREATE TABLE donor_demographics (donor_id INT, donation_amount DECIMAL(10,2), donation_date DATE); INSERT INTO donor_demographics VALUES (1, 15000, '2020-01-01'), (2, 12000, '2020-02-01'), (3, 9000, '2020-03-01'), (4, 6000, '2020-04-01'), (5, 3000, '2020-05-01'); CREATE TABLE philanthropic_trends (donor_id INT, donation_amount DECIMAL(10,2), donation_date DATE); INSERT INTO philanthropic_trends VALUES (1, 20000, '2020-01-01'), (2, 18000, '2020-02-01'), (3, 16000, '2020-03-01'), (6, 14000, '2020-03-01'); | Which donors have made donations only in the donor demographics sector? | SELECT donor_demographics.donor_id FROM donor_demographics LEFT JOIN philanthropic_trends ON donor_demographics.donor_id = philanthropic_trends.donor_id WHERE philanthropic_trends.donor_id IS NULL; | gretelai_synthetic_text_to_sql |
CREATE TABLE movies (id INT, title VARCHAR(100), main_actor VARCHAR(100)); INSERT INTO movies (id, title, main_actor) VALUES (1, 'Movie13', 'Actor1'), (2, 'Movie14', 'Actor2'), (3, 'Movie15', 'Actor1'), (4, 'Movie16', 'Actor3'), (5, 'Movie17', 'Actor1'); | Who are the top 3 actors by the number of movies? | SELECT main_actor, COUNT(*) as movie_count FROM movies GROUP BY main_actor ORDER BY movie_count DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE revenue (restaurant_id INT, date DATE, revenue INT, category VARCHAR(50)); INSERT INTO revenue (restaurant_id, date, revenue, category) VALUES (3, '2022-04-01', 5000, 'Salads'), (3, '2022-04-02', 6000, 'Sandwiches'), (3, '2022-04-01', 4000, 'Soups'), (3, '2022-04-02', 7000, 'Salads'); | What is the revenue for each menu category in the 'Green Garden' restaurant for the month of April 2022? | SELECT category, SUM(revenue) as total_revenue FROM revenue WHERE restaurant_id = 3 AND MONTH(date) = 4 GROUP BY category; | gretelai_synthetic_text_to_sql |
CREATE TABLE TrainBreakdowns (BreakdownID INT, BreakdownDate DATE, District VARCHAR(20)); INSERT INTO TrainBreakdowns (BreakdownID, BreakdownDate, District) VALUES (1, '2022-01-02', 'North'), (2, '2022-01-05', 'South'), (3, '2022-01-07', 'East'), (4, '2022-01-10', 'South'), (5, '2022-01-12', 'West'); CREATE TABLE TrainEvents (EventID INT, EventDate DATE, EventType VARCHAR(20), TrainID INT); INSERT INTO TrainEvents (EventID, EventDate, EventType, TrainID) VALUES (1, '2022-01-01', 'Start of Service', 1001), (2, '2022-01-02', 'Breakdown', 1001), (3, '2022-01-05', 'Breakdown', 1002), (4, '2022-01-06', 'End of Service', 1002), (5, '2022-01-07', 'Start of Service', 1003), (6, '2022-01-07', 'Breakdown', 1003); | What is the average time between train breakdowns for trains in the 'South' district? | SELECT AVG(DATEDIFF(day, EventDate, LEAD(EventDate) OVER (PARTITION BY TrainID ORDER BY EventDate))) FROM TrainEvents WHERE EventType = 'Breakdown' AND District = 'South'; | gretelai_synthetic_text_to_sql |
CREATE TABLE project (id INT, state VARCHAR(20), type VARCHAR(20), hours INT); INSERT INTO project (id, state, type, hours) VALUES (1, 'Texas', 'Sustainable', 400), (2, 'Texas', 'Traditional', 300), (3, 'Seattle', 'Sustainable', 500); | What is the maximum labor hours for any sustainable building project in the state of Texas? | SELECT MAX(hours) FROM project WHERE state = 'Texas' AND type = 'Sustainable'; | gretelai_synthetic_text_to_sql |
CREATE TABLE waste (id INT, manufacturer_id INT, date DATE, weight FLOAT); INSERT INTO waste (id, manufacturer_id, date, weight) VALUES (1, 1, '2022-01-01', 500.00), (2, 1, '2022-04-01', 600.00), (3, 2, '2022-01-01', 700.00), (4, 2, '2022-04-01', 800.00); | What is the total waste produced by the manufacturing sector in the last quarter? | SELECT SUM(weight) FROM waste WHERE date >= '2022-01-01' AND date <= '2022-03-31'; | gretelai_synthetic_text_to_sql |
CREATE TABLE facilitators (facilitator_id INT PRIMARY KEY, name VARCHAR(255), age INT, gender VARCHAR(50), race VARCHAR(50), ethnicity VARCHAR(50), date_of_birth DATE, cases_facilitated INT, organization_id INT); | Update a facilitator record in the 'facilitators' table | UPDATE facilitators SET cases_facilitated = 50, organization_id = 8002 WHERE facilitator_id = 7003; | gretelai_synthetic_text_to_sql |
CREATE TABLE circular_supply_chain (product_id INT, supplier_id INT, recycling_program BOOLEAN); CREATE TABLE product_transparency (product_id INT, supplier_id INT, material VARCHAR(50), country_of_origin VARCHAR(50), production_process VARCHAR(50)); CREATE TABLE supplier_ethics (supplier_id INT, country VARCHAR(50), labor_practices VARCHAR(50), sustainability_score INT); CREATE VIEW recycling_rates_by_country AS SELECT country, AVG(recycling_program) as avg_recycling_rate FROM circular_supply_chain cs JOIN product_transparency pt ON cs.product_id = pt.product_id JOIN supplier_ethics se ON cs.supplier_id = se.supplier_id GROUP BY country; | Show the average recycling rate and number of products for each country | SELECT r.country, AVG(recycling_program) as avg_recycling_rate, COUNT(pt.product_id) as product_count FROM recycling_rates_by_country r JOIN product_transparency pt ON r.country = pt.country_of_origin GROUP BY r.country; | gretelai_synthetic_text_to_sql |
CREATE TABLE geological_surveys (survey_id INT, continent VARCHAR(20)); INSERT INTO geological_surveys (survey_id, continent) VALUES (101, 'Africa'), (102, 'Europe'), (103, 'Asia'), (104, 'South America'), (105, 'North America'); | Identify geological surveys with data from the African continent. | SELECT * FROM geological_surveys WHERE continent = 'Africa'; | gretelai_synthetic_text_to_sql |
CREATE TABLE City (id INT, name VARCHAR(255), population INT, region VARCHAR(255)); INSERT INTO City (id, name, population, region) VALUES (1, 'Chicago', 2700000, 'Midwest'); INSERT INTO City (id, name, population, region) VALUES (2, 'Detroit', 670000, 'Midwest'); | What is the average population of cities in the Midwest region? | SELECT region, AVG(population) FROM City WHERE region = 'Midwest' GROUP BY region; | gretelai_synthetic_text_to_sql |
CREATE TABLE FundingSources (SourceID INT, SourceName VARCHAR(50), TotalContribution DECIMAL(10,2)); CREATE TABLE PerformingArtsEvents (EventID INT, EventName VARCHAR(50), Date DATE); CREATE TABLE EventFunding (EventID INT, SourceID INT, FOREIGN KEY (EventID) REFERENCES PerformingArtsEvents(EventID), FOREIGN KEY (SourceID) REFERENCES FundingSources(SourceID)); | How many funding sources supported performing arts events in the last three years, and what are their respective contributions? | SELECT COUNT(DISTINCT EventFunding.SourceID), SUM(FundingSources.TotalContribution) FROM EventFunding INNER JOIN FundingSources ON EventFunding.SourceID = FundingSources.SourceID INNER JOIN PerformingArtsEvents ON EventFunding.EventID = PerformingArtsEvents.EventID WHERE PerformingArtsEvents.Date >= DATE_SUB(CURDATE(), INTERVAL 3 YEAR) AND PerformingArtsEvents.EventName LIKE '%performing arts%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE sales (sale_id INT, dish_id INT, sale_price DECIMAL(5,2), country VARCHAR(255)); INSERT INTO sales (sale_id, dish_id, sale_price, country) VALUES (1, 1, 9.99, 'USA'), (2, 3, 7.99, 'Mexico'), (3, 2, 12.99, 'USA'), (4, 3, 11.99, 'Mexico'), (5, 1, 10.99, 'USA'); CREATE TABLE dishes (dish_id INT, dish_name VARCHAR(255), cuisine VARCHAR(255)); INSERT INTO dishes (dish_id, dish_name, cuisine) VALUES (1, 'Quinoa Salad', 'Mediterranean'), (2, 'Chicken Caesar Wrap', 'Mediterranean'), (3, 'Tacos', 'Mexican'); CREATE TABLE feedback (feedback_id INT, dish_id INT, customer_id INT, rating INT, comment TEXT); INSERT INTO feedback (feedback_id, dish_id, customer_id, rating, comment) VALUES (1, 1, 1, 5, 'Delicious'), (2, 3, 2, 5, 'Great'), (3, 2, 3, 4, 'Okay'); | List dishes with a rating of 5 | SELECT d.dish_name FROM dishes d INNER JOIN feedback f ON d.dish_id = f.dish_id WHERE f.rating = 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE Hurricanes (HurricaneID INT, Name TEXT, MaxWindSpeed INT, Ocean TEXT); INSERT INTO Hurricanes (HurricaneID, Name, MaxWindSpeed, Ocean) VALUES (1, 'Hurricane1', 120, 'Atlantic'); INSERT INTO Hurricanes (HurricaneID, Name, MaxWindSpeed, Ocean) VALUES (2, 'Hurricane2', 150, 'Atlantic'); INSERT INTO Hurricanes (HurricaneID, Name, MaxWindSpeed, Ocean) VALUES (3, 'Hurricane3', 180, 'Pacific'); | What is the maximum wind speed ever recorded for a hurricane in the Atlantic Ocean? | SELECT MAX(MaxWindSpeed) FROM Hurricanes WHERE Ocean = 'Atlantic'; | gretelai_synthetic_text_to_sql |
CREATE TABLE suppliers (id INT, name VARCHAR(255), country VARCHAR(255)); CREATE TABLE products (id INT, name VARCHAR(255), supplier_id INT); | List all suppliers and the number of products they supply from France. | SELECT s.name, COUNT(p.id) FROM suppliers s INNER JOIN products p ON s.id = p.supplier_id WHERE s.country = 'France' GROUP BY s.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE aircraft_manufacturing (id INT PRIMARY KEY, manufacturer VARCHAR(50), model VARCHAR(50), city VARCHAR(50), country VARCHAR(50), manufacturing_year INT); | Update the 'aircraft_manufacturing' table to reflect 'Boeing' manufacturing the '737' model in 'Seattle', 'USA' in 2020 | UPDATE aircraft_manufacturing SET manufacturer = 'Boeing', city = 'Seattle', country = 'USA', manufacturing_year = 2020 WHERE model = '737'; | gretelai_synthetic_text_to_sql |
CREATE TABLE suppliers (id INT, name VARCHAR(255), country VARCHAR(255), is_organic BOOLEAN); INSERT INTO suppliers (id, name, country, is_organic) VALUES (1, 'EcoFarm', 'USA', true), (2, 'GreenFields', 'Canada', true), (3, 'FreshHarvest', 'USA', false); | How many suppliers are based in the US and provide organic produce? | SELECT COUNT(*) FROM suppliers WHERE country = 'USA' AND is_organic = true; | gretelai_synthetic_text_to_sql |
CREATE TABLE SpacecraftManufacturing (id INT, name VARCHAR(255), manufacturer VARCHAR(255), cost DECIMAL(10, 2)); INSERT INTO SpacecraftManufacturing (id, name, manufacturer, cost) VALUES (1, 'Voyager I', 'AeroSpace Inc.', 70000000.00), (2, 'Voyager II', 'AeroSpace Inc.', 75000000.00); | Which spacecraft had manufacturing costs above the average cost for 'AeroSpace Inc.'? | SELECT name FROM SpacecraftManufacturing WHERE manufacturer = 'AeroSpace Inc.' AND cost > (SELECT AVG(cost) FROM SpacecraftManufacturing WHERE manufacturer = 'AeroSpace Inc.'); | gretelai_synthetic_text_to_sql |
CREATE TABLE product_transparency (product_id INT, product_name VARCHAR(50), circular_supply_chain BOOLEAN, recycled_content DECIMAL(4,2), COUNTRY VARCHAR(50)); | Insert new records into 'product_transparency' table with details of products following circular supply chains. | INSERT INTO product_transparency (product_id, product_name, circular_supply_chain, recycled_content, country) VALUES (1001, 'Organic Cotton T-Shirt', TRUE, 0.85, 'India'); | gretelai_synthetic_text_to_sql |
CREATE TABLE transactions (asset TEXT, tx_date DATE); INSERT INTO transactions (asset, tx_date) VALUES ('Securitize', '2021-01-01'), ('Securitize', '2021-01-02'), ('Polymath', '2021-01-01'); | What is the average number of transactions per day for all digital assets? | SELECT AVG(transactions_per_day) FROM (SELECT asset, COUNT(*) / COUNT(DISTINCT tx_date) AS transactions_per_day FROM transactions GROUP BY asset) AS subquery; | gretelai_synthetic_text_to_sql |
CREATE TABLE PolicePresence (ID INT, City VARCHAR(50), Date TIMESTAMP, Presence INT); INSERT INTO PolicePresence (ID, City, Date, Presence) VALUES (13, 'CityC', '2015-01-01 00:00:00', 4), (14, 'CityC', '2015-01-01 01:00:00', 5), (15, 'CityC', '2015-01-01 02:00:00', 6), (16, 'CityD', '2015-01-01 00:00:00', 3), (17, 'CityD', '2015-01-01 01:00:00', 2), (18, 'CityD', '2015-01-01 02:00:00', 1); | What is the change in police presence for each city, comparing the current record to the previous one, ordered by date? | SELECT City, Date, Presence, Presence - LAG(Presence, 1) OVER (PARTITION BY City ORDER BY Date) AS PresenceChange FROM PolicePresence; | gretelai_synthetic_text_to_sql |
CREATE TABLE EmployeeData (EmployeeID INT, Department VARCHAR(50), Salary DECIMAL(10, 2)); INSERT INTO EmployeeData VALUES (1, 'IT', 50000); INSERT INTO EmployeeData VALUES (2, 'HR', 55000); INSERT INTO EmployeeData VALUES (3, 'Finance', 60000); INSERT INTO EmployeeData VALUES (4, 'IT', 65000); | Get the number of employees in each department who earn more than their department's average salary. | SELECT Department, COUNT(*) AS NumEmployees FROM EmployeeData WHERE Salary > (SELECT AVG(Salary) FROM EmployeeData WHERE Department = EmployeeData.Department) GROUP BY Department; | gretelai_synthetic_text_to_sql |
CREATE TABLE Visitors (VisitorID INT, Age INT, Gender VARCHAR(10), City VARCHAR(50)); INSERT INTO Visitors (VisitorID, Age, Gender, City) VALUES (1, 25, 'Male', 'New York'); INSERT INTO Visitors (VisitorID, Age, Gender, City) VALUES (2, 32, 'Female', 'London'); INSERT INTO Visitors (VisitorID, Age, Gender, City) VALUES (3, 45, 'Male', 'London'); CREATE TABLE Exhibitions (ExhibitionID INT, Title VARCHAR(50), City VARCHAR(50)); INSERT INTO Exhibitions (ExhibitionID, Title, City) VALUES (1, 'Art of the 20th Century', 'New York'); INSERT INTO Exhibitions (ExhibitionID, Title, City) VALUES (2, 'Impressionist Masters', 'London'); CREATE TABLE Attendance (VisitorID INT, ExhibitionID INT); INSERT INTO Attendance (VisitorID, ExhibitionID) VALUES (1, 1); INSERT INTO Attendance (VisitorID, ExhibitionID) VALUES (2, 2); INSERT INTO Attendance (VisitorID, ExhibitionID) VALUES (3, 2); | What is the number of visitors per exhibition in New York and London? | SELECT Exhibitions.Title, COUNT(Attendance.VisitorID) FROM Exhibitions INNER JOIN Attendance ON Exhibitions.ExhibitionID = Attendance.ExhibitionID WHERE Visitors.City IN ('New York', 'London') GROUP BY Exhibitions.Title; | gretelai_synthetic_text_to_sql |
CREATE TABLE economic_diversification (id INT, country VARCHAR(50), year INT, effort FLOAT); INSERT INTO economic_diversification (id, country, year, effort) VALUES (1, 'Brazil', 2018, 0.8), (2, 'Brazil', 2019, 0.9), (3, 'Brazil', 2020, 0.7); | What is the average economic diversification effort in Brazil between 2018 and 2020? | SELECT AVG(effort) FROM economic_diversification WHERE country = 'Brazil' AND year BETWEEN 2018 AND 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE songs (song_id INT, title VARCHAR(255), artist VARCHAR(100), release_year INT, length FLOAT); INSERT INTO songs (song_id, title, artist, release_year, length) VALUES (1, 'Song1', 'Artist X', 2020, 155.5), (2, 'Song2', 'Artist Y', 2019, 205.3), (3, 'Song3', 'Artist X', 2020, 145.7); | What is the average duration (in seconds) of songs produced by "Artist X"? | SELECT AVG(length) FROM songs WHERE artist = 'Artist X'; | gretelai_synthetic_text_to_sql |
CREATE TABLE products (id INT PRIMARY KEY, name VARCHAR(255), price DECIMAL(5,2), manufacturer_id INT, is_sustainable BOOLEAN, FOREIGN KEY (manufacturer_id) REFERENCES manufacturers(id)); CREATE TABLE sales (id INT PRIMARY KEY, product_id INT, quantity INT, sale_date DATE, FOREIGN KEY (product_id) REFERENCES products(id)); | Determine the monthly sales trend for sustainable products, along with the overall sales trend. | SELECT EXTRACT(MONTH FROM sale_date) as month, SUM(quantity) FILTER (WHERE is_sustainable) as sustainable_sales, SUM(quantity) as total_sales FROM sales JOIN products ON sales.product_id = products.id GROUP BY month ORDER BY month; | gretelai_synthetic_text_to_sql |
CREATE TABLE heritage_sites (site_id INT, site_name TEXT, country TEXT); INSERT INTO heritage_sites (site_id, site_name, country) VALUES (1, 'Borobudur Temple', 'Indonesia'), (2, 'Statue of Liberty', 'USA'), (3, 'Sydney Opera House', 'Australia'); | What is the total number of heritage sites in Indonesia? | SELECT COUNT(*) FROM heritage_sites WHERE country = 'Indonesia'; | gretelai_synthetic_text_to_sql |
CREATE TABLE peacekeeping_operations (operation_id INT, operation_name TEXT, start_date DATE, end_date DATE, troops_involved INT, partner_organization TEXT); INSERT INTO peacekeeping_operations (operation_id, operation_name, start_date, end_date, troops_involved, partner_organization) VALUES (1, 'Operation Restore Hope', '1992-12-03', '1993-05-04', 25000, 'United Nations'), (2, 'Operation Iraqi Freedom', '2003-03-20', '2011-12-15', 150000, 'Coalition Forces'); | What is the total number of peacekeeping operations in which the United Nations was involved as a partner organization? | SELECT COUNT(peacekeeping_operations.operation_id) FROM peacekeeping_operations WHERE peacekeeping_operations.partner_organization = 'United Nations'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Orders (order_id INT, order_date DATE, order_lead_time INT, order_country VARCHAR(50), order_shipped_from VARCHAR(50)); | What is the average lead time for orders placed in the US and shipped from China? | SELECT AVG(order_lead_time) AS avg_lead_time FROM Orders WHERE order_country = 'US' AND order_shipped_from = 'China'; | gretelai_synthetic_text_to_sql |
CREATE TABLE SustainablePractices (id INT, country TEXT, practice_date DATE); | How many sustainable tourism practices have been implemented in African countries this year? | SELECT COUNT(*) FROM SustainablePractices WHERE country IN ('Africa', 'Northern Africa', 'Southern Africa', 'Eastern Africa', 'Western Africa') AND practice_date >= DATE_SUB(CURDATE(), INTERVAL 1 YEAR); | gretelai_synthetic_text_to_sql |
CREATE TABLE ResearchLocation (ID INT, Lab VARCHAR(255), Location VARCHAR(255), Year INT, NumPapers INT); INSERT INTO ResearchLocation (ID, Lab, Location, Year, NumPapers) VALUES (1, 'SmartLabs', 'Detroit', 2021, 10), (2, 'RoboLabs', 'Tokyo', 2021, 15), (3, 'SmartLabs', 'Paris', 2021, 20); | How many autonomous driving research papers were published in 'Tokyo' in 2021? | SELECT SUM(NumPapers) FROM ResearchLocation WHERE Location = 'Tokyo' AND Year = 2021; | gretelai_synthetic_text_to_sql |
CREATE TABLE if not exists transportation (transport_id INT, transport VARCHAR(20), emission_date DATE, co2_emission INT); INSERT INTO transportation (transport_id, transport, emission_date, co2_emission) VALUES (1, 'Airplane', '2022-01-01', 445), (2, 'Train', '2022-02-01', 14), (3, 'Car', '2022-03-01', 185), (4, 'Bus', '2022-04-01', 80), (5, 'Bicycle', '2022-05-01', 0); | What is the average CO2 emission for transportation methods by month? | SELECT EXTRACT(MONTH FROM emission_date) as month, AVG(co2_emission) as avg_emission FROM transportation GROUP BY month; | gretelai_synthetic_text_to_sql |
CREATE TABLE Brands (BrandID INT, BrandName VARCHAR(50), Material VARCHAR(50), Quantity INT);INSERT INTO Brands (BrandID, BrandName, Material, Quantity) VALUES (1, 'BrandA', 'Organic Cotton', 3000), (2, 'BrandB', 'Recycled Polyester', 2500), (1, 'BrandA', 'Organic Silk', 1000), (3, 'BrandC', 'Organic Cotton', 2000), (2, 'BrandB', 'Tencel', 1800); | Identify the top 2 materials with the highest total quantity used by brand 'BrandB'? | SELECT Material, SUM(Quantity) as TotalQuantity FROM Brands WHERE BrandName = 'BrandB' GROUP BY Material ORDER BY TotalQuantity DESC LIMIT 2; | gretelai_synthetic_text_to_sql |
CREATE TABLE nile_river_basin (household_id INT, water_consumption FLOAT, timestamp TIMESTAMP); INSERT INTO nile_river_basin (household_id, water_consumption, timestamp) VALUES (1, 500, '2022-01-01 10:00:00'), (2, 550, '2022-02-01 10:00:00'); | What is the average water consumption per household in the Nile river basin in the last quarter? | SELECT AVG(water_consumption) FROM nile_river_basin WHERE timestamp BETWEEN DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 3 MONTH) AND CURRENT_TIMESTAMP; | gretelai_synthetic_text_to_sql |
CREATE TABLE Donors (DonorID INT, DonorName TEXT, Country TEXT); INSERT INTO Donors (DonorID, DonorName, Country) VALUES (1, 'John Doe', 'USA'), (2, 'Jane Smith', 'Canada'); CREATE TABLE Donations (DonationID INT, DonorID INT, Amount DECIMAL); INSERT INTO Donations (DonationID, DonorID, Amount) VALUES (1, 1, 500.00), (2, 1, 250.00), (3, 2, 100.00); | What is the total amount donated by individual donors from the United States? | SELECT SUM(Donations.Amount) FROM Donors INNER JOIN Donations ON Donors.DonorID = Donations.DonorID WHERE Donors.Country = 'USA' AND DonorID <> 0; | gretelai_synthetic_text_to_sql |
CREATE TABLE projects (id INT, budget FLOAT, focus VARCHAR(255)); INSERT INTO projects (id, budget, focus) VALUES (1, 100000.00, 'digital divide'), (2, 150000.00, 'climate change'), (3, 120000.00, 'digital divide'), (4, 75000.00, 'healthcare'), (5, 200000.00, 'digital divide'); | What is the minimum budget of projects focused on digital divide in Africa? | SELECT MIN(budget) FROM projects WHERE focus = 'digital divide'; | gretelai_synthetic_text_to_sql |
CREATE TABLE renewable_energy (country VARCHAR(20), source VARCHAR(20), capacity INT); INSERT INTO renewable_energy (country, source, capacity) VALUES ('Japan', 'Solar', 70000), ('Japan', 'Wind', 35000), ('Australia', 'Solar', 90000), ('Australia', 'Wind', 50000); | Which renewable energy source has the highest installed capacity in Japan and Australia? | SELECT r1.source, MAX(r1.capacity) as max_capacity FROM renewable_energy r1 WHERE r1.country IN ('Japan', 'Australia') GROUP BY r1.source; | gretelai_synthetic_text_to_sql |
CREATE TABLE Grievances (id INT, CompanyType TEXT, Sector TEXT, FilingDate DATE, GrievanceType TEXT); | What is the total number of grievances filed by non-union workers in the 'Energy' sector in the last 2 years? | SELECT COUNT(*) FROM Grievances WHERE CompanyType != 'Union' AND Sector = 'Energy' AND FilingDate >= DATE(NOW()) - INTERVAL 2 YEAR; | gretelai_synthetic_text_to_sql |
CREATE TABLE greenhouse_sensors ( id INT, sensor_type VARCHAR(20), temperature DECIMAL(5,2), humidity DECIMAL(5,2), light_level INT, timestamp TIMESTAMP); INSERT INTO greenhouse_sensors (id, sensor_type, temperature, humidity, light_level, timestamp) VALUES (1, 'temperature', 22.5, 60, 500, '2022-01-01 10:00:00'), (2, 'humidity', 65, 22.5, 300, '2022-01-01 10:00:00'), (3, 'temperature', 18, 62, 550, '2022-01-02 11:00:00'); | What is the lowest temperature recorded in the greenhouse_sensors table? | SELECT MIN(temperature) FROM greenhouse_sensors WHERE sensor_type = 'temperature'; | gretelai_synthetic_text_to_sql |
CREATE TABLE vulnerabilities (id INT, discovered_date DATE, severity VARCHAR(10)); INSERT INTO vulnerabilities (id, discovered_date, severity) VALUES (1, '2022-01-01', 'High'), (2, '2022-01-15', 'Medium'); | How many vulnerabilities were found in the last 30 days, and what is the severity level of each? | SELECT discovered_date, severity, COUNT(*) as num_vulnerabilities FROM vulnerabilities WHERE discovered_date >= DATE_SUB(CURRENT_DATE, INTERVAL 30 DAY) GROUP BY discovered_date, severity; | gretelai_synthetic_text_to_sql |
CREATE TABLE project_timelines (project_id INT, state VARCHAR(2), building_type VARCHAR(20), project_timeline INT); INSERT INTO project_timelines (project_id, state, building_type, project_timeline) VALUES (1, 'OR', 'Residential', 180), (2, 'OR', 'Residential', 200), (3, 'OR', 'Commercial', 240); | What is the average project timeline for sustainable residential building projects in Oregon? | SELECT AVG(project_timeline) FROM project_timelines WHERE state = 'OR' AND building_type = 'Residential'; | gretelai_synthetic_text_to_sql |
CREATE TABLE crime_incidents (incident_id INT, did INT, incident_type VARCHAR(255), incident_date DATE); INSERT INTO crime_incidents (incident_id, did, incident_type, incident_date) VALUES (1, 1, 'Theft', '2022-01-01'), (2, 2, 'Vandalism', '2022-01-02'), (3, 3, 'Assault', '2022-01-03'); | Update records of crime incidents with an 'incident_id' of 2 and change the 'incident_type' to 'Graffiti' | UPDATE crime_incidents SET incident_type = 'Graffiti' WHERE incident_id = 2; | gretelai_synthetic_text_to_sql |
CREATE TABLE animals (id INT PRIMARY KEY, name VARCHAR(100), species VARCHAR(50), population INT); INSERT INTO animals (id, name, species, population) VALUES (1, 'Giraffe', 'Mammal', 30000), (2, 'Elephant', 'Mammal', 5000); | Select all records where the species is 'Mammal' | SELECT * FROM animals WHERE species = 'Mammal'; | gretelai_synthetic_text_to_sql |
CREATE TABLE packages (id INT, weight FLOAT, shipped_date DATE); INSERT INTO packages (id, weight, shipped_date) VALUES (1, 15.3, '2022-01-01'), (2, 22.1, '2022-01-15'); | What is the maximum weight of packages shipped to Europe in the last month? | SELECT MAX(weight) FROM packages WHERE shipped_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) AND destination = 'Europe'; | gretelai_synthetic_text_to_sql |
CREATE TABLE patients (patient_id INT, name VARCHAR(50), age INT, gender VARCHAR(10), condition VARCHAR(50)); INSERT INTO patients (patient_id, name, age, gender, condition) VALUES (1, 'John Doe', 30, 'Male', 'Anxiety Disorder'); INSERT INTO patients (patient_id, name, age, gender, condition) VALUES (2, 'Jane Smith', 35, 'Female', 'Depression'); | Find the oldest male patient in the 'patients' table. | SELECT * FROM patients WHERE gender = 'Male' ORDER BY age DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE GreenBuildings (id INT PRIMARY KEY, name VARCHAR(255), address VARCHAR(255), certification_level VARCHAR(255), city VARCHAR(255), country VARCHAR(255), built_date DATE); INSERT INTO GreenBuildings (id, name, address, certification_level, city, country, built_date) VALUES (1, 'Green Tower', 'New York', 'LEED Platinum', 'USA', '2020-05-01'); | What is the average construction year for Green Buildings with LEED Platinum certification that were built after 2015? | SELECT certification_level, AVG(YEAR(built_date)) as avg_build_year FROM GreenBuildings WHERE certification_level = 'LEED Platinum' AND built_date >= '2016-01-01' GROUP BY certification_level; | gretelai_synthetic_text_to_sql |
CREATE TABLE login_attempts (id INT, ip_address VARCHAR(255), success BOOLEAN, date DATE); INSERT INTO login_attempts (id, ip_address, success, date) VALUES (1, '192.168.0.1', FALSE, '2022-01-01'), (2, '192.168.0.1', FALSE, '2022-01-02'), (3, '10.0.0.1', TRUE, '2022-01-03'), (4, '192.168.0.2', FALSE, '2022-01-04'), (5, '192.168.0.2', FALSE, '2022-01-05'); | How many unique IP addresses have attempted more than 5 failed login attempts in the last week? | SELECT COUNT(DISTINCT ip_address) FROM login_attempts WHERE success = FALSE AND date >= DATEADD(day, -7, GETDATE()) GROUP BY ip_address HAVING COUNT(*) > 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE circular_economy_initiatives (manufacturer_id INT, initiatives INT); INSERT INTO circular_economy_initiatives (manufacturer_id, initiatives) VALUES (1, 3), (2, 5), (3, 4), (4, 6), (5, 2); | How many circular economy initiatives have been implemented by each manufacturer in the ethical fashion industry? | SELECT manufacturer_id, initiatives FROM circular_economy_initiatives; | gretelai_synthetic_text_to_sql |
CREATE TABLE if not exists infrastructure_projects (id INT, name VARCHAR(100), quarter INT, year INT, total_expenditure FLOAT); INSERT INTO infrastructure_projects (id, name, quarter, year, total_expenditure) VALUES (1, 'Infrastructure Development', 1, 2021, 2000000); | What was the total expenditure on infrastructure projects in 'Q1 2021'? | SELECT SUM(total_expenditure) FROM infrastructure_projects WHERE quarter = 1 AND year = 2021; | gretelai_synthetic_text_to_sql |
CREATE TABLE policyholders (id INT, policyholder_name VARCHAR(50), state VARCHAR(20)); INSERT INTO policyholders (id, policyholder_name, state) VALUES (1, 'John Doe', 'Texas'), (2, 'Jane Smith', 'California'), (3, 'Alice Johnson', 'Texas'), (4, 'Bob Brown', 'New York'); | How many policyholders live in each state? | SELECT state, COUNT(*) as policyholder_count FROM policyholders GROUP BY state; | gretelai_synthetic_text_to_sql |
CREATE TABLE Bioprocess (ID INT, Name TEXT, Biosensors TEXT); INSERT INTO Bioprocess (ID, Name, Biosensors) VALUES (2, 'Process_2', 'BS2,BS3'); | Delete the biosensor 'BS3' from the bioprocess 'Process_2'? | DELETE FROM Bioprocess WHERE Name = 'Process_2' AND Biosensors = 'BS3'; | gretelai_synthetic_text_to_sql |
CREATE TABLE fabric_inventory (id INT, fabric_name VARCHAR(50), quantity_sourced INT, country_of_origin VARCHAR(50), source_date DATE); INSERT INTO fabric_inventory (id, fabric_name, quantity_sourced, country_of_origin, source_date) VALUES (1, 'Organic Cotton', 5000, 'India', '2021-01-05'), (2, 'Recycled Polyester', 3000, 'China', '2021-04-10'), (3, 'Bamboo Viscose', 2500, 'Indonesia', '2021-02-22'); | What is the total quantity of organic cotton fabric sourced from India in Q1 2021? | SELECT SUM(quantity_sourced) FROM fabric_inventory WHERE fabric_name = 'Organic Cotton' AND country_of_origin = 'India' AND QUARTER(source_date) = 1 AND YEAR(source_date) = 2021; | gretelai_synthetic_text_to_sql |
CREATE TABLE players (id INT, platform VARCHAR(20));CREATE TABLE games (id INT, player_id INT, game_type VARCHAR(10));CREATE TABLE vr_games (id INT, player_id INT, last_played DATE); | What is the number of unique players who have played on each gaming platform, and the percentage of players who have played VR games? | SELECT p.platform, COUNT(DISTINCT p.id) AS players, 100.0 * COUNT(DISTINCT v.player_id) / COUNT(DISTINCT g.player_id) AS vr_players_percentage FROM players p LEFT JOIN games g ON p.id = g.player_id LEFT JOIN vr_games v ON p.id = v.player_id GROUP BY p.platform; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA if not exists biotech; CREATE TABLE if not exists biotech.startups (id INT PRIMARY KEY, name VARCHAR(255), location VARCHAR(255), funding FLOAT); INSERT INTO biotech.startups (id, name, location, funding) VALUES (1, 'StartupA', 'India', 4000000), (2, 'StartupB', 'India', 5000000), (3, 'StartupC', 'Canada', 3000000), (4, 'StartupD', 'India', 6000000); | What is the total funding received by biotech startups based in India? | SELECT SUM(funding) FROM biotech.startups WHERE location = 'India'; | gretelai_synthetic_text_to_sql |
CREATE TABLE concert_ticket_prices (tier_num INT, concert_name VARCHAR(255), tier_price INT); | What is the maximum ticket price for each tier in the 'concert_ticket_prices' table? | SELECT tier_num, MAX(tier_price) as max_price FROM concert_ticket_prices GROUP BY tier_num; | gretelai_synthetic_text_to_sql |
CREATE TABLE Scores (ScoreID INT, ActID INT, ImpactScore INT); INSERT INTO Scores (ScoreID, ActID, ImpactScore) VALUES (1, 1, 8), (2, 1, 9), (3, 2, 7), (4, 2, 8), (5, 3, 9), (6, 3, 10); | What is the average social impact score for each type of activity? | SELECT Activity, AVG(ImpactScore) as AvgScore FROM (SELECT ActID, AVG(ImpactScore) as ImpactScore, Activity FROM Scores JOIN Activities ON Scores.ActID = Activities.ActID GROUP BY ActID, Activity) as A GROUP BY Activity; | gretelai_synthetic_text_to_sql |
CREATE TABLE plants (id INT, state VARCHAR(20), capacity INT); INSERT INTO plants (id, state, capacity) VALUES (1, 'California', 500), (2, 'Texas', 400), (3, 'California', 600), (4, 'New_York', 300); | List the top 3 states with the highest wastewater treatment capacity? | SELECT state, SUM(capacity) as total_capacity FROM plants GROUP BY state ORDER BY total_capacity DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE farmers (id INT PRIMARY KEY, name VARCHAR(50), location VARCHAR(50), crops VARCHAR(50)); INSERT INTO farmers (id, name, location, crops) VALUES (1, 'Jane Doe', 'Kenya', 'Cassava, Maize'), (2, 'Alex Smith', 'Nigeria', 'Cassava'), (3, 'Olivia Brown', 'South Africa', 'Wheat'); CREATE TABLE sales (id INT PRIMARY KEY, farmer_id INT, crop VARCHAR(50), quantity INT, price FLOAT); INSERT INTO sales (id, farmer_id, crop, quantity, price) VALUES (1, 2, 'Cassava', 1000, 2.5), (2, 2, 'Cassava', 500, 2.8); | Who are the farmers in 'Africa' growing 'Cassava' and what is the total quantity sold? | SELECT f.name, SUM(s.quantity) as total_quantity FROM farmers f JOIN sales s ON f.id = s.farmer_id WHERE f.location = 'Africa' AND s.crop = 'Cassava' GROUP BY f.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE coal_production (site_id INT, site_name TEXT, region TEXT, month INT, year INT, coal_quantity INT); INSERT INTO coal_production (site_id, site_name, region, month, year, coal_quantity) VALUES (4, 'JKL Mine', 'South', 1, 2022, 5000), (5, 'MNO Mine', 'South', 2, 2022, 6000), (6, 'PQR Mine', 'South', 3, 2022, 7000); | What is the total quantity of coal extracted at the 'South' region mines in Q1 2022? | SELECT region, SUM(coal_quantity) as total_q1_2022 FROM coal_production WHERE region = 'South' AND month BETWEEN 1 AND 3 AND year = 2022 GROUP BY region; | gretelai_synthetic_text_to_sql |
CREATE TABLE providers (id INT, name TEXT, service TEXT, location TEXT); INSERT INTO providers (id, name, service, location) VALUES (1, 'Healthcare One', 'Primary Care', 'Wisconsin'); INSERT INTO providers (id, name, service, location) VALUES (2, 'Care Central', 'Mental Health', 'Wisconsin'); INSERT INTO providers (id, name, service, location) VALUES (3, 'Provider Plus', 'Primary Care', 'Wisconsin'); | Delete records of providers in Wisconsin that do not offer mental health services. | DELETE FROM providers WHERE location = 'Wisconsin' AND service != 'Mental Health' | gretelai_synthetic_text_to_sql |
CREATE TABLE ufp_offered (bank_name TEXT, product TEXT); INSERT INTO ufp_offered (bank_name, product) VALUES ('Al Ain Bank', 'Murabaha'), ('Dubai Islamic Bank', 'Ijara'), ('Emirates Islamic Bank', 'Takaful'), ('Noor Bank', 'Musharaka'); | What are the unique financial products offered by Shariah-compliant banks in the United Arab Emirates? | SELECT DISTINCT product FROM ufp_offered WHERE bank_name IN ('Al Ain Bank', 'Dubai Islamic Bank', 'Emirates Islamic Bank', 'Noor Bank') AND country = 'United Arab Emirates'; | gretelai_synthetic_text_to_sql |
CREATE TABLE climate_communication (initiative_id INT, initiative_name VARCHAR(100), year INT, region VARCHAR(50)); | How many climate communication initiatives were conducted in South Asia in 2020? | SELECT COUNT(initiative_id) FROM climate_communication WHERE year = 2020 AND region = 'South Asia'; | gretelai_synthetic_text_to_sql |
CREATE TABLE GameSessions (GameID INT, SessionDuration TIME); CREATE TABLE GameDetails (GameID INT, GameName VARCHAR(100)); | List all games and their total duration in the 'GameSessions' and 'GameDetails' tables | SELECT gd.GameName, SUM(gs.SessionDuration) as TotalGameDuration FROM GameSessions gs INNER JOIN GameDetails gd ON gs.GameID = gd.GameID GROUP BY gd.GameName; | gretelai_synthetic_text_to_sql |
CREATE TABLE organizations (id INT, name TEXT, num_volunteers INT); CREATE TABLE regions (id INT, region TEXT); INSERT INTO organizations (id, name, num_volunteers) VALUES (1, 'Habitat for Humanity', 500), (2, 'Red Cross', 300), (3, 'UNICEF', 200); INSERT INTO regions (id, region) VALUES (1, 'Midwest'), (2, 'Southeast'), (3, 'Northeast'); | What is the average number of volunteers for organizations in the Midwest? | SELECT AVG(o.num_volunteers) AS avg_volunteers FROM organizations o JOIN regions r ON o.id = r.id WHERE r.region = 'Midwest'; | gretelai_synthetic_text_to_sql |
CREATE TABLE policies (id INT, name VARCHAR(255), details TEXT, last_modified DATE); INSERT INTO policies (id, name, details, last_modified) VALUES (1, 'Acceptable Use Policy', '...', '2022-01-01'); | What are the names and details of all policies that have been altered in the last week? | SELECT name, details FROM policies WHERE last_modified >= DATE(NOW()) - INTERVAL 7 DAY; | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_mammals (name VARCHAR(255), location VARCHAR(255), population INT); INSERT INTO marine_mammals (name, location, population) VALUES ('Blue Whale', 'Pacific Ocean', 2000), ('Dolphin', 'Atlantic Ocean', 1500), ('Seal', 'Arctic Ocean', 1000); | What is the average population of marine mammals in the Atlantic and Arctic Oceans? | SELECT AVG(population) FROM marine_mammals WHERE location IN ('Atlantic Ocean', 'Arctic Ocean'); | gretelai_synthetic_text_to_sql |
CREATE TABLE InternationalConferences (ConferenceID INT, ConferenceName VARCHAR(50), Location VARCHAR(50)); | Determine the number of unique countries represented in the InternationalConferences table. | SELECT COUNT(DISTINCT Location) FROM InternationalConferences; | gretelai_synthetic_text_to_sql |
CREATE TABLE unions (id INT, name VARCHAR(255), industry VARCHAR(255), member_gender VARCHAR(10), member_count INT); INSERT INTO unions (id, name, industry, member_gender, member_count) VALUES (1, 'Union A', 'technology', 'male', 200), (2, 'Union B', 'technology', 'female', 150), (3, 'Union C', 'technology', 'male', 250), (4, 'Union D', 'technology', 'female', 100); | What is the total number of male and female members in unions with a 'technology' industry classification? | SELECT SUM(CASE WHEN member_gender = 'male' THEN member_count ELSE 0 END) as total_male, SUM(CASE WHEN member_gender = 'female' THEN member_count ELSE 0 END) as total_female FROM unions WHERE industry = 'technology'; | gretelai_synthetic_text_to_sql |
CREATE TABLE InfrastructureProjects (id INT, name VARCHAR(100), region VARCHAR(50), project_type VARCHAR(50), cost FLOAT, completion_date DATE); INSERT INTO InfrastructureProjects (id, name, region, project_type, cost, completion_date) VALUES (1, 'New York Bridge', 'Atlantic', 'bridge', 30000000, '2017-01-01'); | What is the average cost of bridge projects in the Atlantic region that were completed after 2015? | SELECT AVG(cost) FROM InfrastructureProjects WHERE region = 'Atlantic' AND project_type = 'bridge' AND completion_date > '2015-01-01'; | gretelai_synthetic_text_to_sql |
CREATE TABLE na_compounds (compound_id INT, compound_name TEXT, country TEXT, production_quantity INT); INSERT INTO na_compounds (compound_id, compound_name, country, production_quantity) VALUES (1, 'Compound H', 'USA', 8000), (2, 'Compound I', 'Canada', 9000), (3, 'Compound J', 'USA', 7000), (4, 'Compound K', 'Mexico', 6000); | What are the maximum and minimum production quantities (in kg) for chemical compounds in the North America region, grouped by country? | SELECT country, MAX(production_quantity) as max_production, MIN(production_quantity) as min_production FROM na_compounds GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE IoTDevices (region VARCHAR(255), device_id INT, firmware_version VARCHAR(255)); INSERT INTO IoTDevices (region, device_id, firmware_version) VALUES ('South America', 1001, '3.4.5'), ('North America', 1002, '3.5.1'), ('South America', 1003, '3.4.8'), ('Asia', 1004, '3.6.0'); | Identify the number of IoT devices in the 'South America' region with a firmware version lower than 3.5.0. | SELECT COUNT(*) FROM IoTDevices WHERE region = 'South America' AND firmware_version < '3.5.0'; | gretelai_synthetic_text_to_sql |
CREATE TABLE large_loans (bank_id INT, amount DECIMAL(10,2)); INSERT INTO large_loans (bank_id, amount) VALUES (1, 12000.00), (1, 15000.00), (2, 10000.00), (2, 11000.00); | Identify the bank with the highest percentage of loans above $10,000? | SELECT bank_id, 100.0 * SUM(amount) / (SELECT SUM(amount) FROM large_loans) as large_loan_percentage FROM large_loans GROUP BY bank_id ORDER BY large_loan_percentage DESC FETCH FIRST 1 ROW ONLY; | gretelai_synthetic_text_to_sql |
CREATE TABLE menu_items (id INT, name TEXT, sales INT); CREATE TABLE ingredient_costs (menu_item_id INT, ingredient TEXT, cost INT); | What is the total amount spent on ingredients for each menu item, excluding items with no sales? | SELECT menu_items.name, SUM(ingredient_costs.cost) FROM ingredient_costs JOIN menu_items ON ingredient_costs.menu_item_id = menu_items.id WHERE menu_items.sales > 0 GROUP BY menu_items.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE network_devices (id INT, name VARCHAR(50), install_date DATE); INSERT INTO network_devices (id, name, install_date) VALUES (1, 'RouterA', '2022-01-01'), (2, 'SwitchB', '2021-01-01'); | Which network devices were installed in Q1 2022? | SELECT name FROM network_devices WHERE install_date BETWEEN '2022-01-01' AND '2022-03-31'; | gretelai_synthetic_text_to_sql |
CREATE TABLE facility (id INT, name VARCHAR(50), type VARCHAR(50), capacity INT); INSERT INTO facility (id, name, type, capacity) VALUES (1, 'Sunshine General', 'Hospital', 500); | Update the capacity of an existing healthcare facility in the facility table. | UPDATE facility SET capacity = 600 WHERE name = 'Sunshine General'; | gretelai_synthetic_text_to_sql |
CREATE TABLE PollutionControl (id INT, initiative VARCHAR(50), region VARCHAR(20)); INSERT INTO PollutionControl (id, initiative, region) VALUES (1, 'Ocean Cleanup', 'Arctic'), (2, 'Plastic Reduction', 'Atlantic'), (3, 'Carbon Capture', 'Global'); | Which pollution control initiatives have been implemented in the Arctic region? | SELECT initiative FROM PollutionControl WHERE region = 'Arctic'; | gretelai_synthetic_text_to_sql |
CREATE TABLE satellites (id INT, name VARCHAR(255), country VARCHAR(255), launch_date DATE); INSERT INTO satellites (id, name, country, launch_date) VALUES (1, 'Sputnik', 'Russia', '1957-10-04'); INSERT INTO satellites (id, name, country, launch_date) VALUES (2, 'Explorer 1', 'USA', '1958-01-31'); | Delete all satellites launched before 2010 from the satellites table | DELETE FROM satellites WHERE launch_date < '2010-01-01'; | gretelai_synthetic_text_to_sql |
CREATE TABLE RecyclingRates (material VARCHAR(50), date DATE, recycling_rate DECIMAL(5,2)); INSERT INTO RecyclingRates VALUES ('Plastic', '2021-01-01', 0.65), ('Plastic', '2021-01-02', 0.67), ('Paper', '2021-01-01', 0.70), ('Paper', '2021-01-02', 0.72), ('Glass', '2021-01-01', 0.55), ('Glass', '2021-01-02', 0.56), ('Metal', '2021-01-01', 0.80), ('Metal', '2021-01-02', 0.81); | What is the minimum recycling rate for each material in the past year? | SELECT material, MIN(recycling_rate) FROM RecyclingRates WHERE date >= DATEADD(year, -1, GETDATE()) GROUP BY material; | gretelai_synthetic_text_to_sql |
CREATE TABLE restaurants (id INT, name VARCHAR(255), type VARCHAR(255), city VARCHAR(255), revenue FLOAT); INSERT INTO restaurants (id, name, type, city, revenue) VALUES (1, 'Restaurant A', 'Italian', 'New York', 5000.00), (2, 'Restaurant B', 'Asian', 'New York', 8000.00), (3, 'Restaurant C', 'Mexican', 'Los Angeles', 3000.00); | List the restaurants that have a revenue greater than the average revenue for restaurants in the same city. | SELECT name FROM restaurants r1 WHERE revenue > (SELECT AVG(revenue) FROM restaurants r2 WHERE r1.city = r2.city); | gretelai_synthetic_text_to_sql |
CREATE TABLE customers (customer_id INT, customer_name VARCHAR(255), plan_id INT, last_used_date DATE); INSERT INTO customers (customer_id, customer_name, plan_id, last_used_date) VALUES (1, 'John Doe', 2, '2022-04-15'), (2, 'Jane Smith', 1, '2022-05-01'), (3, 'Bob Johnson', 2, '2022-06-01'); | List all customers who have not used their mobile plans in the last 30 days. | SELECT customer_id, customer_name, plan_id FROM customers WHERE last_used_date < DATEADD(day, -30, CURRENT_TIMESTAMP); | gretelai_synthetic_text_to_sql |
CREATE TABLE Product (product_id INT PRIMARY KEY, product_name VARCHAR(50), price DECIMAL(5,2), is_circular_supply_chain BOOLEAN, material_recycled BOOLEAN); | Find the average price of products that are part of a circular supply chain and are made of recycled materials in the 'Product' table | SELECT AVG(price) FROM Product WHERE is_circular_supply_chain = TRUE AND material_recycled = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE subscribers (id INT, type VARCHAR(10), region VARCHAR(10)); INSERT INTO subscribers (id, type, region) VALUES (1, 'prepaid', 'island'), (2, 'postpaid', 'island'), (3, 'prepaid', 'island'), (4, 'postpaid', 'coastal'); | What is the total number of prepaid mobile customers in the 'island' region? | SELECT COUNT(*) FROM subscribers WHERE type = 'prepaid' AND region = 'island'; | gretelai_synthetic_text_to_sql |
CREATE TABLE bookings (booking_id INT, hotel_id INT, revenue INT); INSERT INTO bookings (booking_id, hotel_id, revenue) VALUES (1, 1, 5000); | Delete all records for a specific hotel in the 'bookings' table. | DELETE FROM bookings WHERE hotel_id = 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE impact (id INT, country TEXT, tourism INT, economic INT); INSERT INTO impact (id, country, tourism, economic) VALUES (1, 'Indonesia', 50000, 1000000); | Get the local economic impact of tourism in Indonesia. | SELECT economic FROM impact WHERE country = 'Indonesia'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Budget (Year INT, County VARCHAR(20), Department VARCHAR(20), Amount INT); INSERT INTO Budget (Year, County, Department, Amount) VALUES (2022, 'CountyE', 'Transportation', 1500000); | What was the total budget allocated for 'Transportation' in 'CountyE' in 2022? | SELECT SUM(Amount) FROM Budget WHERE Year = 2022 AND County = 'CountyE' AND Department = 'Transportation'; | gretelai_synthetic_text_to_sql |
CREATE TABLE patients (patient_id INT, age INT, has_hypertension BOOLEAN, gender VARCHAR, state VARCHAR); INSERT INTO patients (patient_id, age, has_hypertension, gender, state) VALUES (1, 45, true, 'Female', 'California'); INSERT INTO patients (patient_id, age, has_hypertension, gender, state) VALUES (2, 50, true, 'Male', 'Nevada'); CREATE TABLE rural_areas (area_id INT, state VARCHAR); INSERT INTO rural_areas (area_id, state) VALUES (1, 'California'); INSERT INTO rural_areas (area_id, state) VALUES (2, 'Nevada'); | What is the prevalence of hypertension in rural areas, grouped by state and gender? | SELECT state, gender, COUNT(*) * 100.0 / (SELECT COUNT(*) FROM patients JOIN rural_areas ON patients.state = rural_areas.state) AS prevalence FROM patients JOIN rural_areas ON patients.state = rural_areas.state WHERE has_hypertension = true GROUP BY state, gender; | gretelai_synthetic_text_to_sql |
CREATE TABLE skincare_sales (sale_id INT, product_id INT, sale_quantity INT, is_eco_friendly BOOLEAN, sale_date DATE, country VARCHAR(20)); INSERT INTO skincare_sales VALUES (1, 35, 9, true, '2021-11-15', 'Japan'); INSERT INTO skincare_sales VALUES (2, 36, 4, false, '2021-11-15', 'Japan'); | What is the total quantity of eco-friendly skincare products sold in Japan in the last year? | SELECT SUM(sale_quantity) FROM skincare_sales WHERE is_eco_friendly = true AND revenue_date BETWEEN '2020-01-01' AND '2021-12-31' AND country = 'Japan'; | gretelai_synthetic_text_to_sql |
CREATE TABLE victim_services (id INT, case_number INT, victim_name VARCHAR(255), service_type VARCHAR(255)); INSERT INTO victim_services (id, case_number, victim_name, service_type) VALUES (1, 1234, 'John Doe', 'Counseling'); CREATE TABLE defendant_services (id INT, case_number INT, defendant_name VARCHAR(255), service_type VARCHAR(255)); INSERT INTO defendant_services (id, case_number, defendant_name, service_type) VALUES (1, 1234, 'Jane Doe', 'Education'); | What is the total number of cases in both 'victim_services' and 'defendant_services' tables? | SELECT COUNT(DISTINCT v.case_number) FROM victim_services v JOIN defendant_services d ON v.case_number = d.case_number; | 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.