context stringlengths 11 9.12k | question stringlengths 0 1.06k | SQL stringlengths 2 4.44k | source stringclasses 28 values |
|---|---|---|---|
CREATE TABLE vessel_types (id INT, type VARCHAR(255)); CREATE TABLE incidents (id INT, vessel_id INT, incident_type VARCHAR(255), year INT); INSERT INTO vessel_types (id, type) VALUES (1, 'Tanker'), (2, 'Cargo'); INSERT INTO incidents (id, vessel_id, incident_type, year) VALUES (1, 1, 'Collision', 2020), (2, 2, 'Grounding', 2019); | How many vessels of each type have been involved in maritime incidents, per year? | SELECT vt.type, i.year, COUNT(*) as incidents_count FROM incidents i JOIN vessel_types vt ON i.vessel_id = vt.id GROUP BY vt.type, i.year ORDER BY i.year, incidents_count DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE Donations (DonationID int, DonorID int, DonationDate date); | Show the number of new donors per month for the last 12 months. | SELECT DATEPART(YEAR, DonationDate) as Year, DATEPART(MONTH, DonationDate) as Month, COUNT(DISTINCT DonorID) as NewDonors FROM Donations WHERE DonationDate >= DATEADD(YEAR, -1, GETDATE()) GROUP BY DATEPART(YEAR, DonationDate), DATEPART(MONTH, DonationDate) ORDER BY Year, Month; | gretelai_synthetic_text_to_sql |
CREATE TABLE astronauts (id INT, name VARCHAR(50), age INT, spacecraft_experience TEXT); INSERT INTO astronauts (id, name, age, spacecraft_experience) VALUES (3, 'Ivan Ivanov', 45, 'Soyuz MS-18'); INSERT INTO astronauts (id, name, age, spacecraft_experience) VALUES (4, 'Anna Popova', 37, 'Soyuz TMA-20M'); | What is the total number of astronauts who have flown on a Russian spacecraft, grouped by their age? | SELECT age, COUNT(*) FROM astronauts WHERE spacecraft_experience LIKE '%Soyuz%' GROUP BY age; | gretelai_synthetic_text_to_sql |
CREATE TABLE MARINE_SPECIES (REGION TEXT, NUMBER_OF_SPECIES INTEGER); INSERT INTO MARINE_SPECIES (REGION, NUMBER_OF_SPECIES) VALUES ('Arctic Region', 2400), ('Antarctic Region', 7500); | What is the total number of marine species in the Arctic region and the Antarctic region, and the difference between them? | SELECT ARCTIC.REGION, ANTARCTIC.REGION, ARCTIC.NUMBER_OF_SPECIES - ANTARCTIC.NUMBER_OF_SPECIES AS DIFFERENCE FROM MARINE_SPECIES AS ARCTIC, MARINE_SPECIES AS ANTARCTIC WHERE ARCTIC.REGION = 'Arctic Region' AND ANTARCTIC.REGION = 'Antarctic Region'; | gretelai_synthetic_text_to_sql |
CREATE TABLE basketball_matches (match_id INT, match_date DATE, ticket_price DECIMAL(10,2)); INSERT INTO basketball_matches (match_id, match_date, ticket_price) VALUES (1, '2021-01-05', 100.00), (2, '2021-01-10', 120.00), (3, '2021-03-15', 110.00), (4, '2021-03-20', 95.00); | What was the average ticket price for basketball matches in Q1 2021? | SELECT AVG(ticket_price) FROM basketball_matches WHERE QUARTER(match_date) = 1 AND YEAR(match_date) = 2021; | gretelai_synthetic_text_to_sql |
CREATE TABLE species_data (species_id INT, species_name VARCHAR(255), biomass FLOAT); INSERT INTO species_data (species_id, species_name, biomass) VALUES (1, 'polar_bear', 800.0), (2, 'arctic_fox', 15.0), (3, 'caribou', 220.0); | What is the total biomass of each species in the 'species_data' table, ordered by total biomass in descending order? | SELECT species_name, SUM(biomass) as total_biomass FROM species_data GROUP BY species_name ORDER BY total_biomass DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE campaigns (id INT, name VARCHAR(50), location VARCHAR(50), budget INT); | What is the difference in budgets between the most expensive campaign and the least expensive campaign? | SELECT MAX(budget) - MIN(budget) FROM campaigns; | gretelai_synthetic_text_to_sql |
CREATE TABLE high_speed_trains( train_id INT, max_speed DECIMAL(5,2), city VARCHAR(50), train_type VARCHAR(50)); | What is the maximum speed of a public high-speed train in Beijing? | SELECT MAX(max_speed) FROM high_speed_trains WHERE city = 'Beijing' AND train_type = 'public'; | gretelai_synthetic_text_to_sql |
CREATE TABLE CanadianRuralHealthcare (Province VARCHAR(20), Location VARCHAR(50), ProviderType VARCHAR(30), NumberOfProviders INT); INSERT INTO CanadianRuralHealthcare (Province, Location, ProviderType, NumberOfProviders) VALUES ('Province A', 'Rural Area A', 'Nurse', 15), ('Province A', 'Rural Area B', 'Nurse', 20), ('Province B', 'Rural Area C', 'Nurse', 10), ('Province B', 'Rural Area D', 'Nurse', 12); | What is the average number of nurses in rural areas in Canada? | SELECT AVG(NumberOfProviders) FROM CanadianRuralHealthcare WHERE Province IN ('Province A', 'Province B') AND Location LIKE '%Rural Area%' AND ProviderType = 'Nurse'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Payments (PaymentID INT, AttorneyID INT, Amount DECIMAL(10,2)); INSERT INTO Payments (PaymentID, AttorneyID, Amount) VALUES (1, 1, 500), (2, 1, 750), (3, 2, 800); | Calculate the average billing amount for each attorney, grouped by their respective practice areas. | SELECT p.PracticeArea, AVG(b.Amount) AS AverageBilling FROM Attorneys p JOIN Payments b ON p.AttorneyID = b.AttorneyID GROUP BY p.PracticeArea; | gretelai_synthetic_text_to_sql |
CREATE TABLE StorageUnits (id INT, location VARCHAR(50), pressure FLOAT); INSERT INTO StorageUnits (id, location, pressure) VALUES (1, 'Japan', 5.1), (2, 'Japan', 4.6), (3, 'Japan', 5.7); | What is the minimum pressure (in bar) recorded for any chemical storage unit located in Japan, for the month of August? | SELECT MIN(pressure) FROM StorageUnits WHERE location = 'Japan' AND EXTRACT(MONTH FROM DATE '2022-08-01' + INTERVAL id DAY) = 8; | gretelai_synthetic_text_to_sql |
CREATE TABLE contracts (id INT, region VARCHAR(255), year INT, contract_value DECIMAL(10,2)); INSERT INTO contracts (id, region, year, contract_value) VALUES (1, 'Latin America', 2022, 1000000.00), (2, 'Europe', 2021, 750000.00), (3, 'Latin America', 2022, 1500000.00); | What is the total value of defense contracts in the Latin America region for the year 2022? | SELECT SUM(contract_value) as total_contract_value FROM contracts WHERE region = 'Latin America' AND year = 2022; | gretelai_synthetic_text_to_sql |
CREATE TABLE matches (id INT, team1 INT, team2 INT, location TEXT, date DATE, status TEXT); | Show all the matches that have been postponed due to weather conditions. | SELECT * FROM matches WHERE status = 'postponed' AND location IN ('outdoor', 'open-air'); | gretelai_synthetic_text_to_sql |
CREATE TABLE exploration_projects (project_id INT, project_name VARCHAR(50), country VARCHAR(50)); INSERT INTO exploration_projects (project_id, project_name, country) VALUES (1, 'Project X', 'Brazil'), (2, 'Project Y', 'Nigeria'), (3, 'Project Z', 'Brazil'); | Which country has the most exploration projects? | SELECT countries.country_name, COUNT(exploration_projects.project_id) FROM exploration_projects INNER JOIN countries ON exploration_projects.country = countries.country_name GROUP BY countries.country_name ORDER BY COUNT(exploration_projects.project_id) DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE users (user_id INT, username VARCHAR(20), email VARCHAR(50), follower_count INT); CREATE TABLE posts (post_id INT, user_id INT, content TEXT, post_time TIMESTAMP); CREATE TABLE comments (comment_id INT, post_id INT, user_id INT, comment TEXT, comment_time TIMESTAMP); CREATE TABLE reactions (reaction_id INT, post_id INT, user_id INT, reaction VARCHAR(10), reaction_time TIMESTAMP); | Create a table named ads with columns ad_id, user_id, ad_content, start_time, and end_time. | CREATE TABLE ads (ad_id INT, user_id INT, ad_content TEXT, start_time TIMESTAMP, end_time TIMESTAMP); | gretelai_synthetic_text_to_sql |
CREATE TABLE CanadianWasteData (waste_type VARCHAR(50), CO2_emission_tonnes FLOAT); INSERT INTO CanadianWasteData (waste_type, CO2_emission_tonnes) VALUES ('Municipal Solid Waste', 10.5), ('Industrial Waste', 41.7), ('Hazardous Waste', 2.9); | What is the total CO2 emission from waste management in Canada? | SELECT SUM(CO2_emission_tonnes) FROM CanadianWasteData; | gretelai_synthetic_text_to_sql |
CREATE TABLE communication_projects (id INT PRIMARY KEY, name VARCHAR(255), location VARCHAR(255), description TEXT, start_date DATE, end_date DATE, budget FLOAT); INSERT INTO communication_projects (id, name, location, description, start_date, end_date, budget) VALUES (1, 'Public Awareness Campaign', 'New York', 'Raising awareness of climate change', '2018-01-01', '2018-12-31', 200000), (2, 'Climate Education Workshop', 'Nairobi', 'Educating community members on climate change', '2018-06-01', '2018-06-30', 150000); | What was the total budget for climate communication projects in '2018' from the 'communication_projects' table? | SELECT SUM(budget) FROM communication_projects WHERE start_date <= '2018-12-31' AND end_date >= '2018-01-01'; | gretelai_synthetic_text_to_sql |
CREATE TABLE creative_ai (model_name TEXT, sector TEXT, creativity_score FLOAT); INSERT INTO creative_ai (model_name, sector, creativity_score) VALUES ('ModelX', 'Art', 0.95), ('ModelY', 'Art', 0.91), ('ModelZ', 'Music', 0.89); | What is the maximum creativity score for models applied in 'Art'? | SELECT MAX(creativity_score) FROM creative_ai WHERE sector = 'Art'; | gretelai_synthetic_text_to_sql |
CREATE TABLE production (well_id INT, country VARCHAR(50), year INT, production FLOAT); INSERT INTO production (well_id, country, year, production) VALUES (1, 'SaudiArabia', 2018, 12000), (2, 'SaudiArabia', 2019, 15000), (3, 'USA', 2018, 18000); | What is the maximum production in 'SaudiArabia'? | SELECT MAX(production) FROM production WHERE country = 'SaudiArabia'; | gretelai_synthetic_text_to_sql |
CREATE TABLE SpacecraftManufacturing (spacecraft_model VARCHAR(255), cost INT); INSERT INTO SpacecraftManufacturing (spacecraft_model, cost) VALUES ('Voyager', 800000), ('Galileo', 1200000), ('Cassini', 1500000); | What is the name of the spacecraft with the highest cost? | SELECT spacecraft_model FROM SpacecraftManufacturing ORDER BY cost DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE budget (region TEXT, category TEXT, year INT, amount INT); INSERT INTO budget (region, category, year, amount) VALUES ('Americas', 'intelligence operations', 2022, 10000000); INSERT INTO budget (region, category, year, amount) VALUES ('Asia-Pacific', 'military technology', 2022, 12000000); | What is the total budget for military technology in the 'Asia-Pacific' region? | SELECT SUM(amount) FROM budget WHERE region = 'Asia-Pacific' AND category = 'military technology'; | gretelai_synthetic_text_to_sql |
CREATE TABLE operations (id INT, name VARCHAR(255), region VARCHAR(255), year INT);INSERT INTO operations (id, name, region, year) VALUES (1, 'Operation Blue', 'Europe', 2014), (2, 'Operation Red', 'Europe', 2016), (3, 'Operation Green', 'Europe', 2013); | Delete all intelligence operations that were conducted in Europe before 2015. | DELETE FROM operations WHERE region = 'Europe' AND year < 2015; | gretelai_synthetic_text_to_sql |
CREATE TABLE transactions (id INT, employee_id INT, loan_id INT, transaction_type TEXT, amount INT); INSERT INTO transactions (id, employee_id, loan_id, transaction_type, amount) VALUES (1, 1, 1, 'Disbursement', 25000), (2, 1, NULL, 'Salary', 55000), (3, 2, 2, 'Disbursement', 30000), (4, 2, NULL, 'Salary', 45000), (5, 3, NULL, 'Salary', 60000), (6, 3, 3, 'Disbursement', 45000); | List the salaries of employees who made only socially responsible loans? | SELECT employees.salary FROM employees JOIN transactions ON employees.id = transactions.employee_id WHERE transactions.loan_id IS NOT NULL AND transactions.transaction_type = 'Disbursement' AND transactions.id NOT IN (SELECT loan_id FROM transactions WHERE transaction_type = 'Disbursement' AND is_shariah_compliant = TRUE); | gretelai_synthetic_text_to_sql |
CREATE TABLE polar_bear_sightings (id INT, date DATE, sighted BOOLEAN, species VARCHAR(50)); | How many polar bears were sighted in the 'polar_bear_sightings' table during the summer months (June, July, August) in the year 2019, broken down by species ('species' column in the 'polar_bear_sightings' table)? | SELECT MONTH(date) AS month, species, COUNT(*) FROM polar_bear_sightings WHERE MONTH(date) IN (6, 7, 8) AND sighted = TRUE AND YEAR(date) = 2019 GROUP BY month, species; | gretelai_synthetic_text_to_sql |
CREATE TABLE sustainable_projects (project_id INT, state VARCHAR(20), project_name VARCHAR(50), is_sustainable BOOLEAN); INSERT INTO sustainable_projects (project_id, state, project_name, is_sustainable) VALUES (1, 'New York', 'Green Tower', TRUE); INSERT INTO sustainable_projects (project_id, state, project_name, is_sustainable) VALUES (2, 'Texas', 'Solar Ranch', TRUE); INSERT INTO sustainable_projects (project_id, state, project_name, is_sustainable) VALUES (3, 'New York', 'Concrete Jungle', FALSE); | List the number of sustainable building projects in 'New York' and 'Texas' grouped by state. | SELECT state, COUNT(*) FROM sustainable_projects WHERE state IN ('New York', 'Texas') AND is_sustainable = TRUE GROUP BY state; | gretelai_synthetic_text_to_sql |
CREATE TABLE ingredients (id INT, name VARCHAR(50), is_organic BOOLEAN, supplier_id INT); INSERT INTO ingredients (id, name, is_organic, supplier_id) VALUES (1, 'Celery', TRUE, 101), (2, 'Almonds', TRUE, 102), (3, 'Beef', FALSE, 103); CREATE TABLE suppliers (id INT, name VARCHAR(50)); INSERT INTO suppliers (id, name) VALUES (101, 'Green Fields'), (102, 'Nutty Goodness'), (103, 'Cattle King'); | Show all suppliers of a specific organic ingredient | SELECT s.name FROM ingredients i INNER JOIN suppliers s ON i.supplier_id = s.id WHERE i.name = 'Celery' AND i.is_organic = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE research_projects (ocean TEXT, project_count INT); INSERT INTO research_projects (ocean, project_count) VALUES ('Arctic', 150), ('Antarctic', 200); | How many marine research projects have been conducted in the Arctic and Antarctic Oceans? | SELECT SUM(project_count) FROM research_projects WHERE ocean IN ('Arctic', 'Antarctic'); | gretelai_synthetic_text_to_sql |
CREATE TABLE RenewableProjects (ProjectID int, ProjectType varchar(50), CarbonOffsets int); | What is the average carbon offset for each renewable energy project type? | SELECT RenewableProjects.ProjectType, AVG(RenewableProjects.CarbonOffsets) FROM RenewableProjects GROUP BY RenewableProjects.ProjectType; | 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, 'Jane', 'Smith', 'Marketing', 60000.00), (2, 'Bruce', 'Johnson', 'IT', 75000.00); | What is the average salary of employees in the Marketing department? | SELECT AVG(Salary) FROM Employees WHERE Department = 'Marketing'; | gretelai_synthetic_text_to_sql |
CREATE TABLE subscribers(id INT, service VARCHAR(20), region VARCHAR(20)); INSERT INTO subscribers(id, service, region) VALUES (1, 'Mobile', 'Urban'), (2, 'Broadband', 'Urban'), (3, 'Mobile', 'Rural'); CREATE TABLE revenue(id INT, subscriber_id INT, amount DECIMAL(10, 2)); INSERT INTO revenue(id, subscriber_id, amount) VALUES (1, 1, 50), (2, 1, 50), (3, 2, 60), (4, 3, 45); | What is the total revenue generated from the mobile and broadband services for customers in the 'Urban' region? | SELECT SUM(revenue.amount) FROM revenue JOIN subscribers ON revenue.subscriber_id = subscribers.id WHERE subscribers.service IN ('Mobile', 'Broadband') AND subscribers.region = 'Urban'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Revenue (id INT, country TEXT, type TEXT, amount FLOAT); INSERT INTO Revenue (id, country, type, amount) VALUES (1, 'Costa Rica', 'Eco-tourism', 800000), (2, 'Costa Rica', 'Hotels', 600000), (3, 'Costa Rica', 'Eco-tourism', 900000), (4, 'Costa Rica', 'Tour operators', 700000); | What is the total revenue of eco-tourism businesses in Costa Rica? | SELECT SUM(amount) FROM Revenue WHERE country = 'Costa Rica' AND type = 'Eco-tourism'; | gretelai_synthetic_text_to_sql |
CREATE TABLE IoTDevices (device_id INT, device_type VARCHAR(20), region VARCHAR(10)); INSERT INTO IoTDevices (device_id, device_type, region) VALUES (1, 'Soil Moisture Sensor', 'West'); INSERT INTO IoTDevices (device_id, device_type, region) VALUES (2, 'Light Sensor', 'East'); INSERT INTO IoTDevices (device_id, device_type, region) VALUES (3, 'Temperature Sensor', 'North'); | How many IoT devices are of type 'Light Sensor'? | SELECT COUNT(*) FROM IoTDevices WHERE device_type = 'Light Sensor'; | gretelai_synthetic_text_to_sql |
CREATE TABLE temperature_records (id INTEGER, location TEXT, temperature FLOAT, date DATE); | What is the maximum sea surface temperature recorded in the 'Indian Ocean'? | SELECT MAX(temperature) FROM temperature_records WHERE location = 'Indian Ocean'; | gretelai_synthetic_text_to_sql |
CREATE TABLE government_climate_communication(campaign_id INT, campaign_name TEXT, amount_funded FLOAT);CREATE TABLE ngo_climate_communication(campaign_id INT, campaign_name TEXT, amount_funded FLOAT); | What's the total funding spent on climate communication campaigns by governments and non-governmental organizations? | SELECT SUM(g.amount_funded) + SUM(ngo.amount_funded) FROM government_climate_communication g JOIN ngo_climate_communication ngo ON g.campaign_id = ngo.campaign_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE transportation.multimodal_mobility (city VARCHAR(50), mode VARCHAR(50)); | Show the top 3 cities with the most multimodal mobility options in the 'multimodal_mobility' table | SELECT city, COUNT(DISTINCT mode) AS num_modes FROM transportation.multimodal_mobility GROUP BY city ORDER BY num_modes DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE theatre_3 (event VARCHAR(255), date DATE, revenue FLOAT); INSERT INTO theatre_3 (event, date, revenue) VALUES ('Drama Night', '2021-02-01', 1800), ('Drama Night', '2021-02-02', 2000), ('Comedy Night', '2021-03-01', 2500); | What was the total revenue from ticket sales for the "Drama Night" event in the month of February? | SELECT SUM(revenue) FROM theatre_3 WHERE event = 'Drama Night' AND MONTH(date) = 2; | gretelai_synthetic_text_to_sql |
CREATE TABLE TransportationBudget (state VARCHAR(20), year INT, budget INT); INSERT INTO TransportationBudget (state, year, budget) VALUES ('Texas', 2021, 5000000), ('Texas', 2022, 5500000); | Find the percentage change in transportation budget between 2021 and 2022 in Texas. | SELECT ((new_budget - old_budget) * 100.0 / old_budget) AS pct_change FROM (SELECT b1.budget AS old_budget, b2.budget AS new_budget FROM TransportationBudget b1, TransportationBudget b2 WHERE b1.state = b2.state AND b1.year = 2021 AND b2.year = 2022 AND b1.state = 'Texas') AS subquery; | gretelai_synthetic_text_to_sql |
CREATE TABLE organizations (org_id INT, org_name TEXT, avg_donation_2021 FLOAT); INSERT INTO organizations (org_id, org_name, avg_donation_2021) VALUES (1, 'Effective Altruism Funds', 50000.00), (2, 'GiveWell', 45000.00), (3, 'Schistosomiasis Control Initiative', 40000.00), (4, 'The Life You Can Save', 35000.00), (5, 'Animal Charity Evaluators', 30000.00); | List the top 5 organizations with the highest average donation amounts in 2021, sorted in descending order. | SELECT org_name, avg_donation_2021 FROM organizations ORDER BY avg_donation_2021 DESC LIMIT 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE chemical_processes (id INT, chemical_id INT, name TEXT, energy_consumption INT); INSERT INTO chemical_processes (id, chemical_id, name, energy_consumption) VALUES (1, 1, 'Process A', 500), (2, 1, 'Process B', 300), (3, 2, 'Process C', 700), (4, 3, 'Process D', 400); | What is the total energy consumption for each chemical production process? | SELECT chemical_id, SUM(energy_consumption) FROM chemical_processes GROUP BY chemical_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE patents (patent_id INT, filing_date DATE, country VARCHAR(20)); INSERT INTO patents (patent_id, filing_date, country) VALUES (1, '2019-01-01', 'India'); INSERT INTO patents (patent_id, filing_date, country) VALUES (2, '2018-01-01', 'India'); | How many legal technology patents were filed in total in India in 2019? | SELECT COUNT(*) FROM patents WHERE filing_date BETWEEN '2019-01-01' AND '2019-12-31' AND country = 'India'; | gretelai_synthetic_text_to_sql |
CREATE TABLE vessels (id INT, name TEXT, type TEXT); CREATE TABLE hours_at_sea (id INT, vessel_id INT, hours FLOAT, date DATE); | What is the total number of hours spent at sea by each vessel in the past year, grouped by vessel type? | SELECT v.type, SUM(h.hours) FROM vessels v JOIN hours_at_sea h ON v.id = h.vessel_id WHERE h.date >= DATE_SUB(NOW(), INTERVAL 1 YEAR) GROUP BY v.type; | gretelai_synthetic_text_to_sql |
CREATE TABLE WasteProduction (WasteID INT, Plant VARCHAR(255), WasteQuantity DECIMAL(5,2), Timestamp DATETIME); | What is the total waste produced by the Chemical Plant A in the last quarter? | SELECT SUM(WasteQuantity) FROM WasteProduction WHERE Plant = 'Chemical Plant A' AND Timestamp BETWEEN DATE_SUB(CURRENT_DATE(), INTERVAL 3 MONTH) AND CURRENT_DATE(); | gretelai_synthetic_text_to_sql |
CREATE TABLE product_co2 (product_id INT, co2_date DATE, product_name TEXT, co2_emission INT); INSERT INTO product_co2 (product_id, co2_date, product_name, co2_emission) VALUES (1, '2022-02-01', 'Product P', 5000), (2, '2022-03-05', 'Product Q', 7000), (3, '2022-04-10', 'Product R', 8000); | What is the total CO2 emission for each chemical product in the past month, and the percentage of the total emission? | SELECT product_name, SUM(co2_emission) AS total_co2, 100.0 * SUM(co2_emission) / (SELECT SUM(co2_emission) FROM product_co2 WHERE co2_date >= DATEADD(month, -1, CURRENT_DATE)) AS pct_of_total FROM product_co2 WHERE co2_date >= DATEADD(month, -1, CURRENT_DATE) GROUP BY product_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE lifelong_learners (student_id INT, age_group VARCHAR(10), enrolled_in_course BOOLEAN); INSERT INTO lifelong_learners (student_id, age_group, enrolled_in_course) VALUES (1, '10-15', true), (2, '16-20', false), (3, '10-15', true), (4, '21-25', true), (5, '16-20', true), (6, '10-15', false), (7, '16-20', true), (8, '21-25', false); | What is the percentage of lifelong learners by age group? | SELECT age_group, (SUM(enrolled_in_course) * 100.0 / COUNT(*)) AS percentage FROM lifelong_learners GROUP BY age_group; | gretelai_synthetic_text_to_sql |
CREATE TABLE copper_production (country VARCHAR(20), quantity INT); INSERT INTO copper_production (country, quantity) VALUES ('Mexico', 700), ('Chile', 1200); | Which country has higher total copper production, Mexico or Chile? | SELECT country, SUM(quantity) FROM copper_production GROUP BY country HAVING country IN ('Mexico', 'Chile') ORDER BY SUM(quantity) DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE Orders (order_id INT, total_value FLOAT, payment_method VARCHAR(20)); CREATE TABLE Payment_Methods (payment_method_id INT, payment_type VARCHAR(20)); INSERT INTO Payment_Methods (payment_method_id, payment_type) VALUES (1, 'Sustainable'), (2, 'Non-Sustainable'); | What is the average order value for purchases made using sustainable payment methods? | SELECT AVG(Orders.total_value) FROM Orders INNER JOIN Payment_Methods ON Orders.payment_method = Payment_Methods.payment_type WHERE Payment_Methods.payment_type = 'Sustainable'; | gretelai_synthetic_text_to_sql |
CREATE TABLE initiatives (initiative_id INT, initiative_name VARCHAR(50), initiative_type VARCHAR(50), region_id INT); CREATE TABLE budgets (budget_id INT, initiative_id INT, budget_amount INT); CREATE TABLE regions (region_id INT, region_name VARCHAR(50)); INSERT INTO initiatives (initiative_id, initiative_name, initiative_type, region_id) VALUES (101, 'Open Source Textbooks', 'Open Pedagogy', 1), (102, 'Peer Learning Networks', 'Open Pedagogy', 2), (103, 'Project-Based Learning', 'Open Pedagogy', 3); INSERT INTO budgets (budget_id, initiative_id, budget_amount) VALUES (201, 101, 10000), (202, 102, 15000), (203, 103, 12000); INSERT INTO regions (region_id, region_name) VALUES (1, 'Northeast'), (2, 'Southeast'), (3, 'Midwest'); | What are the open pedagogy initiatives and their corresponding budgets per region? | SELECT i.initiative_name, b.budget_amount, r.region_name FROM initiatives i INNER JOIN budgets b ON i.initiative_id = b.initiative_id INNER JOIN regions r ON i.region_id = r.region_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE military_equipment(equipment_id INT, name VARCHAR(255), cost FLOAT, purchase_date DATE); INSERT INTO military_equipment(equipment_id, name, cost, purchase_date) VALUES (1, 'Tank', 5000000, '2020-01-15'), (2, 'Fighter Jet', 10000000, '2020-03-20'); | What is the average cost of military equipment purchased by the US in Q1 2020? | SELECT AVG(cost) FROM military_equipment WHERE YEAR(purchase_date) = 2020 AND QUARTER(purchase_date) = 1 AND name = 'US'; | gretelai_synthetic_text_to_sql |
CREATE TABLE workforce (id INT, name VARCHAR(255), department VARCHAR(255), salary DECIMAL(8,2)); | Update the 'workforce' table and set the 'salary' to $60,000 for all workers in the 'mechanical' department | UPDATE workforce SET salary = 60000 WHERE department = 'mechanical'; | gretelai_synthetic_text_to_sql |
CREATE TABLE ships (name VARCHAR(255), year_decommissioned INT, type VARCHAR(255)); INSERT INTO ships (name, year_decommissioned, type) VALUES ('Ship 1', 2005, 'Cargo'), ('Ship 2', 2015, 'Passenger'), ('Ship 3', 2012, 'Fishing'), ('Ship 4', 2010, 'Exploration'); | Delete all records of ships that were decommissioned in 2010 from the Ships table. | DELETE FROM ships WHERE year_decommissioned = 2010; | gretelai_synthetic_text_to_sql |
CREATE TABLE movies (id INT, title VARCHAR(255), genre VARCHAR(255), studio_location VARCHAR(255)); INSERT INTO movies (id, title, genre, studio_location) VALUES (1, 'Movie1', 'Action', 'USA'), (2, 'Movie2', 'Comedy', 'Canada'); CREATE TABLE studios (id INT, name VARCHAR(255), location VARCHAR(255)); INSERT INTO studios (id, name, location) VALUES (1, 'Studio1', 'USA'), (2, 'Studio2', 'Canada'); | What is the total number of movies produced by studios located in the United States and Canada, by genre? | SELECT genre, COUNT(*) as total FROM movies JOIN studios ON movies.studio_location = studios.location WHERE studios.location IN ('USA', 'Canada') GROUP BY genre; | gretelai_synthetic_text_to_sql |
CREATE TABLE cruelty_free_products (product_id INTEGER, brand VARCHAR(20), is_cruelty_free BOOLEAN); INSERT INTO cruelty_free_products (product_id, brand, is_cruelty_free) VALUES (1, 'BrandG', true), (2, 'BrandG', false), (3, 'BrandH', true), (4, 'BrandH', true), (5, 'BrandI', false); | How many cruelty-free products does each brand offer? | SELECT brand, COUNT(*) FROM cruelty_free_products WHERE is_cruelty_free = true GROUP BY brand; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA if not exists rural_health; use rural_health; CREATE TABLE hospitals (id int, name text, location text); INSERT INTO hospitals (id, name, location) VALUES (1, 'Rural General Hospital', 'Springfield'); INSERT INTO hospitals (id, name, location) VALUES (2, 'Rural District Hospital', 'Maplewood'); | What is the number of hospitals and their locations in the 'rural_health' schema? | SELECT COUNT(id), location FROM rural_health.hospitals GROUP BY location; | gretelai_synthetic_text_to_sql |
CREATE TABLE SharedMobility (vehicle_id INT, type VARCHAR(10), PRIMARY KEY (vehicle_id)); | Insert new records into the 'SharedMobility' table for 3 new car-sharing vehicles | INSERT INTO SharedMobility (vehicle_id, type) VALUES (1001, 'CarShare'), (1002, 'CarShare'), (1003, 'CarShare'); | gretelai_synthetic_text_to_sql |
CREATE TABLE state_community_workers (state VARCHAR(20), num_workers INT); INSERT INTO state_community_workers (state, num_workers) VALUES ('California', 150), ('Texas', 120), ('Florida', 80); | What is the total number of community health workers by state? | SELECT state, SUM(num_workers) FROM state_community_workers; | gretelai_synthetic_text_to_sql |
CREATE TABLE hotels(hotel_id INT, hotel_name TEXT, region TEXT); INSERT INTO hotels(hotel_id, hotel_name, region) VALUES (1, 'Hotel Tropical', 'South America'); CREATE TABLE bookings(booking_id INT, hotel_id INT, booking_status TEXT, booking_revenue DECIMAL, booking_date DATE); CREATE TABLE users(user_id INT, user_country TEXT); | What is the total revenue from bookings in hotels located in the 'South America' region, for users from Brazil, in 2022, considering only completed bookings? | SELECT SUM(booking_revenue) FROM hotels INNER JOIN bookings ON hotels.hotel_id = bookings.hotel_id INNER JOIN users ON bookings.user_id = users.user_id WHERE hotels.region = 'South America' AND users.user_country = 'Brazil' AND YEAR(booking_date) = 2022 AND booking_status = 'completed'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Budget(year INT, department VARCHAR(20), amount INT); INSERT INTO Budget VALUES (2021, 'Education', 5000000), (2021, 'Healthcare', 7000000), (2022, 'Education', 5500000), (2022, 'Healthcare', 7500000); | What was the total budget allocated for the 'Education' department in the year 2021? | SELECT SUM(amount) FROM Budget WHERE department = 'Education' AND year = 2021; | gretelai_synthetic_text_to_sql |
CREATE TABLE Donors (id INT PRIMARY KEY, donor_name VARCHAR(255), email VARCHAR(255)); INSERT INTO Donors (id, donor_name, email) VALUES (1, 'John Doe', 'john.doe@example.com'), (2, 'Jane Smith', 'jane.smith@example.com'); | Delete all records from the 'Donors' table where the donor name is 'John Doe' | DELETE FROM Donors WHERE donor_name = 'John Doe'; | gretelai_synthetic_text_to_sql |
CREATE TABLE if not exists renewable_projects (project_id INT, project_name VARCHAR(255), location VARCHAR(255), installed_capacity FLOAT); | What is the total number of renewable energy projects in the 'renewable_projects' table, by location? | SELECT location, COUNT(*) as total_projects FROM renewable_projects GROUP BY location; | gretelai_synthetic_text_to_sql |
CREATE TABLE wells (id INT, name VARCHAR(255), owner VARCHAR(255), production_quantity INT); INSERT INTO wells (id, name, owner, production_quantity) VALUES (1, 'Well A', 'Acme Oil', 1000), (2, 'Well B', 'Big Oil', 2000), (3, 'Well C', 'Acme Oil', 1500), (4, 'Well D', 'Other Oil', 2500); | What is the total production quantity for wells owned by 'Acme Oil'? | SELECT SUM(production_quantity) FROM wells WHERE owner = 'Acme Oil'; | gretelai_synthetic_text_to_sql |
CREATE TABLE properties (id INT, city VARCHAR(20), listing_price FLOAT, accessible BOOLEAN, co_owned BOOLEAN); INSERT INTO properties (id, city, listing_price, accessible, co_owned) VALUES (1, 'Austin', 350000, true, false), (2, 'Austin', 450000, false, true), (3, 'Austin', 550000, false, false); | What is the average listing price for properties in the city of Austin that are either accessible or co-owned? | SELECT AVG(listing_price) FROM properties WHERE city = 'Austin' AND (accessible = true OR co_owned = true); | gretelai_synthetic_text_to_sql |
CREATE TABLE FieldC_Sensors (sensor_id INT, temperature FLOAT, reading_time DATETIME); INSERT INTO FieldC_Sensors (sensor_id, temperature, reading_time) VALUES (1, 20.2, '2022-02-01 10:00:00'), (1, 19.8, '2022-02-02 10:00:00'); | What is the minimum temperature recorded in 'FieldC' in the past month? | SELECT MIN(temperature) FROM FieldC_Sensors WHERE reading_time BETWEEN DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) AND CURRENT_DATE; | gretelai_synthetic_text_to_sql |
CREATE TABLE carbon_offsets (id INT, name VARCHAR(50), carbon_emissions_saved INT); INSERT INTO carbon_offsets (id, name, carbon_emissions_saved) VALUES (1, 'Program 1', 4000), (2, 'Program 2', 7000), (3, 'Program 3', 5500); | What is the maximum carbon emissions saved in a single carbon offset program in the 'carbon_offset' schema? | SELECT MAX(carbon_emissions_saved) FROM carbon_offsets; | gretelai_synthetic_text_to_sql |
CREATE TABLE Warehouse (id INT, country VARCHAR(255), items_quantity INT, warehouse_date DATE); INSERT INTO Warehouse (id, country, items_quantity, warehouse_date) VALUES (1, 'Argentina', 300, '2021-04-01'), (2, 'Argentina', 200, '2021-03-01'); | What are the total items in the warehouse in Argentina, excluding items in the warehouse in April 2021? | SELECT SUM(items_quantity) FROM Warehouse WHERE country = 'Argentina' AND warehouse_date NOT BETWEEN '2021-04-01' AND '2021-04-30'; | gretelai_synthetic_text_to_sql |
CREATE TABLE guests (guest_id INT, name VARCHAR(50), nationality VARCHAR(30)); CREATE TABLE visits (visit_id INT, guest_id INT, site_id INT); CREATE TABLE cultural_heritage_sites (site_id INT, site_name VARCHAR(50), location VARCHAR(50)); INSERT INTO guests (guest_id, name, nationality) VALUES (1, 'Jacques', 'France'), (2, 'Sophia', 'Germany'), (3, 'Pedro', 'Spain'), (4, 'Clara', 'France'); INSERT INTO visits (visit_id, guest_id, site_id) VALUES (1, 1, 1), (2, 1, 2), (3, 2, 1), (4, 3, 3), (5, 4, 1), (6, 4, 2); INSERT INTO cultural_heritage_sites (site_id, site_name, location) VALUES (1, 'Eiffel Tower', 'France'), (2, 'Neuschwanstein Castle', 'Germany'), (3, 'Alhambra', 'Spain'); | List all cultural heritage sites visited by guests from France? | SELECT site_name FROM cultural_heritage_sites WHERE site_id IN (SELECT site_id FROM visits WHERE guest_id IN (SELECT guest_id FROM guests WHERE nationality = 'France')); | gretelai_synthetic_text_to_sql |
CREATE TABLE community_initiatives (country VARCHAR(50), initiative VARCHAR(50), budget INT); INSERT INTO community_initiatives (country, initiative, budget) VALUES ('Australia', 'Green Spaces', 120000), ('New Zealand', 'Waste Management', 90000); | What is the total number of community development initiatives and their budgets for each country in Oceania? | SELECT country, COUNT(*), SUM(budget) FROM community_initiatives WHERE country IN ('Australia', 'New Zealand') GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE automotive_workers (id INT, name VARCHAR(50), salary FLOAT, industry40 VARCHAR(50)); INSERT INTO automotive_workers (id, name, salary, industry40) VALUES (1, 'Charlie Davis', 50000.0, 'Automation'); INSERT INTO automotive_workers (id, name, salary, industry40) VALUES (2, 'David Wilson', 55000.0, 'AI'); | What is the total salary cost of workers in the automotive industry who are part of industry 4.0 training programs? | SELECT SUM(salary) FROM automotive_workers WHERE industry = 'Automotive' AND industry40 IS NOT NULL; | gretelai_synthetic_text_to_sql |
CREATE TABLE ai_algorithm (algorithm_id INT, algorithm_name VARCHAR(255)); CREATE TABLE explainability_score (score_id INT, algorithm_id INT, score DECIMAL(5, 4)); INSERT INTO ai_algorithm (algorithm_id, algorithm_name) VALUES (1, 'SHAP'); INSERT INTO ai_algorithm (algorithm_id, algorithm_name) VALUES (2, 'LIME'); INSERT INTO explainability_score (score_id, algorithm_id, score) VALUES (1, 1, 0.8756); INSERT INTO explainability_score (score_id, algorithm_id, score) VALUES (2, 2, 0.9231); | Identify the explainability scores and associated AI algorithms, including the average explainability score. | SELECT aa.algorithm_name, es.score, AVG(es.score) OVER () as avg_score FROM ai_algorithm aa INNER JOIN explainability_score es ON aa.algorithm_id = es.algorithm_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE defense_diplomacy (id INT, event_type VARCHAR(50), country VARCHAR(50), year INT); INSERT INTO defense_diplomacy (id, event_type, country, year) VALUES (1, 'Defense Agreement', 'USA', 2018), (2, 'Military Exercise', 'Canada', 2019), (3, 'Defense Agreement', 'Mexico', 2018), (4, 'Military Sale', 'Brazil', 2019); | Summarize defense agreements by country and year | SELECT year, country, COUNT(*) as num_events FROM defense_diplomacy WHERE event_type = 'Defense Agreement' GROUP BY year, country; | gretelai_synthetic_text_to_sql |
CREATE TABLE military_personnel (id INT, name VARCHAR(50), branch VARCHAR(20), rank VARCHAR(20), country VARCHAR(50)); INSERT INTO military_personnel (id, name, branch, rank, country) VALUES (1, 'John Doe', 'army', 'Colonel', 'USA'), (2, 'Jane Smith', 'navy', 'Captain', 'USA'), (3, 'Raj Patel', 'airforce', 'Group Captain', 'India'); | What is the total number of military personnel in each country? | SELECT country, COUNT(*) FROM military_personnel GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE sales (sale_id INT, dish_name TEXT, category TEXT, quantity INT); INSERT INTO sales (sale_id, dish_name, category, quantity) VALUES (1, 'Spicy Quinoa', 'Vegan', 30), (2, 'Tofu Stir Fry', 'Vegan', 25), (3, 'Chickpea Curry', 'Vegan', 40), (4, 'Beef Burrito', 'Non-Veg', 50), (5, 'Chicken Alfredo', 'Non-Veg', 45), (6, 'Fish and Chips', 'Non-Veg', 40), (7, 'Veggie Pizza', 'Veg', 55); | What are the total sales for each dish in the 'Non-Veg' category? | SELECT dish_name, SUM(quantity) FROM sales WHERE category = 'Non-Veg' GROUP BY dish_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE housing_data (id INT, address VARCHAR(255), city VARCHAR(255), state VARCHAR(255), square_footage INT, sustainable_features VARCHAR(255)); INSERT INTO housing_data (id, address, city, state, square_footage, sustainable_features) VALUES (1, '123 Maple St', 'San Francisco', 'CA', 1200, 'solar panels'), (2, '456 Oak St', 'Austin', 'TX', 1500, 'none'), (3, '789 Pine St', 'Seattle', 'WA', 1800, 'green roof'); | What is the average square footage of properties in the 'housing_data' table for each city? | SELECT city, AVG(square_footage) FROM housing_data GROUP BY city; | gretelai_synthetic_text_to_sql |
CREATE TABLE wildlife (id INT, region VARCHAR(255), species VARCHAR(255), year INT, population INT); INSERT INTO wildlife (id, region, species, year, population) VALUES (1, 'North', 'Deer', 2018, 75), (2, 'South', 'Bear', 2019, 60), (3, 'East', 'Elk', 2020, 45), (4, 'West', 'Wolf', 2020, 40), (5, 'North', 'Moose', 2020, 55), (6, 'South', 'Lynx', 2020, 30), (7, 'East', 'Fox', 2020, 50), (8, 'West', 'Raccoon', 2020, 60); | What is the total population of all wildlife species in 2020, grouped by the region? | SELECT region, SUM(population) as total_population FROM wildlife WHERE year = 2020 GROUP BY region; | gretelai_synthetic_text_to_sql |
CREATE TABLE cargo_handling_events (id INT, port_id INT, event_type VARCHAR(50)); INSERT INTO cargo_handling_events (id, port_id, event_type) VALUES (1, 1, 'Loading'), (2, 1, 'Unloading'), (3, 2, 'Loading'); | What is the total number of cargo handling events at each port? | SELECT port_id, COUNT(*) FROM cargo_handling_events GROUP BY port_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE arctic_indigenous (community_name VARCHAR(100), population INT); | What is the total number of indigenous communities in the 'arctic_indigenous' table, with a population greater than 5000? | SELECT COUNT(DISTINCT community_name) FROM arctic_indigenous WHERE population > 5000; | gretelai_synthetic_text_to_sql |
CREATE TABLE spanish_teams (team_id INT, team_name VARCHAR(50)); INSERT INTO spanish_teams (team_id, team_name) VALUES (1, 'Real Madrid'), (2, 'Barcelona'), (3, 'Atletico Madrid'); CREATE TABLE spanish_matches (match_id INT, home_team_id INT, away_team_id INT, home_team_points INT, away_team_points INT); INSERT INTO spanish_matches (match_id, home_team_id, away_team_id, home_team_points, away_team_points) VALUES (1, 1, 2, 3, 1), (2, 2, 3, 2, 2), (3, 3, 1, 1, 1); | What is the maximum number of points scored by a team in a single La Liga season? | SELECT MAX(home_team_points + away_team_points) AS max_points FROM spanish_matches JOIN spanish_teams ON (spanish_matches.home_team_id = spanish_teams.team_id OR spanish_matches.away_team_id = spanish_teams.team_id); | gretelai_synthetic_text_to_sql |
CREATE TABLE Materials (material_id INT PRIMARY KEY, material VARCHAR(50), usage INT); INSERT INTO Materials (material_id, material, usage) VALUES (1, 'Organic Cotton', 500), (2, 'Recycled Polyester', 300), (3, 'Hemp', 100); | Which sustainable material has the least usage in garment production? | SELECT material FROM (SELECT material, ROW_NUMBER() OVER (ORDER BY usage) AS rank FROM Materials) AS ranked_materials WHERE rank = 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE investments (id INT, sector VARCHAR(20), amount FLOAT); INSERT INTO investments (id, sector, amount) VALUES (1, 'Education', 150000.00), (2, 'Healthcare', 120000.00), (3, 'Renewable Energy', 200000.00); | What are the sectors with investments greater than 150000? | SELECT sector FROM investments WHERE amount > 150000; | gretelai_synthetic_text_to_sql |
CREATE TABLE HeritageSites (id INT, site_name VARCHAR(255), country VARCHAR(255), visitors INT); INSERT INTO HeritageSites (id, site_name, country, visitors) VALUES (1, 'Machu Picchu', 'Peru', 1200000), (2, 'Angkor Wat', 'Cambodia', 2000000), (3, 'Petra', 'Jordan', 800000); | How many heritage sites are located in each country and what is their total number of visitors? | SELECT country, COUNT(*), SUM(visitors) FROM HeritageSites GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE athletes (athlete_id INT, athlete_name VARCHAR(50), team_id INT);CREATE TABLE wellbeing_program (athlete_id INT, program_date DATE, score INT);CREATE TABLE performance (athlete_id INT, game_date DATE, score INT); INSERT INTO athletes (athlete_id, athlete_name, team_id) VALUES (1, 'Athlete1', 1), (2, 'Athlete2', 1); INSERT INTO wellbeing_program (athlete_id, program_date, score) VALUES (1, '2022-01-01', 85), (2, '2022-01-02', 75); INSERT INTO performance (athlete_id, game_date, score) VALUES (1, '2022-01-03', 82), (1, '2022-01-04', 78), (2, '2022-01-05', 88); | Which athletes participated in the wellbeing program and had a season average performance score above 80? | SELECT a.athlete_name FROM athletes a JOIN performance p ON a.athlete_id = p.athlete_id JOIN wellbeing_program wp ON a.athlete_id = wp.athlete_id WHERE p.score + wp.score / 2 > 80 GROUP BY a.athlete_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE tokyo_metro_entries (id INT, station_name VARCHAR(255), entries INT, entry_date DATE); INSERT INTO tokyo_metro_entries (id, station_name, entries, entry_date) VALUES (1, 'Station 1', 12000, '2022-01-01'), (2, 'Station 2', 8000, '2022-01-01'), (3, 'Station 1', 15000, '2022-01-02'); | What is the maximum number of entries for a single metro station in Tokyo on any given day? | SELECT MAX(entries) FROM tokyo_metro_entries; | gretelai_synthetic_text_to_sql |
CREATE TABLE Veterans_Employment (ID INT, Industry TEXT, State TEXT, Num_Employees INT); INSERT INTO Veterans_Employment (ID, Industry, State, Num_Employees) VALUES (1, 'Defense', 'Texas', 3000); INSERT INTO Veterans_Employment (ID, Industry, State, Num_Employees) VALUES (2, 'Aerospace', 'Texas', 2000); | What is the total number of veterans employed in Texas in the defense industry? | SELECT SUM(Num_Employees) FROM Veterans_Employment WHERE Industry = 'Defense' AND State = 'Texas'; | gretelai_synthetic_text_to_sql |
CREATE TABLE events (event_id INT, event_type VARCHAR(50)); INSERT INTO events (event_id, event_type) VALUES (1, 'Dance'), (2, 'Theater'), (3, 'Music'); CREATE TABLE attendees (attendee_id INT, event_id INT); INSERT INTO attendees (attendee_id, event_id) VALUES (1, 1), (2, 1), (3, 3), (4, 3), (5, 3), (6, 1), (7, 2), (8, 2), (9, 2), (10, 2), (11, 2); | What is the count of attendees for each event type? | SELECT events.event_type, COUNT(attendees.event_id) FROM events JOIN attendees ON events.event_id = attendees.event_id GROUP BY events.event_type; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA infrastructure; CREATE TABLE projects (country VARCHAR(50), completion_year INT); INSERT INTO projects (country, completion_year) VALUES ('Brazil', 2022), ('India', 2021), ('Indonesia', 2022), ('Colombia', 2021), ('Peru', 2022); | How many rural infrastructure projects were completed in each country in the 'infrastructure' schema, in 2022? | SELECT country, COUNT(*) FROM infrastructure.projects WHERE completion_year = 2022 GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE festivals (festival_id INT PRIMARY KEY, festival_name VARCHAR(100), location VARCHAR(100), attendance INT); INSERT INTO festivals (festival_id, festival_name, location, attendance) VALUES (1, 'Coachella', 'Indio, CA', 100000); INSERT INTO festivals (festival_id, festival_name, location, attendance) VALUES (2, 'Glastonbury', 'Pilton, England', 200000); INSERT INTO festivals (festival_id, festival_name, location, attendance) VALUES (3, 'Tomorrowland', 'Boom, Belgium', 400000); | List all festivals that have an attendance greater than 50000 | SELECT festival_name FROM festivals WHERE attendance > 50000; | gretelai_synthetic_text_to_sql |
CREATE TABLE Concerts (city VARCHAR(255), genre VARCHAR(255), ticket_price DECIMAL(5,2)); | What is the average ticket price for traditional music concerts in Seoul? | SELECT AVG(ticket_price) FROM Concerts WHERE city = 'Seoul' AND genre = 'traditional'; | gretelai_synthetic_text_to_sql |
CREATE TABLE suppliers (id INT PRIMARY KEY, name VARCHAR(255), country VARCHAR(255), sustainable_practices BOOLEAN); | Which suppliers are based in India and have sustainable practices? | SELECT name FROM suppliers WHERE country = 'India' AND sustainable_practices = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE forests (id INT, name VARCHAR(50), hectares DECIMAL(5,2), year_planted INT, avg_carbon_sequestration DECIMAL(5,2), num_wildlife_species INT, PRIMARY KEY (id)); INSERT INTO forests (id, name, hectares, year_planted, avg_carbon_sequestration, num_wildlife_species) VALUES (1, 'Forest A', 123.45, 1990, 2.5, 5), (2, 'Forest B', 654.32, 1985, 3.2, 8), (3, 'Forest C', 456.78, 2010, 3.8, 10), (4, 'Forest D', 903.45, 1980, 1.9, 3); | Find forests with high carbon sequestration and large wildlife populations | SELECT * FROM forests WHERE avg_carbon_sequestration > 3.5 AND num_wildlife_species > 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE volunteers (volunteer_id INT, signup_date DATE, city VARCHAR(50)); INSERT INTO volunteers VALUES (1, '2021-02-01', 'NYC'), (2, '2021-05-15', 'LA'), (3, '2021-11-01', 'NYC'); | How many volunteers signed up in each city in 2021? | SELECT city, COUNT(*) as num_volunteers FROM volunteers WHERE signup_date BETWEEN '2021-01-01' AND '2021-12-31' GROUP BY city; | gretelai_synthetic_text_to_sql |
CREATE TABLE safety_protocols_2 (site VARCHAR(10), protocol VARCHAR(20), review_date DATE); INSERT INTO safety_protocols_2 VALUES ('A', 'P1', '2020-06-01'), ('A', 'P2', '2019-08-15'), ('B', 'P3', '2021-02-03'), ('B', 'P4', '2020-11-28'), ('B', 'P5', '2018-04-22'); | Which safety protocols have not been reviewed in the last 2 years? | SELECT protocol FROM safety_protocols_2 WHERE review_date < DATE_SUB(CURDATE(), INTERVAL 2 YEAR); | gretelai_synthetic_text_to_sql |
CREATE TABLE if not exists flood_control_projects (id INT, name VARCHAR(100), location VARCHAR(50), cost FLOAT); INSERT INTO flood_control_projects (id, name, location, cost) VALUES (1, 'Coastal Flood Control', 'coastal', 1000000); | What is the average cost of flood control projects in 'coastal' areas? | SELECT AVG(cost) FROM flood_control_projects WHERE location = 'coastal'; | gretelai_synthetic_text_to_sql |
CREATE TABLE wells (well_id INT, name VARCHAR(50), location VARCHAR(50), production FLOAT); INSERT INTO wells (well_id, name, location, production) VALUES (1, 'C1', 'Caspian Sea', 8000); INSERT INTO wells (well_id, name, location, production) VALUES (2, 'C2', 'Caspian Sea', 9000); | How many wells are located in the Caspian Sea? | SELECT COUNT(*) FROM wells WHERE location = 'Caspian Sea'; | gretelai_synthetic_text_to_sql |
CREATE TABLE peacekeeping_personnel (country VARCHAR(50), year INT, personnel INT); INSERT INTO peacekeeping_personnel (country, year, personnel) VALUES ('Algeria', 2020, 500), ('Angola', 2020, 600), ('Benin', 2020, 700), ('Botswana', 2020, 800), ('Burkina Faso', 2020, 900), ('Burundi', 2020, 400), ('Cabo Verde', 2020, 300), ('Cameroon', 2020, 1000), ('Central African Republic', 2020, 1200), ('Chad', 2020, 1100); | What is the total number of peacekeeping personnel from African countries as of 2020? | SELECT SUM(personnel) as total_african_personnel FROM peacekeeping_personnel WHERE year = 2020 AND country IN ('Algeria', 'Angola', 'Benin', 'Botswana', 'Burkina Faso', 'Burundi', 'Cabo Verde', 'Cameroon', 'Central African Republic', 'Chad'); | gretelai_synthetic_text_to_sql |
CREATE TABLE incident_responses (id INT, neighborhood VARCHAR(20), response_time INT); INSERT INTO incident_responses (id, neighborhood, response_time) VALUES (1, 'westside', 100), (2, 'westside', 110), (3, 'westside', 95); INSERT INTO incident_responses (id, neighborhood, response_time) VALUES (4, 'northeast', 80), (5, 'northeast', 90), (6, 'northeast', 85); | What is the average response time for fire incidents in the "westside" neighborhood? | SELECT AVG(response_time) FROM incident_responses WHERE neighborhood = 'westside'; | gretelai_synthetic_text_to_sql |
CREATE TABLE artist_concerts (artist_id INT, concert_date DATE, country VARCHAR(50)); | What is the average number of concerts performed by artists in the US, partitioned by year? | SELECT country, EXTRACT(YEAR FROM concert_date) as year, AVG(COUNT(artist_id)) OVER (PARTITION BY country, EXTRACT(YEAR FROM concert_date) ORDER BY concert_date ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) as avg_concerts FROM artist_concerts WHERE country = 'US' GROUP BY country, year; | gretelai_synthetic_text_to_sql |
CREATE TABLE Sales (sale_id INT, product_id INT, sale_revenue FLOAT, region_sold VARCHAR(50)); INSERT INTO Sales (sale_id, product_id, sale_revenue, region_sold) VALUES (100, 1, 50.0, 'Asia'), (101, 2, 75.0, 'Europe'), (102, 3, 100.0, 'Asia'), (103, 4, 25.0, 'Europe'), (104, 5, 35.0, 'America'); CREATE TABLE Products (product_id INT, product_name VARCHAR(100), category VARCHAR(50)); INSERT INTO Products (product_id, product_name, category) VALUES (1, 'Lipstick A', 'Makeup'), (2, 'Lipstick B', 'Makeup'), (3, 'Lipstick C', 'Makeup'), (4, 'Cleanser D', 'Skincare'), (5, 'Toner E', 'Skincare'); | How many beauty products are sold in each region? | SELECT region_sold, COUNT(DISTINCT Products.product_id) as product_count FROM Sales INNER JOIN Products ON Sales.product_id = Products.product_id GROUP BY region_sold; | gretelai_synthetic_text_to_sql |
CREATE TABLE subscribers(id INT, city VARCHAR(20), monthly_data_usage DECIMAL(5,2)); INSERT INTO subscribers(id, city, monthly_data_usage) VALUES (1, 'New York', 3.5), (2, 'New York', 4.2), (3, 'Chicago', 3.8); | What is the average data usage per mobile subscriber in each city? | SELECT city, AVG(monthly_data_usage) FROM subscribers GROUP BY city; | gretelai_synthetic_text_to_sql |
CREATE TABLE fuel_consumption (id INT, vessel_id INT, consumption FLOAT); | What is the average fuel consumption per vessel type? | SELECT v.type, AVG(fc.consumption) as avg_consumption FROM fuel_consumption fc JOIN vessels v ON fc.vessel_id = v.id GROUP BY v.type; | gretelai_synthetic_text_to_sql |
CREATE TABLE ai_projects (id INT, country VARCHAR(255), budget DECIMAL(10, 2)); INSERT INTO ai_projects (id, country, budget) VALUES (1, 'Canada', 500000.00), (2, 'USA', 700000.00), (3, 'Mexico', 300000.00); | What's the average budget for AI projects in Canada? | SELECT AVG(budget) FROM ai_projects WHERE country = 'Canada'; | gretelai_synthetic_text_to_sql |
CREATE TABLE advertisers (id INT, name VARCHAR(50)); CREATE TABLE ad_impressions (advertiser_id INT, impression_time TIMESTAMP); CREATE TABLE ad_clicks (advertiser_id INT, click_time TIMESTAMP); | What are the total number of ad impressions and clicks for each advertiser in the last month? | SELECT advertisers.name, COUNT(ad_impressions.advertiser_id) as total_impressions, COUNT(ad_clicks.advertiser_id) as total_clicks FROM advertisers LEFT JOIN ad_impressions ON advertisers.id = ad_impressions.advertiser_id LEFT JOIN ad_clicks ON advertisers.id = ad_clicks.advertiser_id WHERE ad_impressions.impression_time > NOW() - INTERVAL '1 month' GROUP BY advertisers.name; | 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.