context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE mitigation_projects (id INT PRIMARY KEY, name VARCHAR(255), location VARCHAR(255), description TEXT, start_date DATE, end_date DATE, budget FLOAT); INSERT INTO mitigation_projects (id, name, location, description, start_date, end_date, budget) VALUES (1, 'Solar Farm Installation', 'California', 'Installation of solar panels', '2018-01-01', '2019-12-31', 10000000);
What is the total budget spent on climate mitigation projects in '2019' from the 'mitigation_projects' table?
SELECT SUM(budget) FROM mitigation_projects WHERE start_date <= '2019-12-31' AND end_date >= '2019-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE products (id INT, product_name VARCHAR(50), category VARCHAR(50), is_organic BOOLEAN, price DECIMAL(5,2)); INSERT INTO products (id, product_name, category, is_organic, price) VALUES (1, 'Shampoo', 'Hair Care', true, 12.99), (2, 'Conditioner', 'Hair Care', false, 14.50), (3, 'Styling Gel', 'Hair Care', false, 8.99); CREATE TABLE sales (id INT, product_id INT, quantity INT, sale_date DATE, country VARCHAR(50)); INSERT INTO sales (id, product_id, quantity, sale_date, country) VALUES (1, 1, 200, '2022-03-15', 'Canada'), (2, 2, 150, '2022-06-10', 'Canada'), (3, 3, 300, '2022-02-22', 'USA');
What is the total revenue generated from organic hair care products in Canada in H1 of 2022?
SELECT SUM(price * quantity) FROM products JOIN sales ON products.id = sales.product_id WHERE products.category = 'Hair Care' AND products.is_organic = true AND sales.country = 'Canada' AND sales.sale_date BETWEEN '2022-01-01' AND '2022-06-30';
gretelai_synthetic_text_to_sql
CREATE TABLE bioprocess_engineering (id INT, project_name VARCHAR(100), lead_engineer VARCHAR(100), duration INT);
What is the average bioprocess engineering project duration for projects led by Dr. Patel?
SELECT AVG(duration) FROM bioprocess_engineering WHERE lead_engineer = 'Dr. Patel';
gretelai_synthetic_text_to_sql
CREATE TABLE digital_assets (asset_id varchar(10), asset_name varchar(10)); INSERT INTO digital_assets (asset_id, asset_name) VALUES ('ETH', 'Ethereum'), ('BTC', 'Bitcoin'); CREATE TABLE transactions (transaction_id serial, asset_id varchar(10), transaction_amount numeric); INSERT INTO transactions (asset_id, transaction_amount) VALUES ('ETH', 120), ('ETH', 230), ('BTC', 500), ('ETH', 100);
What is the maximum transaction amount for 'BTC'?
SELECT MAX(transaction_amount) FROM transactions WHERE asset_id = 'BTC';
gretelai_synthetic_text_to_sql
CREATE TABLE CityData (City VARCHAR(20), HeritageSites INT, CommunityEvents INT); INSERT INTO CityData VALUES ('Seattle', 1, 2), ('Portland', 0, 1); CREATE VIEW HeritageSiteCount AS SELECT City, COUNT(*) AS HeritageSites FROM HeritageSites GROUP BY City; CREATE VIEW CommunityEventCount AS SELECT City, COUNT(*) AS CommunityEvents FROM CityEngagement GROUP BY City;
Present the number of heritage sites and community engagement events in each city.
SELECT d.City, h.HeritageSites, e.CommunityEvents FROM CityData d JOIN HeritageSiteCount h ON d.City = h.City JOIN CommunityEventCount e ON d.City = e.City;
gretelai_synthetic_text_to_sql
CREATE TABLE sales (sale_id INT, product_id INT, quantity INT, price DECIMAL(5,2), sale_date DATE); CREATE TABLE products (product_id INT, material VARCHAR(20), market VARCHAR(20)); INSERT INTO sales (sale_id, product_id, quantity, price, sale_date) VALUES (1, 1, 10, 25.00, '2022-01-01'), (2, 2, 5, 10.00, '2022-01-05'), (3, 3, 8, 30.00, '2022-01-10'), (4, 1, 15, 25.00, '2022-02-01'), (5, 2, 8, 10.00, '2022-02-05'), (6, 3, 12, 30.00, '2022-02-10'); INSERT INTO products (product_id, material, market) VALUES (1, 'organic cotton', 'Europe'), (2, 'polyester', 'Asia'), (3, 'recycled cotton', 'Europe');
What is the average quantity of products sold in the European market per month?
SELECT AVG(quantity) FROM sales JOIN products ON sales.product_id = products.product_id WHERE products.market = 'Europe' GROUP BY EXTRACT(MONTH FROM sale_date);
gretelai_synthetic_text_to_sql
CREATE TABLE clinics (clinic_id INT, clinic_name VARCHAR(50), city VARCHAR(50), state VARCHAR(50)); INSERT INTO clinics (clinic_id, clinic_name, city, state) VALUES (1, 'ClinicE', 'Miami', 'FL'), (2, 'ClinicF', 'Tampa', 'FL'); CREATE TABLE patients (patient_id INT, patient_name VARCHAR(50), age INT, clinic_id INT, condition_id INT); INSERT INTO patients (patient_id, patient_name, age, clinic_id, condition_id) VALUES (1, 'James Doe', 35, 1, 3), (2, 'Jasmine Smith', 28, 1, 1), (3, 'Alice Johnson', 42, 2, 2); CREATE TABLE conditions (condition_id INT, condition_name VARCHAR(50)); INSERT INTO conditions (condition_id, condition_name) VALUES (1, 'Depression'), (2, 'Anxiety Disorder'), (3, 'Bipolar Disorder'); CREATE TABLE therapies (therapy_id INT, therapy_name VARCHAR(50), patient_id INT); INSERT INTO therapies (therapy_id, therapy_name, patient_id) VALUES (1, 'CBT', 1), (2, 'DBT', 2);
What is the average age of patients with bipolar disorder who have not received any therapy in mental health clinics located in Florida?
SELECT AVG(age) FROM patients p JOIN clinics c ON p.clinic_id = c.clinic_id LEFT JOIN therapies t ON p.patient_id = t.patient_id JOIN conditions cond ON p.condition_id = cond.condition_id WHERE c.state = 'FL' AND cond.condition_name = 'Bipolar Disorder' AND t.therapy_id IS NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE ingredient_sourcing (ingredient_id INT, ingredient_name VARCHAR(100), sourcing_country VARCHAR(50), is_organic BOOLEAN); INSERT INTO ingredient_sourcing (ingredient_id, ingredient_name, sourcing_country, is_organic) VALUES (1, 'Rosehip Oil', 'Chile', TRUE), (2, 'Shea Butter', 'Ghana', TRUE), (3, 'Jojoba Oil', 'Argentina', TRUE), (4, 'Coconut Oil', 'Philippines', FALSE), (5, 'Aloe Vera', 'Mexico', TRUE);
Display ingredient sourcing information for all organic ingredients.
SELECT * FROM ingredient_sourcing WHERE is_organic = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE reverse_logistics (id INT, shipping_method VARCHAR(20), quantity INT); INSERT INTO reverse_logistics (id, shipping_method, quantity) VALUES (1, 'Return Shipping', 50), (2, 'Exchange Shipping', 30), (3, 'Repair Shipping', 40), (4, 'Return Shipping', 60), (5, 'Exchange Shipping', 20);
List all unique shipping methods used in the reverse logistics process, along with the number of times each method was used.
SELECT shipping_method, COUNT(*) FROM reverse_logistics GROUP BY shipping_method;
gretelai_synthetic_text_to_sql
CREATE TABLE MentalHealth (StudentID int, Date date, MentalHealthScore int);
Delete a mental health record from the 'MentalHealth' table
DELETE FROM MentalHealth WHERE StudentID = 1234 AND Date = '2022-09-01';
gretelai_synthetic_text_to_sql
CREATE TABLE wastewater_treatment (state_name TEXT, efficiency FLOAT); INSERT INTO wastewater_treatment (state_name, efficiency) VALUES ('California', 0.85), ('Texas', 0.83), ('Florida', 0.88), ('New York', 0.82), ('Pennsylvania', 0.87);
What is the rank of each state in terms of wastewater treatment efficiency?
SELECT state_name, RANK() OVER (ORDER BY efficiency DESC) AS rank FROM wastewater_treatment;
gretelai_synthetic_text_to_sql
CREATE TABLE articles_by_day (day DATE, category TEXT, article_count INT); INSERT INTO articles_by_day (day, category, article_count) VALUES ('2022-01-01', 'Entertainment', 3), ('2022-01-02', 'Sports', 2), ('2022-01-01', 'Entertainment', 1);
What is the number of articles published per day in the 'Entertainment' category?
SELECT day, category, SUM(article_count) as total FROM articles_by_day WHERE category = 'Entertainment' GROUP BY day;
gretelai_synthetic_text_to_sql
CREATE TABLE vulnerabilities (id INT, product VARCHAR(50), severity INT, last_patch DATE);
What is the average severity of vulnerabilities for each software product in the last month?
SELECT product, AVG(severity) as avg_severity FROM vulnerabilities WHERE last_patch < DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) GROUP BY product;
gretelai_synthetic_text_to_sql
CREATE TABLE incidents (incident_id INT, detected_at TIMESTAMP, responded_at TIMESTAMP);
What is the average time to detect and respond to security incidents?
AVG(TIMESTAMPDIFF(MINUTE, detected_at, responded_at)) as avg_time_to_respond
gretelai_synthetic_text_to_sql
CREATE TABLE regions (id INT, mine VARCHAR(50), region VARCHAR(50), resource VARCHAR(50), quantity INT); INSERT INTO regions (id, mine, region, resource, quantity) VALUES (1, 'Mine A', 'West', 'Coal', 1000), (2, 'Mine B', 'East', 'Iron Ore', 2000), (3, 'Mine A', 'West', 'Iron Ore', 1500);
What is the total amount of resources produced by each region?
SELECT region, resource, SUM(quantity) AS total_quantity FROM regions GROUP BY region, resource;
gretelai_synthetic_text_to_sql
CREATE TABLE production (production_id INT, well_id INT, production_date DATE, production_type TEXT, country TEXT); INSERT INTO production (production_id, well_id, production_date, production_type, country) VALUES (1, 1, '2018-01-01', 'Oil', 'USA'), (2, 1, '2018-01-02', 'Gas', 'Norway'), (3, 2, '2019-05-03', 'Oil', 'Canada'), (4, 3, '2020-02-04', 'Gas', 'Norway'), (5, 4, '2021-03-09', 'Oil', 'Brazil'), (6, 5, '2021-04-15', 'Gas', 'India'), (7, 6, '2018-06-20', 'Oil', 'Canada'), (8, 6, '2019-06-20', 'Oil', 'Canada'), (9, 7, '2020-06-20', 'Oil', 'Canada'), (10, 7, '2021-06-20', 'Oil', 'Canada');
Find the total production volume for each year, for the 'Oil' production type, for wells located in 'Canada'.
SELECT EXTRACT(YEAR FROM production_date) as year, SUM(production_volume) as total_oil_production FROM production WHERE production_type = 'Oil' AND country = 'Canada' GROUP BY year;
gretelai_synthetic_text_to_sql
CREATE TABLE EV_Data (Id INT, City VARCHAR(50), Type VARCHAR(50), Speed INT, Month VARCHAR(10)); INSERT INTO EV_Data (Id, City, Type, Speed, Month) VALUES (1, 'NewYork', 'Electric', 60, 'August'); INSERT INTO EV_Data (Id, City, Type, Speed, Month) VALUES (2, 'SanFrancisco', 'Hybrid', 55, 'August');
What is the average speed of electric vehicles in the city of New York in the month of August?
SELECT AVG(Speed) FROM EV_Data WHERE City = 'NewYork' AND Month = 'August' AND Type = 'Electric';
gretelai_synthetic_text_to_sql
CREATE VIEW equipment_summary AS SELECT equipment.name AS equipment_name, sales.region, SUM(sales.quantity * equipment.price) AS total_sales FROM equipment INNER JOIN sales ON equipment.id = sales.equipment_id GROUP BY equipment.name, sales.region;
Create a view named 'equipment_summary' with columns 'equipment_name', 'region', 'total_sales'
CREATE VIEW equipment_summary AS SELECT equipment.name AS equipment_name, sales.region, SUM(sales.quantity * equipment.price) AS total_sales FROM equipment INNER JOIN sales ON equipment.id = sales.equipment_id GROUP BY equipment.name, sales.region;
gretelai_synthetic_text_to_sql
CREATE TABLE Programs (id INT, name TEXT, funding_source TEXT); INSERT INTO Programs (id, name, funding_source) VALUES (1, 'Dance Performance', 'Corporate'), (2, 'Film Festival', 'Foundation'), (3, 'Photography Exhibition', 'Government');
Find the number of unique programs funded by 'Corporate' and 'Foundation' funding sources.
SELECT COUNT(DISTINCT name) FROM Programs WHERE funding_source IN ('Corporate', 'Foundation');
gretelai_synthetic_text_to_sql
CREATE TABLE savings (customer_id INT, name TEXT, state TEXT, savings DECIMAL(10, 2)); INSERT INTO savings (customer_id, name, state, savings) VALUES (789, 'Bob Smith', 'California', 8000.00), (111, 'Alice Johnson', 'California', 6000.00);
What is the average savings of customers living in 'California'?
SELECT AVG(savings) FROM savings WHERE state = 'California';
gretelai_synthetic_text_to_sql
CREATE TABLE sustainability (practice VARCHAR(50), country VARCHAR(50)); INSERT INTO sustainability (practice, country) VALUES ('Renewable Energy', 'France'), ('Local Sourcing', 'Italy'), ('Educational Programs', 'Spain'), ('Waste Management', 'Germany'), ('Renewable Energy', 'Japan'), ('Local Sourcing', 'Canada');
List all sustainable tourism practices and the number of countries implementing each.
SELECT practice, COUNT(DISTINCT country) as num_countries FROM sustainability GROUP BY practice;
gretelai_synthetic_text_to_sql
CREATE TABLE habitat (id INT, name VARCHAR(255), area_ha INT); INSERT INTO habitat (id, name, area_ha) VALUES (1, 'Habitat1', 5000), (2, 'Habitat2', 7000), (3, 'Habitat3', 6000);
What is the total area of all wildlife habitats in hectares?
SELECT SUM(area_ha) FROM habitat;
gretelai_synthetic_text_to_sql
CREATE TABLE Army (id INT, name VARCHAR(50), rank VARCHAR(20), region VARCHAR(20), num_personnel INT); INSERT INTO Army (id, name, rank, region, num_personnel) VALUES (1, 'John Doe', 'Colonel', 'Europe', 500);
What is the total number of military personnel in the 'Army' table?
SELECT SUM(num_personnel) FROM Army;
gretelai_synthetic_text_to_sql
CREATE TABLE cultural_heritage (id INT, site VARCHAR(50), country VARCHAR(20), annual_visitors INT); INSERT INTO cultural_heritage (id, site, country, annual_visitors) VALUES (1, 'Colosseum', 'Italy', 6000), (2, 'Leaning Tower of Pisa', 'Italy', 4000), (3, 'Roman Forum', 'Italy', 5500);
How many cultural heritage sites in Italy have more than 5,000 annual visitors?
SELECT COUNT(*) FROM cultural_heritage WHERE country = 'Italy' GROUP BY country HAVING SUM(annual_visitors) > 5000;
gretelai_synthetic_text_to_sql
CREATE TABLE ride_sharing (id INT, vehicle VARCHAR(20), city VARCHAR(20)); INSERT INTO ride_sharing (id, vehicle, city) VALUES (1, 'bike', 'San Francisco'), (2, 'e-scooter', 'San Francisco');
What is the total number of shared bikes and e-scooters in San Francisco?
SELECT SUM(CASE WHEN vehicle IN ('bike', 'e-scooter') THEN 1 ELSE 0 END) FROM ride_sharing WHERE city = 'San Francisco';
gretelai_synthetic_text_to_sql
CREATE TABLE companies (company_id INT, name VARCHAR(30), recycling_program BOOLEAN, recycling_program_start_date DATE);
List all companies that have a 'recycling' program and their corresponding program start dates.
SELECT companies.name, companies.recycling_program_start_date FROM companies WHERE companies.recycling_program = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE Locations (Location_ID INT, Location_Name TEXT); INSERT INTO Locations (Location_ID, Location_Name) VALUES (1, 'Location1'), (2, 'Location2'); CREATE TABLE Sustainable_Sourcing (Source_ID INT, Location_ID INT, Cost DECIMAL); INSERT INTO Sustainable_Sourcing (Source_ID, Location_ID, Cost) VALUES (1, 1, 100.00), (2, 1, 200.00), (3, 2, 300.00), (4, 2, 400.00);
Calculate the total sustainable sourcing cost per location.
SELECT L.Location_Name, SUM(SS.Cost) as Total_Sustainable_Cost FROM Sustainable_Sourcing SS JOIN Locations L ON SS.Location_ID = L.Location_ID GROUP BY L.Location_Name;
gretelai_synthetic_text_to_sql
CREATE TABLE Policyholders (PolicyID INT, PolicyholderName TEXT, State TEXT); INSERT INTO Policyholders (PolicyID, PolicyholderName, State) VALUES (1, 'John Smith', 'CO'), (2, 'Jane Doe', 'NY'); CREATE TABLE Claims (ClaimID INT, PolicyID INT, ClaimAmount INT); INSERT INTO Claims (ClaimID, PolicyID, ClaimAmount) VALUES (1, 1, 5000), (2, 1, 3000), (3, 2, 7000);
What is the number of policies and total claim amount for policyholders in 'CO'?
SELECT COUNT(Policyholders.PolicyID) AS NumPolicies, SUM(Claims.ClaimAmount) AS TotalClaimAmount FROM Policyholders INNER JOIN Claims ON Policyholders.PolicyID = Claims.PolicyID WHERE Policyholders.State = 'CO';
gretelai_synthetic_text_to_sql
CREATE TABLE Artwork (artwork_id INT, artwork_name VARCHAR(30), genre VARCHAR(20), artist_id INT); CREATE TABLE Artist (artist_id INT, artist_name VARCHAR(30));
List all artworks in the 'Surrealism' genre, along with the name of the artist who created each artwork.
SELECT Artwork.artwork_name, Artist.artist_name FROM Artwork INNER JOIN Artist ON Artwork.artist_id = Artist.artist_id WHERE Artwork.genre = 'Surrealism';
gretelai_synthetic_text_to_sql
CREATE TABLE Policyholders (PolicyholderID INT, Name VARCHAR(50), Address VARCHAR(100), State VARCHAR(2)); CREATE TABLE LifeInsurance (PolicyholderID INT, PolicyType VARCHAR(50)); CREATE TABLE HealthInsurance (PolicyholderID INT, PolicyType VARCHAR(50));
Insert new records into the Policyholders, LifeInsurance, and HealthInsurance tables for a new policyholder who lives in California.
INSERT INTO Policyholders (PolicyholderID, Name, Address, State) VALUES (5, 'Maria Garcia', '910 Olive Ave', 'CA'); INSERT INTO LifeInsurance (PolicyholderID, PolicyType) VALUES (5, 'Whole Life'); INSERT INTO HealthInsurance (PolicyholderID, PolicyType) VALUES (5, 'PPO');
gretelai_synthetic_text_to_sql
CREATE TABLE renewable_energy_projects (id INT, project_name VARCHAR(255), country VARCHAR(255), technology VARCHAR(255), start_date DATE, end_date DATE);
Number of renewable energy projects in Latin America
SELECT COUNT(*) FROM renewable_energy_projects WHERE country IN ('Brazil', 'Colombia', 'Argentina', 'Chile', 'Peru') AND technology != 'Fossil';
gretelai_synthetic_text_to_sql
CREATE TABLE production (id INT, garment_id INT, country VARCHAR(255), material VARCHAR(255)); INSERT INTO production (id, garment_id, country, material) VALUES
How many garments are made of hemp in India?
SELECT COUNT(*) FROM production WHERE material = 'Hemp' AND country = 'India';
gretelai_synthetic_text_to_sql
CREATE TABLE courts (court_id INT, court_name VARCHAR(255), PRIMARY KEY (court_id)); CREATE TABLE court_cases (court_id INT, case_id INT, PRIMARY KEY (court_id, case_id), FOREIGN KEY (court_id) REFERENCES courts(court_id), FOREIGN KEY (case_id) REFERENCES cases(case_id)); INSERT INTO courts (court_id, court_name) VALUES (1, 'Court 1'), (2, 'Court 2'), (3, 'Court 3'); INSERT INTO court_cases (court_id, case_id) VALUES (1, 1), (1, 2), (2, 3), (3, 4);
Calculate the average number of cases per court in the justice system
SELECT AVG(cc.court_id) FROM courts c INNER JOIN court_cases cc ON c.court_id = cc.court_id;
gretelai_synthetic_text_to_sql
CREATE TABLE Vendor (VendorID INT, VendorName VARCHAR(50), FarmID INT); INSERT INTO Vendor (VendorID, VendorName, FarmID) VALUES (1, 'EcoMarket', 1), (2, 'NaturalHarvest', 2), (3, 'GreenBasket', 1); CREATE TABLE Sales (VendorID INT, ItemID INT, Quantity INT); INSERT INTO Sales (VendorID, ItemID, Quantity) VALUES (1, 1, 500), (2, 2, 700), (3, 1, 600);
Vendors with the highest quantity of organic food sold
SELECT v.VendorName, SUM(s.Quantity) FROM Vendor v INNER JOIN Sales s ON v.VendorID = s.VendorID INNER JOIN OrganicFarm f ON v.FarmID = f.FarmID GROUP BY v.VendorName ORDER BY SUM(s.Quantity) DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_protected_areas (id INT, name VARCHAR(50), size FLOAT, country VARCHAR(50));
Update the name of the record with id 7 in the table "marine_protected_areas" to 'Coral Reefs'
UPDATE marine_protected_areas SET name = 'Coral Reefs' WHERE id = 7;
gretelai_synthetic_text_to_sql
CREATE TABLE Biosensor (biosensor_id INT, name TEXT, year INT); INSERT INTO Biosensor (biosensor_id, name, year) VALUES (1, 'BS1', 2019), (2, 'BS2', 2021), (3, 'BS3', 2018);
Which biosensors were developed in '2021'?
SELECT name FROM Biosensor WHERE year = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE Donations (donation_id INT, org_id INT, donation_amount DECIMAL(10,2));
What is the total donation amount for each organization in the 'Donations' and 'Organizations' tables?
SELECT O.name, SUM(D.donation_amount) FROM Donations D INNER JOIN Organizations O ON D.org_id = O.org_id GROUP BY O.name;
gretelai_synthetic_text_to_sql
CREATE TABLE premier_league_seasons (season_id INT, season_start_date DATE, season_end_date DATE); CREATE TABLE premier_league_games (game_id INT, season_id INT, home_team VARCHAR(100), away_team VARCHAR(100), home_team_goals INT, away_team_goals INT);
What is the maximum number of goals scored by a single player in a game in each of the last five seasons in the Premier League?
SELECT s.season_start_date, MAX(g.home_team_goals) as max_goals FROM premier_league_seasons s JOIN premier_league_games g ON s.season_id = g.season_id WHERE s.season_id >= (SELECT MAX(season_id) - 5) GROUP BY s.season_start_date;
gretelai_synthetic_text_to_sql
CREATE TABLE whale_sanctuaries (name VARCHAR(255), location VARCHAR(255)); INSERT INTO whale_sanctuaries (name, location) VALUES ('SSS', 'North Atlantic');
What are the names and locations of all whale sanctuaries?
SELECT name, location FROM whale_sanctuaries
gretelai_synthetic_text_to_sql
CREATE TABLE clinical_trials (trial_name TEXT, drug_name TEXT, patient_count INT); INSERT INTO clinical_trials (trial_name, drug_name, patient_count) VALUES ('Trial-A', 'ABC-456', 200), ('Trial-B', 'DEF-789', 300);
How many patients participated in clinical trial 'Trial-A' for drug 'ABC-456'?
SELECT patient_count FROM clinical_trials WHERE trial_name = 'Trial-A' AND drug_name = 'ABC-456';
gretelai_synthetic_text_to_sql
CREATE TABLE Labor_Unions (id INT, union_type VARCHAR(20), region VARCHAR(20)); INSERT INTO Labor_Unions (id, union_type, region) VALUES (1, 'Craft', 'Africa'), (2, 'Professional', 'Americas'), (3, 'Craft', 'Europe'), (4, 'Industrial', 'Asia');
What is the total number of unions in the 'Africa' region with 'Craft' as their union type?
SELECT COUNT(*) FROM Labor_Unions WHERE union_type = 'Craft' AND region = 'Africa';
gretelai_synthetic_text_to_sql
CREATE TABLE countries (id INT, name VARCHAR(255)); CREATE TABLE military_satellites (id INT, country_id INT, number INT);
What is the maximum number of military satellites owned by each country?
SELECT c.name, MAX(ms.number) as max_satellites FROM countries c JOIN military_satellites ms ON c.id = ms.country_id GROUP BY c.id;
gretelai_synthetic_text_to_sql
CREATE TABLE stations (station_id INT, station_name VARCHAR(50), station_type VARCHAR(20)); INSERT INTO stations (station_id, station_name, station_type) VALUES (1, 'StationA', 'Underground'), (2, 'StationB', 'Overground'), (3, 'StationC', 'Underground');
Delete all records from the 'stations' table where the 'station_type' is 'Underground'
DELETE FROM stations WHERE station_type = 'Underground';
gretelai_synthetic_text_to_sql
CREATE TABLE menus (id INT, name VARCHAR(255), category VARCHAR(255), price DECIMAL(5,2)); INSERT INTO menus (id, name, category, price) VALUES (1, 'Veggie Burger', 'Vegan Dishes', 8.99), (2, 'Chickpea Curry', 'Vegan Dishes', 10.99), (3, 'Tofu Stir Fry', 'Vegan Dishes', 12.49);
What is the total revenue for the 'Vegan Dishes' category?
SELECT SUM(price) FROM menus WHERE category = 'Vegan Dishes';
gretelai_synthetic_text_to_sql
CREATE TABLE games (id INT, name VARCHAR(100), genre VARCHAR(50), revenue FLOAT); INSERT INTO games (id, name, genre, revenue) VALUES (1, 'GameA', 'action', 5000000), (2, 'GameB', 'rpg', 7000000), (3, 'GameC', 'action', 8000000);
What is the total revenue for each game in the 'action' genre?
SELECT genre, SUM(revenue) FROM games WHERE genre = 'action' GROUP BY genre;
gretelai_synthetic_text_to_sql
CREATE TABLE Volunteers (id INT, volunteer VARCHAR(50), program VARCHAR(50), hours FLOAT, volunteer_date DATE); INSERT INTO Volunteers (id, volunteer, program, hours, volunteer_date) VALUES (1, 'Alice', 'Education', 10, '2021-01-01'); INSERT INTO Volunteers (id, volunteer, program, hours, volunteer_date) VALUES (2, 'Bob', 'Environment', 15, '2021-02-01');
How many volunteers engaged in each program in Q1 2021?
SELECT program, COUNT(DISTINCT volunteer) as num_volunteers FROM Volunteers WHERE QUARTER(volunteer_date) = 1 AND YEAR(volunteer_date) = 2021 GROUP BY program;
gretelai_synthetic_text_to_sql
CREATE TABLE worker_productivity (worker_id INT, worker_name TEXT, mineral TEXT, productivity DECIMAL); INSERT INTO worker_productivity (worker_id, worker_name, mineral, productivity) VALUES (1, 'John', 'Gold', 5.0), (2, 'Jane', 'Gold', 5.5), (3, 'Bob', 'Silver', 4.8), (4, 'Alice', 'Silver', 5.2), (5, 'Charlie', 'Copper', 4.5), (6, 'David', 'Copper', 4.7);
What is the average productivity of workers per mineral?
SELECT mineral, AVG(productivity) FROM worker_productivity GROUP BY mineral;
gretelai_synthetic_text_to_sql
CREATE TABLE LaborProductivity (Country VARCHAR(255), Year INT, Sector VARCHAR(255), Productivity DECIMAL(5,2)); INSERT INTO LaborProductivity (Country, Year, Sector, Productivity) VALUES ('India', 2020, 'Mining', 40.00), ('India', 2020, 'Mining', 45.00), ('Russia', 2020, 'Mining', 55.00), ('Russia', 2020, 'Mining', 60.00);
What are the labor productivity metrics for mining in India and Russia in 2020?
SELECT Context.Country, Context.Productivity FROM LaborProductivity as Context WHERE Context.Year = 2020 AND Context.Sector = 'Mining' AND Context.Country IN ('India', 'Russia');
gretelai_synthetic_text_to_sql
CREATE TABLE Dams (DamID INT, Name VARCHAR(255), State VARCHAR(255), Company VARCHAR(255), ConstructionYear INT); INSERT INTO Dams VALUES (1, 'Dam A', 'Washington', 'DAMCON', 1985); INSERT INTO Dams VALUES (2, 'Dam B', 'Oregon', 'DAMCO', 1990); INSERT INTO Dams VALUES (3, 'Dam C', 'Washington', 'DAMS Inc.', 1995);
What are the names and locations of all dams in Washington state, along with their respective construction companies and the year they were constructed?
SELECT Name, State, Company, ConstructionYear FROM Dams WHERE State = 'Washington';
gretelai_synthetic_text_to_sql
CREATE TABLE if not exists performing_arts_attendance (id INT, name VARCHAR(255), type VARCHAR(255), attendees INT); INSERT INTO performing_arts_attendance (id, name, type, attendees) VALUES (1, 'Symphony', 'Performing Arts', 250), (2, 'Opera', 'Performing Arts', 180), (3, 'Ballet', 'Performing Arts', 320), (4, 'Theater', 'Performing Arts', 150);
Which performing arts event has the highest average attendance?
SELECT type, AVG(attendees) FROM performing_arts_attendance WHERE type = 'Performing Arts' GROUP BY type ORDER BY AVG(attendees) DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE species (name VARCHAR(255), conservation_priority FLOAT, region VARCHAR(255)); INSERT INTO species (name, conservation_priority, region) VALUES ('Krill', 0.6, 'Southern Ocean'), ('Blue Whale', 0.55, 'Southern Ocean'), ('Orca', 0.5, 'Southern Ocean'), ('Seal', 0.45, 'Southern Ocean'), ('Penguin', 0.4, 'Southern Ocean');
What is the average conservation priority of marine species in the Southern Ocean?
SELECT AVG(conservation_priority) FROM species WHERE region = 'Southern Ocean';
gretelai_synthetic_text_to_sql
CREATE TABLE DonorContributions (donor_id INT, donation_amount DECIMAL(10,2), donation_date DATE, region VARCHAR(50), donor_type VARCHAR(50)); INSERT INTO DonorContributions (donor_id, donation_amount, donation_date, region, donor_type) VALUES (25, 10000, '2022-01-01', 'Central', 'Corporate'), (26, 12000, '2022-02-01', 'Central', 'Corporate'), (27, 8000, '2022-03-01', 'Central', 'Individual');
What was the maximum donation amount from corporate donors in the Central region in 2022?
SELECT MAX(donation_amount) FROM DonorContributions WHERE region = 'Central' AND donation_date BETWEEN '2022-01-01' AND '2022-12-31' AND donor_type = 'Corporate';
gretelai_synthetic_text_to_sql
CREATE TABLE EnvBudget (Year INT, Amount INT); INSERT INTO EnvBudget (Year, Amount) VALUES (2020, 1200000), (2021, 1300000), (2022, 1400000);
What was the total budget allocated for environmental services in 2020, 2021, and 2022?
SELECT Year, SUM(Amount) FROM EnvBudget GROUP BY Year;
gretelai_synthetic_text_to_sql
CREATE TABLE companies (id INT, name TEXT, sector TEXT, ESG_rating FLOAT); INSERT INTO companies (id, name, sector, ESG_rating) VALUES (1, 'Apple', 'Technology', 8.2), (2, 'Microsoft', 'Technology', 8.5), (3, 'Google', 'Technology', 8.3), (4, 'Amazon', 'Technology', 7.9), (5, 'Facebook', 'Technology', 7.7);
What is the distribution of ESG ratings for companies in the technology sector?
SELECT sector, ESG_rating, COUNT(*) AS rating_count FROM companies GROUP BY sector, ESG_rating ORDER BY sector, ESG_rating;
gretelai_synthetic_text_to_sql
CREATE TABLE renewable_energy_projects (id INT, name VARCHAR(255), location VARCHAR(255), capacity FLOAT); INSERT INTO renewable_energy_projects (id, name, location, capacity) VALUES (1, 'SolarFarm1', 'CityA', 1000), (2, 'WindFarm1', 'CityB', 2000), (3, 'SolarFarm2', 'CityA', 1500), (4, 'WindFarm2', 'CityB', 2500), (5, 'HydroPower1', 'CityC', 3000);
Locations with more than 1 renewable energy project
SELECT location, COUNT(*) as num_projects FROM renewable_energy_projects GROUP BY location HAVING COUNT(*) > 1;
gretelai_synthetic_text_to_sql
CREATE TABLE landfill_capacity (province VARCHAR(255), year INT, capacity INT); INSERT INTO landfill_capacity (province, year, capacity) VALUES ('Ontario', 2022, 5000000);
What is the total landfill capacity in the province of Ontario in 2022?
SELECT SUM(capacity) FROM landfill_capacity WHERE province = 'Ontario' AND year = 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE la_evs (id INT, vehicle_type VARCHAR(20), registration_date DATE);
Identify the number of electric vehicles in Los Angeles per day.
SELECT DATE(registration_date) AS registration_day, COUNT(*) FROM la_evs WHERE vehicle_type = 'electric' GROUP BY registration_day;
gretelai_synthetic_text_to_sql
CREATE TABLE donors (donor_id INT, donor_name TEXT, donation_amount DECIMAL, org_id INT); CREATE TABLE volunteers (volunteer_id INT, hours_contributed INT, org_id INT); CREATE TABLE organizations (org_id INT, org_name TEXT);
Show the number of donors, total donation amount, and the average number of hours contributed by volunteers for each organization in the 'organizations' table.
SELECT organizations.org_name, COUNT(donors.donor_id) as num_donors, SUM(donors.donation_amount) as total_donations, AVG(volunteers.hours_contributed) as avg_hours_contributed FROM donors INNER JOIN organizations ON donors.org_id = organizations.org_id INNER JOIN volunteers ON organizations.org_id = volunteers.org_id GROUP BY organizations.org_name;
gretelai_synthetic_text_to_sql
CREATE TABLE wind_farms (id INT, name VARCHAR(100), region VARCHAR(10), capacity FLOAT); INSERT INTO wind_farms (id, name, region, capacity) VALUES (1, 'Wind Farm A', 'West', 150.5); INSERT INTO wind_farms (id, name, region, capacity) VALUES (2, 'Wind Farm B', 'East', 120.3);
Find the total installed capacity (in MW) of Wind Farms in the region 'West'
SELECT SUM(capacity) FROM wind_farms WHERE region = 'West';
gretelai_synthetic_text_to_sql
CREATE TABLE dmo (id INT, name TEXT, region TEXT); CREATE TABLE dmo_markets (id INT, dmo_id INT, destination TEXT); INSERT INTO dmo (id, name, region) VALUES (1, 'Tourism Australia', 'Australia'), (2, 'Japan National Tourism Organization', 'Japan'); INSERT INTO dmo_markets (id, dmo_id, destination) VALUES (1, 1, 'Sydney'), (2, 1, 'Melbourne'), (3, 2, 'Tokyo'), (4, 2, 'Osaka');
How many destinations are marketed by each destination marketing organization?
SELECT dmo.name, COUNT(dmo_markets.destination) FROM dmo INNER JOIN dmo_markets ON dmo.id = dmo_markets.dmo_id GROUP BY dmo.name;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_life (life_id INT, life_name VARCHAR(50), region VARCHAR(50), biomass INT); INSERT INTO marine_life (life_id, life_name, region) VALUES (1, 'Shark', 'Indian Ocean'), (2, 'Tuna', 'Indian Ocean');
What is the total biomass of marine life in the Indian Ocean?
SELECT SUM(biomass) FROM marine_life WHERE region = 'Indian Ocean';
gretelai_synthetic_text_to_sql
CREATE TABLE tv_shows (id INT, title VARCHAR(100), viewership_count INT); INSERT INTO tv_shows (id, title, viewership_count) VALUES (1, 'The Mandalorian', 8000000); INSERT INTO tv_shows (id, title, viewership_count) VALUES (2, 'The Crown', 10000000);
Update the viewership count for TV Show 'The Crown' to 12 million
UPDATE tv_shows SET viewership_count = 12000000 WHERE title = 'The Crown';
gretelai_synthetic_text_to_sql
CREATE TABLE volunteers (volunteer_id INT, volunteer_name VARCHAR(50), volunteer_region VARCHAR(50), volunteer_hours DECIMAL(10,2), volunteer_date DATE);
What is the total number of volunteers from underrepresented communities who engaged in 2022?
SELECT COUNT(*) FROM volunteers WHERE YEAR(volunteer_date) = 2022 AND volunteer_region IN ('Indigenous', 'Latinx', 'Black', 'Asian Pacific Islander', 'LGBTQ+');
gretelai_synthetic_text_to_sql
CREATE TABLE startups(id INT, name TEXT, industry TEXT, founder_gender TEXT, funding FLOAT); INSERT INTO startups(id, name, industry, founder_gender, funding) VALUES (1, 'WomenInAI', 'AI', 'Female', 1000000);
What is the minimum and maximum funding amount for startups founded by women in the AI sector?
SELECT MIN(funding), MAX(funding) FROM startups WHERE industry = 'AI' AND founder_gender = 'Female';
gretelai_synthetic_text_to_sql
CREATE SCHEMA IF NOT EXISTS Cybersecurity; CREATE TABLE IF NOT EXISTS Cybersecurity.Cyber_Strategies (strategy_id INT, strategy_name VARCHAR(255), description TEXT); INSERT INTO Cybersecurity.Cyber_Strategies (strategy_id, strategy_name, description) VALUES (1, 'NIST Cybersecurity Framework', 'Provides guidelines for managing cybersecurity risks'), (2, 'CIS Critical Security Controls', 'Set of 20 actions to stop the most common cyber attacks'), (3, 'ISO 27001/27002', 'Information security management system standard');
List all the cybersecurity strategies related to 'Risk Management' in the 'Cybersecurity' schema.
SELECT * FROM Cybersecurity.Cyber_Strategies WHERE description LIKE '%Risk Management%';
gretelai_synthetic_text_to_sql
CREATE TABLE garment_releases (id INT, garment_type VARCHAR(255), region VARCHAR(255), release_date DATE); INSERT INTO garment_releases (id, garment_type, region, release_date) VALUES (1, 'Ankara Dress', 'Africa', '2022-01-01'), (2, 'Kente Cloth Pants', 'Africa', '2022-02-01'), (3, 'Dashiki Shirt', 'Africa', '2022-03-01');
How many new garment types have been introduced in the African market in the last 6 months?
SELECT COUNT(*) as num_new_garment_types FROM garment_releases WHERE region = 'Africa' AND release_date >= DATEADD(month, -6, CURRENT_TIMESTAMP);
gretelai_synthetic_text_to_sql
CREATE TABLE vehicles (vehicle_id INT, vehicle_type VARCHAR(50)); INSERT INTO vehicles (vehicle_id, vehicle_type) VALUES (1000, 'Bus'), (1001, 'Tram'), (1002, 'Bus'), (1003, 'Tram'), (1004, 'Trolleybus');
Show the number of unique vehicle types in the vehicles table, ordered from highest to lowest
SELECT COUNT(DISTINCT vehicle_type) FROM vehicles GROUP BY vehicle_type ORDER BY COUNT(DISTINCT vehicle_type) DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE Vessels (Id INT, Name VARCHAR(50), FuelType VARCHAR(20)); INSERT INTO Vessels (Id, Name, FuelType) VALUES (1, 'Vessel1', 'Diesel'), (2, 'Vessel2', 'LNG'), (3, 'Vessel3', 'Diesel'), (4, 'Vessel4', 'Hydrogen');
Count the number of vessels for each fuel type in the fleet
SELECT FuelType, COUNT(*) FROM Vessels GROUP BY FuelType;
gretelai_synthetic_text_to_sql
CREATE TABLE oil_platforms (platform_id INT PRIMARY KEY, platform_name VARCHAR(255), water_depth_ft INT, operational_status VARCHAR(50));
Delete all records from the 'oil_platforms' table where the water_depth_ft is greater than 4000
DELETE FROM oil_platforms WHERE water_depth_ft > 4000;
gretelai_synthetic_text_to_sql
CREATE TABLE Policyholder (PolicyholderID INT, State VARCHAR(255), PolicyType VARCHAR(255), ClaimAmount DECIMAL(10,2)); INSERT INTO Policyholder VALUES (1, 'QC', 'Home', 5000), (2, 'NY', 'Home', 7000), (3, 'NJ', 'Auto', 8000), (4, 'CA', 'Life', 6000), (5, 'QC', 'Life', 9000);
Calculate the average claim amount for policyholders from Quebec who have a home or life insurance policy, and order the results by the average claim amount in ascending order.
SELECT PolicyType, AVG(ClaimAmount) as AvgClaimAmount FROM Policyholder WHERE State = 'QC' AND PolicyType IN ('Home', 'Life') GROUP BY PolicyType ORDER BY AvgClaimAmount ASC;
gretelai_synthetic_text_to_sql
CREATE TABLE mental_health_providers (id INT, state VARCHAR(20), rural BOOLEAN, population INT, providers INT); INSERT INTO mental_health_providers (id, state, rural, population, providers) VALUES (1, 'California', true, 1000000, 800), (2, 'California', false, 2000000, 1500), (3, 'Oregon', true, 500000, 400);
Number of mental health providers per 100,000 people in rural California?
SELECT (providers * 100000.0 / population) FROM mental_health_providers WHERE state = 'California' AND rural = true;
gretelai_synthetic_text_to_sql
CREATE TABLE Warehouses (id INT, name VARCHAR(50)); INSERT INTO Warehouses (id, name) VALUES (1, 'Seattle'), (2, 'Toronto'), (3, 'Mexico City'); CREATE TABLE Shipments (id INT, warehouse_id INT, pallets INT, shipment_date DATE); INSERT INTO Shipments (id, warehouse_id, pallets, shipment_date) VALUES (1, 1, 50, '2022-01-01'), (2, 1, 75, '2022-01-15'), (3, 2, 100, '2022-02-01');
How many pallets were shipped from each warehouse in the first quarter of 2022?
SELECT Warehouses.name, SUM(Shipments.pallets) AS total_pallets FROM Warehouses INNER JOIN Shipments ON Warehouses.id = Shipments.warehouse_id WHERE Shipments.shipment_date >= '2022-01-01' AND Shipments.shipment_date < '2022-04-01' GROUP BY Warehouses.name;
gretelai_synthetic_text_to_sql
CREATE TABLE animal_rescue_data (organization VARCHAR(255), year INT, animals_rescued INT);
What is the total number of animals rescued by each organization in the last 3 years?
SELECT organization, SUM(animals_rescued) FROM animal_rescue_data WHERE year BETWEEN 2020 AND 2022 GROUP BY organization;
gretelai_synthetic_text_to_sql
CREATE TABLE gene_sequencing_costs (id INT, lab_name TEXT, country TEXT, cost FLOAT); INSERT INTO gene_sequencing_costs (id, lab_name, country, cost) VALUES (1, 'Lab1', 'Germany', 55000.0), (2, 'Lab2', 'Germany', 60000.0), (3, 'Lab3', 'France', 45000.0);
Identify top 2 most expensive gene sequencing costs in Germany.
SELECT lab_name, cost FROM (SELECT lab_name, cost, RANK() OVER (ORDER BY cost DESC) as rank FROM gene_sequencing_costs WHERE country = 'Germany') sub WHERE rank <= 2;
gretelai_synthetic_text_to_sql
CREATE TABLE Cases (ID INT, CaseNumber INT, DateOpened DATE, DateClosed DATE, Resolution VARCHAR(255)); INSERT INTO Cases (ID, CaseNumber, DateOpened, DateClosed, Resolution) VALUES (1, 12345, '2022-01-01', '2022-03-15', 'Restorative Justice'), (2, 67890, '2022-02-15', '2022-04-30', 'Trial'), (3, 111213, '2022-03-28', NULL, 'Mediation');
What is the median time to resolve cases using restorative justice methods?
SELECT AVG(DATEDIFF(DateClosed, DateOpened)) as MedianTimeToResolve FROM Cases WHERE Resolution = 'Restorative Justice' AND DateClosed IS NOT NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE Inventory (item_id INT, item_name VARCHAR(50), quantity INT, warehouse_id INT);
Show the number of records in the Inventory table where the warehouse_id is 101
SELECT COUNT(*) FROM Inventory WHERE warehouse_id = 101;
gretelai_synthetic_text_to_sql
CREATE TABLE weather_data (measurement_id INT, measurement_date DATE, temperature FLOAT, location VARCHAR(50));
What is the average temperature change in the Arctic Circle for each year, including the total number of measurements taken?
SELECT AVG(temperature) AS avg_temperature_change, YEAR(measurement_date) AS year, COUNT(*) AS total_measurements FROM weather_data WHERE location LIKE '%Arctic Circle%' GROUP BY year;
gretelai_synthetic_text_to_sql
CREATE TABLE defense_contracts (cont_id INT, cont_name VARCHAR(50), proj_id INT, cont_status VARCHAR(50), cont_end_date DATE); INSERT INTO defense_contracts (cont_id, cont_name, proj_id, cont_status, cont_end_date) VALUES (1, 'Army Modernization', 1, 'Expired', '2022-01-01');
Delete defense contracts for 'Brazil' with status 'Expired'
DELETE FROM defense_contracts WHERE cont_status = 'Expired' AND region = 'Brazil';
gretelai_synthetic_text_to_sql
CREATE TABLE Turtles (Species VARCHAR(255), Ocean VARCHAR(255), Population INT);
Insert a new record into the Turtles table for the Leatherback Turtle, with the ocean being the Atlantic Ocean and a population of 45000.
INSERT INTO Turtles (Species, Ocean, Population) VALUES ('Leatherback Turtle', 'Atlantic Ocean', 45000);
gretelai_synthetic_text_to_sql
CREATE TABLE Visitors (id INT, country VARCHAR(50), exhibition_id INT); CREATE TABLE Exhibitions (id INT, name VARCHAR(50)); INSERT INTO Exhibitions (id, name) VALUES (1, 'Digital Art'); ALTER TABLE Visitors ADD FOREIGN KEY (exhibition_id) REFERENCES Exhibitions(id);
What is the total number of visitors who attended the 'Digital Art' exhibition and are from the USA?
SELECT COUNT(*) FROM Visitors WHERE exhibition_id = 1 AND country = 'USA';
gretelai_synthetic_text_to_sql
CREATE TABLE Digital_Divide (area VARCHAR(50), region VARCHAR(50), index INT); INSERT INTO Digital_Divide (area, region, index) VALUES ('Rural', 'Africa', 70), ('Urban', 'Africa', 50), ('Rural', 'Asia', 60), ('Urban', 'Asia', 40), ('Rural', 'South America', 50), ('Urban', 'South America', 30), ('Rural', 'Europe', 40), ('Urban', 'Europe', 20), ('Rural', 'North America', 30), ('Urban', 'North America', 10);
What is the average digital divide index for rural and urban areas?
SELECT area, AVG(index) as avg_index FROM Digital_Divide GROUP BY area;
gretelai_synthetic_text_to_sql
CREATE TABLE FoodTrends (product_id INT, product_name VARCHAR(255), category VARCHAR(100), popularity_score INT); INSERT INTO FoodTrends (product_id, product_name, category, popularity_score) VALUES (1, 'Quinoa Salad', 'Organic', 85), (2, 'Chia Seeds', 'Vegan', 90), (3, 'Grass-Fed Beef', 'Sustainable', 75);
What is the maximum popularity score for each category in the food trends table?
SELECT category, MAX(popularity_score) FROM FoodTrends GROUP BY category;
gretelai_synthetic_text_to_sql
CREATE TABLE Hotels (hotel_id INT, hotel_name TEXT, country TEXT, eco_friendly BOOLEAN, max_guests INT); INSERT INTO Hotels (hotel_id, hotel_name, country, eco_friendly, max_guests) VALUES (1, 'Eco-Friendly Hotel Delhi', 'India', true, 150); INSERT INTO Hotels (hotel_id, hotel_name, country, eco_friendly, max_guests) VALUES (2, 'Green Hotel Mumbai', 'India', true, 120); INSERT INTO Hotels (hotel_id, hotel_name, country, eco_friendly, max_guests) VALUES (3, 'Regular Hotel Bangalore', 'India', false, 200);
What is the maximum number of guests that can be accommodated in eco-friendly hotels in India?
SELECT MAX(max_guests) FROM Hotels WHERE country = 'India' AND eco_friendly = true;
gretelai_synthetic_text_to_sql
CREATE TABLE Suppliers (SupplierID INT, SupplierName VARCHAR(50), Location VARCHAR(50)); INSERT INTO Suppliers (SupplierID, SupplierName, Location) VALUES (1, 'Supplier A', 'Northeast'), (2, 'Supplier B', 'Midwest'), (3, 'Supplier C', 'Southwest'); CREATE TABLE Products (ProductID INT, ProductName VARCHAR(50), SupplierID INT, Category VARCHAR(50)); INSERT INTO Products (ProductID, ProductName, SupplierID, Category) VALUES (1, 'Beef', 1, 'Meat'), (2, 'Chicken', 1, 'Meat'), (3, 'Apples', 2, 'Fruits'), (4, 'Oranges', 2, 'Fruits'), (5, 'Tofu', 3, 'Vegetables'), (6, 'Carrots', 3, 'Vegetables'); CREATE TABLE Sales (SaleID INT, ProductID INT, Quantity INT); INSERT INTO Sales (SaleID, ProductID, Quantity) VALUES (1, 1, 10), (2, 2, 15), (3, 3, 20), (4, 4, 25), (5, 5, 30), (6, 6, 35);
What is the total quantity of fruits sold in the Midwest region?
SELECT SUM(Quantity) FROM Sales JOIN Products ON Sales.ProductID = Products.ProductID JOIN Suppliers ON Products.SupplierID = Suppliers.SupplierID WHERE Category = 'Fruits' AND Suppliers.Location = 'Midwest';
gretelai_synthetic_text_to_sql
CREATE TABLE donations (id INT, donor_id INT, donation_amount DECIMAL, donation_date DATE);
What's the average donation amount per donor in H1 2021?
SELECT AVG(donation_amount) FROM (SELECT donation_amount, donor_id FROM donations WHERE donation_date >= '2021-01-01' AND donation_date < '2021-07-01' GROUP BY donor_id) AS donations_per_donor;
gretelai_synthetic_text_to_sql
CREATE TABLE financial_wellbeing (id INT, household_id INT, region VARCHAR(255), score FLOAT);
What is the average financial wellbeing score for low-income households in Southeast Asia?
SELECT AVG(score) FROM financial_wellbeing WHERE household_id <= 30000 AND region = 'Southeast Asia';
gretelai_synthetic_text_to_sql
CREATE TABLE accommodations (id INT, student_id INT, type TEXT, cost INT, date DATE); INSERT INTO accommodations (id, student_id, type, cost, date) VALUES (1, 1, 'extended time', 200, '2022-01-01'); INSERT INTO accommodations (id, student_id, type, cost, date) VALUES (2, 2, 'note taker', 500, '2022-02-01');
What is the average number of accommodations provided to students with learning disabilities per month in the past year?
SELECT AVG(COUNT(*)) FROM accommodations WHERE student_id IN (SELECT id FROM students WHERE disability = 'learning disability') AND date >= DATE_SUB(NOW(), INTERVAL 1 YEAR) GROUP BY MONTH(date);
gretelai_synthetic_text_to_sql
CREATE TABLE SupportProgramsForHearingImpaired (ProgramID INT, ProviderName VARCHAR(50), DisabilityType VARCHAR(50));
What is the average number of support programs provided to students with hearing impairments per provider?
SELECT ProviderName, AVG(ProgramCount) FROM (SELECT ProviderName, COUNT(ProgramID) as ProgramCount FROM SupportProgramsForHearingImpaired WHERE DisabilityType = 'hearing impairment' GROUP BY ProviderName) as subquery GROUP BY ProviderName;
gretelai_synthetic_text_to_sql
CREATE TABLE workers (id INT, name TEXT, union_id INT, union_member BOOLEAN); INSERT INTO workers (id, name, union_id, union_member) VALUES (1, 'John Doe', 1, true), (2, 'Jane Smith', 1, false); CREATE TABLE unions (id INT, name TEXT, member_count INT); INSERT INTO unions (id, name, member_count) VALUES (1, 'Union A', 50);
What is the total number of workers represented by each union, including workers who are not union members?
SELECT u.name, COALESCE(SUM(w.union_member), 0) FROM unions u LEFT JOIN workers w ON u.id = w.union_id GROUP BY u.name;
gretelai_synthetic_text_to_sql
CREATE TABLE city_certifications (city VARCHAR(20), certifications INT); INSERT INTO city_certifications (city, certifications) VALUES ('New York', 500), ('Los Angeles', 300), ('Chicago', 400);
Show the top 3 cities with the most green building certifications.
SELECT city, certifications FROM (SELECT city, certifications, RANK() OVER (ORDER BY certifications DESC) as rank FROM city_certifications) AS subquery WHERE rank <= 3;
gretelai_synthetic_text_to_sql
CREATE TABLE patients (patient_id INT, patient_name VARCHAR(50), condition VARCHAR(50), country VARCHAR(50), hospitalization_date DATE, discharge_date DATE); INSERT INTO patients (patient_id, patient_name, condition, country, hospitalization_date, discharge_date) VALUES (1, 'Jean Dupont', 'Depression', 'France', '2021-02-01', '2021-02-14');
Find the average number of weeks patients with depression are hospitalized in France.
SELECT AVG(DATEDIFF(day, patients.hospitalization_date, patients.discharge_date)/7.0) FROM patients WHERE patients.condition = 'Depression' AND patients.country = 'France';
gretelai_synthetic_text_to_sql
CREATE TABLE forests (id INT, name VARCHAR(255)); INSERT INTO forests (id, name) VALUES (1, 'Forest A'), (2, 'Forest B'); CREATE TABLE trees (id INT, forest_id INT, age INT); INSERT INTO trees (id, forest_id, age) VALUES (1, 1, 60), (2, 1, 45), (3, 2, 55), (4, 2, 30);
Find the number of trees in each forest that are older than 50 years.
SELECT f.name, COUNT(t.id) FROM forests f JOIN trees t ON f.id = t.forest_id WHERE t.age > 50 GROUP BY f.name;
gretelai_synthetic_text_to_sql
CREATE TABLE community_health_workers (id INT PRIMARY KEY, name VARCHAR(255), region VARCHAR(255), years_experience INT, cultural_competency_score INT); INSERT INTO community_health_workers (id, name, region, years_experience, cultural_competency_score) VALUES (1, 'Ada Williams', 'Southeast', 8, 95), (2, 'Brian Johnson', 'Midwest', 5, 80), (3, 'Carla Garcia', 'West', 12, 90); INSERT INTO community_health_workers (id, name, region, years_experience, cultural_competency_score) VALUES (4, 'Ella Jones', 'Northeast', 6, 85), (5, 'Farhad Ahmed', 'South', 10, 93), (6, 'Graciela Gutierrez', 'Central', 11, 94);
Insert records into the table 'community_health_workers'
INSERT INTO community_health_workers (id, name, region, years_experience, cultural_competency_score) VALUES (7, 'Hee Jeong Lee', 'Northwest', 7, 87), (8, 'Ibrahim Hussein', 'East', 9, 96), (9, 'Jasmine Patel', 'Southwest', 8, 91);
gretelai_synthetic_text_to_sql
CREATE TABLE marine_protected_areas_atlantic_ocean (area_name VARCHAR(255), min_depth DECIMAL(10,2), max_depth DECIMAL(10,2)); INSERT INTO marine_protected_areas_atlantic_ocean (area_name, min_depth, max_depth) VALUES ('Azores Nature Park', 10.25, 50.65), ('Bermuda Park', 50.65, 100.20), ('Galapagos Marine Reserve', 15.00, 300.00);
What is the minimum and maximum depth of all marine protected areas in the Atlantic Ocean?
SELECT MIN(min_depth) AS min_depth, MAX(max_depth) AS max_depth FROM marine_protected_areas_atlantic_ocean;
gretelai_synthetic_text_to_sql
CREATE TABLE CityEnergy (City VARCHAR(50), EnergyCapacity FLOAT, Renewable BOOLEAN); INSERT INTO CityEnergy (City, EnergyCapacity, Renewable) VALUES ('CityA', 5000, TRUE), ('CityB', 3000, FALSE), ('CityC', 7000, TRUE);
What is the renewable energy capacity for each city, ordered from the highest to the lowest?
SELECT City, EnergyCapacity FROM CityEnergy WHERE Renewable = TRUE ORDER BY EnergyCapacity DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE users (id INT, name VARCHAR(50), country VARCHAR(50)); INSERT INTO users (id, name, country) VALUES (1, 'John Doe', 'USA'), (2, 'Jane Smith', 'India'); CREATE TABLE posts (id INT, user_id INT, timestamp DATETIME); INSERT INTO posts (id, user_id, timestamp) VALUES (1, 1, '2022-01-01 12:00:00'), (2, 1, '2022-01-02 14:00:00'), (3, 2, '2022-01-03 10:00:00'), (4, 2, '2022-01-04 16:00:00'), (5, 2, '2022-01-05 18:00:00'); CREATE TABLE engagements (id INT, post_id INT, user_id INT, timestamp DATETIME); INSERT INTO engagements (id, post_id, user_id, timestamp) VALUES (1, 1, 2, '2022-01-01 13:00:00'), (2, 2, 1, '2022-01-02 15:00:00'), (3, 3, 2, '2022-01-04 11:00:00'), (4, 4, 1, '2022-01-05 19:00:00'), (5, 5, 2, '2022-01-06 13:00:00');
How many users have engaged with posts from users in India in the last week?
SELECT COUNT(DISTINCT engagements.user_id) FROM engagements INNER JOIN posts ON engagements.post_id = posts.id INNER JOIN users AS post_users ON posts.user_id = post_users.id INNER JOIN users AS engagement_users ON engagements.user_id = engagement_users.id WHERE post_users.country = 'India' AND engagements.timestamp >= DATE_SUB(NOW(), INTERVAL 1 WEEK);
gretelai_synthetic_text_to_sql
CREATE TABLE carbon_sequestration (year INT, region VARCHAR(255), sequestration FLOAT); INSERT INTO carbon_sequestration (year, region, sequestration) VALUES (2020, 'Region A', 1300.0), (2020, 'Region B', 1400.0), (2020, 'Region C', 1200.0);
Identify the regions with highest carbon sequestration in 2020.
SELECT region FROM carbon_sequestration WHERE sequestration = (SELECT MAX(sequestration) FROM carbon_sequestration WHERE year = 2020);
gretelai_synthetic_text_to_sql
CREATE TABLE Satellites (satellite_id INT, name VARCHAR(255), country VARCHAR(255), altitude FLOAT, constellation VARCHAR(255)); INSERT INTO Satellites (satellite_id, name, country, altitude, constellation) VALUES (1, 'Tianwen-1', 'China', 377.5, 'Mars Exploration'), (2, 'Beidou-3', 'China', 35786, 'Navigation'), (3, 'Fengyun-3', 'China', 836, 'Weather');
What is the maximum altitude of Chinese satellites?
SELECT MAX(altitude) FROM Satellites WHERE country = 'China';
gretelai_synthetic_text_to_sql
CREATE TABLE Inventory (id INT, product_id INT, size VARCHAR(10), quantity INT); INSERT INTO Inventory (id, product_id, size, quantity) VALUES (1, 1, '2XL', 25), (2, 2, 'XS', 50);
What is the total quantity of unsold size 2XL clothing in the warehouse?
SELECT SUM(quantity) FROM Inventory WHERE size = '2XL' AND quantity > 0;
gretelai_synthetic_text_to_sql
CREATE TABLE Collections_Period (city VARCHAR(20), period VARCHAR(20), pieces INT); INSERT INTO Collections_Period (city, period, pieces) VALUES ('Amsterdam', 'Renaissance', 500), ('Amsterdam', 'Baroque', 300), ('Amsterdam', 'Modern', 200), ('Paris', 'Renaissance', 700);
What is the distribution of art collections by period in Amsterdam?
SELECT period, COUNT(*) FROM Collections_Period WHERE city = 'Amsterdam' GROUP BY period;
gretelai_synthetic_text_to_sql