context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE journalist_arrests (id INT, journalist VARCHAR(255), location VARCHAR(255), date DATE); INSERT INTO journalist_arrests (id, journalist, location, date) VALUES (1, 'Journalist 1', 'Africa', '2023-01-01'), (2, 'Journalist 2', 'Africa', '2023-02-01');
How many journalists were arrested in Africa in the last 6 months?
SELECT COUNT(*) FROM journalist_arrests WHERE location = 'Africa' AND date >= DATEADD(month, -6, GETDATE());
gretelai_synthetic_text_to_sql
CREATE TABLE tv_shows (id INT, title VARCHAR(255), rating FLOAT, release_year INT, country VARCHAR(50), genre VARCHAR(50)); INSERT INTO tv_shows (id, title, rating, release_year, country, genre) VALUES (1, 'Show1', 7.5, 2010, 'India', 'Comedy'), (2, 'Show2', 8.2, 2012, 'India', 'Drama'), (3, 'Show3', 6.8, 2015, 'India', 'Action');
What is the average rating of the TV shows produced in India and released between 2010 and 2015, categorized by genre?
SELECT genre, AVG(rating) FROM tv_shows WHERE release_year BETWEEN 2010 AND 2015 AND country = 'India' GROUP BY genre;
gretelai_synthetic_text_to_sql
CREATE TABLE workforce_training (id INT PRIMARY KEY, employee_name VARCHAR(255), training_topic VARCHAR(255), training_hours INT, training_completion_date DATE);
Alter the workforce_training table to add a column for employee ID in the national identification format
ALTER TABLE workforce_training ADD COLUMN national_id VARCHAR(50);
gretelai_synthetic_text_to_sql
CREATE TABLE jeans_production(garment VARCHAR(20), region VARCHAR(20), production_time INT); INSERT INTO jeans_production VALUES('Jeans', 'Europe', 18);
What is the 'Production Time' for 'Jeans' in 'Europe'?
SELECT production_time FROM jeans_production WHERE garment = 'Jeans' AND region = 'Europe';
gretelai_synthetic_text_to_sql
CREATE TABLE if NOT EXISTS tours (id INT, name TEXT, rating FLOAT, wheelchair_accessible BOOLEAN, vegetarian_meal BOOLEAN); INSERT INTO tours (id, name, rating, wheelchair_accessible, vegetarian_meal) VALUES (1, 'Mountain Biking Adventure', 4.5, false, true), (2, 'Historic City Tour', 4.2, true, false), (3, 'Cultural Exploration', 4.8, true, true);
What is the average rating of tours in Europe that are both wheelchair accessible and offer vegetarian meals?
SELECT AVG(rating) FROM tours WHERE wheelchair_accessible = true AND vegetarian_meal = true AND country = 'Europe';
gretelai_synthetic_text_to_sql
CREATE TABLE permit_costs (permit_id INT, permit_type TEXT, state TEXT, cost INT, sqft INT); INSERT INTO permit_costs (permit_id, permit_type, state, cost, sqft) VALUES (1, 'Residential', 'New York', 80000, 2500), (2, 'Commercial', 'New York', 300000, 7500);
What is the average permit cost per square foot for each permit type in the state of New York?
SELECT permit_type, AVG(cost/sqft) FROM permit_costs WHERE state = 'New York' GROUP BY permit_type;
gretelai_synthetic_text_to_sql
CREATE TABLE genres (genre VARCHAR(10), song_id INT, song_length FLOAT); INSERT INTO genres (genre, song_id, song_length) VALUES ('hiphop', 7, 202.5), ('hiphop', 8, 245.8), ('hiphop', 9, 198.1);
What is the maximum song_length in the hiphop genre?
SELECT MAX(song_length) FROM genres WHERE genre = 'hiphop';
gretelai_synthetic_text_to_sql
CREATE TABLE game_sessions (session_id INT, player_id INT, session_start_time TIMESTAMP, session_duration INTERVAL);
Delete sessions with session_duration less than 1 hour
DELETE FROM game_sessions WHERE session_duration < '01:00:00';
gretelai_synthetic_text_to_sql
CREATE TABLE marine_species (name varchar(255), region varchar(255), observations int); INSERT INTO marine_species (name, region, observations) VALUES ('Blue Whale', 'Pacific', 3000), ('Hammerhead Shark', 'Pacific', 1500), ('Sea Otter', 'Pacific', 2000);
What is the total number of marine species observed in the Pacific region?
SELECT SUM(observations) FROM marine_species WHERE region = 'Pacific';
gretelai_synthetic_text_to_sql
CREATE TABLE departments (department_id INT, department_name TEXT); CREATE TABLE teachers (teacher_id INT, teacher_name TEXT, department_id INT, community_representation TEXT); CREATE TABLE sessions (session_id INT, teacher_id INT, session_date DATE, support_type TEXT); INSERT INTO departments VALUES (1, 'Mathematics'), (2, 'Science'), (3, 'English'); INSERT INTO teachers VALUES (1, 'Ms. Acevedo', 1, 'underrepresented'), (2, 'Mr. Chen', 2, 'mainstream'), (3, 'Mx. Patel', 3, 'underrepresented'); INSERT INTO sessions VALUES (1, 1, '2022-02-01', 'mental health'), (2, 2, '2022-02-02', 'academic'), (3, 3, '2022-02-03', 'mental health');
How many mental health support sessions were conducted by teachers from underrepresented communities in each department?
SELECT d.department_name, COUNT(s.session_id) FROM departments d INNER JOIN teachers t ON d.department_id = t.department_id INNER JOIN sessions s ON t.teacher_id = s.teacher_id WHERE t.community_representation = 'underrepresented' AND s.support_type = 'mental health' GROUP BY d.department_id;
gretelai_synthetic_text_to_sql
CREATE TABLE deep_sea_fish (species VARCHAR(255), ocean VARCHAR(255), max_depth INT); INSERT INTO deep_sea_fish (species, ocean, max_depth) VALUES ('Anglerfish', 'Indian Ocean', 3000);
List the species and maximum depth for deep-sea fish found in the Indian Ocean.
SELECT species, max_depth FROM deep_sea_fish WHERE ocean = 'Indian Ocean'
gretelai_synthetic_text_to_sql
CREATE TABLE CropYield (region VARCHAR(255), farming_method VARCHAR(255), yield INT); INSERT INTO CropYield (region, farming_method, yield) VALUES ('India', 'Organic', 100), ('India', 'Non-Organic', 120), ('China', 'Organic', 110), ('China', 'Non-Organic', 130);
What is the difference in crop yield between organic and non-organic farming methods in India?
SELECT farming_method, AVG(yield) FROM CropYield WHERE region = 'India' GROUP BY farming_method;
gretelai_synthetic_text_to_sql
CREATE TABLE funding_data (company_name VARCHAR(100), funding_year INT, funding_amount INT);
List the names of all startups that have received funding in the last 3 years
SELECT company_name FROM funding_data WHERE funding_year >= (YEAR(CURRENT_DATE) - 3);
gretelai_synthetic_text_to_sql
CREATE SCHEMA if not exists startup_funding;CREATE TABLE if not exists startup_funding.data (id INT, startup VARCHAR(50), country VARCHAR(50), funding DECIMAL(10, 2)); INSERT INTO startup_funding.data (id, startup, country, funding) VALUES (1, 'StartupA', 'USA', 1500000.00), (2, 'StartupB', 'USA', 2000000.00), (3, 'StartupC', 'Canada', 1000000.00), (4, 'StartupD', 'Canada', 1250000.00), (5, 'StartupE', 'Mexico', 750000.00);
Calculate the average funding for biotech startups in the USA and Canada.
SELECT country, AVG(funding) FROM startup_funding.data WHERE country IN ('USA', 'Canada') GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE workout_minutes (user_id INT, age INT, workout_minutes INT); INSERT INTO workout_minutes (user_id, age, workout_minutes) VALUES (1, 32, 120), (2, 28, 150), (3, 35, 180), (4, 31, 240);
What is the total number of minutes spent working out by users in their 30s?
SELECT SUM(workout_minutes) FROM workout_minutes WHERE age BETWEEN 30 AND 39;
gretelai_synthetic_text_to_sql
CREATE TABLE TrafficViolations (id INT, violation_type VARCHAR(50), location VARCHAR(50), fine DECIMAL(5,2)); INSERT INTO TrafficViolations (id, violation_type, location, fine) VALUES (1, 'Speeding', 'School Zone', 100), (2, 'Illegal Parking', 'Business District', 50), (3, 'Speeding', 'Residential Area', 30), (4, 'Running Red Light', 'School Zone', 150), (5, 'Speeding', 'School Zone', 200);
What is the maximum number of traffic violations in the "TrafficViolations" table, per type of violation, for violations that occurred in school zones?
SELECT violation_type, COUNT(*) as num_violations FROM TrafficViolations WHERE location LIKE '%School%' GROUP BY violation_type;
gretelai_synthetic_text_to_sql
CREATE TABLE Company (id INT, name VARCHAR(50)); INSERT INTO Company (id, name) VALUES (1, 'Acme Inc'); INSERT INTO Company (id, name) VALUES (2, 'Beta Corp'); INSERT INTO Company (id, name) VALUES (3, 'Gamma Startup'); CREATE TABLE Funding (company_id INT, funding_amount INT, funding_date DATE); INSERT INTO Funding (company_id, funding_amount, funding_date) VALUES (1, 5000000, '2012-01-01'); INSERT INTO Funding (company_id, funding_amount, funding_date) VALUES (1, 10000000, '2016-01-01'); INSERT INTO Funding (company_id, funding_amount, funding_date) VALUES (2, 2000000, '2016-05-10'); INSERT INTO Funding (company_id, funding_amount, funding_date) VALUES (3, 8000000, '2019-04-20');
What is the average funding amount per company, and the company with the highest average funding?
SELECT c.name, AVG(f.funding_amount) as avg_funding, RANK() OVER (ORDER BY AVG(f.funding_amount) DESC) as rank FROM Company c JOIN Funding f ON c.id = f.company_id GROUP BY c.name;
gretelai_synthetic_text_to_sql
CREATE TABLE assets (id INT, country VARCHAR(50), value DECIMAL(10,2)); INSERT INTO assets (id, country, value) VALUES (1, 'USA', 1000000.00), (2, 'Canada', 500000.00), (3, 'Mexico', 300000.00);
What is the total value of assets held by the bank in each country?
SELECT country, SUM(value) FROM assets GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE military_vehicles (id INT, name VARCHAR(255), country_code VARCHAR(3), vehicle_type VARCHAR(255)); CREATE TABLE countries (code VARCHAR(3), name VARCHAR(255)); INSERT INTO military_vehicles (id, name, country_code, vehicle_type) VALUES (1, 'Vehicle A', 'USA', 'Tank'), (2, 'Vehicle B', 'RUS', 'Aircraft'), (3, 'Vehicle C', 'CHN', 'Ship'); INSERT INTO countries (code, name) VALUES ('USA', 'United States of America'), ('RUS', 'Russian Federation'), ('CHN', 'People''s Republic of China');
What is the total number of military vehicles and their corresponding types, along with the country responsible for manufacturing them?
SELECT COUNT(id) as total_vehicles, v.vehicle_type, c.name as country_name FROM military_vehicles v JOIN countries c ON v.country_code = c.code GROUP BY v.vehicle_type, c.name;
gretelai_synthetic_text_to_sql
CREATE TABLE erbium_mines (mine VARCHAR(50), country VARCHAR(50), capacity INT);
What is the maximum production capacity of Erbium mines in Australia?
SELECT MAX(capacity) FROM erbium_mines WHERE country = 'Australia';
gretelai_synthetic_text_to_sql
CREATE TABLE factories (factory_id INT, factory_name VARCHAR(20)); INSERT INTO factories VALUES (1, 'Factory A'), (2, 'Factory B'), (3, 'Factory C'); CREATE TABLE workers (worker_id INT, factory_id INT, salary DECIMAL(5,2)); INSERT INTO workers VALUES (1, 1, 35000.00), (2, 1, 36000.00), (3, 2, 45000.00), (4, 3, 34000.00);
What is the total salary paid by each factory?
SELECT f.factory_name, SUM(salary) FROM workers w INNER JOIN factories f ON w.factory_id = f.factory_id GROUP BY f.factory_name;
gretelai_synthetic_text_to_sql
CREATE TABLE HarvestData (id INT, region VARCHAR(255), crop_type VARCHAR(255), harvest_date DATE);
List the number of times each crop type was harvested in the 'Western' region in 2021.
SELECT region, crop_type, COUNT(DISTINCT harvest_date) FROM HarvestData WHERE region = 'Western' AND YEAR(harvest_date) = 2021 GROUP BY region, crop_type;
gretelai_synthetic_text_to_sql
CREATE TABLE Country (id INT, country VARCHAR(255)); CREATE TABLE Artist (id INT, country_id INT, name VARCHAR(255)); CREATE TABLE Album (id INT, artist_id INT, year INT);
How many artists from each country released an album in 2020?
SELECT C.country, COUNT(DISTINCT A.artist_id) as album_count FROM Country C INNER JOIN Artist A ON C.id = A.country_id INNER JOIN Album AL ON A.id = AL.artist_id WHERE AL.year = 2020 GROUP BY C.country;
gretelai_synthetic_text_to_sql
CREATE TABLE Biomass (species VARCHAR(255), ocean VARCHAR(255), biomass FLOAT); INSERT INTO Biomass (species, ocean, biomass) VALUES ('Krill', 'Arctic Ocean', 2.1); INSERT INTO Biomass (species, ocean, biomass) VALUES ('Krill', 'Arctic Ocean', 1.9);
What is the total biomass of krill in the Arctic Ocean?
SELECT SUM(biomass) FROM Biomass WHERE species = 'Krill' AND ocean = 'Arctic Ocean';
gretelai_synthetic_text_to_sql
CREATE TABLE Policyholders (PolicyholderID INT, Name VARCHAR(50), Age INT, Gender VARCHAR(10), State VARCHAR(2)); INSERT INTO Policyholders (PolicyholderID, Name, Age, Gender, State) VALUES (1, 'Aisha Brown', 68, 'Female', 'NY'); INSERT INTO Policyholders (PolicyholderID, Name, Age, Gender, State) VALUES (2, 'Brian Green', 55, 'Male', 'CA'); INSERT INTO Policyholders (PolicyholderID, Name, Age, Gender, State) VALUES (3, 'Charlotte Lee', 72, 'Female', 'FL');
Show the top 5 oldest policyholders by age.
SELECT * FROM Policyholders ORDER BY Age DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE SCHEMA if not exists biotech;CREATE TABLE if not exists biotech.projects (id INT, name VARCHAR(100), status VARCHAR(20), completion_date DATE); INSERT INTO biotech.projects (id, name, status, completion_date) VALUES (1, 'Project1', 'Completed', '2021-04-15'), (2, 'Project2', 'In Progress', '2021-07-20'), (3, 'Project3', 'Completed', '2021-06-30');
How many biosensor technology projects were completed in Q2 2021?
SELECT COUNT(*) FROM biotech.projects WHERE status = 'Completed' AND completion_date BETWEEN '2021-04-01' AND '2021-06-30';
gretelai_synthetic_text_to_sql
CREATE TABLE space_missions_cost (year INT, cost FLOAT); INSERT INTO space_missions_cost (year, cost) VALUES (2012, 5000000), (2013, 6000000), (2014, 7000000), (2015, 8000000), (2016, 9000000), (2017, 10000000), (2018, 11000000), (2019, 12000000), (2020, 13000000), (2021, 14000000);
What is the average cost of a space mission over the last 10 years?
SELECT AVG(cost) FROM space_missions_cost WHERE year BETWEEN 2012 AND 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE cases (id INT, region VARCHAR(10), billing_amount INT); INSERT INTO cases (id, region, billing_amount) VALUES (1, 'Eastern', 5000), (2, 'Western', 7000), (3, 'Eastern', 6000), (4, 'Western', 9000);
What is the maximum billing amount for cases in the 'Western' region?
SELECT MAX(billing_amount) FROM cases WHERE region = 'Western';
gretelai_synthetic_text_to_sql
CREATE TABLE Oceanography (id INT PRIMARY KEY, location VARCHAR(255), depth FLOAT, salinity FLOAT); INSERT INTO Oceanography (id, location, depth, salinity) VALUES (1, 'Pacific Ocean Trench', 10000, 35), (2, 'Southern Ocean', 7000, 34);
What is the minimum depth of the deepest oceanographic areas?
SELECT location, MIN(depth) FROM Oceanography WHERE depth < 8000;
gretelai_synthetic_text_to_sql
CREATE TABLE SafetyTesting (Id INT, Vehicle VARCHAR(50), Test VARCHAR(50), Result VARCHAR(50)); INSERT INTO SafetyTesting (Id, Vehicle, Test, Result) VALUES (1, 'Volvo XC60', 'Frontal Crash Test', 'Passed'), (2, 'Nissan Leaf', 'Pedestrian Safety Test', 'Passed');
What vehicles passed the 'Pedestrian Safety Test' in the SafetyTesting table?
SELECT Vehicle FROM SafetyTesting WHERE Test = 'Pedestrian Safety Test' AND Result = 'Passed';
gretelai_synthetic_text_to_sql
CREATE TABLE vineyard_soil_analysis (id INT, location VARCHAR(255), soil_type VARCHAR(255)); INSERT INTO vineyard_soil_analysis (id, location, soil_type) VALUES (1, 'South Africa-Stellenbosch', 'loam'), (2, 'South Africa-Franschhoek', 'clay'), (3, 'South Africa-Stellenbosch', 'sand'), (4, 'South Africa-Paarl', 'loam');
Identify the unique soil types analyzed in vineyards located in South Africa.
SELECT DISTINCT soil_type FROM vineyard_soil_analysis WHERE location LIKE '%South Africa%';
gretelai_synthetic_text_to_sql
CREATE TABLE cosmetics_sales (product_category VARCHAR(20), product_type VARCHAR(20), is_organic BOOLEAN, revenue DECIMAL(10,2)); INSERT INTO cosmetics_sales (product_category, product_type, is_organic, revenue) VALUES ('Makeup', 'Lipstick', true, 5000), ('Makeup', 'Lipstick', false, 7000), ('Makeup', 'Foundation', true, 8000), ('Makeup', 'Mascara', false, 6000);
What is the total revenue for lipstick products in the organic category?
SELECT SUM(revenue) FROM cosmetics_sales WHERE product_type = 'Lipstick' AND is_organic = true;
gretelai_synthetic_text_to_sql
CREATE SCHEMA if not exists higher_ed;CREATE TABLE if not exists higher_ed.faculty(id INT, name VARCHAR(255), department VARCHAR(255), grant_amount DECIMAL(10,2), grant_date DATE, gender VARCHAR(10));
What is the total grant amount awarded to female faculty members in the Computer Science department in the last 3 years?
SELECT SUM(grant_amount) FROM higher_ed.faculty WHERE department = 'Computer Science' AND gender = 'Female' AND grant_date >= DATE_SUB(CURRENT_DATE, INTERVAL 3 YEAR);
gretelai_synthetic_text_to_sql
CREATE TABLE ngo_donations (ngo_id INT, donation_amount FLOAT, donation_year INT, ngo_category VARCHAR(255)); INSERT INTO ngo_donations (ngo_id, donation_amount, donation_year, ngo_category) VALUES (1, 50000, 2019, 'Health'), (2, 75000, 2020, 'Education'), (3, 30000, 2018, 'Health'), (4, 100000, 2020, 'Education'); CREATE TABLE ngo_categories (ngo_category_id INT, ngo_category VARCHAR(255)); INSERT INTO ngo_categories (ngo_category_id, ngo_category) VALUES (1, 'Health'), (2, 'Education'), (3, 'Housing');
What is the total amount of donations received by each NGO, grouped by category?
SELECT ngo_category, SUM(donation_amount) as total_donations FROM ngo_donations INNER JOIN ngo_categories ON ngo_donations.ngo_category = ngo_categories.ngo_category GROUP BY ngo_category;
gretelai_synthetic_text_to_sql
CREATE TABLE ancient_artifacts (id INT, artifact_name VARCHAR(50), age INT, excavation_site VARCHAR(50));
What is the age of the second-oldest artifact at each excavation site?
SELECT excavation_site, LEAD(age) OVER (PARTITION BY excavation_site ORDER BY age) as second_oldest_artifact_age FROM ancient_artifacts;
gretelai_synthetic_text_to_sql
CREATE TABLE suppliers (id INT PRIMARY KEY, name VARCHAR(255), location VARCHAR(255), environmental_certification VARCHAR(255)); INSERT INTO suppliers (id, name, location, environmental_certification) VALUES (1, 'Supplier A', 'Germany', 'ISO 14001'), (2, 'Supplier B', 'Brazil', 'ISO 14001'), (3, 'Supplier C', 'Japan', NULL), (4, 'Supplier D', 'Canada', 'ISO 14001');
What is the total number of suppliers in each country, and the number of suppliers with environmental certifications for each country?
SELECT location as country, COUNT(*) as total_suppliers, SUM(CASE WHEN environmental_certification IS NOT NULL THEN 1 ELSE 0 END) as certified_suppliers FROM suppliers GROUP BY location;
gretelai_synthetic_text_to_sql
CREATE TABLE renewable_energy_production (state VARCHAR(50), year INT, energy_production FLOAT, energy_source VARCHAR(50));
Find the total energy production (in MWh) from renewable energy sources for each state in the renewable_energy_production table.
SELECT state, SUM(energy_production) as total_renewable_energy FROM renewable_energy_production WHERE energy_source = 'Wind' OR energy_source = 'Solar' GROUP BY state;
gretelai_synthetic_text_to_sql
CREATE TABLE shipments (id INT, vendor VARCHAR(50), ship_date DATE); INSERT INTO shipments (id, vendor, ship_date) VALUES (1, 'Vendor X', '2021-03-01'); INSERT INTO shipments (id, vendor, ship_date) VALUES (2, 'Vendor Y', '2021-03-05');
What is the total number of shipments made by vendor X in March 2021?
SELECT COUNT(*) FROM shipments WHERE vendor = 'Vendor X' AND EXTRACT(MONTH FROM ship_date) = 3 AND EXTRACT(YEAR FROM ship_date) = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE mine (id INT, name TEXT, location TEXT); INSERT INTO mine (id, name, location) VALUES (1, 'Golden Mine', 'USA'), (2, 'Silver Mine', 'Canada'); CREATE TABLE weather (id INT, mine_id INT, date DATE, rainfall REAL); INSERT INTO weather (id, mine_id, date, rainfall) VALUES (1, 1, '2022-01-01', 30), (2, 1, '2022-02-01', 40), (3, 1, '2022-03-01', 50), (4, 2, '2022-01-01', 60), (5, 2, '2022-02-01', 70), (6, 2, '2022-03-01', 80);
What is the average monthly rainfall at each mine location?
SELECT mine_id, AVG(rainfall) as avg_rainfall FROM weather GROUP BY mine_id;
gretelai_synthetic_text_to_sql
CREATE TABLE Bills (BillID INT, Department VARCHAR(50), Amount FLOAT);
What are the names and total budgets for bills related to education and health with a budget over 500000 dollars?
SELECT Bills.Department, SUM(Bills.Amount) AS TotalBudget FROM Bills WHERE Bills.Department IN ('Education', 'Health') AND Bills.Amount > 500000 GROUP BY Bills.Department;
gretelai_synthetic_text_to_sql
CREATE TABLE union_members (member_id INT, member_name VARCHAR(255), union_id INT, monthly_salary DECIMAL(10,2)); CREATE TABLE unions (union_id INT, union_name VARCHAR(255)); INSERT INTO unions (union_id, union_name) VALUES (123, 'Transportation Workers Union'); INSERT INTO unions (union_id, union_name) VALUES (456, 'Construction Workers Union'); INSERT INTO union_members (member_id, member_name, union_id, monthly_salary) VALUES (1, 'John Doe', 456, 4000.50); INSERT INTO union_members (member_id, member_name, union_id, monthly_salary) VALUES (2, 'Jane Doe', 456, 4500.25);
What is the maximum monthly salary in the 'Construction Workers Union'?
SELECT MAX(monthly_salary) FROM union_members WHERE union_id = (SELECT union_id FROM unions WHERE union_name = 'Construction Workers Union');
gretelai_synthetic_text_to_sql
CREATE TABLE drought_impact (area VARCHAR(255), region VARCHAR(255), population INT); INSERT INTO drought_impact (area, region, population) VALUES ('City A', 'East', 600000), ('City B', 'East', 700000), ('City C', 'East', 500000), ('City D', 'West', 800000), ('City E', 'West', 900000), ('City F', 'West', 750000);
Compare the drought-impacted areas between 'East' and 'West' regions.
SELECT region, COUNT(*) FROM drought_impact GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE Sales (SaleID INT, SaleDate DATE, SaleType VARCHAR(10), Revenue DECIMAL(10, 2)); INSERT INTO Sales (SaleID, SaleDate, SaleType, Revenue) VALUES (1, '2020-01-01', 'Digital', 1000); INSERT INTO Sales (SaleID, SaleDate, SaleType, Revenue) VALUES (2, '2020-02-01', 'Physical', 2000);
Find the total revenue for digital and physical sales for the year 2020.
SELECT SUM(Revenue) FROM Sales WHERE SaleDate BETWEEN '2020-01-01' AND '2020-12-31' AND SaleType IN ('Digital', 'Physical');
gretelai_synthetic_text_to_sql
CREATE TABLE marine_species (species_id INTEGER, species_name VARCHAR(255), ocean VARCHAR(50)); CREATE TABLE oceanography (ocean_id INTEGER, ocean_name VARCHAR(50), total_area FLOAT);
Find the total number of marine species in each ocean.
SELECT ocean, COUNT(species_id) FROM marine_species GROUP BY ocean;
gretelai_synthetic_text_to_sql
CREATE TABLE StaffHires (hire_date DATE, staff_type VARCHAR(255)); INSERT INTO StaffHires (hire_date, staff_type) VALUES ('2022-04-05', 'Accessibility Specialist'); INSERT INTO StaffHires (hire_date, staff_type) VALUES ('2022-08-10', 'Accessibility Coordinator');
What is the total number of accessibility-related staff hires in Q2 and Q3 of 2022?
SELECT SUM(total_hires) as q2_q3_hires FROM (SELECT CASE WHEN hire_date BETWEEN '2022-04-01' AND LAST_DAY('2022-06-30') THEN 1 WHEN hire_date BETWEEN '2022-07-01' AND LAST_DAY('2022-09-30') THEN 1 ELSE 0 END as total_hires FROM StaffHires) AS subquery;
gretelai_synthetic_text_to_sql
CREATE TABLE public_universities (name TEXT, budget INTEGER, state TEXT); INSERT INTO public_universities (name, budget, state) VALUES ('University1', 100000, 'Oregon'), ('University2', 120000, 'Oregon'), ('University3', 90000, 'Oregon');
What is the name and budget of the public university with the largest budget in Oregon?
SELECT name, budget FROM public_universities WHERE state = 'Oregon' ORDER BY budget DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE attorneys (attorney_id INT, name TEXT); CREATE TABLE cases (case_id INT, attorney_id INT, won BOOLEAN);
What is the number of cases for each attorney and their respective success rates?
SELECT a.attorney_id, a.name, COUNT(c.case_id) AS cases_handled, AVG(CASE WHEN won THEN 1.0 ELSE 0.0 END) * 100.0 AS success_rate FROM attorneys a JOIN cases c ON a.attorney_id = c.attorney_id GROUP BY a.attorney_id, a.name;
gretelai_synthetic_text_to_sql
CREATE TABLE district (id INT, name VARCHAR(50), type VARCHAR(50)); INSERT INTO district (id, name, type) VALUES (1, 'City A', 'urban'), (2, 'Town B', 'urban'), (3, 'Village C', 'rural'); CREATE TABLE budget (district_id INT, category VARCHAR(50), amount INT); INSERT INTO budget (district_id, category, amount) VALUES (1, 'education', 500000), (1, 'healthcare', 300000), (2, 'education', 350000), (2, 'healthcare', 400000), (3, 'education', 200000), (3, 'healthcare', 500000);
What is the average budget allocated for education in urban areas?
SELECT AVG(amount) FROM budget WHERE category = 'education' AND district_id IN (SELECT id FROM district WHERE type = 'urban');
gretelai_synthetic_text_to_sql
CREATE TABLE MillSales(mill_name TEXT, sale_volume INT, region TEXT); INSERT INTO MillSales (mill_name, sale_volume, region) VALUES ('Mill X', 500, 'Region A'), ('Mill Y', 350, 'Region B'), ('Mill Z', 700, 'Region A');
Find the total volume of timber sold by mills located in 'Region A' or 'Region B'.
SELECT SUM(sale_volume) FROM MillSales WHERE region IN ('Region A', 'Region B');
gretelai_synthetic_text_to_sql
CREATE TABLE water_usage (site_id INT, site_name TEXT, month INT, year INT, water_usage INT); INSERT INTO water_usage (site_id, site_name, month, year, water_usage) VALUES (1, 'ABC Mine', 3, 2021, 15000), (2, 'DEF Mine', 5, 2021, 20000), (3, 'GHI Mine', 1, 2022, 25000), (1, 'ABC Mine', 4, 2021, 17000), (2, 'DEF Mine', 6, 2021, 18000);
What is the total water usage by mine site in 2021?
SELECT site_name, SUM(water_usage) as total_water_usage_2021 FROM water_usage WHERE year = 2021 GROUP BY site_name;
gretelai_synthetic_text_to_sql
CREATE TABLE Production_Facilities (facility_id INT, facility_name VARCHAR(50), sustainable_material_weight FLOAT);
What is the total weight of sustainable materials used in each production facility?
SELECT Production_Facilities.facility_name, SUM(Production_Facilities.sustainable_material_weight) as total_weight FROM Production_Facilities GROUP BY Production_Facilities.facility_name;
gretelai_synthetic_text_to_sql
CREATE TABLE satellite_deployment (mission VARCHAR(50), launch_site VARCHAR(50)); INSERT INTO satellite_deployment (mission, launch_site) VALUES ('Mars_2020', 'Vandenberg'), ('Mars_2022', 'Cape_Canaveral'), ('Mars_2023', 'Kennedy_Space_Center');
Update the 'launch_site' for the 'Mars_2023' satellite mission to 'Cape Canaveral' in the 'satellite_deployment' table.
UPDATE satellite_deployment SET launch_site = 'Cape_Canaveral' WHERE mission = 'Mars_2023';
gretelai_synthetic_text_to_sql
CREATE TABLE autonomous_vehicles (vehicle_id int, city varchar(20), trips int); INSERT INTO autonomous_vehicles (vehicle_id, city, trips) VALUES (1, 'Singapore', 235), (2, 'Singapore', 345), (3, 'Singapore', 456);
What is the total number of trips taken in autonomous vehicles in Singapore?
SELECT SUM(trips) FROM autonomous_vehicles WHERE city = 'Singapore';
gretelai_synthetic_text_to_sql
CREATE TABLE Movies (id INT, title VARCHAR(255), rating VARCHAR(10), revenue INT);
What is the total revenue of all R-rated movies?
SELECT SUM(revenue) FROM Movies WHERE rating = 'R';
gretelai_synthetic_text_to_sql
CREATE TABLE Students (StudentId INT, Name VARCHAR(50), Age INT); INSERT INTO Students (StudentId, Name, Age) VALUES (1001, 'John Doe', 16); CREATE VIEW StudentNames AS SELECT * FROM Students;
Update 'Age' column in 'Students' table to 16 for StudentId 1001
UPDATE Students SET Age = 16 WHERE StudentId = 1001;
gretelai_synthetic_text_to_sql
CREATE TABLE ghana_gold_export (year INT, export_amount FLOAT); INSERT INTO ghana_gold_export (year, export_amount) VALUES (2016, 2000.0), (2017, 2100.0), (2018, 2200.0); CREATE TABLE mali_gold_export (year INT, export_amount FLOAT); INSERT INTO mali_gold_export (year, export_amount) VALUES (2016, 1500.0), (2017, 1600.0), (2018, 1700.0); CREATE TABLE ghana_mercury_emission (year INT, emission FLOAT); INSERT INTO ghana_mercury_emission (year, emission) VALUES (2016, 10.0), (2017, 11.0), (2018, 12.0); CREATE TABLE mali_mercury_emission (year INT, emission FLOAT); INSERT INTO mali_mercury_emission (year, emission) VALUES (2016, 8.0), (2017, 9.0), (2018, 10.0);
List the total gold exports and mercury emissions from Ghana and Mali between 2016 and 2018.
SELECT 'Ghana' AS country, SUM(ghana_gold_export.export_amount) AS gold_export, SUM(ghana_mercury_emission.emission) AS mercury_emission FROM ghana_gold_export INNER JOIN ghana_mercury_emission ON ghana_gold_export.year = ghana_mercury_emission.year WHERE ghana_gold_export.year BETWEEN 2016 AND 2018 UNION ALL SELECT 'Mali', SUM(mali_gold_export.export_amount), SUM(mali_mercury_emission.emission) FROM mali_gold_export INNER JOIN mali_mercury_emission ON mali_gold_export.year = mali_mercury_emission.year WHERE mali_gold_export.year BETWEEN 2016 AND 2018;
gretelai_synthetic_text_to_sql
CREATE TABLE accidents (id INT, report_date DATE, city TEXT, type TEXT); INSERT INTO accidents (id, report_date, city, type) VALUES (1, '2022-01-01', 'Houston', 'minor');
How many traffic accidents were reported in Texas in the past year?
SELECT COUNT(*) FROM accidents WHERE accidents.report_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR) AND accidents.city IN (SELECT cities.name FROM cities WHERE cities.state = 'Texas');
gretelai_synthetic_text_to_sql
CREATE TABLE unions (id INT, name VARCHAR(50)); INSERT INTO unions (id, name) VALUES (1, 'Union A'), (2, 'Union B'), (3, 'Union C'); CREATE TABLE companies (id INT, name VARCHAR(50), union_id INT, safety_violations INT); INSERT INTO companies (id, name, union_id, safety_violations) VALUES (1, 'Company X', 1, 10), (2, 'Company Y', 2, 5), (3, 'Company Z', 3, 15), (4, 'Company W', 1, 0), (5, 'Company V', 3, 20);
Which union represents the company with the most workplace safety violations?
SELECT unions.name, MAX(companies.safety_violations) FROM unions JOIN companies ON unions.id = companies.union_id GROUP BY unions.name ORDER BY MAX(companies.safety_violations) DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE military_equipment (equipment_type VARCHAR(255), purchase_date DATE); INSERT INTO military_equipment (equipment_type, purchase_date) VALUES ('Tank', '2011-01-01'), ('Jet', '2012-01-01'), ('Submarine', '2005-01-01');
Delete all records from the military equipment table that are older than 10 years
DELETE FROM military_equipment WHERE purchase_date < '2011-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE Equipment (EID INT, Type VARCHAR(50), VendorID INT, MaintenanceCost INT); INSERT INTO Equipment (EID, Type, VendorID, MaintenanceCost) VALUES (1, 'Tank', 1, 10000), (2, 'Fighter Jet', 1, 20000), (3, 'Helicopter', 2, 15000); CREATE TABLE Vendors (VID INT, Name VARCHAR(100)); INSERT INTO Vendors (VID, Name) VALUES (1, 'Raytheon Technologies'), (2, 'BAE Systems');
Which vendors have the highest average maintenance costs for military equipment, and the number of different equipment types maintained by these vendors?
SELECT v.Name, AVG(Equipment.MaintenanceCost) as AvgMaintenanceCost, COUNT(DISTINCT Equipment.Type) as NumEquipmentTypes FROM Equipment JOIN Vendors v ON Equipment.VendorID = v.VID GROUP BY v.Name ORDER BY AvgMaintenanceCost DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE Players (PlayerID INT PRIMARY KEY, Age INT, Gender VARCHAR(10), Country VARCHAR(50)); INSERT INTO Players (PlayerID, Age, Gender, Country) VALUES (6, 28, 'Female', 'France'), (7, 30, 'Male', 'Germany'), (8, 24, 'Female', 'France'), (9, 22, 'Male', 'Canada'), (10, 32, 'Female', 'USA');
Which country has the most female players?
SELECT Country, COUNT(*) FROM Players WHERE Gender = 'Female' GROUP BY Country ORDER BY COUNT(*) DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE worker_salaries (employee_id INT, country VARCHAR(50), sector VARCHAR(50), salary FLOAT);
What is the average salary for workers in the manufacturing sector in France and Germany?
SELECT AVG(salary) FROM worker_salaries WHERE country IN ('France', 'Germany') AND sector = 'Manufacturing';
gretelai_synthetic_text_to_sql
CREATE TABLE Transportation (id INT, mode TEXT, type TEXT, cost FLOAT); INSERT INTO Transportation (id, mode, type, cost) VALUES (1, 'Sea', 'Full Container Load', 1500), (2, 'Air', 'Express', 5000), (3, 'Rail', 'Less than Container Load', 800);
List all unique modes of transportation and their associated average costs for freight forwarding in the Asia-Pacific region.
SELECT DISTINCT mode, AVG(cost) FROM Transportation WHERE type = 'Full Container Load' AND country IN ('Asia', 'Pacific') GROUP BY mode;
gretelai_synthetic_text_to_sql
CREATE TABLE tv_shows (id INT, title VARCHAR(255), season INT, genre VARCHAR(255), rating DECIMAL(3,2)); INSERT INTO tv_shows (id, title, season, genre, rating) VALUES (1, 'TVShow1', 1, 'Horror', 8.2), (2, 'TVShow1', 2, 'Horror', 8.5), (3, 'TVShow2', 1, 'Horror', 7.8), (4, 'TVShow2', 2, 'Horror', 8.0), (5, 'TVShow3', 1, 'Comedy', 9.0), (6, 'TVShow3', 2, 'Comedy', 8.8);
Which TV shows have the highest average rating per season in the horror genre?
SELECT title, AVG(rating) AS avg_rating FROM tv_shows WHERE genre = 'Horror' GROUP BY title ORDER BY avg_rating DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE Players (PlayerID INT, Age INT, Gender VARCHAR(10), Playtime INT, VR INT); INSERT INTO Players (PlayerID, Age, Gender, Playtime, VR) VALUES (1, 25, 'Male', 10, 1); INSERT INTO Players (PlayerID, Age, Gender, Playtime, VR) VALUES (2, 30, 'Female', 15, 1); CREATE TABLE VRPlayers (PlayerID INT); INSERT INTO VRPlayers (PlayerID) VALUES (1); INSERT INTO VRPlayers (PlayerID) VALUES (2);
What is the average playtime of players who use VR technology?
SELECT AVG(Players.Playtime) FROM Players INNER JOIN VRPlayers ON Players.PlayerID = VRPlayers.PlayerID;
gretelai_synthetic_text_to_sql
CREATE TABLE deep_sea_expeditions (id INT, expedition_name VARCHAR(255), year INT, country VARCHAR(255), region VARCHAR(255), num_species INT); INSERT INTO deep_sea_expeditions (id, expedition_name, year, country, region, num_species) VALUES (1, 'Antarctic Circumnavigation Expedition', 2016, 'Australia', 'Southern', 345), (2, 'Southern Ocean Deep-Sea Expedition', 2017, 'New Zealand', 'Southern', 567);
What is the minimum number of deep-sea species observed in a single expedition in the Southern Ocean?
SELECT MIN(num_species) FROM deep_sea_expeditions WHERE region = 'Southern';
gretelai_synthetic_text_to_sql
CREATE TABLE GenePathways (gene_id INT, gene_name TEXT, pathway TEXT); INSERT INTO GenePathways (gene_id, gene_name, pathway) VALUES (1, 'GeneA', 'pathway1'), (2, 'GeneB', 'pathway2'), (3, 'GeneC', 'pathway1');
Which genes are involved in the 'pathway1'?
SELECT gene_name FROM GenePathways WHERE pathway = 'pathway1';
gretelai_synthetic_text_to_sql
CREATE TABLE Intersection (id INT, name TEXT, location TEXT, type TEXT, build_date DATE); INSERT INTO Intersection (id, name, location, type, build_date) VALUES (1, 'Dallas Circle', 'Dallas, TX', 'Roundabout', '2012-05-01');
How many roundabouts have been built in Texas since 2010?
SELECT COUNT(*) FROM Intersection WHERE location LIKE '%TX%' AND type = 'Roundabout' AND build_date >= '2010-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE fields (id INT, field_name VARCHAR(255), area FLOAT, soil_type VARCHAR(255), region VARCHAR(255)); INSERT INTO fields (id, field_name, area, soil_type, region) VALUES (1, 'field1', 10.5, 'loamy', 'Northeast'), (2, 'field2', 12.3, 'sandy', 'South'), (3, 'field3', 8.9, 'loamy', 'Northeast'), (4, 'field4', 15.7, 'clay', 'Midwest');
What is the total area of fields in the "loamy" soil type category, grouped by the region?
SELECT region, SUM(area) FROM fields WHERE soil_type = 'loamy' GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE ArtCollection (ArtworkID INT, ArtistID INT, ArtworkYear INT); INSERT INTO ArtCollection (ArtworkID, ArtistID, ArtworkYear) VALUES (1, 1, 1880), (2, 1, 1885), (3, 2, 1890), (4, 2, 1895), (5, 3, 1890), (6, 3, 1895), (7, 4, 1940), (8, 4, 1945), (9, 5, 1790), (10, 5, 1795);
How many artworks were created per year by artists in the 'ArtCollection' table?
SELECT ArtworkYear, COUNT(*) AS ArtworksPerYear FROM ArtCollection GROUP BY ArtworkYear;
gretelai_synthetic_text_to_sql
CREATE TABLE readers (id INT, name VARCHAR(20), age INT, favorite_category VARCHAR(20)); INSERT INTO readers (id, name, age, favorite_category) VALUES (1, 'John Doe', 35, 'politics'), (2, 'Jane Smith', 40, 'business');
What is the average age of readers who prefer news on 'politics'?
SELECT AVG(age) FROM readers WHERE favorite_category = 'politics';
gretelai_synthetic_text_to_sql
CREATE TABLE machine_maintenance_new3 (id INT PRIMARY KEY, machine_name VARCHAR(50), last_maintenance_date DATE); CREATE TABLE machine_usage_new3 (id INT PRIMARY KEY, machine_name VARCHAR(50), usage_hours INT);
List all the machines that have usage hours greater than 100 and their last maintenance date.
SELECT m.machine_name, m.last_maintenance_date FROM machine_maintenance_new3 m INNER JOIN machine_usage_new3 u ON m.machine_name = u.machine_name WHERE u.usage_hours > 100;
gretelai_synthetic_text_to_sql
CREATE TABLE crop (id INT, type VARCHAR(255), region VARCHAR(255), yield FLOAT, sustainability VARCHAR(255)); INSERT INTO crop (id, type, region, yield, sustainability) VALUES (1, 'corn', 'Midwest', 150.3, 'sustainable'), (2, 'wheat', 'Great Plains', 120.5, 'non-sustainable'), (3, 'rice', 'Southeast', 180.7, 'sustainable'), (4, 'corn', 'Midwest', 165.2, 'sustainable'), (5, 'corn', 'Northeast', 145.8, 'non-sustainable');
What is the average yield for each crop type in the 'agriculture' database, grouped by crop type, for farms that use sustainable practices?
SELECT type, AVG(yield) as avg_yield FROM crop WHERE sustainability = 'sustainable' GROUP BY type;
gretelai_synthetic_text_to_sql
CREATE TABLE habitat_preservation (id INT, region VARCHAR(50), animal_name VARCHAR(50), population INT); INSERT INTO habitat_preservation (id, region, animal_name, population) VALUES (1, 'Habitat Preservation', 'Tiger', 1500), (2, 'Habitat Preservation', 'Elephant', 3000);
What is the total population of animals in the 'habitat_preservation' region?
SELECT SUM(population) FROM habitat_preservation WHERE region = 'Habitat Preservation';
gretelai_synthetic_text_to_sql
CREATE TABLE disinformation_detections (id INT, date DATE, source VARCHAR(255), location VARCHAR(255)); INSERT INTO disinformation_detections (id, date, source, location) VALUES (4, '2023-02-01', 'Blog 1', 'South America'), (5, '2023-02-02', 'Blog 2', 'South America'), (6, '2023-02-03', 'Blog 3', 'South America');
How many instances of disinformation were detected in blogs in South America in the last month?
SELECT COUNT(*) FROM disinformation_detections WHERE location = 'South America' AND source LIKE '%Blog%' AND date >= DATEADD(month, -1, GETDATE());
gretelai_synthetic_text_to_sql
CREATE TABLE districts (id INT, name TEXT, type TEXT, budget FLOAT); INSERT INTO districts (id, name, type, budget) VALUES (1, 'City A', 'urban-coastal', 6000000), (2, 'Town B', 'urban-inland', 2500000), (3, 'Village C', 'rural', 1200000);
What is the average budget for healthcare services in coastal districts?
SELECT AVG(budget) FROM districts WHERE type LIKE '%coastal%';
gretelai_synthetic_text_to_sql
CREATE TABLE geothermal_costs (id INT, name TEXT, country TEXT, energy_production_cost FLOAT); INSERT INTO geothermal_costs (id, name, country, energy_production_cost) VALUES (1, 'Sarulla', 'Indonesia', 0.065), (2, 'Cameron', 'Indonesia', 0.070);
What is the minimum energy production cost of geothermal plants in Indonesia?
SELECT MIN(energy_production_cost) FROM geothermal_costs WHERE country = 'Indonesia';
gretelai_synthetic_text_to_sql
CREATE TABLE cosmetics.lipstick_preferences (consumer_id INT, lipstick_color VARCHAR(20)); INSERT INTO cosmetics.lipstick_preferences (consumer_id, lipstick_color) VALUES (1, 'Red'), (2, 'Pink'), (3, 'Nude'), (4, 'Red'), (5, 'Pink');
What are the top 3 preferred lipstick colors by consumers in the US?
SELECT lipstick_color, COUNT(*) as countOfPreference FROM cosmetics.lipstick_preferences WHERE lipstick_color IN ('Red', 'Pink', 'Nude') GROUP BY lipstick_color ORDER BY countOfPreference DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE products (id INT, name TEXT, supplier TEXT); CREATE TABLE sales (id INT, product_id INT, quantity INT, revenue FLOAT);
List all the suppliers that have provided goods for a specific product, along with the total quantity and total revenue generated from those goods.
SELECT p.supplier, SUM(s.quantity) as total_quantity, SUM(s.revenue) as total_revenue FROM products p JOIN sales s ON p.id = s.product_id WHERE p.name = 'specific product' GROUP BY p.supplier;
gretelai_synthetic_text_to_sql
CREATE TABLE inventory (id INT, item_name VARCHAR(20), is_sustainable BOOLEAN, quantity INT); INSERT INTO inventory (id, item_name, is_sustainable, quantity) VALUES (1, 't-shirt', false, 100), (2, 'blouse', true, 50), (3, 'jeans', true, 75), (4, 'skirt', false, 150), (5, 'jacket', true, 100);
Calculate the percentage of items that are sustainable
SELECT (COUNT(CASE WHEN is_sustainable = true THEN 1 END) * 100.0 / COUNT(*)) AS percentage FROM inventory;
gretelai_synthetic_text_to_sql
CREATE TABLE transactions (customer_id INT, region VARCHAR(20), transaction_value DECIMAL(10,2)); INSERT INTO transactions (customer_id, region, transaction_value) VALUES (1, 'Asia-Pacific', 120.50), (2, 'Europe', 75.30);
What is the total transaction value for all customers in the Asia-Pacific region?
SELECT SUM(transaction_value) FROM transactions WHERE region = 'Asia-Pacific';
gretelai_synthetic_text_to_sql
CREATE TABLE Farmers (id INT, name VARCHAR(50), age INT, country VARCHAR(50)); INSERT INTO Farmers (id, name, age, country) VALUES (1, 'Jane Smith', 45, 'France'); CREATE TABLE Irrigation (id INT, Farm_id INT, irrigation_type VARCHAR(50), duration INT); INSERT INTO Irrigation (id, Farm_id, irrigation_type, duration) VALUES (1, 1, 'Drip', 35);
Identify farms in France using Drip irrigation with a duration greater than 20 minutes.
SELECT f.name FROM Farmers f JOIN Irrigation i ON f.id = i.Farm_id WHERE f.country = 'France' AND i.irrigation_type = 'Drip' AND i.duration > 20;
gretelai_synthetic_text_to_sql
CREATE TABLE spacecraft_manufacturers (manufacturer_id INT, name TEXT, country TEXT); INSERT INTO spacecraft_manufacturers (manufacturer_id, name, country) VALUES (1, 'NASA', 'USA'), (2, 'SpaceX', 'USA'); CREATE TABLE spacecrafts (spacecraft_id INT, name TEXT, manufacturer_id INT, mass FLOAT); INSERT INTO spacecrafts (spacecraft_id, name, manufacturer_id, mass) VALUES (1, 'Orion', 1, 18000), (2, 'Starship', 2, 1200000), (3, 'Crew Dragon', 2, 12500);
What is the average mass of spacecrafts manufactured in the US, grouped by manufacturer?
SELECT sm.name, AVG(s.mass) FROM spacecrafts s JOIN spacecraft_manufacturers sm ON s.manufacturer_id = sm.manufacturer_id WHERE sm.country = 'USA' GROUP BY sm.name;
gretelai_synthetic_text_to_sql
CREATE TABLE tv_studios (studio_id INT, studio_name TEXT, country TEXT); INSERT INTO tv_studios (studio_id, studio_name, country) VALUES (1, 'Studio H', 'Japan'), (2, 'Studio I', 'USA'), (3, 'Studio J', 'Germany'); CREATE TABLE tv_shows (show_id INT, title TEXT, rating DECIMAL(2,1), studio_id INT); INSERT INTO tv_shows (show_id, title, rating, studio_id) VALUES (1, 'Show 7', 8.2, 1), (2, 'Show 8', 7.5, 1), (3, 'Show 9', 6.9, 2);
What is the average rating of TV shows produced by companies based in Japan?
SELECT AVG(tv_shows.rating) FROM tv_shows JOIN tv_studios ON tv_shows.studio_id = tv_studios.studio_id WHERE tv_studios.country = 'Japan';
gretelai_synthetic_text_to_sql
CREATE TABLE repeat_visitors (id INT, name TEXT, visited INT); INSERT INTO repeat_visitors VALUES (1, 'Oliver', 2);
Find the number of visitors who are repeat attendees for theater events.
SELECT COUNT(DISTINCT repeat_visitors.name) FROM repeat_visitors WHERE repeat_visitors.visited > 1 AND repeat_visitors.id IN (SELECT t.id FROM theater_events t);
gretelai_synthetic_text_to_sql
CREATE TABLE sustainable_projects (project_id INT, state VARCHAR(2), building_type VARCHAR(20), project_cost DECIMAL(7,2)); INSERT INTO sustainable_projects (project_id, state, building_type, project_cost) VALUES (1, 'FL', 'Residential', 50000.00), (2, 'FL', 'Residential', 55000.50), (3, 'FL', 'Commercial', 100000.00);
What is the total cost of sustainable construction projects in Florida, grouped by building type?
SELECT building_type, SUM(project_cost) FROM sustainable_projects WHERE state = 'FL' GROUP BY building_type;
gretelai_synthetic_text_to_sql
SAME AS ABOVE
What are the maximum and minimum salaries for employees who identify as male and work in the HR department?
SELECT MAX(Salary), MIN(Salary) FROM Employees WHERE Gender = 'Male' AND Department = 'HR';
gretelai_synthetic_text_to_sql
CREATE TABLE Farm (FarmID int, FarmType varchar(20), Country varchar(50)); INSERT INTO Farm (FarmID, FarmType, Country) VALUES (1, 'Organic', 'USA'), (2, 'Conventional', 'Canada'), (3, 'Urban', 'Mexico'), (4, 'Organic', 'USA'), (5, 'Organic', 'Mexico');
Find the top 2 countries with the most number of organic farms, and the number of organic farms in those countries.
SELECT Country, COUNT(*) as NumOrgFarms FROM Farm WHERE FarmType = 'Organic' GROUP BY Country ORDER BY NumOrgFarms DESC LIMIT 2;
gretelai_synthetic_text_to_sql
CREATE TABLE employee_demographics (id INT PRIMARY KEY, employee_id INT, name VARCHAR(255), gender VARCHAR(255), department VARCHAR(255), region VARCHAR(255)); INSERT INTO employee_demographics (id, employee_id, name, gender, department, region) VALUES (1, 101, 'Jamal Johnson', 'Male', 'Marketing', 'Northwest'), (2, 102, 'Sofia Garcia', 'Female', 'IT', 'Northeast');
Display the number of female and male employees in each department from 'employee_demographics'
SELECT department, gender, COUNT(*) FROM employee_demographics GROUP BY department, gender;
gretelai_synthetic_text_to_sql
CREATE TABLE inmates (inmate_id INT, inmate_name VARCHAR(255), sentence_length INT, PRIMARY KEY (inmate_id)); INSERT INTO inmates (inmate_id, inmate_name, sentence_length) VALUES (1, 'Inmate 1', 60), (2, 'Inmate 2', 36), (3, 'Inmate 3', 72);
Display the names and sentences of all inmates who have been incarcerated for more than 5 years
SELECT inmate_name, sentence_length FROM inmates WHERE sentence_length > 60;
gretelai_synthetic_text_to_sql
CREATE TABLE MemberWorkout (member_id INT, workout_id INT); INSERT INTO MemberWorkout (member_id, workout_id) VALUES (1001, 3001);
Calculate the median age of members who have participated in yoga workouts.
SELECT AVG(DATEDIFF('day', dob, CURDATE()))/365 as median_age FROM Member m JOIN MemberWorkout mw ON m.id = mw.member_id JOIN WorkoutType wt ON mw.workout_id = wt.id WHERE wt.workout_name = 'Yoga' GROUP BY m.id ORDER BY median_age;
gretelai_synthetic_text_to_sql
CREATE TABLE vaccine_administered (patient_id INT, vaccine_name VARCHAR(255), state VARCHAR(255)); INSERT INTO vaccine_administered (patient_id, vaccine_name, state) VALUES (1, 'Moderna', 'Texas'), (2, 'Pfizer', 'Texas');
What is the total number of Moderna vaccines administered in Texas?
SELECT COUNT(*) FROM vaccine_administered WHERE vaccine_name = 'Moderna' AND state = 'Texas';
gretelai_synthetic_text_to_sql
CREATE TABLE military_innovation_2 (id INT, country VARCHAR(255), project VARCHAR(255)); INSERT INTO military_innovation_2 (id, country, project) VALUES (1, 'USA', 'Stealth Helicopter'), (2, 'Russia', 'Hypersonic Missile'), (3, 'China', 'Artificial Intelligence'), (4, 'USA', 'Directed Energy Weapon'), (5, 'France', 'Cybersecurity Defense'), (6, 'China', 'Quantum Computing'), (7, 'Russia', 'Underwater Drone'), (8, 'USA', 'Smart Munitions'), (9, 'France', 'Electronic Warfare'), (10, 'China', '5G Network');
What is the total number of military innovation projects in each country, ordered alphabetically by country name?
SELECT country, COUNT(project) AS total_projects FROM military_innovation_2 GROUP BY country ORDER BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE financial_capability (session_id INT, region VARCHAR(255), date DATE); INSERT INTO financial_capability (session_id, region, date) VALUES (1, 'North', '2022-01-01'), (2, 'South', '2022-02-01'), (3, 'East', '2022-03-01'), (4, 'West', '2022-04-01'), (5, 'North', '2022-05-01'), (6, 'South', '2022-06-01');
How many financial capability training sessions were held in each region?
SELECT region, COUNT(*) FROM financial_capability GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE departments (dept_id INT, dept_name VARCHAR(255));CREATE TABLE faculties (faculty_id INT, name VARCHAR(255), dept_id INT, num_publications INT);
What is the average number of publications per faculty member, for each department, in descending order of average publications?
SELECT dept_name, AVG(num_publications) AS avg_publications FROM faculties f JOIN departments d ON f.dept_id = d.dept_id GROUP BY dept_name ORDER BY avg_publications DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE highest_nhl_scores (player VARCHAR(100), team VARCHAR(50), points INT); INSERT INTO highest_nhl_scores (player, team, points) VALUES ('Wayne Gretzky', 'Edmonton Oilers', 13), ('Mario Lemieux', 'Pittsburgh Penguins', 10);
What is the highest number of points scored by a player in a single NHL game?
SELECT MAX(points) FROM highest_nhl_scores;
gretelai_synthetic_text_to_sql
CREATE TABLE community_health_workers (id INT, name VARCHAR(50), ethnicity VARCHAR(50), salary INT); INSERT INTO community_health_workers (id, name, ethnicity, salary) VALUES (1, 'John Doe', 'Hispanic', 50000), (2, 'Jane Smith', 'African American', 55000);
Update the salary of the community health worker with ID 1 to $60,000.
UPDATE community_health_workers SET salary = 60000 WHERE id = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE Sustainable_Projects_CO (project_id INT, project_name VARCHAR(50), state VARCHAR(2), timeline INT, is_sustainable BOOLEAN); INSERT INTO Sustainable_Projects_CO VALUES (1, 'Denver Eco-Tower', 'CO', 30, true);
What is the minimum timeline for a sustainable construction project in Colorado?
SELECT MIN(timeline) FROM Sustainable_Projects_CO WHERE state = 'CO' AND is_sustainable = true;
gretelai_synthetic_text_to_sql
CREATE TABLE users (user_id INT, user_name VARCHAR(255), country VARCHAR(255));CREATE TABLE posts (post_id INT, user_id INT, likes INT, timestamp TIMESTAMP); INSERT INTO users (user_id, user_name, country) VALUES (1, 'Alice', 'USA'), (2, 'Bob', 'Canada'); INSERT INTO posts (post_id, user_id, likes, timestamp) VALUES (1, 1, 10, '2022-01-01 10:00:00'), (2, 1, 15, '2022-01-02 10:00:00'), (3, 2, 5, '2022-01-01 10:00:00');
What is the average number of likes on posts by users in the United States, for users who have posted at least 5 times in the last month?
SELECT AVG(posts.likes) FROM users INNER JOIN posts ON users.user_id = posts.user_id WHERE users.country = 'USA' AND COUNT(posts.post_id) >= 5 AND posts.timestamp >= NOW() - INTERVAL 1 MONTH;
gretelai_synthetic_text_to_sql
CREATE TABLE climate_adaptation (region VARCHAR(50), year INT, projects INT); INSERT INTO climate_adaptation (region, year, projects) VALUES ('Africa', 2019, 120), ('Asia', 2019, 150), ('South America', 2019, 100);
How many climate adaptation projects were completed in Africa in 2019?
SELECT projects FROM climate_adaptation WHERE region = 'Africa' AND year = 2019;
gretelai_synthetic_text_to_sql