context stringlengths 11 9.12k | question stringlengths 0 1.06k | SQL stringlengths 2 4.44k | source stringclasses 28
values |
|---|---|---|---|
CREATE TABLE articles (article_id INT, author VARCHAR(50), title VARCHAR(100), category VARCHAR(50), word_count INT, publication_date DATE); | What is the total number of articles published by each author in a specific month of a specific year? | SELECT author, EXTRACT(MONTH FROM publication_date) AS month, COUNT(article_id) AS articles_in_month FROM articles WHERE EXTRACT(YEAR FROM publication_date) = 2022 AND EXTRACT(MONTH FROM publication_date) = 12 GROUP BY author, month; | gretelai_synthetic_text_to_sql |
CREATE TABLE authors_articles (author_id INT, article_id INT); INSERT INTO authors_articles (author_id, article_id) VALUES (1, 1), (1, 2), (2, 3);CREATE TABLE authors (id INT, name VARCHAR(50)); INSERT INTO authors (id, name) VALUES (1, 'Alice'), (2, 'Bob'); | What is the name of the author who has published the least articles? | SELECT authors.name FROM authors JOIN (SELECT author_id, COUNT(*) as article_count FROM authors_articles GROUP BY author_id ORDER BY article_count ASC LIMIT 1) as article_counts ON authors.id = article_counts.author_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE waste (plant varchar(10), year int, waste_amount int); INSERT INTO waste (plant, year, waste_amount) VALUES ('North Plant', 2020, 150), ('North Plant', 2019, 140), ('West Plant', 2020, 200), ('West Plant', 2019, 180); | What was the total waste produced by the 'West Coast' plant in 2020? | SELECT SUM(waste_amount) FROM waste WHERE plant = 'West Plant' AND year = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE company (id INT, name TEXT, founding_year INT, founder_gender TEXT, founder_ethnicity TEXT); INSERT INTO company (id, name, founding_year, founder_gender, founder_ethnicity) VALUES (1, 'TechFuturo', 2018, 'male', 'Latinx'); INSERT INTO company (id, name, founding_year, founder_gender, founder_ethnicity) VA... | What is the average funding round size for startups founded by Latinx individuals? | SELECT AVG(funding_round.round_amount) FROM company JOIN funding_round ON company.id = funding_round.company_id WHERE company.founder_ethnicity = 'Latinx'; | gretelai_synthetic_text_to_sql |
CREATE TABLE facility (id INT, name VARCHAR(50), type VARCHAR(50), capacity INT); | Insert a new healthcare facility into the facility table. | INSERT INTO facility (id, name, type, capacity) VALUES (3, 'New Hope Clinic', 'Community Health Center', 150); | gretelai_synthetic_text_to_sql |
CREATE TABLE skincare (id INT, name VARCHAR(255), natural_ingredients BOOLEAN, country VARCHAR(255), sales INT); INSERT INTO skincare (id, name, natural_ingredients, country, sales) VALUES (1, 'Cleanser', true, 'USA', 100), (2, 'Toner', false, 'Canada', 50), (3, 'Moisturizer', true, 'USA', 200); | How many skincare products contain natural ingredients and were sold in the US? | SELECT COUNT(*) FROM skincare WHERE natural_ingredients = true AND country = 'USA'; | gretelai_synthetic_text_to_sql |
CREATE TABLE station_usage (station_name VARCHAR(255), user_id INT, usage_date DATE); INSERT INTO station_usage (station_name, user_id, usage_date) VALUES ('Times Square', 1, '2022-03-29'), ('Grand Central', 2, '2022-03-28'), ('Times Square', 3, '2022-03-27'), ('Union Station', 4, '2022-03-26'), ('Union Station', 5, '2... | Find the top 5 busiest subway stations in terms of unique users in the last week. | SELECT station_name, COUNT(DISTINCT user_id) AS unique_users FROM station_usage WHERE usage_date >= DATEADD(day, -7, CURRENT_DATE) GROUP BY station_name ORDER BY unique_users DESC LIMIT 5 | gretelai_synthetic_text_to_sql |
CREATE TABLE WeeklyStreams (StreamID INT, TrackID INT, PlatformID INT, Date DATE, Streams INT); INSERT INTO WeeklyStreams (StreamID, TrackID, PlatformID, Date, Streams) VALUES (1, 1, 4, '2022-01-01', 100); | What is the total number of streams for electronic music on TikTok, grouped by week? | SELECT EXTRACT(WEEK FROM Date) as Week, EXTRACT(YEAR FROM Date) as Year, SUM(Streams) as TotalStreams FROM WeeklyStreams JOIN Tracks ON WeeklyStreams.TrackID = Tracks.TrackID JOIN StreamingPlatforms ON WeeklyStreams.PlatformID = StreamingPlatforms.PlatformID WHERE Genre = 'Electronic' AND PlatformName = 'TikTok' GROUP ... | gretelai_synthetic_text_to_sql |
CREATE TABLE weather (id INT, region_id INT, temperature_c FLOAT, date DATE); | What was the minimum temperature (in Celsius) recorded in each region in 2020? | SELECT region_id, MIN(temperature_c) FROM weather WHERE YEAR(date) = 2020 GROUP BY region_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE AgriculturalProjects (id INT PRIMARY KEY, name VARCHAR(50), location VARCHAR(50), sector VARCHAR(20), start_date DATE, end_date DATE); INSERT INTO AgriculturalProjects (id, name, location, sector, start_date, end_date) VALUES (1, 'Solar Irrigation', 'Rural Kenya', 'Agricultural Innovation', '2020-01-01', '... | What were the names and locations of agricultural projects that started in 2021? | SELECT name, location FROM AgriculturalProjects WHERE start_date >= '2021-01-01' AND start_date < '2022-01-01'; | gretelai_synthetic_text_to_sql |
CREATE TABLE organizations (id INT, disaster_id INT, amount FLOAT); CREATE TABLE disasters (id INT, name VARCHAR(255)); | List the number of unique organizations and total amount donated for each disaster response. | SELECT d.name, COUNT(DISTINCT organizations.id) as organization_count, SUM(organizations.amount) as total_donated FROM disasters d LEFT JOIN organizations ON d.id = organizations.disaster_id GROUP BY d.id; | gretelai_synthetic_text_to_sql |
CREATE TABLE intelligence_operations (id INT, operation_name VARCHAR(50), location VARCHAR(50)); INSERT INTO intelligence_operations (id, operation_name, location) VALUES (1, 'Operation Horn of Africa', 'Africa'), (2, 'Operation Juniper Shield', 'Middle East'), (3, 'Operation Okra', 'Middle East'); | What are the details of intelligence operations in Africa? | SELECT * FROM intelligence_operations WHERE location = 'Africa'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Crop (id INT, type TEXT, region TEXT, planting_date DATE); | How many crop types were grown in each region in 2019? | SELECT region, COUNT(DISTINCT type) as num_crop_types FROM Crop WHERE EXTRACT(YEAR FROM planting_date) = 2019 GROUP BY region; | gretelai_synthetic_text_to_sql |
CREATE TABLE EcoFriendlyGarments (id INT, garment_type VARCHAR(255), carbon_footprint INT); INSERT INTO EcoFriendlyGarments (id, garment_type, carbon_footprint) VALUES (1, 'Dress', 4), (2, 'Skirt', 2), (3, 'Jacket', 6); | What is the average carbon footprint of a garment in the EcoFriendlyGarments table? | SELECT AVG(carbon_footprint) FROM EcoFriendlyGarments; | gretelai_synthetic_text_to_sql |
CREATE TABLE circular_economy_initiatives (region VARCHAR(20), year INT, spending INT); INSERT INTO circular_economy_initiatives (region, year, spending) VALUES ('West', 2020, 900000), ('West', 2021, 950000), ('East', 2020, 800000), ('East', 2021, 850000); | What was the total circular economy initiative spending in the 'West' region in 2021? | SELECT SUM(spending) FROM circular_economy_initiatives WHERE region = 'West' AND year = 2021; | gretelai_synthetic_text_to_sql |
CREATE TABLE Companies (id INT, name TEXT, founder_gender TEXT); INSERT INTO Companies (id, name, founder_gender) VALUES (1, 'Daisy Enterprise', 'Female'); INSERT INTO Companies (id, name, founder_gender) VALUES (2, 'Bright Star Corp', 'Male'); CREATE TABLE Investors (id INT, name TEXT); INSERT INTO Investors (id, name... | List the names of investors who have invested in companies that have a female founder. | SELECT Investors.name FROM Companies INNER JOIN Investors ON TRUE WHERE Companies.founder_gender = 'Female'; | gretelai_synthetic_text_to_sql |
CREATE TABLE inmates (inmate_id INT, inmate_name VARCHAR(255), sentence_length INT, PRIMARY KEY (inmate_id)); INSERT INTO inmates (inmate_id, inmate_name, sentence_length) VALUES (1, 'Inmate 1', 60), (2, 'Inmate 2', 36), (3, 'Inmate 3', 72); | Display the names and sentences of all inmates who have been incarcerated for less than 3 years | SELECT inmate_name, sentence_length FROM inmates WHERE sentence_length < 36; | gretelai_synthetic_text_to_sql |
CREATE TABLE astronauts (id INT, name VARCHAR(50), gender VARCHAR(10), nationality VARCHAR(50), spacecraft VARCHAR(50)); | Find the number of female astronauts in the US space program | SELECT COUNT(*) FROM astronauts WHERE gender = 'female' AND nationality = 'United States'; | gretelai_synthetic_text_to_sql |
CREATE TABLE sustainable_materials (sustainable_material_id INT, sustainable_material_name VARCHAR(255), product_category VARCHAR(255)); INSERT INTO sustainable_materials (sustainable_material_id, sustainable_material_name, product_category) VALUES (1, 'Material X', 'Category X'), (2, 'Material Y', 'Category X'), (3, '... | Calculate the percentage of sustainable materials used in production for each product category | SELECT product_category, SUM(production_quantity) as total_production_quantity, SUM(CASE WHEN sustainable_material_id IS NOT NULL THEN production_quantity ELSE 0 END) as sustainable_production_quantity, (SUM(CASE WHEN sustainable_material_id IS NOT NULL THEN production_quantity ELSE 0 END) / SUM(production_quantity)) *... | gretelai_synthetic_text_to_sql |
CREATE TABLE Stations (StationID int, WheelchairAccessible bit); INSERT INTO Stations (StationID, WheelchairAccessible) VALUES (1, 1), (2, 0), (3, 1); | How many wheelchair-accessible stations are there in London? | SELECT COUNT(*) FROM Stations WHERE WheelchairAccessible = 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE Sales (SaleID INT, ArtworkID INT, Genre VARCHAR(20), Revenue FLOAT, Location VARCHAR(20)); INSERT INTO Sales (SaleID, ArtworkID, Genre, Revenue, Location) VALUES (1, 1, 'Surrealism', 4000.00, 'France'); CREATE TABLE Artworks (ArtworkID INT, ArtworkName VARCHAR(50)); INSERT INTO Artworks (ArtworkID, Artwork... | Find the total revenue generated from sales in the 'Surrealism' genre and the number of artworks sold in Europe. | SELECT SUM(Sales.Revenue), COUNT(Sales.SaleID) FROM Sales INNER JOIN Artworks ON Sales.ArtworkID = Artworks.ArtworkID WHERE Sales.Genre = 'Surrealism' AND Sales.Location = 'Europe'; | gretelai_synthetic_text_to_sql |
CREATE TABLE mobile_subscribers (id INT, name VARCHAR(255), state_id INT, monthly_data_usage DECIMAL(10,2));CREATE TABLE states (id INT, name VARCHAR(255), region VARCHAR(255)); | What is the average data usage per month for each mobile subscriber in the 'urban' regions, sorted alphabetically by subscriber name? | SELECT ms.name, AVG(ms.monthly_data_usage) as avg_data_usage FROM mobile_subscribers ms INNER JOIN states st ON ms.state_id = st.id WHERE st.region = 'urban' GROUP BY ms.name ORDER BY ms.name; | gretelai_synthetic_text_to_sql |
CREATE TABLE GraduateStudents (StudentID INT, Name VARCHAR(50), Department VARCHAR(50), AdvisorID INT); | Insert a new graduate student record | INSERT INTO GraduateStudents (StudentID, Name, Department, AdvisorID) VALUES (1001, 'Sara Smith', 'Computer Science', 2001); | gretelai_synthetic_text_to_sql |
CREATE TABLE impact_investments (id INT, region VARCHAR(20), investment_year INT, investment_amount FLOAT); INSERT INTO impact_investments (id, region, investment_year, investment_amount) VALUES (1, 'Asia', 2020, 150000), (2, 'Africa', 2019, 120000), (3, 'Asia', 2020, 180000); | How many impact investments were made in 'Asia' in the year 2020? | SELECT COUNT(*) FROM impact_investments WHERE region = 'Asia' AND investment_year = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE warehouses (id VARCHAR(10), name VARCHAR(20), city VARCHAR(10), country VARCHAR(10)); INSERT INTO warehouses (id, name, city, country) VALUES ('SEA-WH-01', 'Seattle Warehouse', 'Seattle', 'USA'); CREATE TABLE inventory (item VARCHAR(10), warehouse_id VARCHAR(10), quantity INT); INSERT INTO inventory (item,... | What is the total quantity of item 'Laptop' in warehouse 'SEA-WH-01'? | SELECT SUM(quantity) FROM inventory WHERE item = 'Laptop' AND warehouse_id = 'SEA-WH-01'; | gretelai_synthetic_text_to_sql |
CREATE TABLE VesselIncidents (id INT, vessel_id INT, incident_type VARCHAR(50), latitude DECIMAL(9,6), longitude DECIMAL(9,6), time TIMESTAMP); | Find the number of vessels that have had an incident in the Mediterranean sea | SELECT COUNT(vessel_id) FROM VesselIncidents vi WHERE ST_Intersects(ST_SetSRID(ST_MakePoint(longitude, latitude), 4326), ST_GeomFromText('POLYGON((19.45 37.00, 19.45 34.00, 29.55 34.00, 29.55 37.00, 19.45 37.00))', 4326)); | gretelai_synthetic_text_to_sql |
CREATE TABLE r_d_expenditure (drug VARCHAR(20), division VARCHAR(20), date DATE, expenditure NUMERIC(12, 2)); | Insert new R&D expenditure records for Q1 2024 into the r_d_expenditure table. | INSERT INTO r_d_expenditure (drug, division, date, expenditure) VALUES ('DrugD', 'Oncology', '2024-01-01', 120000.00), ('DrugE', 'Cardiology', '2024-01-01', 150000.00), ('DrugD', 'Neurology', '2024-01-01', 180000.00), ('DrugE', 'Oncology', '2024-01-01', 200000.00), ('DrugD', 'Cardiology', '2024-01-01', 130000.00), ('Dr... | gretelai_synthetic_text_to_sql |
CREATE TABLE fraud_detection (client_id INT, suspicious_activity VARCHAR(50), detection_date DATE); INSERT INTO fraud_detection (client_id, suspicious_activity, detection_date) VALUES (3, 'Phishing attempt', '2022-02-05'); INSERT INTO fraud_detection (client_id, suspicious_activity, detection_date) VALUES (4, 'Account ... | How many suspicious activities have been detected for each client? | SELECT client_id, COUNT(*) as number_of_suspicious_activities FROM fraud_detection GROUP BY client_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE rural_healthcare_workers (id INT, name TEXT, age INT, is_rural BOOLEAN); INSERT INTO rural_healthcare_workers (id, name, age, is_rural) VALUES (1, 'John Doe', 35, true), (2, 'Jane Smith', 40, false); | What is the average age of healthcare workers in rural areas? | SELECT AVG(age) FROM rural_healthcare_workers WHERE is_rural = true; | gretelai_synthetic_text_to_sql |
CREATE TABLE accessible_tech_projects (id INT, country VARCHAR(2), project_accessibility VARCHAR(10)); INSERT INTO accessible_tech_projects (id, country, project_accessibility) VALUES (1, 'US', 'yes'), (2, 'CA', 'no'), (3, 'MX', 'yes'), (4, 'BR', 'yes'), (5, 'AR', 'no'), (6, 'NG', 'yes'), (7, 'EG', 'no'), (8, 'ZA', 'ye... | What is the total number of accessible technology projects, and how many of those are in Africa? | SELECT COUNT(*) FROM accessible_tech_projects WHERE project_accessibility = 'yes' AND country IN ('NG', 'EG', 'ZA', 'ET', 'GH'); | gretelai_synthetic_text_to_sql |
CREATE TABLE landfill_capacity (location VARCHAR(50), current_capacity INT, projected_capacity INT, year INT); INSERT INTO landfill_capacity (location, current_capacity, projected_capacity, year) VALUES ('Mumbai', 45000, 55000, 2035); | What is the current landfill capacity in Mumbai and the projected capacity in 2035? | SELECT location, current_capacity, projected_capacity FROM landfill_capacity WHERE location = 'Mumbai' AND year = 2035; | gretelai_synthetic_text_to_sql |
CREATE TABLE fish_population (id INT, species TEXT, population INT, date DATE); | Which fish species have had a decline in population in the last 6 months? | SELECT species, (fp1.population - fp2.population) AS population_change FROM fish_population fp1 JOIN fish_population fp2 ON fp1.species = fp2.species WHERE fp1.date = (SELECT MAX(date) FROM fish_population) AND fp2.date = (SELECT MAX(date) - INTERVAL '6 months' FROM fish_population) AND population_change < 0; | gretelai_synthetic_text_to_sql |
CREATE TABLE Artworks (ArtworkID INT, Title VARCHAR(255), Period VARCHAR(255), MuseumID INT, Price INT); INSERT INTO Artworks VALUES (1, 'The Resurrection of Christ', 'Baroque', 5, 3000000); CREATE TABLE Museums (MuseumID INT, Name VARCHAR(255), Location VARCHAR(255)); INSERT INTO Museums VALUES (5, 'Gemäldegalerie', '... | What is the total price of artworks in the 'Baroque' period and in the 'Rococo' period in the 'Berlin' museum? | SELECT SUM(Artworks.Price) FROM Artworks INNER JOIN Museums ON Artworks.MuseumID = Museums.MuseumID WHERE (Artworks.Period = 'Baroque' OR Artworks.Period = 'Rococo') AND Museums.Location = 'Berlin'; | gretelai_synthetic_text_to_sql |
CREATE TABLE mobile_subscribers (subscriber_id INT, data_usage FLOAT, state VARCHAR(20)); INSERT INTO mobile_subscribers (subscriber_id, data_usage, state) VALUES (1, 3.5, 'NY'), (2, 4.2, 'NY'), (3, 3.8, 'NJ'), (4, 5.0, 'CA'), (5, 4.5, 'CA'); | What is the average monthly mobile data usage for customers in California? | SELECT AVG(data_usage) FROM mobile_subscribers WHERE state = 'CA'; | gretelai_synthetic_text_to_sql |
CREATE TABLE clean_energy_investments (id INT, country VARCHAR(255), year INT, investment_amount INT); INSERT INTO clean_energy_investments (id, country, year, investment_amount) VALUES (1, 'China', 2018, 4000000), (2, 'United Kingdom', 2019, 5000000); | What was the total investment in clean energy policy trends in China and the United Kingdom in 2018 and 2019? | SELECT SUM(investment_amount) FROM clean_energy_investments WHERE country IN ('China', 'United Kingdom') AND year IN (2018, 2019); | gretelai_synthetic_text_to_sql |
CREATE TABLE Volunteers (VolunteerID int, EventID int, Hours decimal(5,2)); INSERT INTO Volunteers (VolunteerID, EventID, Hours) VALUES (1, 100, 5.5), (2, 101, 7.2), (3, 100, 3.8), (4, 102, 6.5), (5, 101, 8.0); | Identify the number of unique volunteers who participated in events in NYC in 2020 and the average number of hours they contributed. | SELECT COUNT(DISTINCT VolunteerID), AVG(Hours) FROM Volunteers INNER JOIN (SELECT EventID FROM Events WHERE City = 'NYC') AS EventLocations ON Volunteers.EventID = EventLocations.EventID WHERE EXTRACT(YEAR FROM EventDate) = 2020; | gretelai_synthetic_text_to_sql |
CREATE TABLE wildlife (species VARCHAR(255), habitat_size FLOAT); INSERT INTO wildlife (species, habitat_size) VALUES ('Deer', 123.4), ('Bear', 145.6), ('Elk', 167.8), ('Wolf', 234.6), ('Fox', 256.7), ('Lynx', 345.2); | What is the average wildlife habitat size for each species, ranked by size? | SELECT species, AVG(habitat_size) AS avg_habitat_size FROM wildlife GROUP BY species ORDER BY AVG(habitat_size) DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE member_demographics (member_id INT, age INT, gender VARCHAR(10), city VARCHAR(50), state VARCHAR(20), country VARCHAR(50)); CREATE VIEW demographics_summary AS SELECT country, gender, city, COUNT(*) as member_count FROM member_demographics GROUP BY country, gender, city; | What is the count of members by country, grouped by gender and city, in the 'demographics_summary' view? | SELECT country, gender, city, SUM(member_count) FROM demographics_summary GROUP BY country, gender, city; | gretelai_synthetic_text_to_sql |
CREATE TABLE Astronaut_Medical_4 (Astronaut_ID INT, Medical_Condition VARCHAR(50), Medical_Condition_Duration INT); INSERT INTO Astronaut_Medical_4 (Astronaut_ID, Medical_Condition, Medical_Condition_Duration) VALUES (1, 'Fatigue', 14); INSERT INTO Astronaut_Medical_4 (Astronaut_ID, Medical_Condition, Medical_Condition... | What is the minimum medical condition duration for each unique medical condition? | SELECT Medical_Condition, MIN(Medical_Condition_Duration) as Minimum_Medical_Condition_Duration FROM Astronaut_Medical_4 GROUP BY Medical_Condition; | gretelai_synthetic_text_to_sql |
CREATE TABLE artists (id INT, name TEXT, age INT, num_works INT); INSERT INTO artists (id, name, age, num_works) VALUES (1, 'Picasso', 56, 550), (2, 'Van Gogh', 37, 210), (3, 'Monet', 86, 690); CREATE TABLE works (id INT, artist_id INT, category TEXT); INSERT INTO works (id, artist_id, category) VALUES (1, 1, 'painting... | List the names and ages of all artists who have created at least one work in the 'painting' category. | SELECT a.name, a.age FROM artists a JOIN works w ON a.id = w.artist_id WHERE w.category = 'painting'; | gretelai_synthetic_text_to_sql |
CREATE TABLE games (id INT, team_a TEXT, team_b TEXT, location TEXT, score_team_a INT, score_team_b INT, wins_team_a INT, wins_team_b INT); INSERT INTO games (id, team_a, team_b, location, score_team_a, score_team_b, wins_team_a, wins_team_b) VALUES (1, 'Team A', 'Team B', 'Away', 120, 130, 0, 1); | How many wins did Team C have in the second half of the 2020 season? | SELECT SUM(wins_team_a) FROM games WHERE team_a = 'Team C' AND location = 'Home' AND id > 26; | gretelai_synthetic_text_to_sql |
CREATE TABLE Players (PlayerID INT, PlayerName VARCHAR(100), Country VARCHAR(50), Game VARCHAR(50), Score INT); INSERT INTO Players (PlayerID, PlayerName, Country, Game, Score) VALUES (1, 'John Doe', 'United States', 'Racing Games', 90); INSERT INTO Players (PlayerID, PlayerName, Country, Game, Score) VALUES (2, 'Jane ... | What is the average score of players from the United States who play 'Racing Games'? | SELECT AVG(Score) FROM Players WHERE Country = 'United States' AND Game = 'Racing Games'; | gretelai_synthetic_text_to_sql |
CREATE TABLE mines (id INT, name TEXT, location TEXT, terbium_production FLOAT, timestamp DATE); INSERT INTO mines (id, name, location, terbium_production, timestamp) VALUES (1, 'Mine A', 'Australia', 120.5, '2021-01-01'), (2, 'Mine B', 'Australia', 150.7, '2021-02-01'), (3, 'Mine C', 'USA', 200.3, '2021-03-01'); | What is the maximum Terbium production in 2021 from mines in Australia? | SELECT MAX(terbium_production) FROM mines WHERE location = 'Australia' AND YEAR(mines.timestamp) = 2021; | gretelai_synthetic_text_to_sql |
CREATE TABLE enrollments (student_id INT, course_name TEXT); INSERT INTO enrollments (student_id, course_name) VALUES (123, 'Intro to Psychology'), (123, 'English Composition'), (456, 'English Composition'), (789, 'Intro to Psychology'); | How many students are enrolled in each course? | SELECT course_name, COUNT(*) FROM enrollments GROUP BY course_name; | gretelai_synthetic_text_to_sql |
CREATE TABLE labor_cost_by_month (supplier_id INT, labor_cost_month DATE, labor_cost DECIMAL(10,2)); INSERT INTO labor_cost_by_month (supplier_id, labor_cost_month, labor_cost) VALUES (1, '2021-01-01', 500.00), (1, '2021-02-01', 700.00), (2, '2021-01-01', 800.00), (3, '2021-03-01', 300.00); | What is the total labor cost for each supplier by month? | SELECT EXTRACT(MONTH FROM labor_cost_month) AS month, supplier_id, SUM(labor_cost) AS total_labor_cost FROM labor_cost_by_month GROUP BY month, supplier_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE destinations (destination_id INT, name TEXT, country TEXT); CREATE TABLE travel_advisories (advisory_id INT, destination_id INT, government TEXT, issued_date DATE); INSERT INTO destinations (destination_id, name, country) VALUES (1, 'Paris', 'France'), (2, 'Rio de Janeiro', 'Brazil'); INSERT INTO travel_ad... | List all destinations with travel advisories issued by the US government. | SELECT d.name FROM destinations d INNER JOIN travel_advisories ta ON d.destination_id = ta.destination_id WHERE ta.government = 'USA'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Artworks (ArtworkID INT, Type TEXT, SalePrice INT, CreationYear INT); INSERT INTO Artworks (ArtworkID, Type, SalePrice, CreationYear) VALUES (1, 'Painting', 150000, 1780); | What is the maximum sale price for paintings from the 18th century? | SELECT MAX(SalePrice) FROM Artworks WHERE Type = 'Painting' AND CreationYear BETWEEN 1701 AND 1800; | gretelai_synthetic_text_to_sql |
CREATE TABLE events_per_year (id INT, country VARCHAR(255), year INT, events INT); INSERT INTO events_per_year (id, country, year, events) VALUES (1, 'Argentina', 2015, 10), (2, 'Brazil', 2016, 15); | What is the average number of community engagement events per year in South America? | SELECT AVG(events) FROM events_per_year WHERE country LIKE 'South%'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Games (GameID INT, Name VARCHAR(100), Genre VARCHAR(50), VRPossible BOOLEAN); INSERT INTO Games (GameID, Name, Genre, VRPossible) VALUES (1, 'Game1', 'Action', true), (2, 'Game2', 'Adventure', true), (3, 'Game3', 'Simulation', false), (4, 'Game4', 'Strategy', false), (5, 'Game5', 'Puzzle', true); | List the unique game genres for games designed for VR platforms. | SELECT DISTINCT Genre FROM Games WHERE VRPossible = true; | gretelai_synthetic_text_to_sql |
CREATE TABLE autonomous_buses (bus_id INT, trip_duration INT, start_speed INT, end_speed INT, trip_date DATE); INSERT INTO autonomous_buses (bus_id, trip_duration, start_speed, end_speed, trip_date) VALUES (1, 1800, 5, 15, '2022-01-01'), (2, 1500, 10, 20, '2022-01-02'); CREATE TABLE city_coordinates (city VARCHAR(50), ... | What is the average speed of autonomous buses in Tokyo? | SELECT AVG(end_speed - start_speed) as avg_speed FROM autonomous_buses, city_coordinates WHERE city_coordinates.city = 'Tokyo'; | gretelai_synthetic_text_to_sql |
CREATE TABLE loans (id INT, loan_type VARCHAR(255), balance DECIMAL(10,2)); INSERT INTO loans (id, loan_type, balance) VALUES (1, 'Socially Responsible', 1000.00); | Insert a new record for a socially responsible loan with a balance of $1000. | INSERT INTO loans (loan_type, balance) VALUES ('Socially Responsible', 1000.00); | gretelai_synthetic_text_to_sql |
CREATE TABLE Employees (Employee_ID INT, First_Name VARCHAR(50), Last_Name VARCHAR(50), Department VARCHAR(50), Job_Title VARCHAR(50)); INSERT INTO Employees (Employee_ID, First_Name, Last_Name, Department, Job_Title) VALUES (1, 'John', 'Doe', 'Sales', 'Manager'), (2, 'Jane', 'Smith', 'Sales', 'Associate'), (3, 'Mike',... | Find the difference in unique job titles between the 'Sales' and 'IT' departments. | SELECT Job_Title FROM Employees WHERE Department = 'Sales' INTERSECT SELECT Job_Title FROM Employees WHERE Department = 'IT' | gretelai_synthetic_text_to_sql |
CREATE TABLE arctic_mammals (species VARCHAR(50), population INT); | How many unique species of mammals are present in the 'arctic_mammals' table, with a population greater than 1000? | SELECT COUNT(DISTINCT species) FROM arctic_mammals WHERE population > 1000; | gretelai_synthetic_text_to_sql |
CREATE TABLE Healthcare_Union (union_member_id INT, member_id INT, salary FLOAT); INSERT INTO Healthcare_Union (union_member_id, member_id, salary) VALUES (1, 101, 55000.00), (1, 102, 48000.00), (1, 103, 52000.00), (2, 201, 60000.00), (2, 202, 56000.00); | Count the number of members in the 'Healthcare_Union' having a salary below 50000. | SELECT COUNT(union_member_id) FROM Healthcare_Union WHERE salary < 50000; | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_life_research_stations (id INT, name VARCHAR(255), region VARCHAR(255), depth FLOAT); | What is the minimum depth of any marine life research station in the Pacific region? | SELECT MIN(depth) FROM marine_life_research_stations WHERE region = 'Pacific'; | gretelai_synthetic_text_to_sql |
CREATE TABLE species_data (species_id INT, species_name VARCHAR(255), biomass FLOAT); INSERT INTO species_data (species_id, species_name, biomass) VALUES (1, 'polar_bear', 800.0), (2, 'arctic_fox', 15.0), (3, 'caribou', 220.0); | Update the biomass value of the 'polar_bear' species to 900 in the 'species_data' table. | UPDATE species_data SET biomass = 900 WHERE species_name = 'polar_bear'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Restaurants (id INT, name VARCHAR(50), region VARCHAR(50), inspection_score INT); INSERT INTO Restaurants (id, name, region, inspection_score) VALUES (1, 'Asian Fusion', 'North', 95), (2, 'Bistro Bella', 'South', 88), (3, 'Tacos & More', 'East', 92); | What is the distribution of food safety inspection scores across all restaurants? | SELECT inspection_score, COUNT(*) as restaurant_count FROM Restaurants GROUP BY inspection_score; | gretelai_synthetic_text_to_sql |
CREATE TABLE Building (id INT, name VARCHAR(50), city VARCHAR(50), country VARCHAR(50), sqft INT, PRIMARY KEY (id)); INSERT INTO Building (id, name, city, country, sqft) VALUES (7, 'Brandenburg Gate', 'Berlin', 'Germany', 88200); INSERT INTO Building (id, name, city, country, sqft) VALUES (8, 'Cologne Cathedral', 'Colo... | What is the total size of solar panels in Germany? | SELECT SUM(sp.size) FROM SolarPanel sp JOIN Building b ON sp.building_id = b.id WHERE b.country = 'Germany'; | gretelai_synthetic_text_to_sql |
CREATE TABLE drug_sales(drug_id INT, sale_date DATE, amount DECIMAL(10,2)); INSERT INTO drug_sales(drug_id, sale_date, amount) VALUES (1, '2020-01-01', 1000), (1, '2020-02-01', 1500), (2, '2020-01-01', 2000), (2, '2020-02-01', 2500); | What are the sales figures for a specific drug in 2020? | SELECT drug_id, SUM(amount) as total_sales FROM drug_sales WHERE YEAR(sale_date) = 2020 GROUP BY drug_id; | gretelai_synthetic_text_to_sql |
CREATE TABLE public.defendants (id SERIAL PRIMARY KEY, name VARCHAR(255), age INT, ethnicity VARCHAR(255), case_number VARCHAR(255)); CREATE TABLE public.cases (id SERIAL PRIMARY KEY, plaintiff_id INT, defendant_id INT, case_date DATE, case_type VARCHAR(255), court_location VARCHAR(255)); CREATE TABLE public.verdicts (... | What is the total fine amount ordered for each ethnicity of defendants? | SELECT d.ethnicity, sum(f.fine_amount) as total_fine_amount FROM public.defendants d JOIN public.cases c ON d.id = c.defendant_id JOIN public.verdicts v ON c.case_number = v.case_number JOIN public.fines f ON v.case_number = f.case_number GROUP BY d.ethnicity; | gretelai_synthetic_text_to_sql |
CREATE VIEW outdated_standards AS SELECT * FROM design_standards WHERE standard_version < 3; | Delete the 'outdated_standards' view | DROP VIEW outdated_standards; | gretelai_synthetic_text_to_sql |
CREATE TABLE projects (id INT PRIMARY KEY, name VARCHAR(255), country VARCHAR(255), start_date DATE, end_date DATE, budget DECIMAL(10,2)); CREATE TABLE climate_finance (id INT PRIMARY KEY, project_id INT, source VARCHAR(255), amount DECIMAL(10,2)); CREATE TABLE mitigation_activities (id INT PRIMARY KEY, project_id INT,... | What is the total cost and average climate finance for projects in Africa with climate finance from the Green Climate Fund? | SELECT projects.country, SUM(mitigation_activities.cost) as total_cost, AVG(climate_finance.amount) as avg_climate_finance FROM projects JOIN mitigation_activities ON projects.id = mitigation_activities.project_id JOIN climate_finance ON projects.id = climate_finance.project_id WHERE projects.country = 'Africa' AND cli... | gretelai_synthetic_text_to_sql |
CREATE TABLE attractions (id INT PRIMARY KEY, name VARCHAR(255), type VARCHAR(255), country VARCHAR(255)); | Add a new virtual tourism attraction to 'attractions' table | INSERT INTO attractions (id, name, type, country) VALUES (1, 'Amazon Rainforest Virtual Tour', 'Virtual', 'Brazil'); | gretelai_synthetic_text_to_sql |
CREATE TABLE carbon_offset_projects (id INT, project_name VARCHAR(50), location VARCHAR(50), type VARCHAR(50), status VARCHAR(50)); INSERT INTO carbon_offset_projects (id, project_name, location, type, status) VALUES (1, 'Amazon Rainforest Reforestation', 'Brazil', 'Reforestation', 'Completed'), (2, 'Boreal Forest Cons... | List all records from the 'carbon_offset_projects' table with a 'type' of 'reforestation' and a 'status' of 'completed'. | SELECT * FROM carbon_offset_projects WHERE type = 'Reforestation' AND status = 'Completed'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Annual_Water_Usage (id INT, region VARCHAR(20), year INT, usage FLOAT); INSERT INTO Annual_Water_Usage (id, region, year, usage) VALUES (1, 'RegionA', 2020, 12000), (2, 'RegionB', 2021, 15000), (3, 'RegionC', 2022, NULL); | Display the total water usage in 'RegionC' for the year 2022 | SELECT region, SUM(usage) FROM Annual_Water_Usage WHERE region = 'RegionC' AND year = 2022 GROUP BY region; | gretelai_synthetic_text_to_sql |
CREATE TABLE Artifacts (id INT, excavation_site VARCHAR(20), artifact_name VARCHAR(30), pieces INT); INSERT INTO Artifacts (id, excavation_site, artifact_name, pieces) VALUES (1, 'BronzeAge', 'Sword', 3000,), (2, 'AncientRome', 'Sword', 2500,); | Which artifacts were found in more than one excavation site? | SELECT artifact_name FROM Artifacts GROUP BY artifact_name HAVING COUNT(DISTINCT excavation_site) > 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE maintenance (request_id INT, request_date DATE, equipment_type VARCHAR(255)); INSERT INTO maintenance (request_id, request_date, equipment_type) VALUES (1, '2020-02-12', 'tank'), (2, '2020-04-15', 'plane'), (3, '2019-10-27', 'ship'); | What is the average time between equipment maintenance requests for each equipment type? | SELECT equipment_type, AVG(DATEDIFF(day, LAG(request_date) OVER (PARTITION BY equipment_type ORDER BY request_date), request_date)) AS avg_days_between_requests FROM maintenance GROUP BY equipment_type; | gretelai_synthetic_text_to_sql |
CREATE TABLE Employees (EmployeeID INT, Gender VARCHAR(10), Department VARCHAR(20)); INSERT INTO Employees (EmployeeID, Gender, Department) VALUES (1, 'Female', 'HR'), (2, 'Male', 'IT'), (3, 'Female', 'HR'), (4, 'Male', 'IT'); | What is the ratio of male to female employees in the HR department? | SELECT COUNT(*) * 1.0 / SUM(CASE WHEN Gender = 'Female' THEN 1 ELSE 0 END) FROM Employees WHERE Department = 'HR'; | gretelai_synthetic_text_to_sql |
CREATE TABLE activity_data (member_id INT, activity VARCHAR(20), calories INT); INSERT INTO activity_data (member_id, activity, calories) VALUES (1, 'Running', 300), (2, 'Cycling', 400), (3, 'Yoga', 100), (4, 'Swimming', 250), (5, 'Pilates', 150); | Which activities have the highest and lowest calories burned? | SELECT activity, MAX(calories) AS max_calories, MIN(calories) AS min_calories FROM activity_data GROUP BY activity; | gretelai_synthetic_text_to_sql |
CREATE TABLE vulnerabilities (id INT, severity FLOAT, region VARCHAR(50)); INSERT INTO vulnerabilities (id, severity, region) VALUES (1, 7.5, 'Europe'); | What is the maximum severity of vulnerabilities found in the European region? | SELECT MAX(severity) FROM vulnerabilities WHERE region = 'Europe'; | gretelai_synthetic_text_to_sql |
CREATE TABLE volunteers (id INT, name TEXT, donation FLOAT); INSERT INTO volunteers (id, name, donation) VALUES (1, 'John Doe', 50.00), (2, 'Jane Smith', 100.00), (3, 'Alice Johnson', 25.00); | What is the minimum donation amount per volunteer? | SELECT name, MIN(donation) FROM volunteers GROUP BY name; | gretelai_synthetic_text_to_sql |
CREATE TABLE artists (id INT, name TEXT, genre TEXT); CREATE TABLE albums (id INT, title TEXT, artist_id INT, platform TEXT); CREATE TABLE sales (id INT, album_id INT, quantity INT, revenue DECIMAL); CREATE VIEW genre_sales AS SELECT ar.genre, SUM(s.revenue) as total_revenue FROM albums a JOIN sales s ON a.id = s.album... | Show the total revenue for each music genre on the 'web' platform. | SELECT genre, total_revenue FROM genre_sales_web; | gretelai_synthetic_text_to_sql |
CREATE TABLE hashtags (hashtag_id INT, hashtag VARCHAR(255), post_date DATE); | List the top 10 hashtags used in the past month, along with the number of times they were used. | SELECT hashtag, COUNT(*) as usage_count FROM hashtags WHERE post_date >= DATE_SUB(CURDATE(), INTERVAL 1 MONTH) GROUP BY hashtag ORDER BY usage_count DESC LIMIT 10; | gretelai_synthetic_text_to_sql |
CREATE TABLE grad_students (student_id INT, student_name VARCHAR(50), publications INT); INSERT INTO grad_students (student_id, student_name, publications) VALUES (1, 'John Doe', 3), (2, 'Jane Smith', 5), (3, 'Mike Johnson', 2), (4, 'Alice Davis', 4), (5, 'Bob Brown', 1); | List the top 5 graduate students with the highest number of research publications in the past year, sorted by the number of publications in descending order. | SELECT student_id, student_name, publications FROM (SELECT student_id, student_name, publications, ROW_NUMBER() OVER (ORDER BY publications DESC) as rank FROM grad_students WHERE publication_date >= DATEADD(year, -1, GETDATE())) as top5 WHERE rank <= 5; | gretelai_synthetic_text_to_sql |
CREATE SCHEMA oceans; CREATE TABLE fish_farms (id INT, size FLOAT, location VARCHAR(20)); INSERT INTO fish_farms (id, size, location) VALUES (1, 50.2, 'ocean'), (2, 30.5, 'ocean'), (3, 80.3, 'sea'); | What is the average size of fish farms in 'oceans' schema? | SELECT AVG(size) FROM oceans.fish_farms WHERE location = 'ocean'; | gretelai_synthetic_text_to_sql |
CREATE TABLE astronauts (astronaut_id INT, name TEXT, age INT, flown_in_space BOOLEAN); INSERT INTO astronauts (astronaut_id, name, age, flown_in_space) VALUES (1, 'Mark Watney', 40, true), (2, 'Melissa Lewis', 45, true), (3, 'Jessica Stevens', 35, false); | List the names of astronauts who have never flown in space. | SELECT name FROM astronauts WHERE flown_in_space = false; | gretelai_synthetic_text_to_sql |
CREATE TABLE therapy_sessions_2023 (patient_id INT, session_date DATE); INSERT INTO therapy_sessions_2023 (patient_id, session_date) VALUES (5, '2023-02-03'), (6, '2023-03-17'), (7, '2023-06-28'), (8, '2023-04-01'), (5, '2023-05-10'), (6, '2023-07-01'), (5, '2023-09-01'), (8, '2023-10-01'), (7, '2023-11-01'), (6, '2023... | Identify the patient with the most therapy sessions in 2023? | SELECT patient_id, COUNT(*) AS num_sessions FROM therapy_sessions_2023 WHERE YEAR(session_date) = 2023 GROUP BY patient_id ORDER BY num_sessions DESC LIMIT 1; | gretelai_synthetic_text_to_sql |
CREATE TABLE ethical_production (id INT, producer VARCHAR(20), garment VARCHAR(20)); INSERT INTO ethical_production (id, producer, garment) VALUES (1, 'EcoFabrics', 'tshirt'), (2, 'GreenYarn', 'pants'), (3, 'SustainaFiber', 'dress'), (4, 'EcoFabrics', 'jacket'), (5, 'GreenYarn', 'shirt'), (6, 'SustainaFiber', 'blouse')... | How many garments are produced by each producer in the 'ethical_production' table? | SELECT producer, COUNT(garment) AS total_garments FROM ethical_production GROUP BY producer; | gretelai_synthetic_text_to_sql |
CREATE TABLE users (id INT, name VARCHAR(255), country VARCHAR(255)); CREATE TABLE posts (id INT, user_id INT, content TEXT, created_at TIMESTAMP); CREATE VIEW latest_post AS SELECT posts.user_id, MAX(posts.created_at) AS latest_post FROM posts GROUP BY posts.user_id; | Insert new users from Mexico and their posts about local culture. | INSERT INTO users (id, name, country) VALUES (5, 'Edith', 'Mexico'), (6, 'Fernando', 'Mexico'); INSERT INTO posts (id, user_id, content, created_at) SELECT NULL, users.id, 'Discovering the richness of Mexican culture! #localculture', NOW() FROM users WHERE users.id NOT IN (SELECT latest_post.user_id FROM latest_post) A... | gretelai_synthetic_text_to_sql |
CREATE TABLE Customers (CustomerID INT, Gender VARCHAR(50), Balance DECIMAL(10,2)); INSERT INTO Customers (CustomerID, Gender, Balance) VALUES (1, 'Male', 10000); INSERT INTO Customers (CustomerID, Gender, Balance) VALUES (2, 'Female', 5000); | What is the difference between the total assets of male and female customers? | SELECT SUM(CASE WHEN Gender = 'Male' THEN Balance ELSE -Balance END) FROM Customers | gretelai_synthetic_text_to_sql |
CREATE TABLE Habitats (id INT, name VARCHAR(20)); INSERT INTO Habitats (id, name) VALUES (1, 'Habitat A'), (2, 'Habitat B'), (3, 'Habitat C'); CREATE TABLE Animals (id INT, name VARCHAR(20), habitat_id INT); INSERT INTO Animals (id, name, habitat_id) VALUES (1, 'Tiger', 3), (2, 'Elephant', 3), (3, 'Giraffe', 1); CREATE... | What is the maximum number of education events in a single month for 'Habitat C'? | SELECT MAX(num_education_events) FROM (SELECT habitat_id, MONTH(date) as month, COUNT(*) as num_education_events FROM Education WHERE habitat_id = 3 GROUP BY habitat_id, month) AS subquery | gretelai_synthetic_text_to_sql |
CREATE TABLE GameDesign (GameID INT, GameName VARCHAR(50), VR BIT); INSERT INTO GameDesign (GameID, GameName, VR) VALUES (1, 'Space Explorer', 1), (2, 'Racing Fever', 0), (3, 'VR Puzzle', 1); CREATE TABLE PlayerDemographics (PlayerID INT, Gender VARCHAR(10), EducationLevel VARCHAR(20)); INSERT INTO PlayerDemographics (... | What is the number of games designed for players with different education levels, and what are their names? | SELECT PlayerDemographics.EducationLevel, COUNT(GameDesign.GameID) AS Games_Designed, MIN(GameDesign.GameName) AS First_Game, MAX(GameDesign.GameName) AS Last_Game FROM GameDesign INNER JOIN PlayerDemographics ON GameDesign.VR = 1 GROUP BY PlayerDemographics.EducationLevel; | gretelai_synthetic_text_to_sql |
CREATE TABLE rainfall_data (field VARCHAR(255), precipitation FLOAT, timestamp TIMESTAMP); | Calculate the moving average of precipitation over a 7-day period, for 'Field_2' from the 'rainfall_data' table. | SELECT field, AVG(precipitation) OVER (PARTITION BY field ORDER BY timestamp RANGE BETWEEN INTERVAL '7 day' PRECEDING AND CURRENT ROW) as moving_avg FROM rainfall_data WHERE field = 'Field_2'; | gretelai_synthetic_text_to_sql |
CREATE TABLE chemical_compounds (id INT PRIMARY KEY, name VARCHAR(255), safety_rating INT); | Insert new records for 3 chemical compounds, 'Acetone', 'Isopropyl Alcohol', 'Toluene', with safety_ratings 7, 8, 6 respectively | INSERT INTO chemical_compounds (name, safety_rating) VALUES ('Acetone', 7), ('Isopropyl Alcohol', 8), ('Toluene', 6); | gretelai_synthetic_text_to_sql |
CREATE TABLE project_budget (id INT, project_id INT, location VARCHAR(50), budget FLOAT); INSERT INTO project_budget (id, project_id, location, budget) VALUES (1, 1, 'Africa', 350000.00), (2, 2, 'Asia', 450000.00), (3, 3, 'Africa', 300000.00); | What is the minimum budget for projects in Africa? | SELECT MIN(budget) FROM project_budget WHERE location = 'Africa'; | gretelai_synthetic_text_to_sql |
CREATE TABLE warehouses (warehouse_id INT, warehouse_name VARCHAR(255), city VARCHAR(255)); INSERT INTO warehouses (warehouse_id, warehouse_name, city) VALUES (1, 'Warehouse A', 'City of Industry'), (2, 'Warehouse B', 'Los Angeles'); CREATE TABLE shipments (shipment_id INT, warehouse_id INT, shipped_date DATE, shipped_... | What are the total quantities of items shipped by land to 'City of Industry' between 2021-06-01 and 2021-06-15? | SELECT SUM(shipped_quantity) FROM shipments INNER JOIN warehouses ON shipments.warehouse_id = warehouses.warehouse_id WHERE shipped_date BETWEEN '2021-06-01' AND '2021-06-15' AND city = 'City of Industry'; | gretelai_synthetic_text_to_sql |
CREATE TABLE community_courts (court_id INT, court_state VARCHAR(2)); INSERT INTO community_courts VALUES (1, 'NY'), (2, 'CA'), (3, 'IL'); | What is the total number of cases heard in community courts for each state? | SELECT SUM(1) FROM community_courts cc INNER JOIN court_cases cc ON cc.court_id = cc.court_id GROUP BY cc.court_state; | gretelai_synthetic_text_to_sql |
CREATE TABLE CustomerSizes (CustomerID INT, Size TEXT); INSERT INTO CustomerSizes (CustomerID, Size) VALUES (1, 'XS'), (2, 'S'), (3, 'M'); | Delete size records for customers not fitting standard sizes | DELETE FROM CustomerSizes WHERE Size NOT IN ('XS', 'S', 'M'); | gretelai_synthetic_text_to_sql |
CREATE TABLE projects (project_id INT, name TEXT, rating FLOAT); INSERT INTO projects (project_id, name, rating) VALUES (1, 'Solar Farm', 1.8), (2, 'Wind Turbine', 1.1), (3, 'Geothermal Plant', 2.0), (4, 'Hydro Plant', 1.9); | Delete renewable energy projects that have an efficiency rating below 1.5. | DELETE FROM projects WHERE rating < 1.5; | gretelai_synthetic_text_to_sql |
CREATE TABLE production (id INT, field_name VARCHAR(50), year INT, qty FLOAT); INSERT INTO production (id, field_name, year, qty) VALUES (1, 'Galkynysh', 2018, 100000); INSERT INTO production (id, field_name, year, qty) VALUES (2, 'Galkynysh', 2019, 120000); INSERT INTO production (id, field_name, year, qty) VALUES (3,... | Calculate the year-over-year production change for each oil field | SELECT a.field_name, (b.qty - a.qty) / a.qty as yoy_change FROM production a JOIN production b ON a.field_name = b.field_name WHERE a.year = (YEAR(CURRENT_DATE) - 1) AND b.year = YEAR(CURRENT_DATE); | gretelai_synthetic_text_to_sql |
CREATE TABLE MentalHealthParity (CaseID INT, ReportYear INT); INSERT INTO MentalHealthParity (CaseID, ReportYear) VALUES (1, 2020), (2, 2021), (3, 2020), (4, 2020), (5, 2021), (6, 2022), (7, 2022), (8, 2022); | How many mental health parity cases were reported in 2022? | SELECT SUM(CASE WHEN ReportYear = 2022 THEN 1 ELSE 0 END) as TotalCases FROM MentalHealthParity; | gretelai_synthetic_text_to_sql |
CREATE TABLE startups (id INT PRIMARY KEY, name VARCHAR(100), industry VARCHAR(50), funding_round VARCHAR(50), funding_amount INT); | Update the 'funding_round' column in the 'startups' table to 'Series A' for the startup with 'name' = 'BioVita' | UPDATE startups SET funding_round = 'Series A' WHERE name = 'BioVita'; | gretelai_synthetic_text_to_sql |
CREATE TABLE transactions (id INT, algorithm_type VARCHAR(20)); INSERT INTO transactions (id, algorithm_type) VALUES (1, 'AI Safety'); INSERT INTO transactions (id, algorithm_type) VALUES (2, 'Explainable AI'); | What is the total number of transactions for AI safety and AI explainability algorithms? | SELECT SUM(id) FROM transactions WHERE algorithm_type IN ('AI Safety', 'Explainable AI'); | gretelai_synthetic_text_to_sql |
CREATE TABLE menu_items(id INT, name VARCHAR(255), rating INT, is_vegetarian BOOLEAN); INSERT INTO menu_items (id, name, rating, is_vegetarian) VALUES (1, 'Steak', 5, false), (2, 'Grilled Chicken', 4, false), (3, 'Veggie Burger', 3, true); | List all menu items that have a rating of 4 or higher and are not vegetarian. | SELECT name FROM menu_items WHERE rating >= 4 AND is_vegetarian = false; | gretelai_synthetic_text_to_sql |
CREATE TABLE Donations (id INT, program VARCHAR(255), amount DECIMAL(10, 2)); INSERT INTO Donations (id, program, amount) VALUES (1, 'Arts and Culture', 500.00), (2, 'Education', 300.00); | What is the total number of donations received by the arts and culture program? | SELECT SUM(amount) FROM Donations WHERE program = 'Arts and Culture'; | gretelai_synthetic_text_to_sql |
CREATE TABLE Volunteers (VolunteerID INT, VolunteerName TEXT, VolunteerDate DATE); CREATE TABLE VolunteerHours (VolunteerID INT, Hours INT); | What is the total number of volunteers and total volunteer hours for each month in the year 2021, ordered by the total number of volunteers in descending order? | SELECT DATE_FORMAT(V.VolunteerDate, '%Y-%m') as Month, COUNT(V.VolunteerID) as NumVolunteers, SUM(VH.Hours) as TotalHours FROM Volunteers V JOIN VolunteerHours VH ON V.VolunteerID = VH.VolunteerID WHERE YEAR(V.VolunteerDate) = 2021 GROUP BY Month ORDER BY NumVolunteers DESC; | gretelai_synthetic_text_to_sql |
CREATE TABLE sales (sale_id INT, product_id INT, sale_date DATE, quantity INT, price DECIMAL(5,2)); CREATE TABLE products (product_id INT, product_name VARCHAR(100), category VARCHAR(50), country VARCHAR(50)); | How many units of makeup products are sold in each country in the last quarter? | SELECT sales.country, SUM(sales.quantity) FROM sales JOIN products ON sales.product_id = products.product_id WHERE products.category = 'Makeup' AND sales.sale_date >= DATE_SUB(CURRENT_DATE(), INTERVAL 3 MONTH) GROUP BY sales.country; | gretelai_synthetic_text_to_sql |
CREATE TABLE marine_species (species_id INT, species_name VARCHAR(50), ocean_name VARCHAR(50)); | Delete all records with the ocean_name 'Arctic Ocean' and return the number of deleted records. | WITH deleted_species AS (DELETE FROM marine_species WHERE ocean_name = 'Arctic Ocean' RETURNING species_id) SELECT COUNT(*) FROM deleted_species; | gretelai_synthetic_text_to_sql |
CREATE TABLE algorand_transactions (transaction_id INT, transaction_time DATETIME); | What is the total number of transactions on the Algorand network, and what is the distribution of these transactions by the day of the week? | SELECT DATE_FORMAT(transaction_time, '%W') as day_of_week, COUNT(transaction_id) as total_transactions FROM algorand_transactions GROUP BY day_of_week; | gretelai_synthetic_text_to_sql |
CREATE TABLE satellites (id INT, country VARCHAR(255), name VARCHAR(255), launch_date DATE); | What is the maximum number of satellites launched by any country in a single year? | SELECT MAX(satellites_per_year.count) FROM (SELECT COUNT(*) as count, YEAR(launch_date) as launch_year FROM satellites GROUP BY launch_year) as satellites_per_year; | 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.