context stringlengths 11 9.12k | question stringlengths 0 1.06k | SQL stringlengths 2 4.44k | source stringclasses 28 values |
|---|---|---|---|
CREATE TABLE fish_species (species_id INT PRIMARY KEY, species_name VARCHAR(255), scientific_name VARCHAR(255), conservation_status VARCHAR(50)); CREATE TABLE farm_locations (location_id INT PRIMARY KEY, location_name VARCHAR(255), country VARCHAR(255), ocean VARCHAR(255)); CREATE TABLE fish_production (production_id INT PRIMARY KEY, species_id INT, location_id INT, year INT, quantity INT, FOREIGN KEY (species_id) REFERENCES fish_species(species_id), FOREIGN KEY (location_id) REFERENCES farm_locations(location_id)); | Create a view that displays fish production by species and location | CREATE VIEW fish_production_by_species_location AS SELECT fp.species_id, fs.species_name, fl.location_id, fl.location_name, fp.year, fp.quantity FROM fish_production fp JOIN fish_species fs ON fp.species_id = fs.species_id JOIN farm_locations fl ON fp.location_id = fl.location_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE podcasts (id INT, name TEXT, focus TEXT, location TEXT, host TEXT); INSERT INTO podcasts (id, name, focus, location, host) VALUES (1, 'Podcast1', 'Media Literacy', 'Oceania', 'Host1'); INSERT INTO podcasts (id, title, focus, location, host) VALUES (2, 'Podcast2', 'Politics', 'Europe', 'Host2'); | How many podcasts in Oceania have a focus on media literacy and are hosted by women? | SELECT COUNT(*) FROM podcasts WHERE focus = 'Media Literacy' AND location = 'Oceania' AND host IN (SELECT host FROM hosts WHERE gender = 'Female'); | gretelai_synthetic_text_to_sql |
CREATE TABLE ocean_floor_mapping (location TEXT, depth INTEGER); INSERT INTO ocean_floor_mapping (location, depth) VALUES ('Challenger Deep', 10994), ('Mariana Trench', 10972), ('Tonga Trench', 10823), ('Indian Ocean', 4665); | What is the average depth of the 'Indian Ocean' in the ocean_floor_mapping table? | SELECT AVG(depth) FROM ocean_floor_mapping WHERE location = 'Indian Ocean'; | gretelai_synthetic_text_to_sql |
CREATE TABLE rd_expenditure_data (company_name VARCHAR(50), expenditure_year INT, amount DECIMAL(10,2)); INSERT INTO rd_expenditure_data (company_name, expenditure_year, amount) VALUES ('BioPharm', 2020, 8000000), ('BioPharm', 2018, 7000000); | What is the R&D expenditure for company 'BioPharm' in 2020? | SELECT amount FROM rd_expenditure_data WHERE company_name = 'BioPharm' AND expenditure_year = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE CyberThreatMitigation (id INT, mitigation_date DATE, mitigation_status VARCHAR(50)); INSERT INTO CyberThreatMitigation (id, mitigation_date, mitigation_status) VALUES (1, '2022-01-01', 'Mitigated'); | Get the number of cyber threats mitigated per day in the last week | SELECT DATE(mitigation_date), COUNT(*) FROM CyberThreatMitigation WHERE mitigation_date >= CURDATE() - INTERVAL 7 DAY AND mitigation_status = 'Mitigated' GROUP BY DATE(mitigation_date); | gretelai_synthetic_text_to_sql |
CREATE TABLE Attendance (attendance_id INT PRIMARY KEY, attendee_id INT, attendee_age INT, event_id INT); | Delete all records for attendees with age below 18 in the 'Children's Program'. | DELETE FROM Attendance WHERE attendee_age < 18 AND event_id IN (SELECT event_id FROM Events WHERE program = 'Children''s Program'); | gretelai_synthetic_text_to_sql |
CREATE SCHEMA if not exists arts_culture;CREATE TABLE if not exists arts_culture.donors (donor_id INT PRIMARY KEY, name VARCHAR(255), type VARCHAR(255), donation DECIMAL(10,2));CREATE TABLE if not exists arts_culture.donation_stats (type VARCHAR(255), avg_donation DECIMAL(10,2));INSERT INTO arts_culture.donors (donor_id, name, type, donation) VALUES (1, 'John Doe', 'Individual', 50.00), (2, 'Jane Smith', 'Individual', 100.00), (3, 'Google Inc.', 'Corporation', 5000.00);INSERT INTO arts_culture.donation_stats (type, avg_donation) VALUES ('Individual', 75.00), ('Corporation', 5000.00); | What is the average donation amount by donor type, excluding the top and bottom 25% and updating the result in the 'donation_stats' table. | UPDATE arts_culture.donation_stats ds SET avg_donation = (SELECT AVG(donation) FROM (SELECT donation, type, NTILE(100) OVER (ORDER BY donation) as percentile FROM arts_culture.donors) d WHERE percentile NOT IN (1, 2, 99, 100) GROUP BY type) WHERE ds.type = 'Individual'; | gretelai_synthetic_text_to_sql |
CREATE TABLE diamond_mines (id INT, name TEXT, location TEXT); INSERT INTO diamond_mines (id, name, location) VALUES (1, 'Mirny GOK', 'Yakutia, Russia'), (2, 'Udachny', 'Yakutia, Russia'), (3, 'Aikhal', 'Yakutia, Russia'); | How many diamond mines are there in Russia? | SELECT COUNT(*) FROM diamond_mines WHERE location LIKE '%Russia%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE healthcare_providers (id INT, name TEXT, cultural_competency_score INT, state TEXT); INSERT INTO healthcare_providers (id, name, cultural_competency_score, state) VALUES (1, 'Dr. John Doe', 85, 'Florida'); INSERT INTO healthcare_providers (id, name, cultural_competency_score, state) VALUES (2, 'Dr. Jane Smith', 90, 'California'); | What is the cultural competency score for a healthcare provider in Florida? | SELECT cultural_competency_score FROM healthcare_providers WHERE name = 'Dr. John Doe' AND state = 'Florida'; | gretelai_synthetic_text_to_sql |
CREATE TABLE spills (id INT, location TEXT, spill_date DATE); INSERT INTO spills (id, location, spill_date) VALUES (1, 'US', '2021-03-15'), (2, 'MX', '2021-07-22'), (3, 'CA', '2020-11-01'), (4, 'MX', '2021-02-03'), (5, 'US', '2021-06-09'), (6, 'CA', '2020-05-12'); | How many chemical spills occurred in the past 12 months, grouped by country? | SELECT location, COUNT(*) FROM spills WHERE spill_date >= DATE_SUB(CURRENT_DATE, INTERVAL 12 MONTH) GROUP BY location; | gretelai_synthetic_text_to_sql |
CREATE TABLE Spacecrafts (id INT, name VARCHAR(50), manufacturer VARCHAR(50), weight FLOAT, manufacture_year INT); INSERT INTO Spacecrafts (id, name, manufacturer, weight, manufacture_year) VALUES (1, 'New Horizons', 'Cosmos Constructors', 450.0, 2023), (2, 'Voyager 3', 'Cosmos Constructors', 800.0, 2022), (3, 'Voyager 4', 'Cosmos Constructors', 820.0, 2023); | What is the total weight of spacecrafts manufactured in 2023 by 'Cosmos Constructors'? | SELECT SUM(weight) FROM Spacecrafts WHERE manufacturer = 'Cosmos Constructors' AND manufacture_year = 2023; | gretelai_synthetic_text_to_sql |
CREATE TABLE genomic_data (id INT, project TEXT, funding FLOAT); INSERT INTO genomic_data (id, project, funding) VALUES (1, 'Whole Genome Sequencing', 9000000.0); INSERT INTO genomic_data (id, project, funding) VALUES (2, 'Genomic Data Analysis', 11000000.0); | What is the total funding for genomic data analysis projects? | SELECT SUM(funding) FROM genomic_data WHERE project = 'Genomic Data Analysis'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Players (PlayerID INT, Age INT, GameGenre VARCHAR(10));CREATE TABLE MultiplayerGames (GameID INT, PlayerID INT); | What is the maximum age of players who have played multiplayer games, categorized by the genre of the game? | SELECT g.GameGenre, MAX(p.Age) as MaxAge FROM Players p INNER JOIN MultiplayerGames mg ON p.PlayerID = mg.PlayerID GROUP BY g.GameGenre; | gretelai_synthetic_text_to_sql |
CREATE TABLE Veterans (State VARCHAR(255), Employment_Rate FLOAT); INSERT INTO Veterans (State, Employment_Rate) VALUES ('California', 65.2), ('Texas', 70.5), ('New York', 68.7), ('Florida', 72.1), ('Illinois', 66.9); | What is the average employment rate for veterans in each state? | SELECT State, AVG(Employment_Rate) FROM Veterans GROUP BY State; | gretelai_synthetic_text_to_sql |
CREATE TABLE RenewableEnergyProjects (id INT, project_name VARCHAR(50), country VARCHAR(50), capacity_mw INT); INSERT INTO RenewableEnergyProjects (id, project_name, country, capacity_mw) VALUES (3, 'Hydroelectric Dam', 'Brazil', 10000); | What is the combined capacity of renewable energy projects in Brazil? | SELECT SUM(r.capacity_mw) FROM RenewableEnergyProjects r WHERE r.country = 'Brazil'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Donors (DonorID INT, DonorName TEXT, Country TEXT, Amount DECIMAL(10,2), DonationYear INT); INSERT INTO Donors (DonorID, DonorName, Country, Amount, DonationYear) VALUES (1, 'John Doe', 'USA', 500.00, 2020), (2, 'Jane Smith', 'Canada', 300.00, 2020), (3, 'Marie Curie', 'France', 700.00, 2020); | What is the total amount donated by top 2 donors in 2020? | SELECT DonorName, SUM(Amount) AS TotalDonations FROM Donors WHERE DonationYear = 2020 AND DonorID IN (1, 3) GROUP BY DonorName; | gretelai_synthetic_text_to_sql |
CREATE TABLE landfill_capacity (landfill VARCHAR(50), year INT, capacity INT); INSERT INTO landfill_capacity (landfill, year, capacity) VALUES ('Amazonas', 2019, 7000000), ('Amazonas', 2020, 7500000), ('Sao_Paulo', 2019, 8000000), ('Sao_Paulo', 2020, 8500000); | Landfill capacity of the 'Amazonas' landfill in 2019 and 2020. | SELECT landfill, (SUM(capacity) FILTER (WHERE year = 2019)) AS capacity_2019, (SUM(capacity) FILTER (WHERE year = 2020)) AS capacity_2020 FROM landfill_capacity WHERE landfill = 'Amazonas' GROUP BY landfill; | gretelai_synthetic_text_to_sql |
CREATE TABLE if not exists vendor_equipment (vendor_id INT, vendor VARCHAR(255), equipment VARCHAR(255), contract_value FLOAT); INSERT INTO vendor_equipment (vendor_id, vendor, equipment, contract_value) VALUES (1, 'XYZ Corp', 'M2 Bradley', 2000000); | What is the total contract value and associated equipment for each vendor? | SELECT vendor, equipment, SUM(contract_value) as total_contract_value FROM vendor_equipment GROUP BY vendor, equipment; | gretelai_synthetic_text_to_sql |
CREATE TABLE mobile_customers (customer_id INT, plan_type VARCHAR(10), data_usage FLOAT, region VARCHAR(20)); INSERT INTO mobile_customers (customer_id, plan_type, data_usage, region) VALUES (1, 'postpaid', 3.5, 'Chicago'), (2, 'prepaid', 2.0, 'Chicago'), (3, 'postpaid', 5.0, 'New York'); CREATE TABLE regions (region VARCHAR(20)); INSERT INTO regions (region) VALUES ('Chicago'), ('New York'); CREATE TABLE plan_types (plan_type VARCHAR(10)); INSERT INTO plan_types (plan_type) VALUES ('postpaid'), ('prepaid'); | What is the average data usage for postpaid customers in each region, sorted by usage in descending order? | SELECT r.region, AVG(mc.data_usage) AS avg_data_usage FROM mobile_customers mc JOIN regions r ON mc.region = r.region JOIN plan_types pt ON mc.plan_type = pt.plan_type WHERE pt.plan_type = 'postpaid' GROUP BY r.region ORDER BY avg_data_usage DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE rural_infrastructure (id INT, project_name VARCHAR(255), region VARCHAR(255), completion_date DATE); INSERT INTO rural_infrastructure (id, project_name, region, completion_date) VALUES (1, 'Rural Electrification', 'Mississippi Delta', '2013-05-01'), (2, 'Water Supply System', 'Mississippi Delta', '2015-12-31'); | How many rural infrastructure projects were completed in the 'Mississippi Delta' region before 2015? | SELECT COUNT(*) FROM rural_infrastructure WHERE region = 'Mississippi Delta' AND completion_date < '2015-01-01'; | gretelai_synthetic_text_to_sql |
CREATE TABLE production (id INT, element TEXT, month INT, year INT, quantity INT); | What is the percentage change in the average monthly production of Europium from Q1 2019 to Q2 2019? | SELECT ((Q2_avg - Q1_avg) / Q1_avg) * 100 as percentage_change FROM (SELECT AVG(quantity) as Q1_avg FROM production WHERE element = 'Europium' AND month BETWEEN 1 AND 3 AND year = 2019) q1, (SELECT AVG(quantity) as Q2_avg FROM production WHERE element = 'Europium' AND month BETWEEN 4 AND 6 AND year = 2019) q2; | gretelai_synthetic_text_to_sql |
CREATE TABLE Farmers (farmer_id INT, state VARCHAR(50), sales FLOAT); INSERT INTO Farmers (farmer_id, state, sales) VALUES (1, 'California', 10000), (2, 'Texas', 15000), (3, 'California', 12000); | List the total sales for farmers in California and Texas. | SELECT SUM(sales) FROM Farmers WHERE state IN ('California', 'Texas') | gretelai_synthetic_text_to_sql |
CREATE TABLE donors (id INT, name TEXT, country TEXT, donation_amount DECIMAL(10, 2)); INSERT INTO donors VALUES (1, 'John Doe', 'USA', 500.00), (2, 'Jane Smith', 'Canada', 300.00); | What is the total donation amount by donors from the United States? | SELECT SUM(donation_amount) FROM donors WHERE country = 'USA'; | gretelai_synthetic_text_to_sql |
CREATE TABLE ocean_basins (id INT, species_count INT); | Show the total number of marine species found in each ocean basin | SELECT name, species_count FROM ocean_basins; | gretelai_synthetic_text_to_sql |
CREATE TABLE users (id INT, last_stream_date DATE); CREATE TABLE streams (user_id INT, song_id INT, language VARCHAR(255)); | Find the number of unique users who have streamed songs in Spanish, in the last month. | SELECT COUNT(DISTINCT users.id) FROM users INNER JOIN streams ON users.id = streams.user_id WHERE streams.language = 'Spanish' AND users.last_stream_date >= NOW() - INTERVAL 1 MONTH; | gretelai_synthetic_text_to_sql |
CREATE TABLE lifelong_learning (student_name VARCHAR(20), learning_hours INT, learning_date DATE); INSERT INTO lifelong_learning (student_name, learning_hours, learning_date) VALUES ('Student Y', 10, '2017-09-01'), ('Student Y', 8, '2018-02-14'), ('Student Y', 12, '2019-06-22'), ('Student Y', 15, '2020-12-31'), ('Student Y', 11, '2021-07-04'), ('Student Y', 7, '2022-02-15'); | What is the total number of lifetime learning hours for 'Student Y' up to '2022'? | SELECT student_name, SUM(learning_hours) as total_hours FROM lifelong_learning WHERE student_name = 'Student Y' AND learning_date <= '2022-12-31' GROUP BY student_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE food_safety_inspections (restaurant_id INT, inspection_date DATE, result VARCHAR(10)); | Delete all food safety inspection records for 'XYZ Diner' in 2021. | DELETE FROM food_safety_inspections WHERE restaurant_id = 2 AND inspection_date BETWEEN '2021-01-01' AND '2021-12-31'; | gretelai_synthetic_text_to_sql |
CREATE TABLE renewable_energy (id INT, region VARCHAR(255), installation INT); INSERT INTO renewable_energy (id, region, installation) VALUES (1, 'New South Wales', 1000), (2, 'Victoria', 1500), (3, 'New South Wales', 1200), (4, 'Victoria', 1800); | How many renewable energy installations are there in each region in Australia? | SELECT region, COUNT(DISTINCT installation) as num_installations FROM renewable_energy GROUP BY region; | gretelai_synthetic_text_to_sql |
CREATE TABLE artists (id INT, name VARCHAR(255)); INSERT INTO artists (id, name) VALUES (1, 'Picasso'), (2, 'Van Gogh'), (3, 'Monet'), (4, 'Dali'); CREATE TABLE funding (artist_id INT, source VARCHAR(255), amount FLOAT); INSERT INTO funding (artist_id, source, amount) VALUES (1, 'Private Donor', 10000), (1, 'Corporation', 20000), (2, 'Government', 15000), (2, 'Private Donor', 5000); | Find the names of artists who have not received any funding. | SELECT name FROM artists WHERE id NOT IN (SELECT artist_id FROM funding); | gretelai_synthetic_text_to_sql |
CREATE TABLE MonthlyStreams (StreamID INT, TrackID INT, PlatformID INT, Date DATE, Streams INT); INSERT INTO MonthlyStreams (StreamID, TrackID, PlatformID, Date, Streams) VALUES (1, 1, 3, '2022-01-01', 100); | What is the total number of streams for R&B tracks on YouTube, grouped by month? | SELECT EXTRACT(MONTH FROM Date) as Month, EXTRACT(YEAR FROM Date) as Year, SUM(Streams) as TotalStreams FROM MonthlyStreams JOIN Tracks ON MonthlyStreams.TrackID = Tracks.TrackID JOIN StreamingPlatforms ON MonthlyStreams.PlatformID = StreamingPlatforms.PlatformID WHERE Genre = 'R&B' AND PlatformName = 'YouTube' GROUP BY Month, Year; | gretelai_synthetic_text_to_sql |
CREATE TABLE visitors (id INT PRIMARY KEY, age INT, gender VARCHAR(10), city VARCHAR(20)); | Delete all records from the 'visitors' table where age is less than 18 | DELETE FROM visitors WHERE age < 18; | gretelai_synthetic_text_to_sql |
CREATE TABLE Volunteers (VolunteerID INT PRIMARY KEY, VolunteerName VARCHAR(50), LastVolunteerDate DATE); INSERT INTO Volunteers (VolunteerID, VolunteerName, LastVolunteerDate) VALUES (1, 'John Doe', '2021-12-30'); INSERT INTO Volunteers (VolunteerID, VolunteerName, LastVolunteerDate) VALUES (2, 'Jane Smith', '2022-03-20'); | List all volunteers who have not volunteered since 2021 | SELECT VolunteerName FROM Volunteers WHERE LastVolunteerDate < '2022-01-01'; | gretelai_synthetic_text_to_sql |
CREATE TABLE hotels (hotel_id INT, name VARCHAR(50), category VARCHAR(20), rating DECIMAL(2,1)); INSERT INTO hotels (hotel_id, name, category, rating) VALUES (1, 'The Urban Chic', 'boutique', 4.5), (2, 'The Artistic Boutique', 'boutique', 4.7), (3, 'The Cozy Inn', 'budget', 4.2); | What is the average rating of hotels in the 'boutique' category? | SELECT AVG(rating) FROM hotels WHERE category = 'boutique'; | gretelai_synthetic_text_to_sql |
CREATE TABLE SpacecraftManufacturing (Manufacturer VARCHAR(255), Country VARCHAR(255), SpacecraftModel VARCHAR(255), SpacecraftMass INT); INSERT INTO SpacecraftManufacturing (Manufacturer, Country, SpacecraftModel, SpacecraftMass) VALUES ('SpaceTech Corp', 'USA', 'SpaceshipX', 10000), ('SpaceTech Corp', 'USA', 'SpaceshipY', 12000), ('Galactic Inc', 'Canada', 'SpaceshipA', 8000); | What is the total mass of spacecraft manufactured by Galactic Inc, grouped by the continent of their origin? | SELECT SUM(SpacecraftMass) AS Total_Spacecraft_Mass, CONCAT(SUBSTRING(Country, 1, 2), '%') AS Continent FROM SpacecraftManufacturing WHERE Manufacturer = 'Galactic Inc' GROUP BY Continent; | gretelai_synthetic_text_to_sql |
CREATE TABLE departments (id INT PRIMARY KEY, name VARCHAR(255));CREATE TABLE petitions (id INT PRIMARY KEY, department_id INT, title VARCHAR(255)); | List all the unique departments that have submitted petitions, along with the number of petitions submitted by each department. | SELECT d.name, COUNT(p.id) FROM departments d JOIN petitions p ON d.id = p.department_id GROUP BY d.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE dissolved_oxygen_data (farm_id INT, location VARCHAR(20), dissolved_oxygen FLOAT); INSERT INTO dissolved_oxygen_data (farm_id, location, dissolved_oxygen) VALUES (1, 'Baltic Sea', 8.5), (2, 'North Sea', 7.2), (3, 'Baltic Sea', 8.8), (4, 'North Sea', 7.5); | What is the average dissolved oxygen level in farms located in the Baltic Sea and the North Sea? | SELECT AVG(dissolved_oxygen) FROM dissolved_oxygen_data WHERE location IN ('Baltic Sea', 'North Sea'); | gretelai_synthetic_text_to_sql |
CREATE TABLE clients (id INT PRIMARY KEY, name VARCHAR(255), age INT, city VARCHAR(255)); INSERT INTO clients (id, name, age, city) VALUES (1001, 'Jacob Smith', 34, 'New York'), (1002, 'Sophia Johnson', 45, 'Los Angeles'), (1003, 'Ethan Williams', 29, 'Chicago'), (1005, 'Aaliyah Brown', 31, 'Houston'), (1006, 'Mateo Davis', 42, 'Miami'); CREATE TABLE suspicious_activity (id INT PRIMARY KEY, account_id INT, activity VARCHAR(255), date DATE, client_id INT); INSERT INTO suspicious_activity (id, account_id, activity, date, client_id) VALUES (1, 1, 'Multiple Logins', '2021-01-05', 1001), (2, 3, 'Large Withdrawal', '2021-02-15', 1002), (3, 5, 'Account Hacking', '2021-03-31', 1005), (4, 6, 'Phishing Attempt', '2021-04-10', 1006), (5, 1, 'Suspicious Transactions', '2021-05-15', 1001); | Identify the number of unique clients associated with suspicious activities. | SELECT COUNT(DISTINCT c.id) FROM clients c INNER JOIN suspicious_activity sa ON c.id = sa.client_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE water_pressure_2 (id INT, city VARCHAR(255), location VARCHAR(255), pressure FLOAT, pressure_date DATE); INSERT INTO water_pressure_2 (id, city, location, pressure, pressure_date) VALUES (1, 'Miami', 'Downtown', 55, '2022-03-01'); INSERT INTO water_pressure_2 (id, city, location, pressure, pressure_date) VALUES (2, 'Chicago', 'Loop', 60, '2022-03-02'); | What is the average water pressure by city and location, per day? | SELECT city, location, AVG(pressure) FROM water_pressure_2 GROUP BY city, location, DATE(pressure_date); | gretelai_synthetic_text_to_sql |
See context | What is the total premium for each gender? | SELECT * FROM total_premium_by_gender; | gretelai_synthetic_text_to_sql |
CREATE TABLE organizations (id INT, name TEXT, contact_name TEXT, contact_email TEXT, contact_phone TEXT); INSERT INTO organizations (id, name, contact_name, contact_email, contact_phone) VALUES (1, 'Doctors Without Borders', 'John Smith', 'john.smith@dwb.org', '555-123-4567'), (2, 'Code for Change', 'Jane Doe', 'jane.doe@codeforchange.org', '555-987-6543'); | Update the contact information for the 'Code for Change' organization. | UPDATE organizations SET contact_name = 'James Lee', contact_email = 'james.lee@codeforchange.org', contact_phone = '555-444-3333' WHERE name = 'Code for Change'; | gretelai_synthetic_text_to_sql |
CREATE TABLE per_capita_consumption (quarter VARCHAR(6), country VARCHAR(255), consumption FLOAT); INSERT INTO per_capita_consumption (quarter, country, consumption) VALUES ('Q2 2022', 'Australia', 12.5), ('Q2 2022', 'Canada', 11.2), ('Q3 2022', 'Australia', 13.0); | What was the average energy consumption per capita in Australia in Q2 2022? | SELECT AVG(consumption) FROM per_capita_consumption WHERE quarter = 'Q2 2022' AND country = 'Australia' | gretelai_synthetic_text_to_sql |
CREATE TABLE spacewalks (spacewalk_id INT, astronaut_id INT, duration INT); CREATE TABLE astronauts (astronaut_id INT, name VARCHAR(50), age INT, nationality VARCHAR(50)); | List all astronauts who have been on a spacewalk. | SELECT a.name FROM astronauts a JOIN spacewalks s ON a.astronaut_id = s.astronaut_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE user_age_groups (user_id INT, user_age_group VARCHAR(20)); CREATE TABLE content_topics (content_id INT, content_topic VARCHAR(50), content_length INT); CREATE TABLE user_content_views (view_id INT, user_id INT, content_id INT, view_date DATE); | What is the distribution of view times for content related to climate change, segmented by age group? | SELECT user_age_group, AVG(content_length / 60) as avg_view_time FROM user_content_views JOIN user_age_groups ON user_content_views.user_id = user_age_groups.user_id JOIN content_topics ON user_content_views.content_id = content_topics.content_id WHERE content_topics.content_topic = 'climate change' GROUP BY user_age_group; | gretelai_synthetic_text_to_sql |
CREATE TABLE products (product_id int, product_name varchar(255), product_category varchar(255), recycled_content float); INSERT INTO products (product_id, product_name, product_category, recycled_content) VALUES (1, 'Product A', 'Eco-friendly', 0.8), (2, 'Product B', 'Standard', 0.2), (3, 'Product C', 'Eco-friendly', 0.9); | What is the total recycled content of products in the 'Eco-friendly' category? | SELECT product_category, SUM(recycled_content) FROM products WHERE product_category = 'Eco-friendly' GROUP BY product_category; | gretelai_synthetic_text_to_sql |
CREATE TABLE temperature_data (id INT, farm_id INT, temperature FLOAT, measurement_date DATE); | Update the temperature values to Fahrenheit in the temperature_data table | UPDATE temperature_data SET temperature = temperature * 9/5 + 32; | gretelai_synthetic_text_to_sql |
CREATE TABLE Equipment_Maintenance (Equipment_ID INT, Equipment_Type VARCHAR(50), Maintenance_Date DATE, Maintenance_Cost FLOAT, Maintenance_Company VARCHAR(50)); CREATE VIEW Most_Expensive_Equipment_Maintenance AS SELECT Equipment_Type, SUM(Maintenance_Cost) as Total_Maintenance_Cost FROM Equipment_Maintenance GROUP BY Equipment_Type ORDER BY Total_Maintenance_Cost DESC; | What is the average maintenance cost for the top five equipment types with the most maintenance costs? | SELECT Equipment_Type, AVG(Maintenance_Cost) as Average_Maintenance_Cost FROM Equipment_Maintenance WHERE Equipment_Type IN (SELECT Equipment_Type FROM Most_Expensive_Equipment_Maintenance WHERE ROWNUM <= 5) GROUP BY Equipment_Type; | gretelai_synthetic_text_to_sql |
CREATE TABLE salesperson (id INT, name VARCHAR(50), region VARCHAR(50)); INSERT INTO salesperson (id, name, region) VALUES (1, 'John Doe', 'North'), (2, 'Jane Smith', 'South'); CREATE TABLE orders (id INT, salesperson_id INT, size INT); INSERT INTO orders (id, salesperson_id, size) VALUES (1, 1, 10), (2, 1, 15), (3, 2, 20), (4, 2, 25); | What is the average size of the largest order for each salesperson? | SELECT salesperson_id, AVG(size) as avg_max_order_size FROM (SELECT salesperson_id, MAX(size) as size FROM orders GROUP BY salesperson_id) subquery GROUP BY salesperson_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE satellites (id INT, name VARCHAR(50), launch_country VARCHAR(50), launch_date DATE); INSERT INTO satellites VALUES (1, 'Sputnik 1', 'USSR', '1957-10-04'); INSERT INTO satellites VALUES (2, 'Explorer 1', 'USA', '1958-01-31'); | How many satellites were launched by each country in the satellites table? | SELECT launch_country, COUNT(*) OVER (PARTITION BY launch_country) FROM satellites; | gretelai_synthetic_text_to_sql |
CREATE TABLE RecyclingRates (year INT, region VARCHAR(50), material VARCHAR(50), recycling_rate FLOAT); INSERT INTO RecyclingRates (year, region, material, recycling_rate) VALUES (2019, 'North America', 'Plastic', 0.25), (2019, 'Europe', 'Plastic', 0.3), (2019, 'Asia', 'Plastic', 0.4), (2019, 'Oceania', 'Plastic', 0.2), (2019, 'Australia', 'Plastic', 0.15); | What is the average plastic recycling rate in 2019 for Oceania and Australia? | SELECT AVG(recycling_rate) FROM RecyclingRates WHERE year = 2019 AND material = 'Plastic' AND region IN ('Oceania', 'Australia'); | gretelai_synthetic_text_to_sql |
CREATE TABLE lifelong_learning_programs (program_id INT, country VARCHAR(50), year INT); INSERT INTO lifelong_learning_programs (program_id, country, year) VALUES (1, 'USA', 2022), (2, 'Canada', 2021), (3, 'Mexico', 2022), (4, 'Brazil', 2021), (5, 'USA', 2022), (6, 'UK', 2022), (7, 'Germany', 2021), (8, 'France', 2022), (9, 'Japan', 2022), (10, 'China', 2021); | How many lifelong learning programs were offered in each country in 2022? | SELECT country, COUNT(*) as program_count FROM lifelong_learning_programs WHERE year = 2022 GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE trees (id INT, age FLOAT, species TEXT, region TEXT); INSERT INTO trees (id, age, species, region) VALUES (1, 23.4, 'Oak', 'Temperate'), (2, 56.7, 'Maple', 'Temperate'), (3, 98.2, 'Birch', 'Temperate'); | What is the maximum age of trees in the 'Temperate' region? | SELECT MAX(age) FROM trees WHERE region = 'Temperate'; | gretelai_synthetic_text_to_sql |
CREATE TABLE certifications (id INT, city VARCHAR(20), certification_name VARCHAR(20), capacity INT); INSERT INTO certifications (id, city, certification_name, capacity) VALUES (1, 'New York City', 'LEED', 100), (2, 'New York City', 'BREEAM', 120), (3, 'New York City', 'WELL', 150), (4, 'New York City', 'Green Star', 130); | What is the maximum capacity of green building certifications awarded in New York City? | SELECT MAX(capacity) FROM certifications WHERE city = 'New York City'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Patents (ID INT, Company VARCHAR(255), Country VARCHAR(255), Category VARCHAR(255)); INSERT INTO Patents (ID, Company, Country, Category) VALUES (1, 'Company 1', 'India', 'Climate Change Mitigation'), (2, 'Company 2', 'China', 'Climate Change Adaptation'), (3, 'Company 3', 'India', 'Climate Change Mitigation'), (4, 'Company 4', 'US', 'Climate Change Finance'), (5, 'Company 5', 'India', 'Climate Change Communication'); | What is the number of patents related to climate change mitigation filed by Indian companies? | SELECT COUNT(*) FROM Patents WHERE Country = 'India' AND Category = 'Climate Change Mitigation'; | gretelai_synthetic_text_to_sql |
CREATE TABLE users (user_id INT, user_name VARCHAR(50), join_date DATE, follower_count INT, gender VARCHAR(10));CREATE TABLE posts (post_id INT, user_id INT, post_content TEXT, post_date DATE);INSERT INTO users (user_id, user_name, join_date, follower_count, gender) VALUES (1, 'user1', '2021-01-01', 15000, 'female'), (2, 'user2', '2021-02-01', 12000, 'male'), (3, 'user3', '2021-03-01', 5000, 'non-binary'), (4, 'user4', '2021-03-01', 8000, 'non-binary'); | Show the number of followers for users who have posted about vegan food in the past week, filtered by gender (male, female, non-binary). | SELECT u.gender, COUNT(u.user_id) as follower_count FROM users u JOIN posts p ON u.user_id = p.user_id WHERE p.post_content LIKE '%vegan food%' AND p.post_date >= DATEADD(week, -1, GETDATE()) GROUP BY u.gender; | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_species_observations (species_name VARCHAR(255), location VARCHAR(255), num_observations INT); INSERT INTO marine_species_observations (species_name, location, num_observations) VALUES ('Dolphins', 'Mediterranean Sea', 500), ('Tuna', 'Mediterranean Sea', 1200), ('Jellyfish', 'Mediterranean Sea', 800); | How many marine species have been observed in the Mediterranean Sea? | SELECT COUNT(DISTINCT species_name) FROM marine_species_observations WHERE location = 'Mediterranean Sea'; | gretelai_synthetic_text_to_sql |
CREATE TABLE social_good_technology (id INT, initiative VARCHAR, region VARCHAR, is_social_good BOOLEAN); | What is the percentage of social good technology initiatives in Latin America? | SELECT region, COUNT(*) as total_initiatives, COUNT(*) FILTER (WHERE is_social_good = TRUE) as social_good_initiatives, (COUNT(*) FILTER (WHERE is_social_good = TRUE) * 100.0 / COUNT(*)) as percentage FROM social_good_technology WHERE region = 'Latin America' GROUP BY region; | gretelai_synthetic_text_to_sql |
CREATE TABLE natural_preservatives (product_id INT, preservative_id INT, preservative_name TEXT); CREATE TABLE sales_countries_with_natural_preservatives AS SELECT sales_countries.*, natural_preservatives.preservative_id, natural_preservatives.preservative_name FROM sales_countries JOIN natural_preservatives ON sales_countries.product_id = natural_preservatives.product_id; INSERT INTO natural_preservatives VALUES (1, 1, 'PreservativeA'), (2, 2, 'PreservativeB'), (3, 3, 'PreservativeC'), (4, 4, 'PreservativeD'), (5, 1, 'PreservativeA'), (6, 5, 'PreservativeE'); | Which countries have sales of products with natural preservatives? | SELECT sales_countries_with_natural_preservatives.country_name FROM sales_countries_with_natural_preservatives JOIN natural_preservatives ON sales_countries_with_natural_preservatives.preservative_id = natural_preservatives.preservative_id WHERE natural_preservatives.preservative_name LIKE 'Preservative%' GROUP BY sales_countries_with_natural_preservatives.country_name HAVING COUNT(DISTINCT natural_preservatives.preservative_id) > 1 | gretelai_synthetic_text_to_sql |
CREATE TABLE biosensor_patents (patent_name VARCHAR(255), filing_date DATE, startup_country VARCHAR(255)); INSERT INTO biosensor_patents (patent_name, filing_date, startup_country) VALUES ('BioPatent2', '2022-01-01', 'Canada'); | Which biotech startups from Canada or Japan have filed for biosensor patents in the last 3 years? | SELECT DISTINCT startup_country FROM biosensor_patents WHERE filing_date BETWEEN DATEADD(YEAR, -3, GETDATE()) AND GETDATE() AND startup_country IN ('Canada', 'Japan'); | gretelai_synthetic_text_to_sql |
CREATE TABLE inventory (inventory_id INT, menu_item_id INT, quantity INT, reorder_date DATE); INSERT INTO inventory VALUES (1, 1, 50, '2022-01-01'), (2, 2, 75, '2022-02-01'), (3, 3, 60, '2022-03-01'), (4, 1, 100, '2022-04-01'); CREATE TABLE sales (sale_id INT, menu_item_id INT, sale_amount DECIMAL(10, 2), sale_date DATE); INSERT INTO sales VALUES (1, 1, 50.00, '2022-02-01'), (2, 2, 75.00, '2022-03-01'), (3, 3, 60.00, '2022-04-01'), (4, 1, 100.00, '2022-05-01'); CREATE TABLE menu_items (menu_item_id INT, menu_item_name VARCHAR(255), category VARCHAR(255)); INSERT INTO menu_items VALUES (1, 'Veggie Burger', 'Entrees'), (2, 'Tomato Soup', 'Soups'), (3, 'Caesar Salad', 'Salads'); | Identify the top 3 menu items with the highest inventory turnover ratio in the last 6 months. | SELECT i1.menu_item_id, m1.menu_item_name, c1.category, AVG(i1.quantity / (DATEDIFF(day, i1.reorder_date, s1.sale_date) * AVG(i1.quantity))) AS inventory_turnover_ratio FROM inventory i1 INNER JOIN menu_items m1 ON i1.menu_item_id = m1.menu_item_id INNER JOIN (SELECT menu_item_id, category FROM menu_items EXCEPT SELECT menu_item_id, category FROM menu_items WHERE menu_item_id NOT IN (SELECT menu_item_id FROM sales)) c1 ON m1.menu_item_id = c1.menu_item_id INNER JOIN sales s1 ON i1.menu_item_id = s1.menu_item_id WHERE s1.sale_date > DATEADD(month, -6, GETDATE()) GROUP BY i1.menu_item_id, m1.menu_item_name, c1.category ORDER BY inventory_turnover_ratio DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE suppliers (id INT, name TEXT, industry TEXT); INSERT INTO suppliers (id, name, industry) VALUES (1, 'Supplier A', 'Manufacturing'), (2, 'Supplier B', 'Electronics'), (3, 'Supplier C', 'Manufacturing'), (4, 'Supplier D', 'Electronics'), (5, 'Supplier E', 'Manufacturing'); | Add a new record for a supplier 'Supplier F' from the 'Renewable Energy' industry. | INSERT INTO suppliers (id, name, industry) VALUES (6, 'Supplier F', 'Renewable Energy'); | gretelai_synthetic_text_to_sql |
CREATE TABLE cars (id INT PRIMARY KEY, type VARCHAR(20), sales_year INT, city VARCHAR(20), quantity INT); | How many autonomous cars were sold in San Francisco in 2021? | SELECT SUM(quantity) FROM cars WHERE type = 'Autonomous' AND city = 'San Francisco' AND sales_year = 2021; | gretelai_synthetic_text_to_sql |
CREATE TABLE stocks (stock_symbol TEXT, date DATE, open_price FLOAT, close_price FLOAT); INSERT INTO stocks (stock_symbol, date, open_price, close_price) VALUES ('AAPL', '2022-01-01', 150.00, 155.00), ('AAPL', '2022-01-02', 155.00, 160.00); | What is the previous day's closing price for each stock? | SELECT stock_symbol, date, close_price, LAG(close_price) OVER (PARTITION BY stock_symbol ORDER BY date) as previous_day_close FROM stocks; | gretelai_synthetic_text_to_sql |
CREATE TABLE Players (PlayerID INT, Name VARCHAR(100), Country VARCHAR(50)); INSERT INTO Players (PlayerID, Name, Country) VALUES (1, 'John Doe', 'USA'), (2, 'Jane Smith', 'Canada'), (3, 'James Brown', 'England'), (4, 'Sophia Johnson', 'Germany'), (5, 'Emma White', 'USA'), (6, 'Oliver Black', 'Canada'), (7, 'Lucas Green', 'Brazil'), (8, 'Ava Blue', 'Australia'); | Show the top 3 countries with the most players in the 'Players' table, ordered by the number of players in descending order. | SELECT Country, COUNT(*) AS PlayerCount FROM Players GROUP BY Country ORDER BY PlayerCount DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE players (player_id INT, name VARCHAR(255), country VARCHAR(255), date_registered DATE); CREATE TABLE player_scores (player_id INT, game_name VARCHAR(255), score INT, date DATE); | Insert new player records for the "RPG Quest" game | INSERT INTO players (player_id, name, country, date_registered) VALUES (1, 'Sophia Lee', 'South Korea', '2022-01-03'), (2, 'Pedro Martinez', 'Brazil', '2022-01-04'); INSERT INTO player_scores (player_id, game_name, score, date) VALUES (1, 'RPG Quest', 1200, '2022-01-03'), (2, 'RPG Quest', 1300, '2022-01-04'); | gretelai_synthetic_text_to_sql |
CREATE TABLE tv_show (tv_show_id INT, title VARCHAR(50), genre VARCHAR(50), viewers INT, country VARCHAR(50)); INSERT INTO tv_show (tv_show_id, title, genre, viewers, country) VALUES (1, 'Show 1', 'Comedy', 1000, 'Spain'), (2, 'Show 2', 'Drama', 2000, 'France'), (3, 'Show 3', 'Comedy', 1500, 'Spain'); | What's the number of viewers for each TV show genre in Spain? | SELECT genre, SUM(viewers) FROM tv_show WHERE country = 'Spain' GROUP BY genre; | gretelai_synthetic_text_to_sql |
CREATE TABLE if not exists ports_traffic ( id INT PRIMARY KEY, port_id INT, year INT, total_cargo INT ); INSERT INTO ports_traffic (id, port_id, year, total_cargo) VALUES (1, 1, 2021, 6000000); | What is the total cargo handled by each port in 2021? | SELECT p.name, total_cargo FROM ports p JOIN ports_traffic t ON p.id = t.port_id WHERE t.year = 2021; | gretelai_synthetic_text_to_sql |
CREATE TABLE drugs (id INT PRIMARY KEY, name VARCHAR(255), manufacturer VARCHAR(255), category VARCHAR(255)); INSERT INTO drugs (id, name, manufacturer, category) VALUES (1, 'DrugC', 'Manufacturer2', 'Oncology'); CREATE TABLE sales (id INT PRIMARY KEY, drug_id INT, quantity INT, revenue FLOAT, date DATE, FOREIGN KEY (drug_id) REFERENCES drugs(id)); INSERT INTO sales (id, drug_id, quantity, revenue, date) VALUES (3, 1, 150, 15000.00, '2020-01-01'); | What is the total revenue generated by each manufacturer in the oncology category? | SELECT manufacturer, SUM(revenue) FROM drugs INNER JOIN sales ON drugs.id = sales.drug_id WHERE category = 'Oncology' GROUP BY manufacturer; | gretelai_synthetic_text_to_sql |
CREATE TABLE Volunteers (VolunteerID INT, SignUpDate DATE); INSERT INTO Volunteers (VolunteerID, SignUpDate) VALUES (1, '2022-01-15'), (2, '2022-02-20'), (3, '2022-03-05'), (4, '2021-12-31'), (5, '2021-06-01'); | What is the total number of volunteers who signed up in each quarter of the last two years? | SELECT EXTRACT(QUARTER FROM SignUpDate) as Quarter, COUNT(*) as NumVolunteers FROM Volunteers WHERE SignUpDate >= DATE_TRUNC('year', CURRENT_DATE - INTERVAL '2 years') AND SignUpDate < DATE_TRUNC('year', CURRENT_DATE) GROUP BY Quarter ORDER BY Quarter; | gretelai_synthetic_text_to_sql |
CREATE TABLE projects (id INT, name TEXT, state TEXT, labor_cost DECIMAL(10, 2)); INSERT INTO projects (id, name, state, labor_cost) VALUES (1, 'Eco Project 1', 'California', 50000.00); INSERT INTO projects (id, name, state, labor_cost) VALUES (2, 'Green Project 2', 'California', 75000.00); INSERT INTO projects (id, name, state, labor_cost) VALUES (3, 'Solar Project 3', 'Nevada', 60000.00); | What is the total labor cost for construction projects in California? | SELECT SUM(labor_cost) as total_labor_cost FROM projects WHERE state = 'California'; | gretelai_synthetic_text_to_sql |
CREATE TABLE teachers (id INT, name VARCHAR(50), subject VARCHAR(50), years_experience INT); INSERT INTO teachers (id, name, subject, years_experience) VALUES (1, 'Alice Brown', 'Math', 10); INSERT INTO teachers (id, name, subject, years_experience) VALUES (2, 'Bob Johnson', 'Science', 15); | Insert a new teacher with ID 3, name 'David Jones', subject 'English', and years of experience 8. | INSERT INTO teachers (id, name, subject, years_experience) VALUES (3, 'David Jones', 'English', 8); | gretelai_synthetic_text_to_sql |
CREATE TABLE global_fishing_watch (mmsi INTEGER, vessel_name TEXT, status TEXT); INSERT INTO global_fishing_watch (mmsi, vessel_name, status) VALUES (123456, 'Fishing Vessel A', 'Active'), (789012, 'Fishing Vessel B', 'Inactive'), (345678, 'Fishing Vessel C', 'Active'); | What is the total number of vessels in the Global Fishing Watch database? | SELECT COUNT(*) FROM global_fishing_watch WHERE status = 'Active'; | gretelai_synthetic_text_to_sql |
CREATE TABLE satellite_deployment (id INT PRIMARY KEY, name VARCHAR(255), country VARCHAR(255), launch_date DATE); INSERT INTO satellite_deployment (id, name, country, launch_date) VALUES (1, 'Sentinel-1A', 'European Union', '2014-04-03'), (2, 'TechSat', 'United States', '2022-09-01'); | Update the country of the satellite 'Sentinel-1A' to 'Europe' | UPDATE satellite_deployment SET country = 'Europe' WHERE name = 'Sentinel-1A'; | gretelai_synthetic_text_to_sql |
CREATE TABLE carbon_emissions (country VARCHAR(255), year INT, emissions FLOAT); INSERT INTO carbon_emissions (country, year, emissions) VALUES ('United States', 2018, 5500), ('United States', 2018, 5300), ('United States', 2020, 5000), ('United States', 2020, 5200), ('Canada', 2018, 600), ('Canada', 2018, 650), ('Canada', 2020, 550), ('Canada', 2020, 600); | What was the total carbon emissions in the United States and Canada in 2018 and 2020? | SELECT country, SUM(emissions) as total_emissions, year FROM carbon_emissions GROUP BY country, year; | gretelai_synthetic_text_to_sql |
CREATE TABLE online_travel_agencies (id INT, hotel_id INT, revenue INT, booking_date DATE); CREATE TABLE hotels (id INT, name TEXT, city TEXT, country TEXT); | What is the total number of online travel agency bookings for hotels in Mumbai, India in the month of July 2022? | SELECT SUM(1) FROM online_travel_agencies ota INNER JOIN hotels h ON ota.hotel_id = h.id WHERE h.city = 'Mumbai' AND h.country = 'India' AND booking_date BETWEEN '2022-07-01' AND '2022-07-31'; | gretelai_synthetic_text_to_sql |
CREATE TABLE post_data (post_id INT, category VARCHAR(50), platform VARCHAR(20)); INSERT INTO post_data (post_id, category, platform) VALUES (1, 'beauty', 'Instagram'), (2, 'fashion', 'Instagram'); CREATE TABLE post_comments (comment_id INT, post_id INT, platform VARCHAR(20)); INSERT INTO post_comments (comment_id, post_id, platform) VALUES (1, 1, 'Instagram'), (2, 1, 'Instagram'), (3, 2, 'Instagram'); | What is the total number of comments on posts in the 'beauty' category on Instagram? | SELECT SUM(comment_id) FROM post_comments INNER JOIN post_data ON post_comments.post_id = post_data.post_id WHERE post_data.category = 'beauty' AND post_data.platform = 'Instagram'; | gretelai_synthetic_text_to_sql |
CREATE TABLE rural_infrastructure (project_id INT, project_name TEXT, start_date DATE, end_date DATE, budget INT); INSERT INTO rural_infrastructure (project_id, project_name, start_date, end_date, budget) VALUES (1, 'Water Supply', '2021-01-01', '2021-12-31', 100000), (2, 'Road Construction', '2020-04-01', '2020-12-31', 150000); | What is the maximum budget for a single infrastructure project in the 'rural_infrastructure' table? | SELECT MAX(budget) FROM rural_infrastructure; | gretelai_synthetic_text_to_sql |
CREATE TABLE landfill_capacity (id INT PRIMARY KEY, location VARCHAR(50), capacity INT); | Update the capacity of the Mumbai landfill | UPDATE landfill_capacity SET capacity = 500000 WHERE location = 'Mumbai'; | gretelai_synthetic_text_to_sql |
CREATE TABLE clients (id INT, name TEXT, state TEXT); INSERT INTO clients (id, name, state) VALUES (1, 'Alan Shore', 'New York'); CREATE TABLE billing (id INT, client_id INT, amount INT); INSERT INTO billing (id, client_id, amount) VALUES (1, 1, 1500); CREATE TABLE cases (id INT, client_id INT, result TEXT); INSERT INTO cases (id, client_id, result) VALUES (1, 1, 'won'); | What was the outcome of cases in which clients were billed over $1000? | SELECT cases.result FROM cases INNER JOIN billing ON cases.client_id = billing.client_id WHERE billing.amount > 1000; | gretelai_synthetic_text_to_sql |
CREATE TABLE DiverseStations (id INT, owner TEXT, name TEXT, latitude REAL, longitude REAL, depth REAL); INSERT INTO DiverseStations (id, owner, name, latitude, longitude, depth) VALUES (1, 'Oceanographers United', 'Station 1', 32.9648, -117.2254, 1200); INSERT INTO DiverseStations (id, owner, name, latitude, longitude, depth) VALUES (2, 'Oceanographers United', 'Station 2', 55.3781, -3.4359, 800); | What is the average depth of all stations owned by the Oceanographers United? | SELECT AVG(depth) FROM DiverseStations WHERE owner = 'Oceanographers United'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Inventory (item_id INT, name VARCHAR(50), is_organic BOOLEAN, is_fruit BOOLEAN, quantity INT); INSERT INTO Inventory (item_id, name, is_organic, is_fruit, quantity) VALUES (1, 'Apples', true, true, 50), (2, 'Potatoes', false, false, 30); | What is the total quantity of organic fruits in stock? | SELECT SUM(quantity) FROM Inventory WHERE is_organic = true AND is_fruit = true; | gretelai_synthetic_text_to_sql |
CREATE TABLE wind_projects (project_id INT, project_name VARCHAR(50), state VARCHAR(50), installed_capacity INT); INSERT INTO wind_projects (project_id, project_name, state, installed_capacity) VALUES (1, 'Wind Farm 1', 'California', 50), (2, 'Wind Farm 2', 'Texas', 100); | What is the total installed capacity (in MW) of wind projects in the state of 'California'? | SELECT SUM(installed_capacity) FROM wind_projects WHERE state = 'California'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Department (id INT, name VARCHAR(255), college VARCHAR(255)); INSERT INTO Department (id, name, college) VALUES (1, 'Biology', 'College of Science'), (2, 'Chemistry', 'College of Science'), (3, 'Physics', 'College of Science'), (4, 'Computer Science', 'College of Engineering'), (5, 'Mathematics', 'College of Engineering'); CREATE TABLE ResearchGrants (id INT, department_id INT, num_grants INT); INSERT INTO ResearchGrants (id, department_id, num_grants) VALUES (1, 1, 5), (2, 1, 3), (3, 2, 7), (4, 3, 2), (5, 4, 4), (6, 4, 6), (7, 5, 3); | What is the total number of research grants awarded to the Department of Computer Science and the Department of Mathematics? | SELECT SUM(rg.num_grants) FROM ResearchGrants rg JOIN Department d ON rg.department_id = d.id WHERE d.name IN ('Computer Science', 'Mathematics'); | gretelai_synthetic_text_to_sql |
CREATE TABLE shipments (shipment_id INT, shipment_date DATE, shipping_mode VARCHAR(20), delivery_time INT, delivery_country VARCHAR(20)); INSERT INTO shipments (shipment_id, shipment_date, shipping_mode, delivery_time, delivery_country) VALUES (1, '2022-04-01', 'Ground', 5, 'Canada'), (2, '2022-06-15', 'Air', 3, 'USA'), (3, '2022-05-03', 'Ground', 7, 'Canada'); | What was the average delivery time for ground shipments in Canada? | SELECT AVG(delivery_time) FROM shipments WHERE shipping_mode = 'Ground' AND delivery_country = 'Canada'; | gretelai_synthetic_text_to_sql |
CREATE TABLE products (product_id INT, product_category VARCHAR(50), is_circular_supply BOOLEAN); INSERT INTO products (product_id, product_category, is_circular_supply) VALUES (1, 'Electronics', TRUE), (2, 'Clothing', FALSE), (3, 'Furniture', TRUE), (4, 'Electronics', FALSE), (5, 'Clothing', TRUE); | What is the percentage of products in each category that are part of the circular supply chain? | SELECT product_category, (COUNT(*) FILTER (WHERE is_circular_supply = TRUE)::DECIMAL / COUNT(*)) * 100 AS percentage FROM products GROUP BY product_category; | gretelai_synthetic_text_to_sql |
CREATE TABLE soil_moisture_data (parcel_id INT, moisture FLOAT, timestamp TIMESTAMP); INSERT INTO soil_moisture_data (parcel_id, moisture, timestamp) VALUES (8, 32.1, '2021-01-01 10:00:00'), (9, 40.5, '2021-01-01 10:00:00'), (10, 45.3, '2021-01-01 10:00:00'); | Decrease the soil moisture readings by 5% for parcel_id 9 | WITH updated_data AS (UPDATE soil_moisture_data SET moisture = moisture - 5 WHERE parcel_id = 9 RETURNING *) SELECT * FROM updated_data; | gretelai_synthetic_text_to_sql |
CREATE TABLE artists (id INT, name VARCHAR(255), age INT), festivals (id INT, artist_id INT, year INT); INSERT INTO artists (id, name, age) VALUES (1, 'ArtistA', 30), (2, 'ArtistB', 35), (3, 'ArtistC', 28); INSERT INTO festivals (id, artist_id, year) VALUES (1, 1, 2021), (2, 2, 2021), (3, 3, 2021); | What is the average age of artists who performed at festivals in 2021? | SELECT AVG(age) AS avg_age FROM artists JOIN festivals ON artists.id = festivals.artist_id WHERE festivals.year = 2021; | gretelai_synthetic_text_to_sql |
CREATE TABLE military_innovation (project_name VARCHAR(50), budget DECIMAL(10,2)); | List all military innovation projects with a budget over '1000000' dollars | SELECT project_name FROM military_innovation WHERE budget > 1000000; | gretelai_synthetic_text_to_sql |
CREATE TABLE flu_vaccinations (id INT, country VARCHAR(20), year INT, vaccinations INT); INSERT INTO flu_vaccinations (id, country, year, vaccinations) VALUES (1, 'Canada', 2018, 5000000), (2, 'Canada', 2019, 6000000), (3, 'Mexico', 2019, 4000000); | How many flu vaccinations were administered in Canada in 2019? | SELECT SUM(vaccinations) FROM flu_vaccinations WHERE country = 'Canada' AND year = 2019; | gretelai_synthetic_text_to_sql |
CREATE TABLE VictimAdvocates (VictimAdvocateID INT, Name VARCHAR(30)); CREATE TABLE RestorativeJusticeProgram (CaseID INT, VictimAdvocateID INT, Date DATE); INSERT INTO VictimAdvocates (VictimAdvocateID, Name) VALUES (1, 'Judy Hopps'), (2, 'Nick Wilde'), (3, 'Chief Bogo'); INSERT INTO RestorativeJusticeProgram (CaseID, VictimAdvocateID, Date) VALUES (1, 1, '2021-09-01'), (2, 1, '2021-09-15'), (3, 2, '2021-09-25'), (4, 3, '2021-10-01'), (5, 1, '2021-10-05'), (6, 2, '2021-10-10'); | List the VictimAdvocateID and total cases handled by Victim Advocates who have handled more than 15 cases in the RestorativeJusticeProgram table. | SELECT VictimAdvocateID, COUNT(*) as TotalCases FROM RestorativeJusticeProgram WHERE VictimAdvocateID IN (SELECT VictimAdvocateID FROM RestorativeJusticeProgram GROUP BY VictimAdvocateID HAVING COUNT(*) > 15) GROUP BY VictimAdvocateID; | 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, 'Afghanistan', 'Asia'); INSERT INTO countries (id, name, continent) VALUES (2, 'Algeria', 'Africa'); CREATE TABLE if not exists projects (id INT PRIMARY KEY, name VARCHAR(50), country_id INT, budget DECIMAL(10,2)); INSERT INTO projects (id, name, country_id, budget) VALUES (1, 'Disaster Response', 2, 60000.00); INSERT INTO projects (id, name, country_id, budget) VALUES (2, 'Community Development', 2, 80000.00); | What is the budget for projects in Africa? | SELECT p.budget FROM projects p JOIN countries c ON p.country_id = c.id WHERE c.continent = 'Africa'; | gretelai_synthetic_text_to_sql |
CREATE TABLE wells (well_id INT, well_name VARCHAR(50), location VARCHAR(50), production FLOAT); INSERT INTO wells (well_id, well_name, location, production) VALUES (9, 'Well I', 'Gulf of Mexico', 450.6), (10, 'Well J', 'Sahara', 501.7), (11, 'Well K', 'North Sea', 420.4); | What are the production figures for wells in the Gulf of Mexico? | SELECT location, production FROM wells WHERE location = 'Gulf of Mexico'; | gretelai_synthetic_text_to_sql |
CREATE TABLE creative_ai (id INTEGER, application TEXT, output_quality TEXT, last_updated TIMESTAMP); | Delete all records in the creative_ai table where the application is 'audio generation' and the output_quality is not 'excellent' | DELETE FROM creative_ai WHERE application = 'audio generation' AND output_quality != 'excellent'; | gretelai_synthetic_text_to_sql |
CREATE TABLE hotels(id INT, name TEXT, country TEXT); INSERT INTO hotels(id, name, country) VALUES (5, 'Hotel Original', 'Spain'), (6, 'Hotel Another', 'Portugal'); | Update the name of the hotel in Spain with ID 5 to 'Hotel Renamed'. | UPDATE hotels SET name = 'Hotel Renamed' WHERE id = 5 AND country = 'Spain'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Hiring (HireID INT, HireDate DATE); INSERT INTO Hiring (HireID, HireDate) VALUES (1, '2020-01-01'), (2, '2019-12-31'), (3, '2020-06-15'), (4, '2018-09-01'); | How many employees were hired in 2020? | SELECT COUNT(*) FROM Hiring WHERE YEAR(HireDate) = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE TeachersProfessionalDevelopment (TeacherID INT PRIMARY KEY, DevelopmentType VARCHAR(50), StartDate DATE, EndDate DATE); | Create a table to store information about teachers' professional development | CREATE TABLE TeachersProfessionalDevelopment (TeacherID INT PRIMARY KEY, DevelopmentType VARCHAR(50), StartDate DATE, EndDate DATE); | gretelai_synthetic_text_to_sql |
CREATE TABLE Players (PlayerID INT, Age INT, Gender VARCHAR(10), HasPlayedVR BOOLEAN); INSERT INTO Players (PlayerID, Age, Gender, HasPlayedVR) VALUES (1, 25, 'Male', TRUE), (2, 30, 'Female', FALSE), (3, 22, 'Male', TRUE); | What is the average age of players who have played a VR game? | SELECT AVG(Age) FROM Players WHERE HasPlayedVR = TRUE; | gretelai_synthetic_text_to_sql |
CREATE VIEW autonomous_testing AS SELECT vehicle_make VARCHAR(50), test_result VARCHAR(10) FROM safety_testing WHERE test_type = 'autonomous'; | What percentage of autonomous vehicle crash tests were successful in the 'autonomous_testing' view? | SELECT (COUNT(*) FILTER (WHERE test_result = 'successful')) * 100.0 / COUNT(*) FROM autonomous_testing; | gretelai_synthetic_text_to_sql |
CREATE TABLE Attorneys (AttorneyID INT, Name VARCHAR(50), TotalBilling DECIMAL(10,2)); INSERT INTO Attorneys (AttorneyID, Name, TotalBilling) VALUES (1, 'John Doe', 5000.00), (2, 'Jane Smith', 7000.00); | What is the total billing amount for each attorney, sorted by the total amount? | SELECT Name, SUM(TotalBilling) AS TotalBilling FROM Attorneys GROUP BY Name ORDER BY TotalBilling DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE military_equipment_sales(id INT, year INT, equipment_type VARCHAR(20), quantity INT, sale_price FLOAT); | What is the total military equipment sales revenue for each year? | SELECT year, SUM(quantity * sale_price) FROM military_equipment_sales GROUP BY year; | gretelai_synthetic_text_to_sql |
CREATE TABLE vessel_types (vessel_type VARCHAR(50), quantity INT); CREATE TABLE vessels (vessel_id INT, vessel_type VARCHAR(50)); | What is the number of vessels of type 'tanker' that are in the fleet? | SELECT quantity FROM vessel_types WHERE vessel_type = 'tanker'; | 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.