context stringlengths 11 9.12k | question stringlengths 0 1.06k | SQL stringlengths 2 4.44k | source stringclasses 28
values |
|---|---|---|---|
CREATE TABLE user_revenue (product_category VARCHAR(20), user_id INT, revenue INT); INSERT INTO user_revenue (product_category, user_id, revenue) VALUES ('Electronics', 1, 50), ('Electronics', 2, 100), ('Fashion', 3, 20), ('Fashion', 4, 70), ('Home Appliances', 5, 150), ('Home Appliances', 6, 250); | What is the average revenue per user for each product category? | SELECT product_category, AVG(revenue / NULLIF(COUNT(DISTINCT user_id), 0)) AS avg_revenue_per_user FROM user_revenue GROUP BY product_category; | gretelai_synthetic_text_to_sql |
CREATE TABLE menus (menu_id INT, menu_name VARCHAR(50), menu_type VARCHAR(20), price DECIMAL(5,2), sustainable_ingredients DECIMAL(5,2)); INSERT INTO menus (menu_id, menu_name, menu_type, price, sustainable_ingredients) VALUES (1, 'Quinoa Salad', 'Vegetarian', 9.99, 0.3), (2, 'Margherita Pizza', 'Non-vegetarian', 12.99... | What is the total weight of sustainable ingredients used in menu items? | SELECT SUM(sustainable_ingredients) FROM menus; | gretelai_synthetic_text_to_sql |
CREATE TABLE factories (factory_id INT, country VARCHAR(50), circular_economy VARCHAR(50)); CREATE TABLE workers (worker_id INT, factory_id INT, salary DECIMAL(10,2), position VARCHAR(50)); INSERT INTO factories (factory_id, country, circular_economy) VALUES (1, 'Brazil', 'yes'), (2, 'Argentina', 'yes'), (3, 'Brazil', ... | What is the minimum and maximum salary of workers in factories that have implemented circular economy principles in Brazil and Argentina? | SELECT MIN(workers.salary), MAX(workers.salary) FROM workers INNER JOIN factories ON workers.factory_id = factories.factory_id WHERE factories.country IN ('Brazil', 'Argentina') AND factories.circular_economy = 'yes'; | gretelai_synthetic_text_to_sql |
CREATE TABLE CommunityHealthWorkers (WorkerID INT, Age INT, Gender VARCHAR(25), State VARCHAR(25)); INSERT INTO CommunityHealthWorkers (WorkerID, Age, Gender, State) VALUES (1, 45, 'Male', 'California'), (2, 35, 'Female', 'New York'), (3, 50, 'Non-binary', 'Texas'), (4, 30, 'Transgender', 'Florida'); | What is the number of community health workers by gender in each state? | SELECT State, Gender, COUNT(*) as WorkerCount FROM CommunityHealthWorkers GROUP BY State, Gender; | gretelai_synthetic_text_to_sql |
CREATE TABLE ai_ethics (developer VARCHAR(255), principle VARCHAR(255), country VARCHAR(255)); INSERT INTO ai_ethics (developer, principle, country) VALUES ('Microsoft', 'Fairness', 'USA'), ('Google', 'Accountability', 'USA'), ('AliceLab', 'Transparency', 'Canada'); | Show all AI principles for companies based in the United States | SELECT principle FROM ai_ethics WHERE country = 'USA'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Artists (ArtistID INT PRIMARY KEY, Name VARCHAR(100), Nationality VARCHAR(50)); INSERT INTO Artists (ArtistID, Name, Nationality) VALUES (1, 'Ben Enwonwu', 'Nigerian'); INSERT INTO Artists (ArtistID, Name, Nationality) VALUES (2, 'Lygia Clark', 'Brazilian'); CREATE TABLE ArtWorks (ArtWorkID INT PRIMARY KEY... | List artworks by artists from Nigeria or Brazil, excluding those created before 1970. | SELECT ArtWorks.Title FROM ArtWorks INNER JOIN Artists ON ArtWorks.ArtistID = Artists.ArtistID WHERE Artists.Nationality IN ('Nigerian', 'Brazilian') AND ArtWorks.YearCreated > 1970; | gretelai_synthetic_text_to_sql |
CREATE TABLE SatellitesByCountry (Country VARCHAR(50), Continent VARCHAR(50), Satellites INT); INSERT INTO SatellitesByCountry (Country, Continent, Satellites) VALUES ('USA', 'North America', 1417), ('Russia', 'Europe', 1250), ('China', 'Asia', 413), ('India', 'Asia', 127), ('Germany', 'Europe', 77), ('Brazil', 'South ... | Find the total number of satellites in orbit for each continent. | SELECT Continent, SUM(Satellites) FROM SatellitesByCountry GROUP BY Continent; | gretelai_synthetic_text_to_sql |
CREATE TABLE Community_Development_NA (id INT, location VARCHAR(50), year INT, quarter INT, sector VARCHAR(50), completed BOOLEAN); | How many 'Community Development' projects were completed in 'North America' in each quarter of 2022? | SELECT year, quarter, SUM(completed) as total_completed FROM Community_Development_NA WHERE location = 'North America' AND sector = 'Community Development' GROUP BY year, quarter; | gretelai_synthetic_text_to_sql |
CREATE TABLE Farmers (id INT PRIMARY KEY, name VARCHAR(100), age INT, location VARCHAR(100)); INSERT INTO Farmers (id, name, age, location) VALUES (1, 'Yamada Taro', 50, 'Japan'); INSERT INTO Farmers (id, name, age, location) VALUES (2, 'Kimura Hanako', 45, 'Japan'); CREATE TABLE Plots (id INT PRIMARY KEY, farmer_id IN... | What are the names and crops of farmers who grow crops in Japan? | SELECT f.name, p.crop FROM Farmers f INNER JOIN Plots p ON f.id = p.farmer_id INNER JOIN Crops c ON p.crop = c.name WHERE f.location = 'Japan'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Manufacturers (id INT, name VARCHAR(50)); INSERT INTO Manufacturers (id, name) VALUES (1, 'Boeing'), (2, 'Lockheed Martin'); CREATE TABLE Aircrafts (id INT, manufacturer_id INT, model VARCHAR(50), type VARCHAR(50)); INSERT INTO Aircrafts (id, manufacturer_id, model, type) VALUES (1, 1, 'F-15 Eagle', 'Fight... | Find the total number of military aircraft by manufacturer | SELECT m.name, COUNT(a.id) as total FROM Manufacturers m JOIN Aircrafts a ON m.id = a.manufacturer_id WHERE a.type = 'Fighter' GROUP BY m.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE Collaboration (CollaborationID INT, CollaborationName VARCHAR(50), CollaborationType VARCHAR(50), ArchaeologistID1 INT, ArchaeologistID2 INT); INSERT INTO Collaboration (CollaborationID, CollaborationName, CollaborationType, ArchaeologistID1, ArchaeologistID2) VALUES (1, 'Atlantis Expedition', 'Fieldwork',... | What is the total number of fieldwork collaborations between archaeologists? | SELECT COUNT(*) FROM Collaboration WHERE CollaborationType = 'Fieldwork' | gretelai_synthetic_text_to_sql |
CREATE TABLE climate_data (id INT, month INT, temperature DECIMAL(3,1)); | What is the minimum temperature in the 'climate_data' table for each month? | SELECT month, MIN(temperature) FROM climate_data GROUP BY month; | gretelai_synthetic_text_to_sql |
CREATE TABLE accidents (id INT, site_name VARCHAR(50), date DATE, accident_type VARCHAR(50)); INSERT INTO accidents (id, site_name, date, accident_type) VALUES (1, 'Site X', '2018-03-15', 'Explosion'); | What is the number of mining accidents caused by 'fires' in the 'South America' region, in the last 5 years? | SELECT COUNT(*) AS accidents_count FROM accidents WHERE site_name LIKE 'South America' AND accident_type = 'Fire' AND date >= DATE_SUB(CURDATE(), INTERVAL 5 YEAR); | gretelai_synthetic_text_to_sql |
CREATE TABLE public.physicians (id SERIAL PRIMARY KEY, name TEXT); INSERT INTO public.physicians (name) VALUES ('Dr. Smith'), ('Dr. Johnson'); CREATE TABLE public.patient_visits (id SERIAL PRIMARY KEY, physician TEXT, visit_date DATE); INSERT INTO public.patient_visits (physician, visit_date) VALUES ('Dr. Smith', '2022... | What is the difference in the number of patients seen by each primary care physician in the state of New York? | SELECT physician, COUNT(*) FILTER (WHERE visit_date < '2022-02-01') - COUNT(*) FILTER (WHERE visit_date >= '2022-02-01') FROM public.patient_visits GROUP BY physician; | gretelai_synthetic_text_to_sql |
CREATE TABLE tangible_heritage (id INT, name VARCHAR(255), region VARCHAR(255)); INSERT INTO tangible_heritage (id, name, region) VALUES (1, 'Brimstone Hill Fortress National Park', 'Caribbean'); CREATE TABLE intangible_heritage (id INT, name VARCHAR(255), region VARCHAR(255)); INSERT INTO intangible_heritage (id, name... | What is the total number of heritage sites (tangible and intangible) in the Caribbean region? | SELECT COUNT(*) FROM (SELECT 'tangible' as type, t.name FROM tangible_heritage t WHERE t.region = 'Caribbean' UNION ALL SELECT 'intangible' as type, i.name FROM intangible_heritage i WHERE i.region = 'Caribbean') AS h; | gretelai_synthetic_text_to_sql |
CREATE TABLE Community_Engagement_Scores (community_name VARCHAR(100), quarter INT, year INT, score INT); | Which underrepresented community had the highest community engagement score in Q3 2020? | SELECT community_name, MAX(score) FROM Community_Engagement_Scores WHERE quarter = 3 AND year = 2020 AND community_name IN ('African American', 'Hispanic', 'Indigenous', 'Asian', 'LGBTQ+') GROUP BY community_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE news_data (id INT, country VARCHAR(50), date DATE, disinformation_detected BOOLEAN); INSERT INTO news_data (id, country, date, disinformation_detected) VALUES (1, 'France', '2022-01-01', true), (2, 'Germany', '2022-02-01', false); | Delete all records related to disinformation detection in Europe. | DELETE FROM news_data WHERE disinformation_detected = true AND country LIKE 'Europe%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE donations (id INT, user_id INT, donation_date DATE, donation_amount DECIMAL); | Update the donation amounts of donations that have been increased by 10% in the last month in the donations table | UPDATE donations SET donation_amount = donation_amount * 1.1 WHERE donation_date > DATE_SUB(CURDATE(), INTERVAL 1 MONTH); | gretelai_synthetic_text_to_sql |
CREATE TABLE esg_investments (id INT, country VARCHAR(255), amount FLOAT, esg_score FLOAT); INSERT INTO esg_investments (id, country, amount, esg_score) VALUES (1, 'India', 3000000, 80), (2, 'India', 4000000, 85); | What is the average ESG score of investments in India? | SELECT AVG(esg_score) FROM esg_investments WHERE country = 'India'; | gretelai_synthetic_text_to_sql |
CREATE TABLE investments (id INT, sector VARCHAR(20), amount FLOAT); INSERT INTO investments (id, sector, amount) VALUES (1, 'Education', 150000.00), (2, 'Healthcare', 120000.00); | What's the total investment in the Education sector? | SELECT SUM(amount) FROM investments WHERE sector = 'Education'; | gretelai_synthetic_text_to_sql |
CREATE TABLE state_budget (state VARCHAR(20), service VARCHAR(20), allocation INT); INSERT INTO state_budget (state, service, allocation) VALUES ('StateA', 'Healthcare', 1500000), ('StateA', 'Education', 2000000), ('StateB', 'Healthcare', 1000000), ('StateB', 'Education', 1200000), ('StateC', 'Healthcare', 1750000), ('... | List the services that received budget allocations in all states. | SELECT service FROM state_budget GROUP BY service HAVING COUNT(DISTINCT state) = (SELECT COUNT(DISTINCT state) FROM state_budget); | gretelai_synthetic_text_to_sql |
CREATE TABLE user_posts (user_id INT, post_country VARCHAR(50)); INSERT INTO user_posts (user_id, post_country) VALUES (1, 'Mexico'); INSERT INTO user_posts (user_id, post_country) VALUES (2, 'Mexico'); INSERT INTO user_posts (user_id, post_country) VALUES (3, 'USA'); CREATE TABLE users (id INT, name VARCHAR(50), post_... | What is the average number of posts per user in 'Mexico'? | SELECT AVG(posts_per_user) FROM (SELECT COUNT(*)/COUNT(DISTINCT user_id) as posts_per_user FROM user_posts INNER JOIN users ON user_posts.user_id = users.id WHERE post_country = 'Mexico' GROUP BY post_country) as avg_posts; | gretelai_synthetic_text_to_sql |
CREATE TABLE DEX (transaction_date DATE, digital_asset VARCHAR(20), transaction_volume DECIMAL(10, 2)); INSERT INTO DEX (transaction_date, digital_asset, transaction_volume) VALUES ('2022-01-01', 'ETH', 5000.00), ('2022-01-01', 'BTC', 3000.00), ('2022-01-02', 'ETH', 6000.00), ('2022-01-02', 'BTC', 2000.00), ('2022-01-0... | Calculate the 7-day moving average of the transaction volume for each digital asset in the 'DEX' trading platform, ordered by date and moving average in descending order. | SELECT transaction_date, digital_asset, AVG(transaction_volume) OVER (PARTITION BY digital_asset ORDER BY transaction_date ROWS BETWEEN 6 PRECEDING AND CURRENT ROW) as moving_avg FROM DEX ORDER BY transaction_date, moving_avg DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE programs (program_id INT, program_name TEXT, budget INT); INSERT INTO programs (program_id, program_name, budget) VALUES (1, 'Youth Mentoring', 25000), (2, 'Food Security', 30000), (3, 'Elder Care', 40000), (4, 'Arts Education', 15000), (5, 'After School Program', 20000), (6, 'Environmental Education', 0); | Update the budget of the "Healthcare Access" program to $50,000? | UPDATE programs SET budget = 50000 WHERE program_name = 'Healthcare Access'; | gretelai_synthetic_text_to_sql |
CREATE TABLE sustainable_sourcing (restaurant_id INT, rating INT, sourcing_date DATE); | Insert a new sustainable sourcing record for 'ABC Cafe' with a rating of 4 and a date of '2022-02-01' if it does not exist already. | INSERT INTO sustainable_sourcing (restaurant_id, rating, sourcing_date) SELECT 1, 4, '2022-02-01' FROM (SELECT 1 FROM sustainable_sourcing WHERE restaurant_id = 1 AND sourcing_date = '2022-02-01') AS dummy WHERE NOT EXISTS (SELECT 1 FROM sustainable_sourcing WHERE restaurant_id = 1 AND sourcing_date = '2022-02-01'); | gretelai_synthetic_text_to_sql |
CREATE TABLE Companies (id INT, name VARCHAR(255)); INSERT INTO Companies (id, name) VALUES (1, 'CompanyA'), (2, 'CompanyB'), (3, 'CompanyC'); CREATE TABLE Campaigns (id INT, company_id INT, name VARCHAR(255), start_date DATE); INSERT INTO Campaigns (id, company_id, name, start_date) VALUES (1, 1, 'Eco-friendly initiat... | List all companies with consumer awareness campaigns and their respective start dates. | SELECT Companies.name, Campaigns.start_date FROM Companies JOIN Campaigns ON Companies.id = Campaigns.company_id WHERE Campaigns.name LIKE '%awareness%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE public_participation_events (id INT, state VARCHAR(20), sector VARCHAR(20), year INT); INSERT INTO public_participation_events (id, state, sector, year) VALUES (1, 'California', 'transportation', 2020), (2, 'Texas', 'transportation', 2019), (3, 'New York', 'transportation', 2020), (4, 'Florida', 'transport... | Which states have the most and least number of public participation events in the transportation sector? | SELECT state, MIN(id) AS least, MAX(id) AS most FROM public_participation_events WHERE sector = 'transportation' GROUP BY state; | gretelai_synthetic_text_to_sql |
CREATE TABLE wells (id INT, location VARCHAR(20), depth FLOAT); INSERT INTO wells (id, location, depth) VALUES (1, 'Arctic', 4000.0); INSERT INTO wells (id, location, depth) VALUES (2, 'Arctic', 3800.2); INSERT INTO wells (id, location, depth) VALUES (3, 'North Sea', 3500.5); | What is the minimum depth of wells drilled in the Arctic? | SELECT MIN(depth) FROM wells WHERE location = 'Arctic'; | gretelai_synthetic_text_to_sql |
CREATE TABLE ocean_floor_mapping_projects (project_name TEXT, budget FLOAT); INSERT INTO ocean_floor_mapping_projects (project_name, budget) VALUES ('Atlantic Deep Sea Exploration', 30000000.0), ('Pacific Ocean Mapping Project', 20000000.0), ('Arctic Sea Floor Survey', 15000000.0); | How many ocean floor mapping projects have a budget over 20 million? | SELECT COUNT(*) FROM ocean_floor_mapping_projects WHERE budget > 20000000.0; | 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, material TEXT, destination TEXT, date DATE); INSERT INTO vessels (id, name, type, compliance_score) VALUES (3, 'VesselL', 'Tanker', 88); INSERT INTO cargos (id, vessel_id, material, destination, date) V... | What is the minimum compliance score of vessels that transported dangerous goods to the Arctic Ocean in H1 2022? | SELECT MIN(v.compliance_score) FROM vessels v JOIN cargos c ON v.id = c.vessel_id WHERE c.material = 'Dangerous' AND c.destination = 'Arctic' AND c.date BETWEEN '2022-01-01' AND '2022-06-30'; | gretelai_synthetic_text_to_sql |
CREATE TABLE space_missions (id INT, space_agency VARCHAR(50), duration INT); INSERT INTO space_missions (id, space_agency, duration) VALUES (101, 'NASA', 500); | What is the total duration of all space missions launched by NASA? | SELECT SUM(duration) FROM space_missions WHERE space_agency = 'NASA'; | gretelai_synthetic_text_to_sql |
CREATE TABLE customers (customer_id INT, transaction_date DATE, transaction_value FLOAT); INSERT INTO customers VALUES (1, '2021-01-01', 100.0), (1, '2021-02-01', 200.0), (2, '2021-03-01', 150.0); | Which customer has the highest transaction value in the last month? | SELECT customer_id, MAX(transaction_value) OVER (ORDER BY transaction_date DESC ROWS BETWEEN 29 PRECEDING AND CURRENT ROW) AS max_transaction_value FROM customers WHERE transaction_date >= DATEADD(month, -1, CURRENT_DATE); | gretelai_synthetic_text_to_sql |
CREATE TABLE Military_Technologies (Name VARCHAR(255), Operation VARCHAR(255), Max_Personnel INT); INSERT INTO Military_Technologies (Name, Operation, Max_Personnel) VALUES ('M1 Abrams', 'Operation Desert Storm', 4), ('AH-64 Apache', 'Operation Desert Storm', 2), ('M2 Bradley', 'Operation Desert Storm', 3); | What are the names of the military technologies that were used in Operation Desert Storm and have a maximum personnel of more than 2? | SELECT Name FROM Military_Technologies WHERE Operation = 'Operation Desert Storm' AND Max_Personnel > 2; | gretelai_synthetic_text_to_sql |
CREATE TABLE teams (team_id INT, team_name VARCHAR(100)); CREATE TABLE games (game_id INT, home_team INT, away_team INT); | What is the total number of games played by each team in the NHL? | SELECT teams.team_name, COUNT(games.game_id) as total_games FROM teams INNER JOIN games ON teams.team_id IN (games.home_team, games.away_team) GROUP BY teams.team_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE coal_mines (id INT, region TEXT, assessment_year INT, assessment_result TEXT); INSERT INTO coal_mines (id, region, assessment_year, assessment_result) VALUES (1, 'Appalachia', 2015, 'Passed'), (2, 'Appalachia', 2016, 'Failed'), (3, 'Appalachia', 2017, 'Passed'), (4, 'Powder River Basin', 2018, 'Passed'), (... | How many environmental impact assessments were conducted for coal mines in the region 'Appalachia' between 2015 and 2019? | SELECT COUNT(*) FROM coal_mines WHERE region = 'Appalachia' AND assessment_year BETWEEN 2015 AND 2019 AND assessment_result = 'Passed'; | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_life_habitats_2 (id INT, name VARCHAR(255), water_temp DECIMAL(5,2), ph DECIMAL(3,2)); INSERT INTO marine_life_habitats_2 (id, name, water_temp, ph) VALUES (1, 'Coral Reef', 28.5, 8.2), (2, 'Open Ocean', 18.0, 8.1), (3, 'Estuary', 22.0, 7.5); | What are the names and water temperatures of marine life habitats with a pH level above 8? | SELECT name, water_temp FROM marine_life_habitats_2 WHERE ph > 8.0; | gretelai_synthetic_text_to_sql |
CREATE TABLE timber (id INT, species_id INT, area FLOAT, region_id INT); INSERT INTO timber (id, species_id, area, region_id) VALUES (1, 1, 123.45, 1); INSERT INTO timber (id, species_id, area, region_id) VALUES (2, 2, 234.56, 2); CREATE TABLE species (id INT, name VARCHAR(255)); INSERT INTO species (id, name) VALUES (... | What is the average timber production by species in each region? | SELECT r.name, AVG(t.area) as avg_area, s.name as species_name FROM timber t JOIN species s ON t.species_id = s.id JOIN region r ON t.region_id = r.id GROUP BY r.name, s.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE Concerts (concert_id INT, concert_name TEXT, attendees INT, artist_id INT); INSERT INTO Concerts (concert_id, concert_name, attendees, artist_id) VALUES (1, 'Lollapalooza', 30000, 1), (2, 'Bonnaroo', 25000, 2), (3, 'Firefly', 15000, 3), (4, 'African Music Festival', 5000, 4), (5, 'South American Music Fest... | What is the maximum number of concert attendees for artists who have never released an album and have performed at a music festival? | SELECT MAX(c.attendees) FROM Concerts c JOIN Artists a ON c.artist_id = a.artist_id WHERE a.albums = 0 AND a.festivals = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE movies (id INT, title VARCHAR(100), genre VARCHAR(50), release_year INT, revenue INT); INSERT INTO movies (id, title, genre, release_year, revenue) VALUES (1, 'Movie1', 'Comedy', 2020, 5000000); INSERT INTO movies (id, title, genre, release_year, revenue) VALUES (2, 'Movie2', 'Comedy', 2020, 7000000); | What was the total revenue for the 'comedy' genre movies released in 2020? | SELECT SUM(revenue) FROM movies WHERE genre = 'Comedy' AND release_year = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE mental_health_facilities (facility_id INT, state TEXT, languages TEXT); INSERT INTO mental_health_facilities (facility_id, state, languages) VALUES (1, 'California', 'English, Spanish'), (2, 'Texas', 'Arabic, French'), (3, 'New York', 'English, Mandarin'); | What is the total number of mental health facilities in each state offering services in Arabic? | SELECT state, COUNT(*) FROM mental_health_facilities WHERE languages LIKE '%Arabic%' GROUP BY state; | gretelai_synthetic_text_to_sql |
CREATE TABLE Exhibitions (id INT, artwork_id INT, exhibition_name TEXT); INSERT INTO Exhibitions (id, artwork_id, exhibition_name) VALUES (1, 1, 'Venice Biennale'), (2, 2, 'Whitney Biennial'); CREATE TABLE Artworks (id INT, title TEXT, artist_id INT, price INT); INSERT INTO Artworks (id, title, artist_id, price) VALU... | How many artworks were exhibited in the Whitney Biennial? | SELECT COUNT(DISTINCT Artworks.id) FROM Artworks INNER JOIN Exhibitions ON Artworks.id = Exhibitions.artwork_id WHERE Exhibitions.exhibition_name = 'Whitney Biennial'; | gretelai_synthetic_text_to_sql |
CREATE TABLE water_usage (year INT, sector VARCHAR(20), usage INT); INSERT INTO water_usage (year, sector, usage) VALUES (2020, 'residential', 12000), (2020, 'commercial', 15000), (2020, 'industrial', 20000), (2021, 'residential', 11000), (2021, 'commercial', 14000), (2021, 'industrial', 18000); | What is the total water usage in the residential sector for the year 2020? | SELECT SUM(usage) FROM water_usage WHERE sector = 'residential' AND year = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE attorneys (attorney_id INT, name VARCHAR(50)); INSERT INTO attorneys (attorney_id, name) VALUES (1, 'Smith'), (2, 'Johnson'), (3, 'Williams'), (4, 'Murphy'); CREATE TABLE cases (case_id INT, attorney_id INT, is_success BOOLEAN); INSERT INTO cases (case_id, attorney_id, is_success) VALUES (1, 2, TRUE), (2, ... | What is the success rate of cases with 'Murphy' as the lead attorney? | SELECT COUNT(*) / (SELECT COUNT(*) FROM cases WHERE cases.attorney_id = attorneys.attorney_id) AS success_rate FROM attorneys INNER JOIN cases ON attorneys.attorney_id = cases.attorney_id WHERE attorneys.name = 'Murphy' AND is_success = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE claims (claim_number INT, policy_number INT, claim_amount INT, claim_date DATE, province TEXT); INSERT INTO claims (claim_number, policy_number, claim_amount, claim_date, province) VALUES (111, 12345, 6000, '2021-08-01', 'Ontario'); INSERT INTO claims (claim_number, policy_number, claim_amount, claim_date,... | What is the name and claim amount for claims in Ontario over $5000? | SELECT policyholder_name, claim_amount FROM claims JOIN policies ON claims.policy_number = policies.policy_number WHERE province = 'Ontario' AND claim_amount > 5000; | gretelai_synthetic_text_to_sql |
CREATE TABLE Employees (EmployeeID INT, Gender VARCHAR(10)); CREATE TABLE Training (TrainingID INT, EmployeeID INT, TrainingType VARCHAR(25), TrainingDate DATE); INSERT INTO Employees (EmployeeID, Gender) VALUES (1, 'Female'), (2, 'Male'); INSERT INTO Training (TrainingID, EmployeeID, TrainingType, TrainingDate) VALUES... | How many female employees have completed diversity and inclusion training in the last six months? | SELECT COUNT(*) FROM Employees e JOIN Training t ON e.EmployeeID = t.EmployeeID WHERE e.Gender = 'Female' AND t.TrainingType = 'Diversity and Inclusion' AND t.TrainingDate >= DATEADD(month, -6, GETDATE()); | gretelai_synthetic_text_to_sql |
CREATE TABLE equipment_maintenance_count (id INT, equipment_type VARCHAR(255), maintenance_date DATE); | Get the number of military equipment maintenance records for each equipment type | SELECT equipment_type, COUNT(*) FROM equipment_maintenance_count GROUP BY equipment_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE Restaurants (RestaurantID INT, Name VARCHAR(50)); CREATE TABLE Menu (MenuID INT, RestaurantID INT, Item VARCHAR(50), Price DECIMAL(10,2), Last86Date DATE); | Identify the menu items that have been 86'ed (removed) more than once in the last month. | SELECT M.Item FROM Menu M WHERE M.Last86Date < DATE_SUB(CURDATE(), INTERVAL 30 DAY) GROUP BY M.Item HAVING COUNT(*) > 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE Education_Feedback (region_id INT, score INT); INSERT INTO Education_Feedback (region_id, score) VALUES (1, 8), (1, 9), (2, 7), (2, 6), (3, 9), (3, 8), (4, 6), (4, 5); CREATE TABLE Regions (id INT, name VARCHAR(50)); INSERT INTO Regions (id, name) VALUES (1, 'North'), (2, 'South'), (3, 'East'), (4, 'West')... | What is the average citizen feedback score for education services in each region? | SELECT R.name, AVG(EF.score) as Avg_Score FROM Education_Feedback EF JOIN Regions R ON EF.region_id = R.id GROUP BY R.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE power_plants (id INT, name VARCHAR(255), type VARCHAR(255), capacity INT, location VARCHAR(255)); INSERT INTO power_plants (id, name, type, capacity, location) VALUES (1, 'La Grande-1', 'Hydro', 2730, 'Canada'); INSERT INTO power_plants (id, name, type, capacity, location) VALUES (2, 'Three Gorges', 'Hydro... | What is the number of power plants in 'USA' and 'France' from the 'power_plants' table? | SELECT location, COUNT(*) FROM power_plants WHERE location IN ('USA', 'France') GROUP BY location; | gretelai_synthetic_text_to_sql |
CREATE TABLE SkincareSales (sale_id INT, product_name TEXT, is_paraben_free BOOLEAN, sale_amount FLOAT, sale_date DATE, country TEXT); INSERT INTO SkincareSales (sale_id, product_name, is_paraben_free, sale_amount, sale_date, country) VALUES (1, 'Paraben-Free Cream', TRUE, 40.00, '2022-01-01', 'South Korea'); INSERT IN... | Find the number of paraben-free skincare products sold in South Korea and Japan in 2022 | SELECT COUNT(*) FROM SkincareSales WHERE is_paraben_free = TRUE AND (country = 'South Korea' OR country = 'Japan') AND YEAR(sale_date) = 2022; | gretelai_synthetic_text_to_sql |
CREATE TABLE users (user_id INT, user_name VARCHAR(50), join_date DATE);CREATE TABLE posts (post_id INT, user_id INT, post_content TEXT, post_date DATE);CREATE TABLE followers (follower_id INT, user_id INT);INSERT INTO users (user_id, user_name, join_date) VALUES (1, 'user1', '2021-01-01'), (2, 'user2', '2021-02-01'), ... | Show the number of followers for users who have posted about vegan food in the past week, sorted by the number of followers in descending order. | SELECT f.user_id, COUNT(f.follower_id) as follower_count FROM followers f JOIN users u ON f.user_id = u.user_id JOIN posts p ON u.user_id = p.user_id WHERE p.post_content LIKE '%vegan food%' AND p.post_date >= DATEADD(week, -1, GETDATE()) GROUP BY f.user_id ORDER BY follower_count DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE lifelong_learning_gender (student_id INT, gender TEXT, course TEXT, completion_date DATE); INSERT INTO lifelong_learning_gender (student_id, gender, course, completion_date) VALUES (1, 'Female', 'Data Science', '2022-01-10'), (2, 'Male', 'Programming', '2021-06-15'), (3, 'Non-binary', 'Data Science', '2022... | What is the distribution of lifelong learning course completion rates by gender? | SELECT gender, COUNT(*) / (SELECT COUNT(*) FROM lifelong_learning_gender) AS completion_rate FROM lifelong_learning_gender GROUP BY gender; | gretelai_synthetic_text_to_sql |
CREATE TABLE investments (id INT, sector VARCHAR(20), date DATE, value FLOAT); INSERT INTO investments (id, sector, date, value) VALUES (1, 'Renewable Energy', '2017-01-01', 100000.0), (2, 'Finance', '2016-01-01', 75000.0), (3, 'Renewable Energy', '2018-01-01', 125000.0); | What is the total value of investments made in the renewable energy sector in 2017? | SELECT SUM(value) FROM investments WHERE sector = 'Renewable Energy' AND date = '2017-01-01'; | gretelai_synthetic_text_to_sql |
CREATE TABLE ingredient (id INT, product_id INT, name VARCHAR(50), source_country VARCHAR(50), PRIMARY KEY (id)); INSERT INTO ingredient (id, product_id, name, source_country) VALUES (1, 1, 'Beeswax', 'Australia'), (2, 2, 'Coconut Oil', 'Thailand'), (3, 3, 'Shea Butter', 'Ghana'); | List all ingredients that are sourced from Australia. | SELECT name FROM ingredient WHERE source_country = 'Australia'; | gretelai_synthetic_text_to_sql |
CREATE TABLE cultural_sites (site_id INT, site_name TEXT, location TEXT); INSERT INTO cultural_sites (site_id, site_name, location) VALUES (1, 'Alhambra', 'Spain'), (2, 'Colosseum', 'Italy'); | Delete all records of cultural heritage sites in Spain from the 'cultural_sites' table. | DELETE FROM cultural_sites WHERE location = 'Spain'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Climate_Finance_Australia (Year INT, Investment DECIMAL(10,2)); INSERT INTO Climate_Finance_Australia (Year, Investment) VALUES (2018, 1500.0), (2019, 2000.0), (2020, 2500.0), (2021, 3000.0); | What is the minimum investment in climate finance in Australia? | SELECT MIN(Investment) FROM Climate_Finance_Australia; | gretelai_synthetic_text_to_sql |
CREATE TABLE organizations (id INT, region VARCHAR(20), sector VARCHAR(20), ESG_rating FLOAT); INSERT INTO organizations (id, region, sector, ESG_rating) VALUES (1, 'Asia-Pacific', 'Healthcare', 7.5), (2, 'Americas', 'Technology', 8.2), (3, 'Asia-Pacific', 'Healthcare', 8.0), (4, 'Europe', 'Renewable Energy', 9.0); CRE... | List all organizations from the 'Asia-Pacific' region and their investments. | SELECT organizations.region, organizations.sector, organizations.id, investments.id AS investment_id FROM organizations JOIN investments ON organizations.id = investments.organization_id WHERE organizations.region = 'Asia-Pacific'; | gretelai_synthetic_text_to_sql |
CREATE TABLE country_waste (country VARCHAR(50), year INT, waste_amount FLOAT); INSERT INTO country_waste (country, year, waste_amount) VALUES ('USA', 2022, 500.5), ('Canada', 2022, 450.2), ('Mexico', 2022, 300.1), ('Brazil', 2022, 250.6), ('Argentina', 2022, 200.9), ('USA', 2022, 550.7), ('Canada', 2022, 475.3), ('Mex... | Get the top five countries with the highest chemical waste production in 2022 and the total waste produced. | SELECT country, SUM(waste_amount) as total_waste FROM country_waste WHERE year = 2022 GROUP BY country ORDER BY total_waste DESC LIMIT 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE attendees (id INT, event_id INT, no_attendees INT); CREATE TABLE events (id INT, name VARCHAR(255), category VARCHAR(255), date DATE); | How many total attendees were there for events with a 'family' category? | SELECT SUM(a.no_attendees) FROM attendees a INNER JOIN events e ON a.event_id = e.id WHERE e.category = 'family'; | gretelai_synthetic_text_to_sql |
CREATE TABLE donor (donor_id INT, donor_name TEXT); INSERT INTO donor (donor_id, donor_name) VALUES (1, 'John Doe'), (2, 'Jane Smith'), (3, 'Alice Johnson'), (4, 'Bob Brown'); CREATE TABLE donation (donation_id INT, donor_id INT, org_id INT); INSERT INTO donation (donation_id, donor_id, org_id) VALUES (1, 1, 1), (2, 2,... | List all donors who have given to both 'Habitat for Humanity' and 'Red Cross'. | SELECT donor_name FROM donor WHERE donor_id IN (SELECT donation.donor_id FROM donation WHERE org_id = 1) INTERSECT SELECT donor_name FROM donor WHERE donor_id IN (SELECT donation.donor_id FROM donation WHERE org_id = 2); | gretelai_synthetic_text_to_sql |
CREATE TABLE chemical_products (id INT, name TEXT, category TEXT); INSERT INTO chemical_products (id, name, category) VALUES (1, 'Product A', 'Category X'), (2, 'Product B', 'Category Y'), (3, 'Product C', 'Category Z'), (4, 'Product D', 'Category W'); CREATE TABLE wastes (id INT, product_id INT, amount INT); INSERT IN... | List the total waste generated by each chemical product category, including categories with no waste. | SELECT chemical_products.category, COALESCE(SUM(wastes.amount), 0) FROM chemical_products LEFT JOIN wastes ON chemical_products.id = wastes.product_id GROUP BY chemical_products.category; | gretelai_synthetic_text_to_sql |
CREATE TABLE EventViewership (EventID INT, EventName VARCHAR(50), HoursWatched DECIMAL(10,2)); | List all eSports events with more than 1000 hours of viewership in 'EventViewership' table | SELECT EventID, EventName FROM EventViewership WHERE HoursWatched > 1000; | gretelai_synthetic_text_to_sql |
CREATE TABLE Research_Papers (Paper_ID INT, Title VARCHAR(100), Publication_Date DATE, Country VARCHAR(50)); INSERT INTO Research_Papers (Paper_ID, Title, Publication_Date, Country) VALUES (1, 'Autonomous Driving Algorithms', '2021-01-01', 'USA'), (2, 'Deep Learning for Autonomous Vehicles', '2020-05-15', 'Germany'), (... | What are the top 3 countries with the highest number of autonomous driving research papers published in the last 2 years? | SELECT Country, COUNT(*) as Paper_Count FROM Research_Papers WHERE Publication_Date >= DATE_SUB(CURDATE(), INTERVAL 2 YEAR) GROUP BY Country ORDER BY Paper_Count DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE company (id INT, name TEXT, founder TEXT, industry TEXT, num_investors INT); INSERT INTO company (id, name, founder, industry, num_investors) VALUES (1, 'Acme Inc', 'Latinx', 'Fintech', 3); | What is the average number of investors per round for companies founded by Latinx individuals, in the fintech industry? | SELECT industry, AVG(num_investors) FROM company WHERE founder LIKE '%Latinx%' AND industry = 'Fintech' GROUP BY industry; | gretelai_synthetic_text_to_sql |
CREATE TABLE cargo_movements (id INT PRIMARY KEY, vessel_id INT, cargo_type VARCHAR(255), quantity INT, loading_port VARCHAR(255), unloading_port VARCHAR(255), movement_date DATE); INSERT INTO cargo_movements (id, vessel_id, cargo_type, quantity, loading_port, unloading_port, movement_date) VALUES (1, 1, 'Crude Oil', 5... | Delete records from the cargo_movements table where the loading_port is 'Los Angeles' and the movement_date is before '2021-01-01' | DELETE FROM cargo_movements WHERE loading_port = 'Los Angeles' AND movement_date < '2021-01-01'; | gretelai_synthetic_text_to_sql |
CREATE TABLE TV_shows (id INT, title VARCHAR(255), release_year INT, runtime INT, imdb_rating DECIMAL(2,1)); INSERT INTO TV_shows (id, title, release_year, runtime, imdb_rating) VALUES (1, 'Show1', 2018, 60, 7.2), (2, 'Show2', 2019, 45, 8.1), (3, 'Show3', 2020, 30, 6.5); | Find the average IMDb rating of TV shows released in 2020. | SELECT AVG(imdb_rating) FROM TV_shows WHERE release_year = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE restaurants (id INT, name VARCHAR(255), category VARCHAR(255), food_safety_score INT); INSERT INTO restaurants (id, name, category, food_safety_score) VALUES (1, 'Tasty Thai Eats', 'Fast Casual', 92), (2, 'Gourmet Burger Bites', 'Fast Casual', 88), (3, 'Fresh Mex Cantina', 'Fast Casual', 95); | What is the average food safety score for restaurants in the 'Fast Casual' category? | SELECT AVG(food_safety_score) as avg_score FROM restaurants WHERE category = 'Fast Casual'; | gretelai_synthetic_text_to_sql |
CREATE TABLE policy_documents (id INT, policy_id INT, document_name VARCHAR(50), document_date DATE); INSERT INTO policy_documents (id, policy_id, document_name, document_date) VALUES (1, 1, 'Policy Coverage', '2020-01-05'); INSERT INTO policy_documents (id, policy_id, document_name, document_date) VALUES (2, 2, 'Polic... | What is the second most recent document for each policy? | SELECT policy_id, document_name, NTH_VALUE(document_name, 2) OVER (PARTITION BY policy_id ORDER BY document_date DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) as second_document FROM policy_documents; | gretelai_synthetic_text_to_sql |
CREATE TABLE support_groups (group_id INT, patient_id INT, completed BOOLEAN, improvement_score INT); INSERT INTO support_groups (group_id, patient_id, completed, improvement_score) VALUES (1, 2, TRUE, 15); | What is the success rate of patients who completed a support group program? | SELECT AVG(improvement_score) FROM support_groups WHERE completed = TRUE; | gretelai_synthetic_text_to_sql |
CREATE TABLE organic_production (farm_id INT, country VARCHAR(50), production INT, is_organic BOOLEAN); INSERT INTO organic_production (farm_id, country, production, is_organic) VALUES (1, 'Brazil', 500, true), (2, 'Brazil', 800, true), (3, 'Argentina', 1000, false); | What is the average production of organic crops in Brazil? | SELECT AVG(production) FROM organic_production WHERE country = 'Brazil' AND is_organic = true; | gretelai_synthetic_text_to_sql |
CREATE TABLE drugs_approval (drug_name TEXT, approval_year INTEGER, region TEXT); INSERT INTO drugs_approval (drug_name, approval_year, region) VALUES ('DrugX', 2018, 'North'), ('DrugY', 2019, 'South'), ('DrugZ', 2020, 'East'), ('DrugA', 2018, 'West'), ('DrugB', 2020, 'North'); | What is the total number of drugs approved in a given year across all regions? | SELECT COUNT(DISTINCT drug_name) FROM drugs_approval WHERE approval_year = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE Employees (id INT, name VARCHAR(50), role VARCHAR(50), experience INT); INSERT INTO Employees (id, name, role, experience) VALUES (1, 'John Doe', 'Engineer', 5); INSERT INTO Employees (id, name, role, experience) VALUES (2, 'Jane Doe', 'Software Engineer', 6); INSERT INTO Employees (id, name, role, experie... | Find the average years of experience for all engineers in the Employees table. | SELECT AVG(experience) FROM Employees WHERE role LIKE '%Engineer%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE articles (id INT, title VARCHAR(100), author_id INT, word_count INT); CREATE TABLE authors (id INT, name VARCHAR(50), gender VARCHAR(10)); | What is the average number of words in news articles written by female authors in the 'articles' and 'authors' tables? | SELECT AVG(a.word_count) FROM articles a JOIN authors au ON a.author_id = au.id WHERE au.gender = 'female'; | gretelai_synthetic_text_to_sql |
CREATE TABLE ArtPieces (ArtPieceID INT PRIMARY KEY, ArtPieceName VARCHAR(100), CreationDate DATE, ArtistID INT); INSERT INTO ArtPieces (ArtPieceID, ArtPieceName, CreationDate, ArtistID) VALUES (1, 'Benin Bronzes', '1500-01-01', 1); INSERT INTO ArtPieces (ArtPieceID, ArtPieceName, CreationDate, ArtistID) VALUES (2, 'The... | Find the oldest artwork from African artists | SELECT ArtPieceName FROM ArtPieces JOIN Artists ON ArtPieces.ArtistID = Artists.ArtistID WHERE Artists.Age = (SELECT MAX(Age) FROM Artists WHERE Nationality = 'African'); | gretelai_synthetic_text_to_sql |
CREATE TABLE MiningData (SiteName VARCHAR(50), Resource VARCHAR(50), Quantity INT); INSERT INTO MiningData (SiteName, Resource, Quantity) VALUES ('Black Rock', 'Coal', 5000); | What is the total amount of coal mined from the 'Black Rock' site? | SELECT SUM(Quantity) FROM MiningData WHERE SiteName = 'Black Rock' AND Resource = 'Coal'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Heritagesites (id INT, name VARCHAR(255), continent VARCHAR(255)); INSERT INTO Heritagesites (id, name, continent) VALUES (1, 'Great Wall of China', 'Asia'), (2, 'Machu Picchu', 'South America'), (3, 'Eiffel Tower', 'Europe'); | How many heritage sites are in each continent? | SELECT continent, COUNT(*) FROM Heritagesites GROUP BY continent; | gretelai_synthetic_text_to_sql |
CREATE TABLE space_missions (mission_id INT, name VARCHAR(100), launch_date DATE); INSERT INTO space_missions (mission_id, name, launch_date) VALUES (1, 'Luna 1', '1959-01-02'), (2, 'Apollo 11', '1969-07-16'), (3, 'Mars Rover Perseverance', '2020-07-30'), (4, 'Skylab 1', '1973-05-14'), (5, 'Skylab 2', '1973-05-14'); | Identify the space missions with the same launch date. | SELECT name FROM space_missions WHERE launch_date IN (SELECT launch_date FROM space_missions GROUP BY launch_date HAVING COUNT(*) > 1); | gretelai_synthetic_text_to_sql |
CREATE TABLE Grants (GrantID INT, NonprofitID INT, GrantAmount FLOAT, GrantDate DATE); CREATE TABLE Expenses (ExpenseID INT, NonprofitID INT, ExpenseType VARCHAR(50), ExpenseAmount FLOAT, ExpenseDate DATE); | Identify nonprofits that received grants in Q1 2022 and spent less than the average amount on capacity building in the same period. | SELECT g.NonprofitID, n.NonprofitName FROM Grants g INNER JOIN Expenses e ON g.NonprofitID = e.NonprofitID INNER JOIN ( SELECT AVG(ExpenseAmount) as AvgExpenseAmount FROM Expenses WHERE ExpenseType = 'Capacity Building' AND ExpenseDate BETWEEN '2022-01-01' AND '2022-03-31' ) t ON 1=1 INNER JOIN Nonprofits n ON g.Nonpro... | gretelai_synthetic_text_to_sql |
CREATE TABLE vessel_performance (vessel_id INT, engine_power INT); INSERT INTO vessel_performance (vessel_id, engine_power) VALUES (1, 2000), (2, 3000), (3, 2500); | Update vessel_performance with average engine_power | UPDATE vessel_performance SET engine_power = (SELECT AVG(engine_power) FROM vessel_performance WHERE vessel_performance.vessel_id = vessel_performance.vessel_id GROUP BY vessel_id); | gretelai_synthetic_text_to_sql |
CREATE TABLE ai_safety_incidents (id INT PRIMARY KEY, incident_type VARCHAR(255), severity VARCHAR(255), timestamp TIMESTAMP); INSERT INTO ai_safety_incidents (id, incident_type, severity, timestamp) VALUES (1, 'autonomous_vehicle_accident', 'minor', '2022-01-01 10:00:00'); | How many safety incidents were recorded for each type of autonomous vehicle in the AI Safety Incidents database from January 1, 2022, to January 1, 2022? | SELECT incident_type, COUNT(*) as total_incidents FROM ai_safety_incidents WHERE timestamp BETWEEN '2022-01-01 00:00:00' AND '2022-01-01 23:59:59' GROUP BY incident_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE Donors (DonorID INT, DonationAmount DECIMAL(10,2), DonationDate DATE); | What is the average donation amount for each donor in the 'Donors' table who made donations in 2021? | SELECT DonorID, AVG(DonationAmount) FROM Donors WHERE YEAR(DonationDate) = 2021 GROUP BY DonorID; | gretelai_synthetic_text_to_sql |
CREATE TABLE port (port_id INT, port_name TEXT, full_address TEXT); INSERT INTO port VALUES (1, 'Singapore', 'Singapore'), (2, 'Los Angeles', 'USA'); | Update the address of the port 'Singapore' in the database to 'Singapore, 100 Airport Boulevard'. | UPDATE port SET full_address = 'Singapore, 100 Airport Boulevard' WHERE port_name = 'Singapore'; | gretelai_synthetic_text_to_sql |
CREATE TABLE policyholders (id INT, name TEXT, age INT, gender TEXT, state TEXT); INSERT INTO policyholders (id, name, age, gender, state) VALUES (1, 'John Doe', 36, 'Male', 'California'); INSERT INTO policyholders (id, name, age, gender, state) VALUES (2, 'Jane Smith', 42, 'Female', 'California'); CREATE TABLE claims ... | Delete all claims with a claim amount greater than 5000. | DELETE FROM claims WHERE claim_amount > 5000; | gretelai_synthetic_text_to_sql |
CREATE TABLE GameSessions (PlayerID INT, GameID INT, SessionDuration FLOAT, SessionDate DATE); INSERT INTO GameSessions (PlayerID, GameID, SessionDuration, SessionDate) VALUES (1, 1001, 50.5, '2021-05-01'), (2, 1002, 130.3, '2021-07-10'); | Show the number of players who played a specific game for more than 20 hours in the last year. | SELECT GameID, COUNT(PlayerID) as PlayersCount FROM GameSessions WHERE SessionDate BETWEEN DATEADD(year, -1, CURRENT_DATE) AND CURRENT_DATE AND SessionDuration > 20 GROUP BY GameID; | gretelai_synthetic_text_to_sql |
CREATE TABLE Teams (team_id INT, conference VARCHAR(255), losses INT); INSERT INTO Teams (team_id, conference, losses) VALUES (1, 'Eastern', 5), (2, 'Western', 3), (3, 'Eastern', 7), (4, 'Western', 6); | Which team has the least number of losses in the Western Conference? | SELECT conference, MIN(losses) FROM Teams WHERE conference = 'Western' GROUP BY conference; | gretelai_synthetic_text_to_sql |
CREATE TABLE pollution_control_initiatives (id INT, initiative VARCHAR(50), ocean VARCHAR(50), last_updated TIMESTAMP); | Delete all pollution control initiatives in the Arctic Ocean that have not been updated in the last year. | DELETE FROM pollution_control_initiatives WHERE ocean = 'Arctic Ocean' AND last_updated < NOW() - INTERVAL 1 YEAR; | gretelai_synthetic_text_to_sql |
CREATE TABLE subscribers (subscriber_id INT, network_type VARCHAR(10), data_usage FLOAT, region VARCHAR(20)); | Insert new subscribers with the following data: (6, '5G', 300.0, 'Europe'), (7, '4G', 150.0, 'America'), (8, '3G', 75.0, 'Asia'). | INSERT INTO subscribers (subscriber_id, network_type, data_usage, region) VALUES (6, '5G', 300.0, 'Europe'), (7, '4G', 150.0, 'America'), (8, '3G', 75.0, 'Asia'); | gretelai_synthetic_text_to_sql |
CREATE TABLE cities (city_id INT, name VARCHAR(255), population INT, area FLOAT); INSERT INTO cities (city_id, name, population, area) VALUES (1, 'New York City', 8601000, 302.6); INSERT INTO cities (city_id, name, population, area) VALUES (2, 'Los Angeles', 4000000, 1214.9); | Show the top 5 cities with the highest population density | SELECT name, population / area AS population_density FROM cities ORDER BY population_density DESC LIMIT 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE startups (startup_name VARCHAR(50), last_funded_date DATE); | Update the 'last_funded_date' for 'Startup GHI' in the 'startups' table to '2022-07-15' | UPDATE startups SET last_funded_date = '2022-07-15' WHERE startup_name = 'Startup GHI'; | gretelai_synthetic_text_to_sql |
CREATE TABLE products (product_id INT, product_name VARCHAR(255), restocked_date DATE); | Insert a new product 'Eco-friendly Tote Bag' with restocked_date '2022-02-15' | INSERT INTO products (product_name, restocked_date) VALUES ('Eco-friendly Tote Bag', '2022-02-15'); | gretelai_synthetic_text_to_sql |
CREATE TABLE wildlife_sanctuaries (id INT, species VARCHAR(50), population INT); | List all the distinct animal species in 'wildlife_sanctuaries' table that have a population greater than 100 | SELECT DISTINCT species FROM wildlife_sanctuaries WHERE population > 100; | gretelai_synthetic_text_to_sql |
CREATE TABLE Canals(id INT, name TEXT, location TEXT, length FLOAT); INSERT INTO Canals(id, name, location, length) VALUES (1, 'C-100 Canal', 'Florida', 12.4); | Which canals in Florida are longer than 10 miles? | SELECT name FROM Canals WHERE location = 'Florida' AND length > 10 * 5280; | gretelai_synthetic_text_to_sql |
CREATE TABLE genetic_research_data (id INT, sample_id TEXT, gene_sequence TEXT, analysis_result TEXT); | What are the gene sequences for genetic research data sample 'G002'? | SELECT gene_sequence FROM genetic_research_data WHERE sample_id = 'G002'; | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_species (name TEXT, region TEXT, population INTEGER); INSERT INTO marine_species (name, region, population) VALUES ('Bluefin Tuna', 'Mediterranean Sea', 50000), ('Dolphin', 'Mediterranean Sea', 150000); | What is the total population of marine species in the Mediterranean Sea? | SELECT SUM(population) FROM marine_species WHERE region = 'Mediterranean Sea'; | gretelai_synthetic_text_to_sql |
CREATE TABLE company_budgets (company_name VARCHAR(255), year INT, budget FLOAT); INSERT INTO company_budgets (company_name, year, budget) VALUES ('SpaceX', 2020, 3000000000.00); INSERT INTO company_budgets (company_name, year, budget) VALUES ('SpaceX', 2021, 4000000000.00); | What was the total budget for SpaceX in 2020 and 2021? | SELECT SUM(budget) FROM company_budgets WHERE company_name = 'SpaceX' AND year IN (2020, 2021); | gretelai_synthetic_text_to_sql |
CREATE TABLE smart_contracts (id INT, contract_name VARCHAR(255), function_name VARCHAR(255)); INSERT INTO smart_contracts (id, contract_name, function_name) VALUES (1, 'SafeMultisig', 'execute'), (1, 'SafeMultisig', 'revoke'), (2, 'BancorNetworkToken', 'convertTokenToToken'), (2, 'BancorNetworkToken', 'convertTokenToE... | List all smart contracts with their function names? | SELECT contract_name, function_name FROM smart_contracts; | gretelai_synthetic_text_to_sql |
CREATE TABLE songs (song_name VARCHAR(255), artist VARCHAR(255), genre VARCHAR(255), release_year INT); INSERT INTO songs (song_name, artist, genre, release_year) VALUES ('Djadja', 'Aya Nakamura', 'R&B', 2018), ('Pookie', 'Aya Nakamura', 'R&B', 2019); | Insert a new record for a song by artist 'Aya Nakamura' from genre 'R&B' released in 2022 | INSERT INTO songs (song_name, artist, genre, release_year) VALUES ('Bemba', 'Aya Nakamura', 'R&B', 2022); | gretelai_synthetic_text_to_sql |
CREATE TABLE maintenance_resolution (id INT, equipment_type VARCHAR(255), resolution_time INT); INSERT INTO maintenance_resolution (id, equipment_type, resolution_time) VALUES (1, 'Aircraft', 5), (2, 'Vehicle', 3), (3, 'Aircraft', 7), (4, 'Vessel', 6); | Find the average time to resolve a maintenance issue for each type of equipment | SELECT equipment_type, AVG(resolution_time) as avg_resolution_time FROM maintenance_resolution GROUP BY equipment_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE patients (id INT, country VARCHAR(50)); INSERT INTO patients (id, country) VALUES (1, 'Canada'), (2, 'USA'), (3, 'USA'), (4, 'Mexico'), (5, 'Canada'); CREATE TABLE treatments (id INT, patient_id INT, treatment VARCHAR(50)); INSERT INTO treatments (id, patient_id, treatment) VALUES (1, 1, 'Cognitive Behavio... | How many patients in Canada have received cognitive behavioral therapy as a treatment for their mental health condition? | SELECT COUNT(*) FROM treatments INNER JOIN patients ON treatments.patient_id = patients.id WHERE patients.country = 'Canada' AND treatments.treatment = 'Cognitive Behavioral Therapy'; | gretelai_synthetic_text_to_sql |
CREATE TABLE cybersecurity_strategies (strategy_id INT PRIMARY KEY, strategy_name VARCHAR(100), strategy_description TEXT); INSERT INTO cybersecurity_strategies (strategy_id, strategy_name, strategy_description) VALUES (1, 'Zero Trust', 'Network security model based on strict identity verification'), (2, 'Cybersecurity... | Delete the 'cybersecurity_strategy' with 'strategy_id' 1 from the 'cybersecurity_strategies' table | DELETE FROM cybersecurity_strategies WHERE strategy_id = 1; | 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.