context stringlengths 11 9.12k | question stringlengths 0 1.06k | SQL stringlengths 2 4.44k | source stringclasses 28
values |
|---|---|---|---|
CREATE TABLE members(id INT, age INT); INSERT INTO members (id, age) VALUES (1, 45), (2, 35); CREATE TABLE reps(id INT, member_id INT, exercise VARCHAR(15), reps INT); INSERT INTO reps (id, member_id, exercise, reps) VALUES (1, 1, 'deadlift', 10), (2, 2, 'squat', 8); | What is the minimum number of reps completed in the deadlift exercise by members aged 40 or above? | SELECT MIN(reps) FROM reps r JOIN members m ON r.member_id = m.id WHERE m.age >= 40 AND r.exercise = 'deadlift'; | gretelai_synthetic_text_to_sql |
CREATE TABLE pollution_records (location TEXT, year INTEGER, pollution_level REAL); INSERT INTO pollution_records (location, year, pollution_level) VALUES ('Gulf of Mexico', 2018, 4.5), ('Gulf of Mexico', 2019, 3.2), ('Gulf of Mexico', 2020, 7.8); | Update the pollution level of the Gulf of Mexico in 2019 to 5.2. | UPDATE pollution_records SET pollution_level = 5.2 WHERE location = 'Gulf of Mexico' AND year = 2019; | gretelai_synthetic_text_to_sql |
CREATE TABLE Customers (customer_id INT, customer_name TEXT, favorite_dessert TEXT, city TEXT); INSERT INTO Customers (customer_id, customer_name, favorite_dessert, city) VALUES (1, 'Tanaka Sato', 'Mochi', 'Tokyo'); | What are the top 2 most preferred desserts among customers in Tokyo? | SELECT favorite_dessert, COUNT(*) AS count FROM Customers WHERE city = 'Tokyo' GROUP BY favorite_dessert ORDER BY count DESC LIMIT 2; | gretelai_synthetic_text_to_sql |
CREATE TABLE hotels (id INT PRIMARY KEY, name VARCHAR(255), country VARCHAR(255)); INSERT INTO hotels (id, name, country) VALUES (1, 'Eco-Friendly Hotel', 'Sweden'); INSERT INTO hotels (id, name, country) VALUES (2, 'Sustainable Resort', 'Costa Rica'); | Update the name of the hotel with an id of 1 in the hotels table | UPDATE hotels SET name = 'Green Hotel' WHERE id = 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE vessels (id INT PRIMARY KEY, name VARCHAR(50), type VARCHAR(50)); CREATE TABLE accidents (id INT PRIMARY KEY, vessel_id INT, date DATE, description TEXT); | List the names and types of all vessels in the 'vessels' table that were involved in an accident in the 'accidents' table. | SELECT vessels.name, vessels.type FROM vessels INNER JOIN accidents ON vessels.id = accidents.vessel_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE temperature_records (station_id INT, timestamp TIMESTAMP, temperature FLOAT); | Find the maximum and minimum temperature recorded in the arctic. | SELECT MAX(temperature) AS max_temperature, MIN(temperature) AS min_temperature FROM temperature_records; | gretelai_synthetic_text_to_sql |
CREATE TABLE genres (genre VARCHAR(10), song_id INT, song_length FLOAT); INSERT INTO genres (genre, song_id, song_length) VALUES ('folk', 25, 280.3), ('folk', 26, 265.4), ('folk', 27, 245.1); | What is the number of songs in the folk genre that have a song_length greater than 250 seconds? | SELECT COUNT(*) FROM genres WHERE genre = 'folk' AND song_length > 250; | gretelai_synthetic_text_to_sql |
CREATE TABLE Policyholder (PolicyholderID INT, Name TEXT, Birthdate DATE, PolicyType TEXT); INSERT INTO Policyholder (PolicyholderID, Name, Birthdate, PolicyType) VALUES (1, 'John Doe', '1980-05-01', 'Auto'), (2, 'Jane Smith', '1990-10-15', 'Life'), (3, 'Mike Johnson', '1975-02-22', 'Auto'), (4, 'Alice Williams', '2000... | What are the names and birthdates of policyholders who have a policy in both the 'Auto' and 'Life' categories? | SELECT Name, Birthdate FROM Policyholder WHERE PolicyType = 'Auto' INTERSECT SELECT Name, Birthdate FROM Policyholder WHERE PolicyType = 'Life'; | gretelai_synthetic_text_to_sql |
CREATE TABLE PlayerGames (PlayerID INT, GameID INT, GameWon BOOLEAN); CREATE TABLE Games (GameID INT, GameName VARCHAR(255)); INSERT INTO Games (GameID, GameName) VALUES (1, 'GameX'), (2, 'GameY'), (3, 'GameZ'); | Determine the total number of players who have played game X in the 'PlayerGames' table | SELECT COUNT(DISTINCT PlayerID) as TotalPlayers FROM PlayerGames JOIN Games ON PlayerGames.GameID = Games.GameID WHERE Games.GameName = 'GameX'; | gretelai_synthetic_text_to_sql |
CREATE TABLE pest_data (crop_type TEXT, pest_incident DATE); INSERT INTO pest_data (crop_type, pest_incident) VALUES ('Corn', '2022-01-01'), ('Soybeans', '2022-01-02'), ('Corn', '2022-01-15'); | List crops affected by pests in the last 60 days | SELECT DISTINCT crop_type FROM pest_data WHERE pest_incident >= DATE(NOW()) - INTERVAL 60 DAY; | gretelai_synthetic_text_to_sql |
CREATE TABLE yttrium_production (id INT, year INT, producer VARCHAR(255), yttrium_prod FLOAT); INSERT INTO yttrium_production (id, year, producer, yttrium_prod) VALUES (1, 2021, 'China', 1234.5), (2, 2021, 'USA', 234.5), (3, 2021, 'Australia', 678.9), (4, 2021, 'Myanmar', 345.6), (5, 2021, 'India', 901.2); | What is the difference in Yttrium production between the maximum and minimum producers in 2021? | SELECT MAX(yttrium_prod) - MIN(yttrium_prod) FROM yttrium_production WHERE year = 2021; | gretelai_synthetic_text_to_sql |
CREATE TABLE ports (port_id INT, port_name VARCHAR(50)); INSERT INTO ports (port_id, port_name) VALUES (1, 'Los Angeles'), (2, 'Long Beach'); CREATE TABLE vessel_port (vessel_id INT, port_id INT); INSERT INTO vessel_port (vessel_id, port_id) VALUES (1, 1), (2, 2), (3, 1), (4, 2); CREATE TABLE vessels (vessel_id INT, ve... | What are the names of the vessels that have transported goods to or from the ports of Los Angeles and Long Beach? | SELECT DISTINCT v.vessel_name FROM vessels v JOIN vessel_port vp ON v.vessel_id = vp.vessel_id JOIN ports p ON vp.port_id = p.port_id WHERE p.port_name IN ('Los Angeles', 'Long Beach'); | gretelai_synthetic_text_to_sql |
CREATE TABLE Facilities (State VARCHAR(50), Type VARCHAR(50), Count INT, Year INT); INSERT INTO Facilities (State, Type, Count, Year) VALUES ('Alabama', 'Schools', 1500, 2022), ('Alabama', 'Hospitals', 200, 2022), ('Alaska', 'Schools', 200, 2022), ('Alaska', 'Hospitals', 50, 2022); | How many public schools and hospitals are there in each state of the United States, as of 2022? | SELECT State, Type, SUM(Count) as TotalFacilities FROM Facilities WHERE Year = 2022 GROUP BY State, Type; | gretelai_synthetic_text_to_sql |
CREATE TABLE farm_locations (location VARCHAR, fish_id INT); CREATE TABLE fish_stock (fish_id INT, species VARCHAR, biomass FLOAT); INSERT INTO farm_locations (location, fish_id) VALUES ('Location A', 1), ('Location B', 2), ('Location A', 3), ('Location C', 4); INSERT INTO fish_stock (fish_id, species, biomass) VALUES ... | What is the total biomass of fish for each species at Location A? | SELECT fs.species, SUM(fs.biomass) FROM fish_stock fs JOIN farm_locations fl ON fs.fish_id = fl.fish_id WHERE fl.location = 'Location A' GROUP BY fs.species; | gretelai_synthetic_text_to_sql |
CREATE TABLE climate_mitigation_targets (id INT, country VARCHAR(255), sector VARCHAR(255), year INT, target FLOAT); | Insert new records into the 'climate_mitigation_targets' table with the following details: (1, 'China', 'Emissions', '2030', 30) | INSERT INTO climate_mitigation_targets (id, country, sector, year, target) VALUES (1, 'China', 'Emissions', 2030, 30); | gretelai_synthetic_text_to_sql |
CREATE TABLE exhibitions (id INT, exhibition_name VARCHAR(50), visitor_age INT); INSERT INTO exhibitions (id, exhibition_name, visitor_age) VALUES (1, 'Art Show', 15), (2, 'Science Fair', 8), (3, 'History Expo', 12); | What is the minimum visitor age for each exhibition? | SELECT exhibition_name, MIN(visitor_age) FROM exhibitions GROUP BY exhibition_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE subscribers (id INT, type TEXT, region TEXT); INSERT INTO subscribers (id, type, region) VALUES (1, 'mobile', 'urban'); INSERT INTO subscribers (id, type, region) VALUES (2, 'broadband', 'suburban'); INSERT INTO subscribers (id, type, region) VALUES (3, 'mobile', 'rural'); INSERT INTO subscribers (id, type... | How many broadband subscribers are there in 'suburban' regions? | SELECT COUNT(*) FROM subscribers WHERE type = 'broadband' AND region = 'suburban'; | gretelai_synthetic_text_to_sql |
CREATE TABLE country (name VARCHAR(50), initiatives INT); INSERT INTO country (name, initiatives) VALUES ('USA', 15), ('Canada', 12), ('India', 18), ('Brazil', 10); | Which countries have the most accessible technology initiatives? | SELECT name FROM country ORDER BY initiatives DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE artist (id INT, name VARCHAR(50)); INSERT INTO artist (id, name) VALUES (1, 'Monet'), (2, 'Renoir'), (3, 'Degas'); CREATE TABLE impressionists (artist_id INT, artwork VARCHAR(50)); INSERT INTO impressionists (artist_id, artwork) VALUES (1, 'Water Lilies'), (1, 'Impression, Sunrise'), (2, 'Dance at Le Mouli... | Find the number of artworks by each artist in the 'impressionists' table. | SELECT a.name, COUNT(i.artist_id) AS num_artworks FROM artist a JOIN impressionists i ON a.id = i.artist_id GROUP BY a.id, a.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE regions (id INT, name VARCHAR(50), PRIMARY KEY(id)); INSERT INTO regions (id, name) VALUES (1, 'North America'), (2, 'South America'), (3, 'Asia'), (4, 'Europe'), (5, 'Africa'); CREATE TABLE wastewater_treatment_plants (id INT, region INT, PRIMARY KEY(id), FOREIGN KEY (region) REFERENCES regions(id)); INSE... | How many wastewater treatment plants are there in the Asian region? | SELECT COUNT(*) as num_plants FROM wastewater_treatment_plants wwtp JOIN regions r ON wwtp.region = r.id WHERE r.name = 'Asia'; | gretelai_synthetic_text_to_sql |
CREATE TABLE telescopes (id INT, telescope_name VARCHAR(255), location VARCHAR(255), telescope_type VARCHAR(255), launch_date DATE); INSERT INTO telescopes (id, telescope_name, location, telescope_type, launch_date) VALUES (1, 'Hubble Space Telescope', 'LEO', 'Optical', '1990-04-24'); | Identify the total number of telescopes and their types in each location. | SELECT location, telescope_type, COUNT(*) as total_telescopes FROM telescopes GROUP BY location, telescope_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE weather_extreme (id INT, date DATE, temperature DECIMAL(5,2)); INSERT INTO weather_extreme | Delete all readings with a temperature below -2.0 degrees Celsius | DELETE FROM weather_extreme WHERE temperature < -2.0; | gretelai_synthetic_text_to_sql |
CREATE TABLE recycling_rates (country VARCHAR(50), rate FLOAT); INSERT INTO recycling_rates (country, rate) VALUES ('Germany', 60), ('France', 55), ('Italy', 45); | What is the average recycling rate (in percentage) for countries in the European Union for the year 2020? | SELECT AVG(rate) FROM recycling_rates WHERE country IN ('Germany', 'France', 'Italy') AND YEAR(date) = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE clients (id INT, name VARCHAR(255), sector VARCHAR(255), liabilities DECIMAL(10, 2)); INSERT INTO clients (id, name, sector, liabilities) VALUES (1, 'Emma White', 'Healthcare', 120000.00), (2, 'Liam Black', 'Healthcare', 180000.00), (3, 'Noah Gray', 'Banking', 220000.00), (4, 'Olivia Brown', 'Banking', 280... | What is the number of clients and total liabilities value for each sector? | SELECT sector, COUNT(*), SUM(liabilities) FROM clients GROUP BY sector; | gretelai_synthetic_text_to_sql |
CREATE TABLE renewable_energy_projects (id INT, name VARCHAR(50), city VARCHAR(50), state VARCHAR(50), country VARCHAR(50), energy_type VARCHAR(50), capacity_mw FLOAT, energy_consumption FLOAT, PRIMARY KEY (id)); | What is the average energy consumption and standard deviation for renewable energy projects in a specific country, ordered by the average energy consumption in ascending order? | SELECT country, AVG(energy_consumption) as avg_energy_consumption, STDDEV(energy_consumption) as stddev_energy_consumption FROM renewable_energy_projects WHERE country = 'CountryName' GROUP BY country ORDER BY AVG(energy_consumption); | gretelai_synthetic_text_to_sql |
CREATE VIEW AverageMentalHealthByMonth AS SELECT DATE_TRUNC('month', AssessmentDate) AS Month, AVG(MentalHealthScore) AS AverageScore FROM StudentsMentalHealth GROUP BY Month; | Create a view to show average mental health score by month | CREATE VIEW AverageMentalHealthByMonth AS SELECT DATE_TRUNC('month', AssessmentDate) AS Month, AVG(MentalHealthScore) AS AverageScore FROM StudentsMentalHealth GROUP BY Month; | gretelai_synthetic_text_to_sql |
CREATE TABLE companies (company_id INT, certified TEXT);CREATE TABLE employees (employee_id INT, company_id INT, salary DECIMAL); | What is the average salary for employees of companies that have not received ethical manufacturing certifications? | SELECT AVG(e.salary) FROM employees e INNER JOIN companies c ON e.company_id = c.company_id WHERE c.certified = 'no'; | gretelai_synthetic_text_to_sql |
CREATE TABLE sales (id INT, product_id INT, quantity INT, sale_date DATE); CREATE TABLE products (id INT, name TEXT, is_cruelty_free BOOLEAN, country TEXT); | How many cruelty-free makeup products were sold in Canada last year? | SELECT COUNT(*) FROM sales JOIN products ON sales.product_id = products.id WHERE products.is_cruelty_free = true AND YEAR(sale_date) = YEAR(CURRENT_DATE) - 1 AND products.country = 'Canada'; | gretelai_synthetic_text_to_sql |
CREATE TABLE VR_Games (id INT, name VARCHAR(50), designer VARCHAR(50)); INSERT INTO VR_Games (id, name, designer) VALUES (1, 'Beat Saber', 'Jan Kozlovsky'), (2, 'Job Simulator', 'Alex Schwartz'), (3, 'Superhot VR', 'Tomasz Kaczmarczyk'); | List all the virtual reality games and their respective designers | SELECT name, designer FROM VR_Games; | gretelai_synthetic_text_to_sql |
CREATE TABLE households (id INT, country VARCHAR(255), energy_consumption FLOAT); INSERT INTO households (id, country, energy_consumption) VALUES (1, 'Indonesia', 250.5), (2, 'Indonesia', 275.6), (3, 'Indonesia', 210.3); | What is the average energy consumption of households in Indonesia? | SELECT AVG(energy_consumption) FROM households WHERE country = 'Indonesia'; | gretelai_synthetic_text_to_sql |
CREATE TABLE FINANCIAL_CAPABILITY_PROGRAMS (BANK_NAME VARCHAR(50), PROGRAM_NAME VARCHAR(50), START_DATE DATE); INSERT INTO FINANCIAL_CAPABILITY_PROGRAMS VALUES ('Bank F', 'Program A', '2020-01-01'); INSERT INTO FINANCIAL_CAPABILITY_PROGRAMS VALUES ('Bank F', 'Program B', '2020-02-01'); INSERT INTO FINANCIAL_CAPABILITY_... | Find the difference in the number of financial capability programs offered by each bank, before and after a specified date? | SELECT BANK_NAME, COUNT(*) - LAG(COUNT(*)) OVER (PARTITION BY BANK_NAME ORDER BY START_DATE) DIFFERENCE FROM FINANCIAL_CAPABILITY_PROGRAMS WHERE START_DATE < '2020-05-01' GROUP BY BANK_NAME, START_DATE ORDER BY BANK_NAME, START_DATE; | gretelai_synthetic_text_to_sql |
CREATE TABLE project (id INT, name TEXT, country TEXT, carbon_offset INT); INSERT INTO project (id, name, country, carbon_offset) VALUES (1, 'Solar Farm', 'USA', 5000); | What is the total carbon offset by country? | SELECT country, SUM(carbon_offset) FROM project GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE brands (id INT, brand_name VARCHAR(20), is_sustainable BOOLEAN, revenue DECIMAL(10,2)); INSERT INTO brands (id, brand_name, is_sustainable, revenue) VALUES (1, 'Brand A', true, 50000.00), (2, 'Brand B', false, 70000.00), (3, 'Brand C', true, 60000.00), (4, 'Brand D', false, 40000.00), (5, 'Brand E', true, ... | Identify the top 3 most popular sustainable brands | SELECT brand_name, is_sustainable, SUM(revenue) FROM brands WHERE is_sustainable = true GROUP BY brand_name ORDER BY SUM(revenue) DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE student_course_stats (student_id INT, course_id INT, num_students INT); INSERT INTO student_course_stats (student_id, course_id, num_students) VALUES (1, 1, 45), (2, 2, 35), (3, 3, 55), (4, 1, 45); | Find the number of students who have never taken a course with more than 40 students. | SELECT COUNT(*) FROM student_course_stats WHERE num_students <= 40; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA IF NOT EXISTS defense_security;CREATE TABLE IF NOT EXISTS defense_security.Aircraft_Carriers (id INT PRIMARY KEY, carrier_name VARCHAR(255), class VARCHAR(255));INSERT INTO defense_security.Aircraft_Carriers (id, carrier_name, class) VALUES (1, 'USS Gerald R. Ford', 'Gerald R. Ford'), (2, 'USS Nimitz', 'N... | List all military aircraft carriers and their respective classes in the 'Aircraft_Carriers' table. | SELECT carrier_name, class FROM defense_security.Aircraft_Carriers; | gretelai_synthetic_text_to_sql |
CREATE TABLE events (event_id INT, name VARCHAR(50), type VARCHAR(50), attendance INT); INSERT INTO events (event_id, name, type, attendance) VALUES (1, 'Art Exhibit', 'Painting', 1500); INSERT INTO events (event_id, name, type, attendance) VALUES (2, 'Theater Performance', 'Play', 850); INSERT INTO events (event_id, n... | What is the average attendance at events in the 'events' table for each event type? | SELECT type, AVG(attendance) as avg_attendance FROM events GROUP BY type; | gretelai_synthetic_text_to_sql |
CREATE TABLE animal_population (id INT, animal_name VARCHAR(50)); CREATE TABLE endangered_animals (id INT, animal_name VARCHAR(50)); | What are the names of the animals in the 'endangered_animals' table that are not already included in the 'animal_population' table? | SELECT e.animal_name FROM endangered_animals e LEFT JOIN animal_population a ON e.animal_name = a.animal_name WHERE a.animal_name IS NULL; | gretelai_synthetic_text_to_sql |
CREATE TABLE heritage_sites_4 (id INT, type VARCHAR(50), name VARCHAR(100), region VARCHAR(50)); INSERT INTO heritage_sites_4 (id, type, name, region) VALUES (1, 'Historic Site', 'Angkor Wat', 'Southeast Asia'), (2, 'Museum', 'British Museum', 'United Kingdom'); CREATE TABLE languages_3 (id INT, language VARCHAR(50), s... | What is the total number of heritage sites and language speakers? | SELECT (SELECT COUNT(*) FROM heritage_sites_4) + (SELECT SUM(speakers) FROM languages_3); | gretelai_synthetic_text_to_sql |
CREATE TABLE smart_contracts (id INT, gas_price DECIMAL(10, 2), country VARCHAR(255)); INSERT INTO smart_contracts (id, gas_price, country) VALUES (1, 20.5, 'China'), (2, 25.0, 'Japan'), (3, 18.7, 'India'), (4, 30.2, 'Singapore'), (5, 22.9, 'Vietnam'); CREATE TABLE smart_contract_transactions (id INT, smart_contract_id... | What's the maximum and minimum gas price for smart contracts in Asia in the last week? | SELECT MAX(gas_price), MIN(gas_price) FROM smart_contract_transactions JOIN smart_contracts ON smart_contract_transactions.smart_contract_id = smart_contracts.id WHERE transaction_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 WEEK) AND country IN ('China', 'Japan', 'India', 'Singapore', 'Vietnam'); | gretelai_synthetic_text_to_sql |
CREATE TABLE cosmetic_products (product_id INT, product_name VARCHAR(50), is_cruelty_free BOOLEAN, sales_volume INT, market VARCHAR(10)); INSERT INTO cosmetic_products (product_id, product_name, is_cruelty_free, sales_volume, market) VALUES (1, 'Lip Gloss', true, 500, 'AF'), (2, 'Mascara', false, 400, 'AF'), (3, 'Eyesh... | What are the top 2 cruelty-free cosmetic products by sales in the African market? | SELECT product_name, SUM(sales_volume) FROM cosmetic_products WHERE is_cruelty_free = true GROUP BY product_name ORDER BY SUM(sales_volume) DESC LIMIT 2; | gretelai_synthetic_text_to_sql |
CREATE TABLE clinic_visits (clinic_name TEXT, visit_date DATE); INSERT INTO clinic_visits (clinic_name, visit_date) VALUES ('Clinic A', '2021-01-05'), ('Clinic A', '2021-02-12'), ('Clinic B', '2021-03-20'), ('Clinic B', '2021-03-20'), ('Clinic C', '2021-03-20'); CREATE TABLE clinic_visits_extended (clinic_name TEXT, vi... | What is the average number of patients who visited each clinic per day? | SELECT AVG(patient_count) FROM (SELECT clinic_name, COUNT(*) AS patient_count FROM clinic_visits_extended GROUP BY clinic_name, visit_date) | gretelai_synthetic_text_to_sql |
CREATE SCHEMA if not exists aerospace;CREATE TABLE if not exists aerospace.aircraft (id INT PRIMARY KEY, name VARCHAR(50), model VARCHAR(50), manufacturer VARCHAR(50), accidents INT); INSERT INTO aerospace.aircraft (id, name, model, manufacturer, accidents) VALUES (1, 'Boeing', '737', 'Boeing', 3), (2, 'Boeing', '747',... | What is the total number of accidents for each aircraft manufacturer? | SELECT manufacturer, SUM(accidents) as total_accidents FROM aerospace.aircraft GROUP BY manufacturer; | gretelai_synthetic_text_to_sql |
CREATE TABLE recycling_plants (name TEXT, country TEXT, waste_types INTEGER); INSERT INTO recycling_plants (name, country, waste_types) VALUES ('Recycling Plant 1', 'USA', 6), ('Recycling Plant 2', 'USA', 4), ('Recycling Plant 3', 'Canada', 5); | Which recycling plants in the United States process more than 5 types of waste? | SELECT name FROM recycling_plants WHERE country = 'USA' AND waste_types > 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE genders (id INT, gender VARCHAR(10)); INSERT INTO genders (id, gender) VALUES (1, 'Male'), (2, 'Female'), (3, 'Other'); CREATE TABLE education_sectors (sector_id INT, sector_name VARCHAR(255)); INSERT INTO education_sectors (sector_id, sector_name) VALUES (1, 'Primary Education'), (2, 'Secondary Education'... | Which gender has the highest union membership rate in the education sector? | SELECT gender, MAX(membership_rate) FROM union_membership_by_gender u JOIN genders g ON u.gender_id = g.id JOIN education_sectors e ON u.sector_id = e.sector_id GROUP BY gender; | gretelai_synthetic_text_to_sql |
CREATE TABLE Visitor (id INT, name TEXT, country TEXT); INSERT INTO Visitor (id, name, country) VALUES (1, 'Alice', 'France'), (2, 'Bob', 'Japan'), (3, 'Charlie', 'France'); | Count the number of visitors per country | SELECT country, COUNT(*) FROM Visitor GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE ai_safety_projects (project_name TEXT, funding INTEGER, country TEXT); | Find total funding for AI safety projects in Europe. | SELECT SUM(funding) FROM ai_safety_projects WHERE country IN ('Germany', 'France', 'UK', 'Italy', 'Spain'); | gretelai_synthetic_text_to_sql |
CREATE TABLE crimes (id INT, report_date DATE, crime_type VARCHAR(20)); INSERT INTO crimes (id, report_date, crime_type) VALUES (1, '2021-01-01', 'Murder'), (2, '2021-01-02', 'Theft'), (3, '2021-01-03', 'Assault'); | What is the total number of crimes reported in 2021? | SELECT COUNT(*) FROM crimes WHERE report_date BETWEEN '2021-01-01' AND '2021-12-31'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Hiring (HireID INT, HireDate DATE, Department VARCHAR(20), Salary FLOAT); INSERT INTO Hiring (HireID, HireDate, Department, Salary) VALUES (1, '2021-04-01', 'IT', 60000), (2, '2021-05-15', 'IT', 65000), (3, '2021-06-01', 'HR', 55000); | What is the minimum salary for employees hired in Q2 of 2021? | SELECT MIN(Salary) FROM Hiring WHERE HireDate BETWEEN '2021-04-01' AND '2021-06-30'; | gretelai_synthetic_text_to_sql |
CREATE TABLE digital_divide (region VARCHAR(255), internet_speed FLOAT, updated_on DATE); | Insert new record with digital divide data 'DDDataE' in digital_divide table | INSERT INTO digital_divide (region, internet_speed, updated_on) VALUES ('Europe', 150.5, CURDATE()); | gretelai_synthetic_text_to_sql |
CREATE TABLE sales_category (sale_id INT, sale_date DATE, category VARCHAR(20), quantity INT); INSERT INTO sales_category (sale_id, sale_date, category, quantity) VALUES (1, '2020-07-05', 'Dresses', 10), (2, '2020-08-10', 'Tops', 15), (3, '2020-09-20', 'Dresses', 20), (4, '2020-10-15', 'Jackets', 5), (5, '2020-11-25', ... | How many garments of the 'Dresses' category were sold in the second half of 2020? | SELECT SUM(quantity) FROM sales_category WHERE category = 'Dresses' AND sale_date BETWEEN '2020-07-01' AND '2020-12-31'; | gretelai_synthetic_text_to_sql |
CREATE TABLE unions (id INT, name TEXT, sector TEXT); INSERT INTO unions (id, name, sector) VALUES (1, 'Union A', 'education'), (2, 'Union B', 'healthcare'); CREATE TABLE bargaining (id INT, union_id INT, sector TEXT); INSERT INTO bargaining (id, union_id, sector) VALUES (1, 1, 'education'), (2, 2, 'healthcare'); | Which unions were involved in collective bargaining for the 'education' sector? | SELECT u.name FROM unions u INNER JOIN bargaining b ON u.id = b.union_id WHERE u.sector = 'education'; | gretelai_synthetic_text_to_sql |
CREATE TABLE creative_ai (id INT PRIMARY KEY, contributor_name TEXT, country TEXT); INSERT INTO creative_ai (id, contributor_name, country) VALUES (1, 'John Doe', 'USA'), (2, 'Jane Smith', 'Canada'), (3, 'Pedro Sanchez', 'Spain'); | Who are the 'creative_ai' contributors from 'Europe'? | SELECT contributor_name FROM creative_ai WHERE country = 'Spain'; | gretelai_synthetic_text_to_sql |
CREATE TABLE WaterConsumption (ID INT, City VARCHAR(20), Consumption FLOAT, Date DATE); INSERT INTO WaterConsumption (ID, City, Consumption, Date) VALUES (5, 'New York', 200, '2020-08-01'), (6, 'New York', 195, '2020-08-02'), (7, 'New York', 210, '2020-08-03'), (8, 'New York', 200, '2020-08-04'); | What is the total water consumption in liters for the month of August 2020 for the city of New York? | SELECT SUM(Consumption) FROM WaterConsumption WHERE City = 'New York' AND Date >= '2020-08-01' AND Date <= '2020-08-31' | gretelai_synthetic_text_to_sql |
CREATE TABLE restaurant_revenue(menu_category VARCHAR(20), revenue DECIMAL(10, 2), order_date DATE); INSERT INTO restaurant_revenue(menu_category, revenue, order_date) VALUES ('Vegan', 1500, '2021-02-01'), ('Vegan', 1800, '2021-02-03'), ('Vegan', 2000, '2021-02-12'); | What was the total revenue for the 'Vegan' menu category in February 2021? | SELECT SUM(revenue) FROM restaurant_revenue WHERE menu_category = 'Vegan' AND order_date >= '2021-02-01' AND order_date <= '2021-02-28'; | gretelai_synthetic_text_to_sql |
CREATE TABLE customers (customer_id INT, name VARCHAR(50), region VARCHAR(20)); INSERT INTO customers (customer_id, name, region) VALUES (1, 'John Doe', 'West'), (2, 'Jane Smith', 'East'); CREATE TABLE transactions (transaction_id INT, customer_id INT, amount DECIMAL(10, 2)); INSERT INTO transactions (transaction_id, c... | What is the average transaction amount for customers in the West region? | SELECT AVG(t.amount) FROM customers c INNER JOIN transactions t ON c.customer_id = t.customer_id WHERE c.region = 'West'; | gretelai_synthetic_text_to_sql |
CREATE TABLE event_attendance (id INT, event_category VARCHAR(10), attendee_count INT); INSERT INTO event_attendance (id, event_category, attendee_count) VALUES (1, 'Music', 200), (2, 'Music', 300), (3, 'Music', 250), (4, 'Dance', 150), (5, 'Dance', 200); | What was the average attendance at music events? | SELECT AVG(attendee_count) FROM event_attendance WHERE event_category = 'Music'; | gretelai_synthetic_text_to_sql |
CREATE TABLE farms (region VARCHAR(20), practice VARCHAR(20), land_area INT); INSERT INTO farms VALUES ('Europe', 'Regenerative', 2000), ('South America', 'Holistic', 3000), ('Europe', 'No-till', 1500); | What is the total number of small-scale farms in Europe and South America that use regenerative agriculture practices, and what is the average land area used by these farms? | SELECT f.region, COUNT(f.region) as num_farms, AVG(f.land_area) as avg_land_area FROM farms f WHERE f.region IN ('Europe', 'South America') AND f.practice = 'Regenerative' GROUP BY f.region; | gretelai_synthetic_text_to_sql |
CREATE TABLE orders (id INT PRIMARY KEY, supplier_id INT, delivery_time INT, fair_trade_certified BOOLEAN); INSERT INTO orders (id, supplier_id, delivery_time, fair_trade_certified) VALUES (1, 1, 7, true), (2, 2, 10, false), (3, 3, 5, true), (4, 4, 8, true), (5, 5, 12, false); CREATE TABLE suppliers (id INT PRIMARY KEY... | What is the average delivery time, in days, for orders placed with fair trade certified suppliers? | SELECT AVG(delivery_time) as avg_delivery_time FROM orders JOIN suppliers ON orders.supplier_id = suppliers.id WHERE fair_trade_certified = true; | gretelai_synthetic_text_to_sql |
CREATE TABLE rural_clinic (id INT, name VARCHAR(50), age INT); INSERT INTO rural_clinic (id, name, age) VALUES (1, 'John Doe', 45), (2, 'Jane Smith', 38); | What is the average age of healthcare providers in the 'rural_clinic' table? | SELECT AVG(age) FROM rural_clinic; | gretelai_synthetic_text_to_sql |
CREATE TABLE ingredients (ingredient_id INT, ingredient_name VARCHAR(255), dish_type VARCHAR(255), quantity INT); INSERT INTO ingredients VALUES (1, 'Tomatoes', 'Vegan', 500), (2, 'Garlic', 'Vegan', 200), (3, 'Chickpeas', 'Vegan', 1000); | Identify the total quantity of ingredients used in vegan dishes. | SELECT SUM(quantity) AS total_quantity FROM ingredients WHERE dish_type = 'Vegan'; | gretelai_synthetic_text_to_sql |
CREATE TABLE department (id INT, name TEXT); INSERT INTO department (id, name) VALUES (1, 'Operations'), (2, 'Engineering'), (3, 'HR'); CREATE TABLE employee (id INT, name TEXT, department_id INT, gender TEXT); INSERT INTO employee (id, name, department_id, gender) VALUES (1, 'John Doe', 1, 'male'), (2, 'Jane Smith', 1... | What is the percentage of female and male employees in each department? | SELECT department_id, gender, COUNT(*) as num_employees, ROUND(COUNT(*) * 100.0 / (SELECT COUNT(*) FROM employee WHERE department_id = department.id), 2) as percentage FROM employee GROUP BY department_id, gender; | gretelai_synthetic_text_to_sql |
CREATE TABLE Lipsticks (product_id INT, product_name VARCHAR(255), category VARCHAR(255), price DECIMAL(10,2)); INSERT INTO Lipsticks (product_id, product_name, category, price) VALUES (1, 'Lipstick 1', 'Lipsticks', 12.99), (2, 'Lipstick 2', 'Lipsticks', 17.99), (3, 'Lipstick 3', 'Lipsticks', 22.99), (4, 'Lipstick 4', ... | What is the maximum price of lipsticks? | SELECT MAX(price) FROM Lipsticks WHERE category = 'Lipsticks'; | gretelai_synthetic_text_to_sql |
CREATE TABLE habitat_preservation (id INT PRIMARY KEY, region VARCHAR(20), organization VARCHAR(30), start_date DATE, end_date DATE); | Delete all records from the 'habitat_preservation' table where the 'organization' is 'Wildlife Protection Agency' | DELETE FROM habitat_preservation WHERE organization = 'Wildlife Protection Agency'; | gretelai_synthetic_text_to_sql |
CREATE TABLE transactions (transaction_id INT, sector VARCHAR(20)); INSERT INTO transactions (transaction_id, sector) VALUES (1, 'Healthcare'), (2, 'Technology'); | What is the number of transactions for the healthcare sector? | SELECT COUNT(*) FROM transactions WHERE sector = 'Healthcare'; | gretelai_synthetic_text_to_sql |
CREATE TABLE rural_resources (id INT PRIMARY KEY, resource_name VARCHAR(100), location VARCHAR(200), capacity INT); | Insert a new healthcare resource record into the rural_resources table | INSERT INTO rural_resources (id, resource_name, location, capacity) VALUES (1, 'Clinic', 'Rural Town 1', 50); | gretelai_synthetic_text_to_sql |
CREATE TABLE union_members (id INT, name VARCHAR(50), union_id INT, industry VARCHAR(20)); INSERT INTO union_members (id, name, union_id, industry) VALUES (1, 'John Doe', 123, 'construction'), (2, 'Jane Smith', 456, 'retail'), (3, 'Mike Johnson', 789, 'healthcare'), (4, 'Liam Lee', 111, 'transportation'); | What is the total number of union members in the 'transportation' industry? | SELECT COUNT(*) FROM union_members WHERE industry = 'transportation'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Movies (movie_id INT PRIMARY KEY, title VARCHAR(100), release_year INT, production_budget INT); INSERT INTO Movies (movie_id, title, release_year, production_budget) VALUES (1, 'Avatar', 2009, 237000000), (2, 'The Lion King', 2019, 260000000), (3, 'Pirates of the Caribbean: On Stranger Tides', 2011, 379000... | Delete the records of movies from the 'Movies' table where the production budget exceeds $150 million. | DELETE FROM Movies WHERE production_budget > 150000000; | gretelai_synthetic_text_to_sql |
CREATE TABLE company (id INT, name TEXT, industry TEXT, founder_age INT);CREATE TABLE funding (id INT, company_id INT, amount INT); INSERT INTO company (id, name, industry, founder_age) VALUES (1, 'EdTechX', 'Education', 35), (2, 'LearnMore', 'Education', 45); INSERT INTO funding (id, company_id, amount) VALUES (1, 1, ... | What is the average age of founders in the education sector who received funding? | SELECT AVG(company.founder_age) FROM company INNER JOIN funding ON company.id = funding.company_id WHERE company.industry = 'Education'; | gretelai_synthetic_text_to_sql |
CREATE TABLE renewable_producers (id INT, name TEXT, capacity FLOAT, region TEXT); INSERT INTO renewable_producers (id, name, capacity, region) VALUES (1, 'ABC Energy', 2500, 'North'), (2, 'XYZ Solar', 3000, 'South'), (3, 'DEF Wind', 3500, 'West'); | Find the top 3 renewable energy producers by capacity and their regions. | SELECT name, region, capacity FROM (SELECT name, region, capacity, ROW_NUMBER() OVER (ORDER BY capacity DESC) as rn FROM renewable_producers) sub WHERE rn <= 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE smart_contracts (contract_address VARCHAR(64), user_address VARCHAR(64)); | List all smart contracts associated with a specific user '0x123...'. | SELECT contract_address FROM smart_contracts WHERE user_address = '0x123...'; | gretelai_synthetic_text_to_sql |
CREATE TABLE mining_sites (id INT, site VARCHAR, country VARCHAR, score INT); INSERT INTO mining_sites (id, site, country, score) VALUES (1, 'SiteA', 'USA', 78), (2, 'SiteB', 'USA', 82); | List all mining sites in the USA and their environmental impact scores. | SELECT site, score FROM mining_sites WHERE country = 'USA'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Site (SiteID INT, SiteName VARCHAR(50), Continent VARCHAR(50)); INSERT INTO Site (SiteID, SiteName, Continent) VALUES (1, 'Great Wall', 'Asia'), (2, 'Machu Picchu', 'South America'), (3, 'Easter Island', 'South America'); CREATE TABLE Artifact (ArtifactID INT, ArtifactName VARCHAR(50), SiteID INT); INSERT ... | What is the total number of heritage sites and associated artifacts in each continent? | SELECT Continent, COUNT(DISTINCT SiteID) as SiteCount, (SELECT COUNT(*) FROM Artifact WHERE EXISTS (SELECT 1 FROM Site WHERE Site.SiteID = Artifact.SiteID AND Site.Continent = Site.Continent)) as ArtifactCount FROM Site GROUP BY Continent; | gretelai_synthetic_text_to_sql |
CREATE TABLE industrial_users (id INT, state VARCHAR(20), water_usage FLOAT); INSERT INTO industrial_users (id, state, water_usage) VALUES (1, 'Ohio', 100.5), (2, 'Ohio', 125.6), (3, 'California', 150.2); | What is the maximum water usage by industrial users in the state of Ohio? | SELECT MAX(water_usage) FROM industrial_users WHERE state = 'Ohio'; | gretelai_synthetic_text_to_sql |
CREATE TABLE military_equipment (id INT, equipment_name VARCHAR(50), quantity INT); INSERT INTO military_equipment (id, equipment_name, quantity) VALUES (1, 'tank', 20), (2, 'fighter_jet', 12), (3, 'humvee', 8); | Show the "equipment_name" and "quantity" columns from the "military_equipment" table, sorted by the "quantity" column in descending order | SELECT equipment_name, quantity FROM military_equipment ORDER BY quantity DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE permit (permit_id INT, region VARCHAR(20), cost FLOAT); INSERT INTO permit VALUES (1, 'Northeast', 8000); INSERT INTO permit VALUES (2, 'Midwest', 5000); INSERT INTO permit VALUES (3, 'Southwest', 6000); | List the top three regions with the highest average permit cost. | SELECT region, AVG(cost) as avg_cost, RANK() OVER (ORDER BY AVG(cost) DESC) as avg_cost_rank FROM permit GROUP BY region HAVING avg_cost_rank <= 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE mining_companies (company_id INT, company_name TEXT); INSERT INTO mining_companies (company_id, company_name) VALUES (1, 'CompanyA'), (2, 'CompanyB'); CREATE TABLE mining_methods (method_id INT, method_name TEXT); INSERT INTO mining_methods (method_id, method_name) VALUES (1, 'Open-pit'), (2, 'Underground'... | What is the total amount of minerals extracted by each company, considering both open-pit and underground mining methods? | SELECT mc.company_name, SUM(ed.amount_extracted) AS total_amount_extracted FROM extraction_data ed JOIN mining_companies mc ON ed.company_id = mc.company_id JOIN mining_methods mm ON ed.method_id = mm.method_id WHERE mm.method_name IN ('Open-pit', 'Underground') GROUP BY mc.company_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE department (id INT, name TEXT); CREATE TABLE research_grants (id INT, department_id INT, amount INT, year INT); | What is the total amount of research grants awarded to each department for a specific year? | SELECT d.name, r.year, SUM(r.amount) FROM department d JOIN research_grants r ON d.id = r.department_id WHERE r.year = 2020 GROUP BY d.name, r.year; | gretelai_synthetic_text_to_sql |
CREATE TABLE LanguagePreservation (Region VARCHAR(255), Budget INT); INSERT INTO LanguagePreservation (Region, Budget) VALUES ('North America', 500000), ('South America', 300000), ('Europe', 700000), ('Asia', 900000), ('Africa', 400000); | What is the average budget spent on language preservation programs per region? | SELECT Region, AVG(Budget) as Avg_Budget FROM LanguagePreservation GROUP BY Region; | gretelai_synthetic_text_to_sql |
CREATE TABLE erbium_supply_chain (report_id INT, year INT, report_status TEXT); INSERT INTO erbium_supply_chain (report_id, year, report_status) VALUES (1, 2020, 'Published'), (2, 2020, 'Published'), (3, 2021, 'Published'), (4, 2021, 'Draft'), (5, 2022, 'Planned'); | List all the erbium supply chain transparency reports for the last 2 years. | SELECT * FROM erbium_supply_chain WHERE year >= 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE precincts (name VARCHAR(255), officers INT, population INT); INSERT INTO precincts (name, officers, population) VALUES ('Precinct 1', 50, 1000), ('Precinct 2', 75, 2000), ('Precinct 3', 100, 3000); | What is the ratio of police officers to citizens in each precinct? | SELECT name, officers, population, officers*1.0/population AS ratio FROM precincts; | gretelai_synthetic_text_to_sql |
CREATE TABLE Studies (ID INT, Location VARCHAR(255), Type VARCHAR(255)); INSERT INTO Studies (ID, Location, Type) VALUES (1, 'US', 'Autonomous Driving'), (2, 'China', 'Autonomous Driving'), (3, 'France', 'Electric Vehicles'); | What is the total number of autonomous driving research studies conducted in the US and China? | SELECT COUNT(*) FROM Studies WHERE Location IN ('US', 'China') AND Type = 'Autonomous Driving'; | gretelai_synthetic_text_to_sql |
CREATE TABLE countries (id INT, name VARCHAR(50)); CREATE TABLE urban_agriculture_programs (id INT, country_id INT, name VARCHAR(50)); INSERT INTO countries (id, name) VALUES (1, 'USA'), (2, 'Canada'), (3, 'Mexico'); INSERT INTO urban_agriculture_programs (id, country_id, name) VALUES (1, 1, 'GrowNYC'), (2, 3, 'Ciudad ... | List all the countries that have at least one urban agriculture program and their respective program names, excluding Canada? | SELECT c.name, program_name FROM countries c JOIN urban_agriculture_programs p ON c.id = p.country_id WHERE c.name != 'Canada'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Ethical_AI_Budget (Year INT, Budget FLOAT); INSERT INTO Ethical_AI_Budget (Year, Budget) VALUES (2021, 1500000), (2022, 1800000), (2023, 2000000); | What is the average budget allocated for ethical AI research in the year 2022? | SELECT AVG(Budget) FROM Ethical_AI_Budget WHERE Year = 2022; | gretelai_synthetic_text_to_sql |
CREATE TABLE LandfillCapacityAPAC (id INT, country VARCHAR(50), region VARCHAR(50), capacity_cubic_meters INT); INSERT INTO LandfillCapacityAPAC (id, country, region, capacity_cubic_meters) VALUES (1, 'China', 'APAC', 120000), (2, 'Japan', 'APAC', 90000), (3, 'India', 'APAC', 150000); | Find the average landfill capacity in APAC for countries with a capacity greater than 100,000 cubic meters. | SELECT AVG(capacity_cubic_meters) FROM LandfillCapacityAPAC WHERE capacity_cubic_meters > 100000 AND region = 'APAC'; | gretelai_synthetic_text_to_sql |
CREATE TABLE category_scores (id INT PRIMARY KEY, category VARCHAR(255), sustainability_score INT); INSERT INTO category_scores (id, category, sustainability_score) VALUES (1, 'Dresses', 82); INSERT INTO category_scores (id, category, sustainability_score) VALUES (2, 'Shirts', 78); | Which categories have an average sustainability score above 80? | SELECT category, AVG(sustainability_score) as avg_sustainability_score FROM category_scores GROUP BY category HAVING AVG(sustainability_score) > 80; | gretelai_synthetic_text_to_sql |
CREATE TABLE languages (id INT, language VARCHAR(50), region VARCHAR(50), num_speakers INT); INSERT INTO languages (id, language, region, num_speakers) VALUES (1, 'Livonian', 'Latvia', 0), (2, 'Ubykh', 'Turkey', 0), (3, 'Eyak', 'USA', 0) | Delete records of languages with no speakers | DELETE FROM languages WHERE num_speakers = 0 | gretelai_synthetic_text_to_sql |
CREATE TABLE LaborHours (State VARCHAR(2), HoursWorked DATE, Job VARCHAR(50)); | What is the total number of construction labor hours worked, in each state, in the past month, ordered from highest to lowest? | SELECT State, SUM(HoursWorked) as TotalHours FROM LaborHours WHERE HoursWorked >= DATEADD(MONTH, -1, GETDATE()) GROUP BY State ORDER BY TotalHours DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE victims (victim_id INT, first_name VARCHAR(20), last_name VARCHAR(20)); INSERT INTO victims (victim_id, first_name, last_name) VALUES (2001, 'Victoria', 'Martin'), (2002, 'Victor', 'Martin'), (2003, 'Tom', 'Brown'); | Update the 'victims' table: change the last_name to 'Johnson' for records with victim_id 2001, 2002 | UPDATE victims SET last_name = 'Johnson' WHERE victim_id IN (2001, 2002); | gretelai_synthetic_text_to_sql |
CREATE TABLE PolicyAdvocacy (PolicyAdvocacyID INT, Organization VARCHAR(255), AdvocacyDate DATE); INSERT INTO PolicyAdvocacy (PolicyAdvocacyID, Organization, AdvocacyDate) VALUES (1, 'National Alliance on Mental Illness', '2020-01-01'), (2, 'Autistic Self Advocacy Network', '2019-12-15'); | What is the policy advocacy history for a specific organization, per type of advocacy? | SELECT Organization, AdvocacyDate FROM PolicyAdvocacy WHERE Organization = 'National Alliance on Mental Illness'; | gretelai_synthetic_text_to_sql |
CREATE TABLE customers (customer_id INT, customer_name VARCHAR(255)); CREATE TABLE menu_items (menu_item_id INT, menu_category VARCHAR(255), item_name VARCHAR(255), is_sustainable BOOLEAN); CREATE TABLE orders (order_id INT, customer_id INT, menu_item_id INT, order_date DATE, order_price INT); | What is the total revenue for each menu category by customer in the last 30 days? | SELECT c.customer_name, m.menu_category, SUM(o.order_price) as total_revenue FROM customers c JOIN orders o ON c.customer_id = o.customer_id JOIN menu_items mi ON o.menu_item_id = mi.menu_item_id JOIN menus m ON mi.menu_category = m.menu_category WHERE o.order_date BETWEEN DATEADD(day, -30, GETDATE()) AND GETDATE() GRO... | gretelai_synthetic_text_to_sql |
CREATE TABLE carbon_dioxide_measurements (year INT, co2_ppm FLOAT); | What is the average carbon dioxide concentration in the atmosphere each year? | SELECT year, AVG(co2_ppm) FROM carbon_dioxide_measurements GROUP BY year; | gretelai_synthetic_text_to_sql |
CREATE TABLE CommunityHealthWorker (WorkerID int, Race varchar(25), CulturalCompetencyScore int); INSERT INTO CommunityHealthWorker (WorkerID, Race, CulturalCompetencyScore) VALUES (1, 'Asian', 85), (2, 'Black', 90), (3, 'Hispanic', 80), (4, 'White', 95); | What is the average cultural competency score for community health workers, partitioned by race? | SELECT Race, AVG(CulturalCompetencyScore) OVER (PARTITION BY Race) AS AvgScore FROM CommunityHealthWorker; | gretelai_synthetic_text_to_sql |
CREATE TABLE GraduateStudents(StudentID INT, Name VARCHAR(50), Advisor VARCHAR(50), Publications INT); INSERT INTO GraduateStudents (StudentID, Name, Advisor, Publications) VALUES (1, 'Doe, J', 'Prof. Brown', 12), (2, 'Doe, J', 'Prof. Black', 8); | List the top 5 graduate students with the highest number of research publications in the past year, partitioned by their advisors. | SELECT StudentID, Name, Advisor, ROW_NUMBER() OVER(PARTITION BY Advisor ORDER BY Publications DESC) AS Rank FROM GraduateStudents WHERE YEAR(PublicationDate) = YEAR(CURRENT_DATE()) - 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE workouts (id INT, user_id INT, distance FLOAT, workout_date DATE); INSERT INTO workouts VALUES (1,1,5.6,'2022-01-01'),(2,2,7.2,'2022-01-02'),(3,3,6.3,'2022-01-03'); CREATE TABLE users (id INT, age INT, gender VARCHAR(10)); INSERT INTO users VALUES (1,23,'Female'),(2,32,'Male'),(3,27,'Male'); | What is the total distance run by male and female users? | SELECT u.gender, SUM(w.distance) AS total_distance FROM workouts w JOIN users u ON w.user_id = u.id GROUP BY u.gender; | gretelai_synthetic_text_to_sql |
CREATE TABLE Hospitals (HospitalID INT, CulturalCompetencyScore DECIMAL(5,2), ReportDate DATE); INSERT INTO Hospitals (HospitalID, CulturalCompetencyScore, ReportDate) VALUES (1, 85.6, '2022-01-01'); INSERT INTO Hospitals (HospitalID, CulturalCompetencyScore, ReportDate) VALUES (2, 92.3, '2022-02-15'); INSERT INTO Hosp... | What is the cultural competency score for each hospital in the last quarter? | SELECT ReportDate, CulturalCompetencyScore FROM Hospitals WHERE ReportDate >= DATEADD(quarter, -1, GETDATE()); | gretelai_synthetic_text_to_sql |
CREATE TABLE Trench (trench_name VARCHAR(50), plate_name VARCHAR(50), max_depth NUMERIC(8,2)); INSERT INTO Trench (trench_name, plate_name, max_depth) VALUES ('Cayman Trough', 'Caribbean', 25000); | What is the maximum depth of oceanic trenches in the Caribbean plate? | SELECT MAX(max_depth) FROM Trench WHERE plate_name = 'Caribbean'; | gretelai_synthetic_text_to_sql |
CREATE TABLE landfill_capacity (id INT PRIMARY KEY, location VARCHAR(50), capacity INT); | Delete the record with id 3 from the landfill_capacity table | DELETE FROM landfill_capacity WHERE id = 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE packages (package_id INT, delivery_date DATE); INSERT INTO packages (package_id, delivery_date) VALUES (1, '2021-05-01'), (2, '2021-06-10'), (3, '2021-07-20'); | Delete all packages that were delivered more than 30 days ago | DELETE FROM packages WHERE delivery_date < DATE_SUB(CURRENT_DATE, INTERVAL 30 DAY); | gretelai_synthetic_text_to_sql |
CREATE TABLE causes (id INT, name VARCHAR(255), type VARCHAR(255)); INSERT INTO causes (id, name, type) VALUES (1, 'Education', 'Social'), (2, 'Health', 'Social'), (3, 'Environment', 'Non-social'); CREATE TABLE donations (id INT, cause_id INT, amount DECIMAL(10, 2)); INSERT INTO donations (id, cause_id, amount) VALUES ... | What is the total amount donated to social causes? | SELECT SUM(d.amount) FROM donations d JOIN causes c ON d.cause_id = c.id WHERE c.type = 'Social'; | gretelai_synthetic_text_to_sql |
CREATE TABLE tugboats (id INT PRIMARY KEY, name VARCHAR(50), year_built INT, type VARCHAR(50)); | What is the average age of all tugboats in the 'tugboats' table? | SELECT AVG(year_built) FROM tugboats; | 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.