context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE hospitals (id INT, state CHAR(2), num_beds INT, rural BOOLEAN); INSERT INTO hospitals (id, state, num_beds, rural) VALUES (1, 'IL', 50, true), (2, 'CA', 100, false);
What is the percentage of rural hospitals in each state with less than 50 beds?
SELECT state, ROUND(100.0 * COUNT(*) / SUM(COUNT(*)) OVER (), 2) as pct FROM hospitals WHERE rural = true AND num_beds < 50 GROUP BY state;
gretelai_synthetic_text_to_sql
CREATE TABLE LandfillData (Country VARCHAR(50), Continent VARCHAR(50), LandfillCapacity INT, Year INT); INSERT INTO LandfillData (Country, Continent, LandfillCapacity, Year) VALUES ('China', 'Asia', 12345, 2015), ('China', 'Asia', 12500, 2016), ('India', 'Asia', 6789, 2015), ('India', 'Asia', 6850, 2016);
Calculate the annual change in landfill capacity for the top 2 countries in Asia with the largest capacity, starting from the earliest year reported.
SELECT LandfillData1.Country, LandfillData1.Year, LandfillData1.LandfillCapacity - LandfillData2.LandfillCapacity AS CapacityDifference FROM LandfillData LandfillData1 JOIN LandfillData LandfillData2 ON LandfillData1.Country = LandfillData2.Country AND LandfillData1.Year = LandfillData2.Year + 1 WHERE (SELECT COUNT(*) FROM LandfillData LandfillData2 WHERE LandfillData1.Country = LandfillData2.Country AND LandfillData1.LandfillCapacity < LandfillData2.LandfillCapacity) = 0 AND ROW_NUMBER() OVER (PARTITION BY LandfillData1.Country ORDER BY LandfillData1.Year) <= 2;
gretelai_synthetic_text_to_sql
CREATE TABLE donations (id INT, donor_size VARCHAR(10), cause_area VARCHAR(20), amount INT); INSERT INTO donations (id, donor_size, cause_area, amount) VALUES (1, 'large', 'health', 12000);
Delete records of donations greater than $10,000 in the 'health' cause area.
DELETE FROM donations WHERE amount > 10000 AND cause_area = 'health';
gretelai_synthetic_text_to_sql
CREATE TABLE fair_trade_products (product_id INT, region VARCHAR(20), revenue DECIMAL(10,2));CREATE TABLE europe_region (region VARCHAR(20)); INSERT INTO europe_region (region) VALUES ('Western Europe'), ('Eastern Europe');
What is the total revenue generated from fair trade products in the European region?
SELECT SUM(revenue) FROM fair_trade_products WHERE region IN (SELECT region FROM europe_region);
gretelai_synthetic_text_to_sql
CREATE TABLE Service_Requests(City VARCHAR(20), Service VARCHAR(20), Request_Date DATE); INSERT INTO Service_Requests(City, Service, Request_Date) VALUES('Toronto', 'Waste Collection', '2022-01-01'); INSERT INTO Service_Requests(City, Service, Request_Date) VALUES('Toronto', 'Street Lighting', '2022-02-01'); INSERT INTO Service_Requests(City, Service, Request_Date) VALUES('Montreal', 'Waste Collection', '2022-03-01'); INSERT INTO Service_Requests(City, Service, Request_Date) VALUES('Montreal', 'Street Lighting', '2022-04-01');
How many street lighting repair requests were made in each city?
SELECT City, COUNT(*) FROM Service_Requests WHERE Service = 'Street Lighting' GROUP BY City;
gretelai_synthetic_text_to_sql
CREATE TABLE menu_items (menu_id INT, cuisine VARCHAR(255), calorie_count INT);
List the top 5 cuisine types with the highest average calorie intake in the 'menu_items' table, excluding meals with less than 500 calories?
SELECT cuisine, AVG(calorie_count) as avg_calories FROM menu_items WHERE calorie_count >= 500 GROUP BY cuisine ORDER BY AVG(calorie_count) DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE SpaceMissions(ID INT, AstronautID INT, MissionID INT);
Who are the astronauts who have flown more than one space mission?
SELECT AstronautID FROM SpaceMissions GROUP BY AstronautID HAVING COUNT(DISTINCT MissionID) > 1;
gretelai_synthetic_text_to_sql
CREATE TABLE renewable_projects (id INT, name TEXT, location TEXT, capacity INT);
Find the total installed capacity of renewable energy projects in Texas
SELECT SUM(capacity) FROM renewable_projects WHERE location = 'Texas';
gretelai_synthetic_text_to_sql
CREATE TABLE green_building_certifications (certification_name TEXT, points INTEGER);
List all Green Building certifications and their corresponding points from the 'green_building_certifications' table.
SELECT certification_name, points FROM green_building_certifications;
gretelai_synthetic_text_to_sql
CREATE TABLE country (id INT, name VARCHAR(255)); CREATE TABLE dapps (id INT, country_id INT, name VARCHAR(255)); INSERT INTO country (id, name) VALUES (1, 'USA'), (2, 'China'), (3, 'Japan'); INSERT INTO dapps (id, country_id, name) VALUES (1, 1, 'DApp1'), (2, 1, 'DApp2'), (3, 2, 'DApp3'), (4, 3, 'DApp4'), (5, 3, 'DApp5');
How many decentralized applications are registered in each country?
SELECT country.name AS Country, COUNT(dapps.id) AS Registered_DApps FROM country JOIN dapps ON country.id = dapps.country_id GROUP BY country.name;
gretelai_synthetic_text_to_sql
CREATE TABLE students (id INT, name VARCHAR(50), department VARCHAR(50)); CREATE TABLE papers (id INT, student_id INT, title VARCHAR(100)); INSERT INTO students VALUES (1, 'Dana', 'Arts'), (2, 'Ella', 'Arts'), (3, 'Finn', 'Arts'); INSERT INTO papers VALUES (1, 1, 'Paper with justice'), (2, 1, 'Paper without justice'), (3, 2, 'Another paper with justice'), (4, 3, 'Paper without justice');
List the graduate students in the College of Arts who have published papers with the word 'justice' in the title.
SELECT students.id, students.name FROM students INNER JOIN papers ON students.id = papers.student_id WHERE title LIKE '%justice%';
gretelai_synthetic_text_to_sql
CREATE TABLE nitrogen_data (location VARCHAR(255), date DATE, nitrogen FLOAT); INSERT INTO nitrogen_data (location, date, nitrogen) VALUES ('Iowa Corn Field 1', '2021-06-01', 135.6), ('Iowa Corn Field 1', '2021-06-02', 132.7), ('Iowa Corn Field 2', '2021-06-01', 118.5);
What is the percentage of corn fields in Iowa that have a nitrogen level below 120 ppm, based on IoT sensor data?
SELECT 100.0 * COUNT(*) / (SELECT COUNT(*) FROM nitrogen_data WHERE location LIKE '%Iowa Corn Field%') FROM nitrogen_data WHERE nitrogen < 120.0 AND location LIKE '%Iowa Corn Field%';
gretelai_synthetic_text_to_sql
CREATE TABLE hotels (hotel_id INT, name TEXT, category TEXT); INSERT INTO hotels (hotel_id, name, category) VALUES (1, 'Hotel A', 'Boutique'), (2, 'Hotel B', 'Luxury'), (3, 'Hotel C', 'City');
How many hotels are there in each category?
SELECT category, COUNT(*) FROM hotels GROUP BY category;
gretelai_synthetic_text_to_sql
CREATE TABLE shark_attacks (id INT PRIMARY KEY, location VARCHAR(255), year INT, type VARCHAR(255)); INSERT INTO shark_attacks (id, location, year, type) VALUES (1, 'Australia', 2020, 'Attack'); CREATE TABLE expeditions (id INT PRIMARY KEY, name VARCHAR(255), location VARCHAR(255), year INT, type VARCHAR(255)); INSERT INTO expeditions (id, name, location, year, type) VALUES (1, 'Great Barrier Reef Expedition', 'Australia', 2022, 'Research');
Which research expeditions have not taken place in any country with a recorded shark attack?
SELECT e.name, e.location, e.year, e.type FROM expeditions e LEFT JOIN shark_attacks sa ON e.location = sa.location WHERE sa.location IS NULL AND e.type = 'Research';
gretelai_synthetic_text_to_sql
CREATE TABLE animal_population (animal_id INT, animal_name VARCHAR(50), population INT); INSERT INTO animal_population (animal_id, animal_name, population) VALUES (1, 'Tiger', 2500), (2, 'Elephant', 5000), (3, 'Lion', 3000);
What is the minimum population of any animal in the 'animal_population' table?
SELECT MIN(population) FROM animal_population;
gretelai_synthetic_text_to_sql
CREATE TABLE OrganicProducts (ProductID INT, ProductName VARCHAR(100), Organic BOOLEAN); INSERT INTO OrganicProducts (ProductID, ProductName, Organic) VALUES (1, 'OrganicProduct1', true); INSERT INTO OrganicProducts (ProductID, ProductName, Organic) VALUES (2, 'ConventionalProduct2', false); CREATE TABLE SupplierProducts (SupplierID INT, ProductID INT, Quantity INT); INSERT INTO SupplierProducts (SupplierID, ProductID, Quantity) VALUES (1, 1, 50); INSERT INTO SupplierProducts (SupplierID, ProductID, Quantity) VALUES (2, 2, 30);
What is the total quantity of organic products supplied by each supplier?
SELECT S.SupplierID, S.SupplierName, SUM(SP.Quantity) as TotalOrganicQuantity FROM Suppliers S INNER JOIN SupplierProducts SP ON S.SupplierID = SP.SupplierID INNER JOIN OrganicProducts OP ON SP.ProductID = OP.ProductID WHERE OP.Organic = true GROUP BY S.SupplierID;
gretelai_synthetic_text_to_sql
CREATE TABLE Projects (project_id INT, contractor_id INT, start_date DATE, end_date DATE);
Create a table named "Projects" with columns "project_id", "contractor_id", "start_date", and "end_date".
CREATE TABLE Projects (project_id INT, contractor_id INT, start_date DATE, end_date DATE);
gretelai_synthetic_text_to_sql
CREATE TABLE safety_models_2 (id INT, name VARCHAR(255), type VARCHAR(255), method VARCHAR(255)); INSERT INTO safety_models_2 (id, name, type, method) VALUES (1, 'SafeGuard', 'Safety AI', 'Risk Analysis'), (2, 'SecureAI', 'Safety AI', 'Threat Detection');
Get AI safety models using the 'Risk Analysis' method
SELECT * FROM safety_models_2 WHERE method = 'Risk Analysis';
gretelai_synthetic_text_to_sql
CREATE TABLE MilitarySpending (Country VARCHAR(255), Year INT, Spending DECIMAL(10,2)); INSERT INTO MilitarySpending (Country, Year, Spending) VALUES ('Brazil', 2018, 25000000), ('Brazil', 2019, 26000000), ('Brazil', 2020, 27000000), ('South Africa', 2018, 30000000), ('South Africa', 2019, 32000000), ('South Africa', 2020, 35000000), ('China', 2018, 200000000), ('China', 2019, 210000000), ('China', 2020, 220000000);
What is the total spending on military innovation by Brazil, South Africa, and China from 2018 to 2020?
SELECT SUM(Spending) FROM MilitarySpending WHERE Country IN ('Brazil', 'South Africa', 'China') AND Year BETWEEN 2018 AND 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE teachers (teacher_id INT, teacher_name VARCHAR(50), subject_area VARCHAR(50)); CREATE TABLE professional_development (pd_id INT, teacher_id INT, program_name VARCHAR(50), topic VARCHAR(50)); INSERT INTO teachers (teacher_id, teacher_name, subject_area) VALUES (1, 'John Doe', 'Math'), (2, 'Jane Smith', 'Science'); INSERT INTO professional_development (pd_id, teacher_id, program_name, topic) VALUES (1, 1, 'Open Pedagogy Workshop', 'Open Pedagogy'), (2, 2, 'Diversity Training', 'Diversity');
Which teachers have participated in professional development programs related to open pedagogy?
SELECT teachers.teacher_name FROM teachers INNER JOIN professional_development ON teachers.teacher_id = professional_development.teacher_id WHERE professional_development.topic = 'Open Pedagogy';
gretelai_synthetic_text_to_sql
CREATE TABLE Mineral_Production (year INT, month INT, neodymium_production FLOAT);
What is the average monthly production of Neodymium in 2020 from the Mineral_Production table?
SELECT AVG(neodymium_production) FROM Mineral_Production WHERE year = 2020 AND month BETWEEN 1 AND 12;
gretelai_synthetic_text_to_sql
CREATE TABLE game_design_teams (team_id INT, designer_id INT, country VARCHAR(50)); CREATE TABLE game_design_team_members (member_id INT, team_id INT, designer_id INT);
What is the maximum number of players for any game designed by a team of at least two people from Canada?
SELECT MAX(players) FROM game_designers INNER JOIN (SELECT team_id FROM game_design_teams INNER JOIN game_design_team_members ON game_design_teams.team_id = game_design_team_members.team_id WHERE country = 'Canada' GROUP BY team_id HAVING COUNT(DISTINCT designer_id) >= 2) AS canadian_teams ON game_designers.designer_id = canadian_teams.team_id;
gretelai_synthetic_text_to_sql
CREATE TABLE Accidents (AccidentID INT, VesselType VARCHAR(50), IncidentLocation VARCHAR(50), IncidentYear INT); INSERT INTO Accidents VALUES (1, 'Fishing Vessel', 'Gulf of Mexico', 2021), (2, 'Cargo Ship', 'Atlantic Ocean', 2020), (3, 'Tanker', 'Pacific Ocean', 2019);
How many accidents were reported for fishing vessels in the Gulf of Mexico in 2021?
SELECT COUNT(*) FROM Accidents WHERE VesselType = 'Fishing Vessel' AND IncidentLocation = 'Gulf of Mexico' AND IncidentYear = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE donors (donor_id INT, donor_name TEXT, donation_amount FLOAT, cause TEXT, donation_date DATE);
What are the top 3 causes by total donation amount in 2022?
SELECT cause, SUM(donation_amount) as total_donation FROM donors WHERE donation_date BETWEEN '2022-01-01' AND '2022-12-31' GROUP BY cause ORDER BY total_donation DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE Maintenance (id INT, equipment VARCHAR(255), date DATE, labor INT, parts INT);
Insert a new record of equipment maintenance for a Jeep on Apr 30, 2021 with labor cost 200 and parts cost 100.
INSERT INTO Maintenance (equipment, date, labor, parts) VALUES ('Jeep', '2021-04-30', 200, 100);
gretelai_synthetic_text_to_sql
CREATE TABLE sales (sale_id INT, product_id INT, sale_date DATE, quantity INT, price DECIMAL(10,2)); INSERT INTO sales (sale_id, product_id, sale_date, quantity, price) VALUES (1, 1, '2022-01-01', 1, 25.99), (2, 2, '2022-01-02', 2, 39.99), (3, 3, '2022-02-01', 1, 9.99); CREATE TABLE products (product_id INT, product_name VARCHAR(255), category VARCHAR(255)); INSERT INTO products (product_id, product_name, category) VALUES (1, 'Facial Cleanser', 'Skincare'), (2, 'Moisturizer', 'Skincare'), (3, 'Eye Cream', 'Skincare');
How many skincare products are sold in the US in January?
SELECT COUNT(*) FROM sales JOIN products ON sales.product_id = products.product_id WHERE EXTRACT(MONTH FROM sale_date) = 1 AND EXTRACT(YEAR FROM sale_date) = 2022 AND category = 'Skincare' AND country = 'US';
gretelai_synthetic_text_to_sql
CREATE TABLE research_grants (id INT, student_id INT, country VARCHAR(50)); INSERT INTO research_grants (id, student_id, country) VALUES (1, 123, 'USA'), (2, 456, 'Canada');
What is the total number of research grants awarded to graduate students from the USA?
SELECT COUNT(*) FROM research_grants WHERE country = 'USA';
gretelai_synthetic_text_to_sql
CREATE TABLE shipments (id INT, shipped_date DATE, destination VARCHAR(20)); INSERT INTO shipments (id, shipped_date, destination) VALUES (1, '2022-01-05', 'Asia'), (2, '2022-02-07', 'Europe'), (3, '2022-01-16', 'Asia');
How many shipments were sent to 'Asia' in January?
SELECT COUNT(*) FROM shipments WHERE shipped_date >= '2022-01-01' AND shipped_date < '2022-02-01' AND destination = 'Asia';
gretelai_synthetic_text_to_sql
CREATE SCHEMA defense_diplomacy;CREATE TABLE nato_budget (country VARCHAR(50), budget INT, year INT);INSERT INTO nato_budget (country, budget, year) VALUES ('USA', 5000000, 2020), ('France', 3000000, 2020), ('Germany', 4000000, 2020), ('UK', 6000000, 2020);
What is the total budget allocated for defense diplomacy in the year 2020 for NATO countries?
SELECT SUM(budget) FROM defense_diplomacy.nato_budget WHERE year = 2020 AND country IN ('USA', 'France', 'Germany', 'UK');
gretelai_synthetic_text_to_sql
CREATE TABLE mobile_subscribers (subscriber_id INT, state VARCHAR(20)); INSERT INTO mobile_subscribers (subscriber_id, state) VALUES (1, 'NY'), (2, 'NY'), (3, 'NJ'), (4, 'CA'), (5, 'CA');
How many mobile subscribers are there in each state?
SELECT state, COUNT(*) FROM mobile_subscribers GROUP BY state;
gretelai_synthetic_text_to_sql
USE Biotech; CREATE TABLE if not exists GeneticResearch (projectID INT, projectName VARCHAR(255), completionDate DATE); INSERT INTO GeneticResearch (projectID, projectName, completionDate) VALUES (1, 'Project A', '2020-02-01'), (2, 'Project B', '2019-06-15'), (3, 'Project C', '2021-08-03'), (4, 'Project D', '2020-12-31'), (5, 'Project E', '2018-09-09');
List all genetic research projects that were completed in 2020.
SELECT * FROM GeneticResearch WHERE YEAR(completionDate) = 2020 AND MONTH(completionDate) IN (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12);
gretelai_synthetic_text_to_sql
CREATE TABLE funding_sources (id INT, source_type VARCHAR(255), amount FLOAT); CREATE TABLE dance_programs (id INT, program_name VARCHAR(255), region VARCHAR(255));
Find the total funding from government sources for dance programs in the Southern region?
SELECT SUM(funding_sources.amount) as total_funding FROM funding_sources INNER JOIN dance_programs ON funding_sources.id = dance_programs.id WHERE dance_programs.region = 'Southern' AND funding_sources.source_type = 'Government';
gretelai_synthetic_text_to_sql
CREATE TABLE ProjectTypes (id INT, type VARCHAR(20));CREATE TABLE Savings (id INT, project_type_id INT, energy_savings FLOAT);
Calculate the average energy savings for each type of renewable energy project from the ProjectTypes and Savings tables
SELECT pt.type, AVG(s.energy_savings) as avg_savings FROM ProjectTypes pt INNER JOIN Savings s ON pt.id = s.project_type_id GROUP BY pt.id;
gretelai_synthetic_text_to_sql
CREATE TABLE campaigns (id INT, condition TEXT, reach INT, region TEXT); INSERT INTO campaigns (id, condition, reach, region) VALUES (1, 'Depression', 5000, 'Africa'), (2, 'Anxiety', 6000, 'Africa'), (3, 'PTSD', 4000, 'Africa'), (4, 'Bipolar', 7000, 'Africa'), (5, 'OCD', 3000, 'Africa');
List the mental health conditions with the least number of associated public awareness campaigns in Africa.
SELECT condition, MIN(reach) as least_reach FROM campaigns WHERE region = 'Africa' GROUP BY condition;
gretelai_synthetic_text_to_sql
CREATE TABLE machinery (machine_id INT, manufacturer VARCHAR(20)); CREATE TABLE maintenance (machine_id INT, maintenance VARCHAR(20)); INSERT INTO machinery (machine_id, manufacturer) VALUES (1, 'ABC Corp'), (2, 'XYZ Inc'), (3, 'ABC Corp'); INSERT INTO maintenance (machine_id, maintenance) VALUES (1, 'oil change'), (3, 'inspection');
What is the total number of machines in the 'machinery' table, excluding any machines that also appear in the 'maintenance' table?
SELECT COUNT(*) FROM machinery WHERE machine_id NOT IN (SELECT machine_id FROM maintenance);
gretelai_synthetic_text_to_sql
CREATE TABLE sales (product_type VARCHAR(20), revenue DECIMAL(10,2)); INSERT INTO sales (product_type, revenue) VALUES ('organic skincare', 5000), ('conventional skincare', 7000), ('organic makeup', 3000), ('conventional makeup', 9000);
Calculate the total sales revenue of organic skincare products
SELECT SUM(revenue) FROM sales WHERE product_type = 'organic skincare';
gretelai_synthetic_text_to_sql
CREATE TABLE CulturalCompetency (ID INT, Training VARCHAR(50), State VARCHAR(50)); INSERT INTO CulturalCompetency (ID, Training, State) VALUES (1, 'Training 1', 'Texas'); INSERT INTO CulturalCompetency (ID, Training, State) VALUES (2, 'Training 2', 'Texas');
How many cultural competency trainings have been conducted in Texas?
SELECT COUNT(*) FROM CulturalCompetency WHERE State = 'Texas';
gretelai_synthetic_text_to_sql
CREATE TABLE research_papers (paper_id INT, title VARCHAR(50), publication_month DATE); INSERT INTO research_papers (paper_id, title, publication_month) VALUES (1, 'Autonomous Driving Algorithms', '2022-01-01'), (2, 'Deep Learning for Self-Driving Cars', '2022-02-01'), (3, 'LiDAR Sensor Technology in AVs', '2022-02-15');
Find the number of autonomous driving research papers published per month in the 'research_papers' table.
SELECT EXTRACT(MONTH FROM publication_month) month, COUNT(*) papers_per_month FROM research_papers GROUP BY month ORDER BY month;
gretelai_synthetic_text_to_sql
CREATE TABLE fairness (id INT, project_name VARCHAR(255), region VARCHAR(255), start_date DATE); INSERT INTO fairness (id, project_name, region, start_date) VALUES (1, 'Fairness in AI Algorithms', 'North America', '2020-01-01'), (2, 'AI Ethics in Europe', 'Europe', '2021-03-15'), (3, 'Equitable AI in Asia', 'Asia', '2020-12-01');
How many AI fairness projects have been initiated in the last 2 years, by region?
SELECT region, COUNT(*) as num_projects, RANK() OVER (PARTITION BY 1 ORDER BY COUNT(*) DESC) as rank FROM fairness WHERE start_date >= DATEADD(year, -2, CURRENT_DATE) GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE municipal_water_use (province TEXT, water_consumption FLOAT); INSERT INTO municipal_water_use (province, water_consumption) VALUES ('Ontario', 1500000), ('Quebec', 1200000), ('British Columbia', 2000000);
Which provinces in Canada have a higher than average water consumption in the municipal sector?
SELECT province FROM municipal_water_use WHERE water_consumption > (SELECT AVG(water_consumption) FROM municipal_water_use);
gretelai_synthetic_text_to_sql
CREATE TABLE Members (MemberID INT, Name VARCHAR(50), Age INT, Membership VARCHAR(20)); CREATE TABLE Distance (DistanceID INT, MemberID INT, Distance INT, Date DATE); INSERT INTO Members (MemberID, Name, Age, Membership) VALUES (1, 'Sophia Garcia', 30, 'Platinum'), (2, 'Daniel Kim', 25, 'Gold'), (3, 'Fatima Ahmed', 35, 'Platinum'); INSERT INTO Distance (DistanceID, MemberID, Distance, Date) VALUES (1, 1, 5000, '2022-08-01'), (2, 1, 6000, '2022-08-02'), (3, 1, 7000, '2022-08-03'), (4, 2, 4000, '2022-08-01'), (5, 2, 4500, '2022-08-02'), (6, 2, 5000, '2022-08-03'), (7, 3, 8000, '2022-08-01'), (8, 3, 8500, '2022-08-02'), (9, 3, 9000, '2022-08-03');
What is the total distance covered by all members with a Platinum membership in the last month?
SELECT SUM(Distance) FROM Members JOIN Distance ON Members.MemberID = Distance.MemberID WHERE Membership = 'Platinum' AND Date >= DATEADD(MONTH, -1, GETDATE());
gretelai_synthetic_text_to_sql
CREATE TABLE LunchMenu (id INT, name VARCHAR(255), calories INT);
What is the maximum and minimum calorie intake for each meal in the lunch menu?
SELECT name, MAX(calories) AS max_calories, MIN(calories) AS min_calories FROM LunchMenu GROUP BY name;
gretelai_synthetic_text_to_sql
CREATE TABLE Visitors (ID INT, Age INT, Gender VARCHAR(10), Rating INT, City VARCHAR(20), Country VARCHAR(20), Ethnicity VARCHAR(20)); INSERT INTO Visitors (ID, Age, Gender, Rating, City, Country, Ethnicity) VALUES (1, 35, 'Female', 8, 'Sydney', 'Australia', 'Indigenous'); CREATE TABLE Exhibitions (ID INT, Title VARCHAR(50), City VARCHAR(20), Country VARCHAR(20), Date DATE, InPerson BOOLEAN); INSERT INTO Exhibitions (ID, Title, City, Country, Date, InPerson) VALUES (1, 'The Art of the Dreamtime', 'Sydney', 'Australia', '2025-03-01', TRUE);
What is the number of visitors who identified as Indigenous that attended in-person exhibitions in Sydney, Australia in 2025 and their average rating?
SELECT AVG(Visitors.Rating), COUNT(Visitors.ID) FROM Visitors INNER JOIN Exhibitions ON Visitors.City = Exhibitions.City AND Visitors.Country = Exhibitions.Country WHERE Exhibitions.InPerson = TRUE AND Visitors.Ethnicity = 'Indigenous' AND Exhibitions.Date BETWEEN '2025-01-01' AND '2025-12-31';
gretelai_synthetic_text_to_sql
CREATE TABLE neodymium_prices (year INT, country TEXT, price FLOAT); INSERT INTO neodymium_prices (year, country, price) VALUES (2017, 'Australia', 85.5), (2018, 'Australia', 91.2), (2019, 'Australia', 88.7), (2020, 'Australia', 94.3), (2021, 'Australia', 98.1);
What is the average price of neodymium produced in Australia in the last 5 years?
SELECT AVG(price) FROM neodymium_prices WHERE country = 'Australia' AND year >= 2017 AND year <= 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE investment (id INT, company_id INT, investor TEXT, year INT, amount FLOAT); INSERT INTO investment (id, company_id, investor, year, amount) VALUES (1, 1, 'First Solar', 2020, 5000000.0); CREATE TABLE company (id INT, name TEXT, industry TEXT, founder TEXT, PRIMARY KEY (id)); INSERT INTO company (id, name, industry, founder) VALUES (1, 'GreenRise', 'Renewable Energy', 'Indigenous');
What is the average investment amount for Indigenous-founded startups in the renewable energy industry?
SELECT AVG(i.amount) FROM investment i JOIN company c ON i.company_id = c.id WHERE c.founder = 'Indigenous' AND c.industry = 'Renewable Energy';
gretelai_synthetic_text_to_sql
CREATE TABLE rare_earth_market_trends ( id INT PRIMARY KEY, year INT, country VARCHAR(255), element VARCHAR(255), price_usd FLOAT);
Update the rare_earth_market_trends table to reflect the decreased samarium price in Japan
WITH updated_price AS (UPDATE rare_earth_market_trends SET price_usd = 12.8 WHERE year = 2021 AND country = 'Japan' AND element = 'Samarium') SELECT * FROM rare_earth_market_trends WHERE country = 'Japan' AND element = 'Samarium';
gretelai_synthetic_text_to_sql
CREATE TABLE dams (id INT, name VARCHAR(50), location VARCHAR(50), age INT, height FLOAT); INSERT INTO dams (id, name, location, age, height) VALUES (1, 'Hoover', 'Nevada', 86, 221.4);
Which dams in the 'public_works' schema are located in seismic zones and have an 'age' greater than 50 years?
SELECT name, location, age FROM dams WHERE location IN (SELECT location FROM seismic_zones) AND age > 50;
gretelai_synthetic_text_to_sql
CREATE TABLE Spacecraft (id INT, name TEXT, manufacturer TEXT, launch_date DATE);
What is the earliest and latest launch date for each spacecraft?
SELECT name, MIN(launch_date) AS earliest_launch, MAX(launch_date) AS latest_launch FROM Spacecraft GROUP BY name;
gretelai_synthetic_text_to_sql
CREATE TABLE FireIncidents (id INT, incident_id INT, incident_time TIME, district VARCHAR(255)); INSERT INTO FireIncidents (id, incident_id, incident_time, district) VALUES (1, 1, '12:00:00', 'Downtown'), (2, 2, '21:00:00', 'Uptown'), (3, 3, '06:00:00', 'Harbor'), (4, 4, '18:00:00', 'International'), (5, 5, '09:00:00', 'Central'), (6, 6, '15:00:00', 'North'), (7, 7, '10:00:00', 'East'), (8, 8, '02:00:00', 'West');
What is the average response time for fire incidents in the 'North' district for the current month?
SELECT district, AVG(TIMESTAMP_DIFF(MINUTE, '00:00:00', incident_time)) as avg_response_time FROM FireIncidents WHERE district = 'North' AND incident_time BETWEEN DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) AND CURRENT_DATE GROUP BY district;
gretelai_synthetic_text_to_sql
CREATE TABLE IntelligenceOperations (Operation VARCHAR(50), Type VARCHAR(50)); INSERT INTO IntelligenceOperations (Operation, Type) VALUES ('Operation Red Sparrow', 'Military'), ('Operation Moonlight', 'Cybersecurity'), ('Operation Glowing Symphony', 'Cybersecurity'), ('Operation Olympic Games', 'Cybersecurity'), ('Operation Desert Storm', 'Military'), ('Operation Iraqi Freedom', 'Military');
What are the different types of intelligence operations that intersect with military operations?
SELECT Operation FROM IntelligenceOperations WHERE Type = 'Military' INTERSECT SELECT Operation FROM IntelligenceOperations WHERE Type = 'Cybersecurity';
gretelai_synthetic_text_to_sql
CREATE TABLE artists (id INT, name VARCHAR(50), genre VARCHAR(50)); INSERT INTO artists (id, name, genre) VALUES (1, 'The Beatles', 'Rock'), (2, 'Queen', 'Rock'), (3, 'Taylor Swift', 'Pop'), (4, 'BTS', 'K-Pop');
Which artists belong to the 'Rock' genre?
SELECT name FROM artists WHERE genre = 'Rock';
gretelai_synthetic_text_to_sql
CREATE TABLE Vessels (ID INT, Name VARCHAR(255), SafetyScore INT, Arrival DATETIME, Destination VARCHAR(255)); INSERT INTO Vessels (ID, Name, SafetyScore, Arrival, Destination) VALUES (5, 'Pacific Voyager', 92, '2022-02-21 10:00:00', 'Japan'), (6, 'Marine Marvel', 95, '2022-02-18 15:00:00', 'Japan');
What is the percentage of vessels with a safety score higher than 85 that arrived in Japan in the last week?
SELECT COUNT(*) * 100.0 / (SELECT COUNT(*) FROM Vessels WHERE SafetyScore > 85 AND Arrival >= DATE_SUB(CURRENT_DATE, INTERVAL 1 WEEK)) as Percentage FROM Vessels WHERE SafetyScore > 85 AND Arrival >= DATE_SUB(CURRENT_DATE, INTERVAL 1 WEEK) AND Destination = 'Japan';
gretelai_synthetic_text_to_sql
CREATE TABLE Players (PlayerID INT, Name VARCHAR(100), Age INT, FavoriteGenre VARCHAR(50), VRPossible BOOLEAN); INSERT INTO Players (PlayerID, Name, Age, FavoriteGenre, VRPossible) VALUES (1, 'John Doe', 25, 'Action', true), (2, 'Jane Smith', 28, 'Adventure', true), (3, 'James Johnson', 30, 'Simulation', true), (4, 'Emily Davis', 24, 'Strategy', false);
What's the average age of players who play simulation games on VR platforms?
SELECT AVG(Age) FROM Players WHERE FavoriteGenre = 'Simulation' AND VRPossible = true;
gretelai_synthetic_text_to_sql
CREATE TABLE companies (id INT, name TEXT, industry TEXT, founders_underrepresented_communities BOOLEAN, founding_date DATE);
How many companies were founded by people from underrepresented communities in the transportation sector in 2020?
SELECT COUNT(*) FROM companies WHERE founders_underrepresented_communities = true AND industry = 'transportation' AND YEAR(founding_date) = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE SpaceExplorationMissions (id INT, country VARCHAR(50), mission_year INT, mission_outcome BOOLEAN); INSERT INTO SpaceExplorationMissions (id, country, mission_year, mission_outcome) VALUES (1, 'USA', 2000, true), (2, 'USA', 2010, false), (3, 'China', 2015, true), (4, 'India', 2017, true), (5, 'Russia', 2018, false), (6, 'Japan', 2019, true);
What is the total number of space exploration missions for each country?
SELECT country, COUNT(*) as total_missions FROM SpaceExplorationMissions GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE startups(id INT, name TEXT, country TEXT, founder_gender TEXT); INSERT INTO startups(id, name, country, founder_gender) VALUES (1, 'StartupA', 'USA', 'Female'), (2, 'StartupB', 'Canada', 'Male'), (3, 'StartupC', 'USA', 'Female'), (4, 'StartupD', 'Mexico', 'Female'), (5, 'StartupE', 'Brazil', 'Male');
What is the number of startups founded by women in each country?
SELECT country, founder_gender, COUNT(*) as num_startups FROM startups GROUP BY country, founder_gender;
gretelai_synthetic_text_to_sql
CREATE TABLE carbon_sequestration (id INT PRIMARY KEY, ecosystem TEXT, region TEXT, sequestration_rate FLOAT); INSERT INTO carbon_sequestration (id, ecosystem, region, sequestration_rate) VALUES (1, 'Temperate Rainforest', 'North America', 28);
Update the carbon_sequestration table to set the sequestration_rate to 30 tons/hectare for 'Temperate Rainforest' in 'North America'
UPDATE carbon_sequestration SET sequestration_rate = 30 WHERE ecosystem = 'Temperate Rainforest' AND region = 'North America';
gretelai_synthetic_text_to_sql
CREATE TABLE teams (team_id INT, team_name TEXT, league TEXT, sport TEXT); INSERT INTO teams (team_id, team_name, league, sport) VALUES (1, 'Barcelona', 'La Liga', 'Football'), (2, 'Real Madrid', 'La Liga', 'Football'); CREATE TABLE games (game_id INT, team_id INT, goals INT, season_year INT); INSERT INTO games (game_id, team_id, goals, season_year) VALUES (1, 2, 5, 2020), (2, 2, 2, 2020), (3, 2, 1, 2020);
What is the highest number of goals scored by the 'Real Madrid' football club in a single game in the year 2020?
SELECT MAX(goals) FROM games WHERE team_id = (SELECT team_id FROM teams WHERE team_name = 'Real Madrid') AND season_year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE GraduateStudents(StudentID INT, Department VARCHAR(20), NumPapers INT); INSERT INTO GraduateStudents(StudentID, Department, NumPapers) VALUES (1, 'Mathematics', 3), (2, 'Mathematics', 1), (3, 'Mathematics', 2), (4, 'Physics', 0);
Count the number of graduate students who have published more than two papers in the Mathematics department.
SELECT COUNT(*) FROM GraduateStudents WHERE Department = 'Mathematics' AND NumPapers > 2;
gretelai_synthetic_text_to_sql
CREATE TABLE PrecipitationData (location VARCHAR(50), year INT, month INT, precipitation FLOAT); INSERT INTO PrecipitationData (location, year, month, precipitation) VALUES ('Norrbotten County', 2020, 1, 80.5), ('Norrbotten County', 2020, 2, 75.2), ('Norrbotten County', 2020, 3, 85.6);
What is the average precipitation per month in Sweden's Norrbotten County?
SELECT location, AVG(precipitation) FROM PrecipitationData WHERE location = 'Norrbotten County' GROUP BY year, month;
gretelai_synthetic_text_to_sql
CREATE TABLE products (product_id int, product_category varchar(50), avg_rating decimal(2,1));CREATE TABLE reviews (review_id int, product_id int, rating int);
What is the average rating of products in each category?
SELECT products.product_category, AVG(reviews.rating) FROM reviews JOIN products ON reviews.product_id = products.product_id GROUP BY products.product_category;
gretelai_synthetic_text_to_sql
CREATE TABLE Products (ProductID int, SupplierID int, QuantitySold int);
How many products are sold by each supplier?
SELECT SupplierID, SUM(QuantitySold) FROM Products GROUP BY SupplierID;
gretelai_synthetic_text_to_sql
CREATE TABLE Countries (country_name TEXT, records INTEGER); INSERT INTO Countries (country_name, records) VALUES ('Country A', 5), ('Country B', 10), ('Country C', 8);
How many swimming records has each country set?
SELECT country_name, records FROM Countries;
gretelai_synthetic_text_to_sql
CREATE TABLE Sales (sale_id INT, menu_id INT, sale_date DATE, quantity INT, price DECIMAL(5,2)); INSERT INTO Sales (sale_id, menu_id, sale_date, quantity, price) VALUES (1, 1, '2022-01-01', 2, 12.99), (2, 2, '2022-01-02', 1, 10.99), (3, 3, '2022-01-03', 3, 9.99); CREATE TABLE Menus (menu_id INT, category VARCHAR(255), dish_name VARCHAR(255), price DECIMAL(5,2)); INSERT INTO Menus (menu_id, category, dish_name, price) VALUES (1, 'Vegetarian', 'Cheese Pizza', 9.99), (2, 'Vegan', 'Tofu Stir Fry', 10.99), (3, 'Vegetarian', 'Vegetable Curry', 11.99);
What is the total revenue generated from vegetarian dishes?
SELECT SUM(quantity * price) FROM Sales JOIN Menus ON Sales.menu_id = Menus.menu_id WHERE Menus.category = 'Vegetarian';
gretelai_synthetic_text_to_sql
CREATE TABLE Creative_AI (application_name TEXT, region TEXT); INSERT INTO Creative_AI VALUES ('AI Painter', 'Europe'), ('AI Musician', 'North America'), ('AI Writer', 'Asia');
Which regions are underrepresented in creative AI applications?
SELECT region FROM Creative_AI WHERE application_name NOT IN ('AI Painter', 'AI Musician');
gretelai_synthetic_text_to_sql
CREATE TABLE reporters (reporter_id INT, name VARCHAR(50)); CREATE TABLE articles (article_id INT, title VARCHAR(100), publication_date DATE, views INT); CREATE TABLE reporter_articles (article_id INT, reporter_id INT); INSERT INTO reporters (reporter_id, name) VALUES (1, 'Anna Smith'), (2, 'Bella Johnson'), (3, 'Mike Davis'); INSERT INTO articles (article_id, title, publication_date, views) VALUES (1, 'News from the Capital', '2022-01-01', 1500), (2, 'Tech Innovations in 2022', '2022-01-02', 1200), (3, 'The Art of Persuasion', '2022-01-03', 1800), (4, 'Education Reforms in Europe', '2022-01-04', 1000); INSERT INTO reporter_articles (article_id, reporter_id) VALUES (1, 1), (2, 2), (3, 1), (4, 3);
How many articles were published by each reporter in the "reporter_articles" table?
SELECT r.name, COUNT(ra.article_id) as articles_count FROM reporters r JOIN reporter_articles ra ON r.reporter_id = ra.reporter_id GROUP BY r.name;
gretelai_synthetic_text_to_sql
CREATE TABLE weather (region VARCHAR(255), temperature INT, date DATE); INSERT INTO weather (region, temperature, date) VALUES ('North', 25, '2022-07-01'), ('South', 30, '2022-07-01'), ('East', 28, '2022-07-01'), ('West', 22, '2022-07-01');
What is the average temperature in each region for the month of July, in descending order?
SELECT region, AVG(temperature) as avg_temp FROM weather WHERE date BETWEEN '2022-07-01' AND '2022-07-31' GROUP BY region ORDER BY avg_temp DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE properties (type VARCHAR(10), borough VARCHAR(20), price INT); INSERT INTO properties (type, borough, price) VALUES ('Co-op', 'Bronx', 500000); INSERT INTO properties (type, borough, price) VALUES ('Condo', 'Bronx', 700000);
What is the average listing price for co-op properties in the Bronx?
SELECT AVG(price) FROM properties WHERE type = 'Co-op' AND borough = 'Bronx';
gretelai_synthetic_text_to_sql
CREATE TABLE SecurityIncidents (incident_id INT, incident_region VARCHAR(50), incident_date DATE);
What are the number of security incidents per region for the last year?
SELECT incident_region, COUNT(*) FROM SecurityIncidents WHERE incident_date BETWEEN DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR) AND CURRENT_DATE GROUP BY incident_region;
gretelai_synthetic_text_to_sql
CREATE TABLE diversity_metrics (company_id INT, female_employees_percentage DECIMAL, minority_employees_percentage DECIMAL);
List all diversity metrics for startups founded after 2015
SELECT company_id, female_employees_percentage, minority_employees_percentage FROM diversity_metrics dm INNER JOIN company c ON dm.company_id = c.id WHERE c.founding_year > 2015;
gretelai_synthetic_text_to_sql
CREATE TABLE rd_expenditure_3 (dept TEXT, year INT, amount FLOAT); INSERT INTO rd_expenditure_3 (dept, year, amount) VALUES ('Neurology', 2018, 2000000), ('Cardiology', 2018, 1500000), ('Neurology', 2019, 2500000), ('Cardiology', 2019, 2000000), ('Neurology', 2020, 2800000);
What is the total R&D expenditure for the neurology department for the year 2019?
SELECT SUM(amount) AS total_rd_expenditure FROM rd_expenditure_3 WHERE dept = 'Neurology' AND year = 2019;
gretelai_synthetic_text_to_sql
CREATE TABLE financial_capability (customer_id INT, name VARCHAR(50), financial_capability_score INT); INSERT INTO financial_capability (customer_id, name, financial_capability_score) VALUES (104, 'Raul Garcia', 95), (105, 'Sofia Herrera', 70), (106, 'Maria Rodriguez', 90);
What is the maximum financial capability score for customers in the 'financial_capability' table?
SELECT MAX(financial_capability_score) FROM financial_capability;
gretelai_synthetic_text_to_sql
CREATE TABLE esports_events (id INT, year INT, location VARCHAR(20)); INSERT INTO esports_events (id, year, location) VALUES (1, 2022, 'USA'), (2, 2022, 'Germany'), (3, 2021, 'France');
How many esports events were held in total in 2021?
SELECT COUNT(*) FROM esports_events WHERE year = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE product_ratings (product_id INT, product_name VARCHAR(255), manufacturer_country VARCHAR(50), rating DECIMAL(2,1)); INSERT INTO product_ratings (product_id, product_name, manufacturer_country, rating) VALUES (1, 'Product A', 'Spain', 4.5), (2, 'Product B', 'Italy', 4.2), (3, 'Product C', 'Spain', 4.8);
What is the rank of products based on their rating, for products manufactured in Spain?
SELECT product_id, product_name, rating, RANK() OVER (ORDER BY rating DESC) as rank FROM product_ratings WHERE manufacturer_country = 'Spain';
gretelai_synthetic_text_to_sql
CREATE TABLE union_members (member_id INT, industry VARCHAR(15)); INSERT INTO union_members (member_id, industry) VALUES (1, 'Manufacturing'), (2, 'Construction'), (3, 'Retail');
What percentage of union members work in construction?
SELECT 100.0 * COUNT(*) / (SELECT COUNT(*) FROM union_members) as pct_in_construction FROM union_members WHERE industry = 'Construction';
gretelai_synthetic_text_to_sql
CREATE TABLE mineral_impact (mineral TEXT, impact_score DECIMAL); INSERT INTO mineral_impact (mineral, impact_score) VALUES ('Gold', 18.5), ('Silver', 15.7), ('Copper', 14.3), ('Iron', 12.9), ('Zinc', 11.2);
What is the total environmental impact score per mineral?
SELECT mineral, SUM(impact_score) FROM mineral_impact GROUP BY mineral;
gretelai_synthetic_text_to_sql
CREATE TABLE events (id INT, category VARCHAR(10), tickets_sold INT); INSERT INTO events (id, category, tickets_sold) VALUES (1, 'Dance', 200), (2, 'Music', 300), (3, 'Theater', 150);
What was the total number of tickets sold for events in the 'Music' category?
SELECT SUM(tickets_sold) FROM events WHERE category = 'Music';
gretelai_synthetic_text_to_sql
CREATE TABLE mining_emissions (id INT PRIMARY KEY, element VARCHAR(10), co2_emission INT); INSERT INTO mining_emissions (id, element, co2_emission) VALUES (1, 'Neodymium', 300); INSERT INTO mining_emissions (id, element, co2_emission) VALUES (2, 'Praseodymium', 400); INSERT INTO mining_emissions (id, element, co2_emission) VALUES (3, 'Dysprosium', 500);
What are the average CO2 emissions for each rare earth element in the mining process?
SELECT m.element, AVG(m.co2_emission) AS avg_co2_emission FROM mining_emissions m GROUP BY m.element;
gretelai_synthetic_text_to_sql
CREATE TABLE fleet_vehicles (id INT PRIMARY KEY, fleet_name VARCHAR(255), vehicle_type VARCHAR(255), num_electric_vehicles INT, total_vehicles INT);
Update the number of electric vehicles in the Portland fleet
UPDATE fleet_vehicles SET num_electric_vehicles = 350 WHERE fleet_name = 'Portland';
gretelai_synthetic_text_to_sql
CREATE TABLE tank_inventory (tank_id INT, chemical VARCHAR(20), quantity INT); INSERT INTO tank_inventory (tank_id, chemical, quantity) VALUES (5, 'A', 800), (5, 'B', 300), (6, 'A', 500);
What is the total quantity of chemicals stored in tank 5?
SELECT SUM(quantity) FROM tank_inventory WHERE tank_id = 5;
gretelai_synthetic_text_to_sql
CREATE TABLE Shipments (id INT, source VARCHAR(50), destination VARCHAR(50), weight FLOAT, ship_date DATE); INSERT INTO Shipments (id, source, destination, weight, ship_date) VALUES (33, 'Brazil', 'Australia', 650, '2022-12-01'); INSERT INTO Shipments (id, source, destination, weight, ship_date) VALUES (34, 'Argentina', 'New Zealand', 450, '2022-12-15'); INSERT INTO Shipments (id, source, destination, weight, ship_date) VALUES (35, 'Colombia', 'Fiji', 520, '2022-12-30');
Determine the number of shipments from South America to Oceania in December 2022 that had a weight greater than 500
SELECT COUNT(*) FROM Shipments WHERE (source = 'Brazil' OR source = 'Argentina' OR source = 'Colombia') AND (destination = 'Australia' OR destination = 'New Zealand' OR destination = 'Fiji') AND weight > 500 AND ship_date BETWEEN '2022-12-01' AND '2022-12-31';
gretelai_synthetic_text_to_sql
CREATE TABLE CityBudget (CityName VARCHAR(50), Department VARCHAR(50), Budget INT); INSERT INTO CityBudget (CityName, Department, Budget) VALUES ('CityA', 'Parks', 5000000), ('CityA', 'Roads', 7000000), ('CityB', 'Parks', 6000000), ('CityB', 'Roads', 8000000);
What is the average budget per department for each city?
SELECT CityName, Department, AVG(Budget) OVER(PARTITION BY CityName) as AvgBudgetPerCity FROM CityBudget;
gretelai_synthetic_text_to_sql
CREATE TABLE Artists (artist_name TEXT, location TEXT, num_concerts INTEGER); INSERT INTO Artists (artist_name, location, num_concerts) VALUES ('Artist A', 'Chicago', 200), ('Artist B', 'Miami', 300), ('Artist C', 'Atlanta', 400), ('Artist D', 'Seattle', 500), ('Artist D', 'New York', 100), ('Artist D', 'Los Angeles', 200);
Determine the total number of concerts held by artists who have never held a concert in New York or Los Angeles.
SELECT SUM(num_concerts) as total_concerts FROM Artists WHERE artist_name NOT IN (SELECT artist_name FROM Artists WHERE location IN ('New York', 'Los Angeles'));
gretelai_synthetic_text_to_sql
CREATE TABLE SkyHigh.AircraftSales (id INT, manufacturer VARCHAR(255), model VARCHAR(255), quantity INT, price DECIMAL(10,2), buyer_country VARCHAR(255), sale_date DATE);
What is the total number of military aircraft sold by SkyHigh to the Japanese government?
SELECT SUM(quantity) FROM SkyHigh.AircraftSales WHERE buyer_country = 'Japan';
gretelai_synthetic_text_to_sql
CREATE TABLE clients (client_id INT, name VARCHAR(255)); INSERT INTO clients (client_id, name) VALUES (1, 'ABC Corp'), (2, 'XYZ Inc'), (3, 'DEF Ltd'); CREATE TABLE billing (bill_id INT, client_id INT, amount DECIMAL(10,2)); INSERT INTO billing (bill_id, client_id, amount) VALUES (1, 1, 500.00), (2, 1, 750.00), (3, 2, 600.00), (4, 3, 800.00), (5, 3, 900.00);
What is the total billing amount for each client, grouped by client?
SELECT clients.name, SUM(billing.amount) FROM billing JOIN clients ON billing.client_id = clients.client_id GROUP BY clients.name;
gretelai_synthetic_text_to_sql
CREATE TABLE chemical_table (chemical_id INT, chemical_name VARCHAR(50), safety_rating INT);
Update the safety_rating of 'Methyl Ethyl Ketone' to 3 in the chemical_table
UPDATE chemical_table SET safety_rating = 3 WHERE chemical_name = 'Methyl Ethyl Ketone';
gretelai_synthetic_text_to_sql
CREATE TABLE space_missions (id INT, name VARCHAR(50), start_date DATE, launch_country VARCHAR(50)); INSERT INTO space_missions VALUES (1, 'Apollo 11', '1969-07-16', 'USA'), (2, 'Apollo 13', '1970-04-11', 'USA'), (3, 'Mars Pathfinder', '1996-12-04', 'USA'), (4, 'Cassini-Huygens', '1997-10-15', 'France');
What are the launch dates of space missions having the same launch country?
SELECT name, launch_country, start_date FROM space_missions WHERE launch_country IN (SELECT launch_country FROM space_missions GROUP BY launch_country HAVING COUNT(*) > 1);
gretelai_synthetic_text_to_sql
CREATE TABLE movies (title VARCHAR(255), genre VARCHAR(50), budget INT, release_year INT); CREATE TABLE tv_shows (title VARCHAR(255), genre VARCHAR(50), budget INT, release_year INT); INSERT INTO movies (title, genre, budget, release_year) VALUES ('Movie7', 'Comedy', 22000000, 2020), ('Movie8', 'Drama', 28000000, 2021), ('Movie9', 'Action', 32000000, 2022); INSERT INTO tv_shows (title, genre, budget, release_year) VALUES ('Show13', 'Comedy', 18000000, 2021), ('Show14', 'Drama', 24000000, 2022), ('Show15', 'Action', 29000000, 2023);
Find the average budget for TV shows and movies released in the last 3 years
SELECT AVG(budget) FROM (SELECT budget FROM movies WHERE release_year >= (SELECT YEAR(CURRENT_DATE()) - 3) UNION ALL SELECT budget FROM tv_shows WHERE release_year >= (SELECT YEAR(CURRENT_DATE()) - 3)) as combined;
gretelai_synthetic_text_to_sql
CREATE TABLE artists (id INT, name TEXT, gender TEXT); INSERT INTO artists (id, name, gender) VALUES (1, 'Artist 1', 'Male'), (2, 'Artist 2', 'Female'), (3, 'Artist 3', 'Female'), (4, 'Artist 4', 'Non-binary'); CREATE TABLE artworks (id INT, title TEXT, artist_id INT); INSERT INTO artworks (id, title, artist_id) VALUES (1, 'Artwork 1', 1), (2, 'Artwork 2', 2), (3, 'Artwork 3', 3), (4, 'Artwork 4', 2), (5, 'Artwork 5', 4);
What is the total number of artworks by female artists?
SELECT COUNT(*) FROM artworks a INNER JOIN artists ar ON a.artist_id = ar.id WHERE ar.gender = 'Female';
gretelai_synthetic_text_to_sql
CREATE TABLE if not exists binance_assets (asset_id INT, asset_name VARCHAR(255), total_txn_volume DECIMAL(18,2)); INSERT INTO binance_assets (asset_id, asset_name, total_txn_volume) VALUES (1, 'BNB', 150000000), (2, 'BUSD', 120000000), (3, 'CAKE', 90000000), (4, 'ADA', 80000000), (5, 'XRP', 70000000), (6, 'DOT', 60000000), (7, 'MATIC', 50000000), (8, 'LTC', 40000000), (9, 'LINK', 30000000), (10, 'BCH', 20000000);
What is the average transaction volume for each digital asset in the Binance Smart Chain network?
SELECT asset_name, AVG(total_txn_volume) as avg_volume FROM binance_assets GROUP BY asset_name;
gretelai_synthetic_text_to_sql
CREATE TABLE justice_schemas.legal_tech_tools (id INT PRIMARY KEY, provider_id INT, tool_name TEXT, tool_type TEXT); CREATE TABLE justice_schemas.legal_tech_providers (id INT PRIMARY KEY, provider_name TEXT);
How many legal technology tools are available in the justice_schemas.legal_tech_tools table for each provider in the justice_schemas.legal_tech_providers table?
SELECT ltp.provider_name, COUNT(*) FROM justice_schemas.legal_tech_tools ltt INNER JOIN justice_schemas.legal_tech_providers ltp ON ltt.provider_id = ltp.id GROUP BY ltp.provider_name;
gretelai_synthetic_text_to_sql
CREATE TABLE eco_hotels (hotel_id INT, name TEXT, rating FLOAT, country TEXT); INSERT INTO eco_hotels (hotel_id, name, rating, country) VALUES (1, 'Eco Lodge', 4.5, 'Netherlands'), (2, 'Green Hotel', 4.2, 'Netherlands'), (3, 'Duurzaam Hotel', 4.7, 'Belgium');
What is the average rating of eco-friendly hotels in the Netherlands and Belgium?
SELECT AVG(rating) FROM eco_hotels WHERE country IN ('Netherlands', 'Belgium');
gretelai_synthetic_text_to_sql
CREATE TABLE mobile_subscribers (subscriber_id INT, name VARCHAR(50), data_usage_gb FLOAT, region VARCHAR(50)); INSERT INTO mobile_subscribers (subscriber_id, name, data_usage_gb, region) VALUES (1, 'John Doe', 25.6, 'San Francisco'), (2, 'Jane Smith', 30.9, 'San Francisco'), (3, 'Alice Johnson', 40.5, 'New York'), (4, 'Bob Brown', 35.7, 'New York');
Which mobile subscribers have the top 5 highest data usage in each region?
SELECT region, subscriber_id, name, data_usage_gb, NTILE(5) OVER (PARTITION BY region ORDER BY data_usage_gb DESC) as tier FROM mobile_subscribers ORDER BY region, tier;
gretelai_synthetic_text_to_sql
CREATE TABLE security_incidents (incident_id INT, incident_date DATE, system_id INT);CREATE TABLE systems (system_id INT, system_name VARCHAR(255), system_location VARCHAR(255));
What are the total number of security incidents and the number of unique systems involved in each incident in the last quarter?
SELECT COUNT(*) as total_incidents, COUNT(DISTINCT system_id) as unique_systems_per_incident, system_location FROM security_incidents si JOIN systems s ON si.system_id = s.system_id WHERE incident_date >= DATE_SUB(CURRENT_DATE, INTERVAL 3 MONTH) GROUP BY system_location;
gretelai_synthetic_text_to_sql
CREATE TABLE Players (PlayerID INT, City VARCHAR(20)); INSERT INTO Players (PlayerID, City) VALUES (1, 'Tokyo'), (2, 'Los Angeles'), (3, 'New York'), (4, 'Paris'), (5, 'Tokyo'), (6, 'Los Angeles');
How many players are there in each city?
SELECT City, COUNT(*) AS Count FROM Players GROUP BY City ORDER BY Count DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE StreamingData (StreamID INT, UserID INT, SongID INT, StreamDate DATE); INSERT INTO StreamingData VALUES (1, 1, 1001, '2022-01-01'); INSERT INTO StreamingData VALUES (2, 2, 1002, '2022-01-02'); CREATE TABLE Users (UserID INT, UserName VARCHAR(50)); INSERT INTO Users VALUES (1, 'Alice'); INSERT INTO Users VALUES (2, 'Bob');
What is the average number of streams per user for a specific music streaming service?
SELECT AVG(StreamCount) FROM (SELECT COUNT(*) AS StreamCount FROM StreamingData GROUP BY UserID) AS Subquery;
gretelai_synthetic_text_to_sql
CREATE TABLE public_parks (id INT, name TEXT, city TEXT, budget FLOAT); INSERT INTO public_parks (id, name, city, budget) VALUES (1, 'Central Park', 'New York', 30000000);
What is the average budget allocated to public parks in New York City?
SELECT AVG(budget) FROM public_parks WHERE city = 'New York';
gretelai_synthetic_text_to_sql
CREATE TABLE Accommodations (StudentID INT, DisabilityType VARCHAR(50), Region VARCHAR(50), AccommodationYear INT); INSERT INTO Accommodations (StudentID, DisabilityType, Region, AccommodationYear) VALUES (1, 'Visual Impairment', 'Midwest', 2020), (2, 'Hearing Impairment', 'Midwest', 2020), (3, 'Autism Spectrum Disorder', 'Midwest', 2020);
What is the total number of students who received accommodations by disability type in the Midwest region for the year 2020?
SELECT COUNT(StudentID) FROM Accommodations WHERE Region = 'Midwest' AND AccommodationYear = 2020 GROUP BY DisabilityType;
gretelai_synthetic_text_to_sql
CREATE TABLE maintenance_requests (request_id INT, vendor_name TEXT, state TEXT); CREATE TABLE equipment_maintenance (request_id INT, equipment_type TEXT); INSERT INTO maintenance_requests (request_id, vendor_name, state) VALUES (1, 'XYZ Services', 'California'), (2, 'LMN Co', 'Texas'); INSERT INTO equipment_maintenance (request_id, equipment_type) VALUES (1, 'Tank'), (2, 'Aircraft');
Retrieve the number of military equipment maintenance requests performed in each state
SELECT mr.state, COUNT(mr.request_id) FROM maintenance_requests mr JOIN equipment_maintenance em ON mr.request_id = em.request_id GROUP BY mr.state;
gretelai_synthetic_text_to_sql
CREATE TABLE policyholders (id INT, age INT, gender VARCHAR(10), policy_type VARCHAR(20), premium FLOAT, state VARCHAR(20)); INSERT INTO policyholders (id, age, gender, policy_type, premium, state) VALUES (1, 32, 'Female', 'Comprehensive', 1200.00, 'California'), (2, 41, 'Male', 'Third-Party', 800.00, 'California'); CREATE TABLE claims (id INT, policyholder_id INT, claim_amount FLOAT, claim_date DATE); INSERT INTO claims (id, policyholder_id, claim_amount, claim_date) VALUES (1, 1, 500.00, '2021-01-01'), (2, 2, 1000.00, '2021-02-01'), (3, 1, 300.00, '2021-03-01'), (4, 3, 200.00, '2021-01-01');
What is the maximum claim amount and corresponding policy type for policyholders from California?
SELECT policy_type, MAX(claim_amount) FROM claims JOIN policyholders ON claims.policyholder_id = policyholders.id WHERE policyholders.state = 'California' GROUP BY policy_type;
gretelai_synthetic_text_to_sql