context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE transactions (transaction_id INT, transaction_date DATE, product_category VARCHAR(50), amount DECIMAL(10, 2)); INSERT INTO transactions (transaction_id, transaction_date, product_category, amount) VALUES (1, '2021-04-01', 'Stocks', 500); INSERT INTO transactions (transaction_id, transaction_date, product_category, amount) VALUES (2, '2021-04-15', 'Bonds', 300); INSERT INTO transactions (transaction_id, transaction_date, product_category, amount) VALUES (3, '2021-04-20', 'Mutual Funds', 700);
What is the total value of transactions per month, by product category?
SELECT DATE_FORMAT(transaction_date, '%Y-%m') as month, product_category, SUM(amount) as total_value FROM transactions GROUP BY month, product_category;
gretelai_synthetic_text_to_sql
CREATE TABLE subscriber_tech (subscriber_id INT, subscription_start_date DATE, technology VARCHAR(50), subscription_fee DECIMAL(10, 2)); INSERT INTO subscriber_tech (subscriber_id, subscription_start_date, technology, subscription_fee) VALUES (1, '2020-01-01', 'Fiber', 50.00), (2, '2019-06-15', 'Cable', 40.00), (3, '2021-02-20', 'Fiber', 55.00);
What is the total number of broadband subscribers per technology in the 'subscriber_tech' table?
SELECT technology, COUNT(*) as total_subscribers FROM subscriber_tech GROUP BY technology;
gretelai_synthetic_text_to_sql
CREATE TABLE Dishes (id INT, cuisine VARCHAR(255), organic BOOLEAN); INSERT INTO Dishes (id, cuisine, organic) VALUES (1, 'Italian', TRUE), (2, 'Italian', FALSE), (3, 'Mexican', TRUE), (4, 'Mexican', TRUE), (5, 'Indian', FALSE);
What is the total count of organic dishes by cuisine type?
SELECT cuisine, COUNT(*) as total_organic FROM Dishes WHERE organic = TRUE GROUP BY cuisine;
gretelai_synthetic_text_to_sql
CREATE TABLE NailPolishSales (sale_id INT, product_name VARCHAR(100), category VARCHAR(50), price DECIMAL(10,2), quantity INT, sale_date DATE, country VARCHAR(50), natural BOOLEAN);
What is the total quantity of natural nail polish sold in Canada in Q1 2022?
SELECT SUM(quantity) FROM NailPolishSales WHERE category = 'Nail Polish' AND country = 'Canada' AND natural = TRUE AND sale_date >= '2022-01-01' AND sale_date < '2022-04-01';
gretelai_synthetic_text_to_sql
CREATE TABLE Twitter(id INT, user_id INT, post_time TIMESTAMP, content TEXT); CREATE TABLE Pinterest(id INT, user_id INT, post_time TIMESTAMP, content TEXT);
How many users have posted more than 10 times in 'Twitter' or 'Pinterest' in the last month?
SELECT COUNT(DISTINCT user_id) FROM (SELECT user_id FROM Twitter WHERE post_time >= NOW() - INTERVAL '1 month' GROUP BY user_id HAVING COUNT(*) > 10 UNION ALL SELECT user_id FROM Pinterest WHERE post_time >= NOW() - INTERVAL '1 month' GROUP BY user_id HAVING COUNT(*) > 10) AS total_users;
gretelai_synthetic_text_to_sql
CREATE TABLE landfill_capacity (year INT, location TEXT, capacity INT); INSERT INTO landfill_capacity (year, location, capacity) VALUES (2019, 'SiteA', 60000), (2019, 'SiteB', 45000), (2019, 'SiteC', 52000), (2020, 'SiteA', 62000), (2020, 'SiteB', 46000), (2020, 'SiteC', 53000);
Delete records with landfill capacity below 50000 in 'landfill_capacity' table for 2019.
DELETE FROM landfill_capacity WHERE year = 2019 AND capacity < 50000;
gretelai_synthetic_text_to_sql
CREATE TABLE SmartContracts (id INT, blockchain VARCHAR(50), address VARCHAR(100), deployment_date DATE); INSERT INTO SmartContracts (id, blockchain, address, deployment_date) VALUES (1, 'Binance Smart Chain', '0x123...', '2022-01-01'), (2, 'Binance Smart Chain', '0x456...', '2022-02-10');
How many smart contracts have been deployed on the Binance Smart Chain in the last month?
SELECT COUNT(*) FROM SmartContracts WHERE blockchain = 'Binance Smart Chain' AND deployment_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH);
gretelai_synthetic_text_to_sql
CREATE TABLE second_highest_contracts (id INT, contract_type VARCHAR(255), contract_value INT); INSERT INTO second_highest_contracts (id, contract_type, contract_value) VALUES (1, 'Service', 5000000), (2, 'Supply', 7000000), (3, 'Research', 6000000);
Get the details of the defense contract with the second highest value
SELECT * FROM second_highest_contracts WHERE contract_value = (SELECT MAX(contract_value) FROM second_highest_contracts WHERE contract_value < (SELECT MAX(contract_value) FROM second_highest_contracts));
gretelai_synthetic_text_to_sql
CREATE TABLE Events (event_id INT, region VARCHAR(50), revenue DECIMAL(10,2), event_date DATE); INSERT INTO Events (event_id, region, revenue, event_date) VALUES (50, 'Atlantic', 12000, '2020-01-01'), (51, 'Atlantic', 15000, '2020-02-01'), (52, 'Central', 10000, '2020-01-01');
What was the total revenue generated from events in the Atlantic region in Q1 2020?
SELECT SUM(revenue) FROM Events WHERE region = 'Atlantic' AND MONTH(event_date) BETWEEN 1 AND 3;
gretelai_synthetic_text_to_sql
CREATE TABLE WarehouseTemperatureC (id INT, temperature FLOAT, location VARCHAR(20)); INSERT INTO WarehouseTemperatureC (id, temperature, location) VALUES (1, 30, 'Warehouse C'), (2, 25, 'Warehouse D');
What is the maximum temperature of pallets stored in Warehouse C?
SELECT MAX(temperature) FROM WarehouseTemperatureC WHERE location = 'Warehouse C';
gretelai_synthetic_text_to_sql
CREATE TABLE Buildings (BuildingID INT, Name TEXT, Height INT, City TEXT, Country TEXT); INSERT INTO Buildings (BuildingID, Name, Height, City, Country) VALUES (1, 'BuildingA', 300, 'Tokyo', 'Japan'); INSERT INTO Buildings (BuildingID, Name, Height, City, Country) VALUES (2, 'BuildingB', 250, 'Tokyo', 'Japan'); INSERT INTO Buildings (BuildingID, Name, Height, City, Country) VALUES (3, 'BuildingC', 400, 'Tokyo', 'Japan');
Find the name and height of the five shortest buildings in Tokyo, Japan.
SELECT Name, Height FROM Buildings WHERE Country = 'Japan' AND City = 'Tokyo' ORDER BY Height ASC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (Donor_ID int, Name varchar(50), Donation_Amount decimal(10,2), Country varchar(50)); INSERT INTO Donors (Donor_ID, Name, Donation_Amount, Country) VALUES (1, 'John Doe', 7000, 'USA'), (2, 'Jane Smith', 3000, 'Canada'), (3, 'Mike Johnson', 4000, 'USA');
update Donors set Donation_Amount = Donation_Amount * 1.10 where Country = 'USA'
UPDATE Donors SET Donation_Amount = Donation_Amount * 1.10 WHERE Country = 'USA';
gretelai_synthetic_text_to_sql
CREATE TABLE SupplyChainWorkers (id INT, sustainable_wood BOOLEAN, num_workers INT);
What is the total number of workers in the supply chain for sustainable wood sources?
SELECT SUM(num_workers) FROM SupplyChainWorkers WHERE sustainable_wood = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE CriminalJusticeReformEvents (id INT, event_date DATE, events INT); INSERT INTO CriminalJusticeReformEvents (id, event_date, events) VALUES (1, '2022-01-01', 10), (2, '2022-02-01', 15), (3, '2022-03-01', 18), (4, '2022-04-01', 20), (5, '2022-05-01', 25), (6, '2022-06-01', 28), (7, '2022-07-01', 30), (8, '2022-08-01', 35), (9, '2022-09-01', 38), (10, '2022-10-01', 40), (11, '2022-11-01', 45), (12, '2022-12-01', 48);
What is the change in the number of criminal justice reform events per month in a given year?
SELECT EXTRACT(MONTH FROM event_date) as month, (LEAD(events) OVER (ORDER BY event_date) - events) as change FROM CriminalJusticeReformEvents WHERE EXTRACT(YEAR FROM event_date) = 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE ipl_batters (batter_id INT, batter_name VARCHAR(50), team_id INT, season INT, goals INT); INSERT INTO ipl_batters (batter_id, batter_name, team_id, season, goals) VALUES (1, 'Virat Kohli', 1, 2019, 46), (2, 'David Warner', 2, 2019, 692);
What is the highest number of goals scored by a cricket player in a single season in the IPL, by team?
SELECT team_id, MAX(goals) FROM ipl_batters GROUP BY team_id;
gretelai_synthetic_text_to_sql
CREATE TABLE cybersecurity_incidents (id INT, incident_type VARCHAR(50), incident_date DATE); INSERT INTO cybersecurity_incidents (id, incident_type, incident_date) VALUES (1, 'Phishing', '2022-01-05'), (2, 'Malware', '2022-03-17'), (3, 'Ransomware', '2022-05-29');
What are the details of cybersecurity incidents in the last 6 months?
SELECT * FROM cybersecurity_incidents WHERE incident_date >= DATE(NOW()) - INTERVAL 6 MONTH;
gretelai_synthetic_text_to_sql
CREATE TABLE ingredients (product_id INT, ingredient VARCHAR(50), source_country VARCHAR(50)); CREATE TABLE products (product_id INT, is_vegan BOOLEAN, market VARCHAR(10)); INSERT INTO ingredients (product_id, ingredient, source_country) VALUES (1, 'Vitamin E', 'Brazil'), (2, 'Beeswax', 'France'), (3, 'Mica', 'India'); INSERT INTO products (product_id, is_vegan, market) VALUES (1, true, 'US'), (2, false, 'CA'), (3, true, 'US');
What are the ingredient sources for all vegan cosmetic products in the US market?
SELECT i.ingredient, i.source_country FROM ingredients i JOIN products p ON i.product_id = p.product_id WHERE p.is_vegan = true AND p.market = 'US';
gretelai_synthetic_text_to_sql
CREATE TABLE patients (id INT, name TEXT, age INT, treatment TEXT, treated_year INT); INSERT INTO patients (id, name, age, treatment, treated_year) VALUES (1, 'John Doe', 35, 'CBT', 2020), (2, 'Jane Smith', 40, 'DBT', 2021);
How many patients were treated with therapy in 2020?
SELECT COUNT(*) FROM patients WHERE treatment LIKE '%CBT%' OR treatment LIKE '%DBT%' AND treated_year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE ParityViolations (ViolationID int, CommunityID int, ViolationCount int);CREATE TABLE CommunityMentalHealth (CommunityID int, PatientID int);
What is the total number of mental health parity violations and the total number of patients treated for mental health issues in each community?
SELECT CommunityID, SUM(ViolationCount) as TotalViolations, COUNT(PatientID) as PatientCount FROM ParityViolations JOIN CommunityMentalHealth ON ParityViolations.CommunityID = CommunityMentalHealth.CommunityID GROUP BY CommunityID;
gretelai_synthetic_text_to_sql
CREATE TABLE production_figures (well_id INT, year INT, oil_production INT, gas_production INT); INSERT INTO production_figures (well_id, year, oil_production, gas_production) VALUES (1, 2019, 120000, 50000); INSERT INTO production_figures (well_id, year, oil_production, gas_production) VALUES (2, 2018, 130000, 60000); INSERT INTO production_figures (well_id, year, oil_production, gas_production) VALUES (3, 2020, 110000, 45000);
What is the total oil production in the North Sea in 2020?
SELECT SUM(oil_production) FROM production_figures WHERE year = 2020 AND region = 'North Sea';
gretelai_synthetic_text_to_sql
CREATE TABLE wells (well_id INT, well_name TEXT, production_qty FLOAT, region TEXT); INSERT INTO wells (well_id, well_name, production_qty, region) VALUES (1, 'Well A', 1000, 'North Sea'), (2, 'Well B', 1500, 'North Sea'), (3, 'Well C', 800, 'North Sea');
What are the names and production quantities of the top 5 producing wells in the North Sea?
SELECT well_name, production_qty FROM wells WHERE region = 'North Sea' ORDER BY production_qty DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE Members (MemberID INT, FirstName VARCHAR(50), LastName VARCHAR(50), DateJoined DATE); INSERT INTO Members (MemberID, FirstName, LastName, DateJoined) VALUES (1, 'John', 'Doe', '2022-01-10'); INSERT INTO Members (MemberID, FirstName, LastName, DateJoined) VALUES (2, 'Jane', 'Doe', '2022-01-15'); CREATE TABLE Workouts (WorkoutID INT, MemberID INT, WorkoutDate DATE); INSERT INTO Workouts (WorkoutID, MemberID, WorkoutDate) VALUES (1, 1, '2022-01-12');
Which members joined the gym in January 2022, but have not attended any workout sessions since then?
SELECT m.MemberID, m.FirstName, m.LastName FROM Members m LEFT JOIN Workouts w ON m.MemberID = w.MemberID WHERE m.DateJoined >= '2022-01-01' AND m.DateJoined < '2022-02-01' AND w.WorkoutDate IS NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE clinical_trial_timeline (id INT, trial_initiation_date DATE, trial_type VARCHAR(255));
Find the number of clinical trials initiated per month in 2021, with a 12-month trailing average.
SELECT trial_initiation_date, COUNT(*) OVER (PARTITION BY trial_initiation_date ORDER BY trial_initiation_date ROWS BETWEEN 11 PRECEDING AND CURRENT ROW) as moving_avg_trials_per_month FROM clinical_trial_timeline WHERE trial_initiation_date BETWEEN '2021-01-01' AND '2021-12-31' GROUP BY trial_initiation_date ORDER BY trial_initiation_date;
gretelai_synthetic_text_to_sql
CREATE TABLE dishes (dish_id INT PRIMARY KEY, dish_name VARCHAR(50)); INSERT INTO dishes (dish_id, dish_name) VALUES (1, 'Soy Milk Smoothie'), (2, 'Tofu Curry'); CREATE TABLE dishes_ingredients (dish_id INT, ingredient_id INT, quantity INT);
Insert new dish 'Rajma Masala' with ingredients: Rajma, Onions, Tomatoes, Garlic, Ginger, Turmeric, Garam Masala, Salt, Oil.
INSERT INTO dishes (dish_id, dish_name) VALUES (3, 'Rajma Masala'); INSERT INTO dishes_ingredients (dish_id, ingredient_id, quantity) VALUES (3, 5, 300), (3, 6, 150), (3, 1, 150), (3, 7, 50), (3, 8, 25), (3, 9, 25), (3, 10, 2), (3, 11, 50), (3, 12, 50);
gretelai_synthetic_text_to_sql
CREATE TABLE Foundations (product_id INT, product_name VARCHAR(255), spf INT, price DECIMAL(10,2)); INSERT INTO Foundations (product_id, product_name, spf, price) VALUES (1, 'Foundation 1', 15, 25.99), (2, 'Foundation 2', 30, 35.99), (3, 'Foundation 3', 20, 29.99), (4, 'Foundation 4', 50, 45.99);
What is the average price of foundation products with SPF 30 or higher?
SELECT AVG(price) FROM Foundations WHERE spf >= 30;
gretelai_synthetic_text_to_sql
CREATE TABLE conservation_status (species_id INTEGER, species_name VARCHAR(255), status VARCHAR(50));
List all species in the 'Endangered' status from the 'conservation_status' table.
SELECT species_name FROM conservation_status WHERE status = 'Endangered';
gretelai_synthetic_text_to_sql
CREATE TABLE health_insurance (id INT, insured BOOLEAN, state TEXT); INSERT INTO health_insurance (id, insured, state) VALUES (1, true, 'California'); INSERT INTO health_insurance (id, insured, state) VALUES (2, false, 'California');
What is the percentage of the population with health insurance in California?
SELECT (SUM(insured) * 100.0 / COUNT(*)) FROM health_insurance WHERE state = 'California';
gretelai_synthetic_text_to_sql
CREATE TABLE department (id INT, name TEXT); INSERT INTO department (id, name) VALUES (1, 'sciences'), (2, 'humanities'), (3, 'engineering'); CREATE TABLE faculty (id INT, department_id INT); INSERT INTO faculty (id, department_id) VALUES (1, 1), (2, 1), (3, 2), (4, 2), (5, 3);
How many faculty members work in the 'humanities' department?
SELECT COUNT(*) FROM faculty WHERE department_id = (SELECT id FROM department WHERE name = 'humanities');
gretelai_synthetic_text_to_sql
CREATE TABLE customers (customer_id INT, name VARCHAR(50), financial_capability_score INT); INSERT INTO customers (customer_id, name, financial_capability_score) VALUES (101, 'John Doe', 75), (102, 'Jane Smith', 80);
What is the average financial capability score for customers?
SELECT AVG(financial_capability_score) FROM customers;
gretelai_synthetic_text_to_sql
CREATE TABLE branches (id INT, name VARCHAR(255)); CREATE TABLE customers (id INT, name VARCHAR(255), branch_id INT, transaction_date DATE);
Find the first non-repeat customer for each branch in 2021.
SELECT ROW_NUMBER() OVER (PARTITION BY branch_id ORDER BY transaction_date) as rn, c.* FROM customers c WHERE c.transaction_date >= '2021-01-01' AND c.transaction_date < '2022-01-01' AND rn = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE streams (id INT, artist VARCHAR(50), country VARCHAR(50), streams INT, year INT); INSERT INTO streams (id, artist, country, streams, year) VALUES (1, 'Booba', 'France', 3000000, 2022); INSERT INTO streams (id, artist, country, streams, year) VALUES (2, 'Stromae', 'Belgium', 4000000, 2022); INSERT INTO streams (id, artist, country, streams, year) VALUES (3, 'Kollegah', 'Germany', 5000000, 2022); INSERT INTO streams (id, artist, country, streams, year) VALUES (4, 'Farid Bang', 'Germany', 6000000, 2022);
Find the total number of streams for Hip Hop artists in France and Germany combined in 2022.
SELECT SUM(streams) FROM streams WHERE genre = 'Hip Hop' AND (country = 'France' OR country = 'Germany') AND year = 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE Tilapia_Farms (Farm_ID INT, Farm_Name TEXT, Dissolved_Oxygen FLOAT); INSERT INTO Tilapia_Farms (Farm_ID, Farm_Name, Dissolved_Oxygen) VALUES (1, 'Farm C', 7.5); INSERT INTO Tilapia_Farms (Farm_ID, Farm_Name, Dissolved_Oxygen) VALUES (2, 'Farm D', 8.0); INSERT INTO Tilapia_Farms (Farm_ID, Farm_Name, Dissolved_Oxygen) VALUES (3, 'Farm E', 7.0);
Which Tilapia Farm has the highest dissolved oxygen level?
SELECT Farm_Name, MAX(Dissolved_Oxygen) FROM Tilapia_Farms;
gretelai_synthetic_text_to_sql
CREATE TABLE SatelliteProjects (project_id INT, launch_cost INT, satellite_cost INT);
Find the total cost of satellite deployment projects.
SELECT project_id, launch_cost + satellite_cost AS total_cost FROM SatelliteProjects;
gretelai_synthetic_text_to_sql
CREATE TABLE cultural_heritage_greece (id INT, country VARCHAR(20), site VARCHAR(20), revenue FLOAT); INSERT INTO cultural_heritage_greece (id, country, site, revenue) VALUES (1, 'Greece', 'Acropolis', 3000.0), (2, 'Greece', 'Parthenon', 2500.0), (3, 'Greece', 'Epidaurus', 2000.0);
What is the maximum revenue generated by a single cultural heritage site in Greece?
SELECT MAX(revenue) FROM cultural_heritage_greece WHERE country = 'Greece';
gretelai_synthetic_text_to_sql
CREATE TABLE virtual_tours (tour_id INT, hotel_id INT, city TEXT, engagement INT); INSERT INTO virtual_tours (tour_id, hotel_id, city, engagement) VALUES (1, 3, 'Paris', 200), (2, 3, 'Paris', 250), (3, 4, 'Rome', 150);
How many virtual tours were engaged in 'Paris'?
SELECT SUM(engagement) FROM virtual_tours WHERE city = 'Paris';
gretelai_synthetic_text_to_sql
CREATE TABLE affordable_homes (id INT, size FLOAT, location VARCHAR(255)); INSERT INTO affordable_homes (id, size, location) VALUES (1, 1200.0, 'San Francisco'), (2, 900.0, 'New York'), (3, 1300.0, 'Los Angeles'), (4, 800.0, 'New York');
Find properties with size less than 1000 sq ft in affordable_homes table.
SELECT * FROM affordable_homes WHERE size < 1000;
gretelai_synthetic_text_to_sql
CREATE TABLE Players (player_id INTEGER, name TEXT, team TEXT); INSERT INTO Players (player_id, name, team) VALUES (1, 'Player 1', 'Team A'), (2, 'Player 2', 'Team A'), (3, 'Player 3', 'Team B'); CREATE TABLE Games (game_id INTEGER, team TEXT, player_id INTEGER, points INTEGER); INSERT INTO Games (game_id, team, player_id, points) VALUES (1, 'Team A', 1, 20), (1, 'Team A', 2, 15), (1, 'Team A', 3, 5);
Update the basketball player's points for a specific game.
UPDATE Games SET points = 25 WHERE game_id = 1 AND player_id = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE patients (patient_id INT, region VARCHAR(20), visited_last_year BOOLEAN); INSERT INTO patients (patient_id, region, visited_last_year) VALUES (1, 'Rural', true), (2, 'Urban', false), (3, 'Rural', true); CREATE TABLE hospitals (hospital_id INT, region VARCHAR(20), beds INT); INSERT INTO hospitals (hospital_id, region, beds) VALUES (1, 'Rural', 50), (2, 'Urban', 100); CREATE TABLE clinics (clinic_id INT, region VARCHAR(20), beds INT); INSERT INTO clinics (clinic_id, region, beds) VALUES (1, 'Rural', 10), (2, 'Urban', 20); CREATE TABLE visits (patient_id INT, hospital_id INT, clinic_id INT, visit_year INT); INSERT INTO visits (patient_id, hospital_id, clinic_id, visit_year) VALUES (1, 1, NULL, 2022), (2, NULL, 2, 2022), (3, 1, NULL, 2022);
What is the percentage of patients in each region who have visited a hospital or clinic in the past year, grouped by region?
SELECT s.region, (COUNT(p.patient_id) FILTER (WHERE p.visited_last_year = true) * 100.0 / COUNT(p.patient_id)) as percentage FROM patients p JOIN hospitals h ON p.region = h.region JOIN clinics c ON p.region = c.region JOIN states s ON p.region = s.region JOIN visits v ON p.patient_id = v.patient_id WHERE v.visit_year = 2022 GROUP BY s.region;
gretelai_synthetic_text_to_sql
CREATE TABLE european_cities_landfill_capacity (city VARCHAR(20), capacity INT);
Drop the table for European landfill capacities.
DROP TABLE european_cities_landfill_capacity;
gretelai_synthetic_text_to_sql
CREATE TABLE inventory (inventory_id INT, inventory_category TEXT, inventory_quantity INT);
What is the total quantity of unsold inventory for each category?
SELECT inventory_category, SUM(inventory_quantity) AS total_unsold_inventory FROM inventory WHERE inventory_quantity > 0 GROUP BY inventory_category
gretelai_synthetic_text_to_sql
CREATE TABLE donors (id INT, name VARCHAR(50), country VARCHAR(50), total_donations DECIMAL(10,2)); INSERT INTO donors (id, name, country, total_donations) VALUES (1, 'John Doe', 'USA', 7000.00); INSERT INTO donors (id, name, country, total_donations) VALUES (2, 'Jane Smith', 'Canada', 12000.00); INSERT INTO donors (id, name, country, total_donations) VALUES (3, 'Bob Johnson', 'USA', 6000.00); INSERT INTO donors (id, name, country, total_donations) VALUES (4, 'Charlie Brown', 'UK', 9000.00); INSERT INTO donors (id, name, country, total_donations) VALUES (5, 'David Williams', 'Australia', 15000.00);
Find the top 5 donors by total donation amount, including their names and countries
SELECT id, name, country, total_donations FROM donors ORDER BY total_donations DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE College_of_Science (department VARCHAR(50), grant_funding NUMERIC(15,2)); INSERT INTO College_of_Science (department, grant_funding) VALUES ('Biology', 1250000.00), ('Chemistry', 1785000.00), ('Physics', 2500000.00), ('Mathematics', 1150000.00), ('Computer_Science', 3000000.00);
What is the total research grant funding received by each department in the College of Science, ordered from highest to lowest?
SELECT department, grant_funding FROM College_of_Science ORDER BY grant_funding DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE Events (event_name VARCHAR(255), revenue INT); INSERT INTO Events (event_name, revenue) VALUES ('Dance Performance', 5000), ('Art Exhibition', 8000), ('Theater Play', 6000);
What was the total revenue from the 'Art Exhibition' event?
SELECT revenue FROM Events WHERE event_name = 'Art Exhibition';
gretelai_synthetic_text_to_sql
CREATE TABLE ingredients (product_id INT, ingredient TEXT); INSERT INTO ingredients (product_id, ingredient) VALUES (1, 'paraben'), (2, 'alcohol'), (3, 'water'), (4, 'paraben'), (5, 'lavender'), (6, 'paraben'); CREATE TABLE products (product_id INT, product_name TEXT, country TEXT); INSERT INTO products (product_id, product_name, country) VALUES (1, 'Lipstick A', 'France'), (2, 'Eye Shadow B', 'Canada'), (3, 'Mascara C', 'France'), (4, 'Foundation D', 'USA'), (5, 'Blush E', 'Mexico'), (6, 'Moisturizer F', 'France');
What percentage of cosmetic products sourced from France contain a paraben ingredient?
SELECT 100.0 * COUNT(i.product_id) / (SELECT COUNT(*) FROM products p WHERE p.country = 'France') AS paraben_percentage FROM ingredients i WHERE i.ingredient = 'paraben' AND i.product_id IN (SELECT product_id FROM products WHERE country = 'France');
gretelai_synthetic_text_to_sql
CREATE TABLE donations (id INT, donor_name VARCHAR(50), donation_amount DECIMAL(10,2), donation_date DATE, is_volunteer BOOLEAN); INSERT INTO donations (id, donor_name, donation_amount, donation_date, is_volunteer) VALUES (1, 'John Doe', 50.00, '2021-01-05', true), (2, 'Jane Smith', 100.00, '2021-03-15', false), (3, 'Alice Johnson', 75.00, '2021-01-20', true), (4, 'Bob Brown', 150.00, '2021-02-01', false);
What is the total donation amount from volunteers in the United States?
SELECT SUM(donation_amount) FROM donations WHERE is_volunteer = true AND donor_country = 'USA';
gretelai_synthetic_text_to_sql
CREATE SCHEMA if not exists biotech; CREATE TABLE if not exists biotech.startups_funding (id INT, name VARCHAR(50), location VARCHAR(50), industry VARCHAR(50), funding DECIMAL(10, 2), funded_year INT); INSERT INTO biotech.startups_funding (id, name, location, industry, funding, funded_year) VALUES (1, 'StartupA', 'India', 'Genetic Research', 6000000, 2021), (2, 'StartupB', 'Brazil', 'Bioprocess Engineering', 4500000, 2020), (3, 'StartupC', 'South Africa', 'Synthetic Biology', 5000000, 2019), (4, 'StartupD', 'USA', 'Genetic Research', 8000000, 2022), (5, 'StartupE', 'Mexico', 'Genetic Research', 7000000, 2021), (6, 'StartupF', 'China', 'Genetic Research', 9000000, 2020);
What is the rank of each genetic research startup by total funding, for the past year?
SELECT name, ROW_NUMBER() OVER (PARTITION BY funded_year ORDER BY funding DESC) as startup_rank FROM biotech.startups_funding WHERE industry = 'Genetic Research' AND funded_year = YEAR(CURRENT_DATE) - 1;
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (DonorID int, DonorName varchar(50), Country varchar(50), DonationAmount numeric(18,2)); INSERT INTO Donors (DonorID, DonorName, Country, DonationAmount) VALUES (1, 'Donor1', 'USA', 5000), (2, 'Donor2', 'Canada', 7000), (3, 'Donor3', 'USA', 8000), (4, 'Donor4', 'Mexico', 9000);
Find the number of donors from each country who made donations in 2021.
SELECT Country, COUNT(*) FROM Donors WHERE YEAR(DonationDate) = 2021 GROUP BY Country;
gretelai_synthetic_text_to_sql
CREATE TABLE otas (id INT, name TEXT, region TEXT, daily_revenue FLOAT); CREATE VIEW past_year AS SELECT date_sub(current_date(), INTERVAL n DAY) AS date FROM (SELECT generate_series(0, 365) AS n) AS sequence;
What is the total revenue for online travel agencies (OTAs) in Europe in the past year?
SELECT SUM(otas.daily_revenue) FROM otas JOIN past_year ON date_trunc('day', otas.date) = past_year.date WHERE otas.region = 'Europe';
gretelai_synthetic_text_to_sql
CREATE TABLE geopolitical_risk_us (id INT, country VARCHAR(255), assessment TEXT); INSERT INTO geopolitical_risk_us (id, country, assessment) VALUES (1, 'United States', 'Medium Risk'); INSERT INTO geopolitical_risk_us (id, country, assessment) VALUES (2, 'Canada', 'Low Risk');
What are the geopolitical risk assessments for the United States?
SELECT country, assessment FROM geopolitical_risk_us WHERE country = 'United States';
gretelai_synthetic_text_to_sql
CREATE TABLE manufacturing_equipment (equipment_id INT, equipment_name VARCHAR(50), year_manufactured INT, manufacturer_country VARCHAR(50)); INSERT INTO manufacturing_equipment (equipment_id, equipment_name, year_manufactured, manufacturer_country) VALUES (1, 'CNC Mill', 2018, 'Germany'), (2, 'Injection Molding Machine', 2020, 'China'), (3, 'Robot Arm', 2019, 'Japan');
List all equipment manufactured in 'Germany'
SELECT equipment_name FROM manufacturing_equipment WHERE manufacturer_country = 'Germany';
gretelai_synthetic_text_to_sql
CREATE TABLE donor_country (donor_id INT, country_id INT, donation_year INT); INSERT INTO donor_country (donor_id, country_id, donation_year) VALUES (1, 1, 2019), (2, 1, 2020), (3, 1, 2021), (4, 2, 2019), (5, 2, 2020), (6, 2, 2021), (7, 3, 2019), (8, 3, 2020), (9, 3, 2021);
How many unique donors have donated to each country in the past 3 years?
SELECT country_id, COUNT(DISTINCT donor_id) num_donors FROM donor_country WHERE donation_year BETWEEN (YEAR(CURRENT_DATE) - 3) AND YEAR(CURRENT_DATE) GROUP BY country_id;
gretelai_synthetic_text_to_sql
CREATE TABLE teacher_trainings (teacher_id INT, course_id INT, training_date DATE); CREATE TABLE teachers (teacher_id INT, teacher_name VARCHAR(50));
List the IDs and names of all teachers who have taken a professional development course in the past year, along with the number of courses taken, from the 'teacher_trainings' and 'teachers' tables.
SELECT t.teacher_id, t.teacher_name, COUNT(tt.course_id) as num_courses FROM teachers t JOIN teacher_trainings tt ON t.teacher_id = tt.teacher_id WHERE tt.training_date >= DATE(NOW()) - INTERVAL 1 YEAR GROUP BY t.teacher_id;
gretelai_synthetic_text_to_sql
CREATE TABLE Renewable_Energy_Projects (project_id INT, state VARCHAR(20)); INSERT INTO Renewable_Energy_Projects (project_id, state) VALUES (1, 'California'), (2, 'Oregon'), (3, 'Washington'), (4, 'Nevada');
How many renewable energy projects are there in each state?
SELECT state, COUNT(*) FROM Renewable_Energy_Projects GROUP BY state;
gretelai_synthetic_text_to_sql
CREATE TABLE resource_depletion (id INT, location VARCHAR(50), operation_type VARCHAR(50), monthly_resource_depletion INT); INSERT INTO resource_depletion (id, location, operation_type, monthly_resource_depletion) VALUES (1, 'Australia', 'Gold', 500), (2, 'South Africa', 'Gold', 700), (3, 'Canada', 'Diamond', 600);
What is the average monthly resource depletion from diamond mining operations worldwide?
SELECT AVG(monthly_resource_depletion) as avg_depletion FROM resource_depletion WHERE operation_type = 'Diamond';
gretelai_synthetic_text_to_sql
CREATE TABLE flu_deaths (death_id INT, date TEXT, state TEXT, cause TEXT); INSERT INTO flu_deaths (death_id, date, state, cause) VALUES (1, '2022-01-01', 'California', 'Flu'); INSERT INTO flu_deaths (death_id, date, state, cause) VALUES (2, '2022-02-15', 'New York', 'Heart Attack');
What is the number of flu deaths in the past 12 months in each state?
SELECT state, COUNT(*) FROM flu_deaths WHERE date >= (CURRENT_DATE - INTERVAL '12 months') GROUP BY state;
gretelai_synthetic_text_to_sql
CREATE TABLE Artists (id INT, region VARCHAR(20), year INT, community VARCHAR(50), exhibitions INT); INSERT INTO Artists (id, region, year, community, exhibitions) VALUES (5, 'Asia', 2020, 'Underrepresented', 2); INSERT INTO Artists (id, region, year, community, exhibitions) VALUES (6, 'Asia', 2020, 'Well-represented', 3);
How many artists from underrepresented communities had exhibitions in Asia in 2020?
SELECT SUM(exhibitions) FROM Artists WHERE region = 'Asia' AND year = 2020 AND community = 'Underrepresented';
gretelai_synthetic_text_to_sql
CREATE TABLE Donations (DonationID INT, DonationQuarter INT, DonationAmount DECIMAL(10,2)); INSERT INTO Donations (DonationID, DonationQuarter, DonationAmount) VALUES (1, 1, 1000.00), (2, 4, 1500.00), (3, 3, 2000.00), (4, 2, 500.00), (5, 1, 800.00), (6, 4, 1200.00);
What is the percentage of donations made in each quarter compared to the total donations?
SELECT DonationQuarter, SUM(DonationAmount) AS TotalDonation, SUM(DonationAmount) OVER () AS TotalDonations, (SUM(DonationAmount) / SUM(DonationAmount) OVER ()) * 100.0 AS DonationPercentage FROM Donations GROUP BY DonationQuarter;
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (DonorID INT, DonorName TEXT, DonationDate DATE, Amount DECIMAL(10,2), State TEXT);
Calculate the percentage of donations received from each state in the past year.
SELECT State, SUM(Amount) AS TotalDonated, (SUM(Amount) / (SELECT SUM(Amount) FROM Donors WHERE DonationDate >= DATEADD(year, -1, GETDATE()))) * 100 AS Percentage FROM Donors WHERE DonationDate >= DATEADD(year, -1, GETDATE()) GROUP BY State;
gretelai_synthetic_text_to_sql
CREATE TABLE provinces (id INT, name VARCHAR(255)); INSERT INTO provinces (id, name) VALUES (1, 'Quebec'); CREATE TABLE wastewater_treatment (id INT, province_id INT, treatment_status VARCHAR(255), volume FLOAT, treatment_date DATE); INSERT INTO wastewater_treatment (id, province_id, treatment_status, volume, treatment_date) VALUES (1, 1, 'untreated', 500, '2022-08-01');
Find the total amount of untreated wastewater in the province of Quebec, Canada in the last month
SELECT SUM(wastewater_treatment.volume) as total_untreated_volume FROM wastewater_treatment WHERE wastewater_treatment.treatment_status = 'untreated' AND wastewater_treatment.treatment_date >= (CURRENT_DATE - INTERVAL '1 month')::date AND wastewater_treatment.province_id IN (SELECT id FROM provinces WHERE name = 'Quebec');
gretelai_synthetic_text_to_sql
CREATE TABLE explainable_ai (model_name TEXT, explainability_score INTEGER); INSERT INTO explainable_ai (model_name, explainability_score) VALUES ('modelA', 65), ('modelB', 72), ('modelC', 68);
Delete the record with the lowest explainability score in the 'explainable_ai' table.
DELETE FROM explainable_ai WHERE explainability_score = (SELECT MIN(explainability_score) FROM explainable_ai);
gretelai_synthetic_text_to_sql
CREATE TABLE mobile_customers (customer_id INT, data_usage FLOAT, city VARCHAR(20), plan_type VARCHAR(10)); INSERT INTO mobile_customers (customer_id, data_usage, city, plan_type) VALUES (1, 3.5, 'Los Angeles', 'postpaid'), (2, 4.2, 'New York', 'postpaid'), (3, 3.8, 'Los Angeles', 'prepaid');
What is the minimum data usage for postpaid mobile customers in the city of Los Angeles?
SELECT MIN(data_usage) FROM mobile_customers WHERE city = 'Los Angeles' AND plan_type = 'postpaid';
gretelai_synthetic_text_to_sql
CREATE TABLE Manufacturers (ManufacturerID INT, ManufacturerName VARCHAR(50));CREATE TABLE GarmentDates (GarmentID INT, ManufacturerID INT, AddedDate DATE);
Show the number of new garments added per month by each manufacturer.
SELECT M.ManufacturerName, EXTRACT(MONTH FROM G.AddedDate) AS Month, COUNT(G.GarmentID) AS NewGarments FROM GarmentDates G JOIN Manufacturers M ON G.ManufacturerID = M.ManufacturerID GROUP BY M.ManufacturerName, EXTRACT(MONTH FROM G.AddedDate);
gretelai_synthetic_text_to_sql
CREATE TABLE subscribers (id INT, name TEXT, data_usage FLOAT, region TEXT); INSERT INTO subscribers (id, name, data_usage, region) VALUES (1, 'John Doe', 15.0, 'urban'); INSERT INTO subscribers (id, name, data_usage, region) VALUES (2, 'Jane Smith', 20.0, 'urban'); INSERT INTO subscribers (id, name, data_usage, region) VALUES (3, 'Bob Johnson', 25.0, 'rural'); INSERT INTO subscribers (id, name, data_usage, region) VALUES (4, 'Alice Williams', 30.0, 'rural');
What is the maximum data usage by a single subscriber in 'rural' regions?
SELECT MAX(data_usage) FROM subscribers WHERE region = 'rural';
gretelai_synthetic_text_to_sql
CREATE TABLE Streams (id INT, artist VARCHAR(100), country VARCHAR(100), streams INT); INSERT INTO Streams (id, artist, country, streams) VALUES (1, 'Ariana Grande', 'Germany', 1000000);
How many streams did artist 'Ariana Grande' get in Germany?
SELECT SUM(streams) FROM Streams WHERE artist = 'Ariana Grande' AND country = 'Germany'
gretelai_synthetic_text_to_sql
CREATE TABLE EmployeeDemographics (EmployeeID INT, Department VARCHAR(20), Gender VARCHAR(10)); INSERT INTO EmployeeDemographics (EmployeeID, Department, Gender) VALUES (1, 'IT', 'Male'), (2, 'IT', 'Female'), (3, 'HR', 'Female'), (4, 'HR', 'Male'), (5, 'Finance', 'Female'), (6, 'Finance', 'Female');
List the top five departments with the highest percentage of female employees.
SELECT Department, PERCENT_RANK() OVER (ORDER BY COUNT(*) FILTER (WHERE Gender = 'Female') / COUNT(*) DESC) AS Percent_Female FROM EmployeeDemographics GROUP BY Department ORDER BY Percent_Female DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE Resources (ResourceID INT, SiteID INT, Year INT, Quantity INT); INSERT INTO Resources (ResourceID, SiteID, Year, Quantity) VALUES (1, 1, 2019, 500), (2, 2, 2019, 700), (3, 3, 2019, 800);
What is the total amount of resources depleted from each mining site in 2019?
SELECT SiteID, SUM(Quantity) FROM Resources WHERE Year = 2019 GROUP BY SiteID;
gretelai_synthetic_text_to_sql
CREATE TABLE financial_wellbeing (id INT, individual_id INT, annual_income DECIMAL(10,2), financial_wellbeing_score INT);
What is the financial wellbeing score for individuals with an annual income greater than $75,000 in Canada?
SELECT financial_wellbeing_score FROM financial_wellbeing WHERE annual_income > 75000 AND country = 'Canada';
gretelai_synthetic_text_to_sql
CREATE TABLE ParkVisits (id INT, park_name VARCHAR(50), visit_date DATE, location VARCHAR(50), visitors INT); INSERT INTO ParkVisits (id, park_name, visit_date, location, visitors) VALUES (1, 'Central Park', '2022-01-01', 'Urban', 5000), (2, 'Golden Gate Park', '2022-02-01', 'Urban', 6000), (3, 'Stanley Park', '2022-03-01', 'Urban', 4000), (4, 'High Park', '2022-01-15', 'Urban', 5500);
What is the maximum number of public park visits in the "ParkVisits" table, per month, for parks located in urban areas?
SELECT EXTRACT(MONTH FROM visit_date) as month, MAX(visitors) as max_visitors FROM ParkVisits WHERE location = 'Urban' GROUP BY month;
gretelai_synthetic_text_to_sql
CREATE TABLE Counties (CountyName VARCHAR(50), State VARCHAR(50), AverageIncome FLOAT); INSERT INTO Counties (CountyName, State, AverageIncome) VALUES ('Santa Clara', 'California', 120000), ('Travis', 'Texas', 90000), ('Westchester', 'New York', 85000), ('Miami-Dade', 'Florida', 70000), ('Cook', 'Illinois', 75000); CREATE TABLE States (State VARCHAR(50), AverageIncome FLOAT); INSERT INTO States (State, AverageIncome) VALUES ('California', 70000), ('Texas', 60000), ('New York', 65000), ('Florida', 50000), ('Illinois', 60000);
Identify counties where the average income is above the state average income.
SELECT CountyName, AverageIncome FROM Counties C WHERE AverageIncome > (SELECT AVG(AverageIncome) FROM States S WHERE S.State = C.State);
gretelai_synthetic_text_to_sql
CREATE TABLE teams (team VARCHAR(50), location VARCHAR(50), capacity INT, avg_attendance INT); INSERT INTO teams (team, location, capacity, avg_attendance) VALUES ('Barcelona', 'Spain', 100000, 80000); INSERT INTO teams (team, location, capacity, avg_attendance) VALUES ('Real Madrid', 'Spain', 120000, 95000);
What is the average number of fans that attend the home games of each team in the 'teams' table?
SELECT team, AVG(avg_attendance) FROM teams GROUP BY team;
gretelai_synthetic_text_to_sql
CREATE TABLE wells (id INT, state VARCHAR(2), cost FLOAT); INSERT INTO wells (id, state, cost) VALUES (1, 'TX', 500000.0), (2, 'TX', 600000.0), (3, 'OK', 400000.0);
Get the total number of wells in each state
SELECT state, COUNT(*) FROM wells GROUP BY state;
gretelai_synthetic_text_to_sql
CREATE TABLE transactions (id INT, customer_region VARCHAR(20), transaction_amount DECIMAL(10,2)); INSERT INTO transactions (id, customer_region, transaction_amount) VALUES (1, 'Southeast Asia', 500.00), (2, 'Southeast Asia', 750.00), (3, 'Africa', 800.00), (4, 'Europe', 900.00);
What is the average transaction amount for 'Southeast Asia' customers?
SELECT AVG(transaction_amount) FROM transactions WHERE customer_region = 'Southeast Asia';
gretelai_synthetic_text_to_sql
CREATE TABLE Vendors (VendorID INT, VendorName VARCHAR(50), MachineName VARCHAR(50), Location VARCHAR(50)); INSERT INTO Vendors (VendorID, VendorName, MachineName, Location) VALUES (1, 'VendorX', 'MachineA', 'Factory'), (2, 'VendorY', 'MachineB', 'Factory'), (3, 'VendorZ', 'MachineC', 'Warehouse');
Identify the vendors who supplied materials for the 'MachineA' and 'MachineB' in the 'Factory' location.
SELECT DISTINCT VendorName FROM Vendors WHERE MachineName IN ('MachineA', 'MachineB') AND Location = 'Factory';
gretelai_synthetic_text_to_sql
CREATE TABLE Members (MemberID INT, AgeGroup VARCHAR(20), MembershipType VARCHAR(20), Revenue DECIMAL(5,2)); INSERT INTO Members (MemberID, AgeGroup, MembershipType, Revenue) VALUES (1, 'Young Adults', 'Premium', 50.00), (2, 'Seniors', 'Basic', 30.00), (3, 'Young Adults', 'Basic', 25.00);
What is the total revenue generated from members in the "Young Adults" age group?
SELECT SUM(Revenue) FROM Members WHERE AgeGroup = 'Young Adults';
gretelai_synthetic_text_to_sql
CREATE SCHEMA MarineLife;CREATE TABLE CoralReefs (id INT, region TEXT, biomass REAL); INSERT INTO CoralReefs (id, region, biomass) VALUES (1, 'Indo-Pacific', 230000), (2, 'Atlantic Ocean', 85000), (3, 'Caribbean', 92000), (4, 'Mediterranean Sea', 50000), (5, 'Red Sea', 120000);
What is the total biomass of coral reefs in the Atlantic Ocean region in the 'MarineLife' schema?
SELECT region, SUM(biomass) AS total_biomass FROM MarineLife.CoralReefs WHERE region = 'Atlantic Ocean' GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE SatelliteDeployments (Id INT, Country VARCHAR(20), Year INT, Success BOOLEAN); INSERT INTO SatelliteDeployments VALUES (1, 'USA', 2017, true), (2, 'China', 2017, true), (3, 'India', 2017, false), (4, 'Germany', 2018, true), (5, 'Japan', 2018, true), (6, 'Brazil', 2018, true), (7, 'USA', 2018, true), (8, 'China', 2018, false), (9, 'India', 2019, true), (10, 'Germany', 2019, true), (11, 'Japan', 2019, false), (12, 'Brazil', 2019, true), (13, 'USA', 2019, true), (14, 'China', 2020, true), (15, 'India', 2020, true), (16, 'Germany', 2020, true), (17, 'Japan', 2020, true), (18, 'Brazil', 2020, false), (19, 'USA', 2021, true), (20, 'China', 2021, true);
Identify the top 3 countries with the highest number of successful satellite deployments in the past 5 years.
SELECT Country, COUNT(*) as SuccessfulDeployments FROM SatelliteDeployments WHERE Year >= 2017 AND Success = true GROUP BY Country ORDER BY SuccessfulDeployments DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE mobile_subscriber_limits (subscriber_id INT, data_limit FLOAT, data_usage FLOAT, country VARCHAR(20)); INSERT INTO mobile_subscriber_limits (subscriber_id, data_limit, data_usage, country) VALUES (1, 50, 60, 'Australia'); INSERT INTO mobile_subscriber_limits (subscriber_id, data_limit, data_usage, country) VALUES (2, 75, 85, 'Australia');
Which mobile subscribers have exceeded their data limit in Australia?
SELECT subscriber_id, name FROM mobile_subscriber_limits INNER JOIN (SELECT subscriber_id FROM mobile_subscriber_limits WHERE data_usage > data_limit GROUP BY subscriber_id HAVING COUNT(*) > 1) subscriber_exceed_limit ON mobile_subscriber_limits.subscriber_id = subscriber_exceed_limit.subscriber_id;
gretelai_synthetic_text_to_sql
CREATE TABLE citizen_feedback (citizen_id INT, feedback TEXT, feedback_date DATE);
Delete records of citizens who have provided negative feedback from the 'citizen_feedback' table
DELETE FROM citizen_feedback WHERE feedback < 0;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_species_pacific_ocean (id INT, species_name VARCHAR(255), population INT, habitat VARCHAR(255)); INSERT INTO marine_species_pacific_ocean (id, species_name, population, habitat) VALUES (1, 'Bottlenose Dolphin', 60000, 'Pacific Ocean'), (2, 'Leatherback Sea Turtle', 34000, 'Pacific Ocean'), (3, 'Sperm Whale', 5000, 'Pacific Ocean'); CREATE TABLE oceanography_pacific_ocean (region VARCHAR(255), depth FLOAT, temperature FLOAT, salinity FLOAT); INSERT INTO oceanography_pacific_ocean (region, depth, temperature, salinity) VALUES ('Pacific Ocean', 5000, 25, 35.5);
What is the average depth in the Pacific Ocean where marine mammals reside, grouped by species?
SELECT m.species_name, AVG(o.depth) AS avg_depth FROM marine_species_pacific_ocean m INNER JOIN oceanography_pacific_ocean o ON m.habitat = o.region WHERE m.species_name LIKE '%mammal%' GROUP BY m.species_name;
gretelai_synthetic_text_to_sql
CREATE TABLE infrastructure_projects (id INT, project_name VARCHAR(50), location VARCHAR(50), budget DECIMAL(10,2)); INSERT INTO infrastructure_projects (id, project_name, location, budget) VALUES (1, 'Highway 101 Expansion', 'California', 5000000), (2, 'Bridge Replacement', 'New York', 3000000), (3, 'Transit System Upgrade', 'Texas', 8000000);
What is the average budget for infrastructure projects in California?
SELECT AVG(budget) as avg_budget FROM infrastructure_projects WHERE location = 'California';
gretelai_synthetic_text_to_sql
CREATE TABLE water_consumption (city VARCHAR(50), consumption FLOAT, month INT, year INT); INSERT INTO water_consumption (city, consumption, month, year) VALUES ('Chicago', 150.2, 1, 2021), ('Chicago', 140.5, 2, 2021), ('Chicago', 160.8, 3, 2021);
Calculate the total water consumption for the first half of the year for the city of Chicago.
SELECT SUM(consumption) FROM water_consumption WHERE city = 'Chicago' AND year = 2021 AND month BETWEEN 1 AND 6;
gretelai_synthetic_text_to_sql
CREATE TABLE tennessee_rural_hospitals (hospital_id INT, hospital_name VARCHAR(255), rural BOOLEAN, emergency_room BOOLEAN); INSERT INTO tennessee_rural_hospitals VALUES (1, 'Hospital A', true, true), (2, 'Hospital B', false, true);
What is the percentage of hospitals in rural areas of Tennessee with an emergency room?
SELECT (COUNT(*) FILTER (WHERE emergency_room = true)) * 100.0 / COUNT(*) FROM tennessee_rural_hospitals WHERE rural = true;
gretelai_synthetic_text_to_sql
CREATE TABLE energy_sources (id INT PRIMARY KEY, source VARCHAR(50), capacity_mw FLOAT); INSERT INTO energy_sources (id, source, capacity_mw) VALUES (1, 'Wind', 1200.0), (2, 'Solar', 800.0), (3, 'Hydro', 1500.0);
What is the average capacity of renewable energy sources in MW?
SELECT AVG(capacity_mw) FROM energy_sources WHERE source IN ('Wind', 'Solar', 'Hydro');
gretelai_synthetic_text_to_sql
CREATE TABLE employees (employee_id INT, name VARCHAR(50), department VARCHAR(20), hire_date DATE);
List all employees who have not been involved in any transactions in the past month.
SELECT employee_id, name FROM employees e WHERE NOT EXISTS (SELECT 1 FROM transactions t WHERE t.employee_id = e.employee_id AND t.transaction_date >= (CURRENT_DATE - INTERVAL '1 month'));
gretelai_synthetic_text_to_sql
CREATE TABLE military_promotions (id INT, name TEXT, country TEXT, rank TEXT, promotion_year INT);INSERT INTO military_promotions (id, name, country, rank, promotion_year) VALUES (1, 'John Doe', 'Country Z', 'Sergeant', 2020), (2, 'Jane Smith', 'Country Z', 'Captain', 2020);
What are the names and ranks of all military personnel in country Z who were promoted in the year 2020?
SELECT name, rank FROM military_promotions WHERE country = 'Country Z' AND promotion_year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE Infrastructure (id INT, name VARCHAR(100), type VARCHAR(50), location VARCHAR(100), state VARCHAR(50)); INSERT INTO Infrastructure (id, name, type, location, state) VALUES (1, 'Golden Gate Bridge', 'Bridge', 'San Francisco', 'California');
Find the number of bridges in the state of California
SELECT COUNT(*) FROM Infrastructure WHERE state = 'California' AND type = 'Bridge';
gretelai_synthetic_text_to_sql
CREATE TABLE union_workplaces (id INT, union_id INT, workplace_name VARCHAR(50), injury_rate DECIMAL(5,2)); INSERT INTO union_workplaces (id, union_id, workplace_name, injury_rate) VALUES (1, 1001, 'ABC Factory', 6.5), (2, 1001, 'DEF Warehouse', 2.9), (3, 1002, 'XYZ Inc', 3.2), (4, 1003, 'LMN Corp', 9.1), (5, 1003, 'OPQ Office', 4.7);
How many distinct unions are there and their minimum rates?
SELECT COUNT(DISTINCT union_id) as num_unions, MIN(injury_rate) as min_injury_rate FROM union_workplaces;
gretelai_synthetic_text_to_sql
CREATE TABLE basketball_stats (team VARCHAR(50), player VARCHAR(50), assists INT, date DATE); INSERT INTO basketball_stats (team, player, assists, date) VALUES ('Golden State Warriors', 'Stephen Curry', 8, '2022-01-01'), ('Golden State Warriors', 'Draymond Green', 10, '2022-01-01'), ('Brooklyn Nets', 'Kyrie Irving', 5, '2022-01-02');
What is the average number of assists per game for the 'Golden State Warriors' in the 'basketball_stats' table?
SELECT AVG(assists) FROM basketball_stats WHERE team = 'Golden State Warriors';
gretelai_synthetic_text_to_sql
CREATE TABLE players (player_id INT, name VARCHAR(30), age INT, gender VARCHAR(10), country VARCHAR(30), registration_date DATE, platform VARCHAR(20));
How many players registered in 2022 play multiplayer online battle arena (MOBA) games on PC?
SELECT COUNT(*) FROM players WHERE YEAR(registration_date) = 2022 AND genre = 'MOBA' AND platform = 'PC';
gretelai_synthetic_text_to_sql
CREATE TABLE players(id INT, name VARCHAR(50), country VARCHAR(50), age INT, last_login DATETIME); CREATE TABLE game_sessions(id INT, player_id INT, game_name VARCHAR(50), start_time DATETIME);
Show the number of players who played a specific game in the last month, grouped by country and age.
SELECT game_name, country, age, COUNT(DISTINCT players.id) as num_players FROM game_sessions JOIN players ON game_sessions.player_id = players.id WHERE start_time >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) GROUP BY game_name, country, age;
gretelai_synthetic_text_to_sql
CREATE TABLE education_programs (id INT, program_name VARCHAR(50), year INT, attendees INT); INSERT INTO education_programs (id, program_name, year, attendees) VALUES (1, 'Wildlife Conservation', 2023, 40), (2, 'Habitat Protection', 2022, 30);
What is the total number of community education programs conducted in '2022' and '2023' with less than 50 attendees?
SELECT COUNT(*) FROM education_programs WHERE year IN (2022, 2023) AND attendees < 50;
gretelai_synthetic_text_to_sql
CREATE TABLE Donations (DonationID INT, DonorID INT, DonationDate DATE, DonationAmount FLOAT); INSERT INTO Donations (DonationID, DonorID, DonationDate, DonationAmount) VALUES (1, 1, '2023-01-01', 75.00), (2, 2, '2023-02-14', 125.00), (3, 3, '2023-04-05', 50.00);
What is the total donation amount per quarter in 2023?
SELECT DATE_FORMAT(DonationDate, '%Y-%m') AS Quarter, SUM(DonationAmount) AS TotalDonation FROM Donations WHERE YEAR(DonationDate) = 2023 GROUP BY Quarter;
gretelai_synthetic_text_to_sql
CREATE TABLE ports (port_id INT, port_name VARCHAR(255)); INSERT INTO ports (port_id, port_name) VALUES (1, 'Busan'), (2, 'Incheon'), (3, 'Daegu'); CREATE TABLE cargo (cargo_id INT, port_id INT, weight FLOAT); INSERT INTO cargo (cargo_id, port_id, weight) VALUES (1, 1, 1000), (2, 1, 1500), (3, 2, 800), (4, 3, 1200);
What is the minimum cargo weight handled by port 'Busan' and 'Incheon'?
SELECT MIN(weight) FROM cargo WHERE port_name IN ('Busan', 'Incheon');
gretelai_synthetic_text_to_sql
CREATE TABLE tourism_stats (id INT, country VARCHAR(255), visit_year INT, visit_type VARCHAR(255)); INSERT INTO tourism_stats (id, country, visit_year, visit_type) VALUES (1, 'Japan', 2020, 'eco-tourism'), (2, 'Japan', 2021, 'eco-tourism');
What is the total number of visitors who traveled to Japan for eco-tourism in 2020 and 2021?
SELECT SUM(id) FROM tourism_stats WHERE country = 'Japan' AND visit_year IN (2020, 2021) AND visit_type = 'eco-tourism';
gretelai_synthetic_text_to_sql
CREATE TABLE Transactions (TransactionID int, ContractAddress varchar(50), Developer varchar(50), Transactions int); INSERT INTO Transactions (TransactionID, ContractAddress, Developer, Transactions) VALUES (1, 'ContractA', 'Alice', 100), (2, 'ContractB', 'Bob', 200), (3, 'ContractC', 'Charlie', 300);
Display the smart contracts with the lowest and highest transaction counts for each developer, in ascending order by developer name.
SELECT Developer, MIN(Transactions) as MinTransactions, MAX(Transactions) as MaxTransactions FROM Transactions GROUP BY Developer ORDER BY Developer;
gretelai_synthetic_text_to_sql
CREATE TABLE Stock ( StockID INT, FarmID INT, FishSpecies VARCHAR(255), Weight DECIMAL(10,2), StockDate DATE ); INSERT INTO Stock (StockID, FarmID, FishSpecies, Weight, StockDate) VALUES (1, 1, 'Tilapia', 5.5, '2022-01-01'), (2, 1, 'Salmon', 12.3, '2022-01-02'), (3, 1, 'Tilapia', 6.0, '2022-01-03'), (4, 1, 'Catfish', 8.2, '2022-01-04');
What is the total biomass of fish for each species in a given month?
SELECT FishSpecies, DATE_TRUNC('month', StockDate) as Month, SUM(Weight) OVER (PARTITION BY FishSpecies, DATE_TRUNC('month', StockDate)) as TotalBiomass FROM Stock WHERE FarmID = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE company (id INT, name TEXT, industry TEXT, founding_year INT); INSERT INTO company (id, name, industry, founding_year) VALUES (1, 'Acme Corp', 'Tech', 2010), (2, 'Beta Inc', 'Healthcare', 2012); CREATE TABLE investment (id INT, company_id INT, funding_amount INT, investment_year INT); INSERT INTO investment (id, company_id, funding_amount, investment_year) VALUES (1, 1, 5000000, 2015), (2, 2, 7000000, 2017);
What is the average funding amount for startups in the healthcare industry?
SELECT AVG(funding_amount) FROM investment JOIN company ON investment.company_id = company.id WHERE company.industry = 'Healthcare';
gretelai_synthetic_text_to_sql
CREATE TABLE ptsd_diagnosis (patient_id INT, age INT, condition VARCHAR(255), country VARCHAR(255)); INSERT INTO ptsd_diagnosis (patient_id, age, condition, country) VALUES (1, 35, 'PTSD', 'Japan'); INSERT INTO ptsd_diagnosis (patient_id, age, condition, country) VALUES (2, 40, 'Anxiety', 'Japan');
What is the maximum age of patients diagnosed with PTSD in Japan?
SELECT MAX(age) FROM ptsd_diagnosis WHERE condition = 'PTSD' AND country = 'Japan';
gretelai_synthetic_text_to_sql
CREATE TABLE wheat_production (id INT, quantity INT, yield_per_hectare DECIMAL(5,2), country VARCHAR(255)); INSERT INTO wheat_production (id, quantity, yield_per_hectare, country) VALUES (1, 12, 9.00, 'Germany');
What is the maximum production of wheat per hectare in Germany?
SELECT MAX(yield_per_hectare) FROM wheat_production WHERE country = 'Germany';
gretelai_synthetic_text_to_sql
CREATE TABLE Aircrafts (AircraftID INT, Model VARCHAR(20), ManufacturingDate DATE, TotalProduced INT); CREATE TABLE ManufacturingDates (ManufacturingDate DATE); INSERT INTO ManufacturingDates (ManufacturingDate) VALUES ('1976-08-01'), ('2006-01-01'); INSERT INTO Aircrafts (AircraftID, Model, ManufacturingDate, TotalProduced) VALUES (1, 'F-16', '1976-08-01', 450), (2, 'F-35', '2006-01-01', 50), (3, 'F-35B', '2009-05-01', 70);
List the total production and number of unique manufacturing dates for each aircraft model, excluding the models with total production less than 100.
SELECT Model, SUM(TotalProduced) as 'Total Production', COUNT(DISTINCT ManufacturingDate) as 'Number of Manufacturing Dates' FROM Aircrafts WHERE TotalProduced >= 100 GROUP BY Model;
gretelai_synthetic_text_to_sql