context stringlengths 11 9.12k | question stringlengths 0 1.06k | SQL stringlengths 2 4.44k | source stringclasses 28
values |
|---|---|---|---|
CREATE TABLE visitor_stats (id INT, country VARCHAR(10), destination VARCHAR(20), visit_date DATE); INSERT INTO visitor_stats (id, country, destination, visit_date) VALUES (1, 'USA', 'Ecuador', '2021-06-01'), (2, 'Canada', 'Galapagos', '2022-02-15'), (3, 'USA', 'Bhutan', '2021-12-25'); | How many visitors from the US have traveled to sustainable destinations in the last 12 months? | SELECT COUNT(*) FROM visitor_stats WHERE country = 'USA' AND visit_date BETWEEN DATE_SUB(CURRENT_DATE, INTERVAL 12 MONTH) AND CURRENT_DATE AND destination IN ('Ecuador', 'Galapagos', 'Bhutan'); | gretelai_synthetic_text_to_sql |
CREATE TABLE Concerts (ConcertID INT, Artist VARCHAR(50), City VARCHAR(50), Revenue DECIMAL(10,2)); INSERT INTO Concerts (ConcertID, Artist, City, Revenue) VALUES (1, 'Taylor Swift', 'Los Angeles', 500000.00), (2, 'BTS', 'New York', 750000.00), (3, 'Adele', 'London', 600000.00), (4, 'Taylor Swift', 'Paris', 400000.00),... | List all artists who have never performed in 'New York'. | SELECT Artist FROM Concerts WHERE City != 'New York' GROUP BY Artist HAVING COUNT(DISTINCT City) = (SELECT COUNT(DISTINCT City) FROM Concerts WHERE Artist = Concerts.Artist); | gretelai_synthetic_text_to_sql |
CREATE TABLE gender_workforce (id INT, project_id INT, worker_name VARCHAR(50), gender VARCHAR(10), hire_date DATE); INSERT INTO gender_workforce (id, project_id, worker_name, gender, hire_date) VALUES (1, 1, 'Jane Smith', 'Female', '2022-02-15'); | How many construction workers of each gender were hired for projects, and what is the earliest hire date for each gender? | SELECT gender, COUNT(*) as worker_count, MIN(hire_date) as earliest_hire_date FROM gender_workforce GROUP BY gender; | gretelai_synthetic_text_to_sql |
CREATE TABLE orders (id INT, dish_id INT, quantity INT);INSERT INTO orders (id, dish_id, quantity) VALUES (1, 1, 2), (2, 2, 3), (3, 3, 5); | Which dish has the most orders in Germany? | SELECT d.name, MAX(o.quantity) FROM dishes d JOIN orders o ON d.id = o.dish_id GROUP BY d.name HAVING country = 'Germany'; | gretelai_synthetic_text_to_sql |
CREATE TABLE vessels (id INT, name TEXT, type TEXT, country TEXT); INSERT INTO vessels (id, name, type, country) VALUES (1, 'Vessel A', 'Tanker', 'USA'), (2, 'Vessel B', 'Container Ship', 'Canada'), (3, 'Vessel C', 'Tanker', 'USA'), (4, 'Vessel D', 'Tanker', 'UK'); | What are the top 3 countries with the most vessels in the 'Tanker' category? | SELECT country, COUNT(*) AS vessel_count FROM vessels WHERE type = 'Tanker' GROUP BY country ORDER BY vessel_count DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE company (id INT, name TEXT, number_of_employees INT, has_exited BOOLEAN); | Find the minimum number of employees for startups that have exited | SELECT MIN(number_of_employees) FROM company c WHERE has_exited = true; | gretelai_synthetic_text_to_sql |
CREATE TABLE shariah_compliant_finance (client_id INT, investment_amount FLOAT, investment_type VARCHAR(50), country VARCHAR(50)); INSERT INTO shariah_compliant_finance VALUES (13, 50000, 'Shariah-compliant Fund', 'Saudi Arabia'); | Update the 'shariah_compliant_finance' table to reflect an increase in the investment amount of a client in Saudi Arabia who has invested in a Shariah-compliant fund. | UPDATE shariah_compliant_finance SET investment_amount = 55000 WHERE client_id = 13 AND investment_type = 'Shariah-compliant Fund' AND country = 'Saudi Arabia'; | gretelai_synthetic_text_to_sql |
CREATE TABLE public_works.bridges (bridge_id INT, name VARCHAR(255)); CREATE TABLE public_works.dams (dam_id INT, name VARCHAR(255)); CREATE TABLE public_works.tunnels (tunnel_id INT, name VARCHAR(255)); INSERT INTO public_works.bridges (bridge_id, name) VALUES (1, 'Golden Gate'), (2, 'Verrazano-Narrows'); INSERT INTO ... | How many bridges, dams, and tunnels are there in total in the 'public_works' schema? | SELECT COUNT(*) FROM (SELECT * FROM public_works.bridges UNION ALL SELECT * FROM public_works.dams UNION ALL SELECT * FROM public_works.tunnels); | gretelai_synthetic_text_to_sql |
CREATE TABLE wind_turbines (id INT, name VARCHAR(50), location VARCHAR(50), capacity FLOAT); | Delete records in the "wind_turbines" table where the capacity is greater than 4 MW | DELETE FROM wind_turbines WHERE capacity > 4; | gretelai_synthetic_text_to_sql |
CREATE TABLE community_health_workers (worker_id INT, name TEXT, age INT, state TEXT); INSERT INTO community_health_workers (worker_id, name, age, state) VALUES (1, 'Alice', 45, 'NY'), (2, 'Bob', 35, 'CA'), (3, 'Charlie', 50, 'NY'), (4, 'Diana', 30, 'CA'); | What is the average age of community health workers by state? | SELECT state, AVG(age) FROM community_health_workers GROUP BY state; | gretelai_synthetic_text_to_sql |
CREATE TABLE Players (player_id INTEGER, name TEXT, assists INTEGER); INSERT INTO Players (player_id, name, assists) VALUES (1, 'Player 1', 30), (2, 'Player 2', 40), (3, 'Player 3', 50); | Which ice hockey player has the highest number of assists in a season? | SELECT name FROM Players WHERE assists = (SELECT MAX(assists) FROM Players); | gretelai_synthetic_text_to_sql |
CREATE TABLE regions (region_id INT PRIMARY KEY, region_name VARCHAR(50)); INSERT INTO regions (region_id, region_name) VALUES (1, 'Africa'), (2, 'Asia'), (3, 'Europe'), (4, 'South America'), (5, 'North America'); CREATE TABLE food_supplies (supply_id INT PRIMARY KEY, region_id INT, year INT, quantity INT); INSERT INTO... | Which regions received the most humanitarian aid in the form of food supplies in 2021? | SELECT r.region_name, SUM(fs.quantity) as total_quantity FROM regions r JOIN food_supplies fs ON r.region_id = fs.region_id WHERE fs.year = 2021 GROUP BY r.region_name ORDER BY total_quantity DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE vessels (id INT, name VARCHAR(50), type VARCHAR(20), flag VARCHAR(20), length FLOAT); INSERT INTO vessels (id, name, type, flag, length) VALUES (1, 'Ocean Wave', 'Oil Tanker', 'Liberia', 300.0); INSERT INTO vessels (id, name, type, flag, length) VALUES (2, 'Island Princess', 'Cruise Ship', 'Panama', 250.0)... | Update the 'type' column to 'Bulk Carrier' in the 'vessels' table for the vessel with name = 'Sea Tiger' | UPDATE vessels SET type = 'Bulk Carrier' WHERE name = 'Sea Tiger'; | gretelai_synthetic_text_to_sql |
CREATE TABLE community_development (id INT, initiative VARCHAR(50), status VARCHAR(50)); INSERT INTO community_development (id, initiative, status) VALUES (1, 'Youth Education', 'Completed'); INSERT INTO community_development (id, initiative, status) VALUES (2, 'Women Empowerment', 'In Progress'); INSERT INTO community... | What is the total number of community development initiatives in the 'community_development' table, grouped by status? | SELECT status, COUNT(*) FROM community_development GROUP BY status; | gretelai_synthetic_text_to_sql |
CREATE TABLE public_works_projects ( id INT PRIMARY KEY, name VARCHAR(255), state VARCHAR(255), completion_date DATE, cost INT ); INSERT INTO public_works_projects (id, name, state, completion_date, cost) VALUES (1, 'Project A', 'California', '2016-01-01', 7000000), (3, 'Project X', 'Colorado', '2018-01... | Update the name and state of public works project with ID 3 to 'Project C' and 'Nevada' respectively. | WITH cte AS ( UPDATE public_works_projects SET name = 'Project C', state = 'Nevada' WHERE id = 3 RETURNING * ) SELECT * FROM cte; | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_species_research (species_id INT, species_name TEXT, region TEXT); INSERT INTO marine_species_research (species_id, species_name, region) VALUES (1, 'Species X', 'Atlantic Ocean'), (2, 'Species Y', 'Arctic Ocean'), (3, 'Species Z', 'Atlantic Ocean'); | How many marine species have been researched in the Atlantic Ocean? | SELECT COUNT(*) FROM marine_species_research WHERE region = 'Atlantic Ocean'; | gretelai_synthetic_text_to_sql |
CREATE TABLE mental_health_facilities (facility_id INT, name VARCHAR(50), state VARCHAR(25), cultural_competency_score INT); INSERT INTO mental_health_facilities (facility_id, name, state, cultural_competency_score) VALUES (1, 'Example MHF', 'California', 85); INSERT INTO mental_health_facilities (facility_id, name, st... | What is the minimum cultural competency score for mental health facilities in Texas? | SELECT MIN(cultural_competency_score) FROM mental_health_facilities WHERE state = 'Texas'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Donors (DonorID INT, DonorName TEXT, DonationAmount DECIMAL, Country TEXT); INSERT INTO Donors (DonorID, DonorName, DonationAmount, Country) VALUES (1, 'John Smith', 50.00, 'Canada'); | What is the total amount donated by individual donors from 'Canada'? | SELECT SUM(DonationAmount) FROM Donors WHERE Country = 'Canada' AND DonorName NOT IN ('Organization A', 'Organization B'); | gretelai_synthetic_text_to_sql |
CREATE TABLE hotels (hotel_id INT, name TEXT, category TEXT); CREATE TABLE virtual_tours (tour_id INT, hotel_id INT, engagement INT, last_activity TIMESTAMP); INSERT INTO hotels (hotel_id, name, category) VALUES (1, 'Hotel A', 'Boutique'), (2, 'Hotel B', 'Luxury'), (3, 'Hotel C', 'Boutique'); INSERT INTO virtual_tours ... | What is the average number of virtual tour engagements per hotel in the 'Boutique' category? | SELECT AVG(virtual_tours.engagement) FROM virtual_tours INNER JOIN hotels ON virtual_tours.hotel_id = hotels.hotel_id WHERE hotels.category = 'Boutique'; | gretelai_synthetic_text_to_sql |
CREATE TABLE waste_generation (year INT, location VARCHAR(255), material VARCHAR(255), weight_tons INT); INSERT INTO waste_generation (year, location, material, weight_tons) VALUES (2022, 'Seattle', 'Plastic', 8000), (2022, 'Seattle', 'Paper', 10000), (2022, 'Seattle', 'Glass', 5000); | Update waste generation records in Seattle in 2022 | UPDATE waste_generation SET weight_tons = 9000 WHERE year = 2022 AND location = 'Seattle' AND material = 'Plastic'; | gretelai_synthetic_text_to_sql |
CREATE TABLE articles (article_id INT, author VARCHAR(50), title VARCHAR(100), category VARCHAR(50), word_count INT, publication_date DATE); | What is the average word count for articles published in each month of a specific year? | SELECT EXTRACT(MONTH FROM publication_date) AS month, AVG(word_count) AS avg_word_count FROM articles WHERE EXTRACT(YEAR FROM publication_date) = 2022 GROUP BY month ORDER BY month; | gretelai_synthetic_text_to_sql |
CREATE TABLE Heritage_Sites (id INT, site_name VARCHAR(100), country VARCHAR(50), year_established INT, UNIQUE (id));CREATE TABLE Workshops (workshop_id INT, date DATE, artisan_id INT, language_id INT, heritage_site_id INT, PRIMARY KEY (workshop_id), FOREIGN KEY (artisan_id) REFERENCES Artisans(artisan_id), FOREIGN KEY... | Count the number of workshops conducted in each heritage site. | SELECT heritage_site_id, COUNT(*) FROM Workshops GROUP BY heritage_site_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE mine (id INT, name TEXT, location TEXT, type TEXT, production FLOAT); INSERT INTO mine (id, name, location, type, production) VALUES (1, 'ABC Mine', 'Colorado, USA', 'Coal', 45000.0), (2, 'DEF Mine', 'Wyoming, USA', 'Coal', 72000.0); | What is the total coal production by each mine in Q1 2021? | SELECT name, SUM(production) as total_production FROM mine WHERE production_date BETWEEN '2021-01-01' AND '2021-03-31' GROUP BY name, type, location | gretelai_synthetic_text_to_sql |
CREATE TABLE service_requests (id INT, request_type VARCHAR(255), request_date DATE); INSERT INTO service_requests (id, request_type, request_date) VALUES (1, 'Road Repair', '2022-01-01'), (2, 'Waste Collection', '2022-02-01'), (3, 'Street Lighting', '2022-01-15'); | What is the number of public service requests received per month, in the 'service_requests' table? | SELECT MONTH(request_date), COUNT(*) FROM service_requests GROUP BY MONTH(request_date); | gretelai_synthetic_text_to_sql |
CREATE TABLE boroughs (borough_name VARCHAR(255)); INSERT INTO boroughs (borough_name) VALUES ('Bronx'), ('Brooklyn'), ('Manhattan'), ('Queens'), ('Staten Island'); CREATE TABLE crime_data (crime_date DATE, borough_name VARCHAR(255), crime_count INT); | How many crimes were reported per day in each borough in the past 3 months? | SELECT b.borough_name, AVG(cd.crime_count) as avg_crimes_per_day FROM boroughs b JOIN crime_data cd ON b.borough_name = cd.borough_name WHERE cd.crime_date >= CURDATE() - INTERVAL 3 MONTH GROUP BY b.borough_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE hospitals (state varchar(2), hospital_name varchar(25), num_beds int); INSERT INTO hospitals (state, hospital_name, num_beds) VALUES ('NY', 'NY Presbyterian', 2001), ('CA', 'UCLA Medical', 1012), ('TX', 'MD Anderson', 1543), ('FL', 'Mayo Clinic FL', 1209); | What is the number of hospitals and the number of beds per hospital per state, ordered by the number of hospitals in descending order? | SELECT state, COUNT(DISTINCT hospital_name) as num_hospitals, AVG(num_beds) as avg_beds_per_hospital FROM hospitals GROUP BY state ORDER BY num_hospitals DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE mental_health_parity (state VARCHAR(2), incidents INT); INSERT INTO mental_health_parity (state, incidents) VALUES ('CA', 120), ('NY', 150), ('TX', 80); | What is the total number of mental health parity violation incidents by state? | SELECT state, SUM(incidents) FROM mental_health_parity GROUP BY state; | gretelai_synthetic_text_to_sql |
CREATE TABLE funding (funding_id INT, project_id INT, funding_amount FLOAT, funding_date DATE);CREATE TABLE mitigation_projects (project_id INT, project_type VARCHAR(50)); | What is the total funding for space debris mitigation projects by 2025? | SELECT SUM(funding.funding_amount) FROM funding INNER JOIN mitigation_projects ON funding.project_id = mitigation_projects.project_id WHERE funding.funding_date <= '2025-12-31' AND mitigation_projects.project_type = 'space debris mitigation'; | gretelai_synthetic_text_to_sql |
CREATE TABLE ArtworksSold (id INT, region VARCHAR(20), year INT, artist_community VARCHAR(50), artworks_sold INT); INSERT INTO ArtworksSold (id, region, year, artist_community, artworks_sold) VALUES (17, 'Europe', 2021, 'Indigenous', 5); INSERT INTO ArtworksSold (id, region, year, artist_community, artworks_sold) VALUE... | What is the average number of artworks sold by Indigenous artists in Europe in 2021? | SELECT AVG(artworks_sold) FROM ArtworksSold WHERE region = 'Europe' AND year = 2021 AND artist_community = 'Indigenous'; | gretelai_synthetic_text_to_sql |
CREATE TABLE USVehicleSales (id INT, vehicle_type VARCHAR(50), quantity INT); INSERT INTO USVehicleSales (id, vehicle_type, quantity) VALUES (1, 'Autonomous', 3000), (2, 'Electric', 4000), (3, 'Hybrid', 2500), (4, 'Sedan', 5000), (5, 'SUV', 6000), (6, 'Truck', 7000); | What is the total number of autonomous vehicles sold in the US? | SELECT SUM(quantity) FROM USVehicleSales WHERE vehicle_type = 'Autonomous'; | gretelai_synthetic_text_to_sql |
CREATE TABLE patient (patient_id INT, name VARCHAR(50), age INT, gender VARCHAR(10), condition VARCHAR(50)); INSERT INTO patient (patient_id, name, age, gender, condition) VALUES (1, 'John Doe', 45, 'Male', 'Depression'), (2, 'Jane Smith', 35, 'Female', 'Depression'); CREATE TABLE treatment (treatment_id INT, patient_i... | What is the success rate of the Cognitive Behavioral Therapy program for patients with depression? | SELECT (SUM(success) / COUNT(patient_id)) * 100 AS success_rate FROM treatment WHERE treatment_name = 'Cognitive Behavioral Therapy' AND condition = 'Depression'; | gretelai_synthetic_text_to_sql |
CREATE TABLE students (student_id INT PRIMARY KEY, name VARCHAR(50), grade INT, mental_health_score INT); | Insert a new student record into the 'students' table | INSERT INTO students (student_id, name, grade, mental_health_score) VALUES (101, 'Jamal Johnson', 11, 75); | gretelai_synthetic_text_to_sql |
CREATE TABLE organic_farming (country VARCHAR(50), area INT, year INT); INSERT INTO organic_farming (country, area, year) VALUES ('Australia', 22000, 2018); INSERT INTO organic_farming (country, area, year) VALUES ('Argentina', 30000, 2018); | List the top 5 countries in terms of organic farming area in 2018. | SELECT country, area FROM organic_farming WHERE year = 2018 ORDER BY area DESC LIMIT 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE students (id INT, name VARCHAR(50), department VARCHAR(50)); INSERT INTO students (id, name, department) VALUES (1, 'Grace', 'Chemistry'); INSERT INTO students (id, name, department) VALUES (2, 'Harry', 'Physics'); CREATE TABLE publications (student_id INT, year INT, title VARCHAR(100), department VARCHAR(... | What is the average number of research papers published per graduate student in the Physics department? | SELECT AVG(pubs_per_student) FROM (SELECT COUNT(p.id) AS pubs_per_student FROM students s JOIN publications p ON s.id = p.student_id WHERE s.department = 'Physics' GROUP BY s.id) t; | gretelai_synthetic_text_to_sql |
CREATE TABLE student_mental_health (id INT, student_id INT, score INT, region_id INT); INSERT INTO student_mental_health (id, student_id, score, region_id) VALUES (1, 1, 8, 1); CREATE TABLE regions (id INT, name VARCHAR(50)); INSERT INTO regions (id, name) VALUES (1, 'North America'); | What is the average mental health score for students in North America? | SELECT AVG(smh.score) FROM student_mental_health smh JOIN regions r ON smh.region_id = r.id WHERE r.name = 'North America'; | gretelai_synthetic_text_to_sql |
CREATE TABLE MarineLife (Species VARCHAR(50), LastSighting DATE); INSERT INTO MarineLife (Species, LastSighting) VALUES ('Dolphin', '2021-06-15'); | What is the total number of marine species recorded in the 'MarineLife' table, along with the date of their latest sighting? | SELECT Species, MAX(LastSighting) AS 'Latest Sighting', COUNT(*) OVER () AS 'Total Species' FROM MarineLife; | gretelai_synthetic_text_to_sql |
CREATE TABLE green_buildings (id INT, area FLOAT, city VARCHAR(20), state VARCHAR(20)); INSERT INTO green_buildings (id, area, city, state) VALUES (1, 5000.5, 'San Francisco', 'CA'), (2, 7000.3, 'Los Angeles', 'CA'); | What is the average area of all green buildings in the 'smart_cities' schema? | SELECT AVG(area) FROM green_buildings; | gretelai_synthetic_text_to_sql |
CREATE TABLE products (id INT, name VARCHAR(255), serving_size INT, protein_grams FLOAT); INSERT INTO products (id, name, serving_size, protein_grams) VALUES (1, 'Product H', 250, 8.0); INSERT INTO products (id, name, serving_size, protein_grams) VALUES (2, 'Product I', 150, 5.0); INSERT INTO products (id, name, servin... | How many grams of protein are in products with a serving size larger than 200? | SELECT SUM(protein_grams) AS total_protein_grams FROM products WHERE serving_size > 200; | gretelai_synthetic_text_to_sql |
CREATE TABLE Customers (customerID INT, customerName VARCHAR(50), loyalty_score INT); INSERT INTO Customers (customerID, customerName, loyalty_score) VALUES (1, 'Alice Johnson', 75), (2, 'Bob Smith', 85), (3, 'Carla Jones', 65), (4, 'Daniel Kim', 90); | Delete all customer records from the Customers table. | DELETE FROM Customers; | gretelai_synthetic_text_to_sql |
CREATE TABLE program (id INT, name VARCHAR(255)); CREATE TABLE student (id INT, program_id INT, enrollment_date DATE); | What is the average number of students in each graduate program? | SELECT program.name, AVG(DATEDIFF(CURDATE(), student.enrollment_date) / 365) FROM program LEFT JOIN student ON program.id = student.program_id GROUP BY program.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE labor_statistics (state VARCHAR(255), num_workers INT); INSERT INTO labor_statistics (state, num_workers) VALUES ('New York', 120000), ('California', 150000), ('Texas', 180000); | How many construction workers are employed in the state of New York? | SELECT num_workers FROM labor_statistics WHERE state = 'New York'; | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_species (species_name VARCHAR(50), conservation_status VARCHAR(50)); | How many marine species are there in the 'marine_species' table without any conservation status?" | SELECT COUNT(species_name) FROM marine_species WHERE conservation_status IS NULL; | gretelai_synthetic_text_to_sql |
CREATE TABLE port (port_id INT, port_name VARCHAR(50), region VARCHAR(50)); INSERT INTO port (port_id, port_name, region) VALUES (1, 'Port of New York', 'North America'), (2, 'Port of Miami', 'North America'), (3, 'Port of Tokyo', 'Asia'), (4, 'Port of Rotterdam', 'Europe'); CREATE TABLE vessel (vessel_id INT, vessel_n... | What are the names of the ports where 'Vessel G' has transported cargo and is not located in Asia? | SELECT port_name FROM port WHERE port_id IN (SELECT port_id FROM transport WHERE vessel_id = (SELECT vessel_id FROM vessel WHERE vessel_name = 'Vessel G')) AND region != 'Asia'; | gretelai_synthetic_text_to_sql |
CREATE TABLE artifacts (id INT, artifact_name VARCHAR(255), conservation_start_time TIMESTAMP, conservation_end_time TIMESTAMP); | What is the maximum conservation time for a single artifact? | SELECT MAX(TIMESTAMPDIFF(MINUTE, conservation_start_time, conservation_end_time)) AS max_conservation_time FROM artifacts; | gretelai_synthetic_text_to_sql |
CREATE TABLE security_incidents_by_region (region VARCHAR(50), incident_count INT, incident_date DATE); INSERT INTO security_incidents_by_region (region, incident_count, incident_date) VALUES ('North America', 250, '2023-01-01'), ('Europe', 220, '2023-01-02'), ('Asia', 190, '2023-01-03'), ('South America', 160, '2023-0... | Find the number of security incidents that occurred in each region in the last quarter. | SELECT region, SUM(incident_count) AS total_incidents FROM security_incidents_by_region WHERE incident_date >= DATEADD(quarter, -1, GETDATE()) GROUP BY region; | gretelai_synthetic_text_to_sql |
CREATE TABLE safety_protocols_3 (site VARCHAR(10), protocol VARCHAR(20), review_date DATE); INSERT INTO safety_protocols_3 VALUES ('C', 'P1', '2022-04-01'), ('C', 'P2', '2021-08-15'), ('D', 'P3', '2023-02-03'), ('D', 'P4', '2022-11-28'), ('D', 'P5', '2020-04-22'); | What is the minimum safety protocol review date across all sites? | SELECT MIN(review_date) FROM safety_protocols_3; | gretelai_synthetic_text_to_sql |
CREATE TABLE climate_communication (organization VARCHAR(50), year INT, budget FLOAT); INSERT INTO climate_communication (organization, year, budget) VALUES ('UNFCCC', 2022, 5000000), ('Greenpeace', 2022, 4000000), ('WWF', 2022, 6000000), ('Climate Action Network', 2022, 3000000), ('350.org', 2022, 2500000); | What is the average climate communication budget for the top 3 spending organizations in 2022? | SELECT AVG(budget) FROM (SELECT budget FROM climate_communication WHERE organization IN ('UNFCCC', 'Greenpeace', 'WWF') AND year = 2022) AS top_orgs; | gretelai_synthetic_text_to_sql |
CREATE TABLE waste_by_mining(country VARCHAR(20), year INT, mining_type VARCHAR(20), waste_produced INT); INSERT INTO waste_by_mining VALUES ('United States', 2018, 'coal', 50000), ('United States', 2019, 'coal', 55000), ('United States', 2020, 'coal', 60000), ('China', 2018, 'coal', 70000), ('China', 2019, 'coal', 750... | Calculate the total waste produced by coal mining in the United States and China | SELECT country, SUM(waste_produced) FROM waste_by_mining WHERE country IN ('United States', 'China') AND mining_type = 'coal' GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE train_routes (region VARCHAR(10), num_stations INT); INSERT INTO train_routes (region, num_stations) VALUES ('east', 6), ('west', 4), ('north', 7), ('south', 3); | How many train routes have more than 5 stations in the 'east' region? | SELECT COUNT(*) FROM train_routes WHERE region = 'east' AND num_stations > 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE WorkersData (WorkerID INT, RegionID INT, Date DATE, Violation VARCHAR(50)); | Delete all records with labor rights violations from the year 2020. | DELETE FROM WorkersData WHERE YEAR(Date) = 2020 AND Violation IS NOT NULL; | gretelai_synthetic_text_to_sql |
CREATE TABLE videos (id INT, title VARCHAR(255), publish_date DATE, watch_time INT, topic VARCHAR(255), creator_country VARCHAR(255)); INSERT INTO videos (id, title, publish_date, watch_time, topic, creator_country) VALUES (1, 'Video1', '2016-05-15', 5000, 'Climate Change', 'USA'), (2, 'Video2', '2018-07-22', 7000, 'Cl... | What is the total watch time of videos about climate change, published on YouTube between 2015 and 2020, by creators from different countries? | SELECT creator_country, SUM(watch_time) FROM videos WHERE topic = 'Climate Change' AND publish_date BETWEEN '2015-01-01' AND '2020-12-31' GROUP BY creator_country; | gretelai_synthetic_text_to_sql |
CREATE TABLE forests (id INT, region VARCHAR(50)); INSERT INTO forests (id, region) VALUES (1, 'Boreal'); CREATE TABLE species (id INT, name VARCHAR(50)); CREATE TABLE carbon_sequestration (id INT, species_id INT, forest_id INT, year INT, sequestration FLOAT); INSERT INTO carbon_sequestration (id, species_id, forest_id... | Identify the 'species' with the lowest carbon sequestration in '2020' in 'Boreal' forests. | SELECT species.name, MIN(carbon_sequestration.sequestration) FROM carbon_sequestration JOIN species ON carbon_sequestration.species_id = species.id JOIN forests ON carbon_sequestration.forest_id = forests.id WHERE forests.region = 'Boreal' AND carbon_sequestration.year = 2020 GROUP BY species.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE UnionInfo (UnionID INT, UnionName VARCHAR(50), Sector VARCHAR(20)); INSERT INTO UnionInfo (UnionID, UnionName, Sector) VALUES (1001, 'Teamsters', 'Transportation'); INSERT INTO UnionInfo (UnionID, UnionName, Sector) VALUES (1002, 'United Auto Workers', 'Manufacturing'); CREATE TABLE CollectiveBargaining (C... | Compute the average duration of collective bargaining agreements for unions in the 'Transportation' sector, ordered by the average duration in descending order | SELECT UnionID, AVG(DATEDIFF(day, AgreementDate, ExpirationDate)) as AvgDurationInDays FROM CollectiveBargaining INNER JOIN UnionInfo ON CollectiveBargaining.UnionID = UnionInfo.UnionID WHERE Sector = 'Transportation' GROUP BY UnionID ORDER BY AvgDurationInDays DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE ingredients (ingredient_id INT, product_id INT, ingredient_name VARCHAR(50), is_organic BOOLEAN); INSERT INTO ingredients (ingredient_id, product_id, ingredient_name, is_organic) VALUES (1, 1, 'Beeswax', true), (2, 1, 'Coconut Oil', true), (3, 2, 'Talc', false); | List all ingredients sourced from organic farms for a given product_id=1 | SELECT ingredient_name FROM ingredients WHERE product_id = 1 AND is_organic = true; | gretelai_synthetic_text_to_sql |
CREATE TABLE Movies (title VARCHAR(255), release_year INT, budget INT); INSERT INTO Movies (title, release_year, budget) VALUES ('Movie1', 2015, 50000000), ('Movie2', 2016, 75000000), ('Movie3', 2017, 60000000), ('Movie4', 2018, 80000000); | What is the average budget for movies released between 2015 and 2018? | SELECT AVG(budget) FROM Movies WHERE release_year BETWEEN 2015 AND 2018; | gretelai_synthetic_text_to_sql |
CREATE TABLE Unemployment(Year INT, Location VARCHAR(10), Rate DECIMAL(4, 2)); INSERT INTO Unemployment VALUES (2018, 'Rural', 5.2), (2018, 'Urban', 4.8), (2019, 'Rural', 5.1), (2019, 'Urban', 4.7), (2020, 'Rural', 5.6), (2020, 'Urban', 5.1), (2021, 'Rural', 5.5), (2021, 'Urban', 4.9); | What is the policy impact of unemployment rates in rural areas compared to urban areas from 2018 to 2021? | SELECT Year, AVG(Rate) FROM Unemployment GROUP BY Year ORDER BY Year; | gretelai_synthetic_text_to_sql |
CREATE TABLE Faculty (FacultyID INT, Name VARCHAR(50), Department VARCHAR(50), Gender VARCHAR(10), GrantAmt FLOAT, GrantYear INT); | What is the total amount of research grants received by faculty members in the Social Sciences department in the year 2016? | SELECT SUM(GrantAmt) FROM Faculty WHERE Department = 'Social Sciences' AND GrantYear = 2016; | gretelai_synthetic_text_to_sql |
CREATE TABLE events (event_id INT, event_name VARCHAR(50), funding_source_id INT, event_date DATE); INSERT INTO events (event_id, event_name, funding_source_id, event_date) VALUES (1, 'Art Exhibit', 3, '2020-06-01'), (2, 'Theater Performance', 4, '2020-07-15'), (3, 'Dance Recital', 3, '2020-09-25'); CREATE TABLE fundin... | How many events did each funding source support in 2020? | SELECT funding_source_name, COUNT(events.funding_source_id) AS event_count FROM funding_sources LEFT JOIN events ON funding_sources.funding_source_id = events.funding_source_id WHERE YEAR(events.event_date) = 2020 GROUP BY funding_source_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE crop_moisture (country VARCHAR(255), crop_type VARCHAR(255), moisture_level INT, measurement_date DATE); INSERT INTO crop_moisture (country, crop_type, moisture_level, measurement_date) VALUES ('Canada', 'Wheat', 600, '2022-06-15'), ('Canada', 'Barley', 550, '2022-06-15'), ('Mexico', 'Corn', 700, '2022-06-... | Which crop type has the highest total moisture level in the past 30 days, by country? | SELECT country, crop_type, SUM(moisture_level) as total_moisture FROM crop_moisture WHERE measurement_date BETWEEN '2022-05-16' AND '2022-06-15' GROUP BY country, crop_type ORDER BY total_moisture DESC FETCH FIRST 1 ROW ONLY; | gretelai_synthetic_text_to_sql |
CREATE TABLE volunteers (volunteer_id INT, org_id INT, volunteer_month INT, num_volunteers INT); | What is the average number of volunteers per month for each organization in the 'volunteers' table? | SELECT org_id, volunteer_month, AVG(num_volunteers) FROM volunteers GROUP BY org_id, volunteer_month; | gretelai_synthetic_text_to_sql |
CREATE TABLE licenses (id INT, type TEXT, applicant TEXT, city TEXT, issue_date DATE); INSERT INTO licenses (id, type, applicant, city, issue_date) VALUES (1, 'dispensary', 'social equity', 'Oakland', '2019-01-01'), (2, 'manufacturing', 'general', 'Oakland', '2018-01-01'); | How many social equity dispensary licenses were issued in Oakland before 2020? | SELECT COUNT(*) FROM licenses WHERE type = 'dispensary' AND applicant = 'social equity' AND city = 'Oakland' AND issue_date < '2020-01-01'; | gretelai_synthetic_text_to_sql |
CREATE TABLE military_technology_projects (id INT, project_name VARCHAR(255), budget DECIMAL(10,2), region VARCHAR(255)); INSERT INTO military_technology_projects (id, project_name, budget, region) VALUES (1, 'Project 1', 1000000, 'Asia'), (2, 'Project 2', 2000000, 'Asia'); | What is the total number of military technology projects and their corresponding budgets in Asia, grouped by budget in descending order? | SELECT COUNT(*), budget FROM military_technology_projects WHERE region = 'Asia' GROUP BY budget ORDER BY budget DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE strains (strain_id INT, strain_name TEXT, state TEXT); INSERT INTO strains (strain_id, strain_name, state) VALUES (1, 'Purple Haze', 'Oregon'); INSERT INTO strains (strain_id, strain_name, state) VALUES (2, 'Blue Dream', 'Oregon'); | How many unique strains were available in Oregon during 2021? | SELECT COUNT(DISTINCT strain_name) FROM strains WHERE state = 'Oregon' AND sale_date BETWEEN '2021-01-01' AND '2021-12-31'; | gretelai_synthetic_text_to_sql |
CREATE TABLE cases (case_id INT, attorney_id INT, result VARCHAR(10)); CREATE TABLE attorneys (attorney_id INT, firm VARCHAR(20)); INSERT INTO cases (case_id, attorney_id, result) VALUES (1, 1, 'Won'), (2, 2, 'Lost'), (3, 1, 'Won'), (4, 3, 'Won'); INSERT INTO attorneys (attorney_id, firm) VALUES (1, 'Smith'), (2, 'Jone... | How many cases were won by attorneys from the 'Smith' law firm? | SELECT COUNT(*) FROM cases INNER JOIN attorneys ON cases.attorney_id = attorneys.attorney_id WHERE attorneys.firm = 'Smith' AND result = 'Won'; | gretelai_synthetic_text_to_sql |
CREATE TABLE student_mental_health (student_id INT, mental_health_score INT, semester VARCHAR(10)); INSERT INTO student_mental_health (student_id, mental_health_score, semester) VALUES (1, 75, 'Spring 2021'), (2, 80, 'Spring 2021'), (3, 70, 'Spring 2021'), (4, 77, 'Spring 2021'); CREATE TABLE open_pedagogy (student_id ... | What are the mental health scores of students in 'Spring 2021' who participated in open pedagogy projects? | SELECT mental_health_score FROM student_mental_health JOIN open_pedagogy ON student_mental_health.student_id = open_pedagogy.student_id WHERE semester = 'Spring 2021'; | gretelai_synthetic_text_to_sql |
CREATE TABLE station_emergencies (eid INT, sid INT, time TIMESTAMP, PRIMARY KEY(eid), FOREIGN KEY(sid) REFERENCES stations(sid)); | What is the average response time for emergencies in each police station? | SELECT s.name, AVG(TIMESTAMPDIFF(MINUTE, se.time, (SELECT time FROM station_emergencies se2 WHERE se2.sid = s.sid AND se2.time > se.time ORDER BY se2.time LIMIT 1))) AS avg_response_time FROM stations s JOIN station_emergencies se ON s.sid = se.sid GROUP BY s.sid; | gretelai_synthetic_text_to_sql |
CREATE TABLE military_sales (id INT, year INT, region VARCHAR(20), equipment_type VARCHAR(20), value FLOAT); INSERT INTO military_sales (id, year, region, equipment_type, value) VALUES (1, 2021, 'Asia', 'Missiles', 9000000); INSERT INTO military_sales (id, year, region, equipment_type, value) VALUES (2, 2021, 'Asia', '... | What was the average value of military equipment sales to the Asian region in 2021? | SELECT AVG(value) FROM military_sales WHERE year = 2021 AND region = 'Asia'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Districts (DistrictID int, DistrictName varchar(255)); INSERT INTO Districts (DistrictID, DistrictName) VALUES (1, 'Downtown'), (2, 'Uptown'), (3, 'Northside'), (4, 'Southside'); CREATE TABLE RoutesToDistricts (RouteID int, DistrictID int); INSERT INTO RoutesToDistricts (RouteID, DistrictID) VALUES (1, 1),... | What is the minimum number of routes that serve each district? | SELECT DistrictID, MIN(RouteID) FROM RoutesToDistricts GROUP BY DistrictID; | gretelai_synthetic_text_to_sql |
CREATE TABLE policyholders (id INT, policyholder_name TEXT, state TEXT, claim_amount INT); INSERT INTO policyholders VALUES (1, 'John Doe', 'NY', 5000); INSERT INTO policyholders VALUES (2, 'Jane Smith', 'NY', 7000); INSERT INTO policyholders VALUES (3, 'Mike Johnson', 'NJ', 3000); | What is the average claim amount for policyholders living in 'NY'? | SELECT AVG(claim_amount) FROM policyholders WHERE state = 'NY'; | gretelai_synthetic_text_to_sql |
CREATE TABLE city (id INT, name VARCHAR(255)); INSERT INTO city (id, name) VALUES (1, 'New York'), (2, 'Los Angeles'), (3, 'Chicago'), (4, 'Houston'), (5, 'Phoenix'); CREATE TABLE mayor (id INT, city_id INT, name VARCHAR(255), community VARCHAR(255), start_year INT, end_year INT); INSERT INTO mayor (id, city_id, name, ... | Which cities have had a mayor from a historically underrepresented community for the longest continuous period of time? | SELECT c.name, MAX(m.end_year - m.start_year) as max_tenure FROM city c JOIN mayor m ON c.id = m.city_id WHERE m.community != 'White' GROUP BY c.name HAVING MAX(m.end_year - m.start_year) >= ALL (SELECT MAX(m2.end_year - m2.start_year) FROM mayor m2 WHERE m2.community != 'White') | gretelai_synthetic_text_to_sql |
CREATE TABLE vessels(id INT, name VARCHAR(50), type VARCHAR(50)); CREATE TABLE cargo_transport(vessel_id INT, cargo_type VARCHAR(50), quantity INT, transport_date DATE); INSERT INTO vessels VALUES (1, 'Vessel1', 'Container'); INSERT INTO cargo_transport VALUES (1, 'Container', 2000, '2022-01-01'); | How many containers were transported by each vessel in the last 3 months? | SELECT vessels.name, SUM(cargo_transport.quantity) FROM vessels INNER JOIN cargo_transport ON vessels.id = cargo_transport.vessel_id WHERE cargo_transport.transport_date >= DATE_SUB(CURRENT_DATE, INTERVAL 3 MONTH) AND vessels.type = 'Container' GROUP BY vessels.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE workouts (id INT, user_id INT, workout_type VARCHAR(20), duration INT); INSERT INTO workouts (id, user_id, workout_type, duration) VALUES (1, 101, 'Strength Training', 60), (2, 102, 'Strength Training', 90), (3, 103, 'Strength Training', 45), (4, 104, 'Yoga', 30), (5, 105, 'Pilates', 60), (6, 106, 'Zumba',... | What are the top 3 most popular workout types for users aged 40-50? | SELECT workout_type, COUNT(*) as num_workouts FROM workouts JOIN users ON workouts.user_id = users.id WHERE users.birthdate BETWEEN '1976-01-01' AND '1986-12-31' GROUP BY workout_type ORDER BY num_workouts DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE construction_union (id INT, name VARCHAR, title VARCHAR); INSERT INTO construction_union (id, name, title) VALUES (1, 'Sergei', 'Carpenter'); CREATE TABLE education_union (id INT, name VARCHAR, title VARCHAR); INSERT INTO education_union (id, name, title) VALUES (1, 'Yvonne', 'Teacher'); | Display the names and job titles of members who are in the 'construction' union but not in the 'education' union. | SELECT name, title FROM construction_union WHERE name NOT IN (SELECT name FROM education_union); | gretelai_synthetic_text_to_sql |
CREATE TABLE investment (id INT, company_id INT, investor TEXT, year INT, amount FLOAT); INSERT INTO investment (id, company_id, investor, year, amount) VALUES (1, 1, 'Andreessen Horowitz', 2022, 15000000.0); CREATE TABLE company (id INT, name TEXT, industry TEXT, founder TEXT, PRIMARY KEY (id)); INSERT INTO company (i... | How many investments were made in Black-founded startups in the last 3 years? | SELECT COUNT(*) FROM investment i JOIN company c ON i.company_id = c.id WHERE c.founder = 'Black' AND i.year >= (SELECT YEAR(CURRENT_DATE()) - 3); | gretelai_synthetic_text_to_sql |
CREATE TABLE Vessels (id INT, name VARCHAR(50), type VARCHAR(50), max_cargo_weight INT); CREATE TABLE PortCalls (id INT, vessel_id INT, port VARCHAR(50), call_date DATE); INSERT INTO Vessels (id, name, type, max_cargo_weight) VALUES (1, 'Vessel1', 'OilTanker', 100000), (2, 'Vessel2', 'BulkCarrier', 150000); INSERT INTO... | What is the maximum cargo weight for vessels that visited a specific port? | SELECT Vessels.name, MAX(Vessels.max_cargo_weight) FROM Vessels INNER JOIN PortCalls ON Vessels.id = PortCalls.vessel_id WHERE PortCalls.port = 'PortA' GROUP BY Vessels.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE projects (project_id INT, city TEXT, schema_name TEXT); INSERT INTO projects (project_id, city, schema_name) VALUES (1, 'New York', 'smart_cities'), (2, 'Los Angeles', 'smart_cities'), (3, 'Chicago', 'smart_cities'), (4, 'Houston', 'smart_cities'); CREATE TABLE green_projects (project_id INT, project_type ... | What is the total cost of green building projects for each city in the 'smart_cities' schema, grouped by city? | SELECT city, SUM(cost) FROM projects JOIN green_projects ON projects.project_id = green_projects.project_id WHERE schema_name = 'smart_cities' AND project_type = 'green building' GROUP BY city; | gretelai_synthetic_text_to_sql |
CREATE TABLE PublicWorksProjects (ProjectID INT, Name VARCHAR(255), Location VARCHAR(255), Status VARCHAR(255)); INSERT INTO PublicWorksProjects VALUES (1, 'Water Treatment Plant', 'Colorado', 'Completed'); INSERT INTO PublicWorksProjects VALUES (2, 'Sewer System Upgrade', 'California', 'In Progress'); | How many public works projects have been completed in each state, and which ones are they? | SELECT Location, COUNT(*) as NumberOfProjects, STRING_AGG(Name, ', ') as CompletedProjects FROM PublicWorksProjects WHERE Status = 'Completed' GROUP BY Location; | gretelai_synthetic_text_to_sql |
CREATE TABLE volunteer_hours (volunteer_id INT, program_id INT, hours_served INT, volunteering_year INT); INSERT INTO volunteer_hours (volunteer_id, program_id, hours_served, volunteering_year) VALUES (1, 1, 50, 2021), (2, 1, 75, 2021), (3, 2, 100, 2021), (4, 2, 125, 2021); | What is the total number of volunteers and total volunteer hours for each program in the past year? | SELECT volunteering_year, program_id, COUNT(DISTINCT volunteer_id) num_volunteers, SUM(hours_served) total_hours FROM volunteer_hours WHERE volunteering_year = YEAR(CURRENT_DATE) - 1 GROUP BY volunteering_year, program_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE country (id INT PRIMARY KEY, name VARCHAR(255));CREATE TABLE region (id INT PRIMARY KEY, name VARCHAR(255));CREATE TABLE incident (id INT PRIMARY KEY, country_id INT, region_id INT, reported_date DATE); INSERT INTO country (id, name) VALUES (1, 'China'), (2, 'Japan'), (3, 'India'); INSERT INTO region (id, ... | What is the total number of cybersecurity incidents reported by each country in the Asia-Pacific region in 2020? | SELECT c.name, COUNT(i.id) as total_incidents FROM country c INNER JOIN incident i ON c.id = i.country_id INNER JOIN region r ON i.region_id = r.id WHERE r.name = 'Asia-Pacific' AND YEAR(i.reported_date) = 2020 GROUP BY c.name; | 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 difference in close price between each stock and its previous day's close? | SELECT stock_symbol, date, close_price, close_price - LAG(close_price) OVER (PARTITION BY stock_symbol ORDER BY date) as price_difference FROM stocks; | gretelai_synthetic_text_to_sql |
CREATE TABLE oceans (ocean_id INT, name VARCHAR(50)); CREATE TABLE species (species_id INT, name VARCHAR(50), ocean_id INT, habitat VARCHAR(50)); INSERT INTO oceans VALUES (1, 'Atlantic'), (2, 'Pacific'), (3, 'Indian'), (4, 'Arctic'), (5, 'Southern'); INSERT INTO species VALUES (1, 'Clownfish', 2, 'Marine'), (2, 'Salmo... | Find the number of marine species in each ocean, excluding those in freshwater environments. | SELECT s.ocean_id, COUNT(DISTINCT s.species_id) FROM species s WHERE s.habitat = 'Marine' GROUP BY s.ocean_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE mental_health_providers (id INT, name VARCHAR(50), state VARCHAR(50), cultural_competency_score INT); INSERT INTO mental_health_providers (id, name, state, cultural_competency_score) VALUES (1, 'Dr. Jane Doe', 'New York', NULL), (2, 'Dr. John Smith', 'California', 80), (3, 'Dr. Maria Garcia', 'Florida', NU... | How many mental health providers in total, and by each state, have not reported their cultural competency scores? | SELECT COUNT(*), state FROM mental_health_providers WHERE cultural_competency_score IS NULL GROUP BY state; | gretelai_synthetic_text_to_sql |
CREATE TABLE Brands (Brand_ID INT, Brand_Name TEXT, Number_Of_Products INT, Number_Of_Cruelty_Free_Products INT); INSERT INTO Brands (Brand_ID, Brand_Name, Number_Of_Products, Number_Of_Cruelty_Free_Products) VALUES (1, 'Lush', 50, 50), (2, 'The Body Shop', 100, 80), (3, 'Estée Lauder', 200, 50), (4, 'Natural Beauty', ... | What are the top 3 brands with the highest percentage of cruelty-free products? | SELECT Brand_Name, (Number_Of_Cruelty_Free_Products * 100.0 / Number_Of_Products) AS Percentage FROM Brands ORDER BY Percentage DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE ocean_acidity (id INT, location TEXT, pH FLOAT, year INT); INSERT INTO ocean_acidity (id, location, pH, year) VALUES (1, 'Southern Ocean', 8.0, 2011), (2, 'Southern Ocean', 7.9, 2012), (3, 'Southern Ocean', 8.1, 2013); | What is the average ocean acidity level (pH value) in the Southern Ocean over the last 10 years? | SELECT AVG(pH) FROM ocean_acidity WHERE location = 'Southern Ocean' AND year BETWEEN 2011 AND 2021; | gretelai_synthetic_text_to_sql |
CREATE TABLE satellites (id INT PRIMARY KEY, name VARCHAR(50), launch_date DATE); INSERT INTO satellites (id, name, launch_date) VALUES (1, 'USA-193', '2009-04-22'), (2, 'USA-200', '2010-02-11'), (3, 'USA-202', '2010-11-20'), (4, 'HawkSat-1', '2011-07-14'), (5, 'Dovesat-1', '2012-06-30'); | Delete all satellites deployed before 2010 | DELETE FROM satellites WHERE launch_date < '2010-01-01'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Donations (DonationID INT, DonationAmount DECIMAL(10, 2), Program VARCHAR(20)); INSERT INTO Donations (DonationID, DonationAmount, Program) VALUES (1, 1000.00, 'Education'); INSERT INTO Donations (DonationID, DonationAmount, Program) VALUES (2, 1500.00, 'Education'); INSERT INTO Donations (DonationID, Dona... | What is the total amount of donations received for 'Community Education Programs'? | SELECT SUM(DonationAmount) FROM Donations WHERE Program = 'Education'; | gretelai_synthetic_text_to_sql |
CREATE TABLE soccer_teams (id INT, name VARCHAR(50), sport VARCHAR(50), fans INT); | Which soccer team has the highest number of fans in Asia? | SELECT name FROM (SELECT name, ROW_NUMBER() OVER (ORDER BY fans DESC) as rank FROM soccer_teams WHERE sport = 'soccer' AND country = 'Asia') subquery WHERE rank = 1; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA if not exists engineering; USE engineering; CREATE TABLE if not exists bioprocess (id INT PRIMARY KEY, location VARCHAR(255), efficiency DECIMAL(4,2)); INSERT INTO bioprocess (id, location, efficiency) VALUES (1, 'Germany', 85.25), (2, 'Germany', 87.68), (3, 'USA', 82.34), (4, 'USA', 83.56), (5, 'Mexico',... | What is the average bioprocess efficiency for all locations? | SELECT AVG(efficiency) FROM engineering.bioprocess; | gretelai_synthetic_text_to_sql |
CREATE TABLE Routes (RouteID INT, RouteName VARCHAR(50), TotalRevenue DECIMAL(10,2)); INSERT INTO Routes (RouteID, RouteName, TotalRevenue) VALUES (1, 'RouteA', 5000), (2, 'RouteB', 7000); | What is the total revenue for each route? | SELECT RouteID, RouteName, SUM(TotalRevenue) FROM Routes GROUP BY RouteID, RouteName; | gretelai_synthetic_text_to_sql |
CREATE TABLE project_budget (project_id INT, budget DECIMAL); INSERT INTO project_budget (project_id, budget) VALUES (1, 1000000.00); | What is the average budget for climate adaptation projects in Oceania? | SELECT AVG(budget) FROM project_budget JOIN climate_project ON project_budget.project_id = climate_project.project_id WHERE climate_project.project_type = 'Adaptation' AND climate_project.project_region = 'Oceania'; | gretelai_synthetic_text_to_sql |
CREATE TABLE countries (country_id INT, country_name VARCHAR(255));CREATE TABLE refugee_camps (camp_id INT, camp_name VARCHAR(255), country_id INT, managing_org VARCHAR(50));INSERT INTO countries (country_id, country_name) VALUES (1, 'Country A'), (2, 'Country B'), (3, 'Country C');INSERT INTO refugee_camps (camp_id, c... | List the number of refugee camps in each country, excluding those managed by the UN. | SELECT c.country_name, COUNT(*) as num_camps FROM countries c JOIN refugee_camps rc ON c.country_id = rc.country_id WHERE rc.managing_org != 'UN' GROUP BY c.country_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE recycling_rates_oceania(country VARCHAR(20), year INT, population INT, recycling_rate FLOAT); INSERT INTO recycling_rates_oceania(country, year, population, recycling_rate) VALUES ('Australia', 2019, 25000000, 57.4), ('New Zealand', 2019, 4800000, 41.5), ('Papua New Guinea', 2019, 8000000, 2.6), ('Fiji', 2... | What is the average recycling rate in percentage for the year 2019 for countries in Oceania with a population less than 5 million? | SELECT AVG(recycling_rate) FROM recycling_rates_oceania WHERE year = 2019 AND population < 5000000 GROUP BY year; | gretelai_synthetic_text_to_sql |
CREATE TABLE aquatic_feeds (species VARCHAR(50), feed_cost DECIMAL(5,2)); INSERT INTO aquatic_feeds (species, feed_cost) VALUES ('Tilapia', 2.50), ('Salmon', 3.25), ('Catfish', 1.75), ('Tuna', 4.50); | What is the average feed cost per species for aquatic farming, excluding fish species with an average feed cost greater than $3.50? | SELECT species, AVG(feed_cost) as avg_feed_cost FROM aquatic_feeds WHERE feed_cost <= 3.5 GROUP BY species; | gretelai_synthetic_text_to_sql |
CREATE TABLE mine_sites (id INT PRIMARY KEY, name TEXT, location TEXT, size FLOAT, annual_production INT); INSERT INTO mine_sites (id, name, location, size, annual_production) VALUES (1, 'Konkola', 'Zambia', 250.0, 120000); INSERT INTO mine_sites (id, name, location, size, annual_production) VALUES (2, 'Lumwana', 'Zamb... | What is the maximum annual production for mines located in Zambia? | SELECT location, MAX(annual_production) as max_annual_production FROM mine_sites WHERE location = 'Zambia'; | gretelai_synthetic_text_to_sql |
CREATE TABLE SitePeriods (SiteID varchar(5), SiteName varchar(10), Period varchar(15)); INSERT INTO SitePeriods (SiteID, SiteName, Period) VALUES ('S001', 'Site S', 'Stone Age'), ('S002', 'Site T', 'Ice Age'); | List sites and their corresponding historical periods. | SELECT SiteID, SiteName, Period FROM SitePeriods; | gretelai_synthetic_text_to_sql |
CREATE TABLE circular_sales (sale_id int, product_id int, circular_supply_chain boolean, region varchar, sale_date date); | How many circular supply chain products were sold in each region, in the last 6 months? | SELECT region, COUNT(*) AS circular_sales FROM circular_sales WHERE circular_supply_chain = true AND sale_date >= DATEADD(month, -6, GETDATE()) GROUP BY region; | gretelai_synthetic_text_to_sql |
CREATE TABLE devices (id INT PRIMARY KEY, user_id INT, device_type VARCHAR(50), last_seen TIMESTAMP); INSERT INTO devices (id, user_id, device_type, last_seen) VALUES (1, 1, 'mobile', '2022-01-01 12:00:00'); | Delete inactive users | DELETE FROM devices WHERE last_seen < '2022-01-01'; | gretelai_synthetic_text_to_sql |
CREATE TABLE actors (name VARCHAR(255), gender VARCHAR(10), movies INTEGER); INSERT INTO actors (name, gender, movies) VALUES ('ActorA', 'Female', 12), ('ActorB', 'Male', 15), ('ActorC', 'Female', 8), ('ActorD', 'Female', 20), ('ActorE', 'Male', 18), ('ActorF', 'Male', 10), ('ActorG', 'Female', 11); | Who are the female actors with more than 10 movies acted? | SELECT name FROM actors WHERE gender = 'Female' AND movies > 10; | gretelai_synthetic_text_to_sql |
CREATE TABLE RacingRivals (PlayerID INT, HoursPlayed INT, Wins INT); INSERT INTO RacingRivals (PlayerID, HoursPlayed, Wins) VALUES (1, 25, 7), (2, 30, 8), (3, 22, 6), (4, 35, 10), (5, 28, 9); | What is the total number of hours played by players in the "RacingRivals" table, who have played for more than 20 hours and have more than 5 wins? | SELECT SUM(HoursPlayed) FROM RacingRivals WHERE HoursPlayed > 20 AND Wins > 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE tokyo_bike_station_info (station_id INT, city VARCHAR(20), bikes_available INT); INSERT INTO tokyo_bike_station_info (station_id, city, bikes_available) VALUES (1, 'Tokyo', 25), (2, 'Tokyo', 30), (3, 'Tokyo', 35); | What is the maximum number of bike-share bikes available in a station in Tokyo? | SELECT MAX(bikes_available) FROM tokyo_bike_station_info WHERE city = 'Tokyo'; | 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.