context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE co_ownership (property_id INT, city VARCHAR(20), size INT); INSERT INTO co_ownership (property_id, city, size) VALUES (1, 'Vancouver', 1200), (2, 'Paris', 1000), (3, 'Toronto', 1800);
What is the average property size for co-ownership properties in Paris?
SELECT AVG(size) FROM co_ownership WHERE city = 'Paris' AND property_id IN (SELECT DISTINCT property_id FROM co_ownership WHERE co_ownership.city = 'Paris' AND co_ownership.property_id IS NOT NULL);
gretelai_synthetic_text_to_sql
CREATE TABLE IntelligenceOperations (ID INT, Country VARCHAR(50), Region VARCHAR(10)); INSERT INTO IntelligenceOperations (ID, Country, Region) VALUES (1, 'USA', 'Asia'), (2, 'UK', 'Africa'), (3, 'France', 'Asia'), (4, 'Germany', 'Africa');
Which countries have intelligence operations in 'Asia' and 'Africa'?
SELECT Country FROM IntelligenceOperations WHERE Region IN ('Asia', 'Africa') GROUP BY Country HAVING COUNT(DISTINCT Region) = 2;
gretelai_synthetic_text_to_sql
CREATE TABLE military_sales (id INT, company VARCHAR(255), country VARCHAR(255), sale_value DECIMAL(10,2), sale_date DATE); INSERT INTO military_sales (id, company, country, sale_value, sale_date) VALUES (1, 'Lockheed Martin', 'Brazil', 300000, '2020-01-01'); INSERT INTO military_sales (id, company, country, sale_value, sale_date) VALUES (2, 'Boeing', 'Brazil', 400000, '2019-01-01');
List all military equipment sales by all defense contractors to the Brazilian government in the last 3 years, ordered by sale_date in descending order.
SELECT * FROM military_sales WHERE country = 'Brazil' AND sale_date >= DATE_SUB(CURDATE(), INTERVAL 3 YEAR) ORDER BY sale_date DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE hotels (hotel_id INT, region VARCHAR(50), rating VARCHAR(10), is_eco_friendly BOOLEAN); INSERT INTO hotels (hotel_id, region, rating, is_eco_friendly) VALUES (1, 'Europe', 'Luxury', false), (2, 'Asia', 'Standard', true), (3, 'America', 'Eco-Friendly', true), (4, 'Asia', 'Standard', true);
Which country in Asia has the highest number of eco-friendly hotels?
SELECT region, COUNT(*) as num_hotels FROM hotels WHERE is_eco_friendly = true GROUP BY region ORDER BY num_hotels DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE mangrove_forests (id INT, name VARCHAR(255), country VARCHAR(255), volume DECIMAL(10,2)); INSERT INTO mangrove_forests (id, name, country, volume) VALUES (1, 'Mangrove Forest 1', 'Indonesia', 2000), (2, 'Mangrove Forest 2', 'Indonesia', 3000), (3, 'Mangrove Forest 3', 'Thailand', 1000);
What is the total volume of timber harvested from mangrove forests in Southeast Asia?
SELECT SUM(volume) FROM mangrove_forests WHERE country = 'Indonesia';
gretelai_synthetic_text_to_sql
CREATE TABLE mediterranean_temp (year INT, temperature FLOAT); INSERT INTO mediterranean_temp (year, temperature) VALUES (2018, 25.2), (2019, 25.5), (2020, 26.0), (2021, 26.5), (2022, 27.0);
What is the maximum water temperature recorded in the Mediterranean Sea for the last 5 years?
SELECT MAX(temperature) FROM mediterranean_temp WHERE year BETWEEN (SELECT EXTRACT(YEAR FROM NOW()) - 5) AND EXTRACT(YEAR FROM NOW());
gretelai_synthetic_text_to_sql
CREATE TABLE flu_shots (patient_id INT, state VARCHAR(255)); CREATE TABLE patients (patient_id INT, age INT); INSERT INTO flu_shots (patient_id, state) VALUES (1, 'New York'), (2, 'New York'); INSERT INTO patients (patient_id, age) VALUES (1, 15), (2, 25);
How many flu shots were administered to patients under 18 in New York?
SELECT COUNT(*) FROM flu_shots f INNER JOIN patients p ON f.patient_id = p.patient_id WHERE p.age < 18 AND f.state = 'New York';
gretelai_synthetic_text_to_sql
CREATE TABLE weapons (id INT PRIMARY KEY, weapon_name VARCHAR(50), country VARCHAR(50)); INSERT INTO weapons (id, weapon_name, country) VALUES (1, 'AK-47', 'Russia'); INSERT INTO weapons (id, weapon_name, country) VALUES (2, 'RPG-7', 'Russia');
Delete all records from the 'weapons' table where the 'country' is 'Russia'
DELETE FROM weapons WHERE country = 'Russia';
gretelai_synthetic_text_to_sql
CREATE TABLE crop_planting_history (id INT, location VARCHAR(50), crop VARCHAR(50), planting_date DATE, planting_time TIME); INSERT INTO crop_planting_history (id, location, crop, planting_date, planting_time) VALUES (1, 'Field4', 'Cotton', '2022-02-15', '11:30:00');
Find fields with crop types that have not been planted in the last 30 days.
SELECT location FROM crop_planting_history WHERE planting_date < NOW() - INTERVAL 30 DAY EXCEPT SELECT location FROM crop_planting;
gretelai_synthetic_text_to_sql
CREATE TABLE theater_events (id INT, event_id INT, participant_id INT, country VARCHAR(50)); INSERT INTO theater_events (id, event_id, participant_id, country) VALUES (1, 101, 201, 'USA'), (2, 102, 202, 'Canada'), (3, 103, 203, 'Mexico'); INSERT INTO theater_events (id, event_id, participant_id, country) VALUES (4, 104, 301, 'UK'), (5, 105, 302, 'France'), (6, 106, 303, 'Germany');
How many participants from each country attended the theater events last year?
SELECT country, COUNT(DISTINCT participant_id) FROM theater_events WHERE event_date >= '2021-01-01' GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE inventory(item_id INT, supplier_id INT, quantity INT); CREATE TABLE suppliers(supplier_id INT, name TEXT, location TEXT);
Which suppliers provide more than 10 items?
SELECT suppliers.name FROM suppliers INNER JOIN (SELECT supplier_id, COUNT(*) as item_count FROM inventory GROUP BY supplier_id) as inventory_counts ON suppliers.supplier_id = inventory_counts.supplier_id WHERE item_count > 10;
gretelai_synthetic_text_to_sql
CREATE TABLE medical_supplies (id INT, location VARCHAR(255), distribution_date DATE); INSERT INTO medical_supplies (id, location, distribution_date) VALUES (1, 'Haiti', '2022-01-01'), (2, 'Syria', '2022-01-02'), (3, 'Haiti', '2022-01-03');
What is the total number of medical supply distributions in Haiti?
SELECT COUNT(*) FROM medical_supplies WHERE location = 'Haiti';
gretelai_synthetic_text_to_sql
CREATE TABLE meals (id INT, name VARCHAR(255), customer_id INT, calories INT); INSERT INTO meals (id, name, customer_id, calories) VALUES (1, 'Vegetarian Pizza', 1001, 350), (2, 'Quinoa Salad', 1002, 400), (3, 'Chickpea Curry', 1001, 500); CREATE TABLE customers (id INT, is_vegetarian BOOLEAN); INSERT INTO customers (id, is_vegetarian) VALUES (1001, true), (1002, false);
What is the average calorie intake per meal for vegetarian customers?
SELECT AVG(meals.calories) FROM meals INNER JOIN customers ON meals.customer_id = customers.id WHERE customers.is_vegetarian = true;
gretelai_synthetic_text_to_sql
CREATE TABLE ShariahBanks (id INT, bank_name VARCHAR(50), country VARCHAR(50)); INSERT INTO ShariahBanks (id, bank_name, country) VALUES (1, 'ABC Islamic Bank', 'Malaysia'), (2, 'XYZ Islamic Bank', 'Malaysia'), (3, 'Islamic Bank of Saudi Arabia', 'Saudi Arabia'), (4, 'Al Rajhi Bank', 'Saudi Arabia'), (5, 'Bank Islam Brunei Darussalam', 'Brunei');
What is the number of Shariah-compliant banks in each country?
SELECT country, COUNT(*) as num_banks FROM ShariahBanks GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE organization (id INT, name VARCHAR(255)); CREATE TABLE volunteer (id INT, name VARCHAR(255), organization_id INT); CREATE TABLE donation (id INT, donor_id INT, organization_id INT, amount DECIMAL(10,2));
What is the total number of volunteers and total donation amount for each organization?
SELECT o.name, COUNT(v.id) as total_volunteers, SUM(d.amount) as total_donations FROM volunteer v JOIN organization o ON v.organization_id = o.id JOIN donation d ON o.id = d.organization_id GROUP BY o.id;
gretelai_synthetic_text_to_sql
CREATE TABLE tickets (ticket_id INT, game_name VARCHAR(50), location VARCHAR(50), tickets_sold INT); INSERT INTO tickets (ticket_id, game_name, location, tickets_sold) VALUES (1, 'World Series 2022', 'Boston, MA', 50000), (2, 'World Series 2022', 'New York, NY', 45000);
How many tickets were sold for the 2022 World Series game in Boston, MA?
SELECT SUM(tickets_sold) FROM tickets WHERE game_name = 'World Series 2022' AND location = 'Boston, MA';
gretelai_synthetic_text_to_sql
CREATE TABLE infrastructure_projects (id INT, district VARCHAR(50), project_name VARCHAR(100), start_date DATE, end_date DATE);
List the number of rural infrastructure projects per district that were completed in the last 3 years, sorted by completion date in descending order?
SELECT district, COUNT(*) FROM infrastructure_projects WHERE end_date BETWEEN DATE_SUB(NOW(), INTERVAL 3 YEAR) AND NOW() GROUP BY district ORDER BY end_date DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE tourism_stats (visitor_country VARCHAR(20), destination VARCHAR(20), year INT, tourists INT); INSERT INTO tourism_stats (visitor_country, destination, year, tourists) VALUES ('Canada', 'Toronto', 2021, 600), ('Canada', 'Vancouver', 2021, 700), ('Canada', 'Montreal', 2021, 800);
Find the number of tourists from Canada in each destination in 2021?
SELECT destination, tourists FROM tourism_stats WHERE visitor_country = 'Canada' AND year = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE vr_games (game VARCHAR(20), players INT, release_year INT); INSERT INTO vr_games (game, players, release_year) VALUES ('Game1', 1000, 2019); INSERT INTO vr_games (game, players, release_year) VALUES ('Game2', 500, 2018);
Determine virtual reality games that have more than 800 players and released in 2019
SELECT game FROM vr_games WHERE players > 800 AND release_year = 2019;
gretelai_synthetic_text_to_sql
CREATE TABLE community_development_initiatives (id INT, name TEXT, start_date DATE, country TEXT); INSERT INTO community_development_initiatives (id, name, start_date, country) VALUES (1, 'Initiative G', '2018-05-01', 'Mexico'); INSERT INTO community_development_initiatives (id, name, start_date, country) VALUES (2, 'Initiative H', '2019-07-15', 'Mexico');
How many community development initiatives were initiated in Mexico between 2018 and 2020?
SELECT COUNT(*) FROM community_development_initiatives WHERE country = 'Mexico' AND start_date BETWEEN '2018-01-01' AND '2020-12-31';
gretelai_synthetic_text_to_sql
CREATE TABLE RESEARCH_VESSELS (VESSEL_NAME VARCHAR(20), ORGANIZATION VARCHAR(20), LOCATION VARCHAR(20)); INSERT INTO RESEARCH_VESSELS (VESSEL_NAME, ORGANIZATION, LOCATION) VALUES ('Victor', 'National Oceanic and Atmospheric Administration', 'Pacific Ocean'), ('Atlantis', 'Woods Hole Oceanographic Institution', 'Atlantic Ocean'), ('Sonne', 'Helmholtz Centre for Ocean Research Kiel', 'Indian Ocean'), ('Araon', 'Korea Polar Research Institute', 'Southern Ocean'), ('Healy', 'United States Coast Guard', 'Arctic Ocean');
Show the number of research vessels in each ocean, partitioned by ocean conservation organization.
SELECT LOCATION, ORGANIZATION, COUNT(*) FROM RESEARCH_VESSELS GROUP BY LOCATION, ORGANIZATION;
gretelai_synthetic_text_to_sql
CREATE TABLE audience (id INT, age INT, gender VARCHAR(50), article_id INT); INSERT INTO audience (id, age, gender, article_id) VALUES (1, 30, 'male', 1), (2, 45, 'female', 2); CREATE TABLE articles (id INT, title VARCHAR(50), source VARCHAR(50), date DATE); INSERT INTO articles (id, title, source, date) VALUES (1, 'Article 1', 'Metropolis Herald', '2022-01-01'), (2, 'Article 2', 'Metropolis Herald', '2022-02-01');
What is the distribution of audience demographics by age group for articles in the "Metropolis Herald" in the past year?
SELECT age_groups.age_group, COUNT(audience.id) FROM (SELECT CASE WHEN age < 25 THEN '18-24' WHEN age < 35 THEN '25-34' WHEN age < 45 THEN '35-44' WHEN age < 55 THEN '45-54' ELSE '55+' END AS age_group FROM audience) AS age_groups INNER JOIN audience ON age_groups.age = audience.age INNER JOIN articles ON audience.article_id = articles.id WHERE articles.source = 'Metropolis Herald' AND articles.date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR) GROUP BY age_groups.age_group;
gretelai_synthetic_text_to_sql
CREATE TABLE visitor_stats (country VARCHAR(20), visit_year INT); INSERT INTO visitor_stats (country, visit_year) VALUES ('Canada', 2021), ('Canada', 2021), ('Canada', 2022), ('Canada', 2022), ('Canada', 2022);
What is the total number of tourists who visited Canada in 2021 and 2022?
SELECT SUM(visits) FROM (SELECT COUNT(*) AS visits FROM visitor_stats WHERE country = 'Canada' AND visit_year = 2021 UNION ALL SELECT COUNT(*) FROM visitor_stats WHERE country = 'Canada' AND visit_year = 2022) AS subquery;
gretelai_synthetic_text_to_sql
CREATE TABLE Peacekeeping_Operations (Operation_ID INT PRIMARY KEY, Year INT, Leader VARCHAR(100));
List all peacekeeping operations and their respective operation leads in 2021.
SELECT * FROM Peacekeeping_Operations WHERE Year = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_species (id INT, species_name VARCHAR(255), location VARCHAR(255)); INSERT INTO marine_species (id, species_name, location) VALUES (1, 'Narwhal', 'Arctic'), (2, 'Beluga', 'Arctic');
How many marine species are there in the Arctic?
SELECT COUNT(*) FROM marine_species WHERE marine_species.location = 'Arctic';
gretelai_synthetic_text_to_sql
CREATE TABLE Company (id INT, name TEXT, industry TEXT, location TEXT); INSERT INTO Company (id, name, industry, location) VALUES (1, 'EcoInnovations', 'GreenTech', 'Nigeria'), (2, 'BioSolutions', 'Biotech', 'Brazil'), (3, 'TechBoost', 'Tech', 'India'); CREATE TABLE Employee (id INT, company_id INT, name TEXT, role TEXT, gender TEXT, ethnicity TEXT, date_hired DATE); INSERT INTO Employee (id, company_id, name, role, gender, ethnicity, date_hired) VALUES (1, 1, 'Amina', 'Software Engineer', 'Female', 'Black', '2021-01-10'), (2, 1, 'Bruno', 'Data Scientist', 'Male', 'Latino', '2020-06-01'), (3, 2, 'Chen', 'Hardware Engineer', 'Non-binary', 'Asian', '2019-12-20'), (4, 3, 'Dana', 'Product Manager', 'Female', 'White', '2022-03-01');
How many unique roles are there in the company with the name 'TechBoost'?
SELECT COUNT(DISTINCT Employee.role) FROM Company INNER JOIN Employee ON Company.id = Employee.company_id WHERE Company.name = 'TechBoost';
gretelai_synthetic_text_to_sql
CREATE TABLE Programs (ProgramID INT, ProgramName TEXT); CREATE TABLE Donors (DonorID INT, DonorName TEXT, ProgramID INT, DonationAmount DECIMAL, DonationDate DATE); INSERT INTO Programs (ProgramID, ProgramName) VALUES (1, 'Feeding the Hungry'); INSERT INTO Programs (ProgramID, ProgramName) VALUES (2, 'Tutoring Kids'); INSERT INTO Donors (DonorID, DonorName, ProgramID, DonationAmount, DonationDate) VALUES (1, 'John Doe', 1, 500.00, '2020-01-01'); INSERT INTO Donors (DonorID, DonorName, ProgramID, DonationAmount, DonationDate) VALUES (2, 'Jane Smith', 2, 300.00, '2020-02-15');
What is the average donation amount and total number of donors for each program in the year 2020?
SELECT Programs.ProgramName, AVG(Donors.DonationAmount) as AvgDonation, COUNT(DISTINCT Donors.DonorID) as NumDonors FROM Programs INNER JOIN Donors ON Programs.ProgramID = Donors.ProgramID WHERE YEAR(DonationDate) = 2020 GROUP BY Programs.ProgramName;
gretelai_synthetic_text_to_sql
CREATE TABLE trades (trade_id INT, customer_id INT, trade_date DATE); INSERT INTO trades (trade_id, customer_id, trade_date) VALUES (1, 1, '2022-02-01'), (2, 1, '2022-02-01'), (3, 2, '2022-02-02'), (4, 3, '2022-02-03'), (5, 3, '2022-02-03'), (6, 3, '2022-02-03');
What is the maximum number of trades performed by a single customer in a day?
SELECT customer_id, MAX(count_per_day) FROM (SELECT customer_id, trade_date, COUNT(*) AS count_per_day FROM trades GROUP BY customer_id, trade_date) AS daily_trades GROUP BY customer_id;
gretelai_synthetic_text_to_sql
CREATE TABLE restaurant_revenue(menu_category VARCHAR(20), revenue DECIMAL(10, 2), order_date DATE); INSERT INTO restaurant_revenue(menu_category, revenue, order_date) VALUES ('Vegetarian', 2000, '2021-01-01'), ('Vegetarian', 2200, '2021-01-03'), ('Vegetarian', 1800, '2021-01-12');
What was the total revenue for the 'Vegetarian' menu category in January 2021?
SELECT SUM(revenue) FROM restaurant_revenue WHERE menu_category = 'Vegetarian' AND order_date >= '2021-01-01' AND order_date <= '2021-01-31';
gretelai_synthetic_text_to_sql
CREATE TABLE AthleteWellbeing (AthleteID INT, ProgramName VARCHAR(50)); CREATE TABLE AthleteIllnesses (AthleteID INT, IllnessDate DATE);
List all athletes who participated in the wellbeing program but did not have any illnesses in the last season.
SELECT AthleteID FROM AthleteWellbeing WHERE AthleteID NOT IN (SELECT AthleteID FROM AthleteIllnesses WHERE IllnessDate >= DATEADD(YEAR, -1, GETDATE()));
gretelai_synthetic_text_to_sql
CREATE TABLE subway_stations (station_id INT, station_name VARCHAR(50), city VARCHAR(50), time_between_arrivals TIME, rush_hour BOOLEAN); INSERT INTO subway_stations (station_id, station_name, city, time_between_arrivals, rush_hour) VALUES (1, 'Union Station', 'Toronto', '5:00', false), (2, 'Yonge-Bloor Station', 'Toronto', '4:00', false), (3, 'Finch Station', 'Toronto', '3:00', false);
What is the minimum time between subway train arrivals in Toronto during off-peak hours?
SELECT MIN(TIME_TO_SEC(time_between_arrivals))/60.0 FROM subway_stations WHERE city = 'Toronto' AND rush_hour = false;
gretelai_synthetic_text_to_sql
CREATE TABLE ptsd_age (patient_id INT, region TEXT, age INT); INSERT INTO ptsd_age (patient_id, region, age) VALUES (12, 'Eastern', 33); INSERT INTO ptsd_age (patient_id, region, age) VALUES (13, 'Western', 41);
What is the average age of patients diagnosed with PTSD in the Eastern region?
SELECT AVG(age) FROM ptsd_age WHERE region = 'Eastern';
gretelai_synthetic_text_to_sql
CREATE TABLE marine_species (id INT, species VARCHAR(50), ocean VARCHAR(50), feeding_habits VARCHAR(50), conservation_status VARCHAR(50));
What is the total number of marine species in the Indian Ocean, grouped by their feeding habits and conservation status?
SELECT ocean, feeding_habits, conservation_status, COUNT(*) FROM marine_species WHERE ocean = 'Indian Ocean' GROUP BY ocean, feeding_habits, conservation_status;
gretelai_synthetic_text_to_sql
CREATE TABLE economic_diversification (id INT, industry VARCHAR(255), country VARCHAR(255), progress_percent FLOAT, year INT); INSERT INTO economic_diversification (id, industry, country, progress_percent, year) VALUES (1, 'Textiles', 'India', 22.6, 2016), (2, 'IT Services', 'India', 30.9, 2016), (3, 'Automobiles', 'India', 26.4, 2016);
Economic diversification progress, by industry and country, for the year 2016?
SELECT country, industry, AVG(progress_percent) as average_progress_percent FROM economic_diversification WHERE year = 2016 GROUP BY country, industry;
gretelai_synthetic_text_to_sql
CREATE TABLE space_mission_budgets(id INT, agency VARCHAR(255), mission_name VARCHAR(255), launch_date DATE, budget DECIMAL(10,2));
What is the maximum budget for a single space mission launched by any space agency between 2010 and 2020, inclusive?
SELECT MAX(budget) FROM space_mission_budgets WHERE launch_date BETWEEN '2010-01-01' AND '2020-12-31';
gretelai_synthetic_text_to_sql
CREATE TABLE indigenous_food_systems (system_id INT, system_name TEXT, area FLOAT); INSERT INTO indigenous_food_systems (system_id, system_name, area) VALUES (1, 'Acorn Farming', 12.5), (2, 'Maple Syrup Production', 18.7), (3, 'Bison Ranching', 25.0);
What is the minimum area (in hectares) required for an indigenous food system to operate sustainably?
SELECT MIN(area) FROM indigenous_food_systems WHERE system_name = 'Bison Ranching';
gretelai_synthetic_text_to_sql
CREATE TABLE Consumer_Preferences (Consumer_ID INT, Product_ID INT, Preference_Score INT); INSERT INTO Consumer_Preferences (Consumer_ID, Product_ID, Preference_Score) VALUES (1, 101, 9), (2, 101, 8), (3, 102, 7), (4, 103, 6), (5, 102, 5), (6, 104, 4), (7, 105, 3), (8, 103, 2), (9, 106, 1), (10, 101, 10);
What are the top 5 preferred lipstick shades among consumers in the US?
SELECT Product_ID, SUM(Preference_Score) as Total_Preference FROM Consumer_Preferences WHERE Consumer_ID IN (SELECT Consumer_ID FROM Consumers WHERE Country = 'USA') GROUP BY Product_ID ORDER BY Total_Preference DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE aircraft_manufacturing (id INT PRIMARY KEY, manufacturer VARCHAR(255), model VARCHAR(255), production_year INT, quantity INT);
Insert data into the 'aircraft_manufacturing' table
INSERT INTO aircraft_manufacturing (id, manufacturer, model, production_year, quantity) VALUES (1, 'Boeing', '737 MAX', 2017, 1000);
gretelai_synthetic_text_to_sql
CREATE TABLE Advocacy_Budget (budget_year INT, amount DECIMAL(5,2));
What is the total budget allocated for policy advocacy efforts in the last 5 years?
SELECT SUM(amount) FROM Advocacy_Budget WHERE budget_year BETWEEN YEAR(CURRENT_DATE)-5 AND YEAR(CURRENT_DATE);
gretelai_synthetic_text_to_sql
CREATE TABLE GameDesignData (Game VARCHAR(20), Genre VARCHAR(20), Players INT); INSERT INTO GameDesignData (Game, Genre, Players) VALUES ('Fortnite', 'Battle Royale', 50000), ('Call of Duty', 'FPS', 30000), ('Minecraft', 'Sandbox', 12000), ('Among Us', 'Social Deduction', 70000), ('Valorant', 'FPS', 35000), ('Rainbow Six Siege', 'FPS', 22000);
Identify the unique game genres for games with over 20000 players
SELECT DISTINCT Genre FROM GameDesignData WHERE Players > 20000
gretelai_synthetic_text_to_sql
CREATE TABLE SustainableTourism (Destination VARCHAR(255), Year INT, SustainabilityScore INT);
What are the top 5 destinations for sustainable tourism in 2021?
SELECT Destination, SustainabilityScore, ROW_NUMBER() OVER (ORDER BY SustainabilityScore DESC) AS Rank FROM SustainableTourism WHERE Year = 2021 AND SustainabilityScore > 0 GROUP BY Destination HAVING Rank <= 5;
gretelai_synthetic_text_to_sql
CREATE TABLE volunteers (id INT, name TEXT, signup_date DATE, program TEXT); INSERT INTO volunteers (id, name, signup_date, program) VALUES (1, 'Bob Brown', '2022-01-15', 'Education'), (2, 'Charlie Davis', '2022-03-30', 'Arts'), (3, 'Eva Thompson', '2021-12-31', 'Education');
How many volunteers signed up in Q1 2022 for the education program?
SELECT COUNT(*) FROM volunteers WHERE program = 'Education' AND signup_date >= '2022-01-01' AND signup_date < '2022-04-01';
gretelai_synthetic_text_to_sql
CREATE TABLE artists (id INT, name TEXT); INSERT INTO artists (id, name) VALUES (1, 'Monet'), (2, 'Renoir'); CREATE TABLE artworks (id INT, artist_id INT, title TEXT, medium TEXT); INSERT INTO artworks (id, artist_id, title, medium) VALUES (1, 1, 'Water Lilies', 'Oil on canvas'), (2, 1, 'Bridge over a Pond', 'Oil on canvas'), (3, 2, 'Dance at Bougival', 'Oil on canvas'); CREATE TABLE artist_specialties (id INT, artist_id INT, specialty TEXT); INSERT INTO artist_specialties (id, artist_id, specialty) VALUES (1, 1, 'Impressionism');
List all artworks and their respective mediums from the 'impressionist' artist?
SELECT artworks.title, artworks.medium FROM artworks INNER JOIN artist_specialties ON artworks.artist_id = artist_specialties.artist_id WHERE artist_specialties.specialty = 'Impressionism';
gretelai_synthetic_text_to_sql
CREATE TABLE marine_species (id INT, name VARCHAR(255), country VARCHAR(255), continent VARCHAR(255)); INSERT INTO marine_species (id, name, country, continent) VALUES (1, 'Species1', 'Country1', 'Continent1'), (2, 'Species2', 'Country2', 'Continent2');
Identify countries with the highest number of marine species, by continent?
SELECT continent, country, COUNT(*) as species_count FROM marine_species GROUP BY continent, country ORDER BY continent, species_count DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE subway_fares (id INT, route VARCHAR(10), fare FLOAT); INSERT INTO subway_fares (id, route, fare) VALUES (1, '1', 2.50), (2, '2', 3.25), (3, '3', 4.00);
What is the maximum fare for a trip on the subway?
SELECT MAX(fare) FROM subway_fares;
gretelai_synthetic_text_to_sql
CREATE TABLE audience_demographics (article_id INT, category VARCHAR(30), word_count INT, age INT, gender VARCHAR(10), author VARCHAR(50)); INSERT INTO audience_demographics (article_id, category, word_count, age, gender, author) VALUES (1, 'Politics', 500, 20, 'Male', 'Sophia Lee'), (2, 'Sports', 700, 25, 'Female', 'Maria Rodriguez');
Who are the top 2 authors with the most articles in the 'audience_demographics' table, and what is the age range of their audience?
SELECT author, COUNT(article_id) AS total_articles, MIN(age) AS min_age, MAX(age) AS max_age FROM audience_demographics GROUP BY author ORDER BY total_articles DESC LIMIT 2;
gretelai_synthetic_text_to_sql
CREATE TABLE clinical_trials_2 (drug_name VARCHAR(50), trial_outcome VARCHAR(50)); INSERT INTO clinical_trials_2 (drug_name, trial_outcome) VALUES ('DrugC', 'Approved'), ('DrugD', 'Rejected'), ('DrugC', 'Approved');
What are the clinical trial outcomes for drug 'DrugC'?
SELECT drug_name, trial_outcome FROM clinical_trials_2 WHERE drug_name = 'DrugC';
gretelai_synthetic_text_to_sql
CREATE TABLE carbon_offsets (initiative_name VARCHAR(50), country VARCHAR(50), initiation_year INT); INSERT INTO carbon_offsets (initiative_name, country, initiation_year) VALUES ('Initiative1', 'India', 2021), ('Initiative2', 'India', 2019), ('Initiative3', 'India', 2021);
What is the total number of carbon offset initiatives implemented in India in 2021?
SELECT COUNT(*) FROM carbon_offsets WHERE country = 'India' AND initiation_year = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE PublicServices (ServiceID INT, ServiceName VARCHAR(255), State VARCHAR(255), AllocationDate DATE, Budget DECIMAL(10,2)); INSERT INTO PublicServices (ServiceID, ServiceName, State, AllocationDate, Budget) VALUES (1, 'Waste Management', 'California', '2020-03-15', 50000.00), (2, 'Street Lighting', 'California', '2019-08-28', 30000.00);
What is the average budget allocation per public service in the state of California in the last 2 years, ordered by average allocation amount in descending order?
SELECT AVG(Budget), ServiceName FROM PublicServices WHERE State = 'California' AND AllocationDate >= DATEADD(year, -2, GETDATE()) GROUP BY ServiceName ORDER BY AVG(Budget) DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE donors (id INT, age INT, name VARCHAR(255)); INSERT INTO donors (id, age, name) VALUES (2, 63, 'Senior Donor'); CREATE TABLE donations (id INT, donor_id INT, organization_id INT, amount DECIMAL(10,2), donation_date DATE); INSERT INTO donations (id, donor_id, organization_id, amount, donation_date) VALUES (2, 2, 2, 15000, '2021-02-12');
What is the maximum donation amount given by donors aged 60 or older?
SELECT MAX(amount) FROM donations JOIN donors ON donations.donor_id = donors.id WHERE donors.age >= 60;
gretelai_synthetic_text_to_sql
CREATE TABLE users (id INT, username VARCHAR(50), followers INT, country VARCHAR(50)); CREATE TABLE posts (id INT, user_id INT, content VARCHAR(500));
List the top 10 most active users in terms of total number of posts, along with the number of followers they have, for users in India.
SELECT u.username, u.followers, COUNT(p.id) as total_posts FROM users u JOIN posts p ON u.id = p.user_id WHERE u.country = 'India' GROUP BY u.id ORDER BY total_posts DESC LIMIT 10;
gretelai_synthetic_text_to_sql
CREATE TABLE player_transactions (transaction_id INT, player_id INT, amount FLOAT, date DATE);
Delete records in the 'player_transactions' table where the transaction amount is below 10
DELETE FROM player_transactions WHERE amount < 10;
gretelai_synthetic_text_to_sql
CREATE TABLE CitySmartInitiatives (City VARCHAR(255), Initiative VARCHAR(255), InitiativeCategory VARCHAR(255), CO2EmissionReduction FLOAT); INSERT INTO CitySmartInitiatives (City, Initiative, InitiativeCategory, CO2EmissionReduction) VALUES ('NYC', 'SmartGrid', 'Energy', 15000), ('LA', 'SmartTransit', 'Transportation', 20000), ('Chicago', 'SmartBuildings', 'Energy', 10000);
What is the total CO2 emission reduction for each smart city initiative, partitioned by initiative category and ordered by the total reduction?
SELECT InitiativeCategory, SUM(CO2EmissionReduction) OVER (PARTITION BY InitiativeCategory) AS Total_Reduction FROM CitySmartInitiatives ORDER BY Total_Reduction DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE Events (event_id INT, event_name VARCHAR(255), team VARCHAR(255), month VARCHAR(255)); INSERT INTO Events VALUES (1, 'Match 1', 'WNBA', 'June'), (2, 'Match 2', 'MLS', 'June');
How many 'WNBA' and 'MLS' events were held in 'June'?
SELECT COUNT(*) FROM Events WHERE (team = 'WNBA' OR team = 'MLS') AND month = 'June';
gretelai_synthetic_text_to_sql
CREATE TABLE environmental_impact (id INT PRIMARY KEY, continent VARCHAR(50), impact_score INT, operation_date DATE); INSERT INTO environmental_impact (id, continent, impact_score, operation_date) VALUES (1, 'North America', 75, '2020-01-01'), (2, 'South America', 85, '2019-05-05'), (3, 'North America', 65, '2021-03-15');
What's the average environmental impact score for mining operations in each continent, in the last 3 years?
SELECT continent, AVG(impact_score) as avg_score FROM environmental_impact WHERE operation_date >= DATEADD(year, -3, GETDATE()) GROUP BY continent;
gretelai_synthetic_text_to_sql
CREATE TABLE cultural_sites (id INT, city TEXT, preservation_score INT); INSERT INTO cultural_sites (id, city, preservation_score) VALUES (1, 'Madrid', 7), (2, 'Madrid', 9), (3, 'Madrid', 8);
What is the maximum preservation score of cultural heritage sites in Madrid?
SELECT MAX(preservation_score) FROM cultural_sites WHERE city = 'Madrid';
gretelai_synthetic_text_to_sql
CREATE TABLE offenders (id INT PRIMARY KEY, name VARCHAR(255), age INT, state VARCHAR(2));
Update the record of offender with id 1
UPDATE offenders SET name = 'Jamal Johnson-Smith', age = 36 WHERE id = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE WomenInTech(name VARCHAR(255), role VARCHAR(255), hours_per_week DECIMAL(5,2));INSERT INTO WomenInTech(name, role, hours_per_week) VALUES('Alice', 'Software Engineer', 40.00), ('Bob', 'Product Manager', 45.00), ('Carol', 'Data Scientist', 50.00), ('Dana', 'QA Engineer', 35.00), ('Eva', 'UX Designer', 30.00);
What is the minimum and maximum number of hours worked per week by women in tech roles in Australia?
SELECT MIN(hours_per_week), MAX(hours_per_week) FROM WomenInTech WHERE role LIKE '%tech%';
gretelai_synthetic_text_to_sql
CREATE TABLE clients (id INT, name TEXT, region TEXT, billing_amount DECIMAL(10, 2)); INSERT INTO clients (id, name, region, billing_amount) VALUES (1, 'Alice', 'chicago', 200.00), (2, 'Bob', 'chicago', 300.00), (3, 'Charlie', 'chicago', 400.00);
What is the minimum billing amount for clients in the 'chicago' region?
SELECT MIN(billing_amount) FROM clients WHERE region = 'chicago';
gretelai_synthetic_text_to_sql
CREATE TABLE Buildings (building_id INT, name VARCHAR(255), num_students INT, num_teachers INT, mental_health_resources BOOLEAN);
What is the total number of students and teachers who have access to mental health resources, by building?
SELECT building_id, name, SUM(num_students) AS total_students, SUM(num_teachers) AS total_teachers FROM Buildings WHERE mental_health_resources = TRUE GROUP BY building_id, name;
gretelai_synthetic_text_to_sql
CREATE TABLE Military_Expenditure_Defense_Diplomacy (id INT, region VARCHAR(50), year INT, expenditure INT);
What is the total military expenditure for defense diplomacy by each region in the past decade?
SELECT region, SUM(expenditure) as total_expenditure FROM Military_Expenditure_Defense_Diplomacy WHERE year BETWEEN (YEAR(CURRENT_DATE) - 10) AND YEAR(CURRENT_DATE) GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE Budget (budget_id INT, program_category VARCHAR(255), budget_amount DECIMAL(10,2), budget_date DATE); INSERT INTO Budget (budget_id, program_category, budget_amount, budget_date) VALUES (1, 'Education', 5000, '2021-01-01'), (2, 'Health', 3500, '2021-02-01'), (3, 'Environment', 7000, '2021-03-01'), (4, 'Education', 2800, '2021-04-01'), (5, 'Health', 6000, '2021-05-01');
What was the total budget spent on 'Education' and 'Health' programs in 2021?
SELECT program_category, SUM(budget_amount) as total_budget FROM Budget WHERE budget_date BETWEEN '2021-01-01' AND '2021-12-31' AND program_category IN ('Education', 'Health') GROUP BY program_category;
gretelai_synthetic_text_to_sql
CREATE TABLE Warehouses (WarehouseID int, WarehouseName varchar(255), Country varchar(255));CREATE TABLE Shipments (ShipmentID int, WarehouseID int, LeadTime int); INSERT INTO Warehouses (WarehouseID, WarehouseName, Country) VALUES (1, 'W1', 'USA'); INSERT INTO Shipments (ShipmentID, WarehouseID, LeadTime) VALUES (1, 1, 5);
Provide a list of all warehouses and their average lead times, grouped by country.
SELECT w.Country, AVG(s.LeadTime) as AvgLeadTime FROM Warehouses w INNER JOIN Shipments s ON w.WarehouseID = s.WarehouseID GROUP BY w.Country;
gretelai_synthetic_text_to_sql
CREATE TABLE artist_demographics (artist_id INT, artist_name TEXT, artist_gender TEXT);
Update the artist_demographics table to include the correct artist_gender for artist 'Alexander' with artist_id 101.
UPDATE artist_demographics SET artist_gender = 'Male' WHERE artist_id = 101 AND artist_name = 'Alexander';
gretelai_synthetic_text_to_sql
CREATE TABLE diversity (company_name VARCHAR(50), underrepresented_community BOOLEAN); INSERT INTO diversity (company_name, underrepresented_community) VALUES ('Acme Inc', TRUE), ('Beta Corp', FALSE), ('Echo Startups', TRUE);
Show the total funding for startups founded by people from underrepresented communities
SELECT SUM(funding_amount) FROM funding INNER JOIN company_founding ON funding.company_name = company_founding.company_name INNER JOIN diversity ON funding.company_name = diversity.company_name WHERE diversity.underrepresented_community = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE Bridges ( BridgeID INT, Name VARCHAR(255), Region VARCHAR(255), MaintenanceCost DECIMAL(10, 2), Year INT);
Find the top 3 bridges with the highest maintenance costs in the 'Northeast' region, for the year 2020.
SELECT * FROM ( SELECT *, ROW_NUMBER() OVER (PARTITION BY Region ORDER BY MaintenanceCost DESC) as rank FROM Bridges WHERE Year = 2020 AND Region = 'Northeast') sub WHERE rank <= 3;
gretelai_synthetic_text_to_sql
CREATE TABLE cases (id INT, date DATE, legal_aid_org_id INT);CREATE VIEW latest_quarter AS SELECT EXTRACT(QUARTER FROM date) as quarter, EXTRACT(MONTH FROM date) as month FROM cases;
What is the total number of legal aid cases handled by each organization, in the last quarter?
SELECT legal_aid_org_id, COUNT(*) as total_cases_handled FROM cases INNER JOIN latest_quarter ON EXTRACT(QUARTER FROM cases.date) = latest_quarter.quarter GROUP BY legal_aid_org_id;
gretelai_synthetic_text_to_sql
CREATE TABLE events (event_id INT, event_name TEXT, location_id INT); CREATE TABLE locations (location_id INT, district_id INT, location_text TEXT);
List all disaster preparedness events and their corresponding locations in the 'Westside' district.
SELECT e.event_name, l.location_text FROM events e INNER JOIN locations l ON e.location_id = l.location_id WHERE l.district_id = (SELECT district_id FROM districts WHERE district_name = 'Westside');
gretelai_synthetic_text_to_sql
CREATE TABLE climate_finance (id INT, committer VARCHAR(255), committed_amount DECIMAL(10,2), commit_year INT, sector VARCHAR(255));
What is the total amount of climate finance committed by the United States in the climate communication sector?
SELECT SUM(committed_amount) FROM climate_finance WHERE committer = 'United States' AND sector = 'climate communication';
gretelai_synthetic_text_to_sql
CREATE TABLE machines (id INT PRIMARY KEY, name VARCHAR(255), type VARCHAR(255), status VARCHAR(255)); INSERT INTO machines (id, name, type, status) VALUES (1, 'Machine A', 'CNC', 'Operational'), (2, 'Machine B', 'Robotic Arm', 'Under Maintenance'), (3, 'Machine C', 'CNC', 'Operational');
Retrieve the number of machines that are operational
SELECT COUNT(*) FROM machines WHERE status = 'Operational';
gretelai_synthetic_text_to_sql
CREATE TABLE dispensary_sales (customer_id INT, first_name VARCHAR(50), last_name VARCHAR(50), state VARCHAR(2));
Insert new record into 'dispensary_sales' table with data: customer_id: 101, first_name: 'John', last_name: 'Doe', state: 'NY'
INSERT INTO dispensary_sales (customer_id, first_name, last_name, state) VALUES (101, 'John', 'Doe', 'NY');
gretelai_synthetic_text_to_sql
CREATE TABLE expenses (id INT, category TEXT, year INT, amount FLOAT); INSERT INTO expenses (id, category, year, amount) VALUES (1, 'Food', 2018, 5000.00); INSERT INTO expenses (id, category, year, amount) VALUES (2, 'Clothing', 2019, 3000.00); INSERT INTO expenses (id, category, year, amount) VALUES (3, 'Food', 2020, 8000.00);
What was the total amount spent on food aid in 2020?
SELECT SUM(amount) FROM expenses WHERE category = 'Food' AND year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE strains (strain VARCHAR(30), state VARCHAR(20), quarter VARCHAR(10)); INSERT INTO strains (strain, state, quarter) VALUES ('Blue Dream', 'California', 'Q1'), ('Gorilla Glue', 'California', 'Q1'), ('Sour Diesel', 'California', 'Q1');
How many unique strains were available in California dispensaries in Q1 2022?
SELECT COUNT(DISTINCT strain) as unique_strains FROM strains WHERE state = 'California' AND quarter = 'Q1';
gretelai_synthetic_text_to_sql
CREATE TABLE memberships (id INT, member_type VARCHAR(50), region VARCHAR(50)); CREATE TABLE workout_data (member_id INT, workout_type VARCHAR(50), duration INT, heart_rate_avg INT, calories_burned INT, workout_date DATE);
What is the maximum duration for each workout type in the East region?
SELECT w.workout_type, MAX(w.duration) as max_duration FROM memberships m JOIN workout_data w ON m.id = w.member_id WHERE m.region = 'East' GROUP BY w.workout_type;
gretelai_synthetic_text_to_sql
CREATE TABLE emergency_calls (id INT, region VARCHAR(10), response_time INT); INSERT INTO emergency_calls (id, region, response_time) VALUES (1, 'west', 120), (2, 'west', 150), (3, 'east', 195), (4, 'north', 105);
How many emergency calls were received in the 'east' region with a response time greater than 180 minutes?
SELECT COUNT(*) FROM emergency_calls WHERE region = 'east' AND response_time > 180;
gretelai_synthetic_text_to_sql
CREATE TABLE wells (well_id varchar(10), region varchar(20), production_figures int); INSERT INTO wells (well_id, region, production_figures) VALUES ('W005', 'Caspian Sea', 2500), ('W006', 'Caspian Sea', 1500);
What is the total production figure for all wells located in the Caspian Sea?
SELECT SUM(production_figures) FROM wells WHERE region = 'Caspian Sea';
gretelai_synthetic_text_to_sql
CREATE TABLE Dispensaries (id INT, name TEXT, state TEXT); INSERT INTO Dispensaries (id, name, state) VALUES (1, 'Dispensary A', 'Oregon'); CREATE TABLE Sales (dispid INT, date DATE, strain TEXT, price DECIMAL(10,2)); INSERT INTO Sales (dispid, date, strain, price) VALUES (1, '2022-04-01', 'Strain X', 10.5); INSERT INTO Sales (dispid, date, strain, price) VALUES (1, '2022-04-02', 'Strain X', 10.75);
What was the average price per gram for each strain sold at a specific dispensary in Oregon in Q2 2022?
SELECT s.strain, AVG(s.price) as avg_price_per_gram FROM Dispensaries d JOIN Sales s ON d.id = s.dispid WHERE d.state = 'Oregon' AND d.name = 'Dispensary A' AND QUARTER(s.date) = 2 GROUP BY s.strain;
gretelai_synthetic_text_to_sql
CREATE TABLE mission_data (mission_id INT, name VARCHAR(100), organization VARCHAR(100), launch_date DATE, mission_cost FLOAT);
What is the total cost of all Mars missions launched by any organization in the mission_data table?
SELECT SUM(mission_cost) FROM mission_data WHERE mission_data.name IN (SELECT missions.name FROM (SELECT mission_data.name FROM mission_data WHERE mission_data.organization != 'NASA' AND mission_data.mission_cost IS NOT NULL) AS missions WHERE missions.name LIKE '%Mars%');
gretelai_synthetic_text_to_sql
CREATE TABLE ocean_trenches (trench_name TEXT, location TEXT, avg_depth FLOAT); INSERT INTO ocean_trenches VALUES ('Mariana Trench', 'Pacific Ocean', 8178), ('Tonga Trench', 'South Pacific Ocean', 10820), ('Kuril-Kamchatka Trench', 'Pacific Ocean', 8340);
What is the average depth of the oceanic trenches?
SELECT AVG(avg_depth) FROM ocean_trenches;
gretelai_synthetic_text_to_sql
CREATE TABLE artworks (id INT, name VARCHAR(255), year INT, artist_name VARCHAR(255), artist_birthplace VARCHAR(255), category VARCHAR(255)); INSERT INTO artworks (id, name, year, artist_name, artist_birthplace, category) VALUES (1, 'Painting', 1920, 'John', 'England', 'painting'), (2, 'Sculpture', 1930, 'Sara', 'France', 'sculpture'), (3, 'Print', 1940, 'Alex', 'Germany', 'print');
What is the total number of artworks in the 'sculpture' category created by artists from Europe?
SELECT COUNT(*) FROM artworks WHERE category = 'sculpture' AND artist_birthplace LIKE 'Europe%';
gretelai_synthetic_text_to_sql
CREATE TABLE freight_forwarding (item VARCHAR(255), country VARCHAR(255)); INSERT INTO freight_forwarding (item, country) VALUES ('apple', 'USA'), ('banana', 'Canada'), ('orange', 'Mexico');
Which countries did freight forwarding operations take place in, excluding the USA?
SELECT country FROM freight_forwarding WHERE country != 'USA';
gretelai_synthetic_text_to_sql
CREATE TABLE company_founding (id INT, name VARCHAR(50), country VARCHAR(50), founding_year INT, gender VARCHAR(10)); INSERT INTO company_founding (id, name, country, founding_year, gender) VALUES (1, 'Acme Inc', 'USA', 2010, 'Male'), (2, 'Beta Corp', 'Canada', 2005, 'Female'), (3, 'Gamma Inc', 'India', 2012, 'Male'), (4, 'Delta Corp', 'Brazil', 2008, 'Female');
What is the total number of female and male founders for each country?
SELECT country, gender, COUNT(*) as total FROM company_founding GROUP BY ROLLUP(country, gender);
gretelai_synthetic_text_to_sql
CREATE TABLE incident_resolution_times (id INT, sector VARCHAR(255), incident_type VARCHAR(255), resolution_time FLOAT, occurrence_date DATE); INSERT INTO incident_resolution_times (id, sector, incident_type, resolution_time, occurrence_date) VALUES (1, 'Healthcare', 'Insider Threat', 20, '2021-07-01');
What was the maximum resolution time for insider threats in the healthcare sector in North America in H2 2021?
SELECT MAX(resolution_time) AS max_resolution_time FROM incident_resolution_times WHERE sector = 'Healthcare' AND incident_type = 'Insider Threat' AND occurrence_date >= '2021-07-01' AND occurrence_date < '2022-01-01' AND region = 'North America';
gretelai_synthetic_text_to_sql
CREATE TABLE chemical_production (production_date DATE, chemical_code VARCHAR(10), quantity INT); INSERT INTO chemical_production (production_date, chemical_code, quantity) VALUES ('2021-01-03', 'A123', 450), ('2021-01-07', 'A123', 620), ('2021-01-12', 'A123', 390), ('2021-02-15', 'B456', 550), ('2021-02-19', 'B456', 700), ('2021-03-05', 'C789', 800), ('2021-03-10', 'C789', 900), ('2021-03-15', 'C789', 850);
Get the chemical code, production_date, and quantity for the records with a production quantity greater than 700
SELECT chemical_code, production_date, quantity FROM chemical_production WHERE quantity > 700;
gretelai_synthetic_text_to_sql
CREATE TABLE esports_events (id INT PRIMARY KEY, name VARCHAR(50), date DATE);
Insert a new esports event with the name 'Fantasy Quest World Cup' and date '2023-08-01'
INSERT INTO esports_events (name, date) VALUES ('Fantasy Quest World Cup', '2023-08-01');
gretelai_synthetic_text_to_sql
CREATE TABLE building_permits (permit_id INT, building_type VARCHAR(50), city VARCHAR(50), issue_date DATE); INSERT INTO building_permits (permit_id, building_type, city, issue_date) VALUES (13, 'Residential', 'Chicago', '2021-01-01'); INSERT INTO building_permits (permit_id, building_type, city, issue_date) VALUES (14, 'Residential', 'Chicago', '2021-02-01');
What is the total number of permits issued for residential buildings in the city of Chicago in 2021?
SELECT COUNT(*) FROM building_permits WHERE building_type = 'Residential' AND city = 'Chicago' AND YEAR(issue_date) = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE green_climate_fund (fund_id INT, project_name VARCHAR(100), country VARCHAR(50), amount FLOAT); INSERT INTO green_climate_fund (fund_id, project_name, country, amount) VALUES (1, 'Solar Power Africa', 'Africa', 50000000);
What is the total amount of climate finance provided to projects in Africa by the Green Climate Fund?
SELECT SUM(amount) FROM green_climate_fund WHERE country = 'Africa';
gretelai_synthetic_text_to_sql
CREATE TABLE songs (song_id INT, title VARCHAR(255), release_year INT, genre VARCHAR(50), length FLOAT); INSERT INTO songs (song_id, title, release_year, genre, length) VALUES (1, 'Song1', 1999, 'classical', 120.5), (2, 'Song2', 2005, 'rock', 210.3), (3, 'Song3', 1985, 'classical', 180.7);
How many classical songs were released before 2000?
SELECT COUNT(*) FROM songs WHERE genre = 'classical' AND release_year < 2000;
gretelai_synthetic_text_to_sql
CREATE TABLE agroecology_ngos (country VARCHAR(50), num_ngos INT); INSERT INTO agroecology_ngos (country, num_ngos) VALUES ('India', 150), ('China', 200), ('Indonesia', 100);
What is the minimum and maximum number of agroecology-based NGOs in Asia?
SELECT MIN(num_ngos), MAX(num_ngos) FROM agroecology_ngos WHERE country IN ('India', 'China', 'Indonesia');
gretelai_synthetic_text_to_sql
CREATE TABLE region_rainfall (region TEXT, date DATE, rainfall INTEGER);
What is the total amount of rainfall for each region in the past year?
SELECT region, SUM(rainfall) as total_rainfall FROM region_rainfall WHERE date >= DATEADD(year, -1, GETDATE()) GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE properties (property_id INT, price FLOAT, owner_id INT); CREATE TABLE owners (owner_id INT, name VARCHAR(255), gender VARCHAR(6)); INSERT INTO properties (property_id, price, owner_id) VALUES (1, 500000, 101), (2, 600000, 102); INSERT INTO owners (owner_id, name, gender) VALUES (101, 'Alice', 'female'), (102, 'Alex', 'non-binary');
List all properties co-owned by women and non-binary individuals.
SELECT properties.property_id, owners.name FROM properties INNER JOIN owners ON properties.owner_id = owners.owner_id WHERE owners.gender IN ('female', 'non-binary');
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (id INT, name TEXT, region TEXT, donation_amount DECIMAL); INSERT INTO Donors (id, name, region, donation_amount) VALUES (1, 'John Doe', 'Asia', 100.00); INSERT INTO Donors (id, name, region, donation_amount) VALUES (2, 'Jane Smith', 'North America', 200.00);
What is the average donation amount received from donors in the Asia region?
SELECT AVG(donation_amount) FROM Donors WHERE region = 'Asia';
gretelai_synthetic_text_to_sql
CREATE TABLE Product (product_id INT PRIMARY KEY, product_name VARCHAR(50), price DECIMAL(5,2), is_circular_supply_chain BOOLEAN);
Show the total revenue generated by products that are part of a circular supply chain in the 'Product' table
SELECT SUM(price) FROM Product WHERE is_circular_supply_chain = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE investments (investment_id INT, investor_id INT, sector VARCHAR(20), investment_value DECIMAL(10,2)); INSERT INTO investments (investment_id, investor_id, sector, investment_value) VALUES (1, 1, 'technology', 5000.00), (2, 2, 'finance', 3000.00), (3, 3, 'energy', 1000.00);
What is the minimum investment value in the energy sector?
SELECT MIN(investment_value) FROM investments WHERE sector = 'energy';
gretelai_synthetic_text_to_sql
CREATE TABLE AcademicPublications (PublicationID INT, Author VARCHAR(50), Title VARCHAR(100), Journal VARCHAR(50), PublicationYear INT); INSERT INTO AcademicPublications (PublicationID, Author, Title, Journal, PublicationYear) VALUES (1, 'Jane Smith', 'Title 1', 'Journal 1', 2020); INSERT INTO AcademicPublications (PublicationID, Author, Title, Journal, PublicationYear) VALUES (2, 'John Doe', 'Title 2', 'Journal 2', 2019); INSERT INTO AcademicPublications (PublicationID, Author, Title, Journal, PublicationYear) VALUES (3, 'Sophia Thompson', 'Title 3', 'Journal 3', 2018);
Show the number of academic publications per author in descending order.
SELECT Author, COUNT(*) as PublicationCount FROM AcademicPublications GROUP BY Author ORDER BY PublicationCount DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE tourism_revenue (revenue_id INT, country TEXT, revenue FLOAT); INSERT INTO tourism_revenue (revenue_id, country, revenue) VALUES (1, 'Brazil', 1000000), (2, 'Argentina', 1500000);
What is the total revenue of sustainable tourism in Brazil and Argentina?
SELECT SUM(revenue) FROM tourism_revenue WHERE country IN ('Brazil', 'Argentina');
gretelai_synthetic_text_to_sql
CREATE TABLE Visitor_Demographics (visitor_id INT, age INT, gender VARCHAR(10)); CREATE TABLE Digital_Interactions (visitor_id INT, interaction_date DATE, exhibition_id INT); CREATE TABLE Exhibitions (id INT, name VARCHAR(100), location VARCHAR(50)); INSERT INTO Exhibitions (id, name, location) VALUES (5, 'Nature & Wildlife', 'Canada'); INSERT INTO Visitor_Demographics (visitor_id, age, gender) VALUES (15, 25, 'Male'); INSERT INTO Visitor_Demographics (visitor_id, age, gender) VALUES (16, 27, 'Female'); INSERT INTO Digital_Interactions (visitor_id, interaction_date, exhibition_id) VALUES (15, '2022-03-01', 5); INSERT INTO Digital_Interactions (visitor_id, interaction_date, exhibition_id) VALUES (16, '2022-03-02', 5);
Find the average age of visitors who engaged with digital installations, grouped by gender for a specific exhibition
SELECT Exhibitions.name, Gender, AVG(Age) AS Avg_Age FROM ( SELECT Visitor_Demographics.gender AS Gender, Visitor_Demographics.age AS Age, Digital_Interactions.exhibition_id FROM Visitor_Demographics JOIN Digital_Interactions ON Visitor_Demographics.visitor_id = Digital_Interactions.visitor_id WHERE Digital_Interactions.exhibition_id = 5 ) AS Subquery JOIN Exhibitions ON Subquery.exhibition_id = Exhibitions.id GROUP BY Exhibitions.name, Gender;
gretelai_synthetic_text_to_sql
CREATE TABLE content_lang (content_id INT, content_language VARCHAR(20)); CREATE TABLE content_views (view_id INT, user_id INT, content_id INT, view_date DATE);
What is the total number of users who have viewed content in each language?
SELECT content_language, COUNT(DISTINCT users.user_id) as user_count FROM content_views JOIN content_lang ON content_views.content_id = content_lang.content_id JOIN users ON content_views.user_id = users.user_id GROUP BY content_lang.content_language;
gretelai_synthetic_text_to_sql
CREATE TABLE species_count (ocean VARCHAR(255), total_species INT); INSERT INTO species_count (ocean, total_species) VALUES ('Atlantic', 12432), ('Pacific', 22310), ('Indian', 9814), ('Southern', 6321), ('Arctic', 2837);
How many marine species are there in the Southern Ocean?
SELECT total_species FROM species_count WHERE ocean = 'Southern';
gretelai_synthetic_text_to_sql
CREATE TABLE astronauts (astronaut_id INT, name VARCHAR(100), age INT, craft VARCHAR(50)); INSERT INTO astronauts (astronaut_id, name, age, craft) VALUES (1, 'John', 45, 'Dragon'), (2, 'Sarah', 36, 'Starship'), (3, 'Mike', 50, 'Falcon'); CREATE TABLE spacex_crafts (craft VARCHAR(50), manufacturer VARCHAR(50)); INSERT INTO spacex_crafts (craft, manufacturer) VALUES ('Dragon', 'SpaceX'), ('Starship', 'SpaceX'), ('Falcon', 'SpaceX');
What is the average age of astronauts who have piloted a SpaceX craft?
SELECT AVG(a.age) FROM astronauts a INNER JOIN spacex_crafts c ON a.craft = c.craft WHERE c.manufacturer = 'SpaceX' AND a.pilot = TRUE;
gretelai_synthetic_text_to_sql