context stringlengths 11 9.12k | question stringlengths 0 1.06k | SQL stringlengths 2 4.44k | source stringclasses 28
values |
|---|---|---|---|
CREATE TABLE department (id INT PRIMARY KEY, name TEXT, city_id INT, FOREIGN KEY (city_id) REFERENCES city(id)); CREATE TABLE meeting (id INT PRIMARY KEY, date DATE, department_id INT, FOREIGN KEY (department_id) REFERENCES department(id)); | What is the maximum number of public meetings held in a single year by a department? | SELECT department_id, MAX(YEAR(date)) as max_year, COUNT(*) as max_meetings FROM meeting GROUP BY department_id HAVING MAX(YEAR(date)) = max_year; | gretelai_synthetic_text_to_sql |
CREATE TABLE ResearchStations (id INT PRIMARY KEY, station VARCHAR(255), location VARCHAR(255), year INT); INSERT INTO ResearchStations (id, station, location, year) VALUES (1, 'Station A', 'Greenland', 1990); INSERT INTO ResearchStations (id, station, location, year) VALUES (2, 'Station B', 'Canada', 2005); | find the total number of research stations in Greenland and Canada, and the year they were established. | SELECT location, COUNT(*) as total_stations, MIN(year) as establishment_year FROM ResearchStations WHERE location IN ('Greenland', 'Canada') GROUP BY location; | gretelai_synthetic_text_to_sql |
CREATE TABLE brands (brand_id INT, brand_name VARCHAR(50)); INSERT INTO brands (brand_id, brand_name) VALUES (1, 'Versace'), (2, 'Gucci'), (3, 'Chanel'); CREATE TABLE sales (sale_id INT, brand_id INT, quantity INT); INSERT INTO sales (sale_id, brand_id, quantity) VALUES (1, 1, 10), (2, 1, 20), (3, 2, 30), (4, 3, 40), (... | What is the total quantity of garments sold by each brand, excluding those that have never been sold? | SELECT s.brand_id, SUM(s.quantity) AS total_quantity_sold FROM sales s WHERE s.quantity IS NOT NULL GROUP BY s.brand_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE hospitals (id INT, name TEXT, city TEXT, state TEXT, beds INT); INSERT INTO hospitals (id, name, city, state, beds) VALUES (1, 'General Hospital', 'Miami', 'Florida', 500); INSERT INTO hospitals (id, name, city, state, beds) VALUES (2, 'Memorial Hospital', 'Boston', 'Massachusetts', 600); | What is the total number of hospitals and total number of beds by state? | SELECT state, COUNT(*) as hospital_count, SUM(beds) as total_beds FROM hospitals GROUP BY state; | gretelai_synthetic_text_to_sql |
CREATE TABLE satellites (satellite_id INT, country VARCHAR(50)); INSERT INTO satellites (satellite_id, country) VALUES (1, 'USA'), (2, 'Russia'), (3, 'China'); | What is the total number of satellites launched by country? | SELECT country, COUNT(*) as total_launched FROM satellites GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE suppliers (id INT, name TEXT, sustainable BOOLEAN); INSERT INTO suppliers (id, name, sustainable) VALUES (1, 'Green Fields', true), (2, 'Wholesale Inc.', false), (3, 'Local Harvest', true); CREATE TABLE purchases (supplier_id INT, weight FLOAT); INSERT INTO purchases (supplier_id, weight) VALUES (1, 100.5)... | What is the total weight of ingredients sourced from sustainable suppliers? | SELECT SUM(purchases.weight) FROM purchases JOIN suppliers ON purchases.supplier_id = suppliers.id WHERE suppliers.sustainable = true; | gretelai_synthetic_text_to_sql |
CREATE TABLE MentalHealthScreening (StudentID INT, Age INT, Gender VARCHAR(10), PassedScreening BOOLEAN); INSERT INTO MentalHealthScreening (StudentID, Age, Gender, PassedScreening) VALUES (1, 22, 'Male', true); INSERT INTO MentalHealthScreening (StudentID, Age, Gender, PassedScreening) VALUES (2, 20, 'Female', false);... | What is the percentage of students who passed the mental health screening? | SELECT (COUNT(*) FILTER (WHERE PassedScreening = true)) * 100.0 / COUNT(*) FROM MentalHealthScreening; | gretelai_synthetic_text_to_sql |
CREATE TABLE digital_assets (id INT, name VARCHAR(50), country VARCHAR(10), value INT); INSERT INTO digital_assets (id, name, country, value) VALUES (1, 'Asset1', 'Germany', 1000), (2, 'Asset2', 'France', 2000), (3, 'Asset3', 'Italy', 3000); | Which countries in Europe have the highest number of digital assets under management? | SELECT country, COUNT(*) as num_assets, SUM(value) as total_value, RANK() OVER (ORDER BY SUM(value) DESC) as rank FROM digital_assets WHERE country IN ('Germany', 'France', 'Italy') GROUP BY country; | gretelai_synthetic_text_to_sql |
CREATE TABLE recycling_rates (city varchar(255), sector varchar(255), year int, recycling_rate float); INSERT INTO recycling_rates (city, sector, year, recycling_rate) VALUES ('San Francisco', 'Commercial', 2021, 75); | What is the recycling rate in the commercial sector in the city of San Francisco in 2021? | SELECT recycling_rate FROM recycling_rates WHERE city = 'San Francisco' AND sector = 'Commercial' AND year = 2021 | gretelai_synthetic_text_to_sql |
CREATE TABLE AgeGroupData (AgeGroup VARCHAR(255), Uninsured DECIMAL(3,1)); INSERT INTO AgeGroupData (AgeGroup, Uninsured) VALUES ('0-18', 6.0), ('19-34', 12.5), ('35-49', 8.0), ('50-64', 5.0), ('65+', 1.0); CREATE TABLE OverallData (OverallUninsured DECIMAL(3,1)); INSERT INTO OverallData (OverallUninsured) VALUES (10.0... | What is the percentage of uninsured individuals in each age group, and how does it compare to the overall percentage of uninsured individuals? | SELECT AgeGroup, Uninsured, Uninsured * 100.0 / (SELECT OverallUninsured FROM OverallData) AS Percentage FROM AgeGroupData; | gretelai_synthetic_text_to_sql |
CREATE TABLE nba_teams (team_id INT, team_name VARCHAR(255)); INSERT INTO nba_teams VALUES (1, 'TeamA'), (2, 'TeamB'), (3, 'TeamC'); CREATE TABLE nba_games (game_id INT, home_team_id INT, away_team_id INT, home_score INT, away_score INT, playoff_round VARCHAR(255)); INSERT INTO nba_games VALUES (1, 1, 2, 90, 85, 'First... | What is the percentage of games won by each team in the 2022 NBA playoffs? | SELECT t.team_name, (SUM(CASE WHEN g.home_team_id = t.team_id THEN 1 ELSE 0 END) + SUM(CASE WHEN g.away_team_id = t.team_id THEN 1 ELSE 0 END) - SUM(CASE WHEN (g.home_team_id = t.team_id AND g.home_score < g.away_score) OR (g.away_team_id = t.team_id AND g.home_score > g.away_score) THEN 1 ELSE 0 END)) * 100.0 / COUNT(... | gretelai_synthetic_text_to_sql |
CREATE TABLE av_types (av_id INT, av_type VARCHAR(50));CREATE TABLE av_prices (price_id INT, av_id INT, price DECIMAL(5, 2));INSERT INTO av_types (av_id, av_type) VALUES (1, 'Wayve Truck'), (2, 'NVIDIA Truck'), (3, 'Zoox Truck');INSERT INTO av_prices (price_id, av_id, price) VALUES (1, 1, 150000), (2, 2, 250000), (3, 3... | List all autonomous truck types and their average prices | SELECT av.av_type, AVG(ap.price) as avg_price FROM av_types av JOIN av_prices ap ON av.av_id = ap.av_id WHERE av.av_type LIKE '%Truck' GROUP BY av.av_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE PlayerPlaytime (PlayerID int, PlayerName varchar(50), Game varchar(50), Playtime decimal(10,2)); | What is the average playtime for each player in the "Shooter" genre? | SELECT PlayerName, AVG(Playtime) OVER(PARTITION BY PlayerID) as AvgPlaytime FROM PlayerPlaytime WHERE Game = 'Shooter'; | gretelai_synthetic_text_to_sql |
CREATE TABLE providers (id INT, name VARCHAR(50), language VARCHAR(50), parity_violations INT); INSERT INTO providers (id, name, language, parity_violations) VALUES (1, 'Dr. Maria Garcia', 'Spanish', 7), (2, 'Dr. John Smith', 'English', 3); CREATE TABLE violations (id INT, provider_id INT, date DATE); INSERT INTO viola... | What is the total number of mental health parity violations recorded in the 'violations' table, for providers serving primarily patients who identify as LGBTQ+? | SELECT SUM(v.parity_violations) FROM providers p JOIN violations v ON p.id = v.provider_id JOIN patients patient ON p.id = patient.id WHERE patient.gender LIKE '%Transgender%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE projects (id INT, name TEXT, region TEXT, capacity_mw FLOAT, status TEXT); INSERT INTO projects (id, name, region, capacity_mw, status) VALUES (1, 'Biomass Project 1', 'Europe', 30.6, 'operational'); INSERT INTO projects (id, name, region, capacity_mw, status) VALUES (2, 'Biomass Project 2', 'Europe', 40.2... | What is the minimum capacity (in MW) of operational biomass power projects in the 'Europe' region? | SELECT MIN(capacity_mw) FROM projects WHERE type = 'biomass' AND status = 'operational'; | gretelai_synthetic_text_to_sql |
CREATE TABLE donors (donor_id int, donation_amount decimal(10,2), country varchar(50)); INSERT INTO donors (donor_id, donation_amount, country) VALUES (1, 200.00, 'France'), (2, 100.00, 'France'), (3, 300.00, 'France'); | What is the maximum donation amount made by a donor in France? | SELECT MAX(donation_amount) FROM donors WHERE country = 'France'; | gretelai_synthetic_text_to_sql |
CREATE TABLE climate_finance (sector VARCHAR(255), location VARCHAR(255), year INT, amount FLOAT); INSERT INTO climate_finance (sector, location, year, amount) VALUES ('Public', 'Brazil', 2015, 12000000), ('Private', 'Colombia', 2016, 15000000), ('Public', 'Argentina', 2017, 18000000), ('Private', 'Peru', 2018, 2000000... | What is the total amount of climate finance provided by public and private sector in Latin America between 2015 and 2020? | SELECT SUM(amount) FROM climate_finance WHERE location LIKE 'Latin America%' AND sector IN ('Public', 'Private') AND year BETWEEN 2015 AND 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE Proposals (State VARCHAR(255), Status VARCHAR(255), Proposal VARCHAR(255)); INSERT INTO Proposals (State, Status, Proposal) VALUES ('CA', 'Approved', 'Expand Medicaid'), ('TX', 'Rejected', 'Establish Pre-K Program'), ('CA', 'Rejected', 'Implement Carbon Tax'); | List all the policy proposals that have been rejected by the state of California. | SELECT Proposal FROM Proposals WHERE State = 'CA' AND Status = 'Rejected'; | gretelai_synthetic_text_to_sql |
CREATE TABLE songs (song_id INT, title VARCHAR(255), genre VARCHAR(50), release_year INT, length FLOAT); INSERT INTO songs (song_id, title, genre, release_year, length) VALUES (1, 'Song1', 'Classical', 1975, 120.5), (2, 'Song2', 'Jazz', 1978, 210.3), (3, 'Song3', 'Rock', 1972, 150.7), (4, 'Song4', 'Classical', 1979, 20... | What is the minimum length (in seconds) of any song released in the 1970s? | SELECT MIN(length) FROM songs WHERE release_year >= 1970 AND release_year <= 1979; | gretelai_synthetic_text_to_sql |
CREATE TABLE healthcare_staff (name VARCHAR(255), gender VARCHAR(255), position VARCHAR(255), hospital_id INT); INSERT INTO healthcare_staff (name, gender, position, hospital_id) VALUES ('Dr. Jane Smith', 'Female', 'Doctor', 1), ('Dr. Maria Garcia', 'Female', 'Doctor', 2); | What are the names and positions of all female staff members in the 'healthcare_staff' table? | SELECT name, position FROM healthcare_staff WHERE gender = 'Female'; | gretelai_synthetic_text_to_sql |
CREATE TABLE articles (article_id INT, author_name VARCHAR(255), section VARCHAR(255)); INSERT INTO articles (article_id, author_name, section) VALUES (1, 'John Doe', 'Investigative Journalism'), (2, 'Jane Smith', 'Sports'), (3, 'John Doe', 'Investigative Journalism'); | Identify the total number of articles published by each author in the Investigative Journalism section. | SELECT author_name, section, COUNT(*) as total_articles FROM articles WHERE section = 'Investigative Journalism' GROUP BY author_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE customer_size (id INT, name VARCHAR(50), size VARCHAR(20)); INSERT INTO customer_size (id, name, size) VALUES (1, 'David', 'L'); INSERT INTO customer_size (id, name, size) VALUES (2, 'Eva', 'M'); INSERT INTO customer_size (id, name, size) VALUES (3, 'Frank', 'S'); INSERT INTO customer_size (id, name, size)... | find the most popular size among customers | SELECT size, COUNT(*) FROM customer_size GROUP BY size ORDER BY COUNT(*) DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE energy_consumption (year INT, sector VARCHAR(255), consumption FLOAT); INSERT INTO energy_consumption (year, sector, consumption) VALUES (2015, 'Residential', 1234.5), (2015, 'Commercial', 2345.6), (2015, 'Industrial', 3456.7), (2020, 'Residential', 1567.8), (2020, 'Commercial', 2890.9), (2020, 'Industrial... | What is the total energy consumption by sector in 2020? | SELECT SUM(consumption) AS total_consumption, sector FROM energy_consumption WHERE year = 2020 GROUP BY sector; | gretelai_synthetic_text_to_sql |
CREATE TABLE unions (id INT, name TEXT, region TEXT, collective_bargaining BOOLEAN); CREATE TABLE union_details (id INT, union_id INT, contract_length INT); | Show the names of unions with collective bargaining agreements in the 'northeast' region. | SELECT DISTINCT name FROM unions JOIN union_details ON unions.id = union_details.union_id WHERE unions.region = 'northeast' AND unions.collective_bargaining = true; | gretelai_synthetic_text_to_sql |
CREATE TABLE Games (GameID INT, HomeAttendance INT, AwayAttendance INT); | Delete all games where the attendance was less than 5000. | DELETE FROM Games WHERE HomeAttendance + AwayAttendance < 5000; | gretelai_synthetic_text_to_sql |
CREATE TABLE broadband_subscribers (id INT, region VARCHAR(20), subscription_date DATE); INSERT INTO broadband_subscribers (id, region, subscription_date) VALUES (1, 'urban', '2022-01-01'), (2, 'rural', '2022-03-15'), (3, 'urban', '2022-02-01'), (4, 'asia', '2022-03-25'), (5, 'rural', '2022-04-10'); | How many new broadband subscribers were added in the last month in the 'Asia' region? | SELECT COUNT(*) FROM broadband_subscribers WHERE region = 'asia' AND subscription_date BETWEEN DATE_SUB('2022-04-01', INTERVAL 1 MONTH) AND '2022-04-01'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Bridges (ID INT, Name VARCHAR(50), Location VARCHAR(50), DateAdded DATE); INSERT INTO Bridges (ID, Name, Location, DateAdded) VALUES (1, 'Golden Gate Bridge', 'San Francisco, CA', '1937-05-27'); INSERT INTO Bridges (ID, Name, Location, DateAdded) VALUES (2, 'George Washington Bridge', 'New York, NY', '1931... | Insert a new record into the 'Bridges' table for a bridge named 'Chesapeake Bay Bridge-Tunnel' with an ID of 3, located in 'Virginia Beach, VA', and added on '1964-04-15'. | INSERT INTO Bridges (ID, Name, Location, DateAdded) VALUES (3, 'Chesapeake Bay Bridge-Tunnel', 'Virginia Beach, VA', '1964-04-15'); | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_protected_areas (area_name TEXT, latitude DECIMAL(10,8), longitude DECIMAL(11,8)); INSERT INTO marine_protected_areas (area_name, latitude, longitude) VALUES ('Great Barrier Reef', -18.78, 147.75), ('Galapagos Islands', -0.79, -90.81); | List all marine protected areas that are in the Southern Hemisphere. | SELECT area_name FROM marine_protected_areas WHERE latitude < 0; | gretelai_synthetic_text_to_sql |
CREATE TABLE Cyber_Strategies (id INT, name VARCHAR(50), location VARCHAR(20), type VARCHAR(20), budget INT); INSERT INTO Cyber_Strategies (id, name, location, type, budget) VALUES (1, 'Cyber Shield', 'Africa', 'Defense', 8000000); | Which cybersecurity strategies are located in the 'Africa' region from the 'Cyber_Strategies' table? | SELECT * FROM Cyber_Strategies WHERE location = 'Africa'; | gretelai_synthetic_text_to_sql |
CREATE TABLE sustainable_sourcing (sourcing_id INT, restaurant_id INT, supplier_name VARCHAR(50), sustainable_practices VARCHAR(50)); | Create a table for storing information about sustainable sourcing practices. | CREATE TABLE sustainable_sourcing (sourcing_id INT, restaurant_id INT, supplier_name VARCHAR(50), sustainable_practices VARCHAR(50)); | gretelai_synthetic_text_to_sql |
CREATE TABLE creative_ai.ai_algorithms (ai_algorithm_id INT PRIMARY KEY, ai_algorithm VARCHAR(255), fairness_score FLOAT); INSERT INTO creative_ai.ai_algorithms (ai_algorithm_id, ai_algorithm, fairness_score) VALUES (1, 'Generative Adversarial Networks', 0.75), (2, 'Transformers', 0.85), (3, 'Deep Reinforcement Learnin... | What is the maximum fairness score for each AI algorithm in the 'creative_ai' database? | SELECT ai_algorithm, MAX(fairness_score) as max_fairness_score FROM creative_ai.ai_algorithms GROUP BY ai_algorithm; | gretelai_synthetic_text_to_sql |
CREATE TABLE cities (city_name VARCHAR(255), population INT, num_green_buildings INT); INSERT INTO cities (city_name, population, num_green_buildings) VALUES ('New York', 8500000, 5000), ('Los Angeles', 4000000, 2500), ('Chicago', 2700000, 1500), ('Houston', 2300000, 1000), ('Phoenix', 1700000, 750); | List all the cities with a population of over 1 million people and having at least one green building certified by LEED? | SELECT city_name FROM cities WHERE population > 1000000 AND num_green_buildings > 0; | gretelai_synthetic_text_to_sql |
CREATE TABLE neighborhoods (neighborhood_id INT, neighborhood_name VARCHAR(255));CREATE TABLE community_policing (event_id INT, event_date DATE, neighborhood_id INT); INSERT INTO neighborhoods VALUES (1, 'West Hill'), (2, 'East End'); INSERT INTO community_policing VALUES (1, '2020-01-01', 1), (2, '2020-02-01', 2); | How many community policing events happened in each neighborhood in 2020? | SELECT neighborhood_id, COUNT(*) as num_events FROM community_policing WHERE EXTRACT(YEAR FROM event_date) = 2020 GROUP BY neighborhood_id | gretelai_synthetic_text_to_sql |
CREATE TABLE deliveries (id INT, item TEXT, region TEXT); INSERT INTO deliveries (id, item, region) VALUES (1, 'Medical Supplies', 'Africa'); INSERT INTO deliveries (id, item, region) VALUES (2, 'Water Purifiers', 'Asia'); INSERT INTO deliveries (id, item, region) VALUES (3, 'Medical Supplies', 'Asia'); | How many medical supplies were delivered to region 'Asia'? | SELECT COUNT(*) FROM deliveries WHERE item = 'Medical Supplies' AND region = 'Asia'; | gretelai_synthetic_text_to_sql |
CREATE TABLE GarmentSales (SaleID INT, GarmentID INT, Country VARCHAR(255)); INSERT INTO GarmentSales (SaleID, GarmentID, Country) VALUES (1, 1, 'USA'); | Rank garments by the number of times they were sold, per country, and show only the top ranked garment in each country. | SELECT GarmentID, Country, ROW_NUMBER() OVER (PARTITION BY Country ORDER BY COUNT(*) DESC) as Rank FROM GarmentSales GROUP BY GarmentID, Country HAVING Rank = 1; | gretelai_synthetic_text_to_sql |
CREATE VIEW field_temperatures AS SELECT fields.field_name, field_sensors.temperature, field_sensors.measurement_date FROM fields JOIN field_sensors ON fields.id = field_sensors.field_id; | Which fields have the lowest average temperature in the 'field_temperatures' view? | SELECT field_name, AVG(temperature) as avg_temp FROM field_temperatures GROUP BY field_name ORDER BY avg_temp ASC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE police_departments (id INT, department_name VARCHAR(50), location VARCHAR(50), population INT, average_response_time FLOAT); | What is the maximum and minimum response time for police departments in urban areas with a population between 250,000 and 500,000? | SELECT department_name, MAX(average_response_time) FROM police_departments WHERE population BETWEEN 250000 AND 500000 AND location = 'urban' GROUP BY department_name UNION ALL SELECT department_name, MIN(average_response_time) FROM police_departments WHERE population BETWEEN 250000 AND 500000 AND location = 'urban' GRO... | gretelai_synthetic_text_to_sql |
CREATE TABLE cybersecurity_budgets (country TEXT, year INT, amount INT); INSERT INTO cybersecurity_budgets (country, year, amount) VALUES ('USA', 2020, 18000000000), ('UK', 2020, 3200000000), ('China', 2020, 5000000000); | What are the cybersecurity budgets for each country in 2020? | SELECT country, amount FROM cybersecurity_budgets WHERE year = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE pt_ridership (id INT, system VARCHAR, country VARCHAR, passengers INT); | Which public transportation systems have the highest ridership in country X? | SELECT system, passengers FROM pt_ridership WHERE country = 'X' ORDER BY passengers DESC LIMIT 10; | gretelai_synthetic_text_to_sql |
CREATE TABLE site_b_pottery (id INT PRIMARY KEY, age INT); INSERT INTO site_b_pottery (id, age) VALUES (1, 500), (2, 800), (3, 1200), (4, 750); | What is the age distribution of pottery artifacts in the 'site_b' excavation? | SELECT AVG(age), STDDEV(age), MIN(age), MAX(age) FROM site_b_pottery; | gretelai_synthetic_text_to_sql |
CREATE TABLE company (id INT, name TEXT, country TEXT, rd_expenditure FLOAT); INSERT INTO company (id, name, country, rd_expenditure) VALUES (1, 'ABC Pharma', 'USA', 15000000); INSERT INTO company (id, name, country, rd_expenditure) VALUES (2, 'XYZ Labs', 'USA', 22000000); | What is the average R&D expenditure for companies located in the United States? | SELECT AVG(rd_expenditure) FROM company WHERE country = 'USA'; | gretelai_synthetic_text_to_sql |
CREATE TABLE south_american_conservation_areas (id INT, name VARCHAR(255), area_size FLOAT); CREATE TABLE south_american_animal_population (id INT, conservation_area_id INT, species VARCHAR(255), animal_count INT, status VARCHAR(255)); | What is the total number of animals in the South American wildlife conservation areas, broken down by conservation area and animal status (endangered, threatened, or stable)? | SELECT sa.name, sap.status, SUM(sap.animal_count) as total_animals FROM south_american_conservation_areas sa JOIN south_american_animal_population sap ON sa.id = sap.conservation_area_id GROUP BY sa.name, sap.status; | gretelai_synthetic_text_to_sql |
CREATE TABLE esports_events (event_id INT, location VARCHAR(50), genre VARCHAR(50)); INSERT INTO esports_events (event_id, location, genre) VALUES (1, 'Seoul, Korea', 'MOBA'), (2, 'Beijing, China', 'FPS'), (3, 'Tokyo, Japan', 'RTS'); | How many esports events have been held in Asia by game genre? | SELECT genre, COUNT(*) AS num_events FROM esports_events WHERE location LIKE '%%Asia%%' GROUP BY genre; | gretelai_synthetic_text_to_sql |
CREATE TABLE workforce_diversity (site_id INT, site_name TEXT, worker_id INT, worker_role TEXT, gender TEXT, age INT, ethnicity TEXT); INSERT INTO workforce_diversity (site_id, site_name, worker_id, worker_role, gender, age, ethnicity) VALUES (7, 'RST Mine', 7001, 'Mining Engineer', 'Female', 35, 'Indigenous'), (8, 'ST... | What is the percentage of Indigenous workers at each mine site? | SELECT site_name, (COUNT(*) FILTER (WHERE ethnicity = 'Indigenous')) * 100.0 / COUNT(*) as percentage_indigenous FROM workforce_diversity GROUP BY site_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE conservation_events (id INT, event_name VARCHAR(50), location VARCHAR(50), date DATE, attendees INT); INSERT INTO conservation_events (id, event_name, location, date, attendees) VALUES (5, 'Marine Life Exploration', 'Ocean', '2022-02-20', 75); INSERT INTO conservation_events (id, event_name, location, date... | How many conservation events were held in the ocean habitat last year? | SELECT COUNT(*) FROM conservation_events WHERE location = 'Ocean' AND date BETWEEN '2022-01-01' AND '2022-12-31'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Employees (id INT, name VARCHAR(50), position VARCHAR(50), left_company BOOLEAN, salary DECIMAL(10,2)); | Find the maximum salary of employees in the company, for each position | SELECT position, MAX(salary) FROM Employees WHERE left_company = FALSE GROUP BY position; | gretelai_synthetic_text_to_sql |
CREATE TABLE Artists (ArtistID INT, Name TEXT);CREATE TABLE Artworks (ArtworkID INT, Title TEXT, Genre TEXT, ArtistID INT); INSERT INTO Artists (ArtistID, Name) VALUES (1, 'Pablo Picasso'), (2, 'Jackson Pollock'); INSERT INTO Artworks (ArtworkID, Title, Genre, ArtistID) VALUES (1, 'Guernica', 'Cubism', 1), (2, 'The Old... | What is the average number of artworks per artist? | SELECT AVG(ArtworksPerArtist) FROM (SELECT COUNT(Artworks.ArtworkID) AS ArtworksPerArtist FROM Artworks INNER JOIN Artists ON Artworks.ArtistID = Artists.ArtistID GROUP BY Artists.ArtistID) AS Subquery; | gretelai_synthetic_text_to_sql |
CREATE TABLE businesses (id INT, name TEXT, industry TEXT, ownership TEXT, funding FLOAT); INSERT INTO businesses (id, name, industry, ownership, funding) VALUES (1, 'HealthCo', 'Health', 'Majority', 200000.00); INSERT INTO businesses (id, name, industry, ownership, funding) VALUES (2, 'TechCo', 'Technology', 'Minority... | What is the average amount of funding allocated to businesses in the Health sector? | SELECT AVG(funding) FROM businesses WHERE industry = 'Health'; | gretelai_synthetic_text_to_sql |
CREATE TABLE healthcare_unions (id INT, employee_name TEXT, hours_worked INT, salary REAL); INSERT INTO healthcare_unions (id, employee_name, hours_worked, salary) VALUES (1, 'Daniel Lee', 30, 60000.00), (2, 'Emilia Garcia', 35, 65000.00), (3, 'Fabian Kim', 40, 70000.00); | What is the minimum salary in healthcare unions for employees who work 35 hours per week or less? | SELECT MIN(salary) FROM healthcare_unions WHERE hours_worked <= 35; | gretelai_synthetic_text_to_sql |
CREATE TABLE exhibitions (id INT, name VARCHAR(100), visitors INT); INSERT INTO exhibitions (id, name, visitors) VALUES (1, 'Modern Art', 1500), (2, 'Ancient History', 800); | List all exhibitions with more than 1000 visitors. | SELECT name FROM exhibitions WHERE visitors > 1000; | gretelai_synthetic_text_to_sql |
CREATE TABLE rural_innovations (id INT, project_name VARCHAR(50), funding_org VARCHAR(50)); INSERT INTO rural_innovations (id, project_name, funding_org) VALUES (1, 'Precision Agriculture', 'InnovateAfrica'), (2, 'Smart Greenhouses', 'GrowMoreFund'); CREATE TABLE economic_diversification (id INT, initiative_name VARCHA... | Which economic diversification initiatives from the 'economic_diversification' table have the same funding organization as any agricultural innovation projects in the 'rural_innovations' table? | SELECT initiative_name FROM economic_diversification WHERE funding_org IN (SELECT funding_org FROM rural_innovations); | gretelai_synthetic_text_to_sql |
CREATE TABLE EnergyEfficientBuildings (region VARCHAR(50), certification VARCHAR(50)); | How many energy efficient buildings are there in the 'Northeast' region with a Platinum LEED certification? | SELECT COUNT(*) FROM EnergyEfficientBuildings WHERE region = 'Northeast' AND certification = 'Platinum LEED'; | gretelai_synthetic_text_to_sql |
CREATE TABLE mobile_data_usage (usage_id INT, subscriber_id INT, data_usage FLOAT, usage_date DATE); INSERT INTO mobile_data_usage (usage_id, subscriber_id, data_usage, usage_date) VALUES (1, 1, 200, '2022-03-01'), (2, 2, 150, '2022-03-02'), (3, 3, 250, '2022-03-03'), (4, 4, 300, '2022-03-04'), (5, 5, 400, '2022-03-05'... | What is the top 5 most data-intensive days for mobile subscribers in the past month? | SELECT usage_date, SUM(data_usage) AS total_data_usage FROM mobile_data_usage WHERE usage_date >= DATE_SUB(CURDATE(), INTERVAL 1 MONTH) GROUP BY usage_date ORDER BY total_data_usage DESC LIMIT 5; | gretelai_synthetic_text_to_sql |
CREATE TABLE Construction_Projects (id INT, project_name TEXT, state TEXT, labor_cost INT); | What is the average labor cost for construction projects in Texas? | SELECT AVG(labor_cost) FROM Construction_Projects WHERE state = 'Texas'; | gretelai_synthetic_text_to_sql |
CREATE TABLE AgeGroups (id INT, age_range VARCHAR(20)); INSERT INTO AgeGroups (id, age_range) VALUES (1, '18-24'), (2, '25-34'), (3, '35-44'); CREATE TABLE Donors (id INT, age_group INT, donation_id INT); INSERT INTO Donors (id, age_group, donation_id) VALUES (1, 1, 1001), (2, 2, 1002), (3, 3, 1003); CREATE TABLE Donat... | What is the total amount donated per age group? | SELECT g.age_range, SUM(d.amount) as total_amount FROM Donors g JOIN Donations d ON g.id = d.donor_id GROUP BY g.age_range; | gretelai_synthetic_text_to_sql |
CREATE TABLE hospitals(id INT, name TEXT, location TEXT, rurality_score FLOAT); INSERT INTO hospitals(id, name, location, rurality_score) VALUES (1, 'Hospital A', 'Texas', 0.6), (2, 'Hospital B', 'Texas', 0.3), (3, 'Hospital C', 'California', 0.8); | What is the number of hospitals and their respective rurality scores in Texas? | SELECT COUNT(*) as hospital_count, rurality_score FROM hospitals WHERE location = 'Texas' GROUP BY rurality_score; | gretelai_synthetic_text_to_sql |
CREATE TABLE union_members (id INT, union_name VARCHAR(30), sector VARCHAR(20)); INSERT INTO union_members (id, union_name, sector) VALUES (1, 'Union A', 'manufacturing'), (2, 'Union B', 'education'), (3, 'Union C', 'manufacturing'), (4, 'Union D', 'technology'), (5, 'Union E', 'technology'); CREATE TABLE collective_ba... | What is the percentage of union members involved in collective bargaining in each sector? | SELECT sector, (COUNT(*) * 100.0 / (SELECT SUM(num_members) FROM (SELECT COUNT(*) AS num_members FROM union_members WHERE sector = u.sector) t)) AS percentage FROM union_members u LEFT JOIN collective_bargaining cb ON u.id = cb.union_id GROUP BY sector; | gretelai_synthetic_text_to_sql |
CREATE TABLE Art_Collaboration (artist_1 VARCHAR(255), artist_2 VARCHAR(255)); | Find all collaborations between 'Pablo Picasso' and 'Georges Braque'. | SELECT artist_1, artist_2 FROM Art_Collaboration WHERE (artist_1 = 'Pablo Picasso' AND artist_2 = 'Georges Braque') OR (artist_1 = 'Georges Braque' AND artist_2 = 'Pablo Picasso'); | gretelai_synthetic_text_to_sql |
CREATE TABLE sustainable_tourism (initiative_id INT, name TEXT, country TEXT); INSERT INTO sustainable_tourism VALUES (1, 'Sustainable Copenhagen Tour', 'Denmark'), (2, 'Eco-friendly Norwegian Fjords', 'Norway'); | How many sustainable tourism initiatives are there in total in Denmark and Norway? | SELECT COUNT(*) FROM sustainable_tourism WHERE country IN ('Denmark', 'Norway'); | gretelai_synthetic_text_to_sql |
CREATE TABLE crime_data (id INT, type VARCHAR(255), location VARCHAR(255), reported_date DATE); INSERT INTO crime_data (id, type, location, reported_date) VALUES (1, 'Theft', 'Park', '2021-01-01'); CREATE TABLE community_policing (id INT, type VARCHAR(255), location VARCHAR(255), reported_date DATE); INSERT INTO commun... | What is the total number of crimes reported in 'crime_data' and 'community_policing' tables? | SELECT COUNT(*) FROM crime_data UNION SELECT COUNT(*) FROM community_policing; | gretelai_synthetic_text_to_sql |
CREATE TABLE Users (UserID INT, Age INT, UsedTech4Good BOOLEAN); INSERT INTO Users (UserID, Age, UsedTech4Good) VALUES (1, 34, true), (2, 45, false), (3, 29, true); | What is the minimum age of users who have used technology for social good? | SELECT MIN(Age) FROM Users WHERE UsedTech4Good = true; | gretelai_synthetic_text_to_sql |
CREATE TABLE impact (id INT, mining_operation TEXT, year INT, score FLOAT); INSERT INTO impact (id, mining_operation, year, score) VALUES (1, 'Operation A', 2004, 85.6); INSERT INTO impact (id, mining_operation, year, score) VALUES (2, 'Operation B', 2005, 34.8); | What is the minimum environmental impact score for mining operations in Year 2005? | SELECT MIN(score) FROM impact WHERE year = 2005 AND mining_operation LIKE '%Mining%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE tour_operators (id INT, country VARCHAR(255), certification VARCHAR(255)); INSERT INTO tour_operators (id, country, certification) VALUES (1, 'Australia', 'EcoCert'), (2, 'Australia', 'Green Globe'), (3, 'Australia', NULL), (4, 'Canada', 'Green Tourism'), (5, 'Canada', NULL), (6, 'New Zealand', 'Qualmark')... | List all sustainable tourism certifications and the number of associated tour operators in each country. | SELECT country, certification, COUNT(*) AS num_tour_operators FROM tour_operators WHERE certification IS NOT NULL GROUP BY country, certification; | gretelai_synthetic_text_to_sql |
CREATE TABLE Spacecraft(id INT, organization VARCHAR(255), name VARCHAR(255), capacity INT); INSERT INTO Spacecraft(id, organization, name, capacity) VALUES (1, 'ROSCOSMOS', 'Spacecraft 1', 7), (2, 'NASA', 'Spacecraft 2', 4), (3, 'ROSCOSMOS', 'Spacecraft 3', 8); | What is the maximum number of passengers carried by a single spacecraft of ROSCOSMOS? | SELECT MAX(capacity) FROM Spacecraft WHERE organization = 'ROSCOSMOS'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Routes (RouteID int, RouteName varchar(255)); INSERT INTO Routes (RouteID, RouteName) VALUES (1, 'North'); CREATE TABLE Trips (TripID int, RouteID int, Fare double, TripDateTime datetime); CREATE TABLE PeakHours (PeakHourID int, StartTime time, EndTime time); INSERT INTO PeakHours (PeakHourID, StartTime, E... | What is the average fare for passengers using the 'North' bus route during peak hours? | SELECT AVG(Fare) FROM Routes JOIN Trips ON Routes.RouteID = Trips.RouteID JOIN PeakHours ON Trips.TripDateTime BETWEEN PeakHours.StartTime AND PeakHours.EndTime WHERE Routes.RouteName = 'North'; | gretelai_synthetic_text_to_sql |
CREATE TABLE players (player_id INT, name TEXT, team TEXT, position TEXT, points_per_game FLOAT); INSERT INTO players (player_id, name, team, position, points_per_game) VALUES (1, 'John Doe', 'Boston Celtics', 'Guard', 23.4), (2, 'Jane Smith', 'Philadelphia 76ers', 'Forward', 21.2); | Which basketball players have the highest scoring average in the Eastern Conference? | SELECT p.name, p.points_per_game FROM players p WHERE p.team IN (SELECT t.team FROM teams t WHERE t.conference = 'Eastern') ORDER BY p.points_per_game DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE fabrics (id INT PRIMARY KEY, fabric_name VARCHAR(50), is_sustainable BOOLEAN); | Insert a new sustainable fabric type 'Organic Linen' into the 'fabrics' table | INSERT INTO fabrics (id, fabric_name, is_sustainable) VALUES (1, 'Organic Linen', true); | gretelai_synthetic_text_to_sql |
CREATE TABLE weather_data (region VARCHAR(255), year INT, rainfall FLOAT); INSERT INTO weather_data (region, year, rainfall) VALUES ('Caldas', 2010, 2200), ('Caldas', 2011, 2500), ('Quindio', 2010, 1800), ('Quindio', 2011, 2000), ('Huila', 2010, 1500), ('Huila', 2011, 1700); | What is the average annual rainfall in the coffee-growing regions of Colombia? | SELECT AVG(rainfall) FROM weather_data WHERE region IN ('Caldas', 'Quindio', 'Huila'); | gretelai_synthetic_text_to_sql |
CREATE TABLE artifacts (id INT PRIMARY KEY, site_id INT, artifact_id INT, description TEXT); | insert a new artifact record into the artifacts table | INSERT INTO artifacts (id, site_id, artifact_id, description) VALUES (1, 123, 456, 'Small pottery shard with intricate geometric patterns'); | gretelai_synthetic_text_to_sql |
CREATE TABLE ports (port_id INT, port_name VARCHAR(50), city VARCHAR(50), country VARCHAR(50)); CREATE TABLE cargo (cargo_id INT, port_id INT, weight FLOAT, handling_date DATE); | Find the total cargo weight handled at the port of 'Los Angeles', partitioned by year and month. | SELECT YEAR(handling_date) AS handling_year, MONTH(handling_date) AS handling_month, SUM(weight) AS total_weight FROM cargo WHERE port_id = (SELECT port_id FROM ports WHERE port_name = 'Los Angeles') GROUP BY YEAR(handling_date), MONTH(handling_date); | gretelai_synthetic_text_to_sql |
CREATE TABLE agroecological_projects (project_id INT, name TEXT, location TEXT, website TEXT, city TEXT, state TEXT, country TEXT); INSERT INTO agroecological_projects (project_id, name, location, website, city, state, country) VALUES (1, 'Sustainable Fields', 'rural area', 'sustainablefields.org', 'Puebla', '', 'Mexic... | List all the agroecological projects in Mexico with their respective websites. | SELECT name, website FROM agroecological_projects WHERE country = 'Mexico'; | gretelai_synthetic_text_to_sql |
CREATE TABLE publications (id INT, student_type VARCHAR(10), department VARCHAR(10), year INT); INSERT INTO publications (id, student_type, department, year) VALUES (1, 'graduate', 'Chemistry', 2019), (2, 'undergraduate', 'Biology', 2020), (3, 'graduate', 'Computer Science', 2020); | What is the number of graduate students in the Computer Science department who have published at least one paper? | SELECT COUNT(DISTINCT id) FROM publications WHERE student_type = 'graduate' AND department = 'Computer Science'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Menu (item_id INT, name VARCHAR(50), is_vegan BOOLEAN, price DECIMAL(5,2)); INSERT INTO Menu (item_id, name, is_vegan, price) VALUES (1, 'Vegan Burger', true, 12.99), (2, 'Fries', false, 3.99), (3, 'Vegan Pizza', true, 14.99); | What is the average price of vegan dishes on the menu? | SELECT AVG(price) FROM Menu WHERE is_vegan = true; | gretelai_synthetic_text_to_sql |
CREATE TABLE autonomous_driving_research (id INT PRIMARY KEY, company VARCHAR(255), country VARCHAR(255)); | Insert the following records into the 'autonomous_driving_research' table: 'Zoox' with 'USA', 'Aptiv' with 'USA' | INSERT INTO autonomous_driving_research (company, country) VALUES ('Zoox', 'USA'), ('Aptiv', 'USA'); | gretelai_synthetic_text_to_sql |
CREATE TABLE City (id INT, name VARCHAR, population INT, PRIMARY KEY(id)); INSERT INTO City (id, name, population) VALUES (1, 'NYC', 8500000); INSERT INTO City (id, name, population) VALUES (2, 'LA', 4000000); INSERT INTO City (id, name, population) VALUES (3, 'Sydney', 2500000); CREATE TABLE ElectricVehicle (id INT, c... | How many electric and autonomous vehicle models are available in cities with a population less than 3 million? | SELECT COUNT(DISTINCT E.model) + COUNT(DISTINCT A.model) as total_models FROM City C LEFT JOIN ElectricVehicle E ON C.id = E.city_id LEFT JOIN AutonomousVehicle A ON C.id = A.city_id WHERE C.population < 3000000; | gretelai_synthetic_text_to_sql |
CREATE TABLE Employee (Employee_ID INT, First_Name VARCHAR(50), Last_Name VARCHAR(50), Position VARCHAR(50), Department VARCHAR(50), Division VARCHAR(50), Annual_Salary DECIMAL(10,2), Date_Hired DATE); CREATE TABLE Department_Organization (Department_ID INT, Department VARCHAR(50), Division VARCHAR(50)); | Identify the highest-paid employee for each department in the Engineering division. | SELECT E.Employee_ID, E.First_Name, E.Last_Name, E.Department, E.Division, E.Annual_Salary FROM Employee E JOIN (SELECT Department, MAX(Annual_Salary) AS Max_Salary FROM Employee WHERE Division = 'Engineering' GROUP BY Department) M ON E.Department = M.Department AND E.Annual_Salary = M.Max_Salary; | gretelai_synthetic_text_to_sql |
CREATE TABLE chemical_production (production_date DATE, chemical_code VARCHAR(10), quantity INT); INSERT INTO chemical_production (production_date, chemical_code, quantity) VALUES ('2021-01-03', 'A123', 450), ('2021-01-07', 'A123', 620), ('2021-01-12', 'A123', 390); | Get the chemical code and production_date for the records with the highest production quantity | SELECT chemical_code, production_date, quantity FROM chemical_production WHERE (chemical_code, quantity) IN (SELECT chemical_code, MAX(quantity) FROM chemical_production GROUP BY chemical_code); | gretelai_synthetic_text_to_sql |
CREATE TABLE companies (id INT, name TEXT, region TEXT, funding INT); INSERT INTO companies (id, name, region, funding) VALUES (1, 'Rho Corp', 'EMEA', 4000000), (2, 'Sigma Ltd', 'APAC', 5000000); | What is the average funding amount for companies in EMEA and APAC regions? | SELECT region, AVG(funding) FROM companies WHERE region IN ('EMEA', 'APAC') GROUP BY region; | gretelai_synthetic_text_to_sql |
CREATE TABLE clients (client_id INT, name VARCHAR(50), region VARCHAR(50));CREATE TABLE investments (investment_id INT, client_id INT, market VARCHAR(50), value INT);INSERT INTO clients (client_id, name, region) VALUES (1, 'John Doe', 'North America'), (2, 'Barbara Black', 'Asia');INSERT INTO investments (investment_id... | What is the total investment value for all clients with a last name starting with 'B'? | SELECT SUM(i.value) FROM clients c INNER JOIN investments i ON c.client_id = i.client_id WHERE SUBSTRING(c.name, 1, 1) = 'B'; | gretelai_synthetic_text_to_sql |
CREATE TABLE space_missions (id INT, mission_name VARCHAR(255), country VARCHAR(255), cost FLOAT); INSERT INTO space_missions (id, mission_name, country, cost) VALUES (1, 'Apollo 11', 'USA', 25500000), (2, 'Mars Orbiter Mission', 'India', 73000000), (3, 'Chandrayaan-1', 'India', 79000000), (4, 'Grail', 'USA', 496000000... | What was the total cost of space missions led by countries other than the USA? | SELECT SUM(cost) FROM space_missions WHERE country != 'USA'; | gretelai_synthetic_text_to_sql |
CREATE TABLE art_movements (id INT, movement_name VARCHAR(50)); CREATE TABLE artwork_value (id INT, artwork_name VARCHAR(50), movement_id INT, value DECIMAL(10, 2)); | Find the total value of all artworks in the Surrealism movement. | SELECT SUM(value) as total_value FROM artwork_value WHERE movement_id = (SELECT id FROM art_movements WHERE movement_name = 'Surrealism'); | gretelai_synthetic_text_to_sql |
CREATE TABLE teachers (teacher_id INT, name VARCHAR(50), state VARCHAR(20), teacher_certification VARCHAR(5)); | Update the 'teacher_certification' column in the 'teachers' table to 'yes' if the 'state' is 'California' | UPDATE teachers SET teacher_certification = 'yes' WHERE state = 'California'; | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_mammals (mammal_id INT, name VARCHAR(50), population INT, habitat VARCHAR(50)); INSERT INTO marine_mammals (mammal_id, name, population, habitat) VALUES (1, 'Polar Bear', 25000, 'Arctic'), (2, 'Walrus', 19000, 'Arctic'); | Which marine mammals are found in the Arctic and have a population size greater than 5000? | SELECT name FROM marine_mammals WHERE habitat = 'Arctic' AND population > 5000; | gretelai_synthetic_text_to_sql |
CREATE TABLE ticket_sales (team_name VARCHAR(50), tickets_sold INT, revenue DECIMAL(10,2)); INSERT INTO ticket_sales (team_name, tickets_sold, revenue) VALUES ('Team A Stadium', 1000, 25000.00), ('Team B Arena', 800, 20000.00), ('Stadium City FC', 1200, 32000.00), ('Team D Field', 900, 21000.00), ('Arena City FC', 700,... | What is the total number of tickets sold and the total revenue for teams that have 'Arena' in their name? | SELECT SUM(tickets_sold) AS total_tickets_sold, SUM(revenue) AS total_revenue FROM ticket_sales WHERE team_name LIKE '%Arena%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE AIEthicsBudget(initiative VARCHAR(255), region VARCHAR(255), budget DECIMAL(10,2));INSERT INTO AIEthicsBudget(initiative, region, budget) VALUES('Bias Mitigation', 'Asia', 50000.00), ('Transparency', 'Africa', 45000.00), ('Fairness', 'Asia', 60000.00), ('Accountability', 'Africa', 55000.00); | What is the average budget allocated for AI ethics initiatives in Asia and Africa? | SELECT AVG(budget) FROM AIEthicsBudget WHERE region IN ('Asia', 'Africa'); | gretelai_synthetic_text_to_sql |
CREATE TABLE Exhibitions_Break_Even (exhibition_id INT, city VARCHAR(50), min_visitors INT); | What is the minimum number of visitors required to break even for each exhibition in San Francisco? | SELECT exhibition_id, min_visitors FROM Exhibitions_Break_Even WHERE city = 'San Francisco'; | gretelai_synthetic_text_to_sql |
CREATE TABLE transportation_system (id INT, vehicle_name TEXT, type TEXT);INSERT INTO transportation_system (id, vehicle_name, type) VALUES (1, 'BusA', 'Public'), (2, 'CarB', 'Private'), (3, 'BusC', 'Public'); | What is the total number of public transportation vehicles in use in the transportation system? | SELECT COUNT(*) FROM transportation_system WHERE type = 'Public'; | gretelai_synthetic_text_to_sql |
CREATE TABLE articles (article_id INT, title VARCHAR(100), category VARCHAR(50), publication_date DATE, views INT); INSERT INTO articles (article_id, title, category, publication_date, views) VALUES (1, 'News from the Capital', 'Politics', '2022-01-01', 1500), (2, 'Tech Innovations in 2022', 'Technology', '2022-01-02',... | List the top 3 news categories with the highest number of articles in the "articles" table. | SELECT category, COUNT(*) as article_count FROM articles GROUP BY category ORDER BY article_count DESC LIMIT 3; | gretelai_synthetic_text_to_sql |
CREATE TABLE new_york_water_use (year INT, population INT, water_consumption INT); INSERT INTO new_york_water_use (year, population, water_consumption) VALUES (2020, 8500000, 850000000), (2021, 8600000, 860000000); | What is the average water consumption per capita in New York City for the year 2020? | SELECT AVG(new_york_water_use.water_consumption / new_york_water_use.population) as avg_water_consumption FROM new_york_water_use WHERE new_york_water_use.year = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE Archaeologists (id INT PRIMARY KEY, name VARCHAR(255), specialty TEXT, years_experience INT); INSERT INTO Archaeologists (id, name, specialty, years_experience) VALUES (1, 'Dr. Jane Doe', 'Egyptology', 20), (2, 'Dr. John Smith', 'Mayan Civilization', 15), (3, 'Dr. Maria Lopez', 'Inca Civilization', 18); | List all archaeologists who specialize in a specific field | SELECT * FROM Archaeologists WHERE specialty = 'Egyptology'; | gretelai_synthetic_text_to_sql |
CREATE TABLE companies (id INT, name TEXT, country TEXT); CREATE TABLE fundings (id INT, company_id INT, round TEXT, country TEXT); INSERT INTO companies (id, name, country) VALUES (1, 'Acme Inc', 'USA'), (2, 'Zebra Corp', 'Canada'), (3, 'Dino Tech', 'USA'), (4, 'Elephant Inc', 'Canada'), (5, 'Fox Enterprises', 'USA');... | List the companies that have received funding in both the USA and Canada. | SELECT companies.name FROM companies INNER JOIN fundings AS us_fundings ON companies.id = us_fundings.company_id AND us_fundings.country = 'USA' INNER JOIN fundings AS canada_fundings ON companies.id = canada_fundings.company_id AND canada_fundings.country = 'Canada' GROUP BY companies.name HAVING COUNT(DISTINCT compan... | gretelai_synthetic_text_to_sql |
CREATE TABLE PlayerGameGenres (PlayerID INT, GameGenre VARCHAR(20)); INSERT INTO PlayerGameGenres (PlayerID, GameGenre) VALUES (1, 'Action'), (1, 'Adventure'), (2, 'Strategy'), (2, 'Simulation'), (3, 'Simulation'), (3, 'Virtual Reality'); | How many players from 'Germany' have played a game in the 'Simulation' genre in the last month? | SELECT COUNT(DISTINCT PlayerID) FROM PlayerGameGenres INNER JOIN Players ON PlayerGameGenres.PlayerID = Players.PlayerID WHERE Country = 'Germany' AND GameGenre = 'Simulation' AND LastPurchaseDate >= DATEADD(month, -1, GETDATE()); | gretelai_synthetic_text_to_sql |
CREATE TABLE organizations (id INT, name VARCHAR(100)); CREATE TABLE us_donations (id INT, organization_id INT, amount DECIMAL(10,2)); CREATE TABLE canada_donations (id INT, organization_id INT, amount DECIMAL(10,2)); INSERT INTO organizations (id, name) VALUES (1, 'Organization A'), (2, 'Organization B'), (3, 'Organiz... | Which organizations have not received any donations? | SELECT o.name FROM organizations o LEFT JOIN (SELECT * FROM us_donations UNION ALL SELECT * FROM canada_donations) d ON o.id = d.organization_id WHERE d.organization_id IS NULL; | gretelai_synthetic_text_to_sql |
CREATE TABLE legal_precedents (precedent_id INT, case_id INT, billing_amount FLOAT); INSERT INTO legal_precedents (precedent_id, case_id, billing_amount) VALUES (1, 1, 300.0), (2, 2, 400.0), (3, 3, 500.0); | What is the maximum billing amount for cases in the legal precedents table? | SELECT MAX(billing_amount) FROM legal_precedents; | gretelai_synthetic_text_to_sql |
CREATE TABLE sustainable_tours (tour_id INT, tour_name TEXT, country TEXT, revenue FLOAT); INSERT INTO sustainable_tours (tour_id, tour_name, country, revenue) VALUES (1, 'Wind Farm Visit', 'Germany', 3000), (2, 'Solar Panel Farm', 'Germany', 4000); | What is the maximum revenue generated by sustainable tours in Germany? | SELECT MAX(revenue) FROM sustainable_tours WHERE country = 'Germany'; | gretelai_synthetic_text_to_sql |
CREATE TABLE clients (client_id INT, name TEXT, region TEXT); INSERT INTO clients (client_id, name, region) VALUES (1, 'John Doe', 'US'), (2, 'Jane Smith', 'APAC'), (3, 'Mike Johnson', 'EU'); CREATE TABLE investments (client_id INT, fund_id INT, amount DECIMAL(10, 2)); INSERT INTO investments (client_id, fund_id, amoun... | Delete records of clients from the 'clients' table who have not invested in any funds. | DELETE FROM clients WHERE client_id NOT IN (SELECT c.client_id FROM clients c JOIN investments i ON c.client_id = i.client_id); | gretelai_synthetic_text_to_sql |
CREATE TABLE Events (EventID INT, EventType TEXT, Country TEXT); INSERT INTO Events (EventID, EventType, Country) VALUES (1, 'Concert', 'Germany'), (2, 'Exhibition', 'France'), (3, 'Concert', 'Germany'); CREATE TABLE Attendees (AttendeeID INT, EventID INT); INSERT INTO Attendees (AttendeeID, EventID) VALUES (1, 1), (2,... | How many unique attendees were there at concerts in Germany? | SELECT COUNT(DISTINCT AttendeeID) FROM Attendees A JOIN Events E ON A.EventID = E.EventID WHERE E.EventType = 'Concert' AND E.Country = 'Germany'; | gretelai_synthetic_text_to_sql |
CREATE TABLE manufacturers (id INT PRIMARY KEY, name VARCHAR(255), country VARCHAR(255)); CREATE TABLE chemical_inspections (id INT PRIMARY KEY, chemical_id INT, hazard_type VARCHAR(255), inspection_date DATE); | What are the names, hazard types, and inspection dates of all chemicals from the 'chemical_inspections' and 'chemicals' tables where the manufacturer is based in India? | SELECT c.name, ci.hazard_type, ci.inspection_date FROM chemical_inspections ci INNER JOIN chemicals c ON ci.chemical_id = c.id INNER JOIN manufacturers m ON c.manufacturer_id = m.id WHERE m.country = 'India'; | gretelai_synthetic_text_to_sql |
CREATE TABLE donations_date (donation_id INT, donation_date DATE); INSERT INTO donations_date (donation_id, donation_date) VALUES (1, '2022-01-01'), (2, '2022-02-15'), (3, '2022-01-20'), (4, '2022-03-05'); | How many donations were made in each month of 2022? | SELECT EXTRACT(MONTH FROM donation_date) as month, COUNT(*) as num_donations FROM donations_date GROUP BY month; | gretelai_synthetic_text_to_sql |
CREATE TABLE mitigation_projects (id INT PRIMARY KEY, name VARCHAR(100), location VARCHAR(50), start_date DATE, end_date DATE, budget DECIMAL(10,2)); DROP TABLE mitigation_projects; | Drop the 'mitigation_projects' table | DROP TABLE mitigation_projects; | 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.