context stringlengths 11 9.12k | question stringlengths 0 1.06k | SQL stringlengths 2 4.44k | source stringclasses 28
values |
|---|---|---|---|
CREATE TABLE MilitaryEquipmentSales (SaleID INT, Equipment VARCHAR(50), Quantity INT, Country VARCHAR(50), SaleDate DATE); INSERT INTO MilitaryEquipmentSales (SaleID, Equipment, Quantity, Country, SaleDate) VALUES (1, 'Tank', 10, 'USA', '2020-01-01'), (2, 'Jet', 5, 'Canada', '2019-07-15'); | What is the total quantity of military equipment sold to Canada since 2019? | SELECT Equipment, SUM(Quantity) FROM MilitaryEquipmentSales WHERE Country = 'Canada' AND SaleDate >= '2019-01-01' GROUP BY Equipment; | gretelai_synthetic_text_to_sql |
CREATE TABLE customers (id INT, name VARCHAR(255), city VARCHAR(255)); CREATE TABLE transactions (id INT, customer_id INT, amount DECIMAL(10,2), transaction_type VARCHAR(255)); INSERT INTO customers (id, name, city) VALUES (1, 'John Doe', 'London'); INSERT INTO transactions (id, customer_id, amount, transaction_type) V... | What is the average transaction amount for retail customers in London? | SELECT AVG(t.amount) as avg_amount FROM transactions t JOIN customers c ON t.customer_id = c.id WHERE c.city = 'London' AND t.transaction_type = 'Retail'; | gretelai_synthetic_text_to_sql |
CREATE TABLE RuralInfrastructure (id INT PRIMARY KEY, region VARCHAR(20), year INT, completed BOOLEAN); | How many rural infrastructure projects were completed in Latin America in 2022? | SELECT COUNT(*) FROM RuralInfrastructure WHERE region = 'Latin America' AND year = 2022 AND completed = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE brazil_ingredient_sourcing (id INT, product_id INT, organic_ingredients_percentage INT); INSERT INTO brazil_ingredient_sourcing (id, product_id, organic_ingredients_percentage) VALUES (1, 1, 75); | What is the average percentage of organic ingredients in cosmetic products sourced from Brazil? | SELECT AVG(organic_ingredients_percentage) FROM brazil_ingredient_sourcing; | gretelai_synthetic_text_to_sql |
CREATE TABLE mine (id INT, name TEXT, location TEXT, mineral TEXT, production INT); INSERT INTO mine (id, name, location, mineral, production) VALUES (1, 'Vale', 'Canada', 'Nickel', 12000), (2, 'Glencore', 'Canada', 'Nickel', 15000); | What is the total production of nickel mines in Canada? | SELECT SUM(production) FROM mine WHERE mineral = 'Nickel' AND location = 'Canada'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Players (PlayerID INT, Age INT, Country VARCHAR(50)); INSERT INTO Players (PlayerID, Age, Country) VALUES (1, 25, 'India'), (2, 30, 'Canada'), (3, 22, 'Germany'), (4, 35, 'Japan'); CREATE TABLE GameLibrary (GameID INT, GameName VARCHAR(50), GameType VARCHAR(50), Category VARCHAR(50)); INSERT INTO GameLibra... | How many players from India play games that are available in the 'Action' category? | SELECT COUNT(Players.PlayerID) FROM Players JOIN PlayerGameLibrary ON Players.PlayerID = PlayerGameLibrary.PlayerID JOIN GameLibrary ON PlayerGameLibrary.GameID = GameLibrary.GameID WHERE Players.Country = 'India' AND GameLibrary.Category = 'Action'; | gretelai_synthetic_text_to_sql |
CREATE TABLE covid_data (id INT, state TEXT, region TEXT, confirmed_cases INT); INSERT INTO covid_data (id, state, region, confirmed_cases) VALUES (1, 'State A', 'Region 1', 500), (2, 'State B', 'Region 2', 300), (3, 'State C', 'Region 1', 700), (4, 'State D', 'Region 3', 800); | How many confirmed COVID-19 cases are there in each region, ordered by the total number of cases, descending? | SELECT region, SUM(confirmed_cases) as total_cases FROM covid_data GROUP BY region ORDER BY total_cases DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE Cities (CityID INT, CityName VARCHAR(255)); CREATE TABLE Properties (PropertyID INT, PropertyType VARCHAR(255), CityID INT); INSERT INTO Cities VALUES (1, 'New York'); INSERT INTO Properties VALUES (1, 'Multi-Unit', 1); | How many multi-unit properties are there in each city? | SELECT CityName, COUNT(*) FROM Properties p JOIN Cities c ON p.CityID = c.CityID WHERE p.PropertyType = 'Multi-Unit' GROUP BY CityName; | gretelai_synthetic_text_to_sql |
CREATE TABLE student_mental_health (student_id INT, program VARCHAR(20), score INT); INSERT INTO student_mental_health (student_id, program, score) VALUES (1, 'remote_learning', 75), (2, 'remote_learning', 80), (3, 'in_person', 85), (4, 'in_person', 90); | What is the maximum mental health score for students in the 'remote_learning' program? | SELECT MAX(score) FROM student_mental_health WHERE program = 'remote_learning'; | gretelai_synthetic_text_to_sql |
CREATE TABLE policy (policy_id INT, policy_holder_id INT, policy_type VARCHAR(50), policy_start_date DATE); INSERT INTO policy (policy_id, policy_holder_id, policy_type, policy_start_date) VALUES (1, 10001, 'Commercial Auto', '2015-01-01'); INSERT INTO policy (policy_id, policy_holder_id, policy_type, policy_start_date... | Update the policy_type to 'Renters' for policy_id 1 in the policy table | UPDATE policy SET policy_type = 'Renters' WHERE policy_id = 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE ports (port_id INT, port_name TEXT, country TEXT); INSERT INTO ports VALUES (1, 'Port A', 'China'), (2, 'Port B', 'Japan'), (3, 'Port C', 'South Korea'); CREATE TABLE cargo (cargo_id INT, port_id INT, quantity INT); INSERT INTO cargo VALUES (1, 1, 500), (2, 1, 600), (3, 2, 700), (4, 3, 800); | What is the average quantity of containers handled per port, for ports located in Asia? | SELECT AVG(cargo.quantity) FROM cargo JOIN ports ON cargo.port_id = ports.port_id WHERE ports.country = 'Asia'; | gretelai_synthetic_text_to_sql |
CREATE TABLE vessels (id INT, name VARCHAR(255), type VARCHAR(255)); CREATE TABLE safety_inspections (id INT, vessel_id INT, inspection_date DATE, result VARCHAR(255)); | Update the safety record of 'Seafarer' by adding a new safety inspection with a 'Pass' result on 2022-11-15. | INSERT INTO safety_inspections (id, vessel_id, inspection_date, result) SELECT nextval('safety_inspections_id_seq'::regclass), v.id, '2022-11-15', 'Pass' FROM vessels v WHERE name = 'Seafarer'; | gretelai_synthetic_text_to_sql |
CREATE VIEW budget_data AS SELECT category, allocated_budget FROM budget_table WHERE year = 2021; CREATE TABLE budget_table (year INT, category VARCHAR(50), allocated_budget FLOAT); INSERT INTO budget_table (year, category, allocated_budget) VALUES (2021, 'Cybersecurity', 20000000), (2021, 'Intelligence Operations', 30... | What is the total budget allocated for cybersecurity and intelligence operations in the 'budget_data' view for the year 2021? | SELECT SUM(allocated_budget) FROM budget_data WHERE category IN ('Cybersecurity', 'Intelligence Operations'); | gretelai_synthetic_text_to_sql |
CREATE TABLE districts (id INT, name VARCHAR(255)); CREATE TABLE emergency_responses (id INT, district_id INT, type VARCHAR(255), response_time INT); INSERT INTO districts (id, name) VALUES (1, 'North'); INSERT INTO emergency_responses (id, district_id, type, response_time) VALUES (1, 1, 'Fire', 12); | What is the maximum response time for fire incidents in the 'North' district? | SELECT MAX(response_time) FROM emergency_responses WHERE district_id = (SELECT id FROM districts WHERE name = 'North') AND type = 'Fire'; | gretelai_synthetic_text_to_sql |
CREATE TABLE community_centers (id INT, name VARCHAR(255)); INSERT INTO community_centers (id, name) VALUES (1, 'Community Center A'), (2, 'Community Center B'); CREATE TABLE treatments (id INT, community_center_id INT, patient_id INT, type VARCHAR(255)); INSERT INTO treatments (id, community_center_id, patient_id, typ... | Identify the average age of patients who received group sessions in Community Center A. | SELECT AVG(p.age) FROM patients p JOIN treatments t ON p.id = t.patient_id WHERE t.type = 'group session' AND t.community_center_id = 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE Donations (DonationID INT, DonorID INT, Amount DECIMAL(10,2), Year INT); INSERT INTO Donations (DonationID, DonorID, Amount, Year) VALUES (1, 1, 500.00, 2020), (2, 1, 600.00, 2021), (3, 2, 300.00, 2020); | What is the average donation amount from returning donors who increased their donation in 2021 compared to 2020? | SELECT AVG(Amount) FROM Donations WHERE DonorID IN (SELECT DonorID FROM Donations WHERE Year = 2020 GROUP BY DonorID HAVING AVG(Amount) < (SELECT AVG(Amount) FROM Donations WHERE DonorID = Donations.DonorID AND Year = 2021 GROUP BY DonorID)); | gretelai_synthetic_text_to_sql |
CREATE TABLE patients (id INT, name VARCHAR(50), age INT, ethnicity VARCHAR(50)); INSERT INTO patients (id, name, age, ethnicity) VALUES (1, 'John Doe', 45, 'Caucasian'), (2, 'Jane Smith', 35, 'African American'), (3, 'Alice Johnson', 50, 'Hispanic'); | What is the average age of patients by ethnicity? | SELECT ethnicity, AVG(age) FROM patients GROUP BY ethnicity; | gretelai_synthetic_text_to_sql |
CREATE TABLE FundingSources (FundingSourceID INT PRIMARY KEY, Name VARCHAR(100), Amount FLOAT, Date DATE); | Create a table for storing information about funding sources | CREATE TABLE FundingSources (FundingSourceID INT PRIMARY KEY, Name VARCHAR(100), Amount FLOAT, Date DATE); | gretelai_synthetic_text_to_sql |
CREATE TABLE assets (client_id INT, assets_value FLOAT, assets_date DATE); INSERT INTO assets (client_id, assets_value, assets_date) VALUES (1, 150000.00, '2022-01-01'), (1, 160000.00, '2022-04-01'), (2, 220000.00, '2022-01-01'), (2, 230000.00, '2022-04-01'); | What is the total assets value per client as of the last day of each quarter? | SELECT client_id, SUM(assets_value) as total_assets_value FROM assets WHERE assets_date IN (SELECT LAST_DAY(date_add(DATE(assets_date), INTERVAL (quarter(assets_date) - 1) * 3 MONTH)) as last_day_of_quarter FROM assets GROUP BY client_id) GROUP BY client_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE households (id INT, state TEXT, income INT); INSERT INTO households (id, state, income) VALUES (1, 'California', 75000), (2, 'California', 120000), (3, 'California', 50000); | What is the percentage of households in the state of California with an income greater than $100,000? | SELECT 100.0 * COUNT(*) / (SELECT COUNT(*) FROM households WHERE state = 'California') as pct_households FROM households WHERE state = 'California' AND income > 100000; | gretelai_synthetic_text_to_sql |
CREATE TABLE impact_investments (id INT, region VARCHAR(20), investment_year INT, investment_amount FLOAT); INSERT INTO impact_investments (id, region, investment_year, investment_amount) VALUES (1, 'Asia', 2020, 150000), (2, 'Africa', 2019, 120000), (3, 'Asia', 2020, 180000); | What is the average investment amount for the year 2019? | SELECT AVG(investment_amount) FROM impact_investments WHERE investment_year = 2019; | gretelai_synthetic_text_to_sql |
CREATE TABLE donors (donor_id INT, donor_name TEXT, donor_country TEXT); INSERT INTO donors (donor_id, donor_name, donor_country) VALUES (1, 'John Doe', 'Colombia'), (2, 'Jane Smith', 'USA'), (3, 'Alice Johnson', 'Canada'), (4, 'Carlos Alvarez', 'Argentina'), (5, 'Elizabeth Brown', 'UK'); CREATE TABLE donations (donati... | How many donors from Colombia and Argentina combined have made donations in the past month? | SELECT COUNT(DISTINCT donor_country) as total_donors FROM donors d JOIN donations ON d.donor_id = donations.donor_id WHERE d.donor_country IN ('Colombia', 'Argentina') AND donations.donation_date >= DATEADD(month, -1, CURRENT_TIMESTAMP); | gretelai_synthetic_text_to_sql |
CREATE TABLE labor_force (mine_name VARCHAR(255), employee_count INT, country VARCHAR(255)); INSERT INTO labor_force (mine_name, employee_count, country) VALUES ('Diamond Dunes', 300, 'Canada'), ('Ruby Ridges', 260, 'Australia'); | Which mines have more than 250 employees and are located in Canada or Australia? | SELECT mine_name FROM labor_force WHERE employee_count > 250 AND (country = 'Canada' OR country = 'Australia'); | gretelai_synthetic_text_to_sql |
CREATE TABLE fans (id INT, name VARCHAR(50), country VARCHAR(50), last_game_date DATE); INSERT INTO fans (id, name, country, last_game_date) VALUES (1, 'Rajesh Patel', 'India', '2021-01-01'); INSERT INTO fans (id, name, country, last_game_date) VALUES (2, 'Priya Sharma', 'Pakistan', '2020-01-01'); | How many cricket fans are there who have attended a game in the last 2 years and are from India? | SELECT COUNT(*) FROM fans WHERE country = 'India' AND last_game_date >= DATEADD(year, -2, GETDATE()); | gretelai_synthetic_text_to_sql |
CREATE TABLE ai_ethics (id INT PRIMARY KEY, region VARCHAR(50), initiative VARCHAR(100)); INSERT INTO ai_ethics (id, region, initiative) VALUES (1, 'North America', 'Ethical AI education program for schools'), (2, 'Europe', 'Ethical AI research center'); | Add a new initiative 'Ethical AI for small businesses' to the 'ai_ethics' table | INSERT INTO ai_ethics (id, region, initiative) VALUES (3, 'North America', 'Ethical AI for small businesses'); | gretelai_synthetic_text_to_sql |
CREATE TABLE salaries (id INT, name VARCHAR(50), department VARCHAR(50), salary INT); INSERT INTO salaries (id, name, department, salary) VALUES (1, 'John Doe', 'manufacturing', 45000); INSERT INTO salaries (id, name, department, salary) VALUES (2, 'Jane Smith', 'engineering', 60000); | What is the minimum salary of employees in the 'manufacturing' or 'engineering' department? | SELECT MIN(salary) FROM salaries WHERE department IN ('manufacturing', 'engineering'); | gretelai_synthetic_text_to_sql |
CREATE TABLE IncidentResponse (region VARCHAR(50), incidentDate DATE); INSERT INTO IncidentResponse (region, incidentDate) VALUES ('EMEA', '2022-01-05'), ('APAC', '2022-01-12'), ('AMER', '2022-01-20'); | What is the distribution of incident dates in the IncidentResponse table by month? | SELECT YEAR(incidentDate), MONTH(incidentDate), COUNT(*) FROM IncidentResponse GROUP BY YEAR(incidentDate), MONTH(incidentDate); | gretelai_synthetic_text_to_sql |
CREATE TABLE MarineLife (ID INT, Species VARCHAR(255), Population INT, Location VARCHAR(255)); INSERT INTO MarineLife (ID, Species, Population, Location) VALUES (2, 'Dolphin', 2000, 'Indian Ocean'); | What is the population of dolphins in the Indian Ocean? | SELECT Population FROM MarineLife WHERE Species = 'Dolphin' AND Location = 'Indian Ocean'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Companies (id INT, name VARCHAR(255), region VARCHAR(255)); INSERT INTO Companies (id, name, region) VALUES (1, 'CompanyA', 'Asia-Pacific'), (2, 'CompanyB', 'Europe'), (3, 'CompanyC', 'Asia-Pacific'); CREATE TABLE Materials (id INT, company_id INT, material VARCHAR(255), quantity INT); INSERT INTO Material... | What is the total quantity of sustainable materials used by companies located in the Asia-Pacific region? | SELECT SUM(quantity) FROM Companies JOIN Materials ON Companies.id = Materials.company_id WHERE region = 'Asia-Pacific' AND material IN ('Organic cotton', 'Recycled polyester', 'Tencel'); | gretelai_synthetic_text_to_sql |
CREATE TABLE Employee (Employee_ID INT, Employee_Name VARCHAR(50), Department VARCHAR(50), Country VARCHAR(50), Annual_Salary DECIMAL(10,2)); INSERT INTO Employee (Employee_ID, Employee_Name, Department, Country, Annual_Salary) VALUES (1, 'John Smith', 'IT', 'USA', 80000.00), (2, 'Jane Doe', 'HR', 'Canada', 85000.00), ... | What is the average annual salary for employees in the 'Finance' department? | SELECT AVG(Annual_Salary) FROM Employee WHERE Department = 'Finance'; | gretelai_synthetic_text_to_sql |
CREATE TABLE shariah_compliant_finance_incomes_africa (id INT, country VARCHAR(255), income DECIMAL(10,2)); INSERT INTO shariah_compliant_finance_incomes_africa (id, country, income) VALUES (1, 'South Africa', 25000.00), (2, 'Egypt', 35000.00), (3, 'Nigeria', 28000.00); | What is the total Shariah-compliant finance income in Africa? | SELECT SUM(income) FROM shariah_compliant_finance_incomes_africa WHERE country IN ('South Africa', 'Egypt', 'Nigeria'); | gretelai_synthetic_text_to_sql |
CREATE TABLE missions (id INT, name TEXT, country TEXT, launch_date DATE, cost FLOAT); INSERT INTO missions (id, name, country, launch_date, cost) VALUES (1, 'Ariane 5', 'Europe', '2002-12-15', 145000000), (2, 'Vega', 'Europe', '2012-02-13', 29000000); | What is the maximum cost of a space mission by ESA? | SELECT MAX(cost) FROM missions WHERE country = 'Europe'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Production (ProductionID INT, Material VARCHAR(20), Quantity INT, Country VARCHAR(20)); INSERT INTO Production VALUES (1, 'Recycled Plastic', 500, 'US'); INSERT INTO Production VALUES (2, 'Recycled Metal', 300, 'US'); | What is the total quantity of recycled materials used in production in the US? | SELECT SUM(Quantity) FROM Production WHERE Material LIKE '%Recycled%' AND Country = 'US'; | gretelai_synthetic_text_to_sql |
CREATE TABLE vessels (id INT, type VARCHAR(255)); CREATE TABLE cargo (id INT, vessel_id INT, weight INT, timestamp TIMESTAMP); INSERT INTO vessels VALUES (1, 'Tanker'), (2, 'Cargo Ship'); INSERT INTO cargo VALUES (1, 1, 10000, '2021-01-01 10:00:00'), (2, 1, 12000, '2021-01-15 12:00:00'), (3, 2, 15000, '2021-01-03 08:00... | What is the total cargo weight for each vessel type in the last year? | SELECT v.type, SUM(c.weight) as total_weight FROM vessels v JOIN cargo c ON v.id = c.vessel_id WHERE c.timestamp >= DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 1 YEAR) GROUP BY v.type; | gretelai_synthetic_text_to_sql |
CREATE TABLE YttriumMarket(year INT, trend VARCHAR(50)); INSERT INTO YttriumMarket(year, trend) VALUES (2017, 'Increase'), (2017, 'Steady demand'), (2018, 'Price decrease'), (2018, 'Decreasing demand'); | List the Yttrium market trends for 2017 and 2018. | SELECT year, trend FROM YttriumMarket WHERE year IN (2017, 2018); | gretelai_synthetic_text_to_sql |
CREATE TABLE Artworks (ArtworkID int, Name varchar(50), ArtistID int); CREATE TABLE Artists (ArtistID int, Name varchar(50), BirthYear int, DeathYear int); INSERT INTO Artworks (ArtworkID, Name, ArtistID) VALUES (1, 'Mona Lisa', 1), (2, 'The Starry Night', 2), (3, 'The Persistence of Memory', 3); INSERT INTO Artists (A... | What is the total number of artworks and total number of artists in the database? | SELECT COUNT(DISTINCT A.ArtworkID) AS TotalArtworks, COUNT(DISTINCT AR.ArtistID) AS TotalArtists FROM Artworks A JOIN Artists AR ON A.ArtistID = AR.ArtistID; | gretelai_synthetic_text_to_sql |
CREATE TABLE vessels (vessel_id INT, name VARCHAR(100)); INSERT INTO vessels (vessel_id, name) VALUES (1, 'Sea Serpent'); INSERT INTO vessels (vessel_id, name) VALUES (2, 'Ocean Wave'); INSERT INTO maritime_accidents (accident_id, vessel_id, country) VALUES (1, 1, 'Canada'); | What are the names of vessels that have not been involved in any accidents? | SELECT name FROM vessels WHERE vessel_id NOT IN (SELECT vessel_id FROM maritime_accidents); | gretelai_synthetic_text_to_sql |
CREATE TABLE eco_accommodations (id INT, country VARCHAR(255), type VARCHAR(255)); INSERT INTO eco_accommodations (id, country, type) VALUES (1, 'France', 'Eco Lodge'), (2, 'Germany', 'Green Hotel'), (3, 'Italy', 'Eco Hotel'); | How many eco-friendly accommodations are there in each country? | SELECT country, COUNT(*) FROM eco_accommodations GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE offenders (id INT, age INT, community_service_hours INT, community_service_date DATE); | What is the total number of hours of community service performed, by offender's age, in the past year? | SELECT age, SUM(community_service_hours) FROM offenders WHERE community_service_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR) GROUP BY age; | gretelai_synthetic_text_to_sql |
CREATE TABLE fifa_world_cup (id INT, team VARCHAR(50), year INT, points INT); INSERT INTO fifa_world_cup (id, team, year, points) VALUES (1, 'Brazil', 2022, 12), (2, 'Germany', 2022, 14); | What is the total number of points scored by each team in the FIFA World Cup? | SELECT team, SUM(points) FROM fifa_world_cup GROUP BY team ORDER BY SUM(points) DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE FishCaught (species VARCHAR(50), ocean VARCHAR(50), quantity INT); INSERT INTO FishCaught (species, ocean, quantity) VALUES ('Tuna', 'Indian Ocean', 500), ('Salmon', 'Indian Ocean', 400), ('Cod', 'Indian Ocean', 300), ('Sardines', 'Indian Ocean', 600); | What is the maximum quantity of fish caught per species in the Indian Ocean? | SELECT species, MAX(quantity) as max_quantity FROM FishCaught WHERE ocean = 'Indian Ocean' GROUP BY species; | gretelai_synthetic_text_to_sql |
CREATE TABLE chemicals (id INT, name VARCHAR(255), weight FLOAT, manufacturer_country VARCHAR(255), category VARCHAR(255), production_date DATE); | Calculate the average weight of chemical substances in the category 'agrochemicals' manufactured in Spain in the last 9 months. | SELECT category, AVG(weight) as avg_weight FROM chemicals WHERE manufacturer_country = 'Spain' AND category = 'agrochemicals' AND production_date > DATE_SUB(CURDATE(), INTERVAL 9 MONTH) GROUP BY category; | gretelai_synthetic_text_to_sql |
CREATE TABLE archaeologists (id INT, name VARCHAR(50), age INT, gender VARCHAR(10), country VARCHAR(50)); CREATE TABLE artifact_analysis (id INT, archaeologist_id INT, artifact_id INT, analysis_date DATE); | Get the number of artifacts analyzed by each archaeologist in the 'artifact_analysis' table. | SELECT archaeologist_id, COUNT(artifact_id) FROM artifact_analysis GROUP BY archaeologist_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE customers (customer_id INT, name TEXT, dispensary_id INT); INSERT INTO customers (customer_id, name, dispensary_id) VALUES (1, 'Customer A', 1), (2, 'Customer B', 1), (3, 'Customer C', 2); | What is the total number of unique customers who have made a purchase in each dispensary in California, grouped by dispensary? | SELECT d.name, COUNT(DISTINCT c.customer_id) AS unique_customers FROM dispensaries d JOIN customers c ON d.dispensary_id = c.dispensary_id WHERE d.state = 'California' GROUP BY d.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE MonthlyDonations (DonorID INT, DonationDate DATE); INSERT INTO MonthlyDonations (DonorID, DonationDate) VALUES (1, '2021-01-12'), (2, '2021-01-25'), (3, '2021-02-03'), (1, '2021-03-14'), (4, '2021-03-28'); | What was the average donation amount and total number of donors for each month in 2021? | SELECT EXTRACT(MONTH FROM DonationDate) AS Month, AVG(DonationAmount) AS AverageDonation, COUNT(DISTINCT DonorID) AS TotalDonors FROM Donations GROUP BY Month ORDER BY Month; | gretelai_synthetic_text_to_sql |
CREATE TABLE healthcare_workers (id INT, name TEXT, age INT, position TEXT, hospital_id INT); CREATE TABLE rural_hospitals (id INT, name TEXT, location TEXT, state TEXT); INSERT INTO rural_hospitals (id, name, location, state) VALUES (3, 'Hospital C', 'Rural Area 3', 'New York'); | Update the hospital location of a rural healthcare worker in the "healthcare_workers" table. | UPDATE healthcare_workers SET hospital_id = 3 WHERE id = 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE inventory (product_id INT, product_name VARCHAR(255), quantity INT, price DECIMAL(10,2)); INSERT INTO inventory (product_id, product_name, quantity, price) VALUES (1, 'Product X', 100, 50.00), (2, 'Product Y', 50, 75.00), (3, 'Product Z', 200, 25.00); | Which products have the highest and lowest inventory levels, and what are their prices? | SELECT product_name, quantity, price, NTILE(2) OVER (ORDER BY quantity DESC) as tier FROM inventory; | gretelai_synthetic_text_to_sql |
CREATE TABLE infrastructure_projects(id INT, region TEXT, project_name TEXT, status TEXT); | Insert a new rural infrastructure project in the 'Nairobi' region with ID 5, name 'Solar Powered Irrigation', and status 'completed' into the 'infrastructure_projects' table. | INSERT INTO infrastructure_projects (id, region, project_name, status) VALUES (5, 'Nairobi', 'Solar Powered Irrigation', 'completed'); | gretelai_synthetic_text_to_sql |
CREATE TABLE satellite_images (id INT, project VARCHAR(255), date DATE, time TIME, resolution INT); INSERT INTO satellite_images (id, project, date, time, resolution) VALUES (1, 'Precision Farming', '2022-01-01', '12:00:00', 10), (2, 'Precision Farming', '2022-01-02', '12:00:00', 15), (3, 'Autonomous Tractors', '2022-0... | List all the satellite images and their metadata for the 'Precision Farming' project in the precision_farming database. | SELECT * FROM satellite_images WHERE project = 'Precision Farming'; | gretelai_synthetic_text_to_sql |
CREATE TABLE products (product_id INT, supplier_id INT, ethical_rating INT); CREATE TABLE suppliers (supplier_id INT, supplier_name VARCHAR(50), ethical_rating INT); INSERT INTO products (product_id, supplier_id, ethical_rating) VALUES (1, 101, 9), (2, 102, 5), (3, 103, 8); INSERT INTO suppliers (supplier_id, supplier_... | Remove products that have an ethical rating lower than 7 | DELETE FROM products WHERE ethical_rating < 7; | gretelai_synthetic_text_to_sql |
CREATE TABLE legal_aid_denials (id INT, denial_reason TEXT, race TEXT, application_date DATE); | How many legal aid applications were denied in the past month, broken down by the reason for denial and the applicant's race? | SELECT race, denial_reason, COUNT(*) FROM legal_aid_denials WHERE application_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) GROUP BY race, denial_reason; | gretelai_synthetic_text_to_sql |
CREATE TABLE security_incidents (id INT, incident_date DATE, threat_type VARCHAR(50), resolution_date DATE); INSERT INTO security_incidents (id, incident_date, threat_type, resolution_date) VALUES (1, '2022-01-01', 'Malware', '2022-01-05'), (2, '2022-01-05', 'Phishing', '2022-01-12'), (3, '2022-01-10', 'Ransomware', '2... | What are the average number of days to resolve incidents for each threat type? | SELECT threat_type, AVG(DATEDIFF(day, incident_date, resolution_date)) as avg_days_to_resolve FROM security_incidents GROUP BY threat_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE defense_contracts(id INT, company VARCHAR(50), amount INT, award_date DATE, state VARCHAR(20)); | Show the defense contracts awarded to companies in California and Texas with amounts over $1,000,000, and their respective award dates. | SELECT company, amount, award_date FROM defense_contracts WHERE state IN ('California', 'Texas') AND amount > 1000000; | gretelai_synthetic_text_to_sql |
CREATE TABLE Members (MemberID INT, Age INT, Gender VARCHAR(10), MembershipType VARCHAR(20)); INSERT INTO Members (MemberID, Age, Gender, MembershipType) VALUES (1, 35, 'Female', 'Basic'), (2, 45, 'Male', 'Elite'), (3, 28, 'Female', 'Premium'), (4, 32, 'Male', 'Basic'), (5, 48, 'Female', 'Elite'); CREATE TABLE ClassAtt... | How many members have a 'Basic' membership type and have attended a class in the past week? | SELECT COUNT(*) FROM Members JOIN ClassAttendance ON Members.MemberID = ClassAttendance.MemberID WHERE Members.MembershipType = 'Basic' AND ClassAttendance.Date >= DATEADD(week, -1, GETDATE()); | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_trenches (ocean TEXT, trench TEXT, max_depth INTEGER);INSERT INTO marine_trenches (ocean, trench, max_depth) VALUES ('Pacific', 'Mariana Trench', 10994), ('Indian', 'Galathea Trench', 8020); | What is the maximum depth of the Galathea Trench in the Indian Ocean? | SELECT ocean, trench, max_depth FROM marine_trenches WHERE ocean = 'Indian' AND trench = 'Galathea Trench' AND max_depth = (SELECT MAX(max_depth) FROM marine_trenches WHERE ocean = 'Indian'); | gretelai_synthetic_text_to_sql |
CREATE TABLE satellite_images (image_id TEXT, farm_id TEXT, date DATE); | List all the satellite images taken over a specific farm in the past month. | SELECT image_id FROM satellite_images WHERE farm_id = 'farm123' AND date >= DATEADD(day, -30, GETDATE()); | gretelai_synthetic_text_to_sql |
CREATE TABLE Carbon_Offset_Programs (program_id INT, program_name VARCHAR(100), country VARCHAR(100), co2_reduction_tonnes FLOAT); | What is the average CO2 emissions reduction (in tonnes) achieved by carbon offset programs implemented in Germany? | SELECT AVG(co2_reduction_tonnes) FROM Carbon_Offset_Programs WHERE country = 'Germany'; | gretelai_synthetic_text_to_sql |
CREATE TABLE berthing (id INT, vessel_type VARCHAR(255), berthing_time INT); INSERT INTO berthing VALUES (1, 'container', 120), (2, 'bulk', 150), (3, 'tanker', 200); | What is the maximum berthing time for each vessel type? | SELECT vessel_type, MAX(berthing_time) as max_berthing_time FROM berthing GROUP BY vessel_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE savings (id INT, amount FLOAT, year INT); INSERT INTO savings (id, amount, year) VALUES (1, 1000, 2020), (2, 1500, 2019), (3, 2000, 2018); | What is the total amount of water saved through conservation initiatives in the year 2020? | SELECT SUM(amount) FROM savings WHERE year = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE companies (id INT, name TEXT, sector TEXT, ESG_rating FLOAT); INSERT INTO companies (id, name, sector, ESG_rating) VALUES (1, 'Pfizer', 'Healthcare', 8.5), (2, 'Johnson & Johnson', 'Healthcare', 7.9), (3, 'Medtronic', 'Healthcare', 8.3), (4, 'Abbott', 'Healthcare', 7.7); | How many companies in the healthcare sector have an ESG rating above 8.0? | SELECT COUNT(*) FROM companies WHERE sector = 'Healthcare' AND ESG_rating > 8.0; | gretelai_synthetic_text_to_sql |
CREATE TABLE public.daily_trips (id SERIAL PRIMARY KEY, vehicle_type TEXT, city TEXT, trips_per_day DECIMAL(10,2)); INSERT INTO public.daily_trips (vehicle_type, city, trips_per_day) VALUES ('autonomous_bus', 'Tokyo', 250.50), ('autonomous_bus', 'Tokyo', 275.25), ('autonomous_bus', 'Sydney', 300.00); | What is the average number of trips per day for autonomous buses in Tokyo? | SELECT AVG(trips_per_day) FROM public.daily_trips WHERE vehicle_type = 'autonomous_bus' AND city = 'Tokyo'; | gretelai_synthetic_text_to_sql |
CREATE TABLE country_incidents (incident_id INT, country_name VARCHAR(255), incident_count INT); INSERT INTO country_incidents (incident_id, country_name, incident_count) VALUES (1, 'United States', 250), (2, 'United Kingdom', 120), (3, 'Canada', 80), (4, 'Australia', 60), (5, 'Germany', 50); | What are the top 3 countries with the highest number of security incidents in the past year, and their respective percentages of the total incidents? | SELECT country_name, incident_count, ROUND(incident_count / SUM(incident_count) OVER(), 2) * 100 as incident_percentage FROM country_incidents ORDER BY incident_count DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE reclamation_expenses (miner_name VARCHAR(50), country VARCHAR(50), reclamation_costs DECIMAL(10,2), year INT, PRIMARY KEY (miner_name, year));INSERT INTO reclamation_expenses (miner_name, country, reclamation_costs, year) VALUES ('Emma White', 'Germany', 120000.00, 2020), ('Oliver Black', 'France', 180000.... | What is the reclamation cost for the miner with the most workers in Europe? | SELECT context.miner_name, sql.reclamation_costs FROM reclamation_expenses sql JOIN (SELECT miner_name, worker_count, worker_rank FROM labor_force, miner_year_worker_count WHERE labor_force.miner_name = miner_year_worker_count.miner_name AND worker_rank = 1 AND country = 'Europe') context ON sql.miner_name = context.mi... | gretelai_synthetic_text_to_sql |
CREATE TABLE warehouses (id INT, pallets INT, storage_date DATE); INSERT INTO warehouses (id, pallets, storage_date) VALUES (1, 200, '2022-01-01'), (2, 300, '2022-02-01'), (3, 150, '2022-01-15'); | What is the total number of pallets stored in each warehouse, broken down by the month and year of storage? | SELECT YEAR(storage_date) as storage_year, MONTH(storage_date) as storage_month, SUM(pallets) as total_pallets FROM warehouses GROUP BY YEAR(storage_date), MONTH(storage_date); | gretelai_synthetic_text_to_sql |
CREATE TABLE intelligence_operations (id INT, operation_name VARCHAR(255), location VARCHAR(255), start_date DATE, end_date DATE); INSERT INTO intelligence_operations (id, operation_name, location, start_date, end_date) VALUES (1, 'Operation Red Sands', 'Middle East', '2018-01-01', '2018-12-31'), (2, 'Operation Silent ... | What intelligence operations were conducted in the Middle East since 2018? | SELECT DISTINCT operation_name, location FROM intelligence_operations WHERE location = 'Middle East' AND (start_date IS NULL OR start_date <= CURDATE()) AND (end_date IS NULL OR end_date >= CURDATE()); | gretelai_synthetic_text_to_sql |
CREATE TABLE news_stories (id INT, headline VARCHAR(255), article_text TEXT, word_count INT); | Identify the average word count for articles in the 'news_stories' table, and display the result rounded to the nearest integer. | SELECT ROUND(AVG(word_count)) FROM news_stories; | gretelai_synthetic_text_to_sql |
CREATE TABLE players (player_id INT, name VARCHAR(30), age INT, gender VARCHAR(10), country VARCHAR(30), registration_date DATE, platform VARCHAR(20)); | How many players registered from Asia play on PlayStation consoles? | SELECT COUNT(*) FROM players WHERE country LIKE 'Asia%' AND platform = 'PlayStation'; | gretelai_synthetic_text_to_sql |
CREATE TABLE videos (title VARCHAR(255), host VARCHAR(255), date DATE, language VARCHAR(255), views INT); | How many rows in the videos table have a language other than 'English'? | SELECT COUNT(*) FROM videos WHERE language <> 'English'; | gretelai_synthetic_text_to_sql |
CREATE TABLE route (route_id INT, route_name VARCHAR(50)); INSERT INTO route (route_id, route_name) VALUES (1, 'Red Line'), (2, 'Green Line'), (3, 'Blue Line'), (4, 'Yellow Line'); CREATE TABLE maintenance (maintenance_id INT, route_id INT, maintenance_date DATE); INSERT INTO maintenance (maintenance_id, route_id, main... | What is the earliest vehicle maintenance date for 'Blue Line'? | SELECT MIN(maintenance_date) FROM maintenance WHERE route_id = 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE washington_agencies (name TEXT, budget INTEGER); INSERT INTO washington_agencies (name, budget) VALUES ('Department of Defense', 693000000000), ('Department of Health and Human Services', 134000000000), ('Department of Veterans Affairs', 243000000000); | What is the combined budget of the top 3 agencies in Washington DC? | SELECT SUM(budget) FROM (SELECT budget FROM washington_agencies ORDER BY budget DESC LIMIT 3) AS top_three; | gretelai_synthetic_text_to_sql |
CREATE TABLE worker_departments (id INT, worker_name VARCHAR(255), department VARCHAR(255), country VARCHAR(255)); INSERT INTO worker_departments (id, worker_name, department, country) VALUES (1, 'John Doe', 'renewable energy', 'China'), (2, 'Jane Smith', 'textiles', 'USA'), (3, 'Michael Brown', 'renewable energy', 'Ch... | How many workers are employed in the 'renewable energy' sector in China? | SELECT COUNT(*) FROM worker_departments WHERE department = 'renewable energy' AND country = 'China'; | gretelai_synthetic_text_to_sql |
CREATE TABLE ExcavationSite (SiteID INT, SiteName VARCHAR(50), Continent VARCHAR(50)); INSERT INTO ExcavationSite (SiteID, SiteName, Continent) VALUES (1, 'Site A', 'Africa'), (2, 'Site B', 'Asia'), (3, 'Site C', 'Europe'); CREATE TABLE Artifact (ArtifactID INT, SiteID INT, Weight FLOAT, ObjectType VARCHAR(50)); INSERT... | Create a new table named 'Culture' with columns 'CultureID', 'CultureName', and 'Region'. | CREATE TABLE Culture (CultureID INT, CultureName VARCHAR(50), Region VARCHAR(50)); | gretelai_synthetic_text_to_sql |
CREATE TABLE teachers (teacher_id INT, subject_area VARCHAR(255)); INSERT INTO teachers (teacher_id, subject_area) VALUES (1, 'Math'), (2, 'English'), (3, 'Science'), (4, 'History'), (5, 'Technology'), (6, 'Engineering'); CREATE TABLE courses (course_id INT, course_name VARCHAR(255), subject_area VARCHAR(255)); INSERT ... | How many teachers have completed professional development courses in STEM subjects? | SELECT COUNT(DISTINCT t.teacher_id) as num_teachers FROM teachers t JOIN completions c ON t.teacher_id = c.teacher_id JOIN courses co ON c.course_id = co.course_id WHERE co.subject_area IN ('Math', 'Science', 'Technology', 'Engineering'); | gretelai_synthetic_text_to_sql |
CREATE TABLE grower_inventory (id INT, grower VARCHAR(255), product VARCHAR(255), price FLOAT, gram_weight FLOAT); INSERT INTO grower_inventory (id, grower, product, price, gram_weight) VALUES (1, 'Grower H', 'Flower', 12.0, 3.5); | What is the minimum price per gram of flower sold by Grower H in Q3 2022? | SELECT MIN(price / gram_weight) FROM grower_inventory WHERE grower = 'Grower H' AND product = 'Flower' AND QUARTER(sale_date) = 3 AND YEAR(sale_date) = 2022; | gretelai_synthetic_text_to_sql |
CREATE TABLE designer (id INT PRIMARY KEY, name VARCHAR(255), country_origin VARCHAR(255)); CREATE TABLE designer_garments (id INT PRIMARY KEY, designer_id INT, garment_id INT, FOREIGN KEY (designer_id) REFERENCES designer(id)); | Update the country_origin column of the designer table to 'Mexico' for designers who have created garments made of linen. | UPDATE designer SET country_origin = 'Mexico' WHERE designer.id IN (SELECT designer_id FROM designer_garments WHERE garment_id IN (SELECT id FROM garment_production WHERE fabric_type = 'Linen')); | gretelai_synthetic_text_to_sql |
CREATE TABLE mobile_subscribers (subscriber_id INT, data_usage FLOAT, community_representation VARCHAR(30)); INSERT INTO mobile_subscribers (subscriber_id, data_usage, community_representation) VALUES (1, 30.5, 'Latinx'), (2, 40.3, 'Black/African American'), (3, 50.2, 'Native American'), (4, 60.1, 'Asian'), (5, 35.6, '... | Update the community representation for subscriber 5 to 'Native Hawaiian or Other Pacific Islander'. | UPDATE mobile_subscribers SET community_representation = 'Native Hawaiian or Other Pacific Islander' WHERE subscriber_id = 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE UnionMembership (id INT, sector VARCHAR(255), membership DECIMAL(5,2)); INSERT INTO UnionMembership (id, sector, membership) VALUES (1, 'Finance', 0.10); | What is the Union membership rate in the Finance sector? | SELECT membership FROM UnionMembership WHERE sector = 'Finance'; | gretelai_synthetic_text_to_sql |
CREATE TABLE RegulatoryFrameworks (framework_id INT, framework_name TEXT, implementation_year INT); INSERT INTO RegulatoryFrameworks (framework_id, framework_name, implementation_year) VALUES (1, 'Framework1', 2020), (2, 'Framework2', 2021), (3, 'Framework3', 2022); | List all regulatory frameworks in the blockchain domain that were implemented in 2022. | SELECT framework_name FROM RegulatoryFrameworks WHERE implementation_year = 2022; | gretelai_synthetic_text_to_sql |
CREATE TABLE Clients (ClientID INT, Name VARCHAR(50), Category VARCHAR(50), BillingAmount DECIMAL(10,2)); INSERT INTO Clients (ClientID, Name, Category, BillingAmount) VALUES (1, 'John Doe', 'Personal Injury', 5000.00), (2, 'Jane Smith', 'Personal Injury', 3000.00); | What is the name of the client with the highest billing amount in the 'Personal Injury' category? | SELECT Name FROM Clients WHERE Category = 'Personal Injury' AND BillingAmount = (SELECT MAX(BillingAmount) FROM Clients WHERE Category = 'Personal Injury'); | gretelai_synthetic_text_to_sql |
CREATE TABLE artists (id INT, name VARCHAR(255), age INT, country VARCHAR(255)); INSERT INTO artists (id, name, age, country) VALUES (1, 'Bruce Springsteen', 72, 'United States'), (2, 'Beyoncé', 40, 'United States'); CREATE TABLE streams (song VARCHAR(255), artist VARCHAR(255), location VARCHAR(255), streams INT); INSE... | What is the average age of artists who had the most streams in their respective countries? | SELECT AVG(age) FROM artists a JOIN (SELECT artist, MAX(streams) as max_streams FROM streams GROUP BY artist) b ON a.name = b.artist; | gretelai_synthetic_text_to_sql |
CREATE TABLE hotels (hotel_id INT, hotel_name TEXT, city TEXT, country TEXT, energy_consumption FLOAT, year INT); INSERT INTO hotels (hotel_id, hotel_name, city, country, energy_consumption, year) VALUES (1, 'Hotel A', 'Rome', 'Italy', 12000.0, 2021), (1, 'Hotel A', 'Rome', 'Italy', 13000.0, 2022); | Identify the hotels with a year-over-year increase in energy consumption. | SELECT hotel_name, energy_consumption FROM (SELECT hotel_name, energy_consumption, energy_consumption - LAG(energy_consumption) OVER (PARTITION BY hotel_name ORDER BY year) as diff FROM hotels) where diff > 0; | gretelai_synthetic_text_to_sql |
CREATE TABLE vehicle_sales (sale_id INT, vehicle_id INT, sale_date DATE, vehicle_type TEXT); | What is the total number of electric vehicles sold in Seoul last year? | SELECT COUNT(*) FROM vehicle_sales WHERE vehicle_type = 'electric' AND sale_date BETWEEN DATE_SUB(CURDATE(), INTERVAL 1 YEAR) AND DATE_SUB(CURDATE(), INTERVAL 1 DAY); | gretelai_synthetic_text_to_sql |
CREATE TABLE sales_data (salesperson VARCHAR(50), sale_date DATE, quantity INT); INSERT INTO sales_data (salesperson, sale_date, quantity) VALUES ('John', '2021-01-01', 15), ('Jane', '2021-01-05', 20), ('John', '2021-01-07', 10); | What is the total quantity of garments sold by each salesperson, for each month, sorted by salesperson and then by month? | SELECT salesperson, DATE_TRUNC('month', sale_date) AS month, SUM(quantity) AS total_quantity FROM sales_data GROUP BY salesperson, month ORDER BY salesperson, month; | gretelai_synthetic_text_to_sql |
CREATE TABLE online_sales (sale_date DATE, revenue FLOAT); INSERT INTO online_sales (sale_date, revenue) VALUES ('2022-05-01', 5000.0), ('2022-05-02', 6000.0), ('2022-05-03', 7000.0); | What was the revenue from online sales in May 2022? | SELECT SUM(revenue) FROM online_sales WHERE sale_date BETWEEN '2022-05-01' AND '2022-05-31'; | gretelai_synthetic_text_to_sql |
CREATE TABLE public_transportation (vehicle_id INT, passengers INT, city VARCHAR(50)); | What is the maximum number of passengers on a public transportation vehicle in Paris? | SELECT MAX(passengers) FROM public_transportation WHERE city = 'Paris'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Certifications (restaurant TEXT, certification TEXT); INSERT INTO Certifications (restaurant, certification) VALUES ('Asian Fusion', 'Seafood Watch'), ('Asian Fusion', 'Fair Trade'), ('Bistro Bella Vita', 'Organic'), ('Taqueria Tsunami', 'Local Food Plus'), ('Asian Fusion', 'Local Food Plus'); | How many sustainable sourcing certifications does each restaurant have, grouped by certification type? | SELECT certification, COUNT(DISTINCT restaurant) FROM Certifications GROUP BY certification; | gretelai_synthetic_text_to_sql |
CREATE TABLE sales_q1_2022 (sale_date DATE, category VARCHAR(50), quantity INT, sales DECIMAL(10,2)); | What are the total sales and quantity of garments sold for each category in Q1 2022, grouped by week? | SELECT DATE_TRUNC('week', sale_date) AS week, category, SUM(quantity) AS total_quantity, SUM(sales) AS total_sales FROM sales_q1_2022 WHERE sale_date >= '2022-01-01' AND sale_date < '2022-04-01' GROUP BY week, category; | gretelai_synthetic_text_to_sql |
CREATE TABLE menu_sales_3 (item VARCHAR(255), sales INTEGER, sale_date DATE); INSERT INTO menu_sales_3 (item, sales, sale_date) VALUES ('Burger', 150, '2022-07-01'), ('Pizza', 200, '2022-07-02'), ('Sushi', 250, '2022-07-03'); | Which menu items had the most sales in the first week of July 2022? | SELECT item, SUM(sales) as total_sales FROM menu_sales_3 WHERE sale_date BETWEEN '2022-07-01' AND '2022-07-07' GROUP BY item ORDER BY total_sales DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE Projects (ProjectID INT, State CHAR(2), IsSustainable BOOLEAN); INSERT INTO Projects (ProjectID, State, IsSustainable) VALUES (1, 'CA', true), (2, 'NY', false), (3, 'TX', true), (4, 'CA', false), (5, 'CA', true); | What is the percentage of sustainable projects in California out of all projects in the state? | SELECT (COUNT(*) FILTER (WHERE Projects.IsSustainable = true) * 100.0 / COUNT(*)) AS SustainablePercentage FROM Projects WHERE Projects.State = 'CA'; | gretelai_synthetic_text_to_sql |
CREATE TABLE wildlife_habitats (id INT, name TEXT, region TEXT); INSERT INTO wildlife_habitats (id, name, region) VALUES (1, 'Habitat1', 'Coastal'), (2, 'Habitat2', 'Mountainous'); | How many wildlife habitats are there in the 'Mountainous' region? | SELECT COUNT(*) FROM wildlife_habitats WHERE region = 'Mountainous'; | gretelai_synthetic_text_to_sql |
CREATE TABLE brand_data (brand VARCHAR(255), year INT, revenue FLOAT, employees INT); INSERT INTO brand_data (brand, year, revenue, employees) VALUES ('Brand A', 2019, 20000, 100), ('Brand A', 2020, 25000, 120), ('Brand B', 2019, 18000, 80), ('Brand B', 2020, 23000, 100), ('Brand C', 2019, 16000, 60), ('Brand C', 2020,... | Which ethical fashion brands have the lowest revenue per employee? | SELECT brand, revenue/employees as revenue_per_employee FROM brand_data ORDER BY revenue_per_employee ASC; | gretelai_synthetic_text_to_sql |
CREATE TABLE company (id INT, name TEXT, country TEXT); INSERT INTO company (id, name, country) VALUES (1, 'Acme Inc', 'USA'), (2, 'Beta Corp', 'Canada'), (3, 'Gamma PLC', 'UK'); CREATE TABLE investment (investor_id INT, company_id INT); INSERT INTO investment (investor_id, company_id) VALUES (1, 1), (2, 1), (3, 2); | List unique investors who have invested in companies based in the US and Canada. | SELECT DISTINCT investor_id FROM investment WHERE company_id IN (SELECT id FROM company WHERE country IN ('USA', 'Canada')) | gretelai_synthetic_text_to_sql |
CREATE TABLE student_program_participation (student_id INT, program_name VARCHAR(50), semester VARCHAR(20)); | What is the percentage of students who participated in the 'Critical Thinking' program in the 'Spring 2022' semester? | SELECT (COUNT(student_id) * 100.0 / (SELECT COUNT(*) FROM student_program_participation WHERE semester = 'Spring 2022')) AS percentage FROM student_program_participation WHERE program_name = 'Critical Thinking' AND semester = 'Spring 2022'; | gretelai_synthetic_text_to_sql |
CREATE TABLE military_spending (country VARCHAR(50), year INT, amount FLOAT); INSERT INTO military_spending (country, year, amount) VALUES ('USA', 2017, 611000000), ('USA', 2018, 623000000), ('USA', 2019, 649000000), ('USA', 2020, 680000000), ('USA', 2021, 705000000), ('China', 2017, 215000000), ('China', 2018, 2190000... | Show military spending by each country in the last 5 years | SELECT country, year, amount FROM military_spending WHERE year >= (YEAR(CURDATE()) - 5); | gretelai_synthetic_text_to_sql |
CREATE TABLE publishers (id INT, name VARCHAR(50)); INSERT INTO publishers (id, name) VALUES (1, 'BBC News'); CREATE TABLE articles (id INT, title VARCHAR(50), publisher_id INT, publish_year INT); INSERT INTO articles (id, title, publisher_id, publish_year) VALUES (1, 'Article 1', 1, 2010), (2, 'Article 2', 1, 2015), (... | What is the total number of articles published per year by 'BBC News'? | SELECT publish_year, COUNT(*) as count FROM articles WHERE publisher_id = (SELECT id FROM publishers WHERE name = 'BBC News') GROUP BY publish_year ORDER BY publish_year; | gretelai_synthetic_text_to_sql |
CREATE TABLE recycling_rates(region TEXT, recycling_rate FLOAT); INSERT INTO recycling_rates(region, recycling_rate) VALUES('X', 0.65), ('Y', 0.73); | What is the recycling rate in region X and Y? | SELECT AVG(recycling_rate) FROM recycling_rates WHERE region IN ('X', 'Y'); | gretelai_synthetic_text_to_sql |
CREATE TABLE hospitals (id INT, name VARCHAR(100), state VARCHAR(20), public BOOLEAN); INSERT INTO hospitals (id, name, state, public) VALUES (1, 'Hospital 1', 'California', true); INSERT INTO hospitals (id, name, state, public) VALUES (2, 'Hospital 2', 'California', false); | What is the total number of public hospitals in each state of the USA? | SELECT state, COUNT(*) FROM hospitals WHERE public = true GROUP BY state; | gretelai_synthetic_text_to_sql |
CREATE TABLE waste_generation (city VARCHAR(50), generation_quantity INT, generation_date DATE); INSERT INTO waste_generation (city, generation_quantity, generation_date) VALUES ('Beijing', 3000, '2020-01-01'), ('Beijing', 3500, '2020-02-01'), ('Beijing', 4000, '2020-03-01'); | What is the total waste generation in Beijing in 2020? | SELECT SUM(generation_quantity) FROM waste_generation WHERE city = 'Beijing' AND generation_date >= '2020-01-01' AND generation_date <= '2020-12-31'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Meals (meal_id INT, meal_name TEXT); CREATE TABLE Suppliers (supplier_id INT, meal_id INT, supplier_name TEXT); | List all meals and their associated suppliers from the 'Meals' and 'Suppliers' tables. | SELECT Meals.meal_name, Suppliers.supplier_name FROM Meals INNER JOIN Suppliers ON Meals.meal_id = Suppliers.meal_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE student_mental_health_history (student_id INT, score INT, date DATE); INSERT INTO student_mental_health_history VALUES (1, 60, '2022-01-01'), (1, 66, '2022-07-01'), (2, 80, '2022-01-01'), (2, 88, '2022-07-01'); | How many students have increased their mental health score by more than 10% in the last 6 months? | SELECT COUNT(*) FROM (SELECT student_id, (score - LAG(score) OVER(PARTITION BY student_id ORDER BY date)) / LAG(score) OVER(PARTITION BY student_id ORDER BY date) * 100.0 as increase_percentage FROM student_mental_health_history WHERE date >= DATEADD(month, -6, GETDATE())) t WHERE increase_percentage > 10; | 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.