context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE Menu (menu_name VARCHAR(20), item_name VARCHAR(30), price DECIMAL(5,2)); INSERT INTO Menu (menu_name, item_name, price) VALUES ('Lunch', 'Chicken Sandwich', 9.99), ('Lunch', 'Steak Wrap', 12.49), ('Lunch', 'Quinoa Salad', 14.50);
Update the price of the 'Steak Wrap' on the 'Lunch' menu to 13.49
UPDATE Menu SET price = 13.49 WHERE menu_name = 'Lunch' AND item_name = 'Steak Wrap';
gretelai_synthetic_text_to_sql
CREATE TABLE fare_by_month (route_name VARCHAR(50), month_year DATE, fare_amount DECIMAL(10,2)); INSERT INTO fare_by_month (route_name, month_year, fare_amount) VALUES ('Red Line', '2022-01-01', 100.00), ('Red Line', '2022-02-01', 110.00), ('Red Line', '2022-03-01', 95.00);
What is the minimum fare collected for the 'Red Line' during any given month?
SELECT MIN(fare_amount) FROM fare_by_month WHERE route_name = 'Red Line';
gretelai_synthetic_text_to_sql
CREATE TABLE game_scores (user_id INT, game_name VARCHAR(10), score INT); INSERT INTO game_scores (user_id, game_name, score) VALUES (1, 'A', 50), (2, 'B', 100), (3, 'D', 150), (3, 'D', 120);
Identify the maximum score achieved by user 3 in game 'D'
SELECT MAX(score) FROM game_scores WHERE user_id = 3 AND game_name = 'D';
gretelai_synthetic_text_to_sql
CREATE TABLE humanitarian_assistance (donor VARCHAR(255), recipient VARCHAR(255), amount DECIMAL(10, 2)); INSERT INTO humanitarian_assistance (donor, recipient, amount) VALUES ('USA', 'Syria', 1000000), ('China', 'Pakistan', 500000), ('USA', 'Iraq', 800000), ('China', 'Afghanistan', 700000);
Identify the humanitarian assistance provided by the US
SELECT donor, recipient, amount FROM humanitarian_assistance WHERE donor = 'USA';
gretelai_synthetic_text_to_sql
CREATE TABLE ai_safety_incidents (incident_id INTEGER, incident_region TEXT); INSERT INTO ai_safety_incidents (incident_id, incident_region) VALUES (1, 'Northeast'), (2, 'South'), (3, 'Midwest'), (4, 'West');
Find the number of AI safety incidents for each region in the US.
SELECT incident_region, COUNT(*) FROM ai_safety_incidents GROUP BY incident_region;
gretelai_synthetic_text_to_sql
CREATE TABLE forests (id INT, region VARCHAR(255), species VARCHAR(255), year INT, volume FLOAT); INSERT INTO forests (id, region, species, year, volume) VALUES (1, 'North', 'Pine', 2018, 1200.5), (2, 'South', 'Oak', 2019, 1500.3), (3, 'East', 'Maple', 2020, 2000.7), (4, 'West', 'Birch', 2020, 1750.6), (5, 'North', 'Spruce', 2019, 1300.8), (6, 'South', 'Spruce', 2018, 1400.9), (7, 'East', 'Pine', 2019, 1500.0), (8, 'North', 'Oak', 2018, 1100.2), (9, 'West', 'Maple', 2019, 1600.3), (10, 'South', 'Birch', 2020, 1800.7);
What is the total volume of timber harvested in 2018 and 2019, grouped by the region and species?
SELECT region, species, SUM(volume) as total_volume FROM forests WHERE year IN (2018, 2019) GROUP BY region, species;
gretelai_synthetic_text_to_sql
CREATE TABLE bus_fares (region VARCHAR(10), fare DECIMAL(5,2)); INSERT INTO bus_fares (region, fare) VALUES ('north', 2.00), ('north', 2.50), ('south', 1.50), ('west', 3.00), ('west', 2.75);
What is the total fare collected from buses in 'south' and 'west' regions?
SELECT SUM(fare) FROM bus_fares WHERE region IN ('south', 'west');
gretelai_synthetic_text_to_sql
CREATE TABLE Spacecraft (ID INT PRIMARY KEY, Name TEXT); CREATE TABLE Parts (ID INT PRIMARY KEY, Spacecraft_ID INT, Name TEXT, Weight INT);
What are the total weights of all parts for each spacecraft?
SELECT s.Name, SUM(p.Weight) as Total_Weight FROM Spacecraft s INNER JOIN Parts p ON s.ID = p.Spacecraft_ID GROUP BY s.Name;
gretelai_synthetic_text_to_sql
CREATE TABLE well_production (well_id INT, measurement_date DATE, production_rate FLOAT, location TEXT); INSERT INTO well_production (well_id, measurement_date, production_rate, location) VALUES (1, '2022-01-01', 500, 'Onshore'), (2, '2022-02-01', 700, 'Offshore'), (3, '2022-03-01', 600, 'Onshore'), (4, '2022-02-01', 800, 'Offshore'), (5, '2022-03-01', 900, 'Offshore');
What's the maximum production rate in the last 6 months for offshore wells?
SELECT location, MAX(production_rate) FROM well_production WHERE measurement_date >= DATEADD(month, -6, GETDATE()) AND location = 'Offshore' GROUP BY location;
gretelai_synthetic_text_to_sql
CREATE TABLE financial_capability (id INT, country VARCHAR(50), score INT); INSERT INTO financial_capability (id, country, score) VALUES (1, 'Brazil', 65), (2, 'India', 70), (3, 'China', 80), (4, 'South Africa', 75), (5, 'Indonesia', 60);
List the top 3 countries with the highest financial capability score.
SELECT country, score FROM (SELECT country, score, ROW_NUMBER() OVER (ORDER BY score DESC) as rn FROM financial_capability) tmp WHERE rn <= 3;
gretelai_synthetic_text_to_sql
CREATE TABLE TraditionalArtEvents (ID INT, Art VARCHAR(50), Location VARCHAR(50), Events INT); INSERT INTO TraditionalArtEvents (ID, Art, Location, Events) VALUES (1, 'Kabuki', 'Urban', 40); INSERT INTO TraditionalArtEvents (ID, Art, Location, Events) VALUES (2, 'Flamenco', 'Rural', 30);
What is the ratio of traditional art events in urban to rural areas?
SELECT Art, Location, Events, COUNT(*) OVER (PARTITION BY Location) AS TotalEventsInLocation, 1.0 * Events / SUM(Events) OVER (PARTITION BY Location) AS Ratio FROM TraditionalArtEvents;
gretelai_synthetic_text_to_sql
CREATE TABLE WasteGeneration (year INT, region VARCHAR(50), material VARCHAR(50), volume FLOAT); INSERT INTO WasteGeneration (year, region, material, volume) VALUES (2020, 'North America', 'Metal', 12000), (2020, 'Europe', 'Metal', 15000), (2020, 'Asia', 'Metal', 20000), (2020, 'South America', 'Metal', 8000), (2020, 'Africa', 'Metal', 6000);
What is the total volume of metal waste generated in 2020, categorized by region?
SELECT region, SUM(volume) FROM WasteGeneration WHERE year = 2020 AND material = 'Metal' GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE CommunityPrograms (id INT, program_name VARCHAR(50), location VARCHAR(50), participants INT); INSERT INTO CommunityPrograms (id, program_name, location, participants) VALUES (1, 'Youth Mentoring', 'Suburb I', 150);
Which community programs have the most participants in Suburb I?
SELECT program_name, MAX(participants) FROM CommunityPrograms WHERE location = 'Suburb I';
gretelai_synthetic_text_to_sql
CREATE TABLE athlete_wellbeing (athlete_id INT, program_date DATE); INSERT INTO athlete_wellbeing (athlete_id, program_date) VALUES (1, '2021-03-01'), (1, '2021-07-15'), (2, '2021-02-20'), (3, '2020-12-31'), (3, '2021-06-05');
List the athletes who have participated in wellbeing programs more than once in the past year?
SELECT athlete_id FROM athlete_wellbeing WHERE program_date BETWEEN DATEADD(year, -1, GETDATE()) AND GETDATE() GROUP BY athlete_id HAVING COUNT(*) > 1;
gretelai_synthetic_text_to_sql
CREATE TABLE Fisheries (id INT PRIMARY KEY, name VARCHAR(255), species VARCHAR(255), annual_catch INT, location VARCHAR(255)); INSERT INTO Fisheries (id, name, species, annual_catch, location) VALUES (1, 'Fishing Vessel A', 'Cod', 200, 'Arctic');
What is the total annual catch of all fisheries in the Arctic region?
SELECT SUM(annual_catch) FROM Fisheries WHERE location = 'Arctic';
gretelai_synthetic_text_to_sql
CREATE TABLE patients (id INT, name TEXT, age INT, treatment TEXT); INSERT INTO patients (id, name, age, treatment) VALUES (1, 'Alice', 35, 'CBT'), (2, 'Bob', 42, 'DBT');
Update the treatment for patient 'Alice' to 'DBT'.
UPDATE patients SET treatment = 'DBT' WHERE name = 'Alice';
gretelai_synthetic_text_to_sql
CREATE TABLE students (student_id INT PRIMARY KEY, name VARCHAR(50), department VARCHAR(50), grant_recipient BOOLEAN, first_grant_date DATE); INSERT INTO students (student_id, name, department, grant_recipient, first_grant_date) VALUES (1, 'Fiona', 'Engineering', TRUE, '2022-01-01'); CREATE TABLE publications (publication_id INT PRIMARY KEY, student_id INT, publication_date DATE); INSERT INTO publications (publication_id, student_id, publication_date) VALUES (1, 1, '2022-01-01');
List the names and publication dates of research publications by graduate students in the Engineering department who received their first research grant in the past year.
SELECT s.name, p.publication_date FROM students s INNER JOIN publications p ON s.student_id = p.student_id WHERE s.department = 'Engineering' AND s.grant_recipient = TRUE AND s.first_grant_date >= DATEADD(year, -1, GETDATE());
gretelai_synthetic_text_to_sql
CREATE TABLE students (id INT PRIMARY KEY, disability VARCHAR(255), served_by_support_program BOOLEAN); CREATE TABLE support_programs_students (student_id INT, program_id INT); CREATE TABLE support_programs (id INT PRIMARY KEY, state VARCHAR(255));
How many students with learning disabilities have been served by support programs in Florida in the past year?
SELECT COUNT(*) FROM students JOIN support_programs_students ON students.id = support_programs_students.student_id JOIN support_programs ON support_programs_students.program_id = support_programs.id WHERE students.disability = 'learning disabilities' AND support_programs.state = 'Florida' AND students.served_by_support_program = TRUE AND date >= DATE_SUB(CURDATE(), INTERVAL 1 YEAR);
gretelai_synthetic_text_to_sql
CREATE TABLE workforce (id INT, name VARCHAR(50), ethnicity VARCHAR(50), position VARCHAR(50), department VARCHAR(50)); INSERT INTO workforce (id, name, ethnicity, position, department) VALUES (1, 'John Doe', 'Caucasian', 'Engineer', 'Mining'), (2, 'Jane Smith', 'Indigenous', 'Technician', 'Environment'), (3, 'Alice Johnson', 'African', 'Manager', 'Operations');
What is the percentage of employees from indigenous communities in the mining industry?
SELECT (COUNT(CASE WHEN ethnicity = 'Indigenous' THEN 1 ELSE 0 END) * 100.0 / COUNT(*)) as indigenous_percentage FROM workforce;
gretelai_synthetic_text_to_sql
CREATE TABLE agricultural_projects (id INT, project_name VARCHAR(255), funding FLOAT, start_date DATE, state VARCHAR(50)); INSERT INTO agricultural_projects (id, project_name, funding, start_date, state) VALUES (1, 'Precision Farming', 120000.00, '2016-09-18', 'Ogun'), (2, 'Crop Disease Detection', 180000.00, '2017-02-14', 'Ogun'), (3, 'Sustainable Livestock', 150000.00, '2017-11-15', 'Ogun');
What is the total funding received by agricultural innovation projects in Nigeria's Ogun state that started between 2016 and 2017?
SELECT SUM(funding) FROM agricultural_projects WHERE state = 'Ogun' AND start_date BETWEEN '2016-01-01' AND '2017-12-31'
gretelai_synthetic_text_to_sql
CREATE TABLE mental_health_parity (region VARCHAR(20), case_count INT); INSERT INTO mental_health_parity (region, case_count) VALUES ('Northeast', 200), ('Southeast', 150), ('Midwest', 180), ('Southwest', 250), ('West', 220);
What is the average mental health parity case count per region?
SELECT region, AVG(case_count) FROM mental_health_parity GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE Donations (id INT, amount FLOAT, donation_date DATE);
What is the average donation amount per quarter?
SELECT DATE_FORMAT(donation_date, '%Y-%m') as quarter, AVG(amount) as avg_donations FROM Donations GROUP BY quarter;
gretelai_synthetic_text_to_sql
CREATE TABLE investments (id INT, fund_name VARCHAR(255), sector VARCHAR(255), investment_amount FLOAT);
What is the distribution of investments by sector for Red Fund?
SELECT sector, COUNT(*) as num_investments, SUM(investment_amount) as total_invested FROM investments WHERE fund_name = 'Red Fund' GROUP BY sector;
gretelai_synthetic_text_to_sql
CREATE TABLE inspection_records_2 (restaurant_name VARCHAR(255), inspection_date DATE); INSERT INTO inspection_records_2 (restaurant_name, inspection_date) VALUES ('Restaurant A', '2022-04-01'), ('Restaurant A', '2022-04-15'), ('Restaurant B', '2022-04-03');
Determine the number of food safety inspections for each restaurant in the month of April 2022.
SELECT restaurant_name, COUNT(*) FROM inspection_records_2 WHERE inspection_date BETWEEN '2022-04-01' AND '2022-04-30' GROUP BY restaurant_name;
gretelai_synthetic_text_to_sql
CREATE TABLE unions (id INT, name VARCHAR(255), country VARCHAR(255));INSERT INTO unions (id, name, country) VALUES (1, 'TUC', 'UK'), (2, 'CGT', 'France'), (3, 'CISL', 'Italy'), (4, 'DGB', 'Germany');CREATE TABLE ratings (id INT, union_id INT, rating INT, year INT);INSERT INTO ratings (id, union_id, rating, year) VALUES (1, 1, 9, 2018), (2, 1, 9, 2019), (3, 2, 8, 2018), (4, 2, 7, 2019), (5, 3, 7, 2018), (6, 3, 8, 2019), (7, 4, 9, 2018), (8, 4, 8, 2019);
Which unions in Europe have the highest and lowest workplace safety ratings, and what is the average rating for each union?
SELECT unions.name, AVG(ratings.rating) as avg_rating, MAX(ratings.rating) as highest_rating, MIN(ratings.rating) as lowest_rating FROM unions JOIN ratings ON unions.id = ratings.union_id GROUP BY unions.name ORDER BY avg_rating DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE Vendors (vendorID INT, vendorName VARCHAR(50), country VARCHAR(50), fairTrade BOOLEAN); CREATE TABLE Products (productID INT, vendorID INT, productName VARCHAR(50), price DECIMAL(10,2));
List the vendors in Latin America that supply fair trade products and their average product cost.
SELECT V.vendorName, AVG(P.price) FROM Vendors V INNER JOIN Products P ON V.vendorID = P.vendorID WHERE V.country = 'Latin America' AND V.fairTrade = TRUE GROUP BY V.vendorName;
gretelai_synthetic_text_to_sql
CREATE TABLE MiningOperations (id INT, location TEXT, water_consumption INT);INSERT INTO MiningOperations (id, location, water_consumption) VALUES (1, 'Canada', 15000), (2, 'USA', 20000), (3, 'Mexico', 10000);
What is the total amount of water consumed by the mining operations in the 'MiningOperations' table?
SELECT SUM(water_consumption) FROM MiningOperations;
gretelai_synthetic_text_to_sql
CREATE TABLE class_schedule (class_type VARCHAR(50), start_time TIME, end_time TIME, duration INT); INSERT INTO class_schedule (class_type, start_time, end_time, duration) VALUES ('yoga', '06:00:00', '07:00:00', 60), ('spinning', '07:00:00', '08:00:00', 60), ('yoga', '17:00:00', '18:00:00', 60), ('pilates', '08:00:00', '09:00:00', 60);
Find the total duration of 'yoga' classes offered in a week.
SELECT SUM(duration) FROM class_schedule WHERE class_type = 'yoga' AND start_time BETWEEN '00:00:00' AND '23:59:59' GROUP BY class_type;
gretelai_synthetic_text_to_sql
CREATE TABLE arctic_biodiversity (id INTEGER, species VARCHAR(255), population INTEGER);
What is the maximum population recorded for each species in the 'arctic_biodiversity' table?
SELECT species, MAX(population) AS max_population FROM arctic_biodiversity GROUP BY species;
gretelai_synthetic_text_to_sql
CREATE TABLE military_bases (base_name TEXT, region TEXT); INSERT INTO military_bases (base_name, region) VALUES ('Fort Liberty', 'North America'), ('Camp Humphreys', 'Asia');
What is the total number of military bases in the 'Asia' region and their names?
SELECT COUNT(*), base_name FROM military_bases WHERE region = 'Asia'
gretelai_synthetic_text_to_sql
CREATE TABLE TransportationResilienceNY (State TEXT, ProjectSubtype TEXT, ResilienceRating INTEGER); INSERT INTO TransportationResilienceNY (State, ProjectSubtype, ResilienceRating) VALUES ('New York', 'Highway Bridge', 82), ('New York', 'Rail Tunnel', 87), ('New York', 'Airport Runway', 89);
What was the average resilience rating for transportation infrastructure projects in New York, broken down by project subtype?
SELECT ProjectSubtype, AVG(ResilienceRating) as AvgResilience FROM TransportationResilienceNY WHERE State = 'New York' GROUP BY ProjectSubtype;
gretelai_synthetic_text_to_sql
CREATE TABLE city_water_usage (city VARCHAR(50), year INT, consumption INT); INSERT INTO city_water_usage (city, year, consumption) VALUES ('CityA', 2019, 1200), ('CityA', 2020, 1500), ('CityB', 2019, 1000), ('CityB', 2020, 1100);
What is the total water consumption by each city in the year 2020?
SELECT city, SUM(consumption) as total_consumption FROM city_water_usage WHERE year = 2020 GROUP BY city;
gretelai_synthetic_text_to_sql
CREATE TABLE labor_disputes (id INT, year INT, days_of_work_stoppage INT, industry VARCHAR(255)); INSERT INTO labor_disputes (id, year, days_of_work_stoppage, industry) VALUES (1, 2022, 45, 'manufacturing'), (2, 2021, 32, 'manufacturing'), (3, 2022, 38, 'retail');
How many labor disputes occurred in '2021' in the 'retail' schema, which resulted in a work stoppage of more than 30 days?
SELECT COUNT(*) FROM labor_disputes WHERE year = 2021 AND days_of_work_stoppage > 30 AND industry = 'retail';
gretelai_synthetic_text_to_sql
CREATE TABLE navy_recruits (recruit_id INT, name VARCHAR(50), rank VARCHAR(50), join_date DATE);
Insert records of new recruits who joined the navy in 2021 into the navy_recruits table
INSERT INTO navy_recruits (recruit_id, name, rank, join_date) VALUES (1, 'Alex Johnson', 'Ensign', '2021-03-01'), (2, 'Jessica Smith', 'Petty Officer', '2021-07-15'), (3, 'Michael Brown', 'Seaman', '2021-11-27');
gretelai_synthetic_text_to_sql
CREATE TABLE Articles (id INT, title VARCHAR(255), country VARCHAR(50)); INSERT INTO Articles (id, title, country) VALUES (1, 'Article 1', 'USA'), (2, 'Article 2', 'Canada'), (3, 'Article 3', 'Mexico'), (4, 'Article 4', 'USA'), (5, 'Article 5', 'Brazil'), (6, 'Article 6', 'Canada'), (7, 'Article 7', 'USA'), (8, 'Article 8', 'Mexico'), (9, 'Article 9', 'Canada'), (10, 'Article 10', 'USA');
Who are the top 3 countries with the most articles?
SELECT country, COUNT(*) AS Articles_Count FROM Articles GROUP BY country ORDER BY Articles_Count DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE network_investments (investment_id INT, area VARCHAR(20), budgeted_cost FLOAT, actual_cost FLOAT);
Add new network investments for the Northwest region.
INSERT INTO network_investments (investment_id, area, budgeted_cost, actual_cost) VALUES (5, 'Northwest', 75000, 70000);
gretelai_synthetic_text_to_sql
CREATE TABLE revenue(id INT, team VARCHAR(50), game_date DATE, ticket_type VARCHAR(10), price DECIMAL(10, 2), quantity INT);INSERT INTO revenue(id, team, game_date, ticket_type, price, quantity) VALUES (1, 'Dallas Mavericks', '2022-01-01', 'VIP', 100, 500), (2, 'Dallas Mavericks', '2022-01-02', 'VIP', 120, 550), (3, 'Dallas Mavericks', '2021-12-15', 'VIP', 150, 600);
What is the total revenue generated from VIP tickets for the "Dallas Mavericks" team in the last year?
SELECT SUM(price * quantity) FROM revenue WHERE team = 'Dallas Mavericks' AND ticket_type = 'VIP' AND game_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR);
gretelai_synthetic_text_to_sql
CREATE TABLE Events_Locations (event_id INT, event_name VARCHAR(255), city VARCHAR(255), attendance INT); INSERT INTO Events_Locations (event_id, event_name, city, attendance) VALUES (1, 'Art Exhibition', 'Paris', 500), (2, 'Music Festival', 'London', 800), (3, 'Theatre Performance', 'New York', 300);
What is the total attendance for cultural events held in Paris and London?
SELECT SUM(attendance) FROM Events_Locations WHERE city IN ('Paris', 'London');
gretelai_synthetic_text_to_sql
CREATE TABLE if not exists smart_contracts (contract_address VARCHAR(42) PRIMARY KEY, contract_creator VARCHAR(255), contract_language VARCHAR(50), contract_creation_time TIMESTAMP);
What is the total number of smart contracts created by the top 5 contract creators?
SELECT s.contract_creator, COUNT(s.contract_address) as total_contracts FROM smart_contracts s INNER JOIN (SELECT contract_creator, COUNT(*) as contracts_created FROM smart_contracts GROUP BY contract_creator ORDER BY contracts_created DESC LIMIT 5) t ON s.contract_creator = t.contract_creator GROUP BY s.contract_creator;
gretelai_synthetic_text_to_sql
CREATE TABLE bus_fares (fare_id INT, region_id INT, fare DECIMAL(5,2)); INSERT INTO bus_fares (fare_id, region_id, fare) VALUES (1, 1, 1.50), (2, 2, 2.25), (3, 3, 1.75), (4, 2, 2.25);
What are the total fares collected for buses in the 'north' region?
SELECT SUM(bf.fare) FROM bus_fares bf INNER JOIN regions r ON bf.region_id = r.region_id WHERE r.region_name = 'north';
gretelai_synthetic_text_to_sql
CREATE TABLE genres (genre_id INT, genre VARCHAR(255)); INSERT INTO genres VALUES (1, 'Pop'), (2, 'Rock'), (3, 'Jazz'); CREATE TABLE streams (stream_id INT, genre_id INT, revenue DECIMAL(10,2));
What is the total revenue generated by each genre in the music streaming platform?
SELECT g.genre, SUM(s.revenue) as total_revenue FROM genres g JOIN streams s ON g.genre_id = s.genre_id GROUP BY g.genre;
gretelai_synthetic_text_to_sql
CREATE TABLE football_players (player_id INT, player_name VARCHAR(50), nationality VARCHAR(50));CREATE TABLE football_matches (match_id INT, home_team_id INT, away_team_id INT, home_team_goals INT, away_team_goals INT, match_date DATE);
Find the total number of goals scored by players with a nationality of brazilian in football_matches played since 2010.
SELECT SUM(home_team_goals + away_team_goals) AS total_goals FROM football_matches JOIN football_players ON (football_matches.home_team_id = football_players.player_id OR football_matches.away_team_id = football_players.player_id) WHERE football_players.nationality = 'brazilian' AND football_matches.match_date >= '2010-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE Companies (id INT, name VARCHAR(50), industry VARCHAR(50), country VARCHAR(50), founding_year INT, founder_disabled VARCHAR(10)); INSERT INTO Companies (id, name, industry, country, founding_year, founder_disabled) VALUES (1, 'InnoTech', 'Tech', 'USA', 2015, 'Yes'); INSERT INTO Companies (id, name, industry, country, founding_year, founder_disabled) VALUES (2, 'Code4All', 'Tech', 'Germany', 2018, 'No');
What is the distribution of companies by founding year and disability status?
SELECT founding_year, founder_disabled, COUNT(*) as company_count FROM Companies GROUP BY founding_year, founder_disabled;
gretelai_synthetic_text_to_sql
CREATE TABLE lawyers (id INT PRIMARY KEY, name VARCHAR(255), state VARCHAR(2)); CREATE TABLE lawyer_cases (id INT PRIMARY KEY, lawyer_id INT, case_number VARCHAR(50), FOREIGN KEY (lawyer_id) REFERENCES lawyers(id));
Insert new lawyer records into the 'lawyers' table
INSERT INTO lawyers (id, name, state) VALUES (1, 'Nia Jackson', 'NY'); INSERT INTO lawyers (id, name, state) VALUES (2, 'Mateo Lopez', 'CA');
gretelai_synthetic_text_to_sql
CREATE TABLE rural_hospitals (name TEXT, state TEXT, num_beds INTEGER); INSERT INTO rural_hospitals (name, state, num_beds) VALUES ('Hospital A', 'CA', 50), ('Hospital B', 'CA', 75), ('Clinic C', 'TX', 25), ('Clinic D', 'TX', 30);
What is the total number of rural hospitals and clinics in the states of California and Texas?
SELECT COUNT(*) FROM rural_hospitals WHERE state IN ('CA', 'TX');
gretelai_synthetic_text_to_sql
CREATE TABLE Species (SpeciesID INT, SpeciesName TEXT); CREATE TABLE Fish (FishID INT, SpeciesID INT, BirthDate DATE, Weight DECIMAL); INSERT INTO Species VALUES (1, 'Salmon'); INSERT INTO Species VALUES (2, 'Tuna'); INSERT INTO Fish VALUES (1, 1, '2021-01-01', 5.0); INSERT INTO Fish VALUES (2, 1, '2021-02-01', 6.0); INSERT INTO Fish VALUES (3, 2, '2021-03-01', 7.0);
What is the total biomass of fish in the ocean by species and month?
SELECT SpeciesName, EXTRACT(MONTH FROM BirthDate) AS Month, SUM(Weight) AS TotalBiomass FROM Species INNER JOIN Fish ON Species.SpeciesID = Fish.SpeciesID GROUP BY SpeciesName, Month;
gretelai_synthetic_text_to_sql
CREATE TABLE if not exists vehicle_types (vehicle_type varchar(20)); INSERT INTO vehicle_types (vehicle_type) VALUES ('autonomous'), ('manual'); CREATE TABLE if not exists adoption_rates (vehicle_type varchar(20), city varchar(20), adoption_rate float); INSERT INTO adoption_rates (vehicle_type, city, adoption_rate) VALUES ('autonomous', 'tokyo', 25.6), ('manual', 'tokyo', 74.1), ('autonomous', 'tokyo', 26.8), ('manual', 'tokyo', 73.9);
Which autonomous vehicles have the highest and lowest adoption rates in 'tokyo'?
SELECT vehicle_type, MAX(adoption_rate) as highest_rate, MIN(adoption_rate) as lowest_rate FROM adoption_rates WHERE city = 'tokyo' GROUP BY vehicle_type;
gretelai_synthetic_text_to_sql
CREATE TABLE students (student_id INT, district_id INT, num_hours_online_learning INT); INSERT INTO students (student_id, district_id, num_hours_online_learning) VALUES (1, 1, 100), (2, 1, 120), (3, 1, 150), (4, 2, 75), (5, 2, 80), (6, 2, 100), (7, 3, 125), (8, 3, 130), (9, 3, 150);
What is the total number of hours spent by students in online learning in each district, only showing districts with a total of over 500 hours?
SELECT district_id, SUM(num_hours_online_learning) as total_hours FROM students GROUP BY district_id HAVING total_hours > 500;
gretelai_synthetic_text_to_sql
CREATE TABLE satellites (id INT, name VARCHAR(255), international_designator VARCHAR(20));
Delete all satellites with international designators starting with 'C' from the satellites table
DELETE FROM satellites WHERE international_designator LIKE 'C%';
gretelai_synthetic_text_to_sql
CREATE TABLE States (StateName VARCHAR(50), EducationBudget FLOAT); INSERT INTO States (StateName, EducationBudget) VALUES ('California', 50000), ('Texas', 45000), ('New York', 40000), ('Florida', 35000), ('Illinois', 30000);
What are the top 5 states with the highest total budget for education?
SELECT StateName, SUM(EducationBudget) as TotalBudget FROM States GROUP BY StateName ORDER BY TotalBudget DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE community_policing (id INT, city VARCHAR(20), year INT, initiatives INT);
How many community policing initiatives were conducted in 'New York' in the year 2022?
SELECT SUM(initiatives) FROM community_policing WHERE city = 'New York' AND year = 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE company_diversity (company_id INT, sector VARCHAR(20), female_percent FLOAT, minority_percent FLOAT); INSERT INTO company_diversity (company_id, sector, female_percent, minority_percent) VALUES (1, 'technology', 0.4, 0.3), (2, 'healthcare', 0.6, 0.1), (3, 'technology', 0.5, 0.4), (4, 'healthcare', 0.7, 0.2);
List diversity metrics for companies in the 'healthcare' sector.
SELECT sector, female_percent, minority_percent FROM company_diversity WHERE sector = 'healthcare';
gretelai_synthetic_text_to_sql
CREATE TABLE articles (article_id INT, author_id INT, title VARCHAR(100), pub_date DATE); CREATE TABLE authors (author_id INT, author_name VARCHAR(50), country VARCHAR(50)); CREATE TABLE read_counts (article_id INT, read_count INT);
Identify the top 3 most read articles in 'articles' table, with an inner join on 'read_counts' table containing read counts for each article, and the corresponding author information from the 'authors' table.
SELECT articles.title, authors.author_name, SUM(read_counts.read_count) FROM articles INNER JOIN authors ON articles.author_id = authors.author_id INNER JOIN read_counts ON articles.article_id = read_counts.article_id GROUP BY articles.title ORDER BY SUM(read_counts.read_count) DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE songs (song_id INT, genre VARCHAR(20), album VARCHAR(30), artist VARCHAR(30), length FLOAT, release_year INT); CREATE TABLE genres (genre VARCHAR(20)); INSERT INTO genres (genre) VALUES ('pop'), ('rock'), ('jazz'), ('hip-hop'), ('folk'); ALTER TABLE songs ADD CONSTRAINT fk_genre FOREIGN KEY (genre) REFERENCES genres(genre);
What is the minimum length of songs in the folk genre in the songs table?
SELECT MIN(length) as min_length FROM songs WHERE genre = (SELECT genre FROM genres WHERE genre = 'folk');
gretelai_synthetic_text_to_sql
CREATE TABLE companies (id INT, name TEXT, founder_age INT, num_patents INT);
What is the total number of patents filed by startups founded by people over 40?
SELECT SUM(num_patents) FROM companies WHERE founder_age > 40;
gretelai_synthetic_text_to_sql
CREATE TABLE Courses (id INT, name VARCHAR(20), completed BOOLEAN); INSERT INTO Courses (id, name, completed) VALUES (1, 'Introduction to Open Pedagogy', FALSE), (2, 'Advanced Open Pedagogy', FALSE), (3, 'SQL for Open Pedagogy', TRUE);
List open pedagogy courses that are not yet completed by any student.
SELECT * FROM Courses WHERE completed = FALSE;
gretelai_synthetic_text_to_sql
CREATE TABLE if not exists bike_stations (id INT, city VARCHAR(20), num_stations INT); INSERT INTO bike_stations (id, city, num_stations) VALUES (1, 'Rome', 700), (2, 'Milan', 900);
Update the record for bike-sharing stations in Rome to 800
UPDATE bike_stations SET num_stations = 800 WHERE city = 'Rome';
gretelai_synthetic_text_to_sql
CREATE TABLE Museums (id INT, name VARCHAR(50), city VARCHAR(50)); CREATE TABLE Events (id INT, museum_id INT, name VARCHAR(50), year INT, attendees INT); INSERT INTO Museums (id, name, city) VALUES (1, 'Metropolitan Museum of Art', 'New York'); INSERT INTO Events (id, museum_id, name, year, attendees) VALUES (1, 1, 'Event 1', 2015, 2000); INSERT INTO Events (id, museum_id, name, year, attendees) VALUES (2, 1, 'Event 2', 2017, 3000);
What is the average number of attendees for events held at the Metropolitan Museum of Art?
SELECT AVG(attendees) FROM Events WHERE museum_id = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (DonorID int, DonorName varchar(50), Country varchar(50), AmountDonated float); INSERT INTO Donors (DonorID, DonorName, Country, AmountDonated) VALUES (1, 'John Doe', 'USA', 15000.00), (2, 'Jane Smith', 'Canada', 20000.00);
List the donors who have donated more than $10,000 in total, and their corresponding donation dates.
SELECT DonorName, DonationDate FROM Donors D JOIN Donations DON ON D.DonorID = DON.DonorID WHERE D.DonorID IN (SELECT DonorID FROM Donors WHERE AmountDonated > 10000.00);
gretelai_synthetic_text_to_sql
CREATE TABLE satellites (satellite_id INT, country VARCHAR(50), launch_date DATE); INSERT INTO satellites (satellite_id, country, launch_date) VALUES (1, 'USA', '2018-01-01'), (2, 'Russia', '2017-01-01'), (3, 'China', '2020-01-01'), (4, 'Germany', '2016-01-01'), (5, 'Canada', '2021-01-01');
Which countries have launched satellites in the past 5 years?
SELECT country, COUNT(*) as num_launches FROM satellites WHERE launch_date >= DATEADD(year, -5, GETDATE()) GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE peacekeeping_operations_africa (country VARCHAR(50), year INT, budget INT); INSERT INTO peacekeeping_operations_africa (country, year, budget) VALUES ('Egypt', 2020, 900000), ('South Africa', 2020, 800000), ('Nigeria', 2020, 700000), ('Algeria', 2020, 600000), ('Morocco', 2020, 500000);
Identify the top 2 peacekeeping operation budgets for African nations in 2020.
SELECT ROW_NUMBER() OVER (ORDER BY budget DESC) AS rank, country, budget FROM peacekeeping_operations_africa WHERE country IN ('Egypt', 'South Africa', 'Nigeria', 'Algeria', 'Morocco') AND year = 2020 GROUP BY country HAVING rank <= 2;
gretelai_synthetic_text_to_sql
CREATE TABLE green_vehicles (make VARCHAR(50), model VARCHAR(50), year INT, range INT);
What is the minimum range of electric vehicles in the 'green_vehicles' table?
SELECT MIN(range) FROM green_vehicles WHERE make IN ('Tesla', 'Rivian');
gretelai_synthetic_text_to_sql
CREATE TABLE freight_forwarding (request_id INT, request_date DATE); INSERT INTO freight_forwarding (request_id, request_date) VALUES (1, '2022-01-01'), (2, '2022-01-15'), (3, '2022-06-01'), (4, '2022-07-01');
What was the total number of freight forwarding requests in the first half of 2022?
SELECT COUNT(*) FROM freight_forwarding WHERE request_date BETWEEN '2022-01-01' AND '2022-06-30';
gretelai_synthetic_text_to_sql
CREATE TABLE energy_consumption (country VARCHAR(50), tourists INT, energy_consumption FLOAT); INSERT INTO energy_consumption (country, tourists, energy_consumption) VALUES ('Germany', 12000, 5500000), ('Italy', 15000, 6000000), ('Spain', 18000, 5000000), ('France', 10000, 4000000); CREATE TABLE carbon_emissions (country VARCHAR(50), tourists INT, emissions FLOAT); INSERT INTO carbon_emissions (country, tourists, emissions) VALUES ('Germany', 12000, 1300000), ('Italy', 15000, 1200000), ('Spain', 18000, 1100000), ('France', 10000, 900000);
What is the average carbon emissions per tourist for each country in Europe?
SELECT e.country, AVG(c.emissions / e.tourists) AS avg_carbon_emissions FROM energy_consumption e JOIN carbon_emissions c ON e.country = c.country WHERE e.country IN ('Germany', 'Italy', 'Spain', 'France') GROUP BY e.country;
gretelai_synthetic_text_to_sql
CREATE TABLE state_renewable_energy (state VARCHAR(255), year INT, renewable_energy_consumption FLOAT);
What is the percentage of renewable energy consumption in the state of California for the year 2020?
SELECT renewable_energy_consumption/ (SELECT SUM(energy_consumption) FROM state_energy WHERE state = 'California' AND year = 2020) * 100 AS pct FROM state_renewable_energy WHERE state = 'California' AND year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE Employees (EmployeeID int, HireDate date, Salary decimal(10,2)); INSERT INTO Employees (EmployeeID, HireDate, Salary) VALUES (1, '2021-01-01', 90000.00), (2, '2021-01-15', 85000.00), (3, '2021-02-28', 95000.00);
What is the maximum salary for employees who joined the company in January?
SELECT MAX(Salary) FROM Employees WHERE MONTH(HireDate) = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE MusicSales (sale_id INT, sale_date DATE, sale_amount DECIMAL(10,2), genre VARCHAR(255)); INSERT INTO MusicSales (sale_id, sale_date, sale_amount, genre) VALUES (1, '2020-01-01', 15.99, 'Pop'), (2, '2019-12-31', 20.00, 'Rock'), (3, '2020-02-14', 10.99, 'Jazz');
What is the total revenue for the top 3 genres in the year 2020?
SELECT genre, SUM(sale_amount) as total_revenue FROM MusicSales WHERE YEAR(sale_date) = 2020 GROUP BY genre ORDER BY total_revenue DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE ForeignMilitaryAid (Year INT, Country VARCHAR(50), Amount DECIMAL(10,2)); INSERT INTO ForeignMilitaryAid (Year, Country, Amount) VALUES (2005, 'Afghanistan', 5000000), (2006, 'Iraq', 7000000), (2007, 'Pakistan', 6000000), (2008, 'Afghanistan', 5500000), (2009, 'Iraq', 8000000);
Select the Year, Country, and Amount for the top 3 countries with the highest Foreign Military Aid.
SELECT Year, Country, Amount FROM (SELECT Year, Country, Amount, RANK() OVER (ORDER BY Amount DESC) as Rank FROM ForeignMilitaryAid) AS ForeignMilitaryAidRanked WHERE Rank <= 3;
gretelai_synthetic_text_to_sql
CREATE TABLE WaterConsumption (id INT, plant_id INT, consumption_date DATE, consumption INT, district VARCHAR(50)); INSERT INTO WaterConsumption (id, plant_id, consumption_date, consumption, district) VALUES (13, 7, '2021-09-01', 22000, 'Industrial'), (14, 7, '2021-09-02', 23000, 'Industrial'), (15, 8, '2021-09-01', 25000, 'Industrial'), (16, 8, '2021-09-02', 26000, 'Industrial'), (17, 9, '2021-09-01', 21000, 'Industrial'), (18, 9, '2021-09-02', 20000, 'Industrial');
What is the total water consumption for the 'Industrial' district in the month of September?
SELECT SUM(consumption) FROM WaterConsumption WHERE district = 'Industrial' AND MONTH(consumption_date) = 9;
gretelai_synthetic_text_to_sql
CREATE TABLE local_events (event_id INT, event_name TEXT, location TEXT, cause TEXT); INSERT INTO local_events (event_id, event_name, location, cause) VALUES (1, 'Festival of Diversity', 'India', 'Women''s Rights'), (2, 'Sustainable Fashion Show', 'Mexico', 'Environmental Conservation');
How many local events in India and Mexico support environmental conservation and women's rights?
SELECT COUNT(*) FROM local_events WHERE location IN ('India', 'Mexico') AND cause IN ('Environmental Conservation', 'Women''s Rights');
gretelai_synthetic_text_to_sql
CREATE TABLE donors (donor_id INT, donor_name TEXT, donor_country TEXT); INSERT INTO donors (donor_id, donor_name, donor_country) VALUES (1, 'Raj Patel', 'India'), (2, 'Ana Torres', 'Brazil'), (3, 'John Anderson', 'USA'), (4, 'Sophia Kim', 'South Korea'), (5, 'Emilija Novak', 'Croatia'); CREATE TABLE donations (donation_id INT, donor_id INT, donation_amount DECIMAL, donation_date DATE); INSERT INTO donations (donation_id, donor_id, donation_amount, donation_date) VALUES (1, 1, 150, '2022-10-05'), (2, 2, 300, '2022-11-10'), (3, 3, 500, '2022-12-15'), (4, 1, 200, '2022-11-12'), (5, 2, 650, '2022-12-20'), (6, 4, 900, '2022-10-01');
What were the total donation amounts by country in Q4 2022, ranked in descending order?
SELECT donor_country, SUM(donation_amount) as total_donation_amount FROM donations d JOIN donors don ON d.donor_id = don.donor_id WHERE d.donation_date BETWEEN '2022-10-01' AND '2022-12-31' GROUP BY donor_country ORDER BY total_donation_amount DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE employees (id INT, first_name VARCHAR(50), last_name VARCHAR(50), job_title VARCHAR(50), department VARCHAR(50), age INT, salary DECIMAL(10,2), PRIMARY KEY (id)); INSERT INTO employees (id, first_name, last_name, job_title, department, age, salary) VALUES (1, 'John', 'Doe', 'Engineer', 'Mining', 35, 80000.00), (2, 'Jane', 'Doe', 'Operator', 'Mining', 28, 60000.00), (3, 'Mike', 'Johnson', 'Manager', 'Environment', 45, 90000.00), (4, 'Sara', 'Smith', 'Technician', 'Environment', 30, 75000.00), (5, 'David', 'Williams', 'Engineer', 'Sustainability', 40, 80000.00), (6, 'Grace', 'Lee', 'Operator', 'Sustainability', 32, 65000.00);
Update the job title to 'Senior Engineer' for employee with ID 1 and increase their salary by 10%.
UPDATE employees SET job_title = 'Senior Engineer', salary = salary * 1.10 WHERE id = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE railways (id INT, name VARCHAR(50), location VARCHAR(50), length DECIMAL(10,2)); INSERT INTO railways (id, name, location, length) VALUES (1, 'Saskatchewan Grain Railway', 'Saskatchewan', 1250.00);
Calculate the average length of railways in 'Saskatchewan'
SELECT AVG(length) FROM railways WHERE location = 'Saskatchewan';
gretelai_synthetic_text_to_sql
CREATE TABLE Artwork (ArtworkID INT, Title VARCHAR(100), Category VARCHAR(50), Price FLOAT); CREATE TABLE Sales (SaleID INT, ArtworkID INT, SaleDate DATE); INSERT INTO Sales VALUES (1, 1, '2010-05-01'); INSERT INTO Sales VALUES (2, 3, '2019-12-25');
List all artwork sold in the first quarter of 2016.
SELECT A.Title FROM Artwork A JOIN Sales S ON A.ArtworkID = S.ArtworkID WHERE QUARTER(S.SaleDate) = 1 AND YEAR(S.SaleDate) = 2016;
gretelai_synthetic_text_to_sql
CREATE TABLE Health_Stats (ID INT, Country VARCHAR(50), Continent VARCHAR(50), Infant_Mortality_Rate FLOAT); INSERT INTO Health_Stats (ID, Country, Continent, Infant_Mortality_Rate) VALUES (1, 'Nigeria', 'Africa', 69.8);
What is the infant mortality rate in Africa?
SELECT AVG(Infant_Mortality_Rate) FROM Health_Stats WHERE Continent = 'Africa';
gretelai_synthetic_text_to_sql
CREATE TABLE Events (event_id INT, event_name VARCHAR(50), state VARCHAR(50), focus VARCHAR(50), attendee_count INT); INSERT INTO Events (event_id, event_name, state, focus, attendee_count) VALUES (1, 'Music Festival', 'California', 'Music', 300), (2, 'Art Exhibition', 'California', 'Art', 250);
Find the number of events in 'California' with a 'Music' focus that had less than 100 attendees.
SELECT COUNT(*) FROM Events WHERE state = 'California' AND focus = 'Music' AND attendee_count < 100;
gretelai_synthetic_text_to_sql
CREATE TABLE movies (id INT, title VARCHAR(255), genre VARCHAR(64), runtime INT); INSERT INTO movies (id, title, genre, runtime) VALUES (1, 'MovieA', 'documentary', 90), (2, 'MovieB', 'comedy', 120), (3, 'MovieC', 'documentary', 135);
What is the total runtime of all documentaries in the database?
SELECT SUM(runtime) FROM movies WHERE genre = 'documentary';
gretelai_synthetic_text_to_sql
CREATE TABLE manufacturing (manufacturing_id INT, fabric_type VARCHAR(50), collection VARCHAR(50), units_used INT);
How many units of each fabric type were used in manufacturing for the Spring 2022 collection?
SELECT fabric_type, SUM(units_used) FROM manufacturing WHERE collection = 'Spring 2022' GROUP BY fabric_type;
gretelai_synthetic_text_to_sql
CREATE TABLE vulnerabilities (id INT, timestamp TIMESTAMP, software VARCHAR(255), category VARCHAR(255), severity VARCHAR(255)); INSERT INTO vulnerabilities (id, timestamp, software, category, severity) VALUES (1, '2022-01-01 10:00:00', 'Firefox', 'browser', 'high'), (2, '2022-04-02 15:00:00', 'Windows', 'OS', 'medium'), (3, '2022-06-15 12:00:00', 'Zoom', 'application', 'high'), (4, '2022-07-20 09:00:00', 'Slack', 'application', 'high');
Show the top 3 most vulnerable software by the total number of high severity vulnerabilities in the past year.
SELECT software, SUM(CASE WHEN severity = 'high' THEN 1 ELSE 0 END) as high_severity_count FROM vulnerabilities WHERE timestamp >= DATE_SUB(CURRENT_TIMESTAMP(), INTERVAL 1 YEAR) GROUP BY software ORDER BY high_severity_count DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE flights (id INT, airline VARCHAR(255), safety_issue BOOLEAN); INSERT INTO flights (id, airline, safety_issue) VALUES (1, 'Intergalactic', true), (2, 'UniversalAirlines', false), (3, 'Intergalactic', true), (4, 'UniversalAirlines', false), (5, 'Intergalactic', false);
What is the average number of safety issues per flight for 'Intergalactic' and 'UniversalAirlines'?
SELECT airline, AVG(CASE WHEN safety_issue THEN 1.0 ELSE 0.0 END) as avg_issues_per_flight FROM flights GROUP BY airline;
gretelai_synthetic_text_to_sql
CREATE TABLE sensor_status (sensor_id INTEGER, status TEXT, last_reported DATE);
How many sensors are currently malfunctioning in the fields?
SELECT COUNT(*) as malfunctioning_sensors FROM sensor_status WHERE status = 'malfunctioning' AND last_reported < DATEADD(day, -1, CURRENT_DATE);
gretelai_synthetic_text_to_sql
CREATE TABLE Countries (id INT, name VARCHAR(50)); CREATE TABLE Vehicles (id INT, country_id INT, name VARCHAR(50), type VARCHAR(50), cost INT); INSERT INTO Countries (id, name) VALUES (1, 'USA'), (2, 'Germany'), (3, 'Canada'); INSERT INTO Vehicles (id, country_id, name, type, cost) VALUES (1, 1, 'M1 Abrams', 'Tank', 8000000), (2, 1, 'Humvee', 'Truck', 200000), (3, 2, 'Leopard 2', 'Tank', 7000000), (4, 3, 'LSV', 'Truck', 150000), (5, 1, 'Black Hawk', 'Helicopter', 6000000);
Determine the average maintenance cost for military vehicles by country of origin
SELECT c.name, AVG(v.cost) as avg_cost FROM Vehicles v JOIN Countries c ON v.country_id = c.id WHERE v.type IN ('Tank', 'Truck') GROUP BY c.name;
gretelai_synthetic_text_to_sql
CREATE TABLE game_studios (studio_id INT, studio_name TEXT, country TEXT); INSERT INTO game_studios (studio_id, studio_name, country) VALUES (1, 'GameForge', 'Germany'), (2, 'Epic Games', 'United States'), (3, 'Ubisoft', 'Canada'); CREATE TABLE games (game_id INT, game_name TEXT, genre TEXT, studio_id INT); INSERT INTO games (game_id, game_name, genre, studio_id) VALUES (1, 'Assassin’s Creed', 'Action-Adventure', 3), (2, 'Fortnite', 'Battle Royale', 2), (3, 'Splinter Cell', 'Stealth', 3);
How many virtual reality (VR) games have been developed by game studios located in Canada?
SELECT COUNT(games.game_id) FROM games JOIN game_studios ON games.studio_id = game_studios.studio_id WHERE game_studios.country = 'Canada' AND games.genre LIKE '%Virtual Reality%';
gretelai_synthetic_text_to_sql
CREATE SCHEMA if not exists biotech;USE biotech;CREATE TABLE if not exists startups (name VARCHAR(255), country VARCHAR(255), funding FLOAT);INSERT INTO startups (name, country, funding) VALUES ('Startup1', 'USA', 5000000), ('Startup2', 'Canada', 7000000), ('Startup3', 'USA', 3000000), ('Startup4', 'UK', 8000000);
What is the total funding received by biotech startups in each country?
SELECT country, SUM(funding) FROM startups GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE transactions (transaction_id INT, customer_id INT, transaction_date DATE, transaction_amount DECIMAL); INSERT INTO transactions (transaction_id, customer_id, transaction_date, transaction_amount) VALUES (1, 1, '2022-01-01', 150.00), (2, 1, '2022-01-01', 200.00), (3, 2, '2022-01-02', 200.00);
Identify customers who have made more than one transaction in the same day.
SELECT DISTINCT customer_id FROM transactions t1 WHERE (SELECT COUNT(*) FROM transactions t2 WHERE t1.customer_id = t2.customer_id AND t1.transaction_date = t2.transaction_date) > 1;
gretelai_synthetic_text_to_sql
CREATE TABLE genetic_research_projects (id INT, project_name VARCHAR(50), budget FLOAT); INSERT INTO genetic_research_projects (id, project_name, budget) VALUES (1, 'CRISPR Gene Editing', 5000000), (2, 'Stem Cell Research', 7000000), (3, 'Gene Therapy', 8000000);
List all genetic research projects and their corresponding budgets from the 'genetic_research' database.
SELECT project_name, budget FROM genetic_research_projects;
gretelai_synthetic_text_to_sql
CREATE TABLE MakeupProducts (product_id INT, product_name VARCHAR(255), price DECIMAL(5,2), is_natural BOOLEAN, country VARCHAR(50));
What is the maximum selling price of natural makeup products in France?
SELECT MAX(price) FROM MakeupProducts WHERE is_natural = TRUE AND country = 'France';
gretelai_synthetic_text_to_sql
CREATE SCHEMA if not exists biotech;CREATE TABLE if not exists biotech.startups (id INT PRIMARY KEY, name VARCHAR(100), country VARCHAR(50), funding FLOAT);INSERT INTO biotech.startups (id, name, country, funding) VALUES (1, 'StartupA', 'USA', 5000000.0), (2, 'StartupB', 'USA', 1200000.0), (3, 'StartupC', 'Canada', 800000.0);
What is the average funding received by biotech startups in the US?
SELECT AVG(funding) FROM biotech.startups WHERE country = 'USA';
gretelai_synthetic_text_to_sql
CREATE TABLE otas (ota_id INT, ota_name TEXT); INSERT INTO otas (ota_id, ota_name) VALUES (1, 'Expedia'); CREATE TABLE hotel_revenue (hotel_id INT, city TEXT, ota_id INT, revenue FLOAT); INSERT INTO hotel_revenue (hotel_id, city, ota_id, revenue) VALUES (1, 'Berlin', 1, 3000), (2, 'Berlin', 1, 3500), (3, 'Paris', 1, 4000);
What is the total revenue for 'Berlin' hotels from 'Expedia'?
SELECT SUM(revenue) FROM hotel_revenue JOIN otas ON hotel_revenue.ota_id = otas.ota_id JOIN hotels ON hotel_revenue.hotel_id = hotels.hotel_id WHERE hotels.city = 'Berlin' AND otas.ota_name = 'Expedia';
gretelai_synthetic_text_to_sql
CREATE TABLE IoTDevices (device_id INT, device_type VARCHAR(20), region VARCHAR(10), moisture FLOAT); INSERT INTO IoTDevices (device_id, device_type, region, moisture) VALUES (1, 'Soil Moisture Sensor', 'West', 50.5); INSERT INTO IoTDevices (device_id, device_type, region, moisture) VALUES (2, 'Soil Moisture Sensor', 'East', 55.3); INSERT INTO IoTDevices (device_id, device_type, region, moisture) VALUES (3, 'Soil Moisture Sensor', 'North', 60.1); INSERT INTO IoTDevices (device_id, device_type, region, moisture) VALUES (4, 'Soil Moisture Sensor', 'South', 65.7);
What is the average soil moisture level for crops in the 'South' region?
SELECT AVG(moisture) FROM IoTDevices WHERE region = 'South';
gretelai_synthetic_text_to_sql
CREATE TABLE Projects (name TEXT, start_year INT, end_year INT, location TEXT);
How many projects were completed in California?
SELECT COUNT(*) FROM Projects WHERE location = 'California' AND end_year IS NOT NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_species (name TEXT, class TEXT, order TEXT); INSERT INTO marine_species (name, class, order) VALUES ('Blue Whale', 'Mammalia', 'Cetacea'), ('Sperm Whale', 'Mammalia', 'Cetacea'), ('Dolphin', 'Mammalia', 'Cetacea'), ('Walrus', 'Mammalia', 'Carnivora'), ('Manatee', 'Mammalia', 'Sirenia'), ('Turtle', 'Reptilia', 'Testudines'), ('Shark', 'Chondrichthyes', 'Chondrichthyes'), ('Ray', 'Chondrichthyes', 'Chondrichthyes'), ('Flatfish', 'Actinopterygii', 'Pleuronectiformes'), ('Salmon', 'Actinopterygii', 'Salmoniformes');
How many marine species are there in the 'Actinopterygii' class?
SELECT COUNT(*) FROM marine_species WHERE class = 'Actinopterygii';
gretelai_synthetic_text_to_sql
CREATE TABLE claims_table (claim_id INT, policy_holder TEXT, claim_amount INT); INSERT INTO claims_table (claim_id, policy_holder, claim_amount) VALUES (1, 'David Kim', 20000), (2, 'Mike Johnson', 25000), (3, 'Sarah Lee', 60000);
Delete claims with a claim amount over $50,000 from the claims_table
DELETE FROM claims_table WHERE claim_amount > 50000;
gretelai_synthetic_text_to_sql
CREATE TABLE SpaceMissions (id INT, name VARCHAR(50), agency VARCHAR(50), duration INT); INSERT INTO SpaceMissions (id, name, agency, duration) VALUES (1, 'Mir', 'Roscosmos', 4677); INSERT INTO SpaceMissions (id, name, agency, duration) VALUES (2, 'Salyut 6', 'Roscosmos', 1764); INSERT INTO SpaceMissions (id, name, agency, duration) VALUES (3, 'Salyut 7', 'Roscosmos', 1842);
What is the maximum duration (in days) of space missions for Roscosmos?
SELECT MAX(duration) FROM SpaceMissions WHERE agency = 'Roscosmos';
gretelai_synthetic_text_to_sql
CREATE TABLE Events (id INT, event_name VARCHAR(100), event_type VARCHAR(50), location VARCHAR(100), start_time TIMESTAMP); CREATE TABLE Tickets (id INT, ticket_number INT, event_id INT, purchaser_name VARCHAR(100), purchase_date DATE);
How many tickets were sold for events in New York, broken down by event type?
SELECT event_type, COUNT(ticket_number) as tickets_sold FROM Events JOIN Tickets ON Events.id = Tickets.event_id WHERE location LIKE '%New York%' GROUP BY event_type;
gretelai_synthetic_text_to_sql
CREATE TABLE Dispensaries (id INT, name TEXT, state TEXT); INSERT INTO Dispensaries (id, name, state) VALUES (1, 'Sunset Buds', 'California'); CREATE TABLE Strains (id INT, name TEXT, price DECIMAL); INSERT INTO Strains (id, name, price) VALUES (1, 'Purple Haze', 12.50), (2, 'Blue Dream', 14.25), (3, 'Girl Scout Cookies', 15.00), (4, 'OG Kush', 16.00), (5, 'Sour Diesel', 13.75); CREATE TABLE Sales (dispensary_id INT, strain_id INT, quantity INT); INSERT INTO Sales (dispensary_id, strain_id, quantity) VALUES (1, 1, 50), (1, 2, 75), (1, 3, 60), (1, 4, 40), (1, 5, 80);
What are the top 5 strains sold in California dispensaries, along with their average prices?
SELECT Strains.name, AVG(Strains.price) as avg_price FROM Strains JOIN Sales ON Strains.id = Sales.strain_id JOIN Dispensaries ON Sales.dispensary_id = Dispensaries.id WHERE Dispensaries.state = 'California' GROUP BY Strains.name LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE graduate_students (student_id INT, name TEXT, gpa DECIMAL(3,2), department TEXT); CREATE TABLE research_grants (grant_id INT, student_id INT, amount DECIMAL(10,2), date DATE, department TEXT);
What is the total number of research grants awarded to all departments in the past year?
SELECT SUM(rg.amount) FROM research_grants rg WHERE rg.date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR);
gretelai_synthetic_text_to_sql
CREATE TABLE PeacekeepingOperations (OperationID INT, Country VARCHAR(50), MilitaryPersonnel INT); INSERT INTO PeacekeepingOperations (OperationID, Country, MilitaryPersonnel) VALUES (1, 'Bangladesh', 12000), (2, 'Pakistan', 15000), (3, 'Ethiopia', 8000);
What is the total number of military personnel in each country that has participated in peacekeeping operations?
SELECT Country, SUM(MilitaryPersonnel) AS TotalMilitaryPersonnel FROM PeacekeepingOperations GROUP BY Country;
gretelai_synthetic_text_to_sql
CREATE TABLE station_counts (region VARCHAR(10), num_stations INT, num_buses INT); INSERT INTO station_counts (region, num_stations, num_buses) VALUES ('east', 10, 50), ('west', 12, 60), ('north', 15, 75), ('south', 8, 40);
What is the average number of buses per station in the 'north' region?
SELECT AVG(num_buses/num_stations) FROM station_counts WHERE region = 'north';
gretelai_synthetic_text_to_sql
CREATE TABLE Venues (VenueID INT, VenueName VARCHAR(100), Location VARCHAR(50)); INSERT INTO Venues (VenueID, VenueName, Location) VALUES (1001, 'VenueA', 'New York'), (1002, 'VenueB', 'Los Angeles'), (1003, 'VenueC', 'Chicago'), (1004, 'VenueD', 'New York'), (1005, 'VenueE', 'Los Angeles'); CREATE TABLE Concerts (ConcertID INT, VenueID INT, ArtistID INT); INSERT INTO Concerts (ConcertID, VenueID, ArtistID) VALUES (1, 1001, 1), (2, 1002, 2), (3, 1003, 3), (4, 1004, 1), (5, 1005, 2), (6, 1001, 4), (7, 1005, 4);
Which artists have performed in both 'New York' and 'Los Angeles'?
SELECT ArtistID FROM Concerts C1 JOIN Venues V1 ON C1.VenueID = V1.VenueID WHERE V1.Location = 'New York' INTERSECT SELECT ArtistID FROM Concerts C2 JOIN Venues V2 ON C2.VenueID = V2.VenueID WHERE V2.Location = 'Los Angeles';
gretelai_synthetic_text_to_sql