context stringlengths 11 9.12k | question stringlengths 0 1.06k | SQL stringlengths 2 4.44k | source stringclasses 28
values |
|---|---|---|---|
CREATE TABLE products (product_id INT, product_name TEXT, segment TEXT, price DECIMAL); CREATE TABLE sales (sale_id INT, product_id INT, sale_price DECIMAL); INSERT INTO products VALUES (1, 'Shampoo', 'Luxury', 30), (2, 'Conditioner', 'Luxury', 40), (3, 'Lipstick', 'Drugstore', 10), (4, 'Mascara', 'Drugstore', 12); INS... | What are the average prices of cosmetics in the luxury and drugstore segments? | SELECT segment, AVG(sale_price) as avg_price FROM sales s JOIN products p ON s.product_id = p.product_id GROUP BY segment; | gretelai_synthetic_text_to_sql |
CREATE TABLE Shipments (id INT, weight INT, delay_reason VARCHAR(50), delivery_date DATE, shipped_date DATE); INSERT INTO Shipments (id, weight, delay_reason, delivery_date, shipped_date) VALUES (1, 100, 'Customs', '2022-01-05', '2022-01-03'), (2, 150, 'Mechanical', '2022-01-07', '2022-01-06'), (3, 200, 'Customs', '202... | What is the average delivery time for shipments that were delayed due to customs issues? | SELECT AVG(DATEDIFF(delivery_date, shipped_date)) AS avg_delivery_time FROM Shipments WHERE delay_reason = 'Customs'; | gretelai_synthetic_text_to_sql |
CREATE TABLE network_investments (investment_id INT, region VARCHAR(10), investment_amount FLOAT); | Find the total number of network infrastructure investments in the Western region | SELECT SUM(investment_amount) FROM network_investments WHERE region = 'Western'; | gretelai_synthetic_text_to_sql |
CREATE TABLE defense_contracts (contract_id INT, company_name TEXT, state TEXT, value FLOAT, contract_date DATE); INSERT INTO defense_contracts (contract_id, company_name, state, value, contract_date) VALUES (1, 'ABC Corp', 'California', 500000, '2022-01-05'), (2, 'XYZ Inc', 'California', 750000, '2022-03-15'); | What is the total value of defense contracts awarded to companies in California in Q1 2022? | SELECT SUM(value) FROM defense_contracts WHERE state = 'California' AND contract_date >= '2022-01-01' AND contract_date < '2022-04-01'; | gretelai_synthetic_text_to_sql |
CREATE TABLE volunteers (id INT, state VARCHAR(2)); INSERT INTO volunteers (id, state) VALUES (1, 'NY'), (2, 'CA'), (3, 'TX'); | How many volunteers signed up in each state? | SELECT state, COUNT(*) AS num_volunteers FROM volunteers GROUP BY state; | gretelai_synthetic_text_to_sql |
CREATE TABLE extraction(id INT, location TEXT, month INT, year INT, minerals_extracted FLOAT);INSERT INTO extraction(id, location, month, year, minerals_extracted) VALUES (1, 'north', 1, 2020, 1500), (2, 'north', 2, 2020, 1800), (3, 'south', 1, 2020, 1200), (4, 'east', 1, 2020, 1000); | What is the total amount of minerals extracted in each location for the month 1 in 2020? | SELECT location, SUM(minerals_extracted) FROM extraction WHERE month = 1 AND year = 2020 GROUP BY location; | gretelai_synthetic_text_to_sql |
CREATE TABLE defense_contracts (id INT, contract_date DATE, contract_value INT, company VARCHAR(50)); INSERT INTO defense_contracts (id, contract_date, contract_value, company) VALUES (1, '2021-01-15', 5000000, 'Z'), (2, '2021-03-30', 8000000, 'Y'), (3, '2021-04-12', 3000000, 'Z'); | What is the total value of defense contracts signed with company 'Z' in 2021? | SELECT SUM(contract_value) FROM defense_contracts WHERE company = 'Z' AND YEAR(contract_date) = 2021; | gretelai_synthetic_text_to_sql |
CREATE TABLE ports (port_id INT, port_name TEXT, country TEXT); INSERT INTO ports (port_id, port_name, country) VALUES (1, 'Port A', 'USA'), (2, 'Port B', 'Canada'); CREATE TABLE visits (visit_id INT, vessel_id INT, port_id INT, visit_date DATE); INSERT INTO visits (visit_id, vessel_id, port_id, visit_date) VALUES (1, ... | What is the earliest visit date for vessels that have visited 'Port A'? | SELECT MIN(visit_date) FROM visits WHERE port_id = (SELECT port_id FROM ports WHERE port_name = 'Port A'); | gretelai_synthetic_text_to_sql |
CREATE TABLE ai_projects (sector VARCHAR(20), budget INT); INSERT INTO ai_projects (sector, budget) VALUES ('Education', 200000), ('Healthcare', 500000), ('Finance', 1000000); | What is the average budget for AI projects in the education sector? | SELECT AVG(budget) FROM ai_projects WHERE sector = 'Education'; | gretelai_synthetic_text_to_sql |
CREATE TABLE company (id INT, name TEXT, founder_name TEXT, city TEXT); INSERT INTO company (id, name, founder_name, city) VALUES (1, 'InnoTech', 'John Doe', 'San Francisco'); INSERT INTO company (id, name, founder_name, city) VALUES (2, 'GreenEnergy', 'Jane Smith', 'Berkeley'); INSERT INTO company (id, name, founder_n... | Who are the founders of companies that have received more than $1M in funding and are located in the Bay Area? | SELECT company.founder_name FROM company INNER JOIN funding ON company.id = funding.company_id WHERE funding.amount > 1000000 AND company.city = 'San Francisco'; | gretelai_synthetic_text_to_sql |
CREATE TABLE attorneys (attorney_id INT, attorney_state VARCHAR(255)); CREATE TABLE cases (case_id INT, attorney_id INT); CREATE TABLE billing (bill_id INT, case_id INT, amount DECIMAL(10,2)); | What is the total billing amount for each attorney, based on the 'attorney_id' column in the 'attorneys' table? | SELECT a.attorney_id, SUM(b.amount) FROM attorneys a INNER JOIN cases c ON a.attorney_id = c.attorney_id INNER JOIN billing b ON c.case_id = b.case_id GROUP BY a.attorney_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE eco_hotels(id INT, name TEXT, city TEXT, sustainable BOOLEAN); INSERT INTO eco_hotels(id, name, city, sustainable) VALUES (1, 'EcoHotel Roma', 'Rome', true), (2, 'Paris Sustainable Suites', 'Paris', true), (3, 'Barcelona Green Living', 'Barcelona', true); | Which cities have the most eco-friendly hotels? | SELECT city, COUNT(*) FROM eco_hotels WHERE sustainable = true GROUP BY city ORDER BY COUNT(*) DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE attendees (id INT, name VARCHAR(50), country VARCHAR(50), events INT); INSERT INTO attendees (id, name, country, events) VALUES (1, 'Alex', 'Canada', 20), (2, 'Bella', 'United States', 15), (3, 'Charlie', 'Canada', 25); | What is the number of cultural events attended by 'Alex' from Canada? | SELECT events FROM attendees WHERE name = 'Alex' AND country = 'Canada'; | gretelai_synthetic_text_to_sql |
CREATE TABLE estuaries (id INT, name TEXT, location TEXT, salinity FLOAT, area_size FLOAT); INSERT INTO estuaries (id, name, location, salinity, area_size) VALUES (1, 'Gironde Estuary', 'Europe', 0.5, 665); | Which estuary in Europe has the lowest salinity?" | SELECT name, MIN(salinity) FROM estuaries WHERE location = 'Europe'; | gretelai_synthetic_text_to_sql |
CREATE TABLE WasteGeneration (WasteID INT, WasteType VARCHAR(20), Location VARCHAR(20), Quantity INT, Year INT); INSERT INTO WasteGeneration (WasteID, WasteType, Location, Quantity, Year) VALUES (1, 'Metal', 'New York', 1500, 2019), (2, 'Metal', 'Los Angeles', 1200, 2019); | What are the total quantities of metal waste generated in 2019, grouped by location? | SELECT Location, SUM(Quantity) as TotalQuantity FROM WasteGeneration WHERE WasteType = 'Metal' AND Year = 2019 GROUP BY Location; | gretelai_synthetic_text_to_sql |
CREATE TABLE Warehouses (WarehouseID INT, WarehouseName VARCHAR(50), Country VARCHAR(50)); INSERT INTO Warehouses (WarehouseID, WarehouseName, Country) VALUES (1, 'Japan Warehouse', 'Japan'); CREATE TABLE Shipments (ShipmentID INT, WarehouseID INT, DeliveryTime INT); | What is the difference between the earliest and latest delivery times in Japan? | SELECT MAX(DeliveryTime) - MIN(DeliveryTime) FROM Shipments WHERE WarehouseID = (SELECT WarehouseID FROM Warehouses WHERE Country = 'Japan'); | gretelai_synthetic_text_to_sql |
CREATE TABLE AquacultureCountries (CountryName TEXT, Species TEXT); INSERT INTO AquacultureCountries (CountryName, Species) VALUES ('Norway', 'Salmon'), ('Norway', 'Trout'), ('Chile', 'Salmon'), ('Chile', 'Trout'), ('Scotland', 'Salmon'), ('Scotland', 'Trout'), ('Canada', 'Salmon'), ('Canada', 'Trout'), ('Ireland', 'Sa... | list all countries that farm both salmon and trout | SELECT CountryName FROM AquacultureCountries WHERE Species IN ('Salmon', 'Trout') GROUP BY CountryName HAVING COUNT(DISTINCT Species) = 2; | gretelai_synthetic_text_to_sql |
CREATE TABLE clients (client_id INT PRIMARY KEY AUTO_INCREMENT, client_name VARCHAR(255)); | Insert a new client named 'Jamal Smith' into the 'clients' table and assign them a unique client_id. | INSERT INTO clients (client_name) VALUES ('Jamal Smith'); | gretelai_synthetic_text_to_sql |
CREATE TABLE nba_teams (team_id INT, team_name VARCHAR(100), coach_age INT); INSERT INTO nba_teams (team_id, team_name, coach_age) VALUES (1, 'Golden State Warriors', 50), (2, 'Boston Celtics', 45); | What is the average age of coaches in the NBA? | SELECT AVG(coach_age) FROM nba_teams; | gretelai_synthetic_text_to_sql |
CREATE TABLE workouts (id INT, workout_date DATE, activity_type VARCHAR(50), duration INT); INSERT INTO workouts (id, workout_date, activity_type, duration) VALUES (1, '2022-01-01', 'cardio', 60), (2, '2022-01-02', 'strength', 45), (3, '2022-02-03', 'cardio', 75), (4, '2022-02-04', 'yoga', 60), (5, '2022-03-05', 'cardi... | What is the total number of 'cardio' workouts for each month of the year 2022?' | SELECT DATE_FORMAT(workout_date, '%Y-%m') AS month, COUNT(*) AS total_workouts FROM workouts WHERE activity_type = 'cardio' GROUP BY month; | gretelai_synthetic_text_to_sql |
CREATE TABLE school_data (school_id INT, school_name VARCHAR(50), offers_lifelong_learning BOOLEAN); | What is the total number of schools that offer lifelong learning programs in the 'school_data' table? | SELECT COUNT(*) FROM school_data WHERE offers_lifelong_learning = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE organizations (id INT PRIMARY KEY, name VARCHAR(100), type VARCHAR(50), country VARCHAR(50)); | Insert a new record into the "organizations" table with the name "Green Code Initiative", type "Non-profit", and country "Nigeria" | INSERT INTO organizations (name, type, country) VALUES ('Green Code Initiative', 'Non-profit', 'Nigeria'); | gretelai_synthetic_text_to_sql |
CREATE TABLE projects (id INT, technology VARCHAR(20), CO2_reduction_tons INT); INSERT INTO projects (id, technology, CO2_reduction_tons) VALUES (1, 'wind', 1500), (2, 'solar', 1200), (3, 'wind', 2000), (4, 'hydro', 2500); | Identify the average CO2 emission reduction (in metric tons) of projects in the 'wind' technology type. | SELECT AVG(CO2_reduction_tons) AS avg_reduction FROM projects WHERE technology = 'wind'; | gretelai_synthetic_text_to_sql |
CREATE TABLE cosmetics_ingredients (product_id INT, ingredient TEXT, country TEXT); CREATE VIEW paraben_products AS SELECT product_id FROM cosmetics_ingredients WHERE ingredient = 'parabens'; CREATE VIEW all_products AS SELECT product_id FROM cosmetics_ingredients; | What is the percentage of cosmetic products in the German market that contain parabens, and how many products were rated? | SELECT 100.0 * COUNT(*) FILTER (WHERE product_id IN (SELECT product_id FROM paraben_products)) / COUNT(*) as paraben_percentage FROM all_products WHERE country = 'Germany'; | gretelai_synthetic_text_to_sql |
CREATE TABLE regions (id INT, name VARCHAR(50)); CREATE TABLE accessible_tech_programs (id INT, region_id INT, participants INT); INSERT INTO regions (id, name) VALUES (1, 'Americas'), (2, 'Asia'), (3, 'Europe'), (4, 'Africa'); INSERT INTO accessible_tech_programs (id, region_id, participants) VALUES (1, 1, 500), (2, 1... | Identify the top 3 regions with the highest number of accessible technology programs for people with disabilities. | SELECT regions.name, COUNT(accessible_tech_programs.id) as program_count FROM regions INNER JOIN accessible_tech_programs ON regions.id = accessible_tech_programs.region_id GROUP BY regions.name ORDER BY program_count DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE vessels (vessel_id INT, vessel_name VARCHAR(255), length INT, year_built INT, max_speed FLOAT); | Display vessels with a maximum speed of over 30 knots and their corresponding details. | SELECT * FROM vessels WHERE max_speed > 30; | gretelai_synthetic_text_to_sql |
CREATE TABLE brands (brand_id INT, brand_name TEXT, country TEXT); INSERT INTO brands (brand_id, brand_name, country) VALUES (1, 'EcoBrand', 'India'), (4, 'AfricanEthicalFashion', 'Kenya'); CREATE TABLE material_usage (brand_id INT, material_type TEXT, quantity INT, co2_emissions INT); INSERT INTO material_usage (brand... | Insert new records for a brand from Kenya that has just started using organic cotton and recycled polyester. | INSERT INTO material_usage (brand_id, material_type, quantity, co2_emissions) VALUES (4, 'organic_cotton', 1500, 1200), (4, 'recycled_polyester', 1800, 2000); | gretelai_synthetic_text_to_sql |
CREATE TABLE UnionN(member_id INT); INSERT INTO UnionN(member_id) VALUES(14001), (14002), (14003); CREATE TABLE UnionO(member_id INT); INSERT INTO UnionO(member_id) VALUES(15001), (15002); | What is the difference in the number of members between unions 'N' and 'O'? | SELECT COUNT(*) FROM UnionN EXCEPT SELECT COUNT(*) FROM UnionO; | gretelai_synthetic_text_to_sql |
CREATE TABLE vehicles (vehicle_id INT, model VARCHAR(20), manufacture VARCHAR(20), fuel_efficiency FLOAT, vehicle_type VARCHAR(20)); | What is the average fuel efficiency for compact cars? | SELECT AVG(fuel_efficiency) FROM vehicles WHERE vehicle_type = 'compact'; | gretelai_synthetic_text_to_sql |
CREATE TABLE ArtistRevenue (Artist VARCHAR(20), Revenue FLOAT); INSERT INTO ArtistRevenue (Artist, Revenue) VALUES ('Taylor Swift', '4000000'), ('Eminem', '3500000'), ('The Beatles', '5000000'), ('BTS', '6000000'); | What is the total revenue generated by each artist from digital sales? | SELECT Artist, SUM(Revenue) FROM ArtistRevenue GROUP BY Artist; | gretelai_synthetic_text_to_sql |
CREATE TABLE properties (property_id INT, city VARCHAR(50)); INSERT INTO properties (property_id, city) VALUES (1, 'Portland'), (2, 'Seattle'), (3, 'Portland'), (4, 'Oakland'), (5, 'Seattle'), (6, 'Oakland'), (7, 'Oakland'); | Which cities have more than 2 properties? | SELECT city, COUNT(*) FROM properties GROUP BY city HAVING COUNT(*) > 2; | gretelai_synthetic_text_to_sql |
CREATE TABLE teacher_skills (teacher_id INT, skill_name VARCHAR(20)); INSERT INTO teacher_skills (teacher_id, skill_name) VALUES (1, 'Python'), (2, 'Java'), (3, 'SQL'); | Create a new table 'teacher_skills' with columns 'teacher_id', 'skill_name' and insert at least 3 records. | SELECT * FROM teacher_skills; | gretelai_synthetic_text_to_sql |
CREATE TABLE Renewable_Energy_Projects (project_id INT, location VARCHAR(50), energy_efficiency_rating INT); INSERT INTO Renewable_Energy_Projects (project_id, location, energy_efficiency_rating) VALUES (1, 'Germany', 90), (2, 'Spain', 88), (3, 'Denmark', 85), (4, 'China', 82), (5, 'United States', 80), (6, 'India', 78... | What are the top 5 countries with the highest energy efficiency ratings for renewable energy projects? | SELECT location, energy_efficiency_rating, RANK() OVER (ORDER BY energy_efficiency_rating DESC) as country_rank FROM Renewable_Energy_Projects WHERE location IN ('Germany', 'Spain', 'Denmark', 'China', 'United States', 'India') GROUP BY location, energy_efficiency_rating HAVING country_rank <= 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE patients (patient_id INT, diagnosis VARCHAR(255), age INT, county VARCHAR(255)); INSERT INTO patients (patient_id, diagnosis, age, county) VALUES (1, 'diabetes', 60, 'Briarwood'), (2, 'asthma', 30, 'Briarwood'), (3, 'diabetes', 55, 'Briarwood'); | What is the average age of patients diagnosed with diabetes in the rural county of 'Briarwood'? | SELECT AVG(age) FROM patients WHERE diagnosis = 'diabetes' AND county = 'Briarwood'; | gretelai_synthetic_text_to_sql |
CREATE TABLE region (region_id INT, name VARCHAR(255)); INSERT INTO region (region_id, name) VALUES (1, 'Pacific'); CREATE TABLE community_program (program_id INT, name VARCHAR(255), region_id INT, creation_date DATE); INSERT INTO community_program (program_id, name, region_id, creation_date) VALUES (1, 'Program1', 1, ... | How many community programs were created in the Pacific region in the past year? | SELECT COUNT(*) FROM community_program WHERE region_id = (SELECT region_id FROM region WHERE name = 'Pacific') AND creation_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR); | gretelai_synthetic_text_to_sql |
CREATE TABLE finance.customers (id INT, name VARCHAR(255), country VARCHAR(255), balance DECIMAL(10, 2)); INSERT INTO finance.customers (id, name, country, balance) VALUES (1, 'John Doe', 'USA', 4000.00), (2, 'Jane Smith', 'Canada', 7000.00), (3, 'Alice Johnson', 'UK', 6000.00); | Delete records of customers from the 'finance' schema with a balance less than 5000 | DELETE FROM finance.customers WHERE balance < 5000; | gretelai_synthetic_text_to_sql |
CREATE TABLE providers (id INT, name VARCHAR(50), language VARCHAR(50), parity_violations INT); INSERT INTO providers (id, name, language, parity_violations) VALUES (1, 'Dr. Maria Garcia', 'Spanish', 7), (2, 'Dr. John Smith', 'English', 3); CREATE TABLE violations (id INT, provider_id INT, date DATE); INSERT INTO viola... | What is the average number of mental health parity violations recorded per provider, in the 'providers' and 'violations' tables? | SELECT AVG(p.parity_violations) FROM providers p; | gretelai_synthetic_text_to_sql |
CREATE TABLE products (product_id INT, category VARCHAR(20), price DECIMAL(5,2)); INSERT INTO products (product_id, category, price) VALUES (1, 'home goods', 35.99), (2, 'home goods', 45.00), (3, 'home goods', 29.99); | What is the minimum price of a product in the 'home goods' category? | SELECT MIN(price) FROM products WHERE category = 'home goods'; | gretelai_synthetic_text_to_sql |
CREATE TABLE mobile_subscribers (subscriber_id INT, region_id INT, join_date DATE); INSERT INTO mobile_subscribers (subscriber_id, region_id, join_date) VALUES (1, 1, '2021-04-01'), (2, 2, '2021-06-01'), (3, 3, '2021-05-01'), (4, 4, '2021-04-15'); CREATE TABLE broadband_subscribers (subscriber_id INT, region_id INT, jo... | List the number of mobile and broadband subscribers in each region for the second quarter. | SELECT r.region_name, COUNT(m.subscriber_id) AS mobile_count, COUNT(b.subscriber_id) AS broadband_count FROM regions r LEFT JOIN mobile_subscribers m ON r.region_id = m.region_id LEFT JOIN broadband_subscribers b ON r.region_id = b.region_id WHERE QUARTER(m.join_date) = 2 AND YEAR(m.join_date) = 2021 GROUP BY r.region_... | gretelai_synthetic_text_to_sql |
CREATE TABLE projects (id INT, name VARCHAR(255), start_date DATE, end_date DATE); INSERT INTO projects (id, name, start_date, end_date) VALUES (1, 'ProjectA', '2019-06-01', '2019-09-30'); INSERT INTO projects (id, name, start_date, end_date) VALUES (2, 'ProjectB', '2019-10-01', '2019-12-31'); | How many bioprocess engineering projects were completed in Q3 2019? | SELECT COUNT(*) FROM projects WHERE start_date <= '2019-09-30' AND end_date >= '2019-07-01'; | gretelai_synthetic_text_to_sql |
CREATE TABLE athlete_games (athlete_id INT, game_date DATE, played BOOLEAN); | List athletes who have never missed a game due to injury. | SELECT athlete_id FROM athlete_games WHERE NOT EXISTS (SELECT 1 FROM athlete_games WHERE athlete_id = athlete_games.athlete_id AND played = FALSE); | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_protected_areas (name VARCHAR(255), depth FLOAT, status VARCHAR(255)); INSERT INTO marine_protected_areas (name, depth, status) VALUES ('Area1', 123.4, 'Conserved'), ('Area2', 234.5, 'Threatened'); | What is the average depth of marine protected areas, partitioned by conservation status? | SELECT status, AVG(depth) as avg_depth FROM marine_protected_areas GROUP BY status; | gretelai_synthetic_text_to_sql |
CREATE TABLE TropicalForests (region VARCHAR(20), area FLOAT, management_status VARCHAR(10)); INSERT INTO TropicalForests (region, area, management_status) VALUES ('Tropical Forests', 12345.67, 'sustainable'), ('Tropical Forests', 8765.43, 'unsustainable'); | What is the total area of 'Tropical Forests' under sustainable management? | SELECT SUM(area) FROM TropicalForests WHERE region = 'Tropical Forests' AND management_status = 'sustainable'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Artists (ArtistID INT, Name VARCHAR(50), Nationality VARCHAR(50)); INSERT INTO Artists (ArtistID, Name, Nationality) VALUES (1, 'Vincent van Gogh', 'Dutch'); CREATE TABLE Paintings (PaintingID INT, Title VARCHAR(50), ArtistID INT, YearCreated INT); | Insert a new painting 'The Starry Night Over the Rhone' by 'Vincent van Gogh' in 1888. | INSERT INTO Paintings (PaintingID, Title, ArtistID, YearCreated) VALUES (3, 'The Starry Night Over the Rhone', 1, 1888); | gretelai_synthetic_text_to_sql |
CREATE TABLE Immunization (Region TEXT, ChildImmunizationRate FLOAT); INSERT INTO Immunization VALUES ('Asia', 85); | What is the child immunization rate in Asia? | SELECT ChildImmunizationRate FROM Immunization WHERE Region = 'Asia'; | gretelai_synthetic_text_to_sql |
CREATE TABLE cases (case_id INT, state VARCHAR(2), billing_amount DECIMAL(10, 2), outcome VARCHAR(10)); INSERT INTO cases (case_id, state, billing_amount, outcome) VALUES (1, 'CA', 5000.00, 'Favorable'), (2, 'CA', 7000.00, 'Unfavorable'), (3, 'NY', 3000.00, 'Favorable'), (4, 'NY', 4000.00, 'Favorable'), (5, 'TX', 8000.... | What is the average billing amount per case for cases with a favorable outcome? | SELECT AVG(billing_amount) FROM cases WHERE outcome = 'Favorable'; | gretelai_synthetic_text_to_sql |
CREATE TABLE PlayerDailyGames (PlayerID INT, PlayDate DATE, GamesPlayed INT); INSERT INTO PlayerDailyGames (PlayerID, PlayDate, GamesPlayed) VALUES (1, '2021-04-01', 3), (1, '2021-04-02', 2), (2, '2021-04-01', 1), (2, '2021-04-03', 4), (3, '2021-04-02', 5), (3, '2021-04-03', 3); CREATE TABLE GameGenres (GameID INT, Gen... | What is the average number of games played per day by players from 'Japan' in the 'Action' genre? | SELECT AVG(GamesPlayed) FROM PlayerDailyGames INNER JOIN (SELECT PlayerID FROM PlayerGameGenres INNER JOIN GameGenres ON PlayerGameGenres.GameGenre = GameGenres.Genre WHERE GameGenres.Genre = 'Action') AS ActionPlayers ON PlayerDailyGames.PlayerID = ActionPlayers.PlayerID INNER JOIN Players ON PlayerDailyGames.PlayerID... | gretelai_synthetic_text_to_sql |
CREATE TABLE electric_vehicles (state VARCHAR(255), adoption_count INT); INSERT INTO electric_vehicles (state, adoption_count) VALUES ('California', 500000); INSERT INTO electric_vehicles (state, adoption_count) VALUES ('Texas', 350000); INSERT INTO electric_vehicles (state, adoption_count) VALUES ('Florida', 400000); | Get the number of electric vehicle adoption records in each state in the USA | SELECT state, adoption_count, ROW_NUMBER() OVER (ORDER BY adoption_count DESC) AS rank FROM electric_vehicles; | gretelai_synthetic_text_to_sql |
CREATE TABLE Patients (PatientID int, Gender varchar(10)); INSERT INTO Patients (PatientID, Gender) VALUES (1, 'Male'), (2, 'Female'); | What is the number of patients treated by gender? | SELECT Gender, COUNT(*) FROM Patients GROUP BY Gender; | gretelai_synthetic_text_to_sql |
CREATE TABLE cargo_ships (id INT, name VARCHAR(50), capacity INT, owner_id INT); INSERT INTO cargo_ships (id, name, capacity, owner_id) VALUES (1, 'Sea Titan', 150000, 1), (2, 'Ocean Marvel', 200000, 1), (3, 'Cargo Master', 120000, 2); | Update the capacity of the cargo ship named 'Sea Titan' to 175,000. | UPDATE cargo_ships SET capacity = 175000 WHERE name = 'Sea Titan'; | gretelai_synthetic_text_to_sql |
CREATE TABLE post_stats (post_id INT, category VARCHAR(50), likes INT, comments INT); INSERT INTO post_stats (post_id, category, likes, comments) VALUES (1, 'fashion', 100, 25), (2, 'fashion', 200, 50), (3, 'beauty', 150, 75), (4, 'music', 100, 50); | What is the engagement rate (likes + comments) for posts in the music category? | SELECT post_id, (likes + comments) AS engagement_rate FROM post_stats WHERE category = 'music'; | gretelai_synthetic_text_to_sql |
CREATE TABLE MilitarySatellites (Country VARCHAR(255), Type VARCHAR(255)); INSERT INTO MilitarySatellites (Country, Type) VALUES ('USA', 'Communications Satellite'), ('USA', 'Surveillance Satellite'), ('China', 'Communications Satellite'), ('China', 'Reconnaissance Satellite'); | What are the different types of military satellites operated by the US and China? | SELECT Type FROM MilitarySatellites WHERE Country IN ('USA', 'China'); | gretelai_synthetic_text_to_sql |
CREATE TABLE InfrastructureProjects (Id INT, Name VARCHAR(255), Location VARCHAR(255), ConstructionCost FLOAT, Year INT); INSERT INTO InfrastructureProjects (Id, Name, Location, ConstructionCost, Year) VALUES (1, 'Dam', 'City A', 5000000, 2020), (2, 'Bridge', 'City B', 2000000, 2019), (3, 'Road', 'City C', 1500000, 202... | What was the total construction cost for each infrastructure project in 2020? | SELECT Location, SUM(ConstructionCost) as TotalCost FROM InfrastructureProjects WHERE Year = 2020 GROUP BY Location; | gretelai_synthetic_text_to_sql |
CREATE TABLE fashion_trends (trend_id INT PRIMARY KEY, trend_name VARCHAR(100), popularity_score FLOAT, season VARCHAR(20)); INSERT INTO fashion_trends (trend_id, trend_name, popularity_score, season) VALUES (1, 'Boho Chic', 0.85, 'Spring'), (2, 'Minimalist', 0.9, 'Winter'), (3, 'Vintage', 0.8, 'Autumn'); | Select all trends with a popularity score greater than 0.85 | SELECT * FROM fashion_trends WHERE popularity_score > 0.85; | gretelai_synthetic_text_to_sql |
CREATE TABLE cases (case_id INT, attorney_name VARCHAR(255), billing_amount FLOAT); INSERT INTO cases (case_id, attorney_name, billing_amount) VALUES (1, 'Smith', 5000), (2, 'Jones', 3000), (3, 'Jones', 3500), (4, 'Johnson', 4000), (5, 'Johnson', 6000); | What is the total billing amount for cases handled by attorney Johnson? | SELECT SUM(billing_amount) FROM cases WHERE attorney_name = 'Johnson'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Biosensor (Biosensor_Name VARCHAR(50) PRIMARY KEY, Department VARCHAR(50), Price DECIMAL(10, 2)); INSERT INTO Biosensor (Biosensor_Name, Department, Price) VALUES ('Bio1', 'Genetic Research', 1000.00); INSERT INTO Biosensor (Biosensor_Name, Department, Price) VALUES ('Bio2', 'BioProcess Engineering', 1500.... | Which biosensors and their associated departments have a price less than 1500? | SELECT B.Biosensor_Name, B.Department FROM Biosensor B WHERE B.Price < 1500; | gretelai_synthetic_text_to_sql |
CREATE TABLE RenewableEnergy (ProjectID INT, EnergyConsumption FLOAT); | What is the total energy consumption of renewable energy projects in the RenewableEnergy schema? | select sum(EnergyConsumption) as total_cons from RenewableEnergy; | gretelai_synthetic_text_to_sql |
CREATE TABLE PublicWorks (ID INT, Name VARCHAR(50), Type VARCHAR(20), Location VARCHAR(50), DailyCapacity INT); INSERT INTO PublicWorks (ID, Name, Type, Location, DailyCapacity) VALUES (1, 'Water Treatment Plant A', 'Water Treatment Plant', 'Seattle, WA', 150000); INSERT INTO PublicWorks (ID, Name, Type, Location, Dail... | What is the name and ID of the water treatment plant in the 'PublicWorks' table with the highest daily capacity? | SELECT Name, ID FROM PublicWorks WHERE DailyCapacity = (SELECT MAX(DailyCapacity) FROM PublicWorks WHERE Type = 'Water Treatment Plant'); | gretelai_synthetic_text_to_sql |
CREATE TABLE community_health_workers (worker_id INT, age INT, race VARCHAR(255)); INSERT INTO community_health_workers (worker_id, age, race) VALUES (1, 35, 'Hispanic'); INSERT INTO community_health_workers (worker_id, age, race) VALUES (2, 40, 'African American'); | Insert a new record for a community health worker with ID 3, age 30, and ethnicity Caucasian. | INSERT INTO community_health_workers (worker_id, age, race) VALUES (3, 30, 'Caucasian'); | gretelai_synthetic_text_to_sql |
CREATE TABLE Artists (name VARCHAR(255), art VARCHAR(255), quantity INT); INSERT INTO Artists (name, art, quantity) VALUES ('Picasso', 'Painting', 500), ('Van Gogh', 'Painting', 400), ('Dali', 'Painting', 300), ('Picasso', 'Sculpture', 200); | What is the name of the artist with the highest number of artworks? | SELECT name FROM Artists WHERE quantity = (SELECT MAX(quantity) FROM Artists); | gretelai_synthetic_text_to_sql |
CREATE TABLE subscriber_data (subscriber_id INT, data_usage FLOAT, month DATE); INSERT INTO subscriber_data (subscriber_id, data_usage, month) VALUES (43, 28, '2021-01-01'), (43, 33, '2021-02-01'), (43, 38, '2021-03-01'); | Find the difference in data usage between consecutive months for subscriber_id 43 in the 'Asia-Pacific' region. | SELECT subscriber_id, LAG(data_usage) OVER (PARTITION BY subscriber_id ORDER BY month) as prev_data_usage, data_usage, month FROM subscriber_data WHERE subscriber_id = 43 AND region = 'Asia-Pacific' ORDER BY month; | gretelai_synthetic_text_to_sql |
CREATE TABLE province (province_id INT, province_name VARCHAR(255)); CREATE TABLE lifelong_learning (student_id INT, province_id INT, enrollment_date DATE); INSERT INTO province (province_id, province_name) VALUES (8001, 'Province A'), (8002, 'Province B'), (8003, 'Province C'); INSERT INTO lifelong_learning (student_i... | What is the lifelong learning enrollment rate for each province? | SELECT province_name, enrolled_students.enrolled_count, (enrolled_students.enrolled_count::FLOAT / (SELECT COUNT(DISTINCT student_id) FROM lifelong_learning) * 100) as enrollment_rate FROM province JOIN enrolled_students ON province.province_id = enrolled_students.province_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE Mine (MineID int, MineName varchar(50), Location varchar(50)); CREATE TABLE Employee (EmployeeID int, EmployeeName varchar(50), JobType varchar(50), MineID int, Gender varchar(10)); INSERT INTO Mine VALUES (1, 'ABC Mine', 'Colorado'), (2, 'DEF Mine', 'Wyoming'), (3, 'GHI Mine', 'West Virginia'); INSERT INT... | What is the percentage of female and male employees for each job type across all mines? | SELECT JobType, Gender, COUNT(*) * 100.0 / (SELECT COUNT(*) FROM Employee) as Percentage FROM Employee GROUP BY JobType, Gender; | gretelai_synthetic_text_to_sql |
CREATE TABLE Organic_Farms (farm_name VARCHAR(50), region VARCHAR(20), year INT); CREATE TABLE Pest_Report (report_id INT, farm_name VARCHAR(50), pest VARCHAR(30), year INT); INSERT INTO Organic_Farms (farm_name, region, year) VALUES ('Farm1', 'Northeast', 2019), ('Farm2', 'Northeast', 2019); INSERT INTO Pest_Rep... | How many unique pests were reported in the 'Northeast' region organic farms in 2019? | SELECT COUNT(DISTINCT pest) as unique_pests FROM Pest_Report pr JOIN Organic_Farms of ON pr.farm_name = of.farm_name WHERE of.region = 'Northeast' AND of.year = 2019; | gretelai_synthetic_text_to_sql |
CREATE TABLE satellite_deployment (id INT PRIMARY KEY, name VARCHAR(255), country VARCHAR(255), launch_date DATE); | Add a new column 'weight' to the 'satellite_deployment' table | ALTER TABLE satellite_deployment ADD COLUMN weight FLOAT; | gretelai_synthetic_text_to_sql |
CREATE TABLE subscriber_data (subscriber_id INT, subscriber_type VARCHAR(10), data_usage FLOAT, state VARCHAR(20)); INSERT INTO subscriber_data (subscriber_id, subscriber_type, data_usage, state) VALUES (1, 'mobile', 3.5, 'CA'), (2, 'mobile', 4.2, 'NY'), (3, 'broadband', 200.5, 'CA'), (4, 'mobile', 3.8, 'WA'), (5, 'bro... | What is the average monthly data usage for mobile and broadband subscribers in the state of California? | SELECT subscriber_type, AVG(data_usage) FROM subscriber_data WHERE state = 'CA' GROUP BY subscriber_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE articles (id INT, title VARCHAR(50), word_count INT, category VARCHAR(20)); INSERT INTO articles (id, title, word_count, category) VALUES (1, 'Article1', 500, 'category1'), (2, 'Article2', 700, 'category3'), (3, 'Article3', 800, 'category5'), (4, 'Article4', 600, 'category2'), (5, 'Article5', 400, 'categor... | What is the average word count for articles in 'category1', 'category3', and 'category5'? | SELECT AVG(word_count) FROM articles WHERE category IN ('category1', 'category3', 'category5') | gretelai_synthetic_text_to_sql |
CREATE TABLE SUBMARINE_DIVES (DIVE_ID INT, SUBMARINE_NAME VARCHAR(20), DIVE_DATE DATE, MAX_DEPTH INT); INSERT INTO SUBMARINE_DIVES (DIVE_ID, SUBMARINE_NAME, DIVE_DATE, MAX_DEPTH) VALUES (1, 'Alvin', '2022-01-01', 4000), (2, 'Nautile', '2022-02-01', 6000), (3, 'Alvin', '2022-03-01', 3500), (4, 'Nautile', '2022-04-01', 5... | Find the top 5 submarine dives by maximum depth, showing the dive's date and the name of the submarine. | SELECT SUBMARINE_NAME, DIVE_DATE, MAX_DEPTH FROM (SELECT SUBMARINE_NAME, DIVE_DATE, MAX_DEPTH, ROW_NUMBER() OVER (PARTITION BY SUBMARINE_NAME ORDER BY MAX_DEPTH DESC) AS RN FROM SUBMARINE_DIVES) WHERE RN <= 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE textile_sources (source_id INT, material VARCHAR(50)); INSERT INTO textile_sources (source_id, material) VALUES (1, 'Recycled Polyester'); CREATE TABLE garment_sizes (size_id INT, size VARCHAR(10)); INSERT INTO garment_sizes (size_id, size) VALUES (1, 'S'); CREATE TABLE products (product_id INT, name VARCH... | What is the average price of recycled polyester clothing manufactured in size S? | SELECT AVG(p.price) FROM products p INNER JOIN textile_sources ts ON p.source_id = ts.source_id INNER JOIN garment_sizes gs ON p.size_id = gs.size_id WHERE ts.material = 'Recycled Polyester' AND gs.size = 'S'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Country (Code TEXT, Name TEXT, Continent TEXT); INSERT INTO Country (Code, Name, Continent) VALUES ('CN', 'China', 'Asia'), ('AU', 'Australia', 'Australia'), ('KR', 'South Korea', 'Asia'), ('IN', 'India', 'Asia'); CREATE TABLE ProductionYearly (Year INT, Country TEXT, Element TEXT, Quantity INT); INSERT IN... | Determine the percentage change in total production of Dysprosium for each country from 2019 to 2020. | SELECT a.Country, ((b.Quantity - a.Quantity) * 100.0 / a.Quantity) AS PercentageChange FROM ProductionYearly a JOIN ProductionYearly b ON a.Country = b.Country WHERE a.Element = 'Dysprosium' AND b.Element = 'Dysprosium' AND a.Year = 2019 AND b.Year = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE DefenseProjects (id INT, project_name VARCHAR(255), start_date DATE, end_date DATE, budget INT, actual_cost INT); INSERT INTO DefenseProjects (id, project_name, start_date, end_date, budget, actual_cost) VALUES (1, 'Project A', '2019-01-01', '2021-12-31', 10000000, 11000000), (2, 'Project B', '2018-01-01',... | How many defense projects exceeded their budget in the last 3 years? | SELECT COUNT(*) FROM DefenseProjects WHERE actual_cost > budget AND start_date >= DATE_SUB(CURRENT_DATE, INTERVAL 3 YEAR); | gretelai_synthetic_text_to_sql |
CREATE TABLE teacher_development_gender (teacher_id INT, gender VARCHAR(255), subject_area VARCHAR(255), sessions_attended INT); INSERT INTO teacher_development_gender (teacher_id, gender, subject_area, sessions_attended) VALUES (1, 'Male', 'Math', 3), (2, 'Female', 'English', 2), (3, 'Non-binary', 'Science', 5), (4, '... | What is the number of teachers who have attended professional development sessions in each subject area by gender? | SELECT gender, subject_area, SUM(sessions_attended) as total_sessions_attended FROM teacher_development_gender GROUP BY gender, subject_area; | gretelai_synthetic_text_to_sql |
CREATE TABLE food_safety_inspection(menu_item VARCHAR(255), inspection_date DATE, agency VARCHAR(255)); INSERT INTO food_safety_inspection VALUES ('Chicken Burger', '2021-05-15', 'Food Safety Agency'); INSERT INTO food_safety_inspection VALUES ('Fish Tacos', '2021-10-20', 'Food Safety Agency'); | Which menu items were inspected by the Food Safety Agency in 2021? | SELECT menu_item FROM food_safety_inspection WHERE agency = 'Food Safety Agency' AND YEAR(inspection_date) = 2021; | gretelai_synthetic_text_to_sql |
CREATE TABLE movies (id INT, title VARCHAR(100), release_year INT); | What is the release year of the most recent movie in the "movies" table? | SELECT MAX(release_year) FROM movies; | gretelai_synthetic_text_to_sql |
CREATE TABLE DrugSales (DrugName varchar(50), SalesRepID int, SalesDate date, TotalSalesRev decimal(18,2)); INSERT INTO DrugSales (DrugName, SalesRepID, SalesDate, TotalSalesRev) VALUES ('DrugI', 1, '2021-03-15', 50000.00), ('DrugJ', 2, '2021-02-01', 75000.00), ('DrugK', 3, '2021-01-25', 62000.00), ('DrugL', 4, '2021-0... | What is the total sales revenue for each drug, ranked by total sales revenue? | SELECT DrugName, TotalSalesRev, ROW_NUMBER() OVER (ORDER BY TotalSalesRev DESC) as SalesRank FROM (SELECT DrugName, SUM(TotalSalesRev) as TotalSalesRev FROM DrugSales GROUP BY DrugName) as TotalSales; | gretelai_synthetic_text_to_sql |
CREATE TABLE Programs (ProgramID INT, Name TEXT);CREATE TABLE VolunteerHours (HourID INT, ProgramID INT, Hours DECIMAL(10,2), HourDate DATE); | What is the total number of volunteer hours contributed by each program in Q1 2023, including partial hours? | SELECT P.Name, SUM(VH.Hours) as TotalHours FROM VolunteerHours VH JOIN Programs P ON VH.ProgramID = P.ProgramID WHERE VH.HourDate BETWEEN '2023-01-01' AND '2023-03-31' GROUP BY P.ProgramID, P.Name; | gretelai_synthetic_text_to_sql |
CREATE TABLE workout_equipment (equipment_id INT, equipment_name VARCHAR(50), quantity INT, manufacturer VARCHAR(50)); CREATE VIEW equipment_summary AS SELECT equipment_name, manufacturer, SUM(quantity) as total_quantity FROM workout_equipment GROUP BY equipment_name, manufacturer; | What is the total quantity of equipment for each manufacturer, grouped by equipment type, in the 'equipment_summary' view? | SELECT manufacturer, equipment_name, SUM(total_quantity) FROM equipment_summary GROUP BY manufacturer, equipment_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE Schools (Name VARCHAR(255), Type VARCHAR(255), Region VARCHAR(255)); INSERT INTO Schools (Name, Type, Region) VALUES ('School A', 'Public', 'North'), ('School B', 'Private', 'North'), ('School C', 'Public', 'South'), ('School D', 'Private', 'South'); CREATE TABLE SchoolBudget (Year INT, School VARCHAR(255)... | How many public schools are there in total, and what is the total budget allocated to them? | SELECT COUNT(s.Name), SUM(sb.Amount) FROM Schools s INNER JOIN SchoolBudget sb ON s.Name = sb.School WHERE s.Type = 'Public'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Districts (district_name TEXT, calls INTEGER, crimes INTEGER); INSERT INTO Districts (district_name, calls, crimes) VALUES ('Downtown', 450, 300), ('Uptown', 500, 250); | Find the union of emergency calls and crimes reported in the Downtown and Uptown districts. | SELECT calls, crimes FROM Districts WHERE district_name = 'Downtown' UNION SELECT calls, crimes FROM Districts WHERE district_name = 'Uptown'; | gretelai_synthetic_text_to_sql |
CREATE TABLE north_sea_fields (field_id INT, field_name VARCHAR(50), oil_production FLOAT, gas_production FLOAT, datetime DATETIME); INSERT INTO north_sea_fields (field_id, field_name, oil_production, gas_production, datetime) VALUES (1, 'North Sea Field A', 1500000, 2000000, '2019-01-01 00:00:00'), (2, 'North Sea Fiel... | List the total production of oil and gas for all fields in the North Sea in 2019. | SELECT field_name, SUM(oil_production) + SUM(gas_production) FROM north_sea_fields WHERE YEAR(datetime) = 2019 GROUP BY field_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE members_geo(id INT, name VARCHAR(50), gender VARCHAR(10), age INT, membership_type VARCHAR(20), country VARCHAR(20), city VARCHAR(20)); INSERT INTO members_geo(id, name, gender, age, membership_type, country, city) VALUES (1, 'John Doe', 'Male', 30, 'Gym', 'USA', 'New York'), (2, 'Jane Doe', 'Female', 45, ... | Get the list of members who are older than 40 and from a country other than the United States and Canada. | SELECT id, name, country FROM members_geo WHERE age > 40 AND country NOT IN ('USA', 'Canada'); | gretelai_synthetic_text_to_sql |
CREATE TABLE policyholders (id INT, name TEXT, age INT, gender TEXT, state TEXT); INSERT INTO policyholders (id, name, age, gender, state) VALUES (1, 'John Doe', 36, 'Male', 'Texas'); INSERT INTO policyholders (id, name, age, gender, state) VALUES (2, 'Jane Smith', 42, 'Female', 'Texas'); CREATE TABLE claims (id INT, p... | What is the maximum claim amount for policyholders living in 'Texas'? | SELECT MAX(claim_amount) FROM claims JOIN policyholders ON claims.policyholder_id = policyholders.id WHERE policyholders.state = 'Texas'; | gretelai_synthetic_text_to_sql |
CREATE TABLE carbon_offset_initiatives (initiative_id INT, initiative_name VARCHAR(100), launch_date DATE, city VARCHAR(100)); INSERT INTO carbon_offset_initiatives (initiative_id, initiative_name, launch_date, city) VALUES (1, 'Tree Planting', '2022-01-01', 'Tokyo'), (2, 'Public Transit Expansion', '2021-07-01', 'Toky... | How many carbon offset initiatives have been launched by the city government of Tokyo in the last 5 years? | SELECT COUNT(*) FROM carbon_offset_initiatives WHERE city = 'Tokyo' AND launch_date >= DATE_SUB(CURRENT_DATE, INTERVAL 5 YEAR); | gretelai_synthetic_text_to_sql |
CREATE TABLE donors (id INT, name VARCHAR(50), is_new_donor BOOLEAN, donation_amount DECIMAL(10,2), donation_date DATE); INSERT INTO donors (id, name, is_new_donor, donation_amount, donation_date) VALUES (1, 'John Doe', true, 200.00, '2022-04-15'); INSERT INTO donors (id, name, is_new_donor, donation_amount, donation_d... | What is the total donation amount by new donors (first-time donors) in 2022? | SELECT SUM(donation_amount) FROM donors WHERE YEAR(donation_date) = 2022 AND is_new_donor = true; | gretelai_synthetic_text_to_sql |
CREATE TABLE charging_stations (id INT PRIMARY KEY, station_name VARCHAR(255), city VARCHAR(255), num_ports INT); | Delete all records from the 'charging_stations' table where the 'city' is 'San Diego' | DELETE FROM charging_stations WHERE city = 'San Diego'; | gretelai_synthetic_text_to_sql |
CREATE TABLE PolarBearSightings (id INT, year INT, month INT, polar_bears_sighted INT); INSERT INTO PolarBearSightings (id, year, month, polar_bears_sighted) VALUES (1, 2019, 1, 3), (2, 2019, 2, 5), (3, 2019, 3, 4); | How many polar bears were sighted in total in the past 2 years? | SELECT year, SUM(polar_bears_sighted) FROM PolarBearSightings WHERE year IN (2020, 2021) GROUP BY year; | gretelai_synthetic_text_to_sql |
CREATE TABLE cases (case_id INT, precedent TEXT, total_billing FLOAT); INSERT INTO cases (case_id, precedent, total_billing) VALUES (1, 'Precedent A', 2000.00), (2, 'Precedent A', 3000.00), (3, 'Precedent B', 1500.00); | What is the average billing amount for cases with precedent 'Precedent B'? | SELECT AVG(total_billing) FROM cases WHERE precedent = 'Precedent B'; | gretelai_synthetic_text_to_sql |
CREATE TABLE budgets (budget_id INT, year INT, region_id INT, amount INT); INSERT INTO budgets (budget_id, year, region_id, amount) VALUES (1, 2019, 1, 500), (2, 2020, 1, 600), (3, 2021, 1, 700), (4, 2019, 2, 400), (5, 2020, 2, 450), (6, 2021, 2, 500); | Rank national security budgets from highest to lowest for the last 3 years. | SELECT year, region_id, amount, RANK() OVER (PARTITION BY year ORDER BY amount DESC) as ranking FROM budgets ORDER BY year, ranking; | gretelai_synthetic_text_to_sql |
CREATE TABLE Students(student_id INT, name TEXT, disability TEXT);CREATE TABLE Programs(program_id INT, program_name TEXT);CREATE TABLE Student_Programs(student_id INT, program_id INT); | Which support programs have at least one student with a visual impairment? | SELECT p.program_name FROM Programs p INNER JOIN Student_Programs sp ON p.program_id = sp.program_id INNER JOIN Students s ON sp.student_id = s.student_id WHERE s.disability LIKE '%visual%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE training_data (id INT, model_id INT, community VARCHAR(255)); INSERT INTO training_data (id, model_id, community) VALUES (1, 1, 'Rural Communities'), (2, 1, 'Elderly Population'), (3, 2, 'LGBTQ+ Community'), (4, 3, 'Minority Languages'); | Which underrepresented communities have been included in the training data for each AI model? | SELECT model_id, community FROM training_data; | gretelai_synthetic_text_to_sql |
CREATE TABLE renewable_energy_projects (id INT, project_name TEXT, country TEXT, technology TEXT, installed_capacity FLOAT); INSERT INTO renewable_energy_projects (id, project_name, country, technology, installed_capacity) VALUES (1, 'Project A', 'country1', 'solar', 200.0), (2, 'Project B', 'country2', 'wind', 150.0),... | What is the average installed capacity of wind projects? | SELECT AVG(installed_capacity) FROM renewable_energy_projects WHERE technology = 'wind'; | gretelai_synthetic_text_to_sql |
CREATE TABLE if not exists privacy_update (user_id INT, country VARCHAR(50), accepted BOOLEAN, quarter INT, year INT); INSERT INTO privacy_update (user_id, country, accepted) VALUES (1, 'Senegal', TRUE, 2, 2022), (2, 'Senegal', FALSE, 2, 2022); | Display the number of users who have not accepted the privacy policy in Senegal as of Q2 2022. | SELECT COUNT(user_id) FROM privacy_update WHERE country = 'Senegal' AND accepted = FALSE; | gretelai_synthetic_text_to_sql |
CREATE TABLE mining_operations (id INT PRIMARY KEY, mine_name VARCHAR(255), location VARCHAR(255), resource VARCHAR(255), open_date DATE); | Delete the record of the diamond mine in Mpumalanga, South Africa from the "mining_operations" table | DELETE FROM mining_operations WHERE mine_name = 'Diamond Dream' AND location = 'Mpumalanga, South Africa'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Cosmetics (product_id INT, name VARCHAR(50), price DECIMAL(5,2), sourcing_country VARCHAR(50), type VARCHAR(50)); | What is the minimum price of blushes sourced from Europe? | SELECT MIN(price) FROM Cosmetics WHERE type = 'Blush' AND sourcing_country = 'Europe'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Donors (DonorID INT, DonorName TEXT, DonationAmount INT, DonationYear INT); INSERT INTO Donors (DonorID, DonorName, DonationAmount, DonationYear) VALUES (1, 'Donor A', 2000, 2020), (2, 'Donor B', 3000, 2020), (3, 'Donor C', 4000, 2020); CREATE TABLE Organizations (OrganizationID INT, OrganizationName TEXT)... | What is the total amount donated by each donor to each organization in 2020? | SELECT DonorName, OrganizationName, SUM(DonationAmount) as TotalDonation FROM Donors INNER JOIN Donations ON Donors.DonorID = Donations.DonorID INNER JOIN Organizations ON Donations.OrganizationID = Organizations.OrganizationID WHERE DonationYear = 2020 GROUP BY DonorName, OrganizationName; | gretelai_synthetic_text_to_sql |
CREATE TABLE Donors (DonorID INT, DonorName TEXT, TotalDonated DECIMAL(10,2));CREATE TABLE Donations (DonationID INT, DonorID INT, Program TEXT, Amount DECIMAL(10,2), Success BOOLEAN); | What is the total amount donated and total number of donations for each program, excluding 'Medical Research'? | SELECT D.Program, SUM(D.Amount) as TotalAmount, COUNT(*) as TotalDonations FROM Donations D WHERE D.Program != 'Medical Research' GROUP BY D.Program; | gretelai_synthetic_text_to_sql |
CREATE TABLE professional_development_hours (teacher_id INT, country TEXT, hours_spent INT); INSERT INTO professional_development_hours (teacher_id, country, hours_spent) VALUES (1, 'USA', 10), (2, 'Canada', 15), (3, 'Mexico', 20), (4, 'Brazil', 25), (5, 'Argentina', 30); | What is the total number of hours spent on professional development by teachers in each country? | SELECT country, SUM(hours_spent) as total_hours FROM professional_development_hours GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE Habitat_Preservation (PreservationID INT, Habitat VARCHAR(20), Budget DECIMAL(10, 2)); INSERT INTO Habitat_Preservation (PreservationID, Habitat, Budget) VALUES (1, 'Africa', 50000.00); INSERT INTO Habitat_Preservation (PreservationID, Habitat, Budget) VALUES (2, 'Asia', 75000.00); | What is the total budget allocated for habitat preservation in 'Africa'? | SELECT SUM(Budget) FROM Habitat_Preservation WHERE Habitat = 'Africa'; | gretelai_synthetic_text_to_sql |
CREATE TABLE seafood_exports (id INT, export_date DATE, export_country VARCHAR(50), import_country VARCHAR(50), quantity INT, unit_type VARCHAR(10)); INSERT INTO seafood_exports (id, export_date, export_country, import_country, quantity, unit_type) VALUES (1, '2020-01-01', 'Canada', 'US', 500, 'ton'), (2, '2020-01-02',... | How many tons of seafood were exported from Canada to the US in 2020? | SELECT SUM(quantity) FROM seafood_exports WHERE export_country = 'Canada' AND import_country = 'US' AND EXTRACT(YEAR FROM export_date) = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE arctic_weather (id INT, date DATE, temperature FLOAT); | What is the maximum temperature recorded in the 'arctic_weather' table for each month in the year 2020? | SELECT MONTH(date) AS month, MAX(temperature) AS max_temp FROM arctic_weather WHERE YEAR(date) = 2020 GROUP BY month; | 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.