context stringlengths 11 9.12k | question stringlengths 0 1.06k | SQL stringlengths 2 4.44k | source stringclasses 28
values |
|---|---|---|---|
CREATE TABLE mining_permits (id INT PRIMARY KEY, permit_number VARCHAR(255), company_name VARCHAR(255), mine_location VARCHAR(255), element_type VARCHAR(255), issue_date DATE); | Delete mining permits for Samarium that were issued before 2015. | DELETE FROM mining_permits WHERE element_type = 'Samarium' AND issue_date < '2015-01-01'; | gretelai_synthetic_text_to_sql |
CREATE TABLE patients (id INT PRIMARY KEY, name VARCHAR(255), age INT); INSERT INTO patients (id, name, age) VALUES (8, 'James Bond', 40); | Update the age of the patient with ID 8 to 45. | UPDATE patients SET age = 45 WHERE id = 8; | gretelai_synthetic_text_to_sql |
CREATE TABLE LandfillCapacity (Country VARCHAR(50), TotalCapacity INT, UsedCapacity INT); INSERT INTO LandfillCapacity (Country, TotalCapacity, UsedCapacity) VALUES ('United States', 1000000, 600000), ('Canada', 500000, 300000), ('Mexico', 700000, 450000); | What is the total landfill capacity for the United States, and what percentage of that capacity is currently being used? | SELECT Country, UsedCapacity * 100.0 / TotalCapacity AS PercentageUsed FROM LandfillCapacity WHERE Country = 'United States'; | gretelai_synthetic_text_to_sql |
CREATE TABLE art_pieces (id INT, name VARCHAR(255), artist_id INT); CREATE TABLE artists (id INT, name VARCHAR(255), country VARCHAR(255)); INSERT INTO art_pieces (id, name, artist_id) VALUES (1, 'Painting', 1), (2, 'Sculpture', 2), (3, 'Drawing', 3); INSERT INTO artists (id, name, country) VALUES (1, 'John Doe', 'USA'... | How many art pieces were created by artists from Africa? | SELECT COUNT(*) FROM art_pieces JOIN artists ON art_pieces.artist_id = artists.id WHERE artists.country = 'Nigeria' OR artists.country = 'South Africa'; | gretelai_synthetic_text_to_sql |
esports_event (event_id, name, location, start_date, end_date, prize_pool, game_id) | Add new esports event 'CyberSphereCup' with game 'CS' | INSERT INTO esports_event (name, location, start_date, end_date, prize_pool, game_id) VALUES ('CyberSphereCup', 'LA', '2024-01-01', '2024-01-10', 500000, (SELECT game_id FROM game WHERE name = 'CS')) | gretelai_synthetic_text_to_sql |
CREATE TABLE deliveries (id INT, delivery_time FLOAT, warehouse VARCHAR(20), quarter INT); INSERT INTO deliveries (id, delivery_time, warehouse, quarter) VALUES (1, 3.5, 'Miami', 2), (2, 7.0, 'Seattle', 1), (3, 2.8, 'Miami', 2); CREATE TABLE warehouses (id INT, name VARCHAR(20)); INSERT INTO warehouses (id, name) VALUE... | What is the average delivery time for packages shipped from the Miami warehouse in Q2 2021? | SELECT AVG(delivery_time) FROM deliveries d JOIN warehouses w ON d.warehouse = w.name WHERE w.name = 'Miami' AND d.quarter = 2; | gretelai_synthetic_text_to_sql |
CREATE TABLE esports_teams (id INT PRIMARY KEY, name VARCHAR(50), country VARCHAR(50)); | Insert new eSports team data | INSERT INTO esports_teams (id, name, country) VALUES (1, 'Team A', 'USA'), (2, 'Team B', 'Canada'), (3, 'Team C', 'Mexico'); | gretelai_synthetic_text_to_sql |
CREATE TABLE projects(id INT, name VARCHAR(255), start_date DATE, end_date DATE, region VARCHAR(255)); | List the defense projects with their start and end dates in the Middle East? | SELECT name, start_date, end_date FROM projects WHERE region = 'Middle East'; | gretelai_synthetic_text_to_sql |
CREATE TABLE projects (id INT, name VARCHAR(255), type VARCHAR(255), location VARCHAR(255), organization VARCHAR(255), start_date DATE, end_date DATE); INSERT INTO projects (id, name, type, location, organization, start_date, end_date) VALUES (1, 'Project A', 'Disaster Relief', 'South East Asia', 'World Food Programme'... | How many 'Disaster Relief' projects were conducted by 'World Food Programme' in 'South East Asia' before 2018? | SELECT COUNT(*) FROM projects WHERE location = 'South East Asia' AND organization = 'World Food Programme' AND type = 'Disaster Relief' AND YEAR(start_date) < 2018; | gretelai_synthetic_text_to_sql |
CREATE TABLE sales (sale_id INT, product_id INT, supplier_id INT, sale_amount DECIMAL(5,2)); CREATE TABLE suppliers (supplier_id INT, supplier_name VARCHAR(50), is_ethical_labor_practices BOOLEAN); INSERT INTO sales (sale_id, product_id, supplier_id, sale_amount) VALUES (1, 1, 1, 25.00), (2, 2, 2, 50.00), (3, 3, 3, 75.... | What is the total revenue of ethical labor practices certified suppliers? | SELECT SUM(sale_amount) FROM sales INNER JOIN suppliers ON sales.supplier_id = suppliers.supplier_id WHERE suppliers.is_ethical_labor_practices = true; | gretelai_synthetic_text_to_sql |
CREATE TABLE healthcare_providers (provider_id INT, name TEXT, zip TEXT, state TEXT, score INT); INSERT INTO healthcare_providers (provider_id, name, zip, state, score) VALUES (1, 'Dr. Smith', '94111', 'CA', 90), (2, 'Dr. Johnson', '90001', 'CA', 85), (3, 'Dr. Rodriguez', '77001', 'TX', 95), (4, 'Dr. Lee', '10001', 'NY... | What is the average mental health parity score for healthcare providers by zip code? | SELECT zip, AVG(score) FROM healthcare_providers GROUP BY zip; | gretelai_synthetic_text_to_sql |
CREATE TABLE australian_education_programs (organization VARCHAR(50), program_date DATE); INSERT INTO australian_education_programs (organization, program_date) VALUES ('Organization A', '2020-01-01'), ('Organization B', '2019-12-15'), ('Organization A', '2018-06-20'); | What is the number of community education programs conducted by each organization in the Australian conservation programs? | SELECT organization, COUNT(*) FROM australian_education_programs GROUP BY organization; | gretelai_synthetic_text_to_sql |
CREATE TABLE taxi_rides (id INT, ride_date DATE, rating INT, vehicle_type VARCHAR(10)); INSERT INTO taxi_rides (id, ride_date, rating, vehicle_type) VALUES (1, '2022-01-01', 3, 'Autonomous'), (2, '2022-01-02', 5, 'Autonomous'), (3, '2022-01-03', 4, 'Manual'); | Delete records of autonomous taxi rides with a rating less than 4 in the 'taxi_rides' table. | DELETE FROM taxi_rides WHERE vehicle_type = 'Autonomous' AND rating < 4; | gretelai_synthetic_text_to_sql |
CREATE TABLE Donations (id INT, donor_type VARCHAR(10), donation_amount DECIMAL(10,2), donation_date DATE); INSERT INTO Donations (id, donor_type, donation_amount, donation_date) VALUES (1, 'one-time', 50.00, '2022-01-01'); INSERT INTO Donations (id, donor_type, donation_amount, donation_date) VALUES (2, 'recurring', 2... | What is the minimum donation amount for recurring donors in '2023'? | SELECT MIN(donation_amount) FROM Donations WHERE donor_type = 'recurring' AND YEAR(donation_date) = 2023; | gretelai_synthetic_text_to_sql |
CREATE TABLE conservation_initiatives (id INT, initiative VARCHAR(50), launch_date DATE, water_saved FLOAT); INSERT INTO conservation_initiatives (id, initiative, launch_date, water_saved) VALUES (1, 'Initiative1', '2021-04-01', 2000), (2, 'Initiative2', '2021-04-02', 3000), (3, 'Initiative3', '2021-04-03', 4000); | How many water conservation initiatives were launched in the month of April and what was the total water saved by those initiatives? | SELECT COUNT(initiative) as num_initiatives, SUM(water_saved) as total_water_saved FROM conservation_initiatives WHERE MONTH(launch_date) = 4; | gretelai_synthetic_text_to_sql |
CREATE TABLE cities (id INT, name VARCHAR(50)); INSERT INTO cities (id, name) VALUES (1, 'CityA'), (2, 'CityB'); CREATE TABLE projects (id INT, city_id INT, type VARCHAR(50), capacity INT); INSERT INTO projects (id, city_id, type, capacity) VALUES (1, 1, 'Solar', 1000), (2, 2, 'Wind', 2000), (3, 1, 'Geothermal', 1500); | What is the total renewable energy capacity by city and project type? | SELECT c.name, p.type, SUM(p.capacity) as total_capacity FROM cities c INNER JOIN projects p ON c.id = p.city_id GROUP BY c.name, p.type; | gretelai_synthetic_text_to_sql |
CREATE TABLE hotels (hotel_id INT, name TEXT, city TEXT, rating FLOAT); INSERT INTO hotels (hotel_id, name, city, rating) VALUES (1, 'Green Hotel', 'Paris', 4.3), (2, 'Eco Lodge', 'Paris', 4.6), (3, 'Hotel Roma', 'Rome', 4.1); | What is the average rating of all hotels in each city? | SELECT city, AVG(rating) FROM hotels GROUP BY city; | gretelai_synthetic_text_to_sql |
CREATE TABLE Teams (TeamID INT, TeamName VARCHAR(50), FemaleFanPercentage DECIMAL(5,2)); | Which teams have the highest and lowest percentage of fans who are female? | SELECT TeamName FROM Teams WHERE FemaleFanPercentage = (SELECT MAX(FemaleFanPercentage) FROM Teams) OR FemaleFanPercentage = (SELECT MIN(FemaleFanPercentage) FROM Teams); | gretelai_synthetic_text_to_sql |
CREATE TABLE DonationsByMonth (DonationID int, DonationAmount numeric, DonationMonth date); INSERT INTO DonationsByMonth (DonationID, DonationAmount, DonationMonth) VALUES (1, 100, '2022-01-01'), (2, 200, '2022-02-01'), (3, 50, '2022-01-01'); | What is the average donation amount per month for the past year? | SELECT AVG(DonationAmount) FROM DonationsByMonth WHERE DonationMonth >= DATEADD(year, -1, CURRENT_DATE) GROUP BY MONTH(DonationMonth) ORDER BY DonationMonth; | gretelai_synthetic_text_to_sql |
CREATE TABLE cyber_attacks (id INT, attack_type VARCHAR(30), attack_date DATE); INSERT INTO cyber_attacks (id, attack_type, attack_date) VALUES (1, 'Phishing', '2022-03-25'); INSERT INTO cyber_attacks (id, attack_type, attack_date) VALUES (2, 'Malware', '2022-02-03'); | Show the number of cyber attacks per type for the last month. | SELECT attack_type, COUNT(*) FROM cyber_attacks WHERE attack_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) GROUP BY attack_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE Indigenous_Farmers_3 (id INT PRIMARY KEY, name VARCHAR(50), age INT, location VARCHAR(50), tribe VARCHAR(50), pollination_technique VARCHAR(50)); INSERT INTO Indigenous_Farmers_3 (id, name, age, location, tribe, pollination_technique) VALUES (1, 'Sienna Miller', 40, 'Amazon Rainforest', 'Ashaninka', 'cross... | Identify indigenous farmers who use cross-pollination techniques and their respective produce. | SELECT if.name, if.pollination_technique, ip.product_name, ip.price FROM Indigenous_Farmers_3 if INNER JOIN Indigenous_Produce_3 ip ON if.id = ip.farmer_id WHERE if.pollination_technique = 'cross-pollination'; | gretelai_synthetic_text_to_sql |
CREATE TABLE founders (id INT, name TEXT, company_id INT); INSERT INTO founders (id, name, company_id) VALUES (1, 'Alex', 1); INSERT INTO founders (id, name, company_id) VALUES (2, 'Jamie', 2); INSERT INTO founders (id, name, company_id) VALUES (3, 'Taylor', 1); CREATE TABLE companies (id INT, industry TEXT); INSERT IN... | What is the number of unique founders in the retail sector? | SELECT COUNT(DISTINCT founders.name) FROM founders JOIN companies ON founders.company_id = companies.id WHERE companies.industry = 'Retail'; | gretelai_synthetic_text_to_sql |
CREATE TABLE MiningOperations (OperationID INT, MineName VARCHAR(100), OperationType VARCHAR(50), StartDate DATE, EndDate DATE); INSERT INTO MiningOperations (OperationID, MineName, OperationType, StartDate, EndDate) VALUES (1, 'Golden Mine', 'Exploration', '2015-01-01', '2015-12-31'), (2, 'Silver Ridge', 'Extraction',... | Calculate the percentage of waste generated by each mining operation. | SELECT ei.OperationID, ei.WasteGeneration, (ei.WasteGeneration / SUM(ei.WasteGeneration) OVER ()) * 100 as WastePercentage FROM EnvironmentalImpact ei; | gretelai_synthetic_text_to_sql |
CREATE TABLE donations (id INT, name TEXT, program TEXT, donation_amount DECIMAL(10,2), donation_date DATE); INSERT INTO donations (id, name, program, donation_amount, donation_date) VALUES (1, 'John Doe', 'Disaster Relief', 500.00, '2019-01-01'); INSERT INTO donations (id, name, program, donation_amount, donation_date... | Calculate the total amount donated by each program in the year 2019? | SELECT program, SUM(donation_amount) AS total_donations FROM donations WHERE YEAR(donation_date) = 2019 GROUP BY program; | gretelai_synthetic_text_to_sql |
CREATE TABLE ManufacturingSite(Id INT, Name VARCHAR(50), Location VARCHAR(50)); CREATE TABLE EnvironmentalImpactScore(Id INT, Score INT, ManufacturingSiteId INT, ScoreDate DATE); | What are the environmental impact scores for each manufacturing site, grouped by month? | SELECT m.Name, DATE_FORMAT(e.ScoreDate, '%Y-%m') AS Month, AVG(e.Score) AS AverageScore FROM EnvironmentalImpactScore e JOIN ManufacturingSite m ON e.ManufacturingSiteId = m.Id GROUP BY m.Name, Month; | gretelai_synthetic_text_to_sql |
CREATE TABLE donor_donations (donor_id INT, donation_year INT); INSERT INTO donor_donations (donor_id, donation_year) VALUES (1, 2021), (2, 2021), (3, 2021), (4, 2021), (5, 2021); | What is the average number of donations per unique donor in the past year? | SELECT AVG(cnt) AS avg_donations_per_donor FROM (SELECT donor_id, COUNT(*) AS cnt FROM donor_donations WHERE donation_year = YEAR(CURRENT_DATE) - 1 GROUP BY donor_id) subquery; | gretelai_synthetic_text_to_sql |
CREATE TABLE patients (id INT, name VARCHAR(50), age INT, gender VARCHAR(10), condition VARCHAR(50)); INSERT INTO patients (id, name, age, gender, condition) VALUES (3, 'Maria Garcia', 42, 'Female', 'Bipolar Disorder'); INSERT INTO patients (id, name, age, gender, condition) VALUES (4, 'Ahmed Khan', 30, 'Male', 'PTSD')... | What is the total number of patients and their average age, grouped by condition and gender? | SELECT condition, gender, COUNT(*) as num_patients, AVG(age) as avg_age FROM patients GROUP BY condition, gender; | gretelai_synthetic_text_to_sql |
CREATE TABLE algorithmic_fairness (id INT, model_name VARCHAR(50), sector VARCHAR(50), region VARCHAR(50), score FLOAT); INSERT INTO algorithmic_fairness VALUES (1, 'SafeDrive', 'Transportation', 'Africa', 0.78), (2, 'GreenTech', 'Energy', 'Africa', 0.85), (3, 'AutoML', 'Transportation', 'Europe', 0.91); | List the algorithmic fairness scores for AI models in the transportation sector in Africa. | SELECT model_name, score FROM algorithmic_fairness WHERE sector = 'Transportation' AND region = 'Africa'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Properties (id INT, price INT, city TEXT); INSERT INTO Properties (id, price, city) VALUES (1, 500000, 'Seattle'), (2, 400000, 'Seattle'), (3, 700000, 'Denver'), (4, 1000000, 'Seattle'); | What is the minimum and maximum property price in the city of Seattle? | SELECT MIN(price) AS min_price, MAX(price) AS max_price FROM Properties WHERE city = 'Seattle'; | gretelai_synthetic_text_to_sql |
CREATE TABLE waste_generation_trend (country VARCHAR(50), year INT, person_day FLOAT, waste_amount FLOAT); INSERT INTO waste_generation_trend (country, year, person_day, waste_amount) VALUES ('India', 2018, 1.0, 120.5), ('India', 2019, 1.0, 130.2), ('India', 2020, 1.0, 140.0); | What is the waste generation trend in gram per person per day for India from 2018 to 2020? | SELECT year, waste_amount FROM waste_generation_trend WHERE country = 'India' ORDER BY year; | gretelai_synthetic_text_to_sql |
CREATE TABLE ports (port_id INT, port_name VARCHAR(100), country VARCHAR(100)); INSERT INTO ports (port_id, port_name, country) VALUES (1, 'Port of Los Angeles', 'USA'); CREATE TABLE cargo_ships (ship_id INT, ship_name VARCHAR(100), port_id INT, waiting_time INT); INSERT INTO cargo_ships (ship_id, ship_name, port_id, w... | What is the average waiting time of cargo ships from African countries at the Port of Los Angeles? | SELECT AVG(waiting_time) FROM cargo_ships WHERE country = 'Africa'; | gretelai_synthetic_text_to_sql |
CREATE TABLE outcomes (id INT, approach TEXT, outcome TEXT, region TEXT); INSERT INTO outcomes (id, approach, outcome, region) VALUES (1, 'CBT', 'Improved', 'North America'), (2, 'DBT', 'Improved', 'North America'), (3, 'EMDR', 'Improved', 'North America'), (4, 'Medication', 'No Improvement', 'North America'), (5, 'Med... | List the mental health treatment approaches with the least number of associated patient outcomes in North America. | SELECT approach, MIN(outcome) as least_outcome FROM outcomes WHERE region = 'North America' GROUP BY approach; | gretelai_synthetic_text_to_sql |
CREATE TABLE transactions (id INT, product TEXT, region TEXT, organic BOOLEAN); INSERT INTO transactions (id, product, region, organic) VALUES (1, 'Product 1', 'Northeast', true), (2, 'Product 2', 'Southeast', false); | Find the number of transactions involving 'organic' produce in the 'Northeast' region. | SELECT COUNT(*) FROM transactions WHERE region = 'Northeast' AND organic = true; | gretelai_synthetic_text_to_sql |
CREATE TABLE artists (artist_id INT, name VARCHAR(50), country VARCHAR(50), genre VARCHAR(50), birth_year INT); | List the artists in the 'artists' table, grouped by their country of origin. | SELECT country, COUNT(*) as artist_count FROM artists GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE flight_safety (airline VARCHAR(50), region VARCHAR(50), flight_hours INT, year INT); INSERT INTO flight_safety (airline, region, flight_hours, year) VALUES ('Lufthansa', 'European Union', 120000, 2019), ('Ryanair', 'European Union', 150000, 2019); | What is the maximum number of flight hours for commercial airlines in the European Union in 2019? | SELECT MAX(flight_hours) FROM flight_safety WHERE region = 'European Union' AND year = 2019; | gretelai_synthetic_text_to_sql |
CREATE TABLE posts (id INT, user_id INT, title VARCHAR(100), content TEXT, created_at TIMESTAMP); INSERT INTO posts (id, user_id, title, content, created_at) VALUES (3, 3, 'Bienvenido', 'Hola a todos!', '2021-01-03 12:00:00'), (4, 4, 'Olá Mundo', 'Olá, mundo virtual!', '2021-01-04 13:00:00'); | Retrieve the first and last post of each user. | SELECT p.*, LEAD(p.id, 1) OVER (PARTITION BY p.user_id ORDER BY p.created_at) as next_post_id, LAG(p.id, 1) OVER (PARTITION BY p.user_id ORDER BY p.created_at) as prev_post_id FROM posts p; | gretelai_synthetic_text_to_sql |
CREATE TABLE Factories (id INT, factory_id INT, country VARCHAR(255), type VARCHAR(255)); INSERT INTO Factories (id, factory_id, country, type) VALUES (1, 20001, 'India', 'Cutting'), (2, 20002, 'Bangladesh', 'Sewing'), (3, 20003, 'India', 'Finishing'); | How many garment factories are there in India and Bangladesh? | SELECT COUNT(*) FROM Factories WHERE country IN ('India', 'Bangladesh'); | gretelai_synthetic_text_to_sql |
CREATE TABLE north_programs (region VARCHAR(255), program VARCHAR(255)); INSERT INTO north_programs (region, program) VALUES ('North', 'Childhood Immunization'); INSERT INTO north_programs (region, program) VALUES ('North', 'Flu Vaccination'); CREATE TABLE south_programs (region VARCHAR(255), program VARCHAR(255)); INS... | What are the total number of immunization programs in the North American and South American regions? | SELECT COUNT(*) FROM north_programs UNION ALL SELECT COUNT(*) FROM south_programs; | gretelai_synthetic_text_to_sql |
CREATE TABLE events (event_id INT, event_name VARCHAR(50), year INT); INSERT INTO events (event_id, event_name, year) VALUES (1, 'FIFA World Cup', 2022), (2, 'NBA Finals', 2023), (3, 'Super Bowl', 2022); | Insert new records of events that happened in 2024 | INSERT INTO events (event_id, event_name, year) SELECT 4, 'Wimbledon', 2024 WHERE NOT EXISTS (SELECT 1 FROM events WHERE year = 2024); INSERT INTO events (event_id, event_name, year) SELECT 5, 'Tour de France', 2024 WHERE NOT EXISTS (SELECT 1 FROM events WHERE year = 2024 AND event_name = 'Tour de France'); | gretelai_synthetic_text_to_sql |
CREATE TABLE defense_diplomacy (id INT PRIMARY KEY, name VARCHAR(255), country VARCHAR(255), city VARCHAR(255)); | Insert a new record into the 'defense_diplomacy' table with the following data: 'Defense Attaché', 'France', 'Paris' | INSERT INTO defense_diplomacy (name, country, city) VALUES ('Defense Attaché', 'France', 'Paris'); | gretelai_synthetic_text_to_sql |
CREATE TABLE disaster_response_training (session_id INT, organization_id INT, affected_region VARCHAR(20), attendees INT, training_date DATE); INSERT INTO disaster_response_training (session_id, organization_id, affected_region, attendees, training_date) VALUES (1201, 1001, 'Asia', 25, '2022-02-03'), (1202, 1001, 'Afri... | How many disaster response training sessions were conducted by each organization for each affected region, and what was the total number of attendees in 2022? | SELECT organization_id, affected_region, COUNT(*) as training_sessions_count, SUM(attendees) as total_attendees FROM disaster_response_training WHERE EXTRACT(YEAR FROM training_date) = 2022 GROUP BY organization_id, affected_region; | gretelai_synthetic_text_to_sql |
CREATE TABLE Vessels (VesselID INT, VesselName VARCHAR(50));CREATE TABLE CargoLoads (LoadID INT, VesselID INT, LoadLocation VARCHAR(50), LoadDate DATE); INSERT INTO Vessels (VesselID, VesselName) VALUES (1, 'VesselA'), (2, 'VesselB'), (3, 'VesselC'), (4, 'VesselD'); INSERT INTO CargoLoads (LoadID, VesselID, LoadLocatio... | Which vessels have not loaded cargo in any Asian countries? | SELECT Vessels.VesselName FROM Vessels WHERE Vessels.VesselID NOT IN (SELECT CargoLoads.VesselID FROM CargoLoads WHERE CargoLoads.LoadLocation LIKE 'Asia%') GROUP BY Vessels.VesselName; | gretelai_synthetic_text_to_sql |
CREATE TABLE rural_infrastructure (project_type VARCHAR(255), project_name VARCHAR(255), cost INT); INSERT INTO rural_infrastructure (project_type, project_name, cost) VALUES ('Bridge', 'San Juan River Bridge', 5000000), ('Road', 'Palo Alto Road', 3000000); | Show the total cost of rural infrastructure projects broken down by project type in the 'rural_infrastructure' table. | SELECT project_type, SUM(cost) FROM rural_infrastructure GROUP BY project_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE military_innovations (id INT, innovation VARCHAR(255), type VARCHAR(255)); CREATE TABLE technology_providers (id INT, provider VARCHAR(255), specialization VARCHAR(255)); | List all military innovations and their corresponding technology providers. | SELECT mi.innovation, tp.provider FROM military_innovations mi INNER JOIN technology_providers tp ON mi.id = tp.id; | gretelai_synthetic_text_to_sql |
CREATE TABLE hospitals (hospital_id INT, hospital_name TEXT, beds INT, rural BOOLEAN, state_id INT); INSERT INTO hospitals (hospital_id, hospital_name, beds, rural, state_id) VALUES (1, 'Hospital A', 100, true, 1); CREATE TABLE states (state_id INT, state TEXT); INSERT INTO states (state_id, state) VALUES (1, 'Alabama'... | Identify the top 5 states with the highest number of rural hospitals, showing the state name and the count of rural hospitals. | SELECT states.state, COUNT(hospitals.hospital_id) hospital_count FROM hospitals JOIN states ON hospitals.state_id = states.state_id WHERE hospitals.rural = true GROUP BY states.state ORDER BY hospital_count DESC LIMIT 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE district (id INT, name VARCHAR); INSERT INTO district (id, name) VALUES (1, 'District 1'), (2, 'District 2'), (3, 'District 3'), (4, 'District 4'), (5, 'District 5'); CREATE TABLE participation (id INT, district_id INT, event_id INT, date DATE); INSERT INTO participation (id, district_id, event_id, date) V... | What is the average number of public participation events attended by citizens in each district for the year 2021? | SELECT district_id, AVG(total_events) as avg_events FROM (SELECT district_id, event_id, COUNT(*) as total_events FROM participation WHERE date >= '2021-01-01' AND date < '2022-01-01' GROUP BY district_id, event_id) as subquery GROUP BY district_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE Warehouse (name varchar(20), pallets_handled int, handling_date date); INSERT INTO Warehouse (name, pallets_handled, handling_date) VALUES ('Warehouse A', 50, '2022-01-31'), ('Warehouse B', 80, '2022-01-31'); | How many pallets were handled by each warehouse on the 'last day of each month' in '2022'? | SELECT name, SUM(pallets_handled) FROM (SELECT name, pallets_handled, handling_date, LAG(handling_date) OVER (PARTITION BY name ORDER BY handling_date) AS prev_handling_date FROM Warehouse WHERE YEAR(handling_date) = 2022 AND DAY(LAST_DAY(handling_date)) = DAY(handling_date)) subquery WHERE handling_date <> prev_handli... | gretelai_synthetic_text_to_sql |
CREATE TABLE eia (id INT, process TEXT, location TEXT, assessment_date DATE); INSERT INTO eia (id, process, location, assessment_date) VALUES (1, 'Acid Neutralization', 'Texas', '2021-06-15'), (2, 'Solvent Recovery', 'Texas', '2021-02-20'); | How many environmental impact assessments were conducted in the last 6 months for chemical manufacturing processes in Texas? | SELECT COUNT(*) FROM eia WHERE location = 'Texas' AND assessment_date >= DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH); | gretelai_synthetic_text_to_sql |
CREATE TABLE mobile_subscribers (id INT, subscriber_name VARCHAR(50), state VARCHAR(20), join_date DATE); | How many new mobile subscribers joined in each state in the first quarter of 2022? | SELECT state, COUNT(*) FROM mobile_subscribers WHERE YEAR(join_date) = 2022 AND QUARTER(join_date) = 1 GROUP BY state; | gretelai_synthetic_text_to_sql |
CREATE TABLE chicago_units(id INT, address VARCHAR(50), wheelchair_access BOOLEAN, affordable BOOLEAN); INSERT INTO chicago_units VALUES (1, '123 Main St', true, true), (2, '456 Elm St', false, true); CREATE TABLE chicago_neighborhoods(id INT, name VARCHAR(30), unit_id INT); INSERT INTO chicago_neighborhoods VALUES (1,... | Display the names of neighborhoods in Chicago that have both wheelchair-accessible and affordable units. | SELECT chicago_neighborhoods.name FROM chicago_neighborhoods JOIN chicago_units ON chicago_neighborhoods.unit_id = chicago_units.id WHERE chicago_units.wheelchair_access = true AND chicago_units.affordable = true GROUP BY name HAVING COUNT(DISTINCT chicago_units.id) > 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE mines (id INT, name TEXT, location TEXT, total_safety_incidents INT); INSERT INTO mines (id, name, location, total_safety_incidents) VALUES (1, 'Golden Mine', 'Colorado, USA', 50), (2, 'Silver Ridge', 'Nevada, USA', 60), (3, 'Bronze Basin', 'Utah, USA', 40); | What is the total number of safety incidents at each mine? | SELECT name, SUM(total_safety_incidents) FROM mines GROUP BY name | gretelai_synthetic_text_to_sql |
CREATE TABLE Satisfaction (Service VARCHAR(20), Region VARCHAR(20), Quarter INT, Year INT, Score INT); INSERT INTO Satisfaction (Service, Region, Quarter, Year, Score) VALUES ('ServiceB', 'RegionC', 2, 2021, 85); | What was the average citizen satisfaction score for 'ServiceB' in 'RegionC' in Q2 of 2021? | SELECT AVG(Score) FROM Satisfaction WHERE Service = 'ServiceB' AND Region = 'RegionC' AND Quarter = 2 AND Year = 2021; | gretelai_synthetic_text_to_sql |
CREATE TABLE volunteers (id INT, volunteer_name TEXT, region TEXT, hours INT); INSERT INTO volunteers (id, volunteer_name, region, hours) VALUES (10, 'Jasmine', 'Asia', 50), (11, 'Kevin', 'Europe', 75), (12, 'Luna', 'Asia', 100); | What was the total number of volunteers in Asia in 2021? | SELECT COUNT(*) FROM volunteers WHERE region = 'Asia' AND YEAR(volunteer_date) = 2021; | gretelai_synthetic_text_to_sql |
CREATE TABLE articles (id INT PRIMARY KEY, title TEXT, category TEXT, publication_date DATE, word_count INT, author_id INT); | What is the total number of articles published in the "articles" table for each month in the year 2022? | SELECT EXTRACT(MONTH FROM publication_date) AS month, COUNT(*) AS articles_per_month FROM articles WHERE EXTRACT(YEAR FROM publication_date) = 2022 GROUP BY month ORDER BY month; | gretelai_synthetic_text_to_sql |
CREATE TABLE space_missions (mission_name TEXT, launch_agency TEXT, launch_year INT); INSERT INTO space_missions (mission_name, launch_agency, launch_year) VALUES ('Spirit', 'NASA', 2004); | List all space agencies that have launched space missions in the space_missions table. | SELECT DISTINCT launch_agency FROM space_missions; | gretelai_synthetic_text_to_sql |
CREATE TABLE Employees(id INT, department VARCHAR(20), position VARCHAR(20), salary INT, gender VARCHAR(10), full_time BOOLEAN); | What is the maximum salary paid to full-time employees in the Excavation department? | SELECT MAX(salary) FROM Employees WHERE department = 'Excavation' AND full_time = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE prop_type (property_id INT, area VARCHAR(20), co_ownership BOOLEAN); INSERT INTO prop_type (property_id, area, co_ownership) VALUES (1, 'inclusive', TRUE); | What is the total number of co-ownership properties in the 'inclusive' area? | SELECT COUNT(*) FROM prop_type WHERE area = 'inclusive' AND co_ownership = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE Genre (id INT, genre VARCHAR(255)); CREATE TABLE Sales (id INT, genre_id INT, year INT, revenue INT); | What is the total revenue for each genre of music in 2021? | SELECT G.genre, S.year, SUM(S.revenue) as total_revenue FROM Genre G INNER JOIN Sales S ON G.id = S.genre_id WHERE S.year = 2021 GROUP BY G.genre, S.year; | gretelai_synthetic_text_to_sql |
CREATE TABLE smart_city_tech (tech_type VARCHAR(255), city VARCHAR(255)); | Identify the top 5 most common types of smart city technologies implemented in the world. | SELECT tech_type, COUNT(*) as num_tech FROM smart_city_tech GROUP BY tech_type ORDER BY num_tech DESC LIMIT 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE threat_scores (ip_address VARCHAR(20), threat_level VARCHAR(20), threat_score INT); INSERT INTO threat_scores (ip_address, threat_level, threat_score) VALUES ('192.168.1.1', 'low', 10), ('10.0.0.1', 'high', 90), ('172.16.0.1', 'medium', 50); | What is the average threat score for each threat level? | SELECT threat_level, AVG(threat_score) as avg_threat_score FROM threat_scores GROUP BY threat_level; | gretelai_synthetic_text_to_sql |
CREATE TABLE vehicle_safety_testing (vehicle_id INT, vehicle_name VARCHAR(50), horsepower INT, safety_rating FLOAT, country VARCHAR(50)); CREATE TABLE electric_vehicle_adoption (country VARCHAR(50), adoption_rate FLOAT); | What is the total horsepower of electric vehicles grouped by country in the vehicle_safety_testing and electric_vehicle_adoption tables? | SELECT v.country, SUM(v.horsepower) AS total_horsepower FROM vehicle_safety_testing v INNER JOIN electric_vehicle_adoption e ON v.country = e.country WHERE v.vehicle_type = 'Electric' GROUP BY v.country; | gretelai_synthetic_text_to_sql |
CREATE TABLE Claim (ClaimID INT, ClaimDate DATE, ClaimAmount DECIMAL(10,2)); INSERT INTO Claim VALUES (1, '2021-01-01', 5000), (2, '2021-02-01', 3000), (3, '2021-04-01', 7000), (4, '2021-05-01', 8000), (5, '2021-06-01', 9000); | Determine the total claims paid per month for the past 12 months. | SELECT DATEPART(YEAR, ClaimDate) as Year, DATEPART(MONTH, ClaimDate) as Month, SUM(ClaimAmount) as TotalClaimsPaid FROM Claim WHERE ClaimDate >= DATEADD(YEAR, -1, GETDATE()) GROUP BY DATEPART(YEAR, ClaimDate), DATEPART(MONTH, ClaimDate) ORDER BY Year, Month; | gretelai_synthetic_text_to_sql |
CREATE TABLE Parks( park_id INT PRIMARY KEY, name VARCHAR(255), location VARCHAR(255), area FLOAT, created_date DATE); | Create a table named 'Parks' | CREATE TABLE Parks( park_id INT PRIMARY KEY, name VARCHAR(255), location VARCHAR(255), area FLOAT, created_date DATE); | gretelai_synthetic_text_to_sql |
CREATE TABLE accounts (account_id INT, account_type TEXT); INSERT INTO accounts (account_id, account_type) VALUES (1, 'High Value'); INSERT INTO accounts (account_id, account_type) VALUES (2, 'Premium'); INSERT INTO accounts (account_id, account_type) VALUES (3, 'Standard'); CREATE TABLE transactions (transaction_id IN... | Delete all transactions associated with account type 'Standard'. | DELETE FROM transactions WHERE transactions.account_id IN (SELECT accounts.account_id FROM accounts WHERE accounts.account_type = 'Standard'); | gretelai_synthetic_text_to_sql |
CREATE TABLE diagnoses (id INT, patient_id INT, condition VARCHAR(255)); CREATE TABLE patients (id INT, age INT, country VARCHAR(255)); INSERT INTO diagnoses (id, patient_id, condition) VALUES (1, 1, 'Depression'), (2, 2, 'Anxiety'), (3, 3, 'Bipolar'), (4, 5, 'Depression'); INSERT INTO patients (id, age, country) VALUE... | What is the average age of patients diagnosed with depression in India? | SELECT AVG(patients.age) FROM patients JOIN diagnoses ON patients.id = diagnoses.patient_id WHERE diagnoses.condition = 'Depression' AND patients.country = 'India'; | gretelai_synthetic_text_to_sql |
CREATE TABLE project_timeline (event_id INT, permit_id INT, event_type TEXT, start_date DATE, end_date DATE); INSERT INTO project_timeline (event_id, permit_id, event_type, start_date, end_date) VALUES (7, 7, 'Foundation', '2021-01-01', '2021-03-05'); | What are the construction event types and their start dates for permits with sustainable practices installed after January 1st, 2020? | SELECT event_type, start_date FROM project_timeline pt JOIN building_permits bp ON pt.permit_id = bp.permit_id JOIN sustainable_practices sp ON bp.permit_id = sp.permit_id WHERE sp.installation_date > '2020-01-01'; | gretelai_synthetic_text_to_sql |
USE rural_development; CREATE TABLE IF NOT EXISTS community_development (id INT, name VARCHAR(255), status VARCHAR(255), PRIMARY KEY (id)); INSERT INTO community_development (id, name, status) VALUES (1, 'Community Health Center', 'in progress'); | Update the status of the 'Community Health Center' initiative to 'completed' in the 'community_development' table. | UPDATE community_development SET status = 'completed' WHERE name = 'Community Health Center'; | gretelai_synthetic_text_to_sql |
CREATE TABLE activities (activity_id INT, activity_name TEXT, country TEXT, category TEXT); INSERT INTO activities (activity_id, activity_name, country, category) VALUES (1, 'Eco-Hiking', 'Japan', 'Sustainable Tourism'), (2, 'Cultural Cooking Class', 'Japan', 'Sustainable Tourism'); | How many sustainable tourism activities are available in Japan? | SELECT COUNT(*) FROM activities WHERE country = 'Japan' AND category = 'Sustainable Tourism'; | gretelai_synthetic_text_to_sql |
CREATE TABLE climate_finance (country VARCHAR(50), year INT, amount FLOAT); INSERT INTO climate_finance (country, year, amount) VALUES ('USA', 2020, 12000000), ('China', 2020, 15000000), ('India', 2020, 8000000); | What is the total amount of climate finance provided by each country in 2020? | SELECT country, SUM(amount) FROM climate_finance WHERE year = 2020 GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE ship (id INT PRIMARY KEY, name VARCHAR(50), type VARCHAR(50), length INT, port_id INT, FOREIGN KEY (port_id) REFERENCES port(id)); INSERT INTO ship VALUES (1, 'Sea Giant', 'Container', 300, 1); INSERT INTO ship VALUES (2, 'Ocean Titan', 'Tanker', 400, 2); CREATE TABLE cargo (id INT PRIMARY KEY, ship_id INT... | What is the maximum cargo weight for each type of ship? | SELECT s.type as ship_type, MAX(c.weight) as max_weight FROM cargo c JOIN ship s ON c.ship_id = s.id GROUP BY s.type; | gretelai_synthetic_text_to_sql |
CREATE TABLE salinity (year INT, avg_salinity FLOAT); | Display the change in ocean salinity levels for each year compared to the previous year. | SELECT t1.year, t1.avg_salinity - t2.avg_salinity AS salinity_change FROM salinity t1 INNER JOIN salinity t2 ON t1.year = t2.year + 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE attorneys (id INT, client_id INT); INSERT INTO attorneys (id, client_id) VALUES (1, 1), (2, 1), (3, 2), (4, 3), (5, 3), (6, 3); | List the unique client IDs and the number of cases for each attorney, sorted by the number of cases in descending order. | SELECT attorney_id, COUNT(*) AS num_cases FROM cases GROUP BY attorney_id ORDER BY num_cases DESC; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA if not exists biotech; CREATE TABLE if not exists biotech.investment (id INT PRIMARY KEY, type VARCHAR(255), country VARCHAR(255), amount FLOAT); INSERT INTO biotech.investment (id, type, country, amount) VALUES (1, 'Biosensor Technology Development', 'Germany', 1500000); INSERT INTO biotech.investment (i... | What is the average investment in biosensor technology development in Germany? | SELECT AVG(amount) FROM biotech.investment WHERE country = 'Germany' AND type = 'Biosensor Technology Development'; | gretelai_synthetic_text_to_sql |
CREATE TABLE sectors (sector_id INT, sector VARCHAR(20));CREATE TABLE worker_salaries (worker_id INT, sector_id INT, salary INT); | What is the maximum salary paid to a worker in the 'renewable energy' sector? | SELECT MAX(worker_salaries.salary) FROM worker_salaries INNER JOIN sectors ON worker_salaries.sector_id = sectors.sector_id WHERE sectors.sector = 'renewable energy'; | gretelai_synthetic_text_to_sql |
CREATE TABLE reputable_news (article_id INT, author_name VARCHAR(50), author_age INT, word_count INT, publication_date DATE); | What is the average word count of articles in 'reputable_news' table for each author who is over 40 years old? | SELECT author_name, AVG(word_count) FROM reputable_news WHERE author_age > 40 GROUP BY author_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE Venues (VenueID INT, Name VARCHAR(255), Capacity INT, Country VARCHAR(255)); INSERT INTO Venues VALUES (1, 'Madison Square Garden', 20000, 'USA'); INSERT INTO Venues VALUES (2, 'O2 Arena', 20000, 'UK'); INSERT INTO Venues VALUES (3, 'Budokan', 11000, 'Japan'); | Which country has the most concert venues in our database? | SELECT Country, COUNT(*) FROM Venues GROUP BY Country ORDER BY COUNT(*) DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE programs(id INT, name TEXT, budget FLOAT); | List the programs that have a higher total budget compared to the total budget for all programs combined, and their respective budgets. | SELECT programs.name, programs.budget FROM programs WHERE programs.budget > (SELECT SUM(budget) FROM programs) - programs.budget; | gretelai_synthetic_text_to_sql |
CREATE TABLE legal_technology_grants (id INT, state VARCHAR(2), grant_date DATE); | How many legal technology grants have been awarded in California in the past 5 years? | SELECT COUNT(*) FROM legal_technology_grants WHERE state = 'CA' AND grant_date >= DATE_SUB(CURRENT_DATE, INTERVAL 5 YEARS); | gretelai_synthetic_text_to_sql |
CREATE TABLE Defense_Projects (project_id INT, project_name VARCHAR(255), region VARCHAR(255), risk_score FLOAT); INSERT INTO Defense_Projects (project_id, project_name, region, risk_score) VALUES (1, 'Project A', 'Asia-Pacific', 75), (2, 'Project B', 'Asia-Pacific', 80), (3, 'Project C', 'Europe', 60), (4, 'Project D'... | What is the geopolitical risk score for each defense project in the Asia-Pacific region, ranked by score? | SELECT project_name, region, risk_score, RANK() OVER (ORDER BY risk_score DESC) AS risk_rank FROM Defense_Projects WHERE region = 'Asia-Pacific'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Donations (DonationID INT, Cause VARCHAR(50), Amount DECIMAL(10,2)); INSERT INTO Donations (DonationID, Cause, Amount) VALUES (1, 'Education', 2000), (2, 'Health', 3000), (3, 'Education', 1000), (4, 'Environment', 4000); | What is the total donation amount for each cause? | SELECT Cause, SUM(Amount) as TotalDonation FROM Donations GROUP BY Cause; | gretelai_synthetic_text_to_sql |
CREATE TABLE central_fish_farm (date DATE, dissolved_oxygen FLOAT); | What is the average dissolved oxygen level for each month in 2021 at the Central Fish Farm? | SELECT EXTRACT(MONTH FROM date) AS month, AVG(dissolved_oxygen) AS avg_dissolved_oxygen FROM central_fish_farm WHERE date BETWEEN '2021-01-01' AND '2021-12-31' GROUP BY month; | gretelai_synthetic_text_to_sql |
CREATE TABLE gadolinium_prices (country VARCHAR(20), price DECIMAL(5,2), year INT); INSERT INTO gadolinium_prices (country, price, year) VALUES ('Indonesia', 75.00, 2018), ('Indonesia', 78.00, 2019), ('Indonesia', 80.00, 2020); | What was the highest price of gadolinium in Indonesia? | SELECT MAX(price) FROM gadolinium_prices WHERE country = 'Indonesia'; | gretelai_synthetic_text_to_sql |
CREATE TABLE state_efficiency (state VARCHAR(50), rating FLOAT); INSERT INTO state_efficiency (state, rating) VALUES ('CA', 2.1), ('TX', 1.9), ('NY', 2.4); | What are the energy efficiency ratings for each state? | SELECT state, rating FROM state_efficiency; | gretelai_synthetic_text_to_sql |
CREATE TABLE MiningSites (SiteID INT, SiteName VARCHAR(50), Location VARCHAR(50)); INSERT INTO MiningSites (SiteID, SiteName, Location) VALUES (1, 'Site A', 'New York'), (2, 'Site B', 'Ohio'), (3, 'Site C', 'Alberta'); CREATE TABLE Employees (EmployeeID INT, FirstName VARCHAR(50), LastName VARCHAR(50), JobTitle VARCHAR... | Determine the total number of employees and contractors by mining site and their respective roles | SELECT s.SiteName, s.Location, e.EmploymentType, COUNT(DISTINCT e.EmployeeID) as RoleCount FROM Employees e INNER JOIN MiningSites s ON e.SiteID = s.SiteID GROUP BY s.SiteID, e.EmploymentType; | gretelai_synthetic_text_to_sql |
CREATE TABLE Artwork_Exhibition (artwork_id INT, artwork_name VARCHAR(255), gallery_name VARCHAR(255), artist_name VARCHAR(255)); | Which artworks by 'Claude Monet' were exhibited in the 'Paris Art Gallery'? | SELECT artwork_name FROM Artwork_Exhibition WHERE artist_name = 'Claude Monet' AND gallery_name = 'Paris Art Gallery'; | gretelai_synthetic_text_to_sql |
CREATE TABLE social_good (id INT, industry VARCHAR(20), projects INT, organizations INT); INSERT INTO social_good (id, industry, projects, organizations) VALUES (1, 'finance', 16, 4), (2, 'finance', 10, 2), (3, 'finance', 20, 5); | What is the average number of projects per organization working on social good in the finance industry? | SELECT AVG(projects/organizations) FROM social_good WHERE industry = 'finance'; | gretelai_synthetic_text_to_sql |
CREATE TABLE residents (county TEXT, age INTEGER); INSERT INTO residents (county, age) VALUES ('Ozarks', 38), ('Ozarks', 42), ('Ozarks', 45), ('Ozarks', 50); | What is the average age of residents in rural county 'Ozarks'? | SELECT AVG(age) FROM residents WHERE county = 'Ozarks'; | gretelai_synthetic_text_to_sql |
CREATE TABLE nhl_goalies (goalie TEXT, team TEXT, saves INT); INSERT INTO nhl_goalies (goalie, team, saves) VALUES ('John Smith', 'Canadiens', 52), ('Mike Johnson', 'Blackhawks', 49), ('Tim Jones', 'Maple Leafs', 50); | What is the highest number of saves in a game by a goalkeeper in the 2021-2022 NHL season? | SELECT goalie, MAX(saves) as max_saves FROM nhl_goalies; | gretelai_synthetic_text_to_sql |
CREATE TABLE movies (id INT, title VARCHAR(50), director VARCHAR(50), budget DECIMAL(10,2)); INSERT INTO movies (id, title, director, budget) VALUES (1, 'MovieE', 'DirectorA', 25000000), (2, 'MovieF', 'DirectorB', 18000000); | List all unique directors who have directed movies with budgets over $20M. | SELECT DISTINCT director FROM movies WHERE budget > 20000000; | gretelai_synthetic_text_to_sql |
CREATE TABLE players (id INT, name VARCHAR(100), game_id INT, high_score INT); CREATE TABLE games (id INT, name VARCHAR(100)); INSERT INTO players (id, name, game_id, high_score) VALUES (1, 'Jane Doe', 1, 1500); INSERT INTO players (id, name, game_id, high_score) VALUES (2, 'John Doe', 1, 1200); INSERT INTO players (id... | Show the top 5 players with the highest scores in game 'Fortnite' | SELECT players.name, players.high_score FROM players JOIN games ON players.game_id = games.id WHERE games.name = 'Fortnite' ORDER BY players.high_score DESC LIMIT 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE teams (team_id INT, team_name TEXT, league TEXT, sport TEXT); INSERT INTO teams (team_id, team_name, league, sport) VALUES (1, 'All Blacks', 'Rugby Championship', 'Rugby Union'); CREATE TABLE games (game_id INT, team_id INT, tries INT, season_year INT); INSERT INTO games (game_id, team_id, tries, season_ye... | What is the total number of tries scored by the 'All Blacks' rugby union team in the 'Rugby Championship'? | SELECT SUM(tries) FROM games WHERE team_id = (SELECT team_id FROM teams WHERE team_name = 'All Blacks') AND league = 'Rugby Championship'; | gretelai_synthetic_text_to_sql |
CREATE TABLE cultural_sites (id INT, name TEXT, region TEXT, country TEXT); INSERT INTO cultural_sites (id, name, region, country) VALUES (1, 'Alhambra', 'Andalusia', 'Spain'), (2, 'Prado Museum', 'Madrid', 'Spain'), (3, 'Sagrada Familia', 'Catalonia', 'Spain'); | What is the maximum number of cultural heritage sites in a single region in Spain? | SELECT MAX(site_count) FROM (SELECT region, COUNT(*) AS site_count FROM cultural_sites WHERE country = 'Spain' GROUP BY region) AS subquery; | gretelai_synthetic_text_to_sql |
CREATE TABLE Budget (Year INT, Region VARCHAR(255), Department VARCHAR(255), Amount DECIMAL(10,2)); INSERT INTO Budget (Year, Region, Department, Amount) VALUES (2019, 'Northeast', 'Healthcare', 900000.00), (2019, 'Southeast', 'Healthcare', 1000000.00), (2019, 'Southwest', 'Healthcare', 1100000.00), (2019, 'Northwest',... | What was the total budget allocated for healthcare in the year 2019 across all regions? | SELECT SUM(Amount) FROM Budget WHERE Year = 2019 AND Department = 'Healthcare'; | gretelai_synthetic_text_to_sql |
CREATE TABLE workouts (workout_id INT, member_id INT, distance FLOAT, age INT, gender VARCHAR(10)); INSERT INTO workouts (workout_id, member_id, distance, age, gender) VALUES (1, 1, 2.5, 25, 'Female'), (2, 2, 3.2, 32, 'Male'), (3, 3, 1.8, 28, 'Female'); | Identify the most common gender for each age group in workouts | SELECT FLOOR(age / 10) * 10 as age_group, gender, COUNT(*) as count FROM workouts GROUP BY age_group, gender ORDER BY age_group, count DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE innovation (id INT PRIMARY KEY AUTO_INCREMENT, company_id INT, trend VARCHAR(255), impact FLOAT, innovation_date DATE); | Delete innovation trends older than 2021 for "GreenTech Solutions" | DELETE FROM innovation WHERE innovation_date < '2021-01-01' AND company_id IN (SELECT id FROM company WHERE name = 'GreenTech Solutions'); | gretelai_synthetic_text_to_sql |
CREATE TABLE Artworks (ArtworkID INT, Title VARCHAR(50), Gallery VARCHAR(50), ArtistID INT); INSERT INTO Artworks (ArtworkID, Title, Gallery, ArtistID) VALUES (1, 'Starry Night', 'ImpressionistGallery', 1); INSERT INTO Artworks (ArtworkID, Title, Gallery, ArtistID) VALUES (2, 'Sunflowers', 'ImpressionistGallery', 1); I... | Which artists have more than 3 artworks in the database? | SELECT ArtistID FROM Artworks GROUP BY ArtistID HAVING COUNT(*) > 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE member_activities (member_id INT, activity_type VARCHAR(50)); INSERT INTO member_activities (member_id, activity_type) VALUES (1, 'cardio'), (2, 'cardio'), (3, 'strength'), (4, 'cardio'), (5, 'strength'), (6, 'yoga'), (7, 'cardio'), (8, 'strength'), (9, 'yoga'), (10, 'cardio'); | List all members who have attended 'cardio' and 'strength' classes but not 'yoga' classes. | SELECT member_id FROM member_activities WHERE activity_type IN ('cardio', 'strength') AND member_id NOT IN (SELECT member_id FROM member_activities WHERE activity_type = 'yoga'); | gretelai_synthetic_text_to_sql |
CREATE TABLE word_count_lang (id INT PRIMARY KEY, article_id INT, language VARCHAR(50), word_count INT, FOREIGN KEY (article_id) REFERENCES articles(id)); | What is the distribution of article word counts for a specific language? | SELECT language, word_count, COUNT(*) as total FROM word_count_lang GROUP BY language, word_count; | gretelai_synthetic_text_to_sql |
CREATE TABLE TraditionalArt (ArtistID int, ArtPieceID int, ArtName varchar(50)); INSERT INTO TraditionalArt (ArtistID, ArtPieceID, ArtName) VALUES (1, 101, 'Pottery'), (1, 102, 'Woven Rug'), (2, 103, 'Calligraphy'), (3, 104, 'Dance Performance'); | What is the average number of art pieces per artist in the TraditionalArt table? | SELECT AVG(ArtCount) FROM (SELECT ArtistID, COUNT(ArtPieceID) AS ArtCount FROM TraditionalArt GROUP BY ArtistID) AS ArtSubquery; | gretelai_synthetic_text_to_sql |
CREATE TABLE socially_responsible_lending (id INT PRIMARY KEY, loan_amount DECIMAL(10, 2), lending_date DATE); | What is the average loan amount for socially responsible lending in Q1 2022? | SELECT AVG(loan_amount) FROM socially_responsible_lending WHERE lending_date BETWEEN '2022-01-01' AND '2022-03-31'; | 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.