context stringlengths 11 9.12k | question stringlengths 0 1.06k | SQL stringlengths 2 4.44k | source stringclasses 28
values |
|---|---|---|---|
CREATE TABLE Vehicle (id INT, name TEXT, is_autonomous BOOLEAN, is_electric BOOLEAN, highway_traffic_speed FLOAT); INSERT INTO Vehicle (id, name, is_autonomous, is_electric, highway_traffic_speed) VALUES (1, 'Model S', true, true, 120.3), (2, 'Camry', false, false, 112.5), (3, 'Bolt', true, true, 95.8), (4, 'Tesla', tr... | What are the names of the vehicles that are both autonomous and electric, and their highway traffic speed? | SELECT Vehicle.name, Vehicle.highway_traffic_speed FROM Vehicle WHERE is_autonomous = true AND is_electric = true; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA rural; CREATE TABLE rural.hospitals (id INT, hospital_name TEXT); | List all unique hospital names from the 'rural' schema. | SELECT DISTINCT hospital_name FROM rural.hospitals; | gretelai_synthetic_text_to_sql |
CREATE TABLE Events (ID INT, City VARCHAR(50), EventType VARCHAR(50), AttendeeCount INT); | Update the record for a concert in Los Angeles to have 50 attendees. | UPDATE Events SET AttendeeCount = 50 WHERE City = 'Los Angeles' AND EventType = 'Concert'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Policyholder (PolicyholderID INT, Name TEXT, DOB DATE); INSERT INTO Policyholder (PolicyholderID, Name, DOB) VALUES (1, 'john doe', '1980-05-05'), (2, 'jane smith', '1990-01-01'), (3, 'mike johnson', '1975-09-09'), (4, 'sara rodriguez', '1985-04-04'); | Update policyholder names to uppercase. | UPDATE Policyholder SET Name = UPPER(Name); | gretelai_synthetic_text_to_sql |
CREATE TABLE incidents (incident_id INT, incident_type VARCHAR(255), incident_date DATE); | What is the total number of traffic-related incidents and thefts? | SELECT 'Traffic incidents' AS incident_type, COUNT(*) AS count FROM incidents WHERE incident_type = 'Traffic incident' UNION ALL SELECT 'Thefts' AS incident_type, COUNT(*) AS count FROM incidents WHERE incident_type = 'Theft'; | gretelai_synthetic_text_to_sql |
CREATE TABLE restorative_justice_sentences (sentence_id INT, program_id INT, sentence_length INT, state VARCHAR(2)); INSERT INTO restorative_justice_sentences (sentence_id, program_id, sentence_length, state) VALUES (1, 1001, 18, 'CA'), (2, 1002, 24, 'CA'); | What is the maximum sentence length for offenders who participated in restorative justice programs in California? | SELECT MAX(sentence_length) FROM restorative_justice_sentences WHERE state = 'CA'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Usage (id INT, ingredient VARCHAR(20), quantity INT, usage_date DATE); INSERT INTO Usage (id, ingredient, quantity, usage_date) VALUES (1, 'Cocoa', 10, '2022-01-01'), (2, 'Sugar', 15, '2022-01-02'); | What is the minimum quantity of a fair-trade ingredient used in a week? | SELECT ingredient, MIN(quantity) FROM Usage WHERE usage_date >= DATE_SUB(CURRENT_DATE, INTERVAL 7 DAY) AND ingredient IN ('Cocoa', 'Sugar', 'Coffee') GROUP BY ingredient; | gretelai_synthetic_text_to_sql |
CREATE TABLE Exploration (ExplorationID VARCHAR(10), Location VARCHAR(20), StartDate DATE, EndDate DATE); | Update 'Exploration' table and set 'EndDate' to '2022-12-31' for records where 'Location' is 'South China Sea' | UPDATE Exploration SET EndDate = '2022-12-31' WHERE Location = 'South China Sea'; | gretelai_synthetic_text_to_sql |
CREATE TABLE HabitatPreservation(Year INT, Habitat VARCHAR(20), Efforts INT); INSERT INTO HabitatPreservation VALUES (2017, 'Forest', 120), (2018, 'Forest', 150), (2019, 'Forest', 170), (2017, 'Wetland', 80), (2018, 'Wetland', 90), (2019, 'Wetland', 110); | Which habitats have seen the most preservation efforts in the last 5 years? | SELECT Habitat, SUM(Efforts) FROM HabitatPreservation WHERE Year >= 2017 GROUP BY Habitat ORDER BY SUM(Efforts) DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE military_innovation (id INT, region VARCHAR, project_count INT); | Which regions have the most military innovation projects? | SELECT region, SUM(project_count) AS total_projects FROM military_innovation GROUP BY region ORDER BY total_projects DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE Donations (DonationID INT, DonationDate DATE, DonationAmount DECIMAL(10,2)); INSERT INTO Donations (DonationID, DonationDate, DonationAmount) VALUES (1, '2022-03-22', 100.00), (2, '2022-03-23', 200.00), (3, '2022-03-24', 150.00); | What is the average donation per day for the last 30 days? | SELECT AVG(DonationAmount) as AvgDonationPerDay FROM Donations WHERE DonationDate >= CURRENT_DATE - INTERVAL '30 days'; | gretelai_synthetic_text_to_sql |
CREATE TABLE donors (id INT, name TEXT, age INT, donation FLOAT); INSERT INTO donors (id, name, age, donation) VALUES (1, 'John Doe', 35, 500.00); INSERT INTO donors (id, name, age, donation) VALUES (2, 'Jane Smith', 45, 750.00); | How many donors are there in the 'donors' table? | SELECT COUNT(*) FROM donors; | gretelai_synthetic_text_to_sql |
CREATE TABLE environmental_impact (site VARCHAR(255), score INT); INSERT INTO environmental_impact (site, score) VALUES ('Site A', 80), ('Site B', 70), ('Site C', 90); | Determine the environmental impact score for each mining site | SELECT ei.site, ei.score FROM environmental_impact ei; | gretelai_synthetic_text_to_sql |
CREATE TABLE ExplainableAI (model_name TEXT, confidence FLOAT, country TEXT); INSERT INTO ExplainableAI (model_name, confidence, country) VALUES ('ModelA', 0.85, 'USA'), ('ModelB', 0.92, 'USA'), ('ModelC', 0.78, 'USA'); | What is the average confidence score for explainable AI models in the US, grouped by state? | SELECT country, AVG(confidence) FROM ExplainableAI WHERE country = 'USA' GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE Military_Equipment_Sales (seller VARCHAR(255), equipment VARCHAR(255), year INT, quantity INT); INSERT INTO Military_Equipment_Sales (seller, equipment, year, quantity) VALUES ('Lockheed Martin', 'Tank', 2021, 150), ('Lockheed Martin', 'Humvee', 2021, 200); | What is the total number of military vehicles sold by 'Lockheed Martin' in '2021'? | SELECT SUM(quantity) FROM Military_Equipment_Sales WHERE seller = 'Lockheed Martin' AND year = 2021 AND equipment = 'Tank' OR equipment = 'Humvee'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Contracts (Month VARCHAR(7), Count INT); INSERT INTO Contracts (Month, Count) VALUES ('Jan-2021', 150), ('Feb-2021', 175), ('Mar-2021', 200), ('Apr-2021', 225), ('May-2021', 250), ('Jun-2021', 275), ('Jul-2021', 300), ('Aug-2021', 325), ('Sep-2021', 350), ('Oct-2021', 375), ('Nov-2021', 400), ('Dec-2021', ... | What is the total number of defense contracts awarded per month? | SELECT STR_TO_DATE(Month, '%b-%Y') AS Month, SUM(Count) FROM Contracts GROUP BY Month; | gretelai_synthetic_text_to_sql |
CREATE TABLE MuseumStores (id INT, location VARCHAR(50), date DATE, revenue DECIMAL(5,2)); INSERT INTO MuseumStores (id, location, date, revenue) VALUES (1, 'Paris', '2022-01-01', 100.00), (2, 'Rome', '2022-01-02', 200.00), (3, 'Paris', '2022-04-03', 300.00); | What is the total revenue generated by museum stores in Paris and Rome in the last quarter? | SELECT location, SUM(revenue) FROM MuseumStores WHERE date >= DATEADD(quarter, -1, GETDATE()) AND location IN ('Paris', 'Rome') GROUP BY location; | gretelai_synthetic_text_to_sql |
CREATE TABLE hotels (hotel_id INT, hotel_name VARCHAR(50), rating DECIMAL(2,1), PRIMARY KEY (hotel_id)); | Update the "rating" field in the "hotels" table for all records with a "hotel_name" of 'Grand Hotel' to be 4.8 | UPDATE hotels SET rating = 4.8 WHERE hotel_name = 'Grand Hotel'; | gretelai_synthetic_text_to_sql |
CREATE TABLE factories (id INT PRIMARY KEY, name VARCHAR(255), location VARCHAR(255), co2_emission_per_year INT); | What is the average CO2 emission per garment for factories located in the 'Greater London' region? | SELECT AVG(co2_emission_per_year / quantity_manufactured) as avg_co2_emission_per_garment FROM factories WHERE location LIKE 'Greater London%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE policyholders (id INT, name TEXT, city TEXT, state TEXT, claim_amount FLOAT, coverage TEXT); INSERT INTO policyholders (id, name, city, state, claim_amount, coverage) VALUES (1, 'John Doe', 'New York', 'NY', 1200.00, 'Comprehensive'); INSERT INTO policyholders (id, name, city, state, claim_amount, coverage... | Find the average claim amount for policyholders in 'New York' who have comprehensive coverage. | SELECT AVG(claim_amount) FROM policyholders WHERE state = 'NY' AND coverage = 'Comprehensive'; | gretelai_synthetic_text_to_sql |
CREATE TABLE ambulances (ambulance_id INT, county TEXT, state TEXT); | How many ambulances are available in each rural county of South Dakota? | SELECT county, COUNT(ambulance_id) AS ambulance_count FROM ambulances WHERE state = 'South Dakota' GROUP BY county; | gretelai_synthetic_text_to_sql |
CREATE TABLE clients (client_id INT, client_name TEXT, region TEXT, financial_capability_score FLOAT); | What is the average financial capability score of clients in the Asia-Pacific region? | SELECT AVG(clients.financial_capability_score) FROM clients WHERE clients.region = 'Asia-Pacific'; | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_species (id INT, species VARCHAR(50), ocean VARCHAR(50), conservation_status VARCHAR(50)); | Insert a new marine species 'Sperm Whale' into the Pacific Ocean with a conservation status of 'Vulnerable'. | INSERT INTO marine_species (species, ocean, conservation_status) VALUES ('Sperm Whale', 'Pacific', 'Vulnerable'); | gretelai_synthetic_text_to_sql |
CREATE TABLE ProfessionalDevelopment (TeacherID int, Date date, ProfessionalDevelopmentScore int); | Update the 'ProfessionalDevelopmentScore' field for a professional development record in the 'ProfessionalDevelopment' table | UPDATE ProfessionalDevelopment SET ProfessionalDevelopmentScore = 95 WHERE TeacherID = 5678 AND Date = '2022-10-01'; | gretelai_synthetic_text_to_sql |
CREATE TABLE transactions (tx_id INT, sc_id INT, transaction_volume DECIMAL(10,2), transaction_date DATE); CREATE TABLE smart_contracts (sc_id INT, name VARCHAR(255)); | What is the rank of each smart contract by transaction volume, and how many smart contracts are in the top 10% by transaction volume? | SELECT sc_id, name, RANK() OVER (ORDER BY transaction_volume DESC) as transaction_volume_rank FROM transactions t JOIN smart_contracts s ON t.sc_id = s.sc_id; SELECT COUNT(*) FROM (SELECT sc_id, name, RANK() OVER (ORDER BY transaction_volume DESC) as transaction_volume_rank FROM transactions t JOIN smart_contracts s ON... | gretelai_synthetic_text_to_sql |
CREATE TABLE fare_distribution (route_id INT, trips_taken INT, fare_collected DECIMAL(5,2)); INSERT INTO fare_distribution (route_id, trips_taken, fare_collected) VALUES (1, 500, 1200.00), (2, 600, 1950.00), (3, 450, 1125.00); | Calculate the average fare per trip and number of trips per route | SELECT route_id, AVG(fare_collected / trips_taken) as average_fare_per_trip, AVG(trips_taken) as average_trips_per_route FROM fare_distribution GROUP BY route_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE funding (funding_id INT, company_id INT, funding_amount FLOAT); | Insert data into funding records table | INSERT INTO funding (funding_id, company_id, funding_amount) VALUES (1, 1, 50000), (2, 2, 75000), (3, 3, 100000), (4, 4, 150000), (5, 5, 200000); | gretelai_synthetic_text_to_sql |
CREATE TABLE healthcare_providers (provider_id INT, name TEXT, state TEXT, score INT); INSERT INTO healthcare_providers (provider_id, name, state, score) VALUES (1, 'Dr. Smith', 'CA', 90), (2, 'Dr. Johnson', 'CA', 85), (3, 'Dr. Rodriguez', 'TX', 95), (4, 'Dr. Lee', 'NY', 80), (5, 'Dr. Patel', 'CA', 99), (6, 'Dr. Kim', ... | What is the minimum and maximum cultural competency score for healthcare providers in each state? | SELECT state, MIN(score) AS min_score, MAX(score) AS max_score FROM healthcare_providers GROUP BY state; | gretelai_synthetic_text_to_sql |
CREATE TABLE wells (well_id INT, well_name TEXT, location TEXT, gas_production FLOAT); INSERT INTO wells (well_id, well_name, location, gas_production) VALUES (1, 'Well A', 'Argentina', 1200.5), (2, 'Well B', 'Argentina', 1500.3), (3, 'Well C', 'Brazil', 1700.2), (4, 'Well D', 'Venezuela', 800.8), (5, 'Well E', 'Colomb... | Which country had the highest natural gas production in South America in 2019? | SELECT location, SUM(gas_production) as total_gas_production FROM wells GROUP BY location ORDER BY total_gas_production DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE countries (country_id INT, country_name VARCHAR(100));CREATE TABLE space_missions (mission_id INT, country_id INT, mission_name VARCHAR(100)); | What are the top 5 countries with the most space missions? | SELECT countries.country_name, COUNT(space_missions.mission_id) AS missions_count FROM countries INNER JOIN space_missions ON countries.country_id = space_missions.country_id GROUP BY countries.country_name ORDER BY missions_count DESC LIMIT 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE Attendance (ID INT, ParticipantName TEXT, Program TEXT, Age INT, Attended BOOLEAN); INSERT INTO Attendance (ID, ParticipantName, Program, Age, Attended) VALUES (1, 'Jane Doe', 'Art Class', 25, TRUE), (2, 'John Smith', 'Music Class', 30, FALSE), (3, 'Alice Johnson', 'Theater Class', 35, TRUE); | What is the attendance rate for each program by age group? | SELECT Program, Age, AVG(CASE WHEN Attended = TRUE THEN 1.0 ELSE 0.0 END) as AttendanceRate FROM Attendance GROUP BY Program, Age; | gretelai_synthetic_text_to_sql |
CREATE TABLE fairness_scores (model_name TEXT, sector TEXT, fairness_score FLOAT); INSERT INTO fairness_scores (model_name, sector, fairness_score) VALUES ('ModelA', 'Finance', 0.82), ('ModelB', 'Finance', 0.88), ('ModelC', 'Education', 0.93); | What is the minimum fairness score for models in the 'Finance' sector? | SELECT MIN(fairness_score) FROM fairness_scores WHERE sector = 'Finance'; | gretelai_synthetic_text_to_sql |
CREATE TABLE user_ratings (user_id INT, movie_title VARCHAR(50), rating INT, rating_date DATE); CREATE TABLE show_views (user_id INT, show_name VARCHAR(50), views_date DATE); | Show the number of users who have rated movies and watched shows in each quarter of 2020. | SELECT DATE_FORMAT(rating_date, '%Y-%m') AS quarter, COUNT(DISTINCT user_id) FROM user_ratings WHERE YEAR(rating_date) = 2020 AND MONTH(rating_date) IN (1, 2, 3) GROUP BY quarter UNION SELECT DATE_FORMAT(views_date, '%Y-%m') AS quarter, COUNT(DISTINCT user_id) FROM show_views WHERE YEAR(views_date) = 2020 AND MONTH(vie... | gretelai_synthetic_text_to_sql |
CREATE TABLE MLB_Matches (MatchID INT, HomeTeam VARCHAR(50), AwayTeam VARCHAR(50), HomeTeamScore INT, AwayTeamScore INT); INSERT INTO MLB_Matches (MatchID, HomeTeam, AwayTeam, HomeTeamScore, AwayTeamScore) VALUES (1, 'New York Yankees', 'Boston Red Sox', 7, 7); | How many matches in the MLB have had a result of a 7-7 draw? | SELECT COUNT(*) FROM MLB_Matches WHERE HomeTeamScore = 7 AND AwayTeamScore = 7; | gretelai_synthetic_text_to_sql |
CREATE TABLE supplier_trends (supplier VARCHAR(25), element VARCHAR(2), quantity INT, quarter INT, year INT); INSERT INTO supplier_trends VALUES ('SupplierA', 'Eu', 500, 1, 2022), ('SupplierB', 'Eu', 300, 1, 2022), ('SupplierC', 'Eu', 700, 1, 2022); | What was the total quantity of Eu supplied by each supplier in Q1 2022, ordered by supplier name? | SELECT supplier, SUM(quantity) as total_quantity FROM supplier_trends WHERE element = 'Eu' AND quarter = 1 AND year = 2022 GROUP BY supplier ORDER BY supplier; | gretelai_synthetic_text_to_sql |
CREATE TABLE Service_Responses (City VARCHAR(20), Service VARCHAR(20), Response_Time INT); INSERT INTO Service_Responses (City, Service, Response_Time) VALUES ('CityC', 'Public Safety', 6); INSERT INTO Service_Responses (City, Service, Response_Time) VALUES ('CityC', 'Health Services', 8); | What is the average response time for public safety and health services in CityC? | SELECT City, AVG(CASE WHEN Service = 'Public Safety' THEN Response_Time ELSE 0 END) AS 'Public Safety Avg Response Time', AVG(CASE WHEN Service = 'Health Services' THEN Response_Time ELSE 0 END) AS 'Health Services Avg Response Time' FROM Service_Responses WHERE City = 'CityC' GROUP BY City; | gretelai_synthetic_text_to_sql |
CREATE TABLE products (product_id INT, segment VARCHAR(20), price DECIMAL(5,2)); INSERT INTO products (product_id, segment, price) VALUES (1, 'Natural', 15.99), (2, 'Organic', 20.99), (3, 'Natural', 12.49); | What is the difference in price between the most expensive and least expensive products in the Natural segment? | SELECT t1.segment, t1.price - t2.price AS price_difference FROM (SELECT segment, MAX(price) AS price FROM products GROUP BY segment) t1 INNER JOIN (SELECT segment, MIN(price) AS price FROM products GROUP BY segment) t2 ON t1.segment = t2.segment; | gretelai_synthetic_text_to_sql |
CREATE TABLE veteran_employment (id INT, company VARCHAR(50), state VARCHAR(50), employment_date DATE, num_veterans INT); INSERT INTO veteran_employment (id, company, state, employment_date, num_veterans) VALUES (1, 'ABC', 'California', '2022-01-01', 100); INSERT INTO veteran_employment (id, company, state, employment_... | What is the average number of veterans employed by each company in California in Q1 2022? | SELECT AVG(num_veterans) FROM veteran_employment WHERE state = 'California' AND employment_date BETWEEN '2022-01-01' AND '2022-03-31' GROUP BY company; | gretelai_synthetic_text_to_sql |
CREATE TABLE peacekeeping_operations (id INT PRIMARY KEY, operation VARCHAR(255), year INT, region VARCHAR(255)); | How many peacekeeping operations were conducted between 2010 and 2020? | SELECT COUNT(*) as total_operations FROM peacekeeping_operations WHERE year BETWEEN 2010 AND 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE employees (id INT, name VARCHAR(50), department VARCHAR(50), salary FLOAT, employment_status VARCHAR(50)); INSERT INTO employees (id, name, department, salary, employment_status) VALUES (1, 'John Doe', 'IT', 75000.0, 'Full-time'), (2, 'Jane Smith', 'IT', 80000.0, 'Part-time'), (3, 'Alice Johnson', 'IT', 90... | What is the total number of employees in each department, including those without an assigned manager? | SELECT departments.name, COUNT(employees.id) FROM departments LEFT JOIN employees ON departments.name = employees.department GROUP BY departments.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE mobile_revenue(quarter INT, revenue FLOAT); INSERT INTO mobile_revenue(quarter, revenue) VALUES (1, 1500000), (2, 1800000), (3, 2250000), (4, 2500000); CREATE TABLE broadband_revenue(quarter INT, revenue FLOAT); INSERT INTO broadband_revenue(quarter, revenue) VALUES (1, 2000000), (2, 2750000), (3, 3250000)... | What is the total revenue generated from mobile and broadband services in the first quarter of 2021? | SELECT SUM(revenue) FROM (SELECT revenue FROM mobile_revenue WHERE quarter = 1 UNION SELECT revenue FROM broadband_revenue WHERE quarter = 1); | gretelai_synthetic_text_to_sql |
CREATE TABLE visitors (id INT, visitor TEXT, event TEXT, category TEXT); INSERT INTO visitors (id, visitor, event, category) VALUES (1, 'John Doe', 'Art Exhibit', 'art'), (2, 'Jane Smith', 'Theatre Play', 'theatre'), (3, 'Michael Lee', 'Concert', 'music'); | What is the total number of visitors for each cultural event category, sorted by the number of visitors in descending order? | SELECT category, COUNT(DISTINCT visitor) as num_visitors FROM visitors GROUP BY category ORDER BY num_visitors DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE if not exists countries (id INT PRIMARY KEY, name VARCHAR(50), continent VARCHAR(50)); INSERT INTO countries (id, name, continent) VALUES (1, 'Argentina', 'South America'); INSERT INTO countries (id, name, continent) VALUES (2, 'Brazil', 'South America'); CREATE TABLE if not exists projects (id INT PRIMARY... | What is the name of the projects and their budget in South America? | SELECT p.name, p.budget FROM projects p JOIN countries c ON p.country_id = c.id WHERE c.continent = 'South America'; | gretelai_synthetic_text_to_sql |
CREATE TABLE humanitarian_assistance (id INT PRIMARY KEY, organization VARCHAR(100), personnel INT); INSERT INTO humanitarian_assistance (id, organization, personnel) VALUES (1, 'Org 1', 1200), (2, 'Org 2', 1500), (3, 'Org 3', 1000); | What is the maximum number of humanitarian assistance personnel deployed by a single organization? | SELECT MAX(personnel) FROM humanitarian_assistance; | gretelai_synthetic_text_to_sql |
CREATE TABLE menus (menu_id INT, menu_name VARCHAR(50), type VARCHAR(20), price DECIMAL(5,2)); INSERT INTO menus (menu_id, menu_name, type, price) VALUES (1, 'Quinoa Salad', 'vegetarian', 9.99), (2, 'Margherita Pizza', 'non-vegetarian', 12.99), (3, 'Chickpea Curry', 'vegetarian', 10.99), (4, 'Beef Burger', 'non-vegetar... | How many vegan menu items are there in total? | SELECT COUNT(*) FROM menus WHERE type = 'vegan'; | gretelai_synthetic_text_to_sql |
CREATE TABLE manufacturing (item_code VARCHAR(20), item_name VARCHAR(50), category VARCHAR(20), country VARCHAR(50), quantity INT, is_eco_friendly BOOLEAN); | What is the total quantity of eco-friendly clothing items manufactured in Italy in Q1 2021? | SELECT SUM(quantity) as total_quantity FROM manufacturing WHERE category = 'clothing' AND country = 'Italy' AND is_eco_friendly = TRUE AND manufacturing_date BETWEEN '2021-01-01' AND '2021-03-31'; | gretelai_synthetic_text_to_sql |
CREATE TABLE songs (id INT, title VARCHAR(100), release_year INT, genre VARCHAR(50), streams INT); INSERT INTO songs (id, title, release_year, genre, streams) VALUES (1, 'Shape of You', 2017, 'Pop', 2000000000); INSERT INTO songs (id, title, release_year, genre, streams) VALUES (2, 'Sicko Mode', 2018, 'Hip Hop', 150000... | What is the maximum number of streams for a song released in 2018? | SELECT MAX(streams) FROM songs WHERE release_year = 2018; | gretelai_synthetic_text_to_sql |
CREATE TABLE travel_advisories (travel_advisory_id INT, destination VARCHAR(50), travel_advisory_level INT, updated_date DATE, PRIMARY KEY (travel_advisory_id)); | Update all records in the "travel_advisories" table with a "travel_advisory_level" of '3' to have an 'updated_date' of '2023-01-01' | UPDATE travel_advisories SET updated_date = '2023-01-01' WHERE travel_advisory_level = 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE art_collections (id INT, collection_name VARCHAR(255), city VARCHAR(255), value DECIMAL(10,2)); INSERT INTO art_collections (id, collection_name, city, value) VALUES (1, 'The Met Collection', 'New York', 50000000.00), (2, 'The Guggenheim Collection', 'New York', 20000000.00), (3, 'The MoMA Collection', 'Ne... | Calculate the total value of art collections in New York, NY. | SELECT SUM(value) FROM art_collections WHERE city = 'New York'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Policy (PolicyID INT, PolicyType VARCHAR(50)); INSERT INTO Policy VALUES (1, 'Auto'), (2, 'Home'), (3, 'Life'); CREATE TABLE Claims (ClaimID INT, PolicyID INT, ClaimAmount DECIMAL(10,2)); INSERT INTO Claims VALUES (1, 1, 500.00), (2, 1, 200.00), (3, 2, 750.00), (4, 3, 15000.00), (5, 1, 300.00) | What is the average claim amount for policy type 'Auto'? | SELECT AVG(ClaimAmount) as AvgClaimAmount FROM Policy p INNER JOIN Claims c ON p.PolicyID = c.PolicyID WHERE p.PolicyType = 'Auto'; | gretelai_synthetic_text_to_sql |
CREATE TABLE warehouse_k(item_id INT, item_type VARCHAR(10), quantity INT);CREATE TABLE warehouse_l(item_id INT, item_type VARCHAR(10), quantity INT);INSERT INTO warehouse_k(item_id, item_type, quantity) VALUES (1, 'C', 200), (2, 'C', 300), (3, 'C', 50);INSERT INTO warehouse_l(item_id, item_type, quantity) VALUES (1, '... | What is the total quantity of items with type 'C' in warehouse K and warehouse L? | SELECT quantity FROM warehouse_k WHERE item_type = 'C' UNION ALL SELECT quantity FROM warehouse_l WHERE item_type = 'C'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Agency (id INT PRIMARY KEY, name VARCHAR(100), state_id INT, area DECIMAL(10,2)); INSERT INTO Agency (id, name, state_id, area) VALUES (1, 'California Public Utilities Commission', 1, 50000); | What are the names and states of agencies with an area larger than the average state area, and whose names contain the word 'Commission'? | SELECT a.name, s.name AS state_name FROM Agency a INNER JOIN State s ON a.state_id = s.id WHERE s.area < (SELECT AVG(area) FROM State) AND a.name LIKE '%Commission%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE donors (donor_id INT, region VARCHAR(20), contributions DECIMAL(10,2)); INSERT INTO donors (donor_id, region, contributions) VALUES (1, 'Asia', 50000.00), (2, 'Europe', 100000.00), (3, 'North America', 200000.00), (4, 'Asia', 75000.00), (5, 'Asia', 100000.00); | Who are the top 5 donors contributing to technology for social good projects in Asia? | SELECT donor_id, contributions FROM donors WHERE region = 'Asia' ORDER BY contributions DESC LIMIT 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE players (id INT, age INT, genre VARCHAR(20)); INSERT INTO players (id, age, genre) VALUES (1, 40, 'RPG'), (2, 35, 'RPG'), (3, 25, 'FPS'), (4, 50, 'RPG'); | Who are the top 3 oldest players in the 'RPG' genre? | SELECT * FROM (SELECT id, age, ROW_NUMBER() OVER (ORDER BY age DESC) AS rn FROM players WHERE genre = 'RPG') sub WHERE rn <= 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE Donors (DonorID INT, DonorName TEXT, DonationAmount DECIMAL(10,2)); INSERT INTO Donors (DonorID, DonorName, DonationAmount) VALUES (1, 'John Doe', 500.00), (2, 'Jane Smith', 350.00); | What is the total amount donated by each donor in Q1 2021? | SELECT DonorName, SUM(DonationAmount) as TotalDonation FROM Donors WHERE DonationDate BETWEEN '2021-01-01' AND '2021-03-31' GROUP BY DonorName; | gretelai_synthetic_text_to_sql |
CREATE TABLE ports (port_id INT, port_name VARCHAR(20)); INSERT INTO ports (port_id, port_name) VALUES (1, 'LA'), (2, 'LB'), (3, 'HOU'); CREATE TABLE cargo (cargo_id INT, port_id INT, tonnage INT); INSERT INTO cargo (cargo_id, port_id, tonnage) VALUES (1, 1, 500000), (2, 1, 300000), (3, 2, 800000), (4, 3, 600000); | What is the total tonnage of cargo unloaded at port 'LB'? | SELECT SUM(tonnage) FROM cargo WHERE port_id = (SELECT port_id FROM ports WHERE port_name = 'LB'); | gretelai_synthetic_text_to_sql |
CREATE TABLE matches (match_id INT, home_team INT, away_team INT, home_team_score INT, away_team_score INT); CREATE TABLE teams (team_id INT, name VARCHAR(50), city VARCHAR(50)); | Show the total number of goals scored by each team in the 'matches' and 'teams' tables. | SELECT t.name, SUM(m.home_team_score + m.away_team_score) AS total_goals FROM teams t JOIN matches m ON t.team_id IN (m.home_team, m.away_team) GROUP BY t.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE company_data (company_id INT, company_name VARCHAR(50), company_region VARCHAR(20)); CREATE TABLE transactions (transaction_id INT, company_id INT, transaction_value FLOAT, transaction_date DATE); INSERT INTO company_data (company_id, company_name, company_region) VALUES (1, 'Ethical AI Co.', 'Asia-Pacific... | What is the daily transaction growth rate for ethical AI companies in the Asia-Pacific region, for Q2 2021? | SELECT ROW_NUMBER() OVER (ORDER BY transaction_date) as day, (LAG(SUM(transaction_value)) OVER (ORDER BY transaction_date) - SUM(transaction_value)) / ABS(LAG(SUM(transaction_value)) OVER (ORDER BY transaction_date)) as growth_rate FROM transactions INNER JOIN company_data ON transactions.company_id = company_data.comp... | gretelai_synthetic_text_to_sql |
CREATE TABLE ImmigrationCases (CaseID INT, CaseType VARCHAR(20), AttorneyLastName VARCHAR(20), BillingAmount DECIMAL(10,2)); INSERT INTO ImmigrationCases (CaseID, CaseType, AttorneyLastName, BillingAmount) VALUES (1, 'Immigration', 'Garcia', 5000.00), (2, 'Immigration', 'Rodriguez', 3000.00), (3, 'Immigration', 'Garcia... | List all unique attorney last names who have billed for cases in the 'Immigration' case type, in descending order based on the number of cases they handled. | SELECT DISTINCT AttorneyLastName, COUNT(*) AS CaseCount FROM ImmigrationCases WHERE CaseType = 'Immigration' GROUP BY AttorneyLastName ORDER BY CaseCount DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE subscribers (subscriber_id INT, subscription_type VARCHAR(10), data_usage FLOAT, data_limit FLOAT, usage_date DATE); INSERT INTO subscribers (subscriber_id, subscription_type, data_usage, data_limit, usage_date) VALUES (1, 'postpaid', 3.5, 2.0, '2022-03-01'), (2, 'prepaid', 2.0, 1.5, '2022-03-01'), (3, 'po... | What is the percentage of mobile subscribers who have used more than 50% of their data limit in the current month, for each subscription type, ordered by subscription type and percentage? | SELECT subscription_type, AVG(CASE WHEN data_usage > 0.5 * data_limit THEN 1 ELSE 0 END) * 100 as pct_used_more_than_50_percent FROM subscribers WHERE usage_date >= LAST_DAY(CURRENT_DATE) AND usage_date < LAST_DAY(CURRENT_DATE) + INTERVAL 1 DAY GROUP BY subscription_type ORDER BY subscription_type, pct_used_more_than_5... | gretelai_synthetic_text_to_sql |
CREATE TABLE patient_info_2023 (patient_id INT, first_treatment_date DATE); INSERT INTO patient_info_2023 (patient_id, first_treatment_date) VALUES (5, '2023-02-03'), (6, '2023-01-15'), (7, '2023-06-28'), (8, NULL); CREATE TABLE therapy_sessions_2023 (patient_id INT, session_date DATE); INSERT INTO therapy_sessions_202... | Update the patient's first_treatment_date to the earliest therapy session date if the current date is on or after '2023-06-01' | UPDATE patient_info_2023 JOIN (SELECT patient_id, MIN(session_date) AS min_session_date FROM therapy_sessions_2023 WHERE session_date < '2023-06-01' GROUP BY patient_id) AS earliest_sessions ON patient_info_2023.patient_id = earliest_sessions.patient_id SET patient_info_2023.first_treatment_date = earliest_sessions.min... | gretelai_synthetic_text_to_sql |
CREATE TABLE BAE_Timelines (id INT, corporation VARCHAR(20), region VARCHAR(20), project_name VARCHAR(20), start_date DATE, end_date DATE); INSERT INTO BAE_Timelines (id, corporation, region, project_name, start_date, end_date) VALUES (1, 'BAE Systems', 'Oceania', 'Project A', '2020-01-01', '2022-12-31'); | What are the defense project timelines for BAE Systems in Oceania? | SELECT project_name, start_date, end_date FROM BAE_Timelines WHERE corporation = 'BAE Systems' AND region = 'Oceania'; | gretelai_synthetic_text_to_sql |
CREATE TABLE local_businesses (id INT, name TEXT, country TEXT, hotel_name TEXT); INSERT INTO local_businesses (id, name, country, hotel_name) VALUES (1, 'Eco Shop', 'Italy', 'Eco Hotel Rome'); | How many local businesses in 'Italy' are associated with eco-friendly hotels? | SELECT COUNT(*) FROM local_businesses JOIN hotels ON local_businesses.hotel_name = hotels.name WHERE local_businesses.country = 'Italy' AND hotels.name LIKE '%eco%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Donors (DonorID INT, Name VARCHAR(50), TotalDonation DECIMAL(10,2)); INSERT INTO Donors (DonorID, Name, TotalDonation) VALUES (1, 'John Doe', 500.00), (2, 'Jane Smith', 350.00), (3, 'Mike Johnson', 200.00); | What is the percentage of total donations made by each donor, ordered by the percentage in descending order? | SELECT Name, 100.0 * SUM(TotalDonation) OVER (PARTITION BY NULL) / SUM(SUM(TotalDonation)) OVER () AS Percentage FROM Donors ORDER BY Percentage DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE climate_adaptation (project_id INT, project_name VARCHAR(255), location VARCHAR(255), start_date DATE, end_date DATE, total_cost DECIMAL(10,2)); | Get the total cost of all climate adaptation projects in 'South America'. | SELECT SUM(total_cost) FROM climate_adaptation WHERE location = 'South America'; | gretelai_synthetic_text_to_sql |
CREATE TABLE NYCFireStations (Borough VARCHAR(255), Number INT); INSERT INTO NYCFireStations (Borough, Number) VALUES ('Manhattan', 32), ('Brooklyn', 45), ('Queens', 50), ('Bronx', 39), ('Staten Island', 11); | What is the total number of fire stations in each borough of New York City? | SELECT Borough, SUM(Number) as TotalFireStations FROM NYCFireStations GROUP BY Borough; | gretelai_synthetic_text_to_sql |
CREATE TABLE oceans (ocean_id INT, name VARCHAR(50)); CREATE TABLE species (species_id INT, name VARCHAR(50), ocean_id INT, avg_depth DECIMAL(5,2)); INSERT INTO oceans VALUES (1, 'Atlantic'), (2, 'Indian'), (3, 'Pacific'); INSERT INTO species VALUES (1, 'Clownfish', 2, 10), (2, 'Salmon', 1, 100), (3, 'Clownfish', 3, 15... | Which marine species have a higher average depth in the Atlantic compared to the Indian Ocean? | SELECT s.name FROM species s WHERE s.ocean_id IN (1, 2) GROUP BY s.name HAVING AVG(s.avg_depth) > (SELECT AVG(s.avg_depth) FROM species s WHERE s.ocean_id = 3); | gretelai_synthetic_text_to_sql |
CREATE TABLE wells (id VARCHAR(10), name VARCHAR(10), region VARCHAR(20)); INSERT INTO wells (id, name, region) VALUES ('W002', 'B', 'NorthSea'), ('W003', 'C', 'NorthSea'); CREATE TABLE production (well_id VARCHAR(10), date DATE, quantity INT); INSERT INTO production (well_id, date, quantity) VALUES ('W002', '2022-01-0... | Which wells in the 'NorthSea' have had no production in the last month? | SELECT well_id FROM production WHERE well_id IN (SELECT id FROM wells WHERE region = 'NorthSea') AND date >= (CURRENT_DATE - INTERVAL '1 month') AND quantity = 0; | gretelai_synthetic_text_to_sql |
CREATE TABLE dishes (id INT, name TEXT, type TEXT, price DECIMAL, cost DECIMAL); INSERT INTO dishes (id, name, type, price, cost) VALUES (1, 'Quinoa Salad', 'Vegan', 12.99, 5.50), (2, 'Chickpea Curry', 'Vegan', 10.99, 7.99), (3, 'Beef Burger', 'Non-Vegan', 15.99, 10.50), (4, 'Chicken Sandwich', 'Non-Vegan', 14.99, 9.50... | Which dish has the lowest cost? | SELECT name, cost FROM dishes WHERE cost = (SELECT MIN(cost) FROM dishes); | gretelai_synthetic_text_to_sql |
CREATE TABLE Warehouse (item VARCHAR(10), quantity INT); INSERT INTO Warehouse (item, quantity) VALUES ('A101', 50), ('B202', 75); | Display the warehouse stock for item 'B202' | SELECT item, quantity FROM Warehouse WHERE item = 'B202'; | gretelai_synthetic_text_to_sql |
CREATE TABLE district (did INT, district_name VARCHAR(255)); INSERT INTO district (did, district_name) VALUES (1, 'Central'), (2, 'North'), (3, 'South'); CREATE TABLE drills (drill_id INT, did INT, drill_date DATE); | How many disaster preparedness drills were conducted in the last quarter in the 'South' district? | SELECT COUNT(*) FROM drills WHERE did = 3 AND drill_date >= DATEADD(quarter, -1, GETDATE()); | gretelai_synthetic_text_to_sql |
CREATE TABLE Game_Library (game_id INT, game_name VARCHAR(50), player_id INT); INSERT INTO Game_Library (game_id, game_name, player_id) VALUES (1, 'Space Invaders', 1), (2, 'Star Wars', 2), (3, 'Space Ranger', 3); | How many games have players participated in that start with the word 'Space' in the game library? | SELECT COUNT(DISTINCT game_id) FROM Game_Library WHERE game_name LIKE 'Space%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Military_Innovation_Spending (id INT, country VARCHAR(50), year INT, spending INT); | What is the total spending on military innovation by the top 3 contributing countries in the past 5 years? | SELECT SUM(spending) as total_spending, country FROM Military_Innovation_Spending WHERE year BETWEEN (YEAR(CURRENT_DATE) - 5) AND YEAR(CURRENT_DATE) GROUP BY country ORDER BY total_spending DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE Hotels (hotel_id INT, hotel_name VARCHAR(50), country VARCHAR(50), is_green_certified BOOLEAN, energy_consumption FLOAT); INSERT INTO Hotels (hotel_id, hotel_name, country, is_green_certified, energy_consumption) VALUES (1, 'GreenHotel Ottawa', 'Canada', true, 120.00), (2, 'EcoLodge Montreal', 'Canada', tr... | Show the average energy consumption of green-certified hotels in Canada. | SELECT AVG(energy_consumption) FROM Hotels WHERE country = 'Canada' AND is_green_certified = true; | gretelai_synthetic_text_to_sql |
CREATE TABLE movie_releases (id INT, title VARCHAR(255), studio VARCHAR(255), release_date DATE); INSERT INTO movie_releases (id, title, studio, release_date) VALUES (1, 'Movie1', 'Studio1', '2020-01-01'), (2, 'Movie2', 'Studio2', '2020-02-01'), (3, 'Movie3', 'Studio1', '2020-03-01'); | How many movies were released by each studio in 2020? | SELECT studio, COUNT(*) as movie_count FROM movie_releases WHERE YEAR(release_date) = 2020 GROUP BY studio; | gretelai_synthetic_text_to_sql |
CREATE TABLE patients (patient_id INT, age INT, emergency_room_wait_time INT, location VARCHAR(255)); INSERT INTO patients (patient_id, age, emergency_room_wait_time, location) VALUES (12, 32, 60, 'rural Brazil'); INSERT INTO patients (patient_id, age, emergency_room_wait_time, location) VALUES (13, 50, 90, 'rural Braz... | What is the average emergency room wait time for patients in rural Brazil, and how many nurses are available per patient in the emergency room? | SELECT AVG(emergency_room_wait_time) AS avg_wait_time, COUNT(nurses.nurse_id) / COUNT(DISTINCT patients.patient_id) AS nurses_per_patient FROM patients INNER JOIN nurses ON patients.location = nurses.location WHERE patients.location LIKE 'rural% Brazil'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Graduate_Students (Student_ID INT, First_Name VARCHAR(50), Last_Name VARCHAR(50), Gender VARCHAR(10), Enrollment_Status VARCHAR(20)); | Delete records in the 'Graduate_Students' table where the 'Gender' is 'Unknown' and 'Enrollment_Status' is 'Inactive' | DELETE FROM Graduate_Students WHERE Gender = 'Unknown' AND Enrollment_Status = 'Inactive'; | gretelai_synthetic_text_to_sql |
CREATE TABLE director (director_id INT, director_name VARCHAR(50), total_gross INT); INSERT INTO director (director_id, director_name, total_gross) VALUES (1, 'Director 1', 50000000), (2, 'Director 2', 70000000), (3, 'Director 3', 30000000); CREATE TABLE movie (movie_id INT, title VARCHAR(50), release_year INT, gross I... | Who are the top 3 directors with the highest total gross for movies released between 2015 and 2020? | SELECT director_name, SUM(gross) FROM movie JOIN director ON movie.director_id = director.director_id WHERE release_year BETWEEN 2015 AND 2020 GROUP BY director_name ORDER BY SUM(gross) DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE crime_incidents (id INT PRIMARY KEY, incident_date DATE, incident_type VARCHAR(255)); INSERT INTO crime_incidents (id, incident_date, incident_type) VALUES (1, '2010-01-02', 'Theft'), (2, '2009-12-31', 'Assault'), (3, '2010-01-05', 'Burglary'); | Update the incident_dates in the crime_incidents table for the 'Theft' incident type to be a month later | UPDATE crime_incidents SET incident_date = DATE_ADD(incident_date, INTERVAL 1 MONTH) WHERE incident_type = 'Theft'; | gretelai_synthetic_text_to_sql |
CREATE TABLE StudentAccommodations (studentID INT, accommodationType VARCHAR(50), cost FLOAT); | Display the number of students who received accommodations in the StudentAccommodations table by accommodation type. | SELECT accommodationType, COUNT(*) FROM StudentAccommodations GROUP BY accommodationType; | gretelai_synthetic_text_to_sql |
CREATE TABLE fish_stock (species VARCHAR(50), biomass INT); INSERT INTO fish_stock (species, biomass) VALUES ('Tilapia', 500), ('Tilapia', 700), ('Salmon', 800); | What is the total number of fish in the fish_stock table? | SELECT COUNT(*) FROM fish_stock; | gretelai_synthetic_text_to_sql |
CREATE TABLE InvestmentsMax (id INT, investor VARCHAR(255), sector VARCHAR(255), amount DECIMAL(10,2)); | What is the maximum 'amount' invested by 'SustainableFund'? | SELECT MAX(amount) FROM InvestmentsMax WHERE investor = 'SustainableFund'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Workouts (WorkoutID INT, MemberID INT, WorkoutDate DATE, Duration INT); INSERT INTO Workouts (WorkoutID, MemberID, WorkoutDate, Duration) VALUES (1, 1, '2023-01-01', 60), (2, 2, '2023-01-02', 90), (3, 3, '2023-01-03', 75); | What is the average duration of workouts for members over 40 years old? | SELECT AVG(Duration) FROM Workouts INNER JOIN Members ON Workouts.MemberID = Members.MemberID WHERE Members.Age > 40; | gretelai_synthetic_text_to_sql |
CREATE TABLE Employees (EmployeeID int, FirstName varchar(50), LastName varchar(50), Department varchar(50), Gender varchar(50), Salary decimal(10,2)); INSERT INTO Employees (EmployeeID, FirstName, LastName, Department, Gender, Salary) VALUES (1, 'John', 'Doe', 'IT', 'Male', 75000); INSERT INTO Employees (EmployeeID, F... | What is the total salary paid by department? | SELECT Department, SUM(Salary) as TotalSalary FROM Employees GROUP BY Department; | gretelai_synthetic_text_to_sql |
CREATE TABLE military_sales (id INT PRIMARY KEY, region VARCHAR(20), year INT, equipment_name VARCHAR(30), quantity INT, value FLOAT); | Insert new records for 'Missile System' sales to 'Europe' in the year '2026' with the quantity of 30 and value of 25000000 | INSERT INTO military_sales (id, region, year, equipment_name, quantity, value) VALUES (4, 'Europe', 2026, 'Missile System', 30, 25000000); | gretelai_synthetic_text_to_sql |
CREATE TABLE community_outreach_coordinators (id INT, name VARCHAR(255));CREATE TABLE education_programs (id INT, coordinator_id INT, name VARCHAR(255)); INSERT INTO community_outreach_coordinators (id, name) VALUES (1, 'Alice'), (2, 'Brenda'), (3, 'Charlie'); INSERT INTO education_programs (id, coordinator_id, name) V... | Count the number of educational programs for each community outreach coordinator | SELECT co.name AS coordinator_name, COUNT(e.id) AS program_count FROM community_outreach_coordinators co LEFT JOIN education_programs e ON co.id = e.coordinator_id GROUP BY co.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE spacecraft_temperatures (spacecraft_name TEXT, temperature FLOAT, mission_date DATE); | What is the average temperature (in Kelvin) per spacecraft per month, ranked in descending order? | SELECT spacecraft_name, DATE_TRUNC('month', mission_date) as mission_month, AVG(temperature) as avg_temperature, RANK() OVER (PARTITION BY spacecraft_name ORDER BY AVG(temperature) DESC) as temp_rank FROM spacecraft_temperatures GROUP BY spacecraft_name, mission_month ORDER BY spacecraft_name, temp_rank; | gretelai_synthetic_text_to_sql |
CREATE TABLE Auto (policyholder_id INT, car_make VARCHAR(20), car_model VARCHAR(20)); | Update car make to 'GM' for policyholders with policyholder_id 300, 301, and 302 in the 'Auto' table. | UPDATE Auto SET car_make = 'GM' WHERE policyholder_id IN (300, 301, 302); | gretelai_synthetic_text_to_sql |
CREATE TABLE raw_materials (id INT, chemical_id INT, cost FLOAT, date_purchased DATE); CREATE TABLE chemical_products (id INT, name VARCHAR(50)); | What is the total cost of all raw materials used in the production of chemical X in the past quarter? | SELECT SUM(cost) FROM raw_materials JOIN chemical_products ON raw_materials.chemical_id = chemical_products.id WHERE chemical_products.name = 'chemical X' AND date_purchased >= DATE_SUB(CURRENT_DATE, INTERVAL 3 MONTH); | gretelai_synthetic_text_to_sql |
CREATE TABLE rd_expenditure(company_name TEXT, expenditure INT, expenditure_year INT); INSERT INTO rd_expenditure(company_name, expenditure, expenditure_year) VALUES('CompanyX', 3000000, 2021); | What was the R&D expenditure for 'CompanyX' in 2021? | SELECT expenditure FROM rd_expenditure WHERE company_name = 'CompanyX' AND expenditure_year = 2021; | gretelai_synthetic_text_to_sql |
CREATE TABLE grain_production (farm_id INT, country VARCHAR(50), product VARCHAR(50), production INT); INSERT INTO grain_production (farm_id, country, product, production) VALUES (1, 'Tanzania', 'Maize', 500), (2, 'Tanzania', 'Rice', 300), (3, 'Malawi', 'Wheat', 400), (4, 'Zambia', 'Barley', 100); | What is the total production of grains in Tanzania and Malawi? | SELECT SUM(production) FROM grain_production WHERE country IN ('Tanzania', 'Malawi') AND product LIKE 'Grain%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE commercial_customers (customer_id INT, city VARCHAR(20), water_usage FLOAT); INSERT INTO commercial_customers (customer_id, city, water_usage) VALUES (1, 'Chicago', 3000), (2, 'Chicago', 4000); CREATE TABLE residential_customers (customer_id INT, city VARCHAR(20), water_usage FLOAT); INSERT INTO residentia... | What is the difference in water usage between commercial and residential customers in the city of Chicago? | SELECT SUM(commercial_customers.water_usage) - SUM(residential_customers.water_usage) FROM commercial_customers, residential_customers WHERE commercial_customers.city = 'Chicago' AND residential_customers.city = 'Chicago'; | gretelai_synthetic_text_to_sql |
CREATE TABLE NationalParks (ParkID int, ParkName varchar(255), State varchar(255)); INSERT INTO NationalParks (ParkID, ParkName, State) VALUES (1, 'Big Bend National Park', 'Texas'), (2, 'Guadalupe Mountains National Park', 'Texas'); | List the names of all national parks in the state of Texas. | SELECT ParkName FROM NationalParks WHERE State = 'Texas'; | gretelai_synthetic_text_to_sql |
CREATE TABLE transactions (id INT, customer_id INT, transaction_date DATE, amount FLOAT); INSERT INTO transactions (id, customer_id, transaction_date, amount) VALUES (1, 1, '2022-01-01', 1000.00), (2, 2, '2022-01-02', 2000.00), (3, 1, '2022-01-03', 1500.00); | Identify the number of transactions and total transaction amount per day for the past week | SELECT DATE(transaction_date) AS transaction_date, COUNT(*) AS num_transactions, SUM(amount) AS total_amount FROM transactions WHERE transaction_date BETWEEN DATE_SUB(CURDATE(), INTERVAL 7 DAY) AND CURDATE() GROUP BY transaction_date; | gretelai_synthetic_text_to_sql |
CREATE TABLE districts (id INT, name VARCHAR(255)); INSERT INTO districts (id, name) VALUES (4, 'Uptown'); CREATE TABLE emergency_incidents (id INT, district_id INT, incident_type VARCHAR(50), response_time INT); INSERT INTO emergency_incidents (id, district_id, incident_type, response_time) VALUES (1, 4, 'fire', 8), (... | Update the response time for all medical incidents in district 4 to 10 minutes | UPDATE emergency_incidents SET response_time = 10 WHERE district_id = 4 AND incident_type = 'medical'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Accommodations (student_id INT, visual_impairment BOOLEAN, mobility_impairment BOOLEAN); | How many students require accommodations for both visual and mobility impairments? | SELECT COUNT(*) FROM Accommodations WHERE visual_impairment = TRUE AND mobility_impairment = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE satellites (id INT, country VARCHAR(255), result VARCHAR(10)); INSERT INTO satellites (id, country, result) VALUES (1, 'USA', 'successful'), (2, 'China', 'successful'), (3, 'India', 'unsuccessful'), (4, 'USA', 'successful'), (5, 'China', 'successful'); | What is the total number of satellites launched by each country, and how many of those were successful? | SELECT country, COUNT(*) FILTER (WHERE result = 'successful') as successful_launches, COUNT(*) as total_launches FROM satellites GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE startups(id INT, name TEXT, founders TEXT, founding_year INT, industry TEXT); INSERT INTO startups VALUES (1, 'StartupA', 'Aisha, Pedro', 2012, 'Fintech'); INSERT INTO startups VALUES (2, 'StartupB', 'Eve', 2015, 'Healthcare'); INSERT INTO startups VALUES (3, 'StartupC', 'Carlos', 2018, 'Tech'); CREATE TAB... | What is the average founding year for startups founded by individuals who identify as Latinx in the fintech industry? | SELECT AVG(founding_year) FROM startups WHERE industry = 'Fintech' AND founders LIKE '%Pedro%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE moscow_buses (id INT, route_id VARCHAR(20), distance FLOAT, timestamp TIMESTAMP); | What is the average distance of public bus rides in Moscow? | SELECT AVG(distance) FROM moscow_buses WHERE route_id IS NOT NULL; | gretelai_synthetic_text_to_sql |
CREATE TABLE Accessible_Tech_Projects (ID INT, Project_Name VARCHAR(100), Location VARCHAR(50), Budget DECIMAL(10,2)); INSERT INTO Accessible_Tech_Projects (ID, Project_Name, Location, Budget) VALUES (1, 'Tech4All', 'Africa', 150000.00), (2, 'AI4Good', 'Africa', 200000.00), (3, 'EqualWeb', 'Europe', 120000.00); | What is the total number of accessible technology projects in Africa? | SELECT COUNT(*) FROM Accessible_Tech_Projects WHERE Location = 'Africa'; | 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.