context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE labor_rights_union (id INT, name VARCHAR(50), gender VARCHAR(50), years_active INT); INSERT INTO labor_rights_union (id, name, gender, years_active) VALUES (1, 'Dana', 'Female', 6), (2, 'Eva', 'Female', 7), (3, 'Fiona', 'Female', 8);
Count the number of female members in the 'labor_rights_union' table who have been active for more than 5 years.
SELECT COUNT(*) FROM labor_rights_union WHERE gender = 'Female' AND years_active > 5;
gretelai_synthetic_text_to_sql
CREATE TABLE menus (menu_id INT, menu_name VARCHAR(50), category VARCHAR(50), price DECIMAL(5,2)); INSERT INTO menus (menu_id, menu_name, category, price) VALUES (1, 'Quinoa Salad', 'Vegetarian', 9.99), (2, 'Margherita Pizza', 'Non-Vegetarian', 12.99), (3, 'Chickpea Curry', 'Vegan', 10.99), (4, 'Tofu Stir Fry', 'Vegan'...
How many non-vegetarian items were sold in March?
SELECT COUNT(*) FROM orders JOIN menus ON orders.menu_id = menus.menu_id WHERE menus.category = 'Non-Vegetarian' AND orders.order_date BETWEEN '2022-03-01' AND '2022-03-31';
gretelai_synthetic_text_to_sql
CREATE TABLE fairness_issues (country VARCHAR(255), issue VARCHAR(255)); INSERT INTO fairness_issues (country, issue) VALUES ('Country7', 'Issue4'); INSERT INTO fairness_issues (country, issue) VALUES ('Country8', 'Issue5'); INSERT INTO fairness_issues (country, issue) VALUES ('Country9', 'Issue6');
What are the most common algorithmic fairness issues in South American countries?
SELECT issue, COUNT(*) as num_countries FROM fairness_issues WHERE country LIKE '%South America%' GROUP BY issue ORDER BY num_countries DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE ticket_sales (ticket_id INT, match_id INT, customer_id INT, country VARCHAR(100), quantity INT); INSERT INTO ticket_sales (ticket_id, match_id, customer_id, country, quantity) VALUES (1, 1, 1, 'South Africa', 50); INSERT INTO ticket_sales (ticket_id, match_id, customer_id, country, quantity) VALUES (2, 1, ...
Identify the top 3 countries with the most ticket sales for a specific rugby match.
SELECT country, SUM(quantity) as total_sales, ROW_NUMBER() OVER (ORDER BY SUM(quantity) DESC) as rank FROM ticket_sales WHERE match_id = 1 GROUP BY country
gretelai_synthetic_text_to_sql
CREATE TABLE Hospitals (id INT, name VARCHAR(100), location VARCHAR(100), beds INT, area_type VARCHAR(50)); INSERT INTO Hospitals VALUES (1, 'Rural General Hospital', 'Smalltown', 50, 'Rural'), (2, 'Mountain View Clinic', 'Mountain Village', 15, 'Rural'), (3, 'Seaside Health Center', 'Coastal City', 25, 'Urban'), (4, '...
What is the total number of hospital beds in rural areas vs urban areas in 'rural_healthcare' schema?
SELECT SUM(beds) FROM Hospitals WHERE area_type = 'Rural'; SELECT SUM(beds) FROM Hospitals WHERE area_type = 'Urban';
gretelai_synthetic_text_to_sql
CREATE TABLE WageData (EmployeeID INT, Sector VARCHAR(20), HourlyWage DECIMAL(10, 2)); INSERT INTO WageData (EmployeeID, Sector, HourlyWage) VALUES (1, 'Finance', 30.00), (2, 'Finance', 35.00), (3, 'Retail', 25.00);
What is the average hourly wage for workers in the 'Finance' sector?
SELECT AVG(HourlyWage) FROM WageData WHERE Sector = 'Finance';
gretelai_synthetic_text_to_sql
CREATE TABLE courts (name VARCHAR(255), cases_handled INT); CREATE TABLE criminal_cases (court_name VARCHAR(255), year INT); INSERT INTO courts (name) VALUES ('Court A'), ('Court B'), ('Court C'), ('Court D'), ('Court E'); INSERT INTO criminal_cases (court_name, year) VALUES ('Court A', 2020), ('Court A', 2020), ('Cour...
What is the total number of criminal cases handled by each court in a year?
SELECT court_name, SUM(1) as total_cases FROM criminal_cases GROUP BY court_name;
gretelai_synthetic_text_to_sql
CREATE TABLE clinical_trials (trial_id INT, drug_name VARCHAR(255), start_date DATE, status VARCHAR(255)); INSERT INTO clinical_trials (trial_id, drug_name, start_date, status) VALUES (1, 'DrugA', '2017-06-01', 'Completed'), (2, 'DrugB', '2018-11-15', 'In Progress'), (3, 'DrugC', '2020-02-20', 'Planned'), (4, 'DrugA', ...
What are the clinical trial start dates for a specific drug?
SELECT drug_name, start_date FROM clinical_trials WHERE drug_name = 'DrugA';
gretelai_synthetic_text_to_sql
CREATE TABLE product_recalls (recall_id INT, product_id INT, recall_date DATE, recall_reason VARCHAR(255)); INSERT INTO product_recalls (recall_id, product_id, recall_date, recall_reason) VALUES (1, 1, '2022-01-01', 'Contamination'), (2, 3, '2021-12-31', 'Expiration'), (3, 2, '2022-02-01', 'Contamination');
How many products have been recalled due to contamination issues in the past year?
SELECT COUNT(*) FROM product_recalls WHERE recall_reason = 'Contamination' AND recall_date >= DATEADD(year, -1, GETDATE());
gretelai_synthetic_text_to_sql
CREATE TABLE Countries (Country VARCHAR(50), Continent VARCHAR(50), Hospital_Beds INT); INSERT INTO Countries (Country, Continent, Hospital_Beds) VALUES ('Kenya', 'Africa', 5000), ('Nigeria', 'Africa', 8000), ('South Africa', 'Africa', 10000);
What is the average number of hospital beds in African countries?
SELECT AVG(Hospital_Beds) FROM Countries WHERE Continent = 'Africa';
gretelai_synthetic_text_to_sql
CREATE TABLE emergency_calls (id INT, neighborhood VARCHAR(20), response_time INT); INSERT INTO emergency_calls (id, neighborhood, response_time) VALUES (1, 'westwood', 120), (2, 'southridge', 150), (3, 'westwood', 110);
What is the average response time for emergency calls in the "westwood" neighborhood?
SELECT AVG(response_time) FROM emergency_calls WHERE neighborhood = 'westwood';
gretelai_synthetic_text_to_sql
CREATE TABLE donors (id INT PRIMARY KEY, name VARCHAR(100), age INT, state VARCHAR(2), income FLOAT);
Insert new record into donors table
INSERT INTO donors (id, name, age, state, income) VALUES (5, 'John Doe', 25, 'NY', 50000.00);
gretelai_synthetic_text_to_sql
CREATE TABLE artists (artist_id INT, artist_name TEXT); CREATE TABLE songs (song_id INT, song_length FLOAT, artist_id INT); INSERT INTO artists VALUES (1, 'Beyoncé'), (2, 'Adele'); INSERT INTO songs VALUES (1, 250.3, 1), (2, 180.2, 2), (3, 300.5, 1);
What is the total duration of songs by the artist 'Beyoncé'?
SELECT SUM(song_length) FROM songs INNER JOIN artists ON songs.artist_id = artists.artist_id WHERE artists.artist_name = 'Beyoncé';
gretelai_synthetic_text_to_sql
CREATE TABLE department (id INT, name VARCHAR(255), manager_id INT, manager_name VARCHAR(255), location VARCHAR(255)); INSERT INTO department (id, name, manager_id, manager_name, location) VALUES (1, 'textiles', 101, 'Eva', 'New York'); INSERT INTO department (id, name, manager_id, manager_name, location) VALUES (2, 'm...
What is the name of the manager for the 'textiles' department?
SELECT manager_name FROM department WHERE name = 'textiles';
gretelai_synthetic_text_to_sql
CREATE TABLE Luxury_Hotels (hotel_id INT, hotel_name VARCHAR(50), rating DECIMAL(2,1)); INSERT INTO Luxury_Hotels (hotel_id, hotel_name, rating) VALUES (1, 'Presidential Palace', 4.9), (2, 'Royal Retreat', 4.8), (3, 'Five-Star Palace', 4.6);
Which hotels in the 'Luxury_Hotels' table have a rating greater than 4.7?
SELECT hotel_id, hotel_name FROM Luxury_Hotels WHERE rating > 4.7;
gretelai_synthetic_text_to_sql
CREATE TABLE Animals (AnimalID INT, Species VARCHAR(20), Habitat VARCHAR(20)); INSERT INTO Animals (AnimalID, Species, Habitat) VALUES (1, 'Grizzly Bear', 'North America'); INSERT INTO Animals (AnimalID, Species, Habitat) VALUES (2, 'Whooping Crane', 'North America'); INSERT INTO Animals (AnimalID, Species, Habitat) VA...
How many animals from endangered species are in the 'North America' habitat?
SELECT COUNT(*) FROM Animals WHERE Species IN (SELECT Species FROM Endangered_Species WHERE Habitat = 'North America');
gretelai_synthetic_text_to_sql
CREATE TABLE sales (sale_id INT, product_id INT, product_category VARCHAR(255), sale_date DATE, quantity INT); CREATE TABLE garments (garment_id INT, product_id INT, garment_name VARCHAR(255));
Find the top 5 best-selling garments by quantity in 2021.
SELECT garments.garment_name, SUM(sales.quantity) as total_quantity FROM sales JOIN garments ON sales.product_id = garments.product_id WHERE sale_date BETWEEN '2021-01-01' AND '2021-12-31' GROUP BY garments.garment_name ORDER BY total_quantity DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE gym_memberships (id INT, member_name VARCHAR(50), start_date DATE, end_date DATE, membership_type VARCHAR(50), price DECIMAL(5,2));
What is the number of members who have extended their membership in the last 3 months?
SELECT COUNT(DISTINCT member_name) AS extended_members FROM gym_memberships WHERE end_date < DATE_SUB(CURDATE(), INTERVAL 3 MONTH) AND DATE_ADD(end_date, INTERVAL 1 MONTH) > CURDATE();
gretelai_synthetic_text_to_sql
CREATE TABLE accessible_tech_orgs (id INT, region VARCHAR(20), budget INT, organizations INT); INSERT INTO accessible_tech_orgs (id, region, budget, organizations) VALUES (1, 'Asia', 200000, 10), (2, 'Europe', 300000, 15), (3, 'Americas', 150000, 5);
How many organizations are working on accessible technology projects in the top 2 regions with the most budget allocated for technology accessibility?
SELECT COUNT(*) FROM (SELECT * FROM accessible_tech_orgs WHERE budget = (SELECT MAX(budget) FROM accessible_tech_orgs) ORDER BY budget DESC LIMIT 2) subquery;
gretelai_synthetic_text_to_sql
CREATE TABLE deliveries (id INT, shipment_id INT, delivery_date DATE, delivery_time_days INT); INSERT INTO deliveries (id, shipment_id, delivery_date, delivery_time_days) VALUES (1, 1, '2021-01-01', 5); INSERT INTO deliveries (id, shipment_id, delivery_date, delivery_time_days) VALUES (2, 2, '2021-01-03', 7);
What is the maximum delivery time in days for shipments from China to Australia in January 2021?
SELECT MAX(delivery_time_days) FROM deliveries D INNER JOIN (SELECT id AS shipment_id FROM shipments WHERE origin_country = 'China' AND destination_country = 'Australia' AND EXTRACT(MONTH FROM ship_date) = 1 AND EXTRACT(YEAR FROM ship_date) = 2021) AS S ON D.shipment_id = S.shipment_id;
gretelai_synthetic_text_to_sql
CREATE TABLE departments (id INT, name TEXT, manager TEXT); INSERT INTO departments (id, name, manager) VALUES (1, 'manufacturing', 'John Doe'), (2, 'research', 'Jane Smith'); CREATE TABLE programs (id INT, name TEXT, department TEXT); INSERT INTO programs (id, name, department) VALUES (1, 'training', 'manufacturing');
Insert a new workforce development program for the 'research' department.
INSERT INTO programs (id, name, department) VALUES (2, 'workforce development', 'research');
gretelai_synthetic_text_to_sql
CREATE TABLE warehouse_receipts (id INT, warehouse_location VARCHAR(50), item_id INT, quantity INT, receive_date DATE); INSERT INTO warehouse_receipts (id, warehouse_location, item_id, quantity, receive_date) VALUES (1, 'Location A', 1001, 30, '2022-02-03'); INSERT INTO warehouse_receipts (id, warehouse_location, item_...
Find the top 3 warehouse locations with the highest total quantity of items received in February 2022.
SELECT warehouse_location, SUM(quantity) AS total_quantity FROM warehouse_receipts WHERE receive_date >= '2022-02-01' AND receive_date < '2022-03-01' GROUP BY warehouse_location ORDER BY total_quantity DESC LIMIT 3;
gretelai_synthetic_text_to_sql
SELECT * FROM AgeByDepartment;
Query the AgeByDepartment view
SELECT * FROM AgeByDepartment;
gretelai_synthetic_text_to_sql
CREATE TABLE volunteers (id INT, name TEXT, hours INT); INSERT INTO volunteers (id, name, hours) VALUES (1, 'Alice', 50), (2, 'Bob', 75), (3, 'Charlie', 100);
Who is the top volunteer by total hours in 2020?
SELECT name FROM volunteers ORDER BY hours DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE ReportedCrimes (ID INT, State VARCHAR(20), Year INT, Crimes INT); INSERT INTO ReportedCrimes (ID, State, Year, Crimes) VALUES (1, 'California', 2019, 1500);
What is the total number of reported crimes in the state of California in 2019?
SELECT SUM(Crimes) FROM ReportedCrimes WHERE State = 'California' AND Year = 2019;
gretelai_synthetic_text_to_sql
CREATE TABLE Policyholders (PolicyholderID INT, Name VARCHAR(50), Address VARCHAR(100), AreaType VARCHAR(10)); INSERT INTO Policyholders (PolicyholderID, Name, Address, AreaType) VALUES (1, 'John Doe', '123 Main St, Springfield', 'Urban'); INSERT INTO Policyholders (PolicyholderID, Name, Address, AreaType) VALUES (2, '...
Find the number of policyholders who live in 'urban' areas and have filed at least one claim.
SELECT COUNT(DISTINCT PolicyholderID) FROM Policyholders P JOIN Claims C ON P.PolicyholderID = C.PolicyholderID WHERE P.AreaType = 'Urban';
gretelai_synthetic_text_to_sql
CREATE TABLE restaurants (id INT, name TEXT, city TEXT, state TEXT, inspection_score INT); INSERT INTO restaurants (id, name, city, state, inspection_score) VALUES (1, 'Restaurant A', 'Dallas', 'TX', 92), (2, 'Restaurant B', 'Austin', 'TX', 88), (3, 'Restaurant C', 'Houston', 'TX', 95);
What is the minimum food safety inspection score for restaurants in Texas?
SELECT MIN(inspection_score) FROM restaurants WHERE state = 'TX';
gretelai_synthetic_text_to_sql
CREATE TABLE Policyholders (PolicyholderID INT, Name VARCHAR(50), Address VARCHAR(100)); CREATE TABLE Claims (ClaimID INT, PolicyholderID INT, ClaimAmount INT); INSERT INTO Policyholders (PolicyholderID, Name, Address) VALUES (1, 'John Doe', '123 Main St, Springfield'); INSERT INTO Policyholders (PolicyholderID, Name, ...
Identify the policyholder with the highest total claim amount.
SELECT PolicyholderID, Name, SUM(ClaimAmount) AS TotalClaimAmount FROM Claims C JOIN Policyholders P ON C.PolicyholderID = P.PolicyholderID GROUP BY PolicyholderID, Name ORDER BY TotalClaimAmount DESC FETCH FIRST 1 ROW ONLY;
gretelai_synthetic_text_to_sql
CREATE TABLE JobVacancies (VacancyID INT, Position VARCHAR(50), Department VARCHAR(50), OpenDate DATE, CloseDate DATE);
What is the average time taken to fill a job vacancy for the IT department?
SELECT AVG(DATEDIFF(CloseDate, OpenDate)) as AvgTimeToFill FROM JobVacancies WHERE Department = 'IT';
gretelai_synthetic_text_to_sql
CREATE TABLE Player (PlayerID INT, Name VARCHAR(50), Country VARCHAR(50), Score INT);
What is the maximum score achieved by players from Europe?
SELECT MAX(Score) FROM Player WHERE Country IN ('Germany', 'France', 'United Kingdom', 'Italy', 'Spain');
gretelai_synthetic_text_to_sql
CREATE TABLE Vehicle (id INT, make VARCHAR(50), model VARCHAR(50), safety_rating FLOAT, country VARCHAR(50));
What was the highest safety rating given to any vehicle manufactured in Italy?
SELECT MAX(safety_rating) FROM Vehicle WHERE country = 'Italy';
gretelai_synthetic_text_to_sql
CREATE TABLE Restaurant (id INT, name VARCHAR(50), cuisine VARCHAR(50), location VARCHAR(50)); INSERT INTO Restaurant (id, name, cuisine, location) VALUES (1, 'Bistro Blanc', 'French', 'New York'); INSERT INTO Restaurant (id, name, cuisine, location) VALUES (2, 'Taqueria Tina', 'Mexican', 'California'); INSERT INTO Res...
What is the total number of vegan and non-vegan dishes for each cuisine?
SELECT m.cuisine, COUNT(CASE WHEN m.vegan = true THEN 1 ELSE NULL END) AS vegan_dishes, COUNT(CASE WHEN m.vegan = false THEN 1 ELSE NULL END) AS non_vegan_dishes FROM Menu_Item m GROUP BY m.cuisine;
gretelai_synthetic_text_to_sql
CREATE TABLE solar_farms (id INT, country VARCHAR(20), capacity FLOAT); INSERT INTO solar_farms (id, country, capacity) VALUES (1, 'United States', 50000.0), (2, 'China', 80000.0), (3, 'Germany', 45000.0), (4, 'India', 30000.0), (5, 'Japan', 25000.0);
List the top 5 countries with the highest solar panel installation capacity.
SELECT country, capacity FROM solar_farms ORDER BY capacity DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE reporters (id INT, city VARCHAR(255), salary DECIMAL(10,2)); INSERT INTO reporters (id, city, salary) VALUES (1, 'Tokyo', 90000.00), (2, 'Sydney', 80000.00), (3, 'Delhi', 75000.00)
What is the average salary for reporters from 'Tokyo' and 'Sydney' in the 'reporters' table?
SELECT AVG(salary) FROM reporters WHERE city IN ('Tokyo', 'Sydney');
gretelai_synthetic_text_to_sql
CREATE TABLE grants (id INT, department VARCHAR(50), amount DECIMAL(10,2), grant_date DATE); INSERT INTO grants (id, department, amount, grant_date) VALUES (1, 'Mechanical Engineering', 25000.00, '2018-01-01'), (2, 'Electrical Engineering', 30000.00, '2019-05-15'), (3, 'Chemical Engineering', 22000.00, '2020-12-31'), (...
What is the total number of research grants received by the College of Engineering in the last 5 years?
SELECT SUM(amount) FROM grants WHERE department LIKE 'Engineering%' AND grant_date >= DATE_SUB(CURDATE(), INTERVAL 5 YEAR);
gretelai_synthetic_text_to_sql
CREATE TABLE customer_purchases (customer_id INT, product_name VARCHAR(50), purchase_date DATE, brand VARCHAR(50), category VARCHAR(50)); INSERT INTO customer_purchases (customer_id, product_name, purchase_date, brand, category) VALUES (1, 'Lipstick', '2021-01-01', 'Lush', 'sustainable'), (2, 'Mascara', '2021-01-05', '...
Show the number of unique customers who have purchased from each beauty brand in the 'sustainable' category, ordered by the total number of customers in descending order.
SELECT brand, COUNT(DISTINCT customer_id) as num_customers FROM customer_purchases WHERE category = 'sustainable' GROUP BY brand ORDER BY num_customers DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE community_health_workers (id INT, name VARCHAR(50), ethnicity VARCHAR(50), state VARCHAR(50), lgbtq_identification BOOLEAN); INSERT INTO community_health_workers (id, name, ethnicity, state, lgbtq_identification) VALUES (1, 'John Doe', 'Cisgender', 'California', TRUE), (2, 'Jane Smith', 'Transgender', 'New...
What is the total number of community health workers who identify as LGBTQ+ and work in states that have implemented mental health parity laws?
SELECT COUNT(*) FROM community_health_workers cw JOIN mental_health_parity_laws mhpl ON cw.state = mhpl.state WHERE cw.lgbtq_identification = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE users (id INT, country VARCHAR(2), followers INT); INSERT INTO users (id, country, followers) VALUES (1, 'US', 1000), (2, 'CA', 1500), (3, 'US', 2000), (4, 'UK', 500), (5, 'UK', 750), (6, 'CA', 2500);
What is the maximum number of followers for users from the UK?
SELECT MAX(users.followers) FROM users WHERE users.country = 'UK';
gretelai_synthetic_text_to_sql
CREATE TABLE ferry_fares (fare_id INT, region_id INT, fare DECIMAL(5,2)); INSERT INTO ferry_fares (fare_id, region_id, fare) VALUES (1, 1, 5.50), (2, 2, 6.25), (3, 3, 5.75), (4, 2, 6.25);
What is the maximum fare for ferries in the 'northeast' region?
SELECT MAX(ff.fare) FROM ferry_fares ff INNER JOIN regions r ON ff.region_id = r.region_id WHERE r.region_name = 'northeast';
gretelai_synthetic_text_to_sql
CREATE TABLE projects (id INT, name TEXT, continent TEXT, start_date DATE, end_date DATE); INSERT INTO projects (id, name, continent, start_date, end_date) VALUES (1, 'Asia Gold', 'Asia', '2015-02-01', NULL), (2, 'Asia Coal', 'Asia', '2016-05-15', '2025-04-30');
How many mining projects in Asia have a start date on or after 2015-01-01 and are still ongoing?
SELECT COUNT(*) FROM projects WHERE continent = 'Asia' AND start_date >= '2015-01-01' AND end_date IS NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE AccommodationCosts (StudentID INT, Region VARCHAR(50), AccommodationCost DECIMAL(10,2));
What is the average accommodation cost per student with a learning disability in each region?
SELECT Region, AVG(AccommodationCost) FROM AccommodationCosts WHERE DisabilityType = 'learning disability' GROUP BY Region;
gretelai_synthetic_text_to_sql
CREATE TABLE InfrastructureBudget (FiscalYear INT, Region VARCHAR(50), Budget FLOAT); INSERT INTO InfrastructureBudget (FiscalYear, Region, Budget) VALUES (2019, 'South America', 1200000.00), (2020, 'South America', 1300000.00);
What is the difference in infrastructure budget between the two most recent fiscal years in South America?
SELECT LAG(Budget, 1) OVER (ORDER BY FiscalYear) - Budget AS BudgetDifference FROM InfrastructureBudget WHERE Region = 'South America' ORDER BY FiscalYear DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE production (element VARCHAR(10), year INT, quantity FLOAT); INSERT INTO production (element, year, quantity) VALUES ('Holmium', 2015, 100), ('Holmium', 2016, 150), ('Holmium', 2017, 200), ('Holmium', 2018, 250), ('Holmium', 2019, 300);
What was the total production of Holmium in 2016 and 2017 combined?
SELECT SUM(quantity) FROM production WHERE element = 'Holmium' AND (year = 2016 OR year = 2017);
gretelai_synthetic_text_to_sql
CREATE TABLE marine_species(id INT, species VARCHAR(255), ocean VARCHAR(255));INSERT INTO marine_species(id, species, ocean) VALUES (1, 'Dolphin', 'Pacific'), (2, 'Shark', 'Atlantic'), (3, 'Tuna', 'Pacific'), (4, 'Whale', 'Atlantic');
How many marine species are present in the Pacific and Atlantic Oceans?
SELECT COUNT(*) FROM marine_species WHERE ocean IN ('Pacific', 'Atlantic') GROUP BY ocean;
gretelai_synthetic_text_to_sql
CREATE TABLE healthcare_union (id INT, name VARCHAR); INSERT INTO healthcare_union (id, name) VALUES (1, 'Grace'); CREATE TABLE technology_union (id INT, name VARCHAR); INSERT INTO technology_union (id, name) VALUES (1, 'Hugh');
List the names of all members who are in the 'healthcare' union but not in the 'technology' union.
SELECT name FROM healthcare_union WHERE name NOT IN (SELECT name FROM technology_union);
gretelai_synthetic_text_to_sql
CREATE TABLE Artists (Artist_ID INT PRIMARY KEY, Name VARCHAR(100), Country VARCHAR(50), Region VARCHAR(50)); INSERT INTO Artists (Artist_ID, Name, Country, Region) VALUES (1, 'Alice', 'Australia', 'Southern'); INSERT INTO Artists (Artist_ID, Name, Country, Region) VALUES (2, 'Bob', 'New Zealand', 'Southern');
How many traditional artists are there in each country?
SELECT Country, COUNT(*) FROM Artists GROUP BY Country;
gretelai_synthetic_text_to_sql
CREATE TABLE safety_incidents (incident_id INT, industry TEXT, incident_date DATE); INSERT INTO safety_incidents (incident_id, industry, incident_date) VALUES (1, 'construction', '2022-01-05'), (2, 'construction', '2022-02-12'), (3, 'retail', '2022-03-20');
How many workplace safety incidents have been reported in the 'construction' industry by month in 2022?
SELECT industry, MONTH(incident_date) AS month, COUNT(*) OVER (PARTITION BY industry, MONTH(incident_date)) FROM safety_incidents WHERE industry = 'construction' AND YEAR(incident_date) = 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE excavations (id INT, location VARCHAR(255)); INSERT INTO excavations (id, location) VALUES (1, 'China'), (2, 'Japan'), (3, 'India');
Show all unique artifact types present in excavation sites from Asia.
SELECT DISTINCT a.artifact_type FROM artifacts a INNER JOIN excavations e ON a.excavation_id = e.id WHERE e.location LIKE 'Asia%';
gretelai_synthetic_text_to_sql
CREATE TABLE artwork (id INT, title VARCHAR(50), year INT, artist_id INT, medium VARCHAR(50));
How many pieces of artwork are there in the 'artwork' table for each medium type?
SELECT medium, COUNT(*) FROM artwork GROUP BY medium;
gretelai_synthetic_text_to_sql
CREATE TABLE mining_operations (id INT, name TEXT, location TEXT, water_consumption FLOAT, ore_production FLOAT); INSERT INTO mining_operations VALUES (1, 'Mine A', 'Country X', 100000, 50000), (2, 'Mine B', 'Country Y', 120000, 60000);
Find the top 5 mining operations with the highest water consumption per ton of ore.
SELECT name, water_consumption/ore_production as water_consumption_per_ton_ore FROM mining_operations ORDER BY water_consumption_per_ton_ore DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE cases (id INT, case_type VARCHAR(10), case_outcome VARCHAR(10));
What is the percentage of cases lost by the defense?
SELECT (COUNT(*) FILTER (WHERE case_type = 'defense' AND case_outcome = 'lost')) * 100.0 / COUNT(*) AS percentage_of_lost_cases FROM cases WHERE case_type = 'defense';
gretelai_synthetic_text_to_sql
CREATE TABLE Accommodations (AccommodationID INT, AccommodationType VARCHAR(255), State VARCHAR(255)); INSERT INTO Accommodations (AccommodationID, AccommodationType, State) VALUES (1, 'Sign Language Interpreter', 'California'), (2, 'Assistive Listening Devices', 'Texas');
What is the total number of accommodations provided, per state, for a specific type of accommodation?
SELECT State, AccommodationType, COUNT(*) as Total FROM Accommodations WHERE AccommodationType = 'Sign Language Interpreter' GROUP BY State, AccommodationType;
gretelai_synthetic_text_to_sql
CREATE TABLE YearlyRevenue(id INT, genre VARCHAR(10), region VARCHAR(10), revenue FLOAT, year INT);
What is the yearly growth rate in revenue for the "hip-hop" genre in the Asian region?
SELECT (SUM(revenue) OVER (PARTITION BY genre ORDER BY year ROWS BETWEEN 1 FOLLOWING AND UNBOUNDED FOLLOWING) - SUM(revenue))/SUM(revenue) OVER (PARTITION BY genre) AS yearly_growth_rate FROM YearlyRevenue WHERE genre = 'hip-hop' AND region = 'Asian';
gretelai_synthetic_text_to_sql
CREATE TABLE DiversityScores (BrandID INT, DiversityScore INT);
Which fashion brands have the highest and lowest diversity scores for their product sizes?
SELECT FB.BrandName, DS.DiversityScore FROM FashionBrands FB INNER JOIN DiversityScores DS ON FB.BrandID = DS.BrandID ORDER BY DS.DiversityScore ASC, FB.BrandName ASC;
gretelai_synthetic_text_to_sql
CREATE TABLE MilitaryEquipmentSales (equipment_id INT, region VARCHAR(50), sale_date DATE); INSERT INTO MilitaryEquipmentSales (equipment_id, region, sale_date) VALUES (1, 'Middle East', '2015-01-01'), (2, 'South America', '2016-03-04');
Which military equipment was sold in the Middle East and South America between 2015 and 2018?
SELECT * FROM MilitaryEquipmentSales WHERE region IN ('Middle East', 'South America') AND sale_date BETWEEN '2015-01-01' AND '2018-12-31'
gretelai_synthetic_text_to_sql
CREATE TABLE military_equipment (equipment_id INT PRIMARY KEY, equipment_type VARCHAR(255), last_maintenance_date DATE, equipment_status VARCHAR(255));
Delete records from the 'military_equipment' table where 'equipment_type' is 'aircraft' and 'last_maintenance_date' is older than 2020-01-01
DELETE FROM military_equipment WHERE equipment_type = 'aircraft' AND last_maintenance_date < '2020-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE Sales (SaleID INT, SaleName TEXT, Year INT, Region TEXT, Revenue DECIMAL(10,2)); INSERT INTO Sales (SaleID, SaleName, Year, Region, Revenue) VALUES (1, 'Dubai Art Fair', 2018, 'Middle East', 2500000); INSERT INTO Sales (SaleID, SaleName, Year, Region, Revenue) VALUES (2, 'Abu Dhabi Art Auction', 2019, 'Mid...
What is the total revenue generated by private art sales in the Middle East by year?
SELECT Year, SUM(Revenue) as TotalRevenue FROM Sales WHERE Region = 'Middle East' AND Type = 'Private' GROUP BY Year;
gretelai_synthetic_text_to_sql
CREATE SCHEMA if not exists genetics;CREATE TABLE if not exists genetics.research_projects (id INT PRIMARY KEY, researcher_id INT, name VARCHAR(255), start_date DATE, end_date DATE); INSERT INTO genetics.research_projects (id, researcher_id, name, start_date, end_date) VALUES (1, 1, 'ProjectA', '2021-01-01', '2021-06-3...
What is the maximum genetic research project duration per researcher, ordered by duration?
SELECT researcher_id, MAX(end_date - start_date) AS max_duration FROM genetics.research_projects GROUP BY researcher_id ORDER BY max_duration DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE mls_players (player_id INT, name VARCHAR(50), team VARCHAR(50), points INT); INSERT INTO mls_players (player_id, name, team, points) VALUES (1, 'Carlos Vela', 'Los Angeles FC', 40); INSERT INTO mls_players (player_id, name, team, points) VALUES (2, 'Josef Martinez', 'Atlanta United', 35);
What is the total number of points scored by each soccer player in the MLS?
SELECT name, SUM(points) FROM mls_players GROUP BY name;
gretelai_synthetic_text_to_sql
CREATE TABLE offshore_rigs (rig_id INT, rig_name TEXT, location TEXT); INSERT INTO offshore_rigs (rig_id, rig_name, location) VALUES (1, 'Rig A', 'North Sea'), (2, 'Rig B', 'North Sea'); CREATE TABLE production (prod_id INT, rig_id INT, oil_prod INT, gas_prod INT); INSERT INTO production (prod_id, rig_id, oil_prod, gas...
What are the total oil production figures for offshore rigs in the North Sea?
SELECT SUM(oil_prod) FROM production JOIN offshore_rigs ON production.rig_id = offshore_rigs.rig_id WHERE offshore_rigs.location = 'North Sea';
gretelai_synthetic_text_to_sql
CREATE TABLE Products(id INT, name TEXT, material TEXT, is_sustainable BOOLEAN); INSERT INTO Products(id, name, material, is_sustainable) VALUES (1, 'Shirt', 'Polyester', false), (2, 'Pants', 'Hemp', true);
Update the records where 'Polyester' is mislabeled as sustainable to 'not sustainable'?
UPDATE Products SET is_sustainable = false WHERE material = 'Polyester';
gretelai_synthetic_text_to_sql
CREATE TABLE product_reviews (product_id INT, brand VARCHAR(50), launch_date DATE, rating FLOAT); INSERT INTO product_reviews (product_id, brand, launch_date, rating) VALUES (1, 'Loreal', '2021-01-01', 4.2), (2, 'Garnier', '2021-03-15', 3.9), (3, 'Loreal', '2021-07-01', 4.5);
What is the average rating of beauty products launched in 2021, grouped by brand?
SELECT brand, AVG(rating) as avg_rating FROM (SELECT brand, rating, ROW_NUMBER() OVER (PARTITION BY brand ORDER BY launch_date) as rn FROM product_reviews WHERE EXTRACT(YEAR FROM launch_date) = 2021) t WHERE rn = 1 GROUP BY brand;
gretelai_synthetic_text_to_sql
CREATE TABLE buildings (id INT, country VARCHAR(255), city VARCHAR(255), certification VARCHAR(255)); INSERT INTO buildings (id, country, city, certification) VALUES (1, 'USA', 'New York', 'LEED Platinum'), (2, 'Canada', 'Toronto', 'LEED Gold');
What is the number of LEED Platinum and Gold buildings in each country?
SELECT country, SUM(CASE WHEN certification = 'LEED Platinum' THEN 1 ELSE 0 END) as platinum, SUM(CASE WHEN certification = 'LEED Gold' THEN 1 ELSE 0 END) as gold FROM buildings GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE MarineLife (id INT PRIMARY KEY, species VARCHAR(255), population INT, country VARCHAR(255));
Show all the unique countries in the 'MarineLife' table
SELECT DISTINCT country FROM MarineLife;
gretelai_synthetic_text_to_sql
CREATE TABLE space_agencies_2 (agency VARCHAR(50), country VARCHAR(50), launches INTEGER); INSERT INTO space_agencies_2 (agency, country, launches) VALUES ('NASA', 'USA', 228), ('Soviet Union', 'Russia', 182), ('ESA', 'Europe', 105), ('ISRO', 'India', 105), ('CNSA', 'China', 64);
How many spacecraft were launched by each space agency?
SELECT agency, launches FROM space_agencies_2;
gretelai_synthetic_text_to_sql
CREATE TABLE wastewater(county VARCHAR(20), year INT, volume INT); INSERT INTO wastewater(county, year, volume) VALUES ('Miami-Dade', 2015, 1000), ('Miami-Dade', 2016, 1200), ('Miami-Dade', 2017, 1500), ('Miami-Dade', 2018, 1800), ('Los Angeles', 2015, 1200), ('Los Angeles', 2016, 1400), ('Los Angeles', 2017, 1600), ('...
Delete all the wastewater records for the county of Miami-Dade in 2017.
DELETE FROM wastewater WHERE county = 'Miami-Dade' AND year = 2017;
gretelai_synthetic_text_to_sql
CREATE TABLE education (id INT PRIMARY KEY, program_name VARCHAR(50), location VARCHAR(50), start_date DATE, end_date DATE);
Update the end date of the community education program with id 2 to '2023-12-31'
UPDATE education SET end_date = '2023-12-31' WHERE id = 2;
gretelai_synthetic_text_to_sql
CREATE TABLE crypto_assets (asset_id INT, asset_name VARCHAR(50), blockchain_id INT, daily_transactions INT); INSERT INTO crypto_assets (asset_id, asset_name, blockchain_id, daily_transactions) VALUES (1, 'Solana Token', 2, 10000); INSERT INTO crypto_assets (asset_id, asset_name, blockchain_id, daily_transactions) VALU...
List the names and daily transaction counts of all digital assets on the 'Solana' blockchain.
SELECT crypto_assets.asset_name, crypto_assets.daily_transactions FROM crypto_assets INNER JOIN blockchains ON crypto_assets.blockchain_id = blockchains.blockchain_id WHERE blockchains.blockchain_name = 'Solana';
gretelai_synthetic_text_to_sql
CREATE TABLE impact (id INT PRIMARY KEY, site_id INT, impact_score INT);
Update environmental impact score for site 4
UPDATE impact SET impact_score = 85 WHERE site_id = 4;
gretelai_synthetic_text_to_sql
CREATE TABLE union_members (member_id INT, gender VARCHAR(6)); INSERT INTO union_members (member_id, gender) VALUES (1, 'Female'), (2, 'Male'), (3, 'Female');
What is the total number of union members by gender?
SELECT gender, COUNT(*) as num_members FROM union_members GROUP BY gender;
gretelai_synthetic_text_to_sql
CREATE TABLE digital_assets_market_cap (asset_name TEXT, market_cap FLOAT); INSERT INTO digital_assets_market_cap (asset_name, market_cap) VALUES ('Bitcoin', 1000000), ('Ethereum', 500000), ('Binance Coin', 200000), ('Cardano', 150000), ('Ripple', 100000), ('Polkadot', 80000);
What is the distribution of digital assets by market capitalization?
SELECT asset_name, market_cap FROM digital_assets_market_cap;
gretelai_synthetic_text_to_sql
CREATE TABLE factories(factory_id INT, name TEXT, location TEXT); CREATE TABLE ethical_manufacturing(factory_id INT, worker_count INT);
What is the total number of workers employed in ethical manufacturing?
SELECT SUM(em.worker_count) as total_workers FROM factories f JOIN ethical_manufacturing em ON f.factory_id = em.factory_id;
gretelai_synthetic_text_to_sql
CREATE TABLE intelligence_agencies (agency_id SERIAL PRIMARY KEY, agency_name TEXT, region TEXT, established_year INT);
Insert a new record into 'intelligence_agencies' table with 'agency_name' as 'Servicio de Inteligencia Nacional', 'region' as 'South America', and 'established_year' as 1960
INSERT INTO intelligence_agencies (agency_name, region, established_year) VALUES ('Servicio de Inteligencia Nacional', 'South America', 1960);
gretelai_synthetic_text_to_sql
CREATE TABLE animals (id INT, name VARCHAR(50), species VARCHAR(50), adoption_rate FLOAT); INSERT INTO animals (id, name, species, adoption_rate) VALUES (1, 'Tiger', 'Feline', 0.15); INSERT INTO animals (id, name, species, adoption_rate) VALUES (2, 'Panda', 'Bear', 0.20);
What is the adoption rate for 'Tigers' in the last 6 months?
SELECT adoption_rate as tiger_adoption_rate FROM animals WHERE species = 'Tiger';
gretelai_synthetic_text_to_sql
CREATE TABLE tours (id INT, name TEXT, city TEXT, rating FLOAT); INSERT INTO tours (id, name, city, rating) VALUES (1, 'Eiffel Tower Tour', 'Paris', 4.8), (2, 'Louvre Museum Tour', 'Paris', 4.7), (3, 'Notre Dame Tour', 'Paris', 4.6);
What is the name of the top-rated virtual tour in Paris?
SELECT name FROM tours WHERE city = 'Paris' AND rating = (SELECT MAX(rating) FROM tours WHERE city = 'Paris');
gretelai_synthetic_text_to_sql
CREATE TABLE investigative_projects (id INT, title VARCHAR(255), reporter_id INT, status VARCHAR(20), start_date DATE, end_date DATE); INSERT INTO investigative_projects (id, title, reporter_id, status, start_date, end_date) VALUES (1, 'The Secret Investigation', 1, 'In Progress', '2021-09-01', '2022-08-31'); INSERT IN...
What are the completed investigative projects that ended before December 2021?
SELECT * FROM investigative_projects WHERE status = 'Completed' AND end_date < '2021-12-31';
gretelai_synthetic_text_to_sql
CREATE TABLE indian_ocean (id INT, name VARCHAR(100), region VARCHAR(50)); CREATE TABLE deep_sea_species (id INT, name VARCHAR(100), species_type VARCHAR(50), discovery_year INT, ocean_id INT); INSERT INTO indian_ocean (id, name, region) VALUES (1, 'Indian Ocean', 'Indian'); INSERT INTO deep_sea_species (id, name, spec...
How many deep-sea species have been discovered in the Indian Ocean since 2010?
SELECT COUNT(*) FROM deep_sea_species dss WHERE dss.ocean_id = (SELECT id FROM indian_ocean WHERE name = 'Indian Ocean') AND discovery_year >= 2010;
gretelai_synthetic_text_to_sql
CREATE TABLE garment_sizes (id INT PRIMARY KEY, garment_type VARCHAR(255), size VARCHAR(50), quantity INT); INSERT INTO garment_sizes (id, garment_type, size, quantity) VALUES (1, 'T-shirts', 'Small', 50), (2, 'T-shirts', 'Medium', 75), (3, 'T-shirts', 'Large', 100), (4, 'T-shirts', 'X-large', 25), (5, 'Pants', 'Small'...
Calculate the total quantity of each garment type and its average size.
SELECT garment_type, SUM(quantity) AS total_quantity, AVG(size) AS avg_size FROM garment_sizes GROUP BY garment_type;
gretelai_synthetic_text_to_sql
CREATE TABLE movie (movie_id INT, title VARCHAR(100), studio_id INT, genre VARCHAR(50), budget INT); INSERT INTO movie (movie_id, title, studio_id, genre, budget) VALUES (1, 'The Lost Empire', 1, 'Action', 30000000);
Delete the movie 'The Lost Empire' from the database.
DELETE FROM movie WHERE title = 'The Lost Empire';
gretelai_synthetic_text_to_sql
CREATE TABLE athletes (athlete_id INT, name VARCHAR(50), sport VARCHAR(50)); INSERT INTO athletes (athlete_id, name, sport) VALUES (1, 'Michael Phelps', 'Swimming'), (2, 'Usain Bolt', 'Athletics'), (3, 'Simone Biles', 'Gymnastics'); INSERT INTO athletes (athlete_id, name, sport) VALUES (4, 'Nadia Comăneci', 'Gymnastics...
Which athletes have won medals in more than one sport?
SELECT name FROM athletes GROUP BY name HAVING COUNT(DISTINCT sport) > 1;
gretelai_synthetic_text_to_sql
CREATE TABLE illinois_water_usage (id INT, building_type VARCHAR(20), water_consumption FLOAT, day VARCHAR(10)); INSERT INTO illinois_water_usage (id, building_type, water_consumption, day) VALUES (1, 'Residential', 800, 'Monday'), (2, 'Residential', 1000, 'Tuesday');
What is the minimum daily water consumption for residential buildings in Illinois?
SELECT MIN(water_consumption) FROM illinois_water_usage WHERE building_type = 'Residential';
gretelai_synthetic_text_to_sql
CREATE TABLE companies (id INT, name TEXT, region TEXT, founding_year INT, founder_immigrant BOOLEAN); INSERT INTO companies (id, name, region, founding_year, founder_immigrant) VALUES (1, 'Acme Inc', 'Silicon Valley', 2010, true); INSERT INTO companies (id, name, region, founding_year, founder_immigrant) VALUES (2, 'B...
Which regions have the highest number of startups founded by immigrants?
SELECT region, COUNT(*) as company_count FROM companies WHERE founder_immigrant = true GROUP BY region ORDER BY company_count DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE traffic_cases (case_id INT, case_type VARCHAR(255), severity VARCHAR(255), resolution VARCHAR(255), case_year INT, court_district INT); INSERT INTO traffic_cases (case_id, case_type, severity, resolution, case_year, court_district) VALUES (1, 'Speeding', 'Minor', 'Warning', 2020, 1), (2, 'Reckless Driving'...
What is the number of traffic violation cases by type, severity, and resolution, for a specific district court in the last 3 years?
SELECT case_type, severity, resolution, case_year, COUNT(*) as num_cases FROM traffic_cases WHERE court_district = 1 AND case_year BETWEEN 2019 AND 2021 GROUP BY case_type, severity, resolution, case_year;
gretelai_synthetic_text_to_sql
CREATE TABLE Maintenance (id INT, equipment VARCHAR(255), date DATE, labor INT, parts INT); INSERT INTO Maintenance (id, equipment, date, labor, parts) VALUES (1, 'Tank', '2020-01-05', 500, 200), (2, 'Humvee', '2020-01-10', 300, 150), (3, 'Helicopter', '2020-02-15', 700, 300), (4, 'Airplane', '2020-03-20', 800, 400);
Delete all equipment maintenance records related to aircraft.
DELETE FROM Maintenance WHERE equipment = 'Airplane';
gretelai_synthetic_text_to_sql
CREATE TABLE recycling_facilities (id INT, waste_generated DECIMAL, region VARCHAR(20)); INSERT INTO recycling_facilities (id, waste_generated, region) VALUES (1, 2500.00, 'North America'), (2, 3000.00, 'North America'), (3, 3500.00, 'North America');
Calculate the total waste generated in recycling facilities in North America.
SELECT SUM(waste_generated) FROM recycling_facilities WHERE region = 'North America';
gretelai_synthetic_text_to_sql
CREATE TABLE waste_reduction (id INT PRIMARY KEY, initiative_name VARCHAR(255), reduction_percentage DECIMAL(5,2), start_date DATE, end_date DATE); INSERT INTO waste_reduction (id, initiative_name, reduction_percentage, start_date, end_date) VALUES (1, 'Waste Sorting', 12.5, '2020-01-01', '2020-12-31');
What is the average reduction percentage for each waste reduction initiative?
SELECT initiative_name, AVG(reduction_percentage) FROM waste_reduction GROUP BY initiative_name;
gretelai_synthetic_text_to_sql
CREATE TABLE community_engagement (id INT, location VARCHAR(20), event_date DATE); INSERT INTO community_engagement (id, location, event_date) VALUES (1, 'Africa', '2022-01-15'), (2, 'Africa', '2022-02-20'), (3, 'Africa', '2022-07-10');
How many community engagement events occurred in Africa in the last 6 months?
SELECT COUNT(*) FROM community_engagement WHERE location = 'Africa' AND event_date >= DATEADD(month, -6, GETDATE());
gretelai_synthetic_text_to_sql
CREATE TABLE RoadProjects (id INT, name TEXT, city TEXT, budget DECIMAL(10,2), completionDate DATE);
What is the total number of road projects in the city of Chicago with a budget over $5 million that were completed in the last 3 years?
SELECT city, COUNT(*) FROM RoadProjects WHERE city = 'Chicago' AND budget > 5000000 AND completionDate >= DATE_SUB(CURRENT_DATE, INTERVAL 3 YEAR) GROUP BY city;
gretelai_synthetic_text_to_sql
CREATE TABLE donations_3 (program VARCHAR(255), donor VARCHAR(255), donation FLOAT); INSERT INTO donations_3 (program, donor, donation) VALUES ('Music Education', 'Jane Doe', 120), ('Music Education', 'John Smith', 150), ('Music Education', 'Jane Doe', 200);
What was the average donation amount from donors in the "Music Education" program who donated more than $100?
SELECT AVG(donation) FROM donations_3 WHERE program = 'Music Education' AND donation > 100;
gretelai_synthetic_text_to_sql
CREATE SCHEMA socialmedia; CREATE TABLE ads(user_id INT, country VARCHAR(2), revenue FLOAT, transaction_date DATE); INSERT INTO ads (user_id, country, revenue, transaction_date) VALUES (1, 'US', 100, '2022-01-01'); INSERT INTO ads (user_id, country, revenue, transaction_date) VALUES (2, 'CA', 150, '2022-01-02');
What was the total revenue generated from users in the US and Canada for Q1 2022?
SELECT SUM(revenue) FROM socialmedia.ads WHERE country IN ('US', 'CA') AND transaction_date BETWEEN '2022-01-01' AND '2022-03-31';
gretelai_synthetic_text_to_sql
CREATE TABLE Infectious_Diseases (Year INT, Region VARCHAR(50), Disease VARCHAR(50)); INSERT INTO Infectious_Diseases (Year, Region, Disease) VALUES (2020, 'North America', 'Influenza'), (2020, 'South America', 'Zika'), (2020, 'Africa', 'Ebola'), (2020, 'Europe', 'Tuberculosis'), (2020, 'Asia', 'SARS');
How many infectious diseases were reported in each region in 2020?
SELECT Region, COUNT(DISTINCT Disease) FROM Infectious_Diseases WHERE Year = 2020 GROUP BY Region;
gretelai_synthetic_text_to_sql
CREATE TABLE drug_approvals (drug_name VARCHAR(50), approval_date DATE, region VARCHAR(50)); CREATE TABLE sales_data (drug_name VARCHAR(50), year INT, sales_figure INT); INSERT INTO drug_approvals (drug_name, approval_date, region) VALUES ('DrugA', '2015-04-01', 'EU'), ('DrugB', '2016-08-15', 'EU'), ('DrugC', '2017-12-...
List all drugs that were approved for sale in the EU between 2015 and 2017, along with their sales figures in the first year after approval.
SELECT a.drug_name, YEAR(a.approval_date) + 1 AS first_year_sales, b.sales_figure FROM drug_approvals a INNER JOIN sales_data b ON a.drug_name = b.drug_name WHERE a.region = 'EU' AND b.year = (SELECT MIN(year) FROM sales_data WHERE drug_name = b.drug_name AND year > YEAR(a.approval_date));
gretelai_synthetic_text_to_sql
CREATE TABLE employees (id INT PRIMARY KEY, name VARCHAR(50), role VARCHAR(50), region VARCHAR(50), salary INT);
Insert new records for employees in the "Northwest" region with the following names, roles, and salaries: "John Doe", "Manager", 80000; "Jane Smith", "Assistant Manager", 60000.
INSERT INTO employees (name, role, region, salary) VALUES ('John Doe', 'Manager', 'Northwest', 80000), ('Jane Smith', 'Assistant Manager', 'Northwest', 60000);
gretelai_synthetic_text_to_sql
CREATE TABLE Wave_Data (wave_date date, wave_height numeric, wave_location text);
What is the average wave height in the North Sea in the winter months?
SELECT AVG(wave_height) FROM Wave_Data WHERE wave_location LIKE '%North Sea%' AND EXTRACT(MONTH FROM wave_date) IN (12, 1, 2);
gretelai_synthetic_text_to_sql
CREATE TABLE customers (id INT, name VARCHAR(50), region VARCHAR(50)); INSERT INTO customers (id, name, region) VALUES (1, 'John Smith', 'Southeast'), (2, 'Jane Doe', 'Northeast'), (3, 'Bob Johnson', 'Southeast'), (4, 'Alex Brown', 'Central'), (5, 'Karen Green', 'Central'), (6, 'Michael Lee', 'Northwest'), (7, 'Sarah C...
What is the total number of customers in each region?
SELECT region, COUNT(*) FROM customers GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE fire_incidents (id INT, incident_time TIMESTAMP, district VARCHAR(20)); INSERT INTO fire_incidents (id, incident_time, district) VALUES (1, '2022-02-01 12:30:00', 'downtown'), (2, '2022-02-01 15:10:00', 'north'), (3, '2022-02-01 09:45:00', 'downtown');
What is the minimum response time for fire incidents in the 'downtown' district?
SELECT MIN(EXTRACT(EPOCH FROM incident_time - LAG(incident_time) OVER (PARTITION BY district ORDER BY incident_time))) AS min_response_time FROM fire_incidents WHERE district = 'downtown';
gretelai_synthetic_text_to_sql
CREATE TABLE galleries (id INT, name TEXT, location TEXT, city TEXT, state TEXT, zip INT); INSERT INTO galleries (id, name, location, city, state, zip) VALUES (1, 'Gallery A', 'Arts District', 'Los Angeles', 'CA', 90001); CREATE TABLE artists (id INT, name TEXT, age INT, gallery_id INT); INSERT INTO artists (id, name, ...
What is the minimum age of artists who have exhibited in galleries located in the Arts District?
SELECT MIN(age) FROM artists JOIN galleries ON artists.gallery_id = galleries.id WHERE galleries.location = 'Arts District';
gretelai_synthetic_text_to_sql
CREATE TABLE Artists (ArtistID INT, ArtistName VARCHAR(255), Genre VARCHAR(50)); CREATE TABLE Albums (AlbumID INT, AlbumName VARCHAR(255), Sales INT, ArtistID INT);
Identify the music genres with the lowest number of unique artists and their total album sales.
SELECT A.Genre, COUNT(DISTINCT A.ArtistName) AS Artists_Count, SUM(Albums.Sales) AS Total_Sales FROM Artists A INNER JOIN (SELECT ArtistID, COUNT(DISTINCT ArtistID) FROM Artists GROUP BY Genre HAVING COUNT(DISTINCT ArtistID) = (SELECT MIN(ArtistCount) FROM (SELECT COUNT(DISTINCT ArtistID) AS ArtistCount FROM Artists GR...
gretelai_synthetic_text_to_sql
CREATE TABLE ManufacturingProcesses (country VARCHAR(50), sustainable_material_use DECIMAL(3,2));
Which countries have the highest and lowest use of sustainable materials in their manufacturing processes?
SELECT country, sustainable_material_use FROM (SELECT country, sustainable_material_use, RANK() OVER (ORDER BY sustainable_material_use DESC) as rank FROM ManufacturingProcesses) AS subquery WHERE rank = 1 OR rank = (SELECT COUNT(*) FROM ManufacturingProcesses) ORDER BY rank;
gretelai_synthetic_text_to_sql
CREATE TABLE streams (id INT, track_id INT, date DATE, views INT, genre VARCHAR(255), platform VARCHAR(255)); INSERT INTO streams (id, track_id, date, views, genre, platform) VALUES (1, 1, '2022-01-01', 10000, 'Hip-Hop', 'Pandora');
What is the total number of streams for hip-hop music on Pandora in Q1 2022?
SELECT SUM(views) FROM streams WHERE genre = 'Hip-Hop' AND platform = 'Pandora' AND YEAR(date) = 2022 AND QUARTER(date) = 1;
gretelai_synthetic_text_to_sql