context stringlengths 11 9.12k | question stringlengths 0 1.06k | SQL stringlengths 2 4.44k | source stringclasses 28 values |
|---|---|---|---|
CREATE TABLE Research.Species ( id INT, species_name VARCHAR(255), population INT ); | Find the species names and their respective populations, ordered alphabetically, in the 'Research' schema's 'Species' table | SELECT species_name, population FROM Research.Species ORDER BY species_name ASC; | gretelai_synthetic_text_to_sql |
CREATE TABLE fair_labor_practices (member_id INT, name VARCHAR(50), union_joined_date DATE); INSERT INTO fair_labor_practices (member_id, name, union_joined_date) VALUES (32, 'Mason Green', '2021-03-01'), (33, 'Olivia Baker', '2021-06-15'), (34, 'Nathan Robinson', '2021-08-28'); | List all members who joined the 'fair_labor_practices' union in 2021. | SELECT * FROM fair_labor_practices WHERE YEAR(union_joined_date) = 2021; | gretelai_synthetic_text_to_sql |
CREATE TABLE menu_items (menu_item_id INT, name VARCHAR(255), description TEXT, price DECIMAL(5,2), category VARCHAR(255), sustainability_rating INT); | List all menu items with a sustainability_rating of 5 | SELECT * FROM menu_items WHERE sustainability_rating = 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE vessels (id INT, name TEXT, type TEXT, compliance_score INT);CREATE TABLE cargos (id INT, vessel_id INT, weight FLOAT, destination TEXT, date DATE); INSERT INTO vessels (id, name, type, compliance_score) VALUES (1, 'VesselD', 'Container', 85); INSERT INTO cargos (id, vessel_id, weight, destination, date) VALUES (1, 1, 10000, 'Atlantic', '2021-01-01'); | What is the total cargo weight transported by vessels with a compliance score above 80 in the Atlantic Ocean in Q1 2021? | SELECT SUM(c.weight) FROM vessels v JOIN cargos c ON v.id = c.vessel_id WHERE v.compliance_score > 80 AND c.destination LIKE 'Atlantic%' AND c.date BETWEEN '2021-01-01' AND '2021-03-31'; | gretelai_synthetic_text_to_sql |
CREATE TABLE teacher_workshops (teacher_id INT, workshop_id INT, enrollment_date DATE); INSERT INTO teacher_workshops VALUES (1, 1001, '2022-03-01'), (1, 1002, '2022-04-01'); CREATE TABLE workshops (workshop_id INT, workshop_name VARCHAR(50)); INSERT INTO workshops VALUES (1001, 'Tech Tools'), (1002, 'Diverse Classrooms'); | What is the progression of professional development workshops attended by a randomly selected teacher, in the last 6 months? | SELECT teacher_id, workshop_id, LEAD(enrollment_date, 1) OVER (PARTITION BY teacher_id ORDER BY enrollment_date) as next_workshop_date FROM teacher_workshops JOIN workshops ON teacher_workshops.workshop_id = workshops.workshop_id WHERE teacher_id = 1 AND enrollment_date >= DATEADD(month, -6, GETDATE()); | gretelai_synthetic_text_to_sql |
CREATE TABLE RestaurantInspections (restaurant_id INT, inspection_score INT, country VARCHAR(50)); INSERT INTO RestaurantInspections (restaurant_id, inspection_score, country) VALUES (1, 95, 'Canada'), (2, 85, 'Canada'), (3, 90, 'Canada'), (4, 80, 'Canada'), (5, 92, 'Canada'); | What is the distribution of food safety inspection scores for restaurants in Canada? | SELECT inspection_score, COUNT(*) AS count FROM RestaurantInspections WHERE country = 'Canada' GROUP BY inspection_score; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA if not exists biosensor;CREATE TABLE if not exists biosensor.sensors(id INT, name TEXT, disease_category TEXT);INSERT INTO biosensor.sensors (id, name, disease_category) VALUES (1, 'BiosensorA', 'Cancer'), (2, 'BiosensorB', 'Heart Disease'), (3, 'BiosensorC', 'Cancer'), (4, 'BiosensorD', 'Neurological Disorders'); | List the biosensors developed for a specific disease category. | SELECT * FROM biosensor.sensors WHERE disease_category = 'Cancer'; | gretelai_synthetic_text_to_sql |
CREATE TABLE virtual_tour_count (tour_id INT, city TEXT, region TEXT, tour_date DATE); INSERT INTO virtual_tour_count (tour_id, city, region, tour_date) VALUES (1, 'CityN', 'South America', '2022-01-01'), (2, 'CityO', 'South America', '2022-01-02'), (3, 'CityP', 'South America', '2022-01-03'); | How many virtual tours were conducted in 'South America'? | SELECT COUNT(*) FROM virtual_tour_count WHERE region = 'South America'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Cases (CaseID INT, ClientFirstName VARCHAR(50), ClientLastName VARCHAR(50), State VARCHAR(2), CaseOutcome VARCHAR(20), OpenDate DATE, CloseDate DATE); INSERT INTO Cases (CaseID, ClientFirstName, ClientLastName, State, CaseOutcome, OpenDate, CloseDate) VALUES (1, 'John', 'Doe', 'NY', 'won', '2020-01-01', '2020-06-01'), (2, 'Jane', 'Smith', 'CA', 'won', '2019-01-01', '2019-12-31'), (3, 'Mike', 'Johnson', 'NY', 'lost', '2021-01-01', '2021-06-01'); | Find the client's first and last name, state, and the difference between the case closing date and the case opening date, for cases with an outcome of 'won', partitioned by state and ordered by the difference in ascending order. | SELECT State, ClientFirstName, ClientLastName, DATEDIFF(CloseDate, OpenDate) AS DaysOpen FROM Cases WHERE CaseOutcome = 'won' ORDER BY State, DaysOpen; | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_life (id INT, species VARCHAR(255), population INT, region VARCHAR(255)); | Insert a new record into the marine_life table for the 'Shark' species with a population of 1000 in the indian_ocean region. | INSERT INTO marine_life (id, species, population, region) VALUES ((SELECT COALESCE(MAX(id), 0) + 1 FROM marine_life), 'Shark', 1000, 'indian_ocean'); | gretelai_synthetic_text_to_sql |
CREATE TABLE students (id INT, name VARCHAR(50), program VARCHAR(50), absences INT, last_visit DATE); | How many students in the mental health program have had more than 3 absences in the past month? | SELECT COUNT(*) FROM students WHERE program = 'mental health' AND absences > 3 AND last_visit >= DATE_SUB(CURDATE(), INTERVAL 1 MONTH); | gretelai_synthetic_text_to_sql |
CREATE TABLE veteran_hires (id INT, hire_number VARCHAR(255), industry VARCHAR(255), date DATE); | What is the total number of veteran hires in the defense industry in the last quarter? | SELECT SUM(*) FROM veteran_hires WHERE industry = 'defense' AND date >= DATE_SUB(CURRENT_DATE, INTERVAL 3 MONTH); | gretelai_synthetic_text_to_sql |
CREATE TABLE companies (id INT, name TEXT, region TEXT); INSERT INTO companies (id, name, region) VALUES (1, 'CompanyI', 'APAC'), (2, 'CompanyJ', 'EMEA'); CREATE TABLE production (year INT, element TEXT, company_id INT, quantity INT); INSERT INTO production (year, element, company_id, quantity) VALUES (2018, 'Praseodymium', 1, 200), (2018, 'Praseodymium', 2, 300), (2019, 'Praseodymium', 1, 400), (2019, 'Praseodymium', 2, 500), (2020, 'Praseodymium', 1, 600), (2020, 'Praseodymium', 2, 700); | What is the total annual production of Praseodymium for companies in the APAC region, for each year? | SELECT production.year, SUM(quantity) as total_quantity FROM production JOIN companies ON production.company_id = companies.id WHERE production.element = 'Praseodymium' AND companies.region = 'APAC' GROUP BY production.year; | gretelai_synthetic_text_to_sql |
CREATE TABLE genres (genre_id INT, genre VARCHAR(50)); CREATE TABLE albums (album_id INT, genre_id INT, title VARCHAR(100), price DECIMAL(5,2), sales INT); | What are the total sales of digital albums for each artist in the Pop genre? | SELECT a.artist, SUM(a.sales) AS total_sales FROM albums al JOIN (SELECT artist_id, artist FROM artists WHERE artists.genre = 'Pop') a ON al.album_id = a.artist_id GROUP BY a.artist; | gretelai_synthetic_text_to_sql |
CREATE TABLE Mineral_Production_4 (year INT, cerium_production FLOAT); | Find the total production of Cerium in 2019 and 2020 from the Mineral_Production_4 table? | SELECT SUM(cerium_production) FROM Mineral_Production_4 WHERE year IN (2019, 2020); | gretelai_synthetic_text_to_sql |
CREATE TABLE Countries (Country VARCHAR(50), Continent VARCHAR(50), Life_Expectancy FLOAT); INSERT INTO Countries (Country, Continent, Life_Expectancy) VALUES ('Algeria', 'Africa', 76.29), ('Angola', 'Africa', 60.79); | What is the average life expectancy in Africa by country? | SELECT Continent, AVG(Life_Expectancy) FROM Countries WHERE Continent = 'Africa' GROUP BY Continent; | gretelai_synthetic_text_to_sql |
CREATE TABLE whale_biomass (species TEXT, location TEXT, biomass INTEGER); INSERT INTO whale_biomass (species, location, biomass) VALUES ('Blue Whale', 'Arctic', 200000), ('Humpback Whale', 'Arctic', 70000), ('Sperm Whale', 'Arctic', 300000), ('Beluga Whale', 'Arctic', 60000); | What is the minimum biomass of any whale species in the Arctic Ocean? | SELECT MIN(biomass) FROM whale_biomass WHERE location = 'Arctic'; | gretelai_synthetic_text_to_sql |
CREATE TABLE movies (title VARCHAR(255), genre VARCHAR(50)); INSERT INTO movies (title, genre) VALUES ('Movie1', 'Action'), ('Movie2', 'Drama'), ('Movie3', 'Comedy'), ('Movie4', 'Action'), ('Movie5', 'Drama'), ('Movie6', 'Sci-Fi'); | How many unique genres are there in the database? | SELECT COUNT(DISTINCT genre) FROM movies; | gretelai_synthetic_text_to_sql |
CREATE TABLE game_reviews (review_id INT, player_id INT, game_name VARCHAR(100), rating INT, region VARCHAR(50), date DATE); | Update the 'game_reviews' table to set the 'rating' column as 5 for the game 'Game1' in the 'Europe' region | UPDATE game_reviews SET rating = 5 WHERE game_name = 'Game1' AND region = 'Europe'; | gretelai_synthetic_text_to_sql |
CREATE TABLE songs (id INT, title VARCHAR(255), artist VARCHAR(255)); INSERT INTO songs (id, title, artist) VALUES (1, 'Song 1', 'Artist A'); | Which artist has the most songs in the songs table? | SELECT artist, COUNT(*) as song_count FROM songs GROUP BY artist ORDER BY song_count DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE recycling_rates (region VARCHAR(10), year INT, material_type VARCHAR(20), recycling_rate DECIMAL(5,2)); INSERT INTO recycling_rates (region, year, material_type, recycling_rate) VALUES ('Asia-Pacific', 2019, 'Plastic', 0.35), ('Asia-Pacific', 2019, 'Paper', 0.60), ('Asia-Pacific', 2019, 'Glass', 0.45); | Identify the recycling rates for 'Asia-Pacific' in 2019, for each material type, and show the overall recycling rate. | SELECT material_type, AVG(recycling_rate) AS avg_recycling_rate FROM recycling_rates WHERE region = 'Asia-Pacific' AND year = 2019 GROUP BY material_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE donations (id INT, program TEXT, donation_amount DECIMAL(10, 2), donation_date DATE); INSERT INTO donations VALUES (1, 'Education', 200.00, '2021-01-01'), (2, 'Healthcare', 300.00, '2021-02-01'), (3, 'Environment', 400.00, '2020-12-01'); | What is the total donation amount per program in the last year? | SELECT program, SUM(donation_amount) FROM donations WHERE donation_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR) GROUP BY program; | gretelai_synthetic_text_to_sql |
CREATE TABLE labor_hours (zip VARCHAR(5), state VARCHAR(2), year INT, hours INT); INSERT INTO labor_hours (zip, state, year, hours) VALUES ('75201', 'TX', 2019, 5000); | What are the top 5 zip codes with the most construction labor hours in Texas in 2019? | SELECT zip, SUM(hours) FROM labor_hours WHERE state = 'TX' AND year = 2019 GROUP BY zip ORDER BY SUM(hours) DESC LIMIT 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE playtime (id INT, player_id INT, game VARCHAR(50), playtime FLOAT); INSERT INTO playtime VALUES (1, 1, 'Galactic Guardians', 180.5); INSERT INTO playtime VALUES (2, 2, 'Galactic Guardians', 240.75); | What is the total playtime of all players who have played the game "Galactic Guardians" for more than 3 hours in the past week? | SELECT SUM(playtime) FROM playtime WHERE game = 'Galactic Guardians' AND playtime > 3 * 60; | gretelai_synthetic_text_to_sql |
CREATE TABLE wind_farms (name VARCHAR(50), location VARCHAR(50), capacity FLOAT, primary key (name)); INSERT INTO wind_farms (name, location, capacity) VALUES ('Farm A', 'California', 100), ('Farm B', 'Texas', 150), ('Farm C', 'Oregon', 200); CREATE TABLE production (wind_farm VARCHAR(50), date DATE, energy_production FLOAT, primary key (wind_farm, date), foreign key (wind_farm) references wind_farms(name)); INSERT INTO production (wind_farm, date, energy_production) VALUES ('Farm A', '2021-01-01', 2500), ('Farm A', '2021-01-02', 2400), ('Farm B', '2021-01-01', 3500), ('Farm B', '2021-01-02', 3700), ('Farm C', '2021-01-01', 4500), ('Farm C', '2021-01-02', 4300); | What is the average daily energy production (in MWh) for each wind farm in the month of January 2021? | SELECT wind_farm, AVG(energy_production) as avg_daily_production FROM production WHERE date BETWEEN '2021-01-01' AND '2021-01-31' GROUP BY wind_farm, EXTRACT(MONTH FROM date), EXTRACT(YEAR FROM date) | gretelai_synthetic_text_to_sql |
CREATE TABLE CustomerData2 (id INT, customer_id INT, product VARCHAR(20), size INT, country VARCHAR(10)); INSERT INTO CustomerData2 (id, customer_id, product, size, country) VALUES (1, 2001, 'jacket', 14, 'India'), (2, 2002, 'shirt', 12, 'Australia'); | What is the average size of customers who purchased jackets in India? | SELECT AVG(size) FROM CustomerData2 WHERE product = 'jacket' AND country = 'India'; | gretelai_synthetic_text_to_sql |
CREATE TABLE sales_data (sale_id INT, dish_id INT, sale_date DATE, revenue DECIMAL(10, 2)); INSERT INTO sales_data (sale_id, dish_id, sale_date, revenue) VALUES (1, 1, '2022-01-01', 15.99), (2, 2, '2022-01-01', 7.99), (3, 1, '2022-01-02', 12.99), (4, 3, '2022-01-02', 6.99), (5, 1, '2022-01-16', 10.99), (6, 4, '2022-01-17', 9.99); CREATE TABLE menu (dish_id INT, dish_name VARCHAR(255), dish_type VARCHAR(255)); INSERT INTO menu (dish_id, dish_name, dish_type) VALUES (1, 'Quinoa Salad', 'Vegetarian'), (2, 'Chicken Sandwich', 'Non-Vegetarian'), (3, 'Pumpkin Soup', 'Vegetarian'), (4, 'Beef Stew', 'Non-Vegetarian'); | Find the total sales revenue for each dish type in the last 30 days | SELECT m.dish_type, SUM(s.revenue) AS total_revenue FROM sales_data s JOIN menu m ON s.dish_id = m.dish_id WHERE s.sale_date >= DATE_SUB(CURDATE(), INTERVAL 30 DAY) GROUP BY m.dish_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE chemical_compounds (compound_id INT, compound_name VARCHAR(50), country VARCHAR(50), innovation_score DECIMAL(5,2)); INSERT INTO chemical_compounds (compound_id, compound_name, country, innovation_score) VALUES (1, 'Compound A', 'South Korea', 92.3), (2, 'Compound B', 'South Korea', 87.6), (3, 'Compound C', 'USA', 78.9); | Find the top 3 chemical compounds with the highest innovation scores in South Korea. | SELECT * FROM (SELECT compound_id, compound_name, innovation_score, ROW_NUMBER() OVER (ORDER BY innovation_score DESC) as rn FROM chemical_compounds WHERE country = 'South Korea') tmp WHERE rn <= 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE vessels (id INT, name TEXT, last_port TEXT, last_port_date DATE); INSERT INTO vessels (id, name, last_port, last_port_date) VALUES (1, 'VesselX', 'Santos', '2022-02-12'); INSERT INTO vessels (id, name, last_port, last_port_date) VALUES (2, 'VesselY', 'Rio de Janeiro', '2022-01-28'); INSERT INTO vessels (id, name, last_port, last_port_date) VALUES (3, 'VesselZ', 'Santos', '2021-12-30'); | Which vessels have traveled to the port of Santos, Brazil in the last year? | SELECT DISTINCT name FROM vessels WHERE last_port = 'Santos' AND last_port_date >= DATE_SUB(CURDATE(), INTERVAL 1 YEAR); | gretelai_synthetic_text_to_sql |
CREATE TABLE inclusive_housing (id INT, price FLOAT, wheelchair_accessible BOOLEAN); INSERT INTO inclusive_housing (id, price, wheelchair_accessible) VALUES (1, 400000, true), (2, 500000, false), (3, 600000, true); | What is the minimum price of properties in the table 'inclusive_housing' that have wheelchair accessibility? | SELECT MIN(price) FROM inclusive_housing WHERE wheelchair_accessible = true; | gretelai_synthetic_text_to_sql |
CREATE TABLE DeezerSongs (SongID INT, AddedDate DATE, Genre VARCHAR(50)); INSERT INTO DeezerSongs (SongID, AddedDate, Genre) VALUES (1, '2022-02-15', 'Latin'), (2, '2022-02-16', 'Pop'); | How many songs were added to Deezer's Latin music library in the last month? | SELECT COUNT(*) FROM DeezerSongs WHERE AddedDate >= DATEADD(MONTH, -1, GETDATE()) AND Genre = 'Latin'; | gretelai_synthetic_text_to_sql |
CREATE TABLE animals (id INT PRIMARY KEY, name VARCHAR(50), species VARCHAR(50), population INT, habitat_status VARCHAR(50)); | Delete the animal record for the Komodo Dragon in the 'animals' table | DELETE FROM animals WHERE name = 'Komodo Dragon'; | gretelai_synthetic_text_to_sql |
CREATE TABLE movies (id INT, title VARCHAR(255), rating FLOAT, release_year INT, country VARCHAR(50)); INSERT INTO movies (id, title, rating, release_year, country) VALUES (1, 'Movie1', 7.5, 2010, 'USA'), (2, 'Movie2', 8.2, 2012, 'USA'), (3, 'Movie3', 6.8, 2015, 'USA'); | What is the average rating of movies produced in the US and released between 2010 and 2015? | SELECT AVG(rating) FROM movies WHERE release_year BETWEEN 2010 AND 2015 AND country = 'USA'; | gretelai_synthetic_text_to_sql |
CREATE TABLE smart_city_projects (id INT, name TEXT, country TEXT, completion_year INT); INSERT INTO smart_city_projects (id, name, country, completion_year) VALUES (1, 'Project A', 'Canada', 2016), (2, 'Project B', 'Canada', NULL), (3, 'Project C', 'USA', 2018); | Update the completion year of Project B in Canada to 2017. | UPDATE smart_city_projects SET completion_year = 2017 WHERE name = 'Project B' AND country = 'Canada'; | gretelai_synthetic_text_to_sql |
CREATE TABLE network_investments (id INT, location VARCHAR(50), network_tech VARCHAR(30)); INSERT INTO network_investments (id, location, network_tech) VALUES (1, 'City A', '4G'); | List all the unique network technologies invested in by the company. | SELECT DISTINCT network_tech FROM network_investments; | gretelai_synthetic_text_to_sql |
CREATE TABLE PurpleEnterprisesProjects(id INT, contractor VARCHAR(255), project VARCHAR(255), start_date DATE, end_date DATE);INSERT INTO PurpleEnterprisesProjects(id, contractor, project, start_date, end_date) VALUES (1, 'Purple Enterprises', 'Missile Defense System', '2021-01-01', '2022-12-31'); | Update the 'end_date' of the 'Missile Defense System' project for 'Purple Enterprises' to 2023-06-30 if the current end_date is before 2023-06-30. | UPDATE PurpleEnterprisesProjects SET end_date = '2023-06-30' WHERE contractor = 'Purple Enterprises' AND project = 'Missile Defense System' AND end_date < '2023-06-30'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Donors (DonorID INT, DonorName VARCHAR(50)); INSERT INTO Donors (DonorID, DonorName) VALUES (1, 'John Smith'), (2, 'Jane Doe'); CREATE TABLE Donations (DonationID INT, DonorID INT, DonationDate DATE, Amount DECIMAL(10,2), Department VARCHAR(50)); INSERT INTO Donations (DonationID, DonorID, DonationDate, Amount, Department) VALUES (1, 1, '2023-01-05', 200.00, 'Education'), (2, 1, '2023-01-10', 300.00, 'Health'), (3, 2, '2023-01-15', 400.00, 'Education'); | What is the total donation amount for each department in Q1 of 2023? | SELECT Department, SUM(Amount) as TotalDonation FROM Donations WHERE QUARTER(DonationDate) = 1 AND Year(DonationDate) = 2023 GROUP BY Department; | gretelai_synthetic_text_to_sql |
CREATE TABLE hotels (hotel_id INT, hotel_name TEXT, region TEXT); CREATE TABLE ai_solutions (solution_id INT, hotel_id INT, implemented_date DATE); CREATE TABLE virtual_tours (tour_id INT, hotel_id INT, engagement_score INT); INSERT INTO hotels (hotel_id, hotel_name, region) VALUES (1, 'Scandinavian Retreat', 'EMEA'), (2, 'Mediterranean Palace', 'EMEA'); INSERT INTO ai_solutions (solution_id, hotel_id, implemented_date) VALUES (1, 1, '2021-02-01'), (2, 1, '2021-03-01'), (1, 2, '2021-01-01'), (2, 2, '2021-02-01'); INSERT INTO virtual_tours (tour_id, hotel_id, engagement_score) VALUES (1, 1, 80), (2, 1, 85), (1, 2, 70), (2, 2, 90); | What is the total number of AI-powered solutions implemented in hotels with a virtual tour engagement score of at least 75 in EMEA? | SELECT COUNT(DISTINCT ai_solutions.solution_id) AS total_solutions FROM ai_solutions INNER JOIN hotels ON ai_solutions.hotel_id = hotels.hotel_id INNER JOIN virtual_tours ON hotels.hotel_id = virtual_tours.hotel_id WHERE hotels.region = 'EMEA' AND virtual_tours.engagement_score >= 75; | gretelai_synthetic_text_to_sql |
CREATE TABLE products (id INT, name TEXT, discontinued DATE, sustainable_package BOOLEAN); | Find all products that were discontinued before being sold in a sustainable package. | SELECT name FROM products WHERE discontinued < (SELECT MIN(date) FROM sustainable_packages) AND sustainable_package = FALSE; | gretelai_synthetic_text_to_sql |
CREATE TABLE Employees (EmployeeID INT, Department VARCHAR(255), Gender VARCHAR(255), Salary DECIMAL(10,2)); INSERT INTO Employees (EmployeeID, Department, Gender, Salary) VALUES (1, 'IT', 'Male', 75000.00), (2, 'Diversity and Inclusion', 'Female', 68000.00), (3, 'HR', 'Male', 65000.00); | Update the salaries of all employees in the 'IT' department to 80,000. | UPDATE Employees SET Salary = 80000.00 WHERE Department = 'IT'; | gretelai_synthetic_text_to_sql |
CREATE TABLE national_parks (id INT, name TEXT, daily_visitor_limit INT); INSERT INTO national_parks (id, name, daily_visitor_limit) VALUES (1, 'Yellowstone National Park', 9000); | What is the maximum number of visitors allowed per day in Yellowstone National Park? | SELECT MAX(daily_visitor_limit) FROM national_parks WHERE name = 'Yellowstone National Park'; | gretelai_synthetic_text_to_sql |
CREATE TABLE works (id INT, artist_id INT, medium TEXT); INSERT INTO works (id, artist_id, medium) VALUES (1, 1, 'painting'), (2, 2, 'drawing'), (3, 3, 'sculpture'), (4, 4, 'drawing'), (5, 5, 'painting'); | What is the total number of artists who have created works in the 'drawing' medium? | SELECT COUNT(DISTINCT artist_id) FROM works WHERE medium = 'drawing'; | gretelai_synthetic_text_to_sql |
CREATE TABLE daily_transaction_volume (date DATE, platform_id INT, volume DECIMAL(10,2)); INSERT INTO daily_transaction_volume (date, platform_id, volume) VALUES ('2022-01-01', 1, 5000), ('2022-01-02', 1, 5500), ('2022-01-03', 1, 6000), ('2022-01-01', 2, 3000), ('2022-01-02', 2, 3500), ('2022-01-03', 2, 4000); CREATE TABLE deFi_platforms (platform_id INT, platform_name VARCHAR(255), network VARCHAR(50)); INSERT INTO deFi_platforms (platform_id, platform_name, network) VALUES (1, 'Uniswap', 'ETH'), (2, 'Aave', 'ETH'), (3, 'Compound', 'ETH'); | Who are the top 5 'DeFi' platforms with the highest daily transaction volume on the 'ETH' network in the last 30 days? | SELECT dp.platform_name, SUM(dt.volume) as total_volume FROM daily_transaction_volume dt JOIN deFi_platforms dp ON dt.platform_id = dp.platform_id WHERE dt.date >= CURDATE() - INTERVAL 30 DAY GROUP BY dp.platform_name ORDER BY total_volume DESC LIMIT 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE pine_forests (id INT, area FLOAT); INSERT INTO pine_forests VALUES (1, 22.33), (2, 44.55), (3, 66.77); | What is the maximum wildlife habitat size in pine forests? | SELECT MAX(area) FROM pine_forests; | gretelai_synthetic_text_to_sql |
CREATE TABLE HeritageSites (SiteID INT, Name VARCHAR(50), Location VARCHAR(50), ArtPieceID INT); INSERT INTO HeritageSites VALUES (1, 'Taj Mahal', 'India', 101), (2, 'Machu Picchu', 'Peru', 201), (3, 'Angkor Wat', 'Cambodia', 301); CREATE TABLE ArtPieces (ArtPieceID INT, Name VARCHAR(50), Type VARCHAR(50), Value INT); INSERT INTO ArtPieces VALUES (101, 'Painting 1', 'Traditional', 1000), (201, 'Sculpture 1', 'Traditional', 2000), (301, 'Painting 2', 'Traditional', 3000); | List all heritage sites with more than 5 traditional art pieces, their respective art piece counts, and the average value. | SELECT hs.Name AS HeritageSite, COUNT(ap.ArtPieceID) AS ArtPieceCount, AVG(ap.Value) AS AvgValue FROM HeritageSites hs JOIN ArtPieces ap ON hs.ArtPieceID = ap.ArtPieceID WHERE ap.Type = 'Traditional' GROUP BY hs.Name HAVING COUNT(ap.ArtPieceID) > 5 ORDER BY AvgValue DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE member_demographics (member_id INT, age INT, gender VARCHAR(10), city VARCHAR(50), state VARCHAR(20), country VARCHAR(50)); | Create a view named 'demographics_summary' based on the 'member_demographics' table | CREATE VIEW demographics_summary AS SELECT country, gender, city, COUNT(*) as member_count FROM member_demographics GROUP BY country, gender, city; | gretelai_synthetic_text_to_sql |
CREATE TABLE victims (id INT, name VARCHAR(255), age INT, gender VARCHAR(10), ethnicity VARCHAR(50)); INSERT INTO victims (id, name, age, gender, ethnicity) VALUES (1, 'Raj Patel', 42, 'Male', 'South Asian'); INSERT INTO victims (id, name, age, gender, ethnicity) VALUES (2, 'Priya Kapoor', 36, 'Female', 'South Asian'); CREATE TABLE restorative_justice (case_id INT, type VARCHAR(50), facilitator VARCHAR(255), victim_id INT); INSERT INTO restorative_justice (case_id, type, facilitator, victim_id) VALUES (1, 'Restorative Circles', 'Susan Kim', 1); INSERT INTO restorative_justice (case_id, type, facilitator, victim_id) VALUES (2, 'Victim-Offender Mediation', 'Michael Chen', 2); CREATE TABLE cases (id INT, victim_id INT, case_number VARCHAR(50), location VARCHAR(100)); INSERT INTO cases (id, victim_id, case_number, location) VALUES (1, 1, '2021-CJR-0001', 'New York'); INSERT INTO cases (id, victim_id, case_number, location) VALUES (2, 2, '2022-CJR-0002', 'New York'); | What are the case numbers and types of Restorative Justice interventions for cases with victims from South Asia in New York? | SELECT c.case_number, rj.type FROM cases c JOIN restorative_justice rj ON c.id = rj.case_id WHERE c.victim_id IN (SELECT id FROM victims WHERE ethnicity = 'South Asian') AND rj.location = 'New York'; | gretelai_synthetic_text_to_sql |
CREATE TABLE bus_trips (id INT, bus_type VARCHAR(50), bus_start_location VARCHAR(50), bus_end_location VARCHAR(50), distance FLOAT, travel_time FLOAT); | Calculate the average speed of autonomous buses in London | SELECT AVG(distance / travel_time) AS avg_speed FROM bus_trips WHERE bus_type = 'autonomous' AND bus_start_location = 'London'; | gretelai_synthetic_text_to_sql |
CREATE TABLE workforce_training (team VARCHAR(50), total_hours FLOAT); INSERT INTO workforce_training (team, total_hours) VALUES ('engineering', 12.3), ('production', 14.7), ('maintenance', NULL); | Find the team with the highest total number of training hours in the 'workforce_training' table. | SELECT team, MAX(total_hours) OVER () AS max_total_hours FROM workforce_training WHERE total_hours IS NOT NULL; | gretelai_synthetic_text_to_sql |
CREATE TABLE Customers (CustomerID INT, Name VARCHAR(50), AccountBalance DECIMAL(18,2));CREATE TABLE Investments (CustomerID INT, InvestmentType VARCHAR(10), Sector VARCHAR(10));INSERT INTO Customers VALUES (1,'John Doe',25000.00),(2,'Jane Smith',30000.00),(3,'Bob Johnson',40000.00);INSERT INTO Investments VALUES (1,'Stocks','Real Estate'),(2,'Stocks','Real Estate'),(3,'Stocks','Healthcare'); | What is the average account balance of customers who have invested in the real estate sector? | SELECT AVG(c.AccountBalance) FROM Customers c INNER JOIN Investments i ON c.CustomerID = i.CustomerID WHERE i.Sector = 'Real Estate'; | gretelai_synthetic_text_to_sql |
CREATE TABLE agricultural_innovation_projects (id INT, country VARCHAR(255), year INT, cost FLOAT); INSERT INTO agricultural_innovation_projects (id, country, year, cost) VALUES (1, 'Rwanda', 2020, 30000.00), (2, 'Rwanda', 2020, 35000.00); | What was the average cost of agricultural innovation projects in Rwanda in 2020?' | SELECT AVG(cost) FROM agricultural_innovation_projects WHERE country = 'Rwanda' AND year = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE policyholders (policy_number INT, policyholder_name VARCHAR(50), car_make VARCHAR(20), car_model VARCHAR(20), policyholder_state VARCHAR(20), policy_effective_date DATE); | Retrieve the policy numbers, policyholder names, car models, and policy effective dates for policyholders who own a 'Ford' or 'Subaru' vehicle and live in 'Texas' | SELECT policy_number, policyholder_name, car_model, policy_effective_date FROM policyholders WHERE (car_make = 'Ford' OR car_make = 'Subaru') AND policyholder_state = 'Texas'; | gretelai_synthetic_text_to_sql |
CREATE TABLE cosmetics_products(product_id INT, product_name VARCHAR(100), category VARCHAR(50), cruelty_free BOOLEAN, consumer_rating FLOAT); | What are the average consumer ratings for cruelty-free cosmetics products in the skincare category? | SELECT AVG(consumer_rating) FROM cosmetics_products WHERE category = 'skincare' AND cruelty_free = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE mental_health_facilities (facility_id INT, name VARCHAR(50), state VARCHAR(25)); INSERT INTO mental_health_facilities (facility_id, name, state) VALUES (1, 'Example MHF', 'California'); INSERT INTO mental_health_facilities (facility_id, name, state) VALUES (2, 'Another MHF', 'New York'); INSERT INTO mental_health_facilities (facility_id, name, state) VALUES (3, 'Third MHF', 'Texas'); | How many mental health facilities are there in each state? | SELECT state, COUNT(*) FROM mental_health_facilities GROUP BY state; | gretelai_synthetic_text_to_sql |
CREATE TABLE products (product_id INT, name VARCHAR(100), is_organic BOOLEAN, category VARCHAR(50), country VARCHAR(50)); INSERT INTO products (product_id, name, is_organic, category, country) VALUES (1, 'Shampoo', true, 'Hair Care', 'France'); INSERT INTO products (product_id, name, is_organic, category, country) VALUES (2, 'Conditioner', false, 'Hair Care', 'France'); | What is the percentage of organic hair care products in France? | SELECT (COUNT(*) * 100.0 / (SELECT COUNT(*) FROM products WHERE category = 'Hair Care' AND country = 'France')) AS percentage FROM products WHERE is_organic = true AND category = 'Hair Care' AND country = 'France'; | gretelai_synthetic_text_to_sql |
CREATE TABLE citizen_feedback (citizen_id INT, feedback TEXT, feedback_date DATE); | Show the number of citizens who have provided feedback in the last 3 months | SELECT COUNT(*) FROM citizen_feedback WHERE feedback_date >= DATE_SUB(CURRENT_DATE, INTERVAL 3 MONTH); | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_protected_areas (area_name TEXT, location TEXT, country TEXT); INSERT INTO marine_protected_areas (area_name, location, country) VALUES ('Norwegian Arctic National Park', 'Arctic Ocean', 'Norway'), ('Canadian Arctic Archipelago Park', 'Arctic Ocean', 'Canada'); | How many countries have marine protected areas in the Arctic Ocean? | SELECT COUNT(DISTINCT country) FROM marine_protected_areas WHERE location = 'Arctic Ocean'; | gretelai_synthetic_text_to_sql |
CREATE TABLE products (product_id INT, product_name TEXT, supplier_id INT, manufacturer_country TEXT); INSERT INTO products (product_id, product_name, supplier_id, manufacturer_country) VALUES (1, 'Product X', 1001, 'Brazil'), (2, 'Product Y', 1002, 'Argentina'), (3, 'Product Z', 1003, 'Brazil'); | Retrieve the product names and their suppliers for all products made in 'Brazil'. | SELECT product_name, supplier_id FROM products WHERE manufacturer_country = 'Brazil'; | gretelai_synthetic_text_to_sql |
CREATE TABLE PeacekeepingOperations (id INT PRIMARY KEY, operation VARCHAR(100), location VARCHAR(50), year INT, budget INT); INSERT INTO PeacekeepingOperations (id, operation, location, year, budget) VALUES (3, 'Pacific Partnership', 'Papua New Guinea', 2018, 45678901); | What is the maximum budget for peacekeeping operations in Oceania in 2018? | SELECT MAX(budget) FROM PeacekeepingOperations WHERE location LIKE '%Oceania%' AND year = 2018; | gretelai_synthetic_text_to_sql |
CREATE TABLE Continent (id INT, name VARCHAR(255)); INSERT INTO Continent (id, name) VALUES (1, 'Africa'), (2, 'Asia'), (3, 'Europe'), (4, 'North America'), (5, 'South America'); CREATE TABLE Crop (id INT, name VARCHAR(255), continent_id INT, production INT); INSERT INTO Crop (id, name, continent_id, production) VALUES (1, 'Soybean', 2, 1000), (2, 'Rice', 3, 1500), (3, 'Soybean', 5, 800); | What is the total production of soybean crops by continent? | SELECT SUM(Crop.production) FROM Crop INNER JOIN Continent ON Crop.continent_id = Continent.id WHERE Crop.name = 'Soybean'; | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_species_avg_depths (name VARCHAR(255), basin VARCHAR(255), depth FLOAT); INSERT INTO marine_species_avg_depths (name, basin, depth) VALUES ('Species1', 'Atlantic', 123.45), ('Species2', 'Pacific', 567.89), ('Species3', 'Indian', 345.67), ('Species4', 'Atlantic', 789.10); | What is the average depth of all marine species in the Pacific basin, grouped by species name? | SELECT name, AVG(depth) as avg_depth FROM marine_species_avg_depths WHERE basin = 'Pacific' GROUP BY name; | gretelai_synthetic_text_to_sql |
CREATE TABLE samarium_production (country VARCHAR(255), price DECIMAL(10,2)); INSERT INTO samarium_production (country, price) VALUES ('China', 70.50); | What is the maximum price of samarium produced in China? | SELECT MAX(price) FROM samarium_production WHERE country = 'China'; | gretelai_synthetic_text_to_sql |
CREATE TABLE asia_artifacts (id INT, site_name VARCHAR(50), artifact_name VARCHAR(50), period VARCHAR(20), weight INT); | Minimum weight of 'ceramic' artifacts in 'asia_artifacts' | SELECT MIN(weight) FROM asia_artifacts WHERE artifact_name = 'ceramic'; | gretelai_synthetic_text_to_sql |
CREATE TABLE researchers (id INT PRIMARY KEY, name VARCHAR(100), affiliation VARCHAR(100), area_of_study VARCHAR(100)); INSERT INTO researchers (id, name, affiliation, area_of_study) VALUES (1, 'John Smith', 'Arctic Institute', 'Biodiversity'); | Update the area of study for researcher 'John Smith' to 'Climate Change'. | UPDATE researchers SET area_of_study = 'Climate Change' WHERE name = 'John Smith'; | gretelai_synthetic_text_to_sql |
CREATE TABLE security_incidents (id INT, sector VARCHAR(20), date DATE); INSERT INTO security_incidents (id, sector, date) VALUES (1, 'education', '2022-03-01'), (2, 'education', '2022-05-15'); | How many security incidents were there in the education sector in the last quarter? | SELECT COUNT(*) FROM security_incidents WHERE sector = 'education' AND date >= DATEADD(quarter, -1, GETDATE()); | gretelai_synthetic_text_to_sql |
CREATE TABLE DailyRevenue (Date date, GameID int, Revenue int); INSERT INTO DailyRevenue (Date, GameID, Revenue) VALUES ('2022-01-01', 1, 2000), ('2022-01-02', 1, 3000), ('2022-01-01', 2, 2500), ('2022-01-02', 2, 3500), ('2022-01-01', 3, 1500), ('2022-01-02', 3, 2500); | What is the maximum revenue generated in a single day for each game? | SELECT G.GameName, MAX(DR.Revenue) as MaxRevenue FROM DailyRevenue DR JOIN Games G ON DR.GameID = G.GameID GROUP BY G.GameName; | gretelai_synthetic_text_to_sql |
CREATE TABLE country_metric (id INT, country TEXT, metric FLOAT, date DATE); | Which countries had the highest sustainable fashion metrics in the past year? | SELECT country, AVG(metric) FROM country_metric WHERE date >= DATE_SUB(CURDATE(), INTERVAL 1 YEAR) GROUP BY country ORDER BY AVG(metric) DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE facility (name TEXT, state TEXT, type TEXT); | How many infectious disease reports were made by medical facilities in Texas? | SELECT COUNT(*) FROM (SELECT f.name, f.state, f.type FROM facility f JOIN report r ON f.name = r.facility_name WHERE f.state = 'Texas' AND r.disease_type = 'infectious') AS subquery; | gretelai_synthetic_text_to_sql |
CREATE TABLE Donors (donor_id INT, donor_name TEXT, donation_amount DECIMAL, donation_date DATE); | Insert a new record of a donation made by 'Bob Johnson' for $1000 on 2023-01-01. | INSERT INTO Donors (donor_id, donor_name, donation_amount, donation_date) VALUES (NULL, 'Bob Johnson', 1000, '2023-01-01'); | gretelai_synthetic_text_to_sql |
CREATE TABLE ota_hotel (ota_id INT, ota_name TEXT, region TEXT, ai_powered TEXT, hotel_listings INT); INSERT INTO ota_hotel (ota_id, ota_name, region, ai_powered, hotel_listings) VALUES (1, 'TravelEase', 'Australia', 'yes', 1000), (2, 'VoyagePlus', 'Australia', 'no', 800), (3, 'ExploreNow', 'Australia', 'yes', 1200); | Which OTAs in Australia have the highest number of hotel listings with AI-powered services? | SELECT ota_name, MAX(hotel_listings) FROM ota_hotel WHERE region = 'Australia' AND ai_powered = 'yes' GROUP BY ota_name | gretelai_synthetic_text_to_sql |
CREATE TABLE budget_2021 (service TEXT, budget INTEGER); INSERT INTO budget_2021 (service, budget) VALUES ('Police', 1000000), ('Transportation', 800000); | Find the difference in budget allocation between police and transportation from 2021 to 2022. | SELECT (COALESCE(SUM(budget_2022.budget), 0) - COALESCE(SUM(budget_2021.budget), 0)) FROM budget_2022 FULL OUTER JOIN budget_2021 ON budget_2022.service = budget_2021.service WHERE service IN ('Police', 'Transportation'); | gretelai_synthetic_text_to_sql |
CREATE TABLE offenders (id INT, first_name VARCHAR(20), last_name VARCHAR(20), offense VARCHAR(20), state VARCHAR(20)); INSERT INTO offenders (id, first_name, last_name, offense, state) VALUES (1, 'John', 'Doe', 'theft', 'NY'); INSERT INTO offenders (id, first_name, last_name, offense, state) VALUES (2, 'Jane', 'Doe', 'murder', 'CA'); INSERT INTO offenders (id, first_name, last_name, offense, state) VALUES (3, 'Bob', 'Smith', 'burglary', 'TX'); | Update the "offenders" table to change the offense from "burglary" to "robbery" for the offender with id 3 | UPDATE offenders SET offense = 'robbery' WHERE id = 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE Events (EventID INT, Name TEXT, Attendance INT);CREATE TABLE EventLocations (EventID INT, Country TEXT); | What is the average attendance at events in Canada and the United States? | SELECT AVG(Events.Attendance) FROM Events INNER JOIN EventLocations ON Events.EventID = EventLocations.EventID WHERE EventLocations.Country IN ('Canada', 'United States'); | gretelai_synthetic_text_to_sql |
CREATE TABLE autonomous_vehicles (id INT PRIMARY KEY, city VARCHAR(255), type VARCHAR(255), num_vehicles INT); | Create a view to show the total number of autonomous vehicles in each city | CREATE VIEW autonomous_vehicles_by_city AS SELECT city, SUM(num_vehicles) as total_autonomous_vehicles FROM autonomous_vehicles WHERE type = 'Autonomous' GROUP BY city; | gretelai_synthetic_text_to_sql |
CREATE TABLE tech_accessibility_assessments (id INT, assessment_date DATE); INSERT INTO tech_accessibility_assessments (id, assessment_date) VALUES (1, '2021-04-15'), (2, '2021-06-30'), (3, '2021-02-28'); | How many technology accessibility assessments were conducted in Q2 2021? | SELECT COUNT(*) FROM tech_accessibility_assessments WHERE assessment_date BETWEEN '2021-04-01' AND '2021-06-30'; | gretelai_synthetic_text_to_sql |
CREATE TABLE SecurityIncidents (id INT, incident_name VARCHAR(255), country VARCHAR(255), date DATE); INSERT INTO SecurityIncidents (id, incident_name, country, date) VALUES (2, 'Ransomware Attack', 'India', '2022-04-15'); | How many security incidents were there in Q2 2022 that originated from India? | SELECT COUNT(*) FROM SecurityIncidents WHERE country = 'India' AND date >= '2022-04-01' AND date < '2022-07-01'; | gretelai_synthetic_text_to_sql |
CREATE TABLE MiningOperations (OperationID INT, MineName VARCHAR(50), Location VARCHAR(50), WaterUsage INT); INSERT INTO MiningOperations (OperationID, MineName, Location, WaterUsage) VALUES (1, 'Ruby Mine', 'India', 3000), (2, 'Sapphire Mine', 'Thailand', 4000), (3, 'Emerald Mine', 'China', 5000); | What is the minimum water usage for mining operations in Asia? | SELECT MIN(WaterUsage) FROM MiningOperations WHERE Location LIKE 'Asia%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE companies (id INT, sector TEXT, ESG_rating FLOAT); INSERT INTO companies (id, sector, ESG_rating) VALUES (1, 'technology', 78.2), (2, 'finance', 82.5), (3, 'technology', 64.6); | Delete companies with ESG rating below 70. | DELETE FROM companies WHERE ESG_rating < 70; | gretelai_synthetic_text_to_sql |
CREATE TABLE concerts (id INT, artist VARCHAR(50), genre VARCHAR(50), tickets_sold INT, revenue DECIMAL(10,2)); INSERT INTO concerts (id, artist, genre, tickets_sold, revenue) VALUES (1, 'Taylor Swift', 'Pop', 15000, 2500000); INSERT INTO concerts (id, artist, genre, tickets_sold, revenue) VALUES (2, 'BTS', 'K-Pop', 20000, 3000000); INSERT INTO concerts (id, artist, genre, tickets_sold, revenue) VALUES (3, 'Metallica', 'Rock', 12000, 1800000); INSERT INTO concerts (id, artist, genre, tickets_sold, revenue) VALUES (4, 'Adele', 'Pop', 18000, 2700000); | What are the top 3 genres by average revenue from concert ticket sales? | SELECT genre, AVG(revenue) as avg_revenue FROM concerts GROUP BY genre ORDER BY avg_revenue DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE ocean_floor_mapping_projects (id INT PRIMARY KEY, project_name VARCHAR(255), start_date DATE, end_date DATE, budget FLOAT); | Delete ocean floor mapping projects that were completed before 2010 | DELETE FROM ocean_floor_mapping_projects WHERE end_date < '2010-01-01'; | gretelai_synthetic_text_to_sql |
CREATE TABLE HeritageSites (id INT, name VARCHAR(255), country VARCHAR(255), UNIQUE (id)); CREATE TABLE Events (id INT, name VARCHAR(255), heritage_site_id INT, year INT, UNIQUE (id), FOREIGN KEY (heritage_site_id) REFERENCES HeritageSites(id)); CREATE TABLE VisitorStatistics (id INT, heritage_site_id INT, year INT, visitor_count INT, PRIMARY KEY (id), FOREIGN KEY (heritage_site_id) REFERENCES HeritageSites(id)); | Identify heritage sites in India with an average visitor count greater than 150 and at least 3 associated events in the last 2 years. | SELECT hs.name FROM HeritageSites hs JOIN Events e ON hs.id = e.heritage_site_id JOIN VisitorStatistics vs ON hs.id = vs.heritage_site_id WHERE hs.country = 'India' GROUP BY hs.name HAVING COUNT(DISTINCT e.id) >= 3 AND AVG(vs.visitor_count) > 150 AND e.year BETWEEN 2020 AND 2022; | gretelai_synthetic_text_to_sql |
CREATE TABLE fares (ride_type TEXT, fare DECIMAL(5,2)); CREATE TABLE light_rail_fares AS SELECT * FROM fares WHERE ride_type = 'Light Rail'; | Update the fare for 'Light Rail' rides | UPDATE light_rail_fares SET fare = 2.00 WHERE ride_type = 'Light Rail'; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA if not exists county; CREATE TABLE if not exists county.emergency_responses (id INT, response_time TIME, call_date DATE); INSERT INTO county.emergency_responses (id, response_time, call_date) VALUES (1, '01:34:00', '2022-04-25'), (2, '02:15:00', '2022-06-12'), (3, '01:52:00', '2022-07-03'); | What is the average response time for emergency calls in the 'county' schema in Q2 2022? | SELECT AVG(TIME_TO_SEC(response_time)) FROM county.emergency_responses WHERE QUARTER(call_date) = 2 AND YEAR(call_date) = 2022; | gretelai_synthetic_text_to_sql |
CREATE TABLE eu_military_spending (id INT, country VARCHAR(255), year INT, spending FLOAT); INSERT INTO eu_military_spending (id, country, year, spending) VALUES (1, 'Germany', 2020, 55.0), (2, 'France', 2020, 50.0), (3, 'United Kingdom', 2020, 52.0), (4, 'Italy', 2020, 47.0), (5, 'Spain', 2020, 43.0); | What was the minimum military spending by a country in the European Union in 2020? | SELECT MIN(spending) FROM eu_military_spending WHERE year = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE vulnerabilities (id INT, reported_date DATE, num_vulnerabilities INT); INSERT INTO vulnerabilities (id, reported_date, num_vulnerabilities) VALUES (1, '2021-10-01', 5); INSERT INTO vulnerabilities (id, reported_date, num_vulnerabilities) VALUES (2, '2021-10-03', 7); INSERT INTO vulnerabilities (id, reported_date, num_vulnerabilities) VALUES (3, '2021-11-05', 3); | What is the maximum number of vulnerabilities reported per day in the last month? | SELECT reported_date, num_vulnerabilities FROM vulnerabilities WHERE reported_date >= DATE_SUB(CURDATE(), INTERVAL 1 MONTH) AND num_vulnerabilities = (SELECT MAX(num_vulnerabilities) FROM vulnerabilities WHERE reported_date >= DATE_SUB(CURDATE(), INTERVAL 1 MONTH)); | gretelai_synthetic_text_to_sql |
CREATE TABLE startups (id INT, name TEXT, location TEXT, founder_gender TEXT, funding_amount INT); INSERT INTO startups (id, name, location, founder_gender, funding_amount) VALUES (1, 'Startup A', 'USA', 'male', 3000000); INSERT INTO startups (id, name, location, founder_gender, funding_amount) VALUES (2, 'Startup B', 'Canada', 'female', NULL); | Delete startups that have no funding records. | DELETE FROM startups WHERE funding_amount IS NULL; | gretelai_synthetic_text_to_sql |
CREATE TABLE research_stations (name TEXT, location TEXT); INSERT INTO research_stations (name, location) VALUES ('Norilsk Research Station', 'Arctic Circle'), ('Abisko Research Station', 'Arctic Circle'); | What is the number of research stations in the Arctic Circle? | SELECT COUNT(*) FROM research_stations WHERE location = 'Arctic Circle'; | gretelai_synthetic_text_to_sql |
CREATE TABLE bike_stations (station_id INT PRIMARY KEY, station_name TEXT, location TEXT); | Add a new 'Bike Share' station in 'Central Park' | INSERT INTO bike_stations (station_id, station_name, location) VALUES (1, 'Bike Share', 'Central Park'); | gretelai_synthetic_text_to_sql |
CREATE TABLE wells (well_id INT, well_type VARCHAR(10), location VARCHAR(20), production_rate FLOAT); INSERT INTO wells (well_id, well_type, location, production_rate) VALUES (1, 'offshore', 'Gulf of Mexico', 1000), (2, 'onshore', 'Texas', 800), (3, 'offshore', 'North Sea', 1200); | Update the production rate for well_id 1 to 1100. | UPDATE wells SET production_rate = 1100 WHERE well_id = 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE properties (id INT, city VARCHAR(255)); INSERT INTO properties (id, city) VALUES (1, 'San Francisco'), (2, 'Los Angeles'), (3, 'San Diego'), (4, 'San Jose'), (5, 'San Francisco'); | What is the total number of properties in each city in the state of California? | SELECT city, COUNT(*) FROM properties GROUP BY city; | gretelai_synthetic_text_to_sql |
CREATE TABLE trip (trip_id INT, vehicle_id INT, route_id INT, fare FLOAT); INSERT INTO trip (trip_id, vehicle_id, route_id, fare) VALUES (1, 1, 1, 3.5), (2, 1, 2, 4.0), (3, 2, 1, 3.5), (4, 2, 2, 4.0), (5, 3, 1, 2.5), (6, 3, 2, 3.0); CREATE TABLE vehicle (vehicle_id INT, type TEXT); INSERT INTO vehicle (vehicle_id, type) VALUES (1, 'Bus'), (2, 'Tram'), (3, 'Trolleybus'); | What was the average fare per trip for each vehicle type in the first quarter of 2022? | SELECT vehicle.type, AVG(trip.fare) as avg_fare FROM trip JOIN vehicle ON trip.vehicle_id = vehicle.vehicle_id WHERE trip.trip_id BETWEEN 1 AND (SELECT MAX(trip_id) FROM trip WHERE trip.trip_date < '2022-04-01' AND EXTRACT(MONTH FROM trip.trip_date) < 4) GROUP BY vehicle.type; | gretelai_synthetic_text_to_sql |
CREATE TABLE ethical_manufacturing (id INT PRIMARY KEY, company VARCHAR(50), location VARCHAR(50), ethical_rating FLOAT); WITH ins AS (VALUES (1, 'GreenTech', 'USA', 4.2), (2, 'EcoInnovations', 'Canada', 4.6)) INSERT INTO ethical_manufacturing (id, company, location, ethical_rating) SELECT * FROM ins; | Insert new records into 'ethical_manufacturing' | WITH ins AS (VALUES (1, 'GreenTech', 'USA', 4.2), (2, 'EcoInnovations', 'Canada', 4.6)) INSERT INTO ethical_manufacturing (id, company, location, ethical_rating) SELECT * FROM ins; | gretelai_synthetic_text_to_sql |
CREATE TABLE case_hearings (hearing_id INT, case_id INT, state VARCHAR(20), year INT); INSERT INTO case_hearings (hearing_id, case_id, state, year) VALUES (1, 1, 'New York', 2021), (2, 1, 'New York', 2021), (3, 2, 'New York', 2022); | What is the minimum number of hearings for a case in the state of New York in the year 2021? | SELECT MIN(count) FROM (SELECT case_id, COUNT(*) as count FROM case_hearings WHERE state = 'New York' AND year = 2021 GROUP BY case_id) as subquery; | gretelai_synthetic_text_to_sql |
CREATE TABLE tokyo_ev_trips (vehicle_id INT, trips INT, type VARCHAR(20)); CREATE TABLE seoul_ev_trips (vehicle_id INT, trips INT, type VARCHAR(20)); INSERT INTO tokyo_ev_trips (vehicle_id, trips, type) VALUES (1, 10, 'Bus'), (2, 20, 'Car'), (3, 30, 'Taxi'); INSERT INTO seoul_ev_trips (vehicle_id, trips, type) VALUES (4, 40, 'Bus'), (5, 50, 'Car'), (6, 60, 'Taxi'); | Get the total number of trips made by electric buses and autonomous taxis in Tokyo and Seoul. | SELECT SUM(trips) FROM tokyo_ev_trips WHERE type IN ('Bus', 'Taxi') UNION ALL SELECT SUM(trips) FROM seoul_ev_trips WHERE type IN ('Bus', 'Taxi'); | gretelai_synthetic_text_to_sql |
CREATE TABLE Donors (id INT, name TEXT, country TEXT, donation_amount DECIMAL(10, 2), donation_date DATE); INSERT INTO Donors (id, name, country, donation_amount, donation_date) VALUES (1, 'John Doe', 'India', 100.00, '2021-01-01'); INSERT INTO Donors (id, name, country, donation_amount, donation_date) VALUES (2, 'Jane Smith', 'India', 200.00, '2021-04-15'); INSERT INTO Donors (id, name, country, donation_amount, donation_date) VALUES (3, 'Alice Johnson', 'Australia', 500.00, '2021-05-05'); INSERT INTO Donors (id, name, country, donation_amount, donation_date) VALUES (4, 'Bob Brown', 'India', 300.00, '2021-07-10'); | Update the donation amount to 150.00 for donor 'Alice Johnson' from Australia. | UPDATE Donors SET donation_amount = 150.00 WHERE name = 'Alice Johnson' AND country = 'Australia'; | gretelai_synthetic_text_to_sql |
CREATE TABLE regulatory_compliance (compliance_id INT, regulation_name VARCHAR(50), compliance_status VARCHAR(50), compliance_date DATE); | Update the compliance status for a record in the regulatory_compliance table | UPDATE regulatory_compliance SET compliance_status = 'Non-Compliant' WHERE compliance_id = 22222; | gretelai_synthetic_text_to_sql |
CREATE TABLE DonorPrograms (DonorID INT, ProgramID INT); INSERT INTO DonorPrograms (DonorID, ProgramID) VALUES (1, 101), (1, 102), (2, 102), (3, 103), (3, 104); CREATE TABLE ProgramCategories (CategoryID INT, Category TEXT); INSERT INTO ProgramCategories (CategoryID, Category) VALUES (1, 'Education'), (2, 'Health'), (3, 'Environment'), (4, 'Other'); CREATE TABLE Programs (ProgramID INT, CategoryID INT); INSERT INTO Programs (ProgramID, CategoryID) VALUES (101, 1), (102, 2), (103, 3), (104, 4); | Delete all records from the DonorPrograms table where the program ID is not in the Education or Health categories. | DELETE DP FROM DonorPrograms DP WHERE DP.ProgramID NOT IN (SELECT P.ProgramID FROM Programs P INNER JOIN ProgramCategories PC ON P.CategoryID = PC.CategoryID WHERE PC.Category IN ('Education', 'Health')); | gretelai_synthetic_text_to_sql |
CREATE TABLE MiningOperations (OperationID INT, EquipmentAge INT); | What are the mining operations with the oldest equipment? | SELECT OperationID FROM MiningOperations WHERE ROW_NUMBER() OVER(ORDER BY EquipmentAge DESC) <= 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE region (region_id INT, name VARCHAR(50)); INSERT INTO region (region_id, name) VALUES (1, 'Asia'), (2, 'South America'); CREATE TABLE activity (activity_id INT, name VARCHAR(50)); INSERT INTO activity (activity_id, name) VALUES (1, 'Disaster response'), (2, 'Community development'), (3, 'Refugee support'); CREATE TABLE volunteers (volunteer_id INT, name VARCHAR(50), region_id INT, activity_id INT); INSERT INTO volunteers (volunteer_id, name, region_id, activity_id) VALUES (1, 'Volunteer A', 1, 1), (2, 'Volunteer B', 1, 1), (3, 'Volunteer C', 2, 1), (4, 'Volunteer D', 2, 2); | What is the total number of volunteers who participated in 'disaster response' activities in 'Asia'? | SELECT COUNT(*) FROM volunteers WHERE region_id = 1 AND activity_id = 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE if not exists sales (id INT PRIMARY KEY, product_id INT, purchase_date DATE, quantity INT, price DECIMAL(5,2)); INSERT INTO sales (id, product_id, purchase_date, quantity, price) VALUES (4, 3, '2022-03-01', 1, 9.99); CREATE TABLE if not exists product (id INT PRIMARY KEY, name TEXT, brand_id INT, is_organic BOOLEAN, price DECIMAL(5,2)); INSERT INTO product (id, name, brand_id, is_organic, price) VALUES (3, 'Organic Moisturizer', 2, true, 9.99); CREATE TABLE if not exists brand (id INT PRIMARY KEY, name TEXT, category TEXT, country TEXT); INSERT INTO brand (id, name, category, country) VALUES (2, 'Ecco Verde', 'Cosmetics', 'Austria'); | What are the total sales for organic products? | SELECT SUM(quantity * price) FROM sales JOIN product ON sales.product_id = product.id WHERE product.is_organic = true; | 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.