context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE tourism_data (visitor_country VARCHAR(50), destination_country VARCHAR(50), visit_year INT); INSERT INTO tourism_data (visitor_country, destination_country, visit_year) VALUES ('China', 'New Zealand', 2019), ('India', 'New Zealand', 2019), ('USA', 'New Zealand', 2019), ('Indonesia', 'New Zealand', 2019), (...
How many tourists visited New Zealand in 2019 from countries with a population of over 100 million?
SELECT SUM(*) FROM tourism_data JOIN (SELECT DISTINCT visitor_country FROM population_data WHERE population > 100000000) pop ON visitor_country = pop.visitor_country WHERE visit_year = 2019 AND destination_country = 'New Zealand';
gretelai_synthetic_text_to_sql
CREATE TABLE Farmers (id INT PRIMARY KEY, name VARCHAR(255), age INT, gender VARCHAR(10), location VARCHAR(255), farmer_id INT); CREATE TABLE Equipment (id INT PRIMARY KEY, type VARCHAR(255), model VARCHAR(255), purchased_date DATE, last_service_date DATE, farmer_id INT, FOREIGN KEY (farmer_id) REFERENCES Farmers(farme...
List of farmers who haven't had their equipment serviced in the last 6 months?
SELECT Farmers.name, Equipment.type FROM Farmers INNER JOIN Equipment ON Farmers.farmer_id = Equipment.farmer_id WHERE Equipment.last_service_date < DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH);
gretelai_synthetic_text_to_sql
CREATE TABLE Players (id INT, name VARCHAR(50), age INT, country VARCHAR(50), num_games_played INT); INSERT INTO Players (id, name, age, country, num_games_played) VALUES (1, 'Player1', 25, 'USA', 5), (2, 'Player2', 30, 'Canada', 3), (3, 'Player3', 35, 'USA', 10);
How many players are there from each country, and what is the maximum number of games played by a player from a single country?
SELECT country, COUNT(*) AS num_players, MAX(num_games_played) AS max_games_per_country FROM Players GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE case_information(case_id INT, district VARCHAR(10), case_type VARCHAR(10), opened_date DATE); INSERT INTO case_information(case_id, district, case_type, opened_date) VALUES (101, 'Downtown', 'civil', '2021-03-15'), (102, 'Uptown', 'criminal', '2020-12-22'), (103, 'Downtown', 'civil', '2021-08-04'), (104, '...
How many civil cases were opened in 'Downtown' and 'Uptown' districts in 2021?
SELECT COUNT(*) FROM case_information WHERE district IN ('Downtown', 'Uptown') AND YEAR(opened_date) = 2021 AND case_type = 'civil';
gretelai_synthetic_text_to_sql
CREATE TABLE VeteranAccommodations (StudentID INT, Status VARCHAR(10)); INSERT INTO VeteranAccommodations (StudentID, Status) VALUES (1, 'Veteran'), (2, 'Veteran'), (3, 'Refugee'); CREATE TABLE RefugeeAccommodations (StudentID INT, Status VARCHAR(10)); INSERT INTO RefugeeAccommodations (StudentID, Status) VALUES (4, 'R...
What is the total number of accommodations provided to students who are veterans, and the total number of accommodations provided to students who are refugees?
SELECT COUNT(*) FROM VeteranAccommodations WHERE Status = 'Veteran' INTERSECT SELECT COUNT(*) FROM RefugeeAccommodations WHERE Status = 'Refugee';
gretelai_synthetic_text_to_sql
CREATE TABLE AccommodationCosts (CostID INT, StudentID INT, AccommodationType VARCHAR(50), Cost DECIMAL(5,2), CostDate DATE); INSERT INTO AccommodationCosts (CostID, StudentID, AccommodationType, Cost, CostDate) VALUES (1, 1, 'Sign Language Interpreter', 150.00, '2021-01-01');
What is the maximum, minimum, and average cost of accommodations by accommodation type?
SELECT AccommodationType, MAX(Cost) as MaxCost, MIN(Cost) as MinCost, AVG(Cost) as AvgCost FROM AccommodationCosts GROUP BY AccommodationType;
gretelai_synthetic_text_to_sql
CREATE TABLE healthcare_centers (id INT, name TEXT, country TEXT, created_at TIMESTAMP);
Insert a new healthcare center record for 'Hospital del Niño Dios' located in 'Mexico' and created at '2019-01-01 00:00:00'.
INSERT INTO healthcare_centers (name, country, created_at) VALUES ('Hospital del Niño Dios', 'Mexico', '2019-01-01 00:00:00');
gretelai_synthetic_text_to_sql
CREATE TABLE fish_farms (id INT, name TEXT, location TEXT, fish_density INT); INSERT INTO fish_farms (id, name, location, fish_density) VALUES (1, 'Farm A', 'Indian Ocean', 600), (2, 'Farm B', 'Atlantic Ocean', 400);
How many fish are there in fish farms located in the Indian Ocean that have a density greater than 500 fish/m3?
SELECT COUNT(*) FROM fish_farms WHERE location = 'Indian Ocean' AND fish_density > 500;
gretelai_synthetic_text_to_sql
CREATE TABLE legal_aid_servings (serving_id INT, serviced_state VARCHAR(20), servicing_year INT); INSERT INTO legal_aid_servings (serving_id, serviced_state, servicing_year) VALUES (1, 'California', 2017), (2, 'California', 2018), (3, 'California', 2019), (4, 'California', 2020);
How many individuals have been served by legal aid organizations in California since 2017?
SELECT COUNT(*) FROM legal_aid_servings WHERE serviced_state = 'California' AND servicing_year >= 2017;
gretelai_synthetic_text_to_sql
CREATE TABLE species (id INT, species_name VARCHAR(255)); CREATE TABLE habitats (id INT, species_id INT, habitat_type VARCHAR(255), location VARCHAR(255)); INSERT INTO species (id, species_name) VALUES (1, 'Jaguar'), (2, 'Giant Otter'), (3, 'Amazonian Manatee'); INSERT INTO habitats (id, species_id, habitat_type, locat...
Count the number of habitats preserved for each species in Latin America
SELECT species.species_name, COUNT(habitats.id) AS habitat_count FROM species INNER JOIN habitats ON species.id = habitats.species_id WHERE habitats.location = 'Latin America' GROUP BY species.species_name;
gretelai_synthetic_text_to_sql
CREATE TABLE CleanUp (id INT PRIMARY KEY, location VARCHAR(255), cleanup_date DATE, volunteers INT, hours_worked INT);
What is the total number of cleanup efforts and the total number of volunteers for each location, and the total number of cleanup efforts and total number of volunteers for each month?
SELECT l.location, DATE_FORMAT(c.cleanup_date, '%Y-%m') as month, COUNT(*) as total_cleanup_efforts, SUM(volunteers) as total_volunteers FROM CleanUp c INNER JOIN (SELECT DISTINCT location FROM CleanUp) as l ON c.location = l.location GROUP BY l.location, month;
gretelai_synthetic_text_to_sql
CREATE TABLE menu_items (menu_item VARCHAR(255), price DECIMAL(10,2), cost DECIMAL(10,2)); INSERT INTO menu_items (menu_item, price, cost) VALUES ('Wings', 12.99, 3.50), ('Burger', 14.99, 4.50), ('Salad', 11.99, 2.50);
Which menu items have the highest food cost percentage?
SELECT menu_item, (cost/price)*100 AS food_cost_percentage FROM menu_items ORDER BY food_cost_percentage DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE mental_health_conditions (id INT PRIMARY KEY, name VARCHAR(255), description TEXT);
Create a table for mental health conditions
CREATE TABLE mental_health_conditions (id INT PRIMARY KEY, name VARCHAR(255), description TEXT);
gretelai_synthetic_text_to_sql
CREATE TABLE labor_hours (id INT, garment VARCHAR(255), manufacturing_country VARCHAR(255), labor_hours FLOAT, production_date DATE); INSERT INTO labor_hours (id, garment, manufacturing_country, labor_hours, production_date) VALUES (1, 'jeans', 'Pakistan', 4.5, '2021-01-01'); INSERT INTO labor_hours (id, garment, manuf...
Which country has the highest labor hours for jeans production?
SELECT manufacturing_country, MAX(labor_hours) as max_labor_hours FROM labor_hours WHERE garment = 'jeans' GROUP BY manufacturing_country;
gretelai_synthetic_text_to_sql
CREATE TABLE mediterranean_sea (region VARCHAR(255), id INTEGER); INSERT INTO mediterranean_sea (region, id) VALUES ('Mediterranean Sea', 1); CREATE TABLE fish_species (id INTEGER, species VARCHAR(255)); INSERT INTO fish_species (id, species) VALUES (1, 'Sardines'), (2, 'Anchovies'); CREATE TABLE feed_conversion (speci...
List all fish species and their feed conversion ratios in the Mediterranean Sea.
SELECT f.species, c.ratio FROM feed_conversion c JOIN fish_species f ON c.species_id = f.id JOIN mediterranean_sea ms ON c.region_id = ms.id WHERE ms.region = 'Mediterranean Sea';
gretelai_synthetic_text_to_sql
CREATE TABLE Exhibitions (id INT, name VARCHAR(100), curator VARCHAR(100)); INSERT INTO Exhibitions (id, name, curator) VALUES (1, 'Modern Art', 'Charlie'); INSERT INTO Exhibitions (id, name, curator) VALUES (2, 'Ancient Civilizations', 'Delta');
List all exhibitions with a curator named 'Charlie'
SELECT name FROM Exhibitions WHERE curator = 'Charlie';
gretelai_synthetic_text_to_sql
CREATE TABLE MitigationSequestration (Id INT, Project VARCHAR(50), CO2Sequestered DECIMAL(10,2), Location VARCHAR(20));
What is the minimum amount of CO2 sequestered by a single climate change mitigation project in Asia?
SELECT MIN(CO2Sequestered) FROM MitigationSequestration WHERE Location = 'Asia';
gretelai_synthetic_text_to_sql
CREATE TABLE volunteers (id INT, name TEXT, volunteer_date DATE, hours_served INT);
Insert a new record for a volunteer named "Jane Smith" who served 20 hours on February 14, 2022.
INSERT INTO volunteers (id, name, volunteer_date, hours_served) VALUES (1, 'Jane Smith', '2022-02-14', 20);
gretelai_synthetic_text_to_sql
CREATE TABLE artists_mediums (artist_id INT, name VARCHAR(50), medium VARCHAR(50));
List the names of artists who have created pieces in both oil and acrylic mediums.
SELECT name FROM artists_mediums WHERE medium IN ('oil', 'acrylic') GROUP BY name HAVING COUNT(DISTINCT medium) = 2;
gretelai_synthetic_text_to_sql
CREATE TABLE Volunteers (VolunteerID INT, VolunteerName TEXT, JoinDate DATE); INSERT INTO Volunteers (VolunteerID, VolunteerName, JoinDate) VALUES (1, 'Ali', '2021-01-01'), (2, 'Sophia', '2020-06-15'), (3, 'James', '2019-12-31');
What is the number of volunteers who have joined each year?
SELECT YEAR(JoinDate) AS Year, COUNT(*) AS VolunteerCount FROM Volunteers GROUP BY YEAR(JoinDate) ORDER BY Year;
gretelai_synthetic_text_to_sql
CREATE TABLE arizona_water_usage (location VARCHAR(20), is_urban BOOLEAN, water_waste INT); INSERT INTO arizona_water_usage (location, is_urban, water_waste) VALUES ('Phoenix', true, 1200), ('Tucson', true, 900), ('Rural', false, 500);
Identify the total water waste in urban areas of Arizona after implementing water conservation initiatives.
SELECT SUM(water_waste) FROM arizona_water_usage WHERE is_urban = true
gretelai_synthetic_text_to_sql
CREATE TABLE violations (id INT, city VARCHAR(255), violation_date DATE); INSERT INTO violations (id, city, violation_date) VALUES (1, 'New York', '2020-01-01'), (2, 'New York', '2019-12-31'), (3, 'Chicago', '2020-02-01'), (4, 'Chicago', '2020-03-01'), (5, 'Chicago', '2020-03-15');
What is the total number of traffic violations in the city of Chicago for each month in the year 2020?
SELECT city, EXTRACT(MONTH FROM violation_date) as month, COUNT(*) as num_violations FROM violations WHERE city = 'Chicago' AND EXTRACT(YEAR FROM violation_date) = 2020 GROUP BY city, month;
gretelai_synthetic_text_to_sql
CREATE TABLE defense_contracts (contract_id INT, contract_value FLOAT, business_zone VARCHAR(20)); INSERT INTO defense_contracts (contract_id, contract_value, business_zone) VALUES (1, 500000, 'HUBZone'), (2, 750000, 'HUBZone'), (3, 1000000, 'Non-HUBZone');
Find the number of contracts awarded to HUBZone businesses in the Defense industry, broken down by contract value range
SELECT CASE WHEN contract_value < 500000 THEN 'Under 500,000' WHEN contract_value < 1000000 THEN '500,000 to 1,000,000' ELSE 'Over 1,000,000' END AS value_range, COUNT(*) AS contract_count FROM defense_contracts WHERE business_zone = 'HUBZone' GROUP BY value_range;
gretelai_synthetic_text_to_sql
CREATE TABLE football_players (player_id INT, name VARCHAR(50), position VARCHAR(10), team VARCHAR(50), birth_year INT); INSERT INTO football_players (player_id, name, position, team, birth_year) VALUES (1, 'Jane Smith', 'Quarterback', 'New York Giants', 1990);
Delete the records of football players who played for the 'New York Giants' and were born after 1995.
DELETE FROM football_players WHERE team = 'New York Giants' AND birth_year > 1995;
gretelai_synthetic_text_to_sql
CREATE TABLE sports_team_performance (team_name VARCHAR(20), wins INT, losses INT);
Insert a new record into the 'sports_team_performance' table with team_name 'Chicago Bulls', wins 50 and losses 32
INSERT INTO sports_team_performance (team_name, wins, losses) VALUES ('Chicago Bulls', 50, 32);
gretelai_synthetic_text_to_sql
CREATE TABLE rural_hospitals( hospital_id INT PRIMARY KEY, name VARCHAR(255), bed_count INT, rural_population_served INT);
Create a view named 'high_bed_hospitals' with hospitals having more than 100 beds
CREATE VIEW high_bed_hospitals AS SELECT name, bed_count FROM rural_hospitals WHERE bed_count > 100;
gretelai_synthetic_text_to_sql
CREATE TABLE hotel_revenue (hotel_id INT, country VARCHAR(20), daily_revenue FLOAT); INSERT INTO hotel_revenue (hotel_id, country, daily_revenue) VALUES (1, 'Germany', 110), (2, 'Germany', 130), (3, 'Portugal', 160), (4, 'Portugal', 150); CREATE TABLE museum_visitors (visit_id INT, country VARCHAR(20), daily_visitors I...
Find the average daily revenue of eco-friendly hotels in Germany and Portugal, and the average daily visitor count to museums in these two countries.
SELECT AVG(daily_revenue) FROM hotel_revenue WHERE country = 'Germany' UNION ALL SELECT AVG(daily_visitors) FROM museum_visitors WHERE country = 'Germany' UNION ALL SELECT AVG(daily_revenue) FROM hotel_revenue WHERE country = 'Portugal' UNION ALL SELECT AVG(daily_visitors) FROM museum_visitors WHERE country = 'Portugal...
gretelai_synthetic_text_to_sql
CREATE SCHEMA IF NOT EXISTS projects; CREATE TABLE IF NOT EXISTS projects.renewable_energy (project_id INT, project_name VARCHAR(100), project_location VARCHAR(100)); CREATE TABLE IF NOT EXISTS projects.carbon_offset (offset_id INT, offset_name VARCHAR(100), project_id INT);
Show renewable energy projects with their corresponding carbon offset programs?
SELECT r.project_name, r.project_location, c.offset_name FROM projects.renewable_energy AS r JOIN projects.carbon_offset AS c ON r.project_id = c.project_id;
gretelai_synthetic_text_to_sql
CREATE TABLE vessels (id INT, name VARCHAR(255)); INSERT INTO vessels (id, name) VALUES (1, 'VesselA'), (2, 'VesselB'), (3, 'VesselC'); CREATE TABLE safety_records (id INT, vessel_id INT, inspection_date DATE, result ENUM('PASS', 'FAIL')); INSERT INTO safety_records (id, vessel_id, inspection_date, result) VALUES (1, 1...
Identify vessels that have not had a safety inspection in the last year.
SELECT s.vessel_id, v.name FROM safety_records s RIGHT JOIN vessels v ON s.vessel_id = v.id WHERE s.inspection_date < DATE_SUB(CURDATE(), INTERVAL 1 YEAR) OR s.inspection_date IS NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE MissionData (name VARCHAR(50), type VARCHAR(15), duration INT); INSERT INTO MissionData (name, type, duration) VALUES ('Ares 1', 'Low Earth Orbit', 150), ('Artemis 1', 'Deep Space', 300), ('Apollo 11', 'Low Earth Orbit', 200), ('Voyager 1', 'Deep Space', 400);
What is the maximum duration of 'Deep Space' missions?
SELECT MAX(duration) FROM MissionData WHERE type = 'Deep Space';
gretelai_synthetic_text_to_sql
CREATE TABLE ai_budget_usa(budget INT, year INT, country VARCHAR(10)); INSERT INTO ai_budget_usa VALUES (5000000, 2018, 'USA'), (6000000, 2019, 'USA'), (7000000, 2020, 'USA'); CREATE TABLE ai_budget_uk(budget INT, year INT, country VARCHAR(10)); INSERT INTO ai_budget_uk VALUES (4000000, 2018, 'UK'), (4500000, 2019, 'UK...
Find the average annual budget for AI research in the USA, UK, and Japan, for the years 2018-2020.
SELECT AVG(budget) FROM (SELECT budget FROM ai_budget_usa WHERE year BETWEEN 2018 AND 2020 UNION ALL SELECT budget FROM ai_budget_uk WHERE year BETWEEN 2018 AND 2020 UNION ALL SELECT budget FROM ai_budget_japan WHERE year BETWEEN 2018 AND 2020) AS combined;
gretelai_synthetic_text_to_sql
CREATE TABLE concert_genres (concert_id INT, genre VARCHAR(50), attendance INT); INSERT INTO concert_genres VALUES (1, 'Pop', 5000); INSERT INTO concert_genres VALUES (2, 'Jazz', 3000); INSERT INTO concert_genres VALUES (3, 'Rock', 7000);
What are the top 3 most popular music genres by total concert attendance?
SELECT genre, SUM(attendance) AS total_attendance FROM concert_genres GROUP BY genre ORDER BY total_attendance DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE Volunteers (id INT, volunteer_name VARCHAR(50), hours_per_week DECIMAL(3,1), skills VARCHAR(50)); INSERT INTO Volunteers (id, volunteer_name, hours_per_week, skills) VALUES (5, 'Fatima', 6.0, 'Graphic Design'), (6, 'Jose', 4.5, 'Translation'), (7, 'Ali', 5.5, 'Fundraising'), (8, 'Sofia', 7.0, 'Tutoring');
Who are the volunteers with more than 5 hours per week availability?
SELECT volunteer_name FROM Volunteers WHERE hours_per_week > 5.0;
gretelai_synthetic_text_to_sql
CREATE TABLE spacecraft (id INT, name VARCHAR(100), country VARCHAR(50), launch_date DATE); INSERT INTO spacecraft (id, name, country, launch_date) VALUES (1, 'Voyager 1', 'USA', '1977-09-05'); INSERT INTO spacecraft (id, name, country, launch_date) VALUES (2, 'Galileo', 'USA', '1989-10-18'); INSERT INTO spacecraft (id...
What is the total number of spacecraft launched by country?
SELECT country, COUNT(*) as total_launches FROM spacecraft GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE articles (id INT PRIMARY KEY, title TEXT, author_id INT); INSERT INTO articles (id, title, author_id) VALUES (1, 'Diversity Article', 1), (2, 'Article 2', 2), (3, 'Article 3', 3);
What is the total number of articles with the word "diversity" in the title?
SELECT COUNT(id) FROM articles WHERE title LIKE '%diversity%';
gretelai_synthetic_text_to_sql
CREATE TABLE research_submersibles (id INT, name VARCHAR(100), type VARCHAR(50), max_depth FLOAT); CREATE TABLE expeditions (id INT, submersible_id INT, name VARCHAR(100), year INT);
What is the maximum depth ever reached by a research submersible, and what was the name of the submersible and the expedition it was part of?
SELECT rs.name as submersible_name, e.name as expedition_name, rs.max_depth FROM research_submersibles rs INNER JOIN expeditions e ON rs.id = e.submersible_id ORDER BY rs.max_depth DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE RecyclingRates (city VARCHAR(255), population INT, recycling_rate FLOAT); INSERT INTO RecyclingRates (city, population, recycling_rate) VALUES ('New York', 8500000, 35), ('Los Angeles', 4000000, 20), ('Toronto', 3000000, 50);
What is the average recycling rate in percentage for cities with a population over 1 million?
SELECT AVG(recycling_rate) FROM RecyclingRates WHERE population > 1000000;
gretelai_synthetic_text_to_sql
CREATE TABLE tourism_stats (country VARCHAR(255), year INT, visitors INT, continent VARCHAR(255)); INSERT INTO tourism_stats (country, year, visitors, continent) VALUES ('Egypt', 2022, 4000000, 'Africa'); INSERT INTO tourism_stats (country, year, visitors, continent) VALUES ('South Africa', 2022, 2000000, 'Africa'); IN...
Calculate the number of tourists who visited each country in Africa in 2022, excluding Egypt.
SELECT country, SUM(visitors) as total_visitors FROM tourism_stats WHERE continent = 'Africa' AND year = 2022 AND country != 'Egypt' GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE FoiaRequests ( RequestId INT, RequestDate DATE, RequestCity VARCHAR(255) ); INSERT INTO FoiaRequests (RequestId, RequestDate, RequestCity) VALUES (1, '2021-01-01', 'Washington DC'), (2, '2021-02-01', 'Washington DC'), (3, '2021-03-01', 'Washington DC');
How many FOIA requests were submitted per month in Washington DC?
SELECT ROW_NUMBER() OVER (ORDER BY EXTRACT(MONTH FROM RequestDate)) as Month, COUNT(*) as NumRequests FROM FoiaRequests WHERE RequestCity = 'Washington DC' GROUP BY EXTRACT(MONTH FROM RequestDate);
gretelai_synthetic_text_to_sql
CREATE TABLE labor_cost (cost_id INT, province VARCHAR(50), cost_date DATE, gender VARCHAR(50), race VARCHAR(50), labor_cost FLOAT); INSERT INTO labor_cost (cost_id, province, cost_date, gender, race, labor_cost) VALUES (9, 'Saskatchewan', '2022-04-01', 'Male', 'Asian', 7000.00);
What is the total construction labor cost for Asian workers in Saskatchewan in Q2 2022?
SELECT SUM(labor_cost) FROM labor_cost WHERE province = 'Saskatchewan' AND cost_date BETWEEN '2022-04-01' AND '2022-06-30' AND race = 'Asian';
gretelai_synthetic_text_to_sql
CREATE TABLE mental_health_parity_violations (violation_id INT, region TEXT, violation_count INT); INSERT INTO mental_health_parity_violations (violation_id, region, violation_count) VALUES (1, 'Northeast', 10), (2, 'Midwest', 8), (3, 'Pacific Islands', 15);
What is the maximum number of mental health parity violations in each region in the Pacific Islands?
SELECT region, MAX(violation_count) FROM mental_health_parity_violations GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE water_usage (id INT, state VARCHAR(50), consumption FLOAT, date DATE); INSERT INTO water_usage (id, state, consumption, date) VALUES (1, 'California', 15000, '2021-04-01'); INSERT INTO water_usage (id, state, consumption, date) VALUES (2, 'Texas', 12000, '2021-04-02');
Determine the average water consumption in liters for the top 2 states with the highest water consumption in April 2021
SELECT AVG(consumption) FROM (SELECT state, SUM(consumption) AS consumption FROM water_usage WHERE date >= '2021-04-01' AND date <= '2021-04-30' GROUP BY state ORDER BY consumption DESC LIMIT 2) AS top_states;
gretelai_synthetic_text_to_sql
CREATE TABLE movie (id INT, title VARCHAR(100), production_country VARCHAR(50), release_year INT, total_revenue INT); INSERT INTO movie (id, title, production_country, release_year, total_revenue) VALUES (1, 'Avatar', 'United States', 2009, 2787965087);
List all the countries with their respective total revenue for movies released between 2010 and 2015.
SELECT production_country, SUM(total_revenue) FROM movie WHERE release_year BETWEEN 2010 AND 2015 GROUP BY production_country;
gretelai_synthetic_text_to_sql
CREATE TABLE sports (id INT, name VARCHAR(255)); INSERT INTO sports (id, name) VALUES (1, 'Basketball'), (2, 'Soccer'), (3, 'Football'); CREATE TABLE games (id INT, sport_id INT, attendees INT, year INT); INSERT INTO games (id, sport_id, attendees, year) VALUES (1, 1, 2000, 2021), (2, 2, 3000, 2021), (3, 3, 4000, 2021)...
What is the total number of fans who attended each sport's games in 2021?
SELECT s.name, SUM(g.attendees) as total_attendees FROM games g JOIN sports s ON g.sport_id = s.id WHERE g.year = 2021 GROUP BY s.name;
gretelai_synthetic_text_to_sql
CREATE TABLE inventory (inventory_id INT, item_name VARCHAR(50), inventory_category VARCHAR(50), quantity INT); INSERT INTO inventory (inventory_id, item_name, inventory_category, quantity) VALUES (1, 'Tomato', 'Produce', 50), (2, 'Chicken Breast', 'Meat', 100), (3, 'Vanilla Ice Cream', 'Dairy', 75);
How many items are there in each inventory category?
SELECT inventory_category, COUNT(*) FROM inventory GROUP BY inventory_category;
gretelai_synthetic_text_to_sql
CREATE TABLE climate_finance (id INT, project_name VARCHAR(20), project_location VARCHAR(20), finance_type VARCHAR(20), amount INT); INSERT INTO climate_finance (id, project_name, project_location, finance_type, amount) VALUES (1, 'Mitigation Project 1', 'Europe', 'Climate Mitigation', 700000);
Update the amount of climate finance for a specific record in the climate_finance table to 800000.
UPDATE climate_finance SET amount = 800000 WHERE id = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE ConcertData (ArtistCountry TEXT, Month TEXT(2), Year INTEGER, NumOfConcerts INTEGER); INSERT INTO ConcertData (ArtistCountry, Month, Year, NumOfConcerts) VALUES ('USA', '01', 2022, 20), ('UK', '02', 2022, 15), ('Canada', '03', 2022, 18), ('Australia', '04', 2022, 10), ('USA', '05', 2022, 14);
How many concerts were held each month in 2022 by artists from the USA?
SELECT Month, SUM(NumOfConcerts) as TotalConcerts FROM ConcertData WHERE ArtistCountry = 'USA' AND Year = 2022 GROUP BY Month;
gretelai_synthetic_text_to_sql
CREATE TABLE Games (Id INT, Name VARCHAR(100), Genre VARCHAR(50), Platform VARCHAR(50), Publisher VARCHAR(100), PlayTime FLOAT); INSERT INTO Games VALUES (1, 'GameG', 'Action', 'PC', 'Publisher1', 20.5), (2, 'GameH', 'Role-playing', 'VR', 'Publisher2', 35.2), (3, 'GameI', 'Action', 'Console', 'Publisher1', 18.4), (4, '...
What is the average play time for each 'Role-playing' game on PC, by publisher?
SELECT Publisher, AVG(PlayTime) AS Avg_PlayTime FROM Games WHERE Genre = 'Role-playing' AND Platform = 'PC' GROUP BY Publisher;
gretelai_synthetic_text_to_sql
CREATE TABLE Manufacturers (ManufacturerID int, ManufacturerName varchar(50), Region varchar(50)); INSERT INTO Manufacturers (ManufacturerID, ManufacturerName, Region) VALUES (1, 'EcoStitch', 'Midwest'); INSERT INTO Manufacturers (ManufacturerID, ManufacturerName, Region) VALUES (2, 'GreenThreads', 'Northeast'); CREATE...
What is the total quantity of sustainable fabric used by each manufacturer in the Midwest region, ordered by the total quantity?
SELECT m.ManufacturerName, SUM(fu.Quantity) as TotalQuantity FROM Manufacturers m INNER JOIN FabricUsage fu ON m.ManufacturerID = fu.ManufacturerID WHERE m.Region = 'Midwest' AND fu.FabricType = 'sustainable' GROUP BY m.ManufacturerName ORDER BY TotalQuantity DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE animal_population (id INT, animal_name VARCHAR(50), population INT); INSERT INTO animal_population VALUES (1, 'Tiger', 500);
What is the total number of animals in 'animal_population' and 'rehabilitated_animals' tables?
SELECT COALESCE(SUM(ap.population), 0) + COALESCE(SUM(ra.population), 0) FROM animal_population ap RIGHT JOIN rehabilitated_animals ra ON ap.animal_name = ra.animal_name;
gretelai_synthetic_text_to_sql
CREATE TABLE investment (id INT, region VARCHAR(20), category VARCHAR(20), investment FLOAT); INSERT INTO investment (id, region, category, investment) VALUES (1, 'Eastern', 'Renewable Energy', 5000000); INSERT INTO investment (id, region, category, investment) VALUES (2, 'Central', 'Green Building', 3000000);
What is the total investment in renewable energy projects in the Eastern region?
SELECT SUM(investment) FROM investment WHERE region = 'Eastern' AND category = 'Renewable Energy';
gretelai_synthetic_text_to_sql
CREATE TABLE Dispensaries (id INT, name VARCHAR(255), city VARCHAR(255), state VARCHAR(255));CREATE TABLE Inventory (id INT, dispensary_id INT, price DECIMAL(10, 2), product_type VARCHAR(255), grams INT, month INT, year INT);INSERT INTO Dispensaries (id, name, city, state) VALUES (1, 'Emerald City', 'Portland', 'OR');I...
What was the average price per gram of cannabis flower sold by each dispensary in the city of Portland in the month of August 2021?
SELECT d.name, AVG(i.price/i.grams) as avg_price_per_gram FROM Dispensaries d JOIN Inventory i ON d.id = i.dispensary_id WHERE d.city = 'Portland' AND i.product_type = 'flower' AND i.month = 8 AND i.year = 2021 GROUP BY d.name;
gretelai_synthetic_text_to_sql
CREATE TABLE project (id INT, name VARCHAR(50), location VARCHAR(50), start_date DATE); INSERT INTO project (id, name, location, start_date) VALUES (1, 'Green Build', 'NYC', '2020-01-01'), (2, 'Solar Tower', 'LA', '2019-12-15'), (3, 'Eco House', 'Austin', '2020-03-01'); CREATE TABLE labor (id INT, project_id INT, worke...
What is the average number of workers per sustainable project in 'Austin'?
SELECT AVG(l.worker_count) FROM (SELECT COUNT(DISTINCT l.worker) AS worker_count FROM labor l JOIN project p ON l.project_id = p.id JOIN sustainable s ON p.id = s.project_id WHERE p.location = 'Austin' AND s.solar_panels = TRUE GROUP BY l.project_id) l;
gretelai_synthetic_text_to_sql
CREATE TABLE menu_categories (category_id INT, category VARCHAR(255), revenue INT); INSERT INTO menu_categories (category_id, category, revenue) VALUES (1, 'Entree', 5000), (2, 'Side', 2000), (3, 'Entree', 6000), (4, 'Dessert', 3000);
Which menu categories have the highest revenue?
SELECT category, SUM(revenue) as total_revenue FROM menu_categories GROUP BY category ORDER BY total_revenue DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE funding (startup_id INT, investor_type VARCHAR(10));
List all startups that have received funding from "VC" investors but not from "angel" investors
SELECT startups.name FROM startups INNER JOIN funding ON startups.id = funding.startup_id WHERE funding.investor_type = 'VC' AND startups.id NOT IN (SELECT startup_id FROM funding WHERE investor_type = 'angel');
gretelai_synthetic_text_to_sql
CREATE TABLE patients (id INT, name VARCHAR(50), age INT, gender VARCHAR(10), race VARCHAR(20), ethnicity VARCHAR(30)); INSERT INTO patients (id, name, age, gender, race, ethnicity) VALUES (1, 'John Doe', 35, 'Male', 'Caucasian', 'Non-Hispanic'), (2, 'Jane Smith', 40, 'Female', 'African American', 'African American'), ...
Delete the record of patient with ID 3 from the patients table.
DELETE FROM patients WHERE id = 3;
gretelai_synthetic_text_to_sql
CREATE TABLE recycling_rates (id INT, material VARCHAR(20), city VARCHAR(20), rate DECIMAL(3,2)); INSERT INTO recycling_rates (id, material, city, rate) VALUES (1, 'Plastic', 'Tokyo', 0.45), (2, 'Glass', 'Tokyo', 0.65);
Find the recycling rates for 'Plastic' and 'Glass' materials in 'Tokyo'
SELECT material, rate FROM recycling_rates WHERE material IN ('Plastic', 'Glass') AND city = 'Tokyo';
gretelai_synthetic_text_to_sql
CREATE TABLE donations_age_ind (donation_id INT, donor_age INT, amount DECIMAL(10,2), country VARCHAR(255)); INSERT INTO donations_age_ind (donation_id, donor_age, amount, country) VALUES (15, 22, 400.00, 'India'), (16, 38, 550.00, 'India'), (17, 65, 200.00, 'India');
What is the total donation amount by age group in India?
SELECT SUM(amount) as total_donation, FLOOR(donor_age / 10) * 10 as age_group FROM donations_age_ind WHERE country = 'India' GROUP BY age_group;
gretelai_synthetic_text_to_sql
CREATE TABLE RestaurantRevenue (restaurant_id INT, category VARCHAR(50), revenue DECIMAL(10,2)); INSERT INTO RestaurantRevenue (restaurant_id, category, revenue) VALUES (1, 'Italian', 15000.00), (1, 'Mexican', 12000.00), (1, 'Chinese', 18000.00);
What is the total revenue for each category of cuisine, ranked from highest to lowest?
SELECT category, SUM(revenue) as total_revenue FROM restaurantrevenue GROUP BY category ORDER BY total_revenue DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE eu_ets_data (country TEXT, date DATE, price FLOAT); INSERT INTO eu_ets_data (country, date, price) VALUES ('Germany', '2022-01-01', 30.0), ('France', '2022-01-01', 28.0), ('Italy', '2022-01-01', 32.0);
Which countries in the EU have a carbon price (€/tCO2) higher than the average?
SELECT country FROM eu_ets_data WHERE price > (SELECT AVG(price) FROM eu_ets_data);
gretelai_synthetic_text_to_sql
CREATE TABLE Workout (user_id INT, workout_duration INT, country VARCHAR(50)); INSERT INTO Workout (user_id, workout_duration, country) VALUES (1, 30, 'Japan'), (2, 40, 'Japan'), (3, 50, 'Japan'), (4, 60, 'Japan'), (5, 70, 'Japan');
How many users are from Japan in the Workout table?
SELECT COUNT(*) FROM Workout WHERE country = 'Japan';
gretelai_synthetic_text_to_sql
CREATE TABLE shipping_lines (shipping_line_id INT, shipping_line_name VARCHAR(50), cargo_handling_time INT); INSERT INTO shipping_lines (shipping_line_id, shipping_line_name, cargo_handling_time) VALUES (1, 'SL1', 100), (2, 'SL2', 120), (3, 'SL3', 150);
What is the minimum cargo handling time for each shipping line?
SELECT shipping_line_name, MIN(cargo_handling_time) FROM shipping_lines GROUP BY shipping_line_name;
gretelai_synthetic_text_to_sql
CREATE TABLE athletes (id INT PRIMARY KEY, name VARCHAR(100), age INT, sport VARCHAR(50), team VARCHAR(50));
get the average age of athletes in the basketball team
SELECT AVG(age) FROM athletes WHERE sport = 'Basketball' AND team = 'Chicago Bulls';
gretelai_synthetic_text_to_sql
CREATE TABLE properties (property_id INT, sale_date DATE, neighborhood_id INT);CREATE TABLE neighborhoods (neighborhood_id INT, neighborhood_name VARCHAR(255)); INSERT INTO neighborhoods (neighborhood_id, neighborhood_name) VALUES (1, 'NeighborhoodA'), (2, 'NeighborhoodB'); INSERT INTO properties (property_id, sale_dat...
What is the total number of properties sold in each neighborhood, ordered by the highest number of sales?
SELECT neighborhood_id, COUNT(property_id) as sales_in_neighborhood FROM properties GROUP BY neighborhood_id ORDER BY sales_in_neighborhood DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE thai_farms (farmer_id INT, farm_location TEXT, farming_method TEXT); INSERT INTO thai_farms (farmer_id, farm_location, farming_method) VALUES (1, 'Bangkok', 'Ponds'), (2, 'Chiang Mai', 'Cages'), (3, 'Phuket', 'Ponds');
How many farms in Thailand grow fish in ponds?
SELECT COUNT(*) FROM thai_farms WHERE farming_method = 'Ponds';
gretelai_synthetic_text_to_sql
CREATE TABLE students (student_id INT, district_id INT, num_surveys INT); INSERT INTO students (student_id, district_id, num_surveys) VALUES (1, 1, 50), (2, 1, 55), (3, 1, 60), (4, 2, 45), (5, 2, 40), (6, 2, 35), (7, 3, 65), (8, 3, 70), (9, 3, 75);
What is the total number of mental health surveys submitted by students in each district, only showing districts with a total of over 100 surveys?
SELECT district_id, SUM(num_surveys) as total_surveys FROM students GROUP BY district_id HAVING total_surveys > 100;
gretelai_synthetic_text_to_sql
CREATE TABLE animal_populations (id INT, species VARCHAR(50), population INT); INSERT INTO animal_populations (id, species, population) VALUES (1, 'Giraffe', 1500), (2, 'Elephant', 2000), (3, 'Lion', 300), (4, 'Rhinoceros', 800), (5, 'Hippopotamus', 1200);
List the number of animals in each population by species
SELECT species, population FROM animal_populations;
gretelai_synthetic_text_to_sql
CREATE TABLE environmental_impact_assessments (mine_type VARCHAR(20), num_assessments INT); INSERT INTO environmental_impact_assessments (mine_type, num_assessments) VALUES ('Coal', 100), ('Coal', 105), ('Coal', 95), ('Gold', 110), ('Gold', 120), ('Gold', 115);
Compare environmental impact assessments between coal and gold mining sectors.
SELECT mine_type, AVG(num_assessments) FROM environmental_impact_assessments GROUP BY mine_type;
gretelai_synthetic_text_to_sql
CREATE TABLE inspections (id INT, workplace_id INT, state VARCHAR, inspection_date DATE); INSERT INTO inspections (id, workplace_id, state, inspection_date) VALUES (1, 2, 'Texas', '2022-02-15');
What is the total number of workplace safety inspections in Texas by month in 2022?
SELECT EXTRACT(MONTH FROM inspection_date) as month, COUNT(*) as total_inspections FROM inspections WHERE state = 'Texas' AND inspection_date >= '2022-01-01' GROUP BY month;
gretelai_synthetic_text_to_sql
CREATE TABLE military_bases (country VARCHAR(50), num_bases INT); INSERT INTO military_bases (country, num_bases) VALUES ('Egypt', 12), ('Algeria', 15), ('South Africa', 10), ('Morocco', 14), ('Sudan', 11), ('Libya', 8);
What is the maximum number of military bases in African countries?
SELECT MAX(num_bases) FROM military_bases WHERE country IN ('Egypt', 'Algeria', 'South Africa', 'Morocco', 'Sudan', 'Libya');
gretelai_synthetic_text_to_sql
CREATE TABLE tech (id INT PRIMARY KEY, name VARCHAR(255), start_date DATE);
Add a new military technology 'Quantum Computing' with a start date of June 1, 2015.
INSERT INTO tech (name, start_date) VALUES ('Quantum Computing', '2015-06-01');
gretelai_synthetic_text_to_sql
CREATE TABLE PeacekeepingOperations (id INT, operation VARCHAR(50), location VARCHAR(50), start_date DATE, end_date DATE); INSERT INTO PeacekeepingOperations (id, operation, location, start_date, end_date) VALUES (1, 'Operation Restore Hope', 'Somalia', '1992-12-03', '1993-05-04'), (2, 'Operation United Assistance', 'L...
List all peacekeeping operations in Africa and their duration.
SELECT operation, location, end_date - start_date AS duration FROM PeacekeepingOperations WHERE location LIKE '%Africa%';
gretelai_synthetic_text_to_sql
CREATE TABLE nhl_2021_2022 (team TEXT, losses INT);
Find the team with the least losses in the NHL in the 2021-2022 season.
SELECT team, MIN(losses) FROM nhl_2021_2022 GROUP BY team ORDER BY losses ASC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE InfrastructureCostsCA (State TEXT, Year INTEGER, ProjectType TEXT, ConstructionCost REAL); INSERT INTO InfrastructureCostsCA (State, Year, ProjectType, ConstructionCost) VALUES ('California', 2018, 'Bridge', 1800000.0), ('California', 2018, 'Highway', 2400000.0), ('California', 2018, 'Tunnel', 3300000.0), ...
What was the total construction cost for infrastructure projects in California from 2018 to 2020, broken down by project type?
SELECT Year, ProjectType, SUM(ConstructionCost) as TotalCost FROM InfrastructureCostsCA WHERE State = 'California' GROUP BY Year, ProjectType;
gretelai_synthetic_text_to_sql
CREATE TABLE streams (id INT, song_id INT, date DATE, views INT); INSERT INTO streams (id, song_id, date, views) VALUES (1, 1, '2022-01-01', 10000);
What is the maximum number of streams for a hip-hop song in a single day?
SELECT MAX(views) FROM streams WHERE song_id IN (SELECT id FROM tracks WHERE genre = 'Hip-Hop') GROUP BY song_id;
gretelai_synthetic_text_to_sql
CREATE TABLE Cases ( CaseID INT, AttorneyID INT, Region VARCHAR(50), CaseOutcome VARCHAR(50) ); INSERT INTO Cases (CaseID, AttorneyID, Region, CaseOutcome) VALUES (1, 1, 'Northeast', 'Won'), (2, 1, 'Northeast', 'Lost'), (3, 2, 'Northeast', 'Won'), (4, 2, 'Northeast', 'Won'), (5, 3, 'Midwest', 'Won'), (6, 3, 'Midwest', ...
How many cases were won by each attorney in the Northeast region?
SELECT a.Name AS AttorneyName, COUNT(c.CaseID) AS WonCases FROM Attorneys a JOIN Cases c ON a.AttorneyID = c.AttorneyID WHERE a.Region = 'Northeast' AND c.CaseOutcome = 'Won' GROUP BY a.Name;
gretelai_synthetic_text_to_sql
CREATE TABLE startups(name VARCHAR(50), founder_ethnicity VARCHAR(20), budget DECIMAL(10,2));INSERT INTO startups(name, founder_ethnicity, budget) VALUES('StartupA', 'Latinx', 5000000.00), ('StartupB', 'Caucasian', 6000000.00), ('StartupC', 'Latinx', 7000000.00);
What is the minimum budget of a biotech startup founded by a Latinx individual in the US?
SELECT MIN(budget) FROM startups WHERE founder_ethnicity = 'Latinx';
gretelai_synthetic_text_to_sql
CREATE TABLE svalbard_weather(year INT, temperature FLOAT); INSERT INTO svalbard_weather(year, temperature) VALUES (2000, 2.5), (2001, 3.2), (2002, 1.8);
Find the year with the biggest difference in temperature in Svalbard.
SELECT year, temperature, LAG(temperature) OVER (ORDER BY year ASC) lag_temp, temperature - LAG(temperature) OVER (ORDER BY year ASC) temp_diff FROM svalbard_weather WHERE temperature - LAG(temperature) OVER (ORDER BY year ASC) = (SELECT MAX(temp_diff) FROM (SELECT year, temperature, LAG(temperature) OVER (ORDER BY yea...
gretelai_synthetic_text_to_sql
CREATE TABLE carbon_sequestration (country_code CHAR(3), year INT, sequestration FLOAT); INSERT INTO carbon_sequestration (country_code, year, sequestration) VALUES ('ZAF', 2020, 1.1), ('ZAF', 2019, 1.0), ('DEU', 2020, 2.2), ('DEU', 2019, 2.1);
Update carbon sequestration data for South Africa in 2020
UPDATE carbon_sequestration SET sequestration = 1.2 WHERE country_code = 'ZAF' AND year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE vehicle_ownership (id INT, vehicle_type VARCHAR(20), ownership INT);
What is the total number of shared mobility vehicles in 'vehicle_ownership' table?
SELECT SUM(ownership) FROM vehicle_ownership WHERE vehicle_type = 'Shared Mobility';
gretelai_synthetic_text_to_sql
CREATE TABLE machinery (machine_id INT, manufacturer VARCHAR(20)); CREATE TABLE maintenance (machine_id INT); INSERT INTO machinery (machine_id, manufacturer) VALUES (1, 'ABC Corp'), (2, 'XYZ Inc'), (3, 'ABC Corp'); INSERT INTO maintenance (machine_id) VALUES (1), (3);
What is the total number of machines in the 'machinery' table, including any machines that also appear in the 'maintenance' table?
SELECT COUNT(*) FROM machinery INNER JOIN maintenance ON machinery.machine_id = maintenance.machine_id;
gretelai_synthetic_text_to_sql
CREATE TABLE organizations (id INT, name TEXT, country TEXT); INSERT INTO organizations (id, name, country) VALUES (1, 'Foundation X', 'USA'), (2, 'Foundation Y', 'Canada'); CREATE TABLE grants (id INT, organization_id INT, initiative_type TEXT, amount FLOAT); INSERT INTO grants (id, organization_id, initiative_type, a...
What are the names of organizations that have received grants for education initiatives in the US?
SELECT organizations.name FROM organizations JOIN grants ON organizations.id = grants.organization_id WHERE grants.initiative_type = 'Education' AND organizations.country = 'USA';
gretelai_synthetic_text_to_sql
CREATE TABLE Mammals (species VARCHAR(255), region VARCHAR(255), biomass FLOAT); INSERT INTO Mammals (species, region, biomass) VALUES ('Polar Bear', 'Arctic Ocean', 500), ('Reindeer', 'Greenland', 200), ('Polar Fox', 'Norway', 10), ('Musk Ox', 'Canada', 300), ('Walrus', 'Russia', 2000);
Calculate the total biomass of each mammal species in the Arctic regions
SELECT region, species, SUM(biomass) as total_biomass FROM Mammals WHERE region IN ('Arctic Ocean', 'Greenland', 'Norway', 'Canada', 'Russia') GROUP BY region, species;
gretelai_synthetic_text_to_sql
CREATE TABLE nursing_faculty (faculty_id INT, faculty_gender VARCHAR(10), last_publication_date DATE, faculty_department VARCHAR(50)); INSERT INTO nursing_faculty (faculty_id, faculty_gender, last_publication_date, faculty_department) VALUES (1, 'Female', '2022-01-01', 'College of Nursing'), (2, 'Male', '2021-06-15', '...
How many female faculty members are there in the College of Nursing, and how many of them have published research in the past year?
SELECT COUNT(*) as num_faculty, SUM(CASE WHEN last_publication_date >= DATEADD(year, -1, GETDATE()) THEN 1 ELSE 0 END) as num_published FROM nursing_faculty WHERE faculty_department = 'College of Nursing' AND faculty_gender = 'Female';
gretelai_synthetic_text_to_sql
CREATE TABLE CybersecurityBudget (region TEXT, budget INTEGER); INSERT INTO CybersecurityBudget (region, budget) VALUES ('Africa', 500000), ('Europe', 2000000), ('Asia', 1000000), ('NorthAmerica', 3000000), ('SouthAmerica', 800000);
What is the minimum cybersecurity budget for countries in the African region?
SELECT MIN(budget) FROM CybersecurityBudget WHERE region = 'Africa';
gretelai_synthetic_text_to_sql
CREATE TABLE indigenous_food_systems (system_id INT, system_name TEXT, country TEXT, establishment_year INT); INSERT INTO indigenous_food_systems (system_id, system_name, country, establishment_year) VALUES (1, 'Milpa System', 'Guatemala', 2000), (2, 'Maya System', 'Belize', 1500), (3, 'Nahua System', 'El Salvador', 12...
List all indigenous food systems in Central America, along with their establishment years.
SELECT system_name, establishment_year FROM indigenous_food_systems WHERE country = 'Central America';
gretelai_synthetic_text_to_sql
CREATE TABLE farm_biomass_by_location (farm_id INT, location VARCHAR(255), biomass INT); INSERT INTO farm_biomass_by_location (farm_id, location, biomass) VALUES (1, 'Pacific Ocean', 4000), (2, 'Atlantic Ocean', 5000), (3, 'Mediterranean Sea', 3000), (4, 'Pacific Ocean', 6000), (5, 'Atlantic Ocean', 4000);
What is the average biomass of fish in all farms, grouped by location, where the biomass is greater than 3000 tons?
SELECT location, AVG(biomass) FROM farm_biomass_by_location WHERE biomass > 3000 GROUP BY location;
gretelai_synthetic_text_to_sql
CREATE TABLE Vessels (Id INT, Name VARCHAR(50)); CREATE TABLE Accidents (VesselId INT, AccidentDate DATE); INSERT INTO Vessels (Id, Name) VALUES (1, 'Vessel1'), (2, 'Vessel2'), (3, 'Vessel3'), (4, 'Vessel4'); INSERT INTO Accidents (VesselId, AccidentDate) VALUES (1, '2021-02-01'), (2, '2022-03-15'), (3, '2022-01-05'), ...
List the names of vessels that have not had an accident in the last year
SELECT Vessels.Name FROM Vessels LEFT JOIN Accidents ON Vessels.Id = Accidents.VesselId WHERE Accidents.AccidentDate IS NULL OR Accidents.AccidentDate < DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR);
gretelai_synthetic_text_to_sql
CREATE TABLE company_funding (id INT, company_name VARCHAR(50), year INT, location VARCHAR(50), industry VARCHAR(50), funding_amount DECIMAL(10, 2)); CREATE TABLE company_founders (id INT, company_name VARCHAR(50), founder_gender VARCHAR(50));
Display the total funding raised by companies founded by women in the renewable energy sector, in the New York metropolitan area, from 2015 to 2017
SELECT SUM(funding_amount) AS total_funding FROM company_funding JOIN company_founders ON company_funding.company_name = company_founders.company_name WHERE founder_gender = 'Female' AND industry = 'Renewable Energy' AND location = 'New York metropolitan area' AND year BETWEEN 2015 AND 2017;
gretelai_synthetic_text_to_sql
CREATE TABLE months (month_id INT, month_name VARCHAR(255)); CREATE TABLE products (product_id INT, product_name VARCHAR(255), is_refillable BOOLEAN, sales INT, month_id INT);
What is the total sales of refillable skincare products by month?
SELECT m.month_name, SUM(p.sales) as total_sales FROM months m INNER JOIN products p ON m.month_id = p.month_id WHERE p.is_refillable = TRUE AND p.product_name LIKE '%skincare%' GROUP BY m.month_name;
gretelai_synthetic_text_to_sql
CREATE TABLE vehicles (vehicle_id INT, vehicle_model VARCHAR(20), system_name VARCHAR(20)); CREATE TABLE trips (trip_id INT, vehicle_id INT, trip_start_time DATETIME, trip_end_time DATETIME);
List all the unique vehicle IDs and models for each system in August 2021.
SELECT system_name, vehicle_id, vehicle_model FROM vehicles WHERE system_name IN ('Bus', 'Subway', 'Tram') AND trip_start_time BETWEEN '2021-08-01' AND '2021-08-31' GROUP BY system_name, vehicle_id, vehicle_model;
gretelai_synthetic_text_to_sql
CREATE TABLE shipment_data (shipment_id INT, company_id INT, origin_country VARCHAR(50), destination_country VARCHAR(50), num_pallets INT, shipment_date DATE); INSERT INTO shipment_data (shipment_id, company_id, origin_country, destination_country, num_pallets, shipment_date) VALUES (1, 1, 'India', 'Netherlands', 25, '...
How many pallets were shipped from India to the Netherlands in the last month?
SELECT SUM(num_pallets) FROM shipment_data WHERE origin_country = 'India' AND destination_country = 'Netherlands' AND shipment_date >= DATEADD(month, -1, GETDATE());
gretelai_synthetic_text_to_sql
CREATE TABLE defense_innovation (id INT, innovation_name VARCHAR(50), description TEXT, technology_innovation VARCHAR(50), year INT); INSERT INTO defense_innovation (id, innovation_name, description, technology_innovation, year) VALUES (1, 'Laser Weapon System', 'Directed-energy weapon', 'High-energy laser', 2020); INS...
What is the earliest 'technology_innovation' in the 'defense_innovation' table?
SELECT technology_innovation FROM defense_innovation ORDER BY year ASC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE military_bases (base_id INT, base_name VARCHAR(255), maintenance_cost FLOAT); INSERT INTO military_bases (base_id, base_name, maintenance_cost) VALUES (1, 'Fort Bragg', 12000000), (2, 'Camp Pendleton', 15000000), (3, 'Fort Hood', 18000000);
Which military bases have the highest maintenance costs?
SELECT base_name, maintenance_cost FROM military_bases ORDER BY maintenance_cost DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE farm_size (id INT, farm_name VARCHAR(255), size INT, country VARCHAR(255)); INSERT INTO farm_size (id, farm_name, size, country) VALUES (1, 'Farm 1', 50, 'India'); INSERT INTO farm_size (id, farm_name, size, country) VALUES (2, 'Farm 2', 100, 'India'); INSERT INTO farm_size (id, farm_name, size, country) V...
What is the distribution of farms by size in India?
SELECT size, COUNT(*) AS num_farms FROM farm_size WHERE country = 'India' GROUP BY size;
gretelai_synthetic_text_to_sql
CREATE TABLE Crimes (id INT, city VARCHAR(20), date DATE, number_of_crimes INT);
What is the minimum number of crimes committed in a single day in the city of Los Angeles?
SELECT MIN(number_of_crimes) FROM Crimes WHERE city = 'Los Angeles';
gretelai_synthetic_text_to_sql
CREATE TABLE materials (id INT, garment_type VARCHAR(255), material VARCHAR(255), co2_emissions_reduction INT); INSERT INTO materials (id, garment_type, material, co2_emissions_reduction) VALUES (1, 'T-Shirt', 'Recycled Polyester', 3), (2, 'Pants', 'Recycled Cotton', 5), (3, 'Jacket', 'Recycled Nylon', 7);
What is the total CO2 emissions reduction for garments made of recycled materials?
SELECT SUM(co2_emissions_reduction) as total_reduction FROM materials WHERE material LIKE '%Recycled%';
gretelai_synthetic_text_to_sql
CREATE TABLE journalists (name VARCHAR(50), gender VARCHAR(10), years_experience INT); INSERT INTO journalists (name, gender, years_experience) VALUES ('Alice Johnson', 'Female', 12), ('Bob Smith', 'Male', 8), ('Charlie Brown', 'Male', 15), ('Dana Rogers', 'Female', 20), ('Evan Green', 'Male', 7);
Find the total number of female and male journalists in our database.
SELECT SUM(CASE WHEN gender = 'Female' THEN 1 ELSE 0 END) AS total_female, SUM(CASE WHEN gender = 'Male' THEN 1 ELSE 0 END) AS total_male FROM journalists;
gretelai_synthetic_text_to_sql
CREATE TABLE user_demographics (user_id INT, age INT, gender VARCHAR(10), occupation VARCHAR(255));
Insert records into the 'user_demographics' table
INSERT INTO user_demographics (user_id, age, gender, occupation) VALUES (1, 35, 'male', 'software engineer');
gretelai_synthetic_text_to_sql
CREATE TABLE Schools (id INT, name TEXT, country TEXT, num_students INT); INSERT INTO Schools (id, name, country, num_students) VALUES (1, 'School A', 'Middle East', 500); INSERT INTO Schools (id, name, country, num_students) VALUES (2, 'School B', 'Middle East', 750);
What is the maximum number of students served by a school in the Middle East?
SELECT MAX(num_students) FROM Schools WHERE country = 'Middle East';
gretelai_synthetic_text_to_sql