context stringlengths 11 9.12k | question stringlengths 0 1.06k | SQL stringlengths 2 4.44k | source stringclasses 28
values |
|---|---|---|---|
CREATE TABLE contracts (id INT, contractor VARCHAR(255), negotiation_date DATE, contract_value DECIMAL(10,2)); INSERT INTO contracts (id, contractor, negotiation_date, contract_value) VALUES (1, 'Northrop Grumman', '2021-01-10', 5000000); INSERT INTO contracts (id, contractor, negotiation_date, contract_value) VALUES (... | Display the total value of contracts negotiated by 'Northrop Grumman' in Q1 2021 from the 'contracts' table | SELECT SUM(contract_value) FROM contracts WHERE contractor = 'Northrop Grumman' AND QUARTER(negotiation_date) = 1 AND YEAR(negotiation_date) = 2021; | gretelai_synthetic_text_to_sql |
CREATE TABLE Training (WorkerID INT, Completion INT, Location VARCHAR(255)); INSERT INTO Training (WorkerID, Completion, Location) VALUES (1, 100, 'Urban'); INSERT INTO Training (WorkerID, Completion, Location) VALUES (2, 85, 'Suburban'); INSERT INTO Training (WorkerID, Completion, Location) VALUES (3, 92, 'Urban'); | What is the percentage of cultural competency training completed by community health workers from urban areas? | SELECT AVG(Completion) as AvgCompletion, Location FROM Training WHERE Location = 'Urban' GROUP BY Location; | gretelai_synthetic_text_to_sql |
CREATE TABLE users (user_id INT, username VARCHAR(20), email VARCHAR(50), follower_count INT); CREATE TABLE ads (ad_id INT, user_id INT, ad_content TEXT, start_time TIMESTAMP, end_time TIMESTAMP); | Create a table named privacy_settings with columns user_id, public_profile, location_sharing, posts_visibility, and comments_visibility. | CREATE TABLE privacy_settings (user_id INT, public_profile BOOLEAN, location_sharing BOOLEAN, posts_visibility ENUM('public', 'friends', 'private'), comments_visibility ENUM('public', 'friends', 'private')); | gretelai_synthetic_text_to_sql |
CREATE TABLE cbt_treatment (cbt_treatment_id INT, patient_id INT, country VARCHAR(50), duration_months INT); INSERT INTO cbt_treatment (cbt_treatment_id, patient_id, country, duration_months) VALUES (1, 25, 'Italy', 10), (2, 26, 'Italy', 12), (3, 27, 'Italy', 8); INSERT INTO cbt_treatment (cbt_treatment_id, patient_id,... | What is the average duration (in months) of cognitive behavioral therapy (CBT) treatment for patients in Italy? | SELECT AVG(duration_months) FROM cbt_treatment WHERE country = 'Italy'; | gretelai_synthetic_text_to_sql |
CREATE TABLE revenue (region VARCHAR(10), product VARCHAR(20), revenue INT); INSERT INTO revenue (region, product, revenue) VALUES ('Asia', 'shirt', 20000), ('Asia', 'pants', 30000); | What is the average revenue generated from the sale of clothing products in Asia? | SELECT AVG(revenue) FROM revenue WHERE region = 'Asia'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Visitors (id INT, city VARCHAR(50), first_time_visitor BOOLEAN, visit_year INT); INSERT INTO Visitors (id, city, first_time_visitor, visit_year) VALUES (1, 'London', TRUE, 2021); | Count the number of first-time visitors from London in the past 5 years. | SELECT COUNT(*) FROM Visitors WHERE city = 'London' AND first_time_visitor = TRUE AND visit_year BETWEEN 2017 AND 2021; | gretelai_synthetic_text_to_sql |
CREATE TABLE races (race_id INT, race_name VARCHAR(255)); INSERT INTO races VALUES (1, 'Race 1'); INSERT INTO races VALUES (2, 'Race 2'); CREATE TABLE results (race_id INT, winner_id INT, olympics VARCHAR(255)); INSERT INTO results VALUES (1, 1, '2022 Winter Olympics'); INSERT INTO results VALUES (2, 2, '2022 Winter Ol... | List all the races in the 2022 Winter Olympics with their corresponding winners | SELECT races.race_name, athletes.athlete_name as winner FROM races JOIN results ON races.race_id = results.race_id JOIN athletes ON results.winner_id = athletes.athlete_id WHERE races.olympics = '2022 Winter Olympics'; | gretelai_synthetic_text_to_sql |
CREATE TABLE experience (id INT, worker VARCHAR(50), years_of_experience INT); INSERT INTO experience (id, worker, years_of_experience) VALUES (1, 'John Doe', 3), (2, 'Jane Smith', 7), (3, 'Alice Johnson', 6); | Show all workers who have more than 5 years of experience | SELECT worker FROM experience WHERE years_of_experience > 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE ExcavationSites (id INT, site VARCHAR(20), location VARCHAR(30), start_date DATE, end_date DATE); INSERT INTO ExcavationSites (id, site, location, start_date, end_date) VALUES (1, 'BronzeAge', 'UK', '2000-01-01', '2005-12-31'), (2, 'IndusValley', 'India', '1993-01-01', '1996-12-31'); CREATE TABLE Artifacts... | Which artifacts were found in excavation sites located in 'Asia'? | SELECT artifact_name FROM Artifacts JOIN ExcavationSites ON Artifacts.excavation_site = ExcavationSites.site WHERE ExcavationSites.location = 'Asia'; | gretelai_synthetic_text_to_sql |
CREATE TABLE delivery (delivery_id INT, delivery_date DATE, num_items INT); INSERT INTO delivery (delivery_id, delivery_date, num_items) VALUES (1, '2022-01-01', 5), (2, '2022-01-02', 10), (3, '2022-01-03', 15); | What is the maximum number of items delivered in a single day? | SELECT MAX(d.num_items) FROM delivery d; | gretelai_synthetic_text_to_sql |
CREATE TABLE attractions (id INT, name TEXT, location TEXT, rating FLOAT); INSERT INTO attractions (id, name, location, rating) VALUES (1, 'Mt. Fuji', 'Japan', 4.6), (2, 'Eiffel Tower', 'France', 4.5); | What is the average rating of tourist attractions in each country? | SELECT location, AVG(rating) FROM attractions GROUP BY location; | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_species (id INT, name VARCHAR(255), conservation_status VARCHAR(255)); INSERT INTO marine_species (id, name, conservation_status) VALUES (1, 'Clownfish', 'Least Concern'); INSERT INTO marine_species (id, name, conservation_status) VALUES (2, 'Blue Whale', 'Endangered'); CREATE VIEW conservation_stat... | How many marine species are found in each conservation status category? | SELECT * FROM conservation_status_counts; | gretelai_synthetic_text_to_sql |
CREATE TABLE union_members (union_id VARCHAR(5), membership_count INT); | Delete all records with a membership count less than 100 from the union_members table | DELETE FROM union_members WHERE membership_count < 100; | gretelai_synthetic_text_to_sql |
CREATE TABLE esg_scores (id INT, ownership VARCHAR(20), sector VARCHAR(20), ESG_score FLOAT); INSERT INTO esg_scores (id, ownership, sector, ESG_score) VALUES (1, 'BIPOC', 'Renewable Energy', 87.5), (2, 'Non-BIPOC', 'Renewable Energy', 82.5), (3, 'BIPOC', 'Renewable Energy', 85.0); | Maximum ESG score for BIPOC-owned businesses in the renewable energy sector? | SELECT MAX(ESG_score) FROM esg_scores WHERE sector = 'Renewable Energy' AND ownership = 'BIPOC'; | gretelai_synthetic_text_to_sql |
CREATE TABLE SocialImpactInvestments (InvestmentID INT, InvestmentDate DATE, Sector VARCHAR(20), ESGScore INT); INSERT INTO SocialImpactInvestments VALUES (1, '2021-01-01', 'Education', 85), (2, '2021-02-01', 'Healthcare', 75), (3, '2021-03-01', 'Education', 90); | List all social impact investments in the Education sector with ESG scores above 80, ordered by investment date and ESG score. | SELECT * FROM SocialImpactInvestments WHERE Sector = 'Education' AND ESGScore > 80 ORDER BY InvestmentDate, ESGScore DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE Mining_Operations (Operation_ID INT, Mine_Name VARCHAR(100), Production_Volume INT, Energy_Consumption FLOAT); INSERT INTO Mining_Operations (Operation_ID, Mine_Name, Production_Volume, Energy_Consumption) VALUES (1, 'Golden Mine', 15000, 2500000); INSERT INTO Mining_Operations (Operation_ID, Mine_Name, Pr... | What is the total energy consumption for mining operations with production volume greater than 12,000 units? | SELECT SUM(Energy_Consumption) as 'Total Energy Consumption' FROM Mining_Operations WHERE Production_Volume > 12000; | gretelai_synthetic_text_to_sql |
CREATE TABLE fans (fan_id INT, team_id INT, gender VARCHAR(10)); CREATE TABLE teams (team_id INT, team_name VARCHAR(255)); INSERT INTO fans VALUES (1, 101, 'Male'), (2, 101, 'Female'), (3, 102, 'Male'), (4, 102, 'Other'), (5, 103, 'Female'), (6, 103, 'Male'); INSERT INTO teams VALUES (101, 'TeamA'), (102, 'TeamB'), (10... | How many fans of each team identify as male, female, or other? | SELECT t.team_name, f.gender, COUNT(f.fan_id) as fan_count FROM fans f JOIN teams t ON f.team_id = t.team_id GROUP BY t.team_name, f.gender; | gretelai_synthetic_text_to_sql |
CREATE TABLE AgriculturalProjects (id INT, project_name VARCHAR(255), location VARCHAR(255), start_date DATE, end_date DATE, budget FLOAT, focus_area VARCHAR(255)); INSERT INTO AgriculturalProjects (id, project_name, location, start_date, end_date, budget, focus_area) VALUES (1, 'Drip Irrigation', 'City C', '2018-01-01... | What is the total cost of agricultural projects with a focus on water conservation in urban areas? | SELECT AgriculturalProjects.location, AgriculturalProjects.focus_area, SUM(AgriculturalProjects.budget) as total_cost FROM AgriculturalProjects WHERE AgriculturalProjects.location = 'City C' AND AgriculturalProjects.focus_area = 'Water Conservation' GROUP BY AgriculturalProjects.location, AgriculturalProjects.focus_are... | gretelai_synthetic_text_to_sql |
CREATE TABLE Astronaut_Training (id INT, astronaut_id INT, training_type VARCHAR(255), hours FLOAT, date DATE); INSERT INTO Astronaut_Training VALUES (1, 1, 'EVA Training', 40.5, '2023-05-05'); | What is the average duration of spacewalk training for each astronaut in 2023? | SELECT astronaut_id, AVG(hours) as avg_spacewalk_hours FROM Astronaut_Training WHERE training_type = 'EVA Training' AND date BETWEEN '2023-01-01' AND '2023-12-31' GROUP BY astronaut_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE conservation_initiatives (initiative_id INT, initiative_name TEXT, start_date DATE); INSERT INTO conservation_initiatives (initiative_id, initiative_name, start_date) VALUES (1, 'Rainwater Harvesting', '2020-04-01'), (2, 'Greywater Recycling', '2019-08-15'), (3, 'Smart Irrigation', '2021-06-20'); | List water conservation initiatives with their start dates | SELECT initiative_name, start_date FROM conservation_initiatives; | gretelai_synthetic_text_to_sql |
CREATE TABLE HeartRate (UserID INT, HeartRate INT, Minutes INT); INSERT INTO HeartRate (UserID, HeartRate, Minutes) VALUES (1, 130, 45), (1, 110, 30), (2, 125, 35), (2, 140, 20); | How many users have a heart rate above 120 bpm for more than 30 minutes in a workout session? | SELECT COUNT(*) FROM HeartRate WHERE HeartRate > 120 AND Minutes > 30; | gretelai_synthetic_text_to_sql |
CREATE TABLE patients (id INT, name TEXT, age INT, is_indigenous BOOLEAN, has_diabetes BOOLEAN); INSERT INTO patients (id, name, age, is_indigenous, has_diabetes) VALUES (1, 'Juanita Flores', 50, true, true), (2, 'Brian White', 45, false, false), (3, 'Nia Brown', 60, true, true); | What is the average age of patients with diabetes in indigenous communities, and what is the total population in those communities? | SELECT AVG(patients.age), COUNT(patients.id) FROM patients WHERE patients.is_indigenous = true AND patients.has_diabetes = true; | gretelai_synthetic_text_to_sql |
CREATE TABLE UnderwritingData (PolicyID INT, Team VARCHAR(20), RiskAssessment DECIMAL(5,2), State VARCHAR(20)); INSERT INTO UnderwritingData VALUES (1, 'Team A', 0.35, 'California'), (2, 'Team B', 0.20, 'California'), (3, 'Team A', 0.15, 'Texas'); | Show Underwriting team's total risk assessment for policies in California? | SELECT SUM(RiskAssessment) FROM UnderwritingData WHERE State = 'California'; | gretelai_synthetic_text_to_sql |
CREATE TABLE diversity_metrics (company_name VARCHAR(50), gender VARCHAR(10), representation_percentage DECIMAL(5,2)); | Add diversity metrics for company LMN with gender Female and gender Non-binary in the 'diversity_metrics' table | INSERT INTO diversity_metrics (company_name, gender, representation_percentage) VALUES ('LMN', 'Female', 30.00), ('LMN', 'Non-binary', 7.50); | gretelai_synthetic_text_to_sql |
CREATE TABLE water_temperature (id INT, datetime DATE, temperature FLOAT, sea TEXT); INSERT INTO water_temperature (id, datetime, temperature, sea) VALUES (1, '2022-01-01', 5.5, 'North Sea'), (2, '2022-02-01', 4.8, 'North Sea'), (3, '2022-03-01', 4.2, 'North Sea'); | What is the minimum water temperature in the North Sea by month? | SELECT EXTRACT(MONTH FROM datetime) AS month, MIN(temperature) FROM water_temperature WHERE sea = 'North Sea' GROUP BY month; | gretelai_synthetic_text_to_sql |
CREATE TABLE Vessels (VesselID INT, VesselName TEXT, AverageSpeed DECIMAL(5,2)); CREATE TABLE Ports (PortID INT, PortName TEXT, Country TEXT); INSERT INTO Ports (PortID, PortName, Country) VALUES (1, 'Vancouver', 'Canada'), (2, 'Montreal', 'Canada'); INSERT INTO Vessels (VesselID, VesselName, AverageSpeed) VALUES (1, '... | What is the average speed of vessels that docked in a Canadian port? | SELECT AVG(AverageSpeed) FROM Vessels INNER JOIN Ports ON Vessels.VesselID = Ports.PortID WHERE Country = 'Canada'; | gretelai_synthetic_text_to_sql |
CREATE TABLE production (year INT, element VARCHAR(10), quantity INT); INSERT INTO production (year, element, quantity) VALUES (2018, 'Neodymium', 5000), (2019, 'Neodymium', 5500), (2020, 'Neodymium', 6000), (2021, 'Neodymium', 6500); | What is the total production of Neodymium in 2020? | SELECT SUM(quantity) FROM production WHERE year = 2020 AND element = 'Neodymium'; | gretelai_synthetic_text_to_sql |
CREATE TABLE posts (id INT, user_id INT, timestamp TIMESTAMP, content TEXT, likes INT, shares INT); | What is the average number of likes on posts containing the hashtag #sustainability in the past month? | SELECT AVG(likes) FROM posts WHERE timestamp BETWEEN DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 1 MONTH) AND CURRENT_TIMESTAMP AND content LIKE '%#sustainability%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE SpaceMissions (id INT, name VARCHAR(255), launch_date DATE);CREATE TABLE Astronauts (id INT, name VARCHAR(255), country VARCHAR(10), mission_id INT);CREATE VIEW Latin_America_Astronauts AS SELECT * FROM Astronauts WHERE country IN ('Argentina', 'Bolivia', 'Brazil', 'Chile', 'Colombia', 'Ecuador', 'French G... | List all space missions involving an astronaut from a Latin American country. | SELECT name FROM SpaceMissions sm JOIN Astronauts a ON sm.id = a.mission_id WHERE a.country IN (SELECT country FROM Latin_America_Astronauts); | gretelai_synthetic_text_to_sql |
CREATE TABLE RenewableEnergy.CityEnergy (city VARCHAR(50), energy_consumption FLOAT, num_buildings INT); INSERT INTO RenewableEnergy.CityEnergy (city, energy_consumption, num_buildings) VALUES ('NYC', 123456.7, 2000), ('LA', 150000.2, 3000), ('SF', 105000.1, 1500), ('Chicago', 140000.5, 2500), ('Houston', 180000.9, 350... | List all cities with their total energy consumption and the number of buildings in the 'RenewableEnergy' schema. | SELECT city, SUM(energy_consumption) AS total_energy, num_buildings FROM RenewableEnergy.CityEnergy GROUP BY city; | gretelai_synthetic_text_to_sql |
CREATE TABLE warehouse (id INT, name VARCHAR(20)); CREATE TABLE shipment (id INT, warehouse_id INT, weight FLOAT); INSERT INTO warehouse VALUES (1, 'LA'), (2, 'NY'), (3, 'TX'); INSERT INTO shipment VALUES (1, 1, 50.3), (2, 2, 60.2), (3, 3, 45.1), (4, 1, 70.4); | What are the names of all warehouses and their respective average shipment weights? | SELECT warehouse.name, AVG(shipment.weight) FROM warehouse INNER JOIN shipment ON warehouse.id = shipment.warehouse_id GROUP BY warehouse.id; | gretelai_synthetic_text_to_sql |
CREATE TABLE resource_depletion_rates (id INT, resource VARCHAR(255), depletion_rate DECIMAL(10,2)); | Calculate the percentage of resources that are depleted | SELECT resource, (depletion_rate * 100.0) as percentage FROM resource_depletion_rates; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA fitness; USE fitness; CREATE TABLE members (member_id INT PRIMARY KEY, name VARCHAR(50), age INT, membership VARCHAR(20)); INSERT INTO members (member_id, name, age, membership) VALUES (1, 'John Doe', 30, 'gold'), (2, 'Jane Smith', 40, 'silver'), (3, 'Mike Johnson', 50, 'platinum'), (4, 'Alice Davis', 35,... | How many members have a gold membership? | SELECT COUNT(*) FROM members WHERE membership = 'gold'; | gretelai_synthetic_text_to_sql |
CREATE TABLE public_participation_events (id INT, sector VARCHAR(20), year INT); INSERT INTO public_participation_events (id, sector, year) VALUES (1, 'justice', 2018), (2, 'justice', 2019), (3, 'justice', 2020), (4, 'justice', 2018), (5, 'justice', 2019), (6, 'justice', 2020); | What is the total number of public participation events in the justice sector in the last 3 years? | SELECT COUNT(DISTINCT year) FROM public_participation_events WHERE sector = 'justice' AND year BETWEEN (SELECT MAX(year) - 2 FROM public_participation_events) AND MAX(year); | gretelai_synthetic_text_to_sql |
CREATE TABLE online_course (id INT, student_id INT, course_name VARCHAR(50), completed BOOLEAN); | How many students have completed the online_course for the intro_to_psychology course? | SELECT COUNT(*) FROM online_course WHERE course_name = 'intro_to_psychology' AND completed = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE humanitarian_assistance (country VARCHAR(50), year INT, amount FLOAT); INSERT INTO humanitarian_assistance (country, year, amount) VALUES ('USA', 2020, 3000000000), ('China', 2020, 1000000000), ('Japan', 2020, 2000000000), ('India', 2020, 1500000000); | What is the total amount of humanitarian assistance provided by the USA and China for the year 2020? | SELECT SUM(amount) FROM humanitarian_assistance WHERE country IN ('USA', 'China') AND year = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE indian_pollution (pollutant_id INT, pollutant_name VARCHAR(255), weight DECIMAL(10,2), location VARCHAR(255)); CREATE VIEW indian_pollution_indian AS SELECT * FROM indian_pollution WHERE location LIKE '%Indian%'; | Determine the total weight of pollutants in the Indian ocean | SELECT SUM(weight) FROM indian_pollution_indian; | gretelai_synthetic_text_to_sql |
CREATE TABLE sites (site_id INT, state VARCHAR(2), num_workers INT, acres FLOAT); CREATE TABLE environmental_impact_assessments (assessment_id INT, site_id INT, assessment_date DATE); CREATE TABLE mining_sites (site_id INT, job_title VARCHAR(20), productivity FLOAT); | List all mining sites that have recorded environmental impact assessments, but have not recorded any productivity metrics. | SELECT s.site_id, s.state FROM sites s INNER JOIN environmental_impact_assessments e ON s.site_id = e.site_id LEFT JOIN mining_sites m ON s.site_id = m.site_id WHERE m.site_id IS NULL; | gretelai_synthetic_text_to_sql |
CREATE TABLE user_streams (user_id INT, song_id INT, times INT); INSERT INTO user_streams (user_id, song_id, times) VALUES (1, 1, 12), (1, 2, 5), (2, 1, 15), (3, 3, 10), (3, 1, 20), (4, 2, 3); | How many users have streamed a song more than 10 times? | SELECT COUNT(DISTINCT user_id) FROM user_streams WHERE times > 10; | gretelai_synthetic_text_to_sql |
CREATE TABLE Exhibition_Attendance (Exhibition_ID INT, Visitor_Count INT); INSERT INTO Exhibition_Attendance (Exhibition_ID, Visitor_Count) VALUES (1, 600), (2, 400), (3, 800); CREATE TABLE Exhibitions (ID INT, Name VARCHAR(255), Type VARCHAR(255)); INSERT INTO Exhibitions (ID, Name, Type) VALUES (1, 'Modern Art Show'... | List the names of all exhibitions that have more than 500 visitors. | SELECT Name FROM Exhibitions INNER JOIN Exhibition_Attendance ON Exhibitions.ID = Exhibition_Attendance.Exhibition_ID WHERE Visitor_Count > 500; | gretelai_synthetic_text_to_sql |
CREATE TABLE GameSales (GameID INT, GameType VARCHAR(10), Sales INT); INSERT INTO GameSales (GameID, GameType, Sales) VALUES (1, 'RPG', 50000), (2, 'FPS', 70000), (3, 'RPG', 60000), (4, 'Simulation', 80000); | What are the most popular game genres in Europe? | SELECT GameType, AVG(Sales) FROM GameSales GROUP BY GameType ORDER BY AVG(Sales) DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE volunteer_hours (volunteer_id INT, program_id INT, hours_spent INT, hours_date DATE); CREATE TABLE programs (program_id INT, program_name TEXT); INSERT INTO programs VALUES (1, 'Food Bank'); INSERT INTO programs VALUES (2, 'Education Support'); | What was the average number of hours spent by volunteers on each program in 2021? | SELECT program_id, program_name, AVG(hours_spent) as avg_hours_spent FROM volunteer_hours JOIN programs ON volunteer_hours.program_id = programs.program_id WHERE YEAR(hours_date) = 2021 GROUP BY program_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE RestaurantRevenue (category VARCHAR(20), year INT, revenue FLOAT); INSERT INTO RestaurantRevenue (category, year, revenue) VALUES ('Vegan', 2022, 12000.00),('Vegan', 2022, 15000.00),('Vegan', 2022, 18000.00); | What is the total revenue for the 'Vegan' category in '2022'? | SELECT SUM(revenue) FROM RestaurantRevenue WHERE category = 'Vegan' AND year = 2022; | gretelai_synthetic_text_to_sql |
CREATE TABLE startups(id INT, name TEXT, founder_continent TEXT, founding_year INT, funding FLOAT); INSERT INTO startups(id, name, founder_continent, founding_year, funding) VALUES (1, 'StartupA', 'North America', 2020, 500000), (2, 'StartupB', 'North America', 2019, 750000), (3, 'StartupC', 'North America', 2020, 2500... | What is the total funding received by startups founded by individuals from each continent in each year? | SELECT founder_continent, founding_year, SUM(funding) FROM startups GROUP BY founder_continent, founding_year; | gretelai_synthetic_text_to_sql |
CREATE TABLE GameStats (Game VARCHAR(100), MAU INT); INSERT INTO GameStats (Game, MAU) VALUES ('Overwatch', 150000); INSERT INTO GameStats (Game, MAU) VALUES ('Fortnite', 200000); INSERT INTO GameStats (Game, MAU) VALUES ('CS:GO', 120000); | How many unique games in the database have more than 100,000 monthly active users? | SELECT COUNT(DISTINCT Game) FROM GameStats WHERE MAU > 100000; | gretelai_synthetic_text_to_sql |
CREATE TABLE agroecology_projects (id INT, name TEXT, country TEXT, avg_rainfall FLOAT); INSERT INTO agroecology_projects (id, name, country, avg_rainfall) VALUES (1, 'Project 1', 'India', 150.0), (2, 'Project 2', 'Indonesia', 200.5); | What is the average rainfall in July for agroecology projects in India and Indonesia? | SELECT AVG(avg_rainfall) as avg_rainfall FROM agroecology_projects WHERE country IN ('India', 'Indonesia') AND MONTH(datetime) = 7; | gretelai_synthetic_text_to_sql |
CREATE TABLE students (id INT, name VARCHAR(50), gender VARCHAR(10), department VARCHAR(50)); INSERT INTO students (id, name, gender, department) VALUES (1, 'Grace', 'Female', 'Chemistry'); INSERT INTO students (id, name, gender, department) VALUES (2, 'Harry', 'Male', 'Physics'); INSERT INTO students (id, name, gender... | What is the percentage of female graduate students in the Computer Science department? | SELECT ROUND(100.0 * COUNT(CASE WHEN s.gender = 'Female' THEN 1 END) / COUNT(*), 2) AS pct_female_students FROM students s WHERE s.department = 'Computer Science'; | gretelai_synthetic_text_to_sql |
CREATE TABLE SalesDataNonGMO (sale_id INT, product_id INT, sale_date DATE, sale_revenue FLOAT, is_non_gmo BOOLEAN); INSERT INTO SalesDataNonGMO (sale_id, product_id, sale_date, sale_revenue, is_non_gmo) VALUES (1, 1, '2022-01-02', 75, true), (2, 2, '2022-01-15', 30, false), (3, 3, '2022-01-28', 60, false), (4, 4, '2022... | Determine the percentage of sales revenue for products that are labeled 'non-GMO', considering only sales from the past week. | SELECT (SUM(sale_revenue) / (SELECT SUM(sale_revenue) FROM SalesDataNonGMO WHERE sale_date >= DATEADD(week, -1, GETDATE()))) * 100 as revenue_percentage FROM SalesDataNonGMO WHERE is_non_gmo = true AND sale_date >= DATEADD(week, -1, GETDATE()); | gretelai_synthetic_text_to_sql |
CREATE TABLE grants (id INT, year INT, amount FLOAT, grant_type VARCHAR(20)); INSERT INTO grants (id, year, amount, grant_type) VALUES (1, 2020, 50000, 'Research'); INSERT INTO grants (id, year, amount, grant_type) VALUES (2, 2019, 75000, 'Research'); | What is the total number of research grants awarded by year? | SELECT year, SUM(amount) FROM grants WHERE grant_type = 'Research' GROUP BY year; | gretelai_synthetic_text_to_sql |
CREATE TABLE city_security_events (city VARCHAR(255), event_count INT); INSERT INTO city_security_events (city, event_count) VALUES ('São Paulo', 120), ('Moscow', 150), ('Delhi', 180), ('Beijing', 200), ('Johannesburg', 220); | What is the total number of security events recorded for each city? | SELECT city, SUM(event_count) as total_events FROM city_security_events GROUP BY city; | gretelai_synthetic_text_to_sql |
CREATE TABLE products (product_id INT, product VARCHAR(255), category VARCHAR(255), contains_parabens BOOLEAN); INSERT INTO products (product_id, product, category, contains_parabens) VALUES (1, 'Paraben-free Face Cream', 'Skin Care', FALSE), (2, 'Paraben-containing Hair Serum', 'Hair Care', TRUE), (3, 'Paraben-free Li... | What is the percentage of products that contain parabens, for each category? | SELECT category, (COUNT(contains_parabens) * 100.0 / (SELECT COUNT(*) FROM products WHERE category = outer_products.category)) as paraben_percentage FROM products outer_products GROUP BY category; | gretelai_synthetic_text_to_sql |
CREATE TABLE countries (name VARCHAR(50), region VARCHAR(50), carbon_emissions INT, population INT); INSERT INTO countries (name, region, carbon_emissions, population) VALUES ('India', 'Asia', 1805, 1380004385); INSERT INTO countries (name, region, carbon_emissions, population) VALUES ('China', 'Asia', 7494, 1439323776... | What is the average carbon emissions per capita for each country in the Asia region with a population greater than 50 million? | SELECT region, AVG(carbon_emissions) FROM countries WHERE region = 'Asia' AND population > 50000000 GROUP BY region; | gretelai_synthetic_text_to_sql |
CREATE TABLE mining_sites (site_id INT, site_name TEXT, location TEXT); INSERT INTO mining_sites (site_id, site_name, location) VALUES (1, 'Caribbean Gold', 'Kingston, Jamaica'), (2, 'Sahara Silver', 'Timbuktu, Mali'), (3, 'Andean Copper', 'Santiago, Chile'); CREATE TABLE waste_production (site_id INT, production_date ... | What is the total amount of waste produced by each mining site per month? | SELECT site_name, EXTRACT(MONTH FROM production_date) AS month, SUM(amount_waste) AS total_waste FROM waste_production JOIN mining_sites ON waste_production.site_id = mining_sites.site_id GROUP BY site_name, month; | gretelai_synthetic_text_to_sql |
CREATE TABLE green_buildings.green_buildings_data (city VARCHAR(20), green_building BOOLEAN); | What is the total number of green buildings in the 'green_buildings' schema, by city? | SELECT city, COUNT(*) FROM green_buildings.green_buildings_data WHERE green_building = TRUE GROUP BY city; | gretelai_synthetic_text_to_sql |
CREATE TABLE shelter_units (id INT, company VARCHAR(255), country VARCHAR(255), units_constructed INT); INSERT INTO shelter_units (id, company, country, units_constructed) VALUES ('1', 'ABC Construction', 'Afghanistan', '10'), ('2', 'XYZ Construction', 'Afghanistan', '15'), ('3', 'LMN Construction', 'Pakistan', '20'), ... | What is the total number of shelter units constructed in Afghanistan and Pakistan, grouped by construction company? | SELECT company, SUM(units_constructed) as total_units FROM shelter_units WHERE country IN ('Afghanistan', 'Pakistan') GROUP BY company; | gretelai_synthetic_text_to_sql |
CREATE TABLE Sustainable_Projects (Project_ID INT, Project_Name TEXT, Location TEXT, Cost FLOAT, Sustainable BOOLEAN); INSERT INTO Sustainable_Projects (Project_ID, Project_Name, Location, Cost, Sustainable) VALUES (1, 'Green House', 'California', 500000.00, true), (2, 'Eco Office', 'New York', 750000.00, true), (3, 'S... | What is the total cost of all sustainable building projects in Texas? | SELECT SUM(Cost) FROM Sustainable_Projects WHERE Location = 'Texas' AND Sustainable = true; | gretelai_synthetic_text_to_sql |
CREATE TABLE urban_agriculture (project_name TEXT, country TEXT, area_ha FLOAT); INSERT INTO urban_agriculture (project_name, country, area_ha) VALUES ('Project A', 'Canada', 23.5); INSERT INTO urban_agriculture (project_name, country, area_ha) VALUES ('Project B', 'USA', 45.6); | What is the total area (in hectares) of all urban agriculture projects in Canada and the United States? | SELECT SUM(area_ha) FROM urban_agriculture WHERE country IN ('Canada', 'USA'); | gretelai_synthetic_text_to_sql |
CREATE TABLE age_groups (age_group TEXT, lower_limit INTEGER, upper_limit INTEGER); INSERT INTO age_groups (age_group, lower_limit, upper_limit) VALUES ('18-24', 18, 24), ('25-34', 25, 34); CREATE TABLE california_farmers (farmer_name TEXT, age INTEGER, state TEXT, year INTEGER); INSERT INTO california_farmers (farmer_... | Find the number of farmers by age group for the state of California in 2020. | SELECT state, age_group, COUNT(*) FROM california_farmers JOIN age_groups ON california_farmers.age BETWEEN age_groups.lower_limit AND age_groups.upper_limit WHERE state = 'CA' AND year = 2020 GROUP BY state, age_group; | gretelai_synthetic_text_to_sql |
CREATE TABLE weather (city VARCHAR(255), temperature FLOAT, date DATE); INSERT INTO weather (city, temperature, date) VALUES ('Berlin', 80, '2022-05-01'), ('Berlin', 85, '2022-06-15'), ('Berlin', 90, '2022-07-20'); | What is the highest temperature recorded in 'Berlin'? | SELECT MAX(temperature) FROM weather WHERE city = 'Berlin'; | gretelai_synthetic_text_to_sql |
CREATE TABLE region (region_id INT, region_name VARCHAR(50), country_code VARCHAR(5)); INSERT INTO region (region_id, region_name, country_code) VALUES (1, 'Shinjuku', 'JPN'), (2, 'Shibuya', 'JPN'); CREATE TABLE support_program (program_id INT, program_date DATE, region_id INT); INSERT INTO support_program (program_id,... | How many disability support programs were implemented in each district in Tokyo? | SELECT R.region_name, COUNT(SP.program_id) as total_programs FROM support_program SP JOIN region R ON SP.region_id = R.region_id WHERE R.country_code = 'JPN' GROUP BY R.region_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE artists (id INT, name TEXT, genre TEXT); INSERT INTO artists (id, name, genre) VALUES (1, 'Beyoncé', 'Pop'), (2, 'Rihanna', 'Hip Hop'); | Update the genre of the artist with id 2 to 'R&B'. | UPDATE artists SET genre = 'R&B' WHERE id = 2; | gretelai_synthetic_text_to_sql |
CREATE TABLE Sales (id INT, garmentID INT, quantity INT, saleDate DATE); INSERT INTO Sales (id, garmentID, quantity, saleDate) VALUES (1, 101, 7, '2021-01-10'), (2, 102, 4, '2021-02-15'), (3, 103, 6, '2021-03-20'), (4, 104, 5, '2021-04-12'); CREATE TABLE Garments (id INT, garmentID INT, size INT, country VARCHAR(50)); ... | How many size 14 garments were sold in the United States in the last quarter? | SELECT SUM(quantity) FROM Sales INNER JOIN Garments ON Sales.garmentID = Garments.garmentID WHERE Garments.size = 14 AND Sales.saleDate BETWEEN '2021-01-01' AND '2021-04-30' AND Garments.country = 'USA'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Donors (Donor_ID int, Name varchar(50), Donation_Amount int, Country varchar(50)); | Insert a new donor from Egypt with a donation amount of 5500 | INSERT INTO Donors (Donor_ID, Name, Donation_Amount, Country) VALUES (6, 'Ahmed Hussein', 5500, 'Egypt'); | gretelai_synthetic_text_to_sql |
CREATE TABLE desert_sheriff (id INT, call_type VARCHAR(20), call_date TIMESTAMP); INSERT INTO desert_sheriff VALUES (1, 'heat_exhaustion', '2022-01-04 22:00:00'), (2, 'heat_exhaustion', '2022-01-05 23:00:00'); | List the total number of calls for each call type in the 'desert_sheriff' table, ordered by the number of calls. | SELECT call_type, COUNT(*) FROM desert_sheriff GROUP BY call_type ORDER BY COUNT(*) DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE Employees (EmployeeID INT, FirstName VARCHAR(50), LastName VARCHAR(50), Department VARCHAR(50), Salary DECIMAL(10,2)); INSERT INTO Employees (EmployeeID, FirstName, LastName, Department, Salary) VALUES (1, 'John', 'Doe', 'Assembly', 60000.00), (2, 'Jane', 'Doe', 'Quality', 55000.00), (3, 'Mike', 'Smith', '... | What is the minimum salary of employees who work in the 'Assembly' department? | SELECT MIN(Salary) FROM Employees WHERE Department = 'Assembly'; | gretelai_synthetic_text_to_sql |
CREATE TABLE New_Mine_Productivity (Mine_Name VARCHAR(50), Productivity FLOAT, Year INT); | Insert a new record for the mine 'Amethyst Ascent' with productivity 5.9 and year 2019. | INSERT INTO New_Mine_Productivity (Mine_Name, Productivity, Year) VALUES ('Amethyst Ascent', 5.9, 2019); | gretelai_synthetic_text_to_sql |
CREATE TABLE dispensaries (id INT, name TEXT, state TEXT, equitable BOOLEAN); INSERT INTO dispensaries (id, name, state, equitable) VALUES (1, 'Dispensary X', 'Michigan', true), (2, 'Dispensaries Y', 'Michigan', false); CREATE TABLE licenses (id INT, dispensary_id INT, status TEXT); INSERT INTO licenses (id, dispensary... | Which dispensaries in MI have a license and specific strain available? | SELECT d.name FROM dispensaries d JOIN licenses l ON d.id = l.dispensary_id JOIN strains s ON d.id = s.dispensary_id WHERE d.state = 'Michigan' AND l.status = 'active' AND s.name = 'Strain A'; | gretelai_synthetic_text_to_sql |
CREATE TABLE ai_safety_incidents (incident_id INTEGER, incident_cost FLOAT, region TEXT); INSERT INTO ai_safety_incidents (incident_id, incident_cost, region) VALUES (11, 6500, 'Asia'), (12, 5000, 'Asia'), (13, 7000, 'Europe'); | Display the AI safety incidents in Asia with costs greater than $6000. | SELECT incident_id, incident_cost FROM ai_safety_incidents WHERE region = 'Asia' AND incident_cost > 6000; | gretelai_synthetic_text_to_sql |
CREATE TABLE households (id INT, household_id INT, water_consumption FLOAT, state VARCHAR(50)); INSERT INTO households VALUES (1, 1001, 500, 'Florida'), (2, 1002, 550, 'Florida'), (3, 1003, 600, 'Florida'), (4, 1004, 450, 'Florida'); CREATE TABLE cities (id INT, city_name VARCHAR(50), state VARCHAR(50)); INSERT INTO ci... | What is the average water consumption per household in the state of Florida? | SELECT AVG(households.water_consumption) as avg_consumption FROM households JOIN addresses ON households.household_id = addresses.household_id JOIN cities ON addresses.city_id = cities.id WHERE cities.state = 'Florida'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Departments (id INT, name VARCHAR(50), budget DECIMAL(10,2)); | What is the total salary cost for the Production department? | SELECT SUM(d.budget) FROM Departments d JOIN Employees e ON d.name = e.department WHERE d.name = 'Production'; | gretelai_synthetic_text_to_sql |
CREATE TABLE community_policing (id INT, initiative_name VARCHAR(255), start_date DATE); INSERT INTO community_policing (id, initiative_name, start_date) VALUES (1, 'Safe Streets Program', '2018-01-01'), (2, 'Youth Mentoring', '2019-04-01'); | What is the total number of community policing initiatives implemented in the city of Houston since the year 2018? | SELECT COUNT(*) FROM community_policing WHERE start_date <= '2018-12-31'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Seals (id INT, seal_species VARCHAR(20), location VARCHAR(30), population INT); INSERT INTO Seals (id, seal_species, location, population) VALUES (1, 'Leopard Seal', 'Southern Ocean', 1500); INSERT INTO Seals (id, seal_species, location, population) VALUES (2, 'Crabeater Seal', 'Southern Ocean', 1000); | What is the minimum population of seals in the Southern Hemisphere? | SELECT location, MIN(population) as min_population FROM Seals WHERE location LIKE 'Southern%' GROUP BY location; | gretelai_synthetic_text_to_sql |
CREATE TABLE incidents (incident_id INT, incident_year INT, incident_quarter INT, region_id INT, incident_count INT); INSERT INTO incidents (incident_id, incident_year, incident_quarter, region_id, incident_count) VALUES (1, 2021, 1, 3, 50), (2, 2021, 2, 3, 75), (3, 2021, 3, 3, 60), (4, 2021, 4, 3, 80); | What is the total number of cybersecurity incidents in the last year, grouped by the quarter, for the 'Asia' region? | SELECT incident_year, incident_quarter, SUM(incident_count) as total_incidents FROM incidents WHERE region_id = 3 AND incident_year >= YEAR(CURRENT_DATE) - 1 GROUP BY incident_year, incident_quarter ORDER BY incident_year, incident_quarter; | gretelai_synthetic_text_to_sql |
CREATE TABLE systems (id INT, software_version VARCHAR(255), vulnerabilities INT); INSERT INTO systems (id, software_version, vulnerabilities) VALUES (1, 'outdated', 3), (2, 'updated', 1), (3, 'outdated', 2); | What is the total number of vulnerabilities found in systems with outdated software? | SELECT SUM(vulnerabilities) FROM systems WHERE software_version = 'outdated'; | gretelai_synthetic_text_to_sql |
CREATE TABLE market_trends ( id INT PRIMARY KEY, element VARCHAR(10), year INT, price DECIMAL(5,2)); INSERT INTO market_trends (id, element, year, price) VALUES (1, 'Europium', 2018, 500), (2, 'Europium', 2019, 600), (3, 'Europium', 2020, 700), (4, 'Europium', 2021, 800); | Show all the records from 'market_trends' table with prices above the average price of Europium in 2020. | SELECT * FROM market_trends WHERE element = 'Europium' AND year = 2020; SELECT * FROM market_trends WHERE price > (SELECT AVG(price) FROM market_trends WHERE element = 'Europium' AND year = 2020); | gretelai_synthetic_text_to_sql |
CREATE TABLE GamePublishers (GameID int, Publisher varchar(50), PlayTime int, Score int); INSERT INTO GamePublishers (GameID, Publisher, PlayTime, Score) VALUES (5, 'PublisherA', 300, 82); INSERT INTO GamePublishers (GameID, Publisher, PlayTime, Score) VALUES (6, 'PublisherB', 350, 87); | What is the total play time and average score for each game publisher? | SELECT Publisher, SUM(PlayTime) as TotalPlayTime, AVG(Score) as AvgScore FROM GamePublishers GROUP BY Publisher; | gretelai_synthetic_text_to_sql |
CREATE TABLE restorative_justice_programs (id INT, case_number INT, program_duration INT); | What is the maximum duration of a case in restorative justice programs? | SELECT MAX(program_duration) FROM restorative_justice_programs; | gretelai_synthetic_text_to_sql |
CREATE TABLE if not exists sales (id INT PRIMARY KEY, product_id INT, purchase_date DATE, quantity INT, price DECIMAL(5,2)); INSERT INTO sales (id, product_id, purchase_date, quantity, price) VALUES (2, 2, '2022-01-02', 3, 18.99); CREATE TABLE if not exists product (id INT PRIMARY KEY, name TEXT, brand_id INT, price DE... | What are the top 3 brands by sales? | SELECT brand.name, SUM(quantity * price) AS total_sales FROM sales JOIN product ON sales.product_id = product.id JOIN brand ON product.brand_id = brand.id GROUP BY brand.name ORDER BY total_sales DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE events (event_id INT, event_name VARCHAR(50), city VARCHAR(30), funding_source VARCHAR(30), attendance INT); INSERT INTO events (event_id, event_name, city, funding_source, attendance) VALUES (1, 'Theater Play', 'New York', 'Government', 200), (2, 'Art Exhibit', 'Los Angeles', 'Private Donors', 300), (3, '... | Display the number of events funded by "Private Donors" per city and the total attendance for these events | SELECT city, COUNT(*) as num_events, SUM(attendance) as total_attendance FROM events WHERE funding_source = 'Private Donors' GROUP BY city; | gretelai_synthetic_text_to_sql |
CREATE TABLE DinnerMenu(menu_item VARCHAR(50), ingredients TEXT, weight DECIMAL(5,2)); INSERT INTO DinnerMenu VALUES('Steak', 'beef 500g, potatoes 200g', 500), ('Spaghetti Bolognese', 'beef 300g, tomatoes 400g', 300), ('Vegetable Lasagna', 'eggplant 400g, zucchini 400g', 0); | What is the total weight of beef used in the dinner menu? | SELECT SUM(weight) FROM DinnerMenu WHERE ingredients LIKE '%beef%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE soil_types (region VARCHAR(255), soil_type VARCHAR(255), soil_description TEXT); | Create a new table 'soil_types' with columns 'region', 'soil_type', and 'soil_description'. | INSERT INTO soil_types (region, soil_type, soil_description) VALUES ('RegionA', 'Loamy', 'Well-draining soil with ideal balance of sand, silt, and clay'), ('RegionB', 'Sandy', 'Coarse-grained soil with quick water drainage and low nutrient content'), ('RegionC', 'Clay', 'Fine-grained soil with slow water drainage and h... | gretelai_synthetic_text_to_sql |
CREATE TABLE mines (id INT, name TEXT, location TEXT, production_quantity INT); INSERT INTO mines (id, name, location, production_quantity) VALUES (1, 'Phalaborwa', 'South Africa', 250), (2, 'Palabora', 'South Africa', 400); | What is the average production quantity (in metric tons) of Samarium from mines located in South Africa? | SELECT AVG(production_quantity) FROM mines WHERE location = 'South Africa' AND element = 'Samarium'; | gretelai_synthetic_text_to_sql |
CREATE TABLE ports (port_id INT, port_name VARCHAR(50), country VARCHAR(50)); CREATE TABLE cargo (cargo_id INT, port_id INT, cargo_type VARCHAR(50), weight INT); | What is the most common type of cargo at the Port of Oakland? | SELECT cargo_type, COUNT(cargo_type) AS frequency FROM cargo C JOIN ports P ON C.port_id = P.port_id WHERE port_name = 'Port of Oakland' GROUP BY cargo_type ORDER BY frequency DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE carbon_offset (id INT, initiative_name VARCHAR(50), region VARCHAR(50), offset_amount INT); INSERT INTO carbon_offset (id, initiative_name, region, offset_amount) VALUES (1, 'GreenCities EU', 'Europe', 25000), (2, 'CleanAir NA', 'North America', 18000), (3, 'SmartGrid AP', 'Asia Pacific', 22000), (4, 'EcoR... | What is the total carbon offset by smart city initiatives in Europe? | SELECT SUM(offset_amount) FROM carbon_offset WHERE region = 'Europe'; | gretelai_synthetic_text_to_sql |
CREATE TABLE CoOwnership (id INT, city VARCHAR(20), year INT); | What is the maximum year of implementation of co-ownership agreements in the city of Berlin? | SELECT MAX(year) FROM CoOwnership WHERE city = 'Berlin'; | gretelai_synthetic_text_to_sql |
CREATE TABLE news_articles_2 (article_id INT, pub_date DATE, category VARCHAR(255)); INSERT INTO news_articles_2 (article_id, pub_date, category) VALUES (1, '2022-01-01', 'Politics'), (2, '2022-01-10', 'Sports'), (3, '2022-03-15', 'Entertainment'), (4, '2022-03-20', 'Politics'), (5, '2022-04-01', 'Politics'); | List the top 3 categories with the highest number of articles published in H1 2022, and the corresponding total amounts. | SELECT category, SUM(amount) AS total FROM (SELECT category, COUNT(*) AS amount, ROW_NUMBER() OVER (PARTITION BY category ORDER BY COUNT(*) DESC) AS rn FROM news_articles_2 WHERE pub_date BETWEEN '2022-01-01' AND '2022-06-30' GROUP BY category) t WHERE rn <= 3 GROUP BY category; | gretelai_synthetic_text_to_sql |
CREATE TABLE Food (FoodID varchar(10), FoodName varchar(20), Calories int); INSERT INTO Food VALUES ('X', 'Product X', 400); | Update the caloric information of product X to 350. | UPDATE Food SET Calories = 350 WHERE FoodID = 'X'; | gretelai_synthetic_text_to_sql |
CREATE TABLE systems (system_id INT, system_name VARCHAR(255), country VARCHAR(255));CREATE TABLE scan_dates (scan_date DATE, system_id INT); | What are the top 3 most scanned countries and their corresponding number of scans in the last month? | SELECT s.country, COUNT(sd.scan_date) as scan_count FROM systems s INNER JOIN scan_dates sd ON s.system_id = sd.system_id WHERE sd.scan_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) GROUP BY s.country ORDER BY scan_count DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE community_policing (policing_type VARCHAR(255), frequency INT, location VARCHAR(255)); | Insert data into 'community_policing' table with policing type 'community meetings', frequency 5, and location 'Chicago' | INSERT INTO community_policing (policing_type, frequency, location) VALUES ('community meetings', 5, 'Chicago'); | gretelai_synthetic_text_to_sql |
CREATE TABLE WorkplaceSafety (id INT PRIMARY KEY, union_member BOOLEAN, incident_date DATE, incident_type VARCHAR(20), severity INT); CREATE TABLE UnionMembers (id INT PRIMARY KEY, name VARCHAR(50), state VARCHAR(2), union_id INT, FOREIGN KEY (union_id) REFERENCES UnionNegotiations(union_id)); CREATE TABLE UnionNegoti... | Display the names and states of union members who were involved in more than one machinery malfunction incident in the past year. | SELECT DISTINCT u.name, u.state FROM UnionMembers u JOIN WorkplaceSafety w ON u.id = w.union_member WHERE incident_date >= DATE(NOW()) - INTERVAL 1 YEAR GROUP BY u.id HAVING COUNT(*) > 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE articles (id INT, title VARCHAR(100), word_count INT, publication_date DATE, category VARCHAR(50)); | What is the total number of articles published in the "articles" table that have more than 500 words? | SELECT COUNT(*) FROM articles WHERE word_count > 500; | gretelai_synthetic_text_to_sql |
CREATE TABLE Employees (EmployeeID INT, Department VARCHAR(20), Gender VARCHAR(20), Salary FLOAT); INSERT INTO Employees (EmployeeID, Department, Gender, Salary) VALUES (1, 'IT', 'Male', 70000), (2, 'HR', 'Female', 60000), (3, 'IT', 'Female', 75000), (4, 'IT', 'Male', 78000), (5, 'Finance', 'Male', 85000), (6, 'Finance... | What is the minimum salary of male employees in the Finance department? | SELECT MIN(Salary) FROM Employees WHERE Department = 'Finance' AND Gender = 'Male'; | gretelai_synthetic_text_to_sql |
CREATE TABLE ThreatIntel (indicator_id INT, indicator VARCHAR(50), type VARCHAR(20), timestamp TIMESTAMP); INSERT INTO ThreatIntel (indicator_id, indicator, type, timestamp) VALUES (1, '192.168.1.1', 'IP', '2022-01-01 10:00:00'); | What are the top 3 types of threat indicators with the highest number of occurrences in the last month? | SELECT type, COUNT(indicator_id) as total_occurrences FROM ThreatIntel WHERE timestamp BETWEEN DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 1 MONTH) AND CURRENT_TIMESTAMP GROUP BY type ORDER BY total_occurrences DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE matches (id INT, game VARCHAR(10), player VARCHAR(50), result VARCHAR(10), match_date DATE); INSERT INTO matches (id, game, player, result, match_date) VALUES (1, 'CS:GO', 'ZywOo', 'Win', '2023-02-22'); | Which eSports players have the highest win rate in 'CS:GO' Major Championships? | SELECT player, COUNT(*) * 100.0 / SUM(CASE WHEN result = 'Win' THEN 1 ELSE 0 END) AS win_rate FROM matches WHERE game = 'CS:GO' AND match_date BETWEEN '2018-08-30' AND '2023-02-22' GROUP BY player ORDER BY win_rate DESC, player DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE schools (id INT, name TEXT, num_teachers INT, num_female_teachers INT); | Which schools have the highest proportion of female teachers? | SELECT s.name, (s.num_female_teachers::FLOAT/s.num_teachers) as prop_female_teachers FROM schools s ORDER BY prop_female_teachers DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_protected_areas (id INT, name TEXT, location TEXT, size FLOAT); INSERT INTO marine_protected_areas (id, name, location, size) VALUES (1, 'Pacific MPAs', 'Pacific Ocean', 1800.0), (2, 'Atlantic MPAs', 'Atlantic Ocean', 1200.5), (3, 'Caribbean MPAs', 'Caribbean Ocean', 2000.3); | How many marine protected areas (MPAs) are there in the Pacific Ocean that are larger than 1500 square kilometers? | SELECT COUNT(*) FROM marine_protected_areas WHERE location = 'Pacific Ocean' AND size > 1500; | gretelai_synthetic_text_to_sql |
CREATE TABLE broadband_usage (subscriber_id INT, technology VARCHAR(20), data_usage FLOAT, usage_date DATE); INSERT INTO broadband_usage (subscriber_id, technology, data_usage, usage_date) VALUES (1, 'Cable', 15.5, '2022-01-01'), (2, 'Fiber', 20.0, '2022-02-15'), (3, 'Cable', 16.0, '2022-03-01'); | What is the monthly trend of data usage for the top 10 broadband subscribers, for each technology type, in the past 12 months? | SELECT subscriber_id, technology, EXTRACT(MONTH FROM usage_date) as month, AVG(data_usage) as avg_data_usage FROM broadband_usage WHERE subscriber_id IN (SELECT subscriber_id FROM broadband_usage GROUP BY subscriber_id ORDER BY SUM(data_usage) DESC LIMIT 10) AND usage_date >= DATE_SUB(CURRENT_DATE, INTERVAL 12 MONTH) G... | gretelai_synthetic_text_to_sql |
CREATE TABLE Brands (BrandID INT, BrandName VARCHAR(50)); INSERT INTO Brands (BrandID, BrandName) VALUES (1, 'H&M'), (2, 'Zara'), (3, 'Patagonia'), (4, 'Everlane'), (5, 'People Tree'); CREATE TABLE Awareness (BrandID INT, Score INT); INSERT INTO Awareness (BrandID, Score) VALUES (1, 75), (2, 60), (3, 90), (4, 80), (5, ... | What is the consumer awareness score for each brand in the ethical fashion domain? | SELECT b.BrandName, a.Score FROM Brands b JOIN Awareness a ON b.BrandID = a.BrandID | gretelai_synthetic_text_to_sql |
CREATE TABLE customers (customer_id INT, name VARCHAR(50), country VARCHAR(50)); INSERT INTO customers (customer_id, name, country) VALUES (1, 'John Doe', 'Canada'); CREATE TABLE products (product_id INT, name VARCHAR(50), eco_friendly BOOLEAN); INSERT INTO products (product_id, name, eco_friendly) VALUES (1, 'Eco-Frie... | How many customers in Canada have purchased eco-friendly jeans? | SELECT COUNT(*) FROM sales s INNER JOIN customers c ON s.customer_id = c.customer_id INNER JOIN products p ON s.product_id = p.product_id WHERE c.country = 'Canada' AND p.name = 'Eco-Friendly Jeans' AND p.eco_friendly = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE Player (PlayerID int, PlayerName varchar(50), TeamID int); CREATE TABLE Assists (AssistID int, PlayerID int, Assists int, MatchDate date); INSERT INTO Player (PlayerID, PlayerName, TeamID) VALUES (1, 'Lionel Messi', 1), (2, 'Cristiano Ronaldo', 2), (3, 'Kevin De Bruyne', 1), (4, 'Bruno Fernandes', 2); INS... | What is the total number of assists by a player, partitioned by their team, in descending order? | SELECT PlayerID, TeamID, SUM(Assists) OVER (PARTITION BY TeamID ORDER BY SUM(Assists) DESC) AS Total_Assists FROM Assists a JOIN Player p ON a.PlayerID = p.PlayerID ORDER BY Total_Assists DESC; | 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.