context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE programs (id INT, name VARCHAR(255)); INSERT INTO programs (id, name) VALUES (1, 'Education'), (2, 'Health'), (3, 'Social Services');
Insert a new record of program expenses for each program.
INSERT INTO program_expenses (id, program_id, amount) SELECT ROW_NUMBER() OVER (ORDER BY p.id) AS id, p.id AS program_id, 1000 AS amount FROM programs p;
gretelai_synthetic_text_to_sql
CREATE TABLE geopolitical_risk_assessments (region VARCHAR(255), year INTEGER, num_assessments INTEGER); INSERT INTO geopolitical_risk_assessments (region, year, num_assessments) VALUES ('Asia-Pacific', 2018, 3), ('Asia-Pacific', 2019, 4);
How many geopolitical risk assessments have been conducted for the Asia-Pacific region since 2018?
SELECT SUM(num_assessments) FROM geopolitical_risk_assessments WHERE region = 'Asia-Pacific' AND year >= 2018;
gretelai_synthetic_text_to_sql
CREATE TABLE defense_diplomacy (id INT PRIMARY KEY, name VARCHAR(255), country VARCHAR(255), city VARCHAR(255));
Delete the 'defense_diplomacy' table
DROP TABLE defense_diplomacy;
gretelai_synthetic_text_to_sql
CREATE TABLE mining (year INT, element VARCHAR(10), quantity INT); INSERT INTO mining VALUES (2019, 'Gadolinium', 1400), (2020, 'Gadolinium', 1600); CREATE TABLE recycling (year INT, element VARCHAR(10), quantity INT); INSERT INTO recycling VALUES (2019, 'Gadolinium', 1000), (2020, 'Gadolinium', 1200);
What are the total production quantities of Gadolinium in 2019 and 2020 from the 'mining' and 'recycling' sources?
SELECT year, SUM(quantity) FROM (SELECT year, quantity FROM mining WHERE element = 'Gadolinium' UNION ALL SELECT year, quantity FROM recycling WHERE element = 'Gadolinium') AS total_sources GROUP BY year HAVING year IN (2019, 2020);
gretelai_synthetic_text_to_sql
CREATE TABLE studio (studio_id INT, name VARCHAR(100)); INSERT INTO studio (studio_id, name) VALUES (1, 'Green Studios'); CREATE TABLE tv_show (tv_show_id INT, title VARCHAR(100), studio_id INT, revenue INT);
Find the total revenue of TV shows produced by Green Studios.
SELECT SUM(tv_show.revenue) FROM tv_show WHERE tv_show.studio_id = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE CosmeticsBrands (brand_id INT, brand TEXT, sustainability_score DECIMAL(3,1), is_halal BOOLEAN); INSERT INTO CosmeticsBrands (brand_id, brand, sustainability_score, is_halal) VALUES (1, 'Inika', 3.5, true); CREATE TABLE BrandRegion (brand_id INT, region TEXT); INSERT INTO BrandRegion (brand_id, region) VALUES (1, 'Southeast Asia');
Which halal cosmetics brands have the lowest sustainability scores in Southeast Asia?
SELECT brand, MIN(sustainability_score) FROM CosmeticsBrands cb JOIN BrandRegion br ON cb.brand_id = br.brand_id WHERE cb.is_halal = true AND br.region LIKE 'Southeast%' GROUP BY brand;
gretelai_synthetic_text_to_sql
CREATE TABLE al_jazeera (project_id INT, project_name VARCHAR(50), source VARCHAR(20), investigative_journalism BOOLEAN); INSERT INTO al_jazeera (project_id, project_name, source, investigative_journalism) VALUES (1, 'Project A', 'Al Jazeera', TRUE), (2, 'Project B', 'Al Jazeera', FALSE); CREATE TABLE cnn (project_id INT, project_name VARCHAR(50), source VARCHAR(20), investigative_journalism BOOLEAN); INSERT INTO cnn (project_id, project_name, source, investigative_journalism) VALUES (3, 'Project C', 'CNN', TRUE), (4, 'Project D', 'CNN', FALSE); CREATE TABLE deutsche_welle (project_id INT, project_name VARCHAR(50), source VARCHAR(20), investigative_journalism BOOLEAN); INSERT INTO deutsche_welle (project_id, project_name, source, investigative_journalism) VALUES (5, 'Project E', 'Deutsche Welle', TRUE), (6, 'Project F', 'Deutsche Welle', FALSE);
Identify any investigative journalism projects published by 'Al Jazeera' or 'CNN' but not by 'Deutsche Welle'.
SELECT project_name, source FROM al_jazeera WHERE investigative_journalism = TRUE UNION ALL SELECT project_name, source FROM cnn WHERE investigative_journalism = TRUE EXCEPT SELECT project_name, source FROM deutsche_welle WHERE investigative_journalism = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE cybersecurity_incidents (incident_id INT, location VARCHAR(255), severity INT, timestamp TIMESTAMP); INSERT INTO cybersecurity_incidents (incident_id, location, severity, timestamp) VALUES (1, 'Australia', 8, '2022-02-12 15:20:00'), (2, 'New Zealand', 5, '2022-03-03 09:30:00'), (3, 'Papua New Guinea', 7, '2022-01-10 11:45:00');
Identify cybersecurity incidents in Oceania with a severity level above 6 in the past year.
SELECT * FROM cybersecurity_incidents WHERE location LIKE 'Oceania%' AND severity > 6 AND timestamp > DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 1 YEAR);
gretelai_synthetic_text_to_sql
CREATE TABLE countries (id INT, name VARCHAR(50), space_missions INT);
Count the number of countries with no space missions
SELECT COUNT(*) FROM countries WHERE space_missions = 0;
gretelai_synthetic_text_to_sql
CREATE TABLE port_of_houston (vessel_name VARCHAR(255), dock_month INT); CREATE TABLE port_of_new_orleans (vessel_name VARCHAR(255), dock_month INT); CREATE TABLE port_of_miami (vessel_name VARCHAR(255), dock_month INT); INSERT INTO port_of_houston (vessel_name, dock_month) VALUES ('Vessel CC', 8), ('Vessel DD', 8), ('Vessel EE', 9); INSERT INTO port_of_new_orleans (vessel_name, dock_month) VALUES ('Vessel EE', 9), ('Vessel FF', 10), ('Vessel GG', 10); INSERT INTO port_of_miami (vessel_name, dock_month) VALUES ('Vessel HH', 10), ('Vessel II', 11), ('Vessel JJ', 11);
Which vessels docked in the Port of Houston in August 2022 but have not docked in any other port since then?
SELECT vessel_name FROM port_of_houston WHERE dock_month = 8 EXCEPT (SELECT vessel_name FROM port_of_new_orleans WHERE dock_month >= 8 UNION SELECT vessel_name FROM port_of_miami WHERE dock_month >= 8);
gretelai_synthetic_text_to_sql
CREATE TABLE teams (team_id INT, team_name VARCHAR(50), division VARCHAR(50)); INSERT INTO teams (team_id, team_name, division) VALUES (1, 'Golden State Warriors', 'Pacific'); INSERT INTO teams (team_id, team_name, division) VALUES (2, 'Los Angeles Lakers', 'Pacific'); INSERT INTO teams (team_id, team_name, division) VALUES (3, 'Los Angeles Clippers', 'Pacific');
What is the total revenue generated from ticket sales for each team in the Pacific division?
SELECT teams.team_name, SUM(ticket_price * number_of_tickets) as total_revenue FROM games JOIN teams ON games.team_id = teams.team_id WHERE teams.division = 'Pacific' GROUP BY teams.team_name;
gretelai_synthetic_text_to_sql
CREATE TABLE field_sensors (field_id INT, sensor_type VARCHAR(20), value FLOAT, timestamp TIMESTAMP); INSERT INTO field_sensors (field_id, sensor_type, value, timestamp) VALUES (8, 'temperature', 15.5, '2023-02-20 10:00:00'), (8, 'humidity', 85.0, '2023-02-20 10:00:00');
Find the minimum temperature and humidity for crops in field 8 during the last 3 days.
SELECT field_id, MIN(value) FROM field_sensors WHERE sensor_type IN ('temperature', 'humidity') AND timestamp >= NOW() - INTERVAL 3 DAY GROUP BY field_id;
gretelai_synthetic_text_to_sql
CREATE TABLE ResearchLocation (ID INT, Lab VARCHAR(255), Location VARCHAR(255), Year INT, NumPapers INT); INSERT INTO ResearchLocation (ID, Lab, Location, Year, NumPapers) VALUES (1, 'SmartLabs', 'Detroit', 2021, 10), (2, 'RoboLabs', 'Tokyo', 2021, 15), (3, 'SmartLabs', 'Paris', 2021, 20), (4, 'RoboLabs', 'Seoul', 2022, 25), (5, 'RoboLabs', 'Sydney', 2022, 30);
What are the autonomous driving research paper counts for 'RoboLabs' in 2022?
SELECT SUM(NumPapers) FROM ResearchLocation WHERE Lab = 'RoboLabs' AND Year = 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE farmers (id INT, name VARCHAR(255), region VARCHAR(255), training_year INT, training_topic VARCHAR(255));
Insert a new record for a farmer who received training in 'Precision Agriculture' in the region of 'Bihar' in 2022.
INSERT INTO farmers (id, name, region, training_year, training_topic) VALUES (3, 'Rakesh Kumar', 'Bihar', 2022, 'Precision Agriculture');
gretelai_synthetic_text_to_sql
CREATE TABLE drug_data (drug_id INT, drug_name TEXT, category TEXT, rd_expenditure INT, sale_date DATE);
What is the average R&D expenditure per month for the past year for each drug category, ranked in descending order of average expenditure?
SELECT category, AVG(rd_expenditure) AS avg_expenditure FROM drug_data WHERE sale_date BETWEEN DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR) AND CURRENT_DATE GROUP BY category ORDER BY avg_expenditure DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE drug_approval (drug_name TEXT, approval_year INTEGER, approved BOOLEAN); INSERT INTO drug_approval (drug_name, approval_year, approved) VALUES ('DrugA', 2016, true), ('DrugB', 2017, true), ('DrugC', 2018, true), ('DrugD', 2019, true), ('DrugE', 2020, false);
How many drugs were approved each year from 2015 to 2020?
SELECT approval_year, COUNT(*) as drugs_approved FROM drug_approval WHERE approval_year BETWEEN 2015 AND 2020 AND approved = true GROUP BY approval_year;
gretelai_synthetic_text_to_sql
CREATE TABLE factories (factory_id INT, name TEXT, location TEXT); INSERT INTO factories (factory_id, name, location) VALUES (1, 'Factory A', 'New York'), (2, 'Factory B', 'Texas'), (3, 'Factory C', 'Louisiana'); CREATE TABLE safety_protocols (protocol_id INT, factory_id INT, protocol TEXT); INSERT INTO safety_protocols (protocol_id, factory_id, protocol) VALUES (1, 1, 'Fire Safety'), (2, 1, 'Emergency Exits'), (3, 2, 'Fire Safety'), (4, 2, 'Chemical Spills'), (5, 3, 'Fire Safety'), (6, 3, 'Hurricane Preparedness');
List all the safety protocols for factories located in Texas or Louisiana?
SELECT s.protocol FROM factories f JOIN safety_protocols s ON f.factory_id = s.factory_id WHERE f.location IN ('Texas', 'Louisiana');
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (DonorID INT, DonorName TEXT, Amount DECIMAL(10,2), Year INT); INSERT INTO Donors (DonorID, DonorName, Amount, Year) VALUES (1, 'John Doe', 500.00, 2021), (2, 'Jane Smith', 1500.00, 2021), (3, 'Bob Johnson', 750.00, 2021);
What is the percentage of donors who donated more than $1000 in the year 2021 compared to the total number of donors in that year?
SELECT (COUNT(DonorID) * 100.00 / (SELECT COUNT(DonorID) FROM Donors WHERE Year = 2021)) FROM Donors WHERE Amount > 1000 AND Year = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE Organizations (id INT, name TEXT, country TEXT); INSERT INTO Organizations (id, name, country) VALUES (1, 'WFP', 'Kenya'), (2, 'UNICEF', 'Kenya'); CREATE TABLE Donations (id INT, org_id INT, project TEXT, amount INT, donation_date DATE); INSERT INTO Donations (id, org_id, project, amount, donation_date) VALUES (1, 1, 'Food Security', 5000, '2021-01-01'), (2, 1, 'Food Security', 3000, '2021-02-15'), (3, 2, 'Food Security', 7000, '2021-04-20'), (4, 2, 'Food Security', 8000, '2021-12-31');
What is the total amount of donations received by each organization for the 'Food Security' project in Kenya in 2021?
SELECT O.name, SUM(D.amount) as total_donations FROM Donations D INNER JOIN Organizations O ON D.org_id = O.id WHERE D.project = 'Food Security' AND YEAR(D.donation_date) = 2021 GROUP BY O.name;
gretelai_synthetic_text_to_sql
CREATE TABLE MilitaryEquipmentSales (seller VARCHAR(255), buyer VARCHAR(255), equipment VARCHAR(255), sale_value FLOAT, sale_date DATE); INSERT INTO MilitaryEquipmentSales (seller, buyer, equipment, sale_value, sale_date) VALUES ('Lockheed Martin', 'Germany', 'F-35 Fighter Jet', 92000000, '2019-07-23');
Update the sale_value of the F-35 fighter jet sold to Germany in 2019 to 85,000,000.
UPDATE MilitaryEquipmentSales SET sale_value = 85000000 WHERE seller = 'Lockheed Martin' AND buyer = 'Germany' AND equipment = 'F-35 Fighter Jet' AND sale_date = '2019-07-23';
gretelai_synthetic_text_to_sql
CREATE TABLE countries (country_id INT PRIMARY KEY, country_name VARCHAR(255)); INSERT INTO countries (country_id, country_name) VALUES (1, 'India'), (2, 'China'), (3, 'Australia'); CREATE TABLE regions (region_id INT PRIMARY KEY, region_name VARCHAR(255), country_id INT); INSERT INTO regions (region_id, region_name, country_id) VALUES (1, 'East', 1), (2, 'West', 1), (3, 'North', 2), (4, 'South', 3); CREATE TABLE mobile_towers (tower_id INT PRIMARY KEY, region_id INT); INSERT INTO mobile_towers (tower_id, region_id) VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5); CREATE TABLE mobile_subscribers (subscriber_id INT PRIMARY KEY, region_id INT, data_usage FLOAT); INSERT INTO mobile_subscribers (subscriber_id, region_id, data_usage) VALUES (1, 1, 60.0), (2, 2, 45.0), (3, 3, 55.0), (4, 4, 40.0), (5, 5, 70.0);
List the mobile towers, regions, and countries for mobile subscribers with an average data usage over 50 MB.
SELECT c.country_name, r.region_name, m.tower_id FROM countries c JOIN regions r ON c.country_id = r.country_id JOIN mobile_towers m ON r.region_id = m.region_id JOIN mobile_subscribers s ON r.region_id = s.region_id GROUP BY r.region_id HAVING AVG(s.data_usage) > 50;
gretelai_synthetic_text_to_sql
CREATE TABLE attorneys (attorney_id INT, name VARCHAR(50), city VARCHAR(50)); INSERT INTO attorneys (attorney_id, name, city) VALUES (1, 'John Doe', 'New York'); CREATE TABLE cases (case_id INT, attorney_id INT, billing_amount DECIMAL(10, 2)); INSERT INTO cases (case_id, attorney_id, billing_amount) VALUES (1, 1, 5000.00), (2, 1, 7000.00);
What is the total billing amount for cases handled by attorney John Doe in the city of New York?
SELECT SUM(billing_amount) FROM cases INNER JOIN attorneys ON cases.attorney_id = attorneys.attorney_id WHERE attorneys.name = 'John Doe' AND attorneys.city = 'New York';
gretelai_synthetic_text_to_sql
CREATE TABLE Employees(id INT, department VARCHAR(20), position VARCHAR(20), salary INT, gender VARCHAR(10), full_time BOOLEAN);
What is the minimum salary paid to full-time employees in the Processing department?
SELECT MIN(salary) FROM Employees WHERE department = 'Processing' AND full_time = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE workouts (id INT, member_id INT, calories INT, workout_date DATE, member_gender VARCHAR(20));
What is the average calories burned per workout for members who identify as transgender or non-binary, for the past 6 months?
SELECT AVG(calories) as avg_calories FROM workouts WHERE member_gender IN ('transgender', 'non-binary') AND workout_date >= DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH) GROUP BY member_gender;
gretelai_synthetic_text_to_sql
CREATE TABLE tourism_data (id INT, country VARCHAR(50), destination VARCHAR(50), arrival_date DATE, age INT); INSERT INTO tourism_data (id, country, destination, arrival_date, age) VALUES (3, 'India', 'Australia', '2021-04-20', 42), (4, 'India', 'Australia', '2021-11-12', 22);
Delete records of tourists visiting Australia from India in 2021.
DELETE FROM tourism_data WHERE country = 'India' AND destination = 'Australia' AND YEAR(arrival_date) = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE CityAPD (programID INT, city VARCHAR(50), programDate DATE); INSERT INTO CityAPD (programID, city, programDate) VALUES (1, 'City A', '2021-03-01'), (2, 'City A', '2021-06-15');
How many professional development programs were conducted in 'City A' last year?
SELECT COUNT(*) FROM CityAPD WHERE city = 'City A' AND YEAR(programDate) = 2021 AND type = 'professional development';
gretelai_synthetic_text_to_sql
CREATE TABLE songs (id INT, title TEXT, release_year INT); INSERT INTO songs (id, title, release_year) VALUES (1, 'Song 1', 2020), (2, 'Song 2', 2019), (3, 'Song 3', 2021);
How many songs were released per year?
SELECT release_year, COUNT(id) as num_songs FROM songs GROUP BY release_year;
gretelai_synthetic_text_to_sql
CREATE TABLE Accidents (AccidentID INT, SiteID INT, Year INT); INSERT INTO Accidents (AccidentID, SiteID, Year) VALUES (1, 1, 2020), (2, 2, 2019), (3, 3, 2020);
What is the minimum number of accidents that occurred at each mining site in 2020?
SELECT SiteID, MIN(COUNT(*)) OVER (PARTITION BY SiteID) FROM Accidents WHERE Year = 2020 GROUP BY SiteID;
gretelai_synthetic_text_to_sql
CREATE TABLE tourism_data (visitor_id INT, country VARCHAR(50), arrival_age INT); INSERT INTO tourism_data (visitor_id, country, arrival_age) VALUES (1, 'USA', 35), (2, 'USA', 42), (3, 'Japan', 28), (4, 'Australia', 31), (5, 'UK', 29), (6, 'UK', 34), (7, 'Canada', 22), (8, 'Canada', 25);
What is the average arrival age of visitors from each country?
SELECT country, AVG(arrival_age) FROM tourism_data GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE if not exists bridges (id INT, name VARCHAR(100), location VARCHAR(50), design_load_rating FLOAT); INSERT INTO bridges (id, name, location, design_load_rating) VALUES (1, 'Downtown Bridge', 'downtown', 12000000);
What is the name of the bridge with the highest design load rating in 'downtown'?
SELECT name FROM bridges WHERE location = 'downtown' AND design_load_rating = (SELECT MAX(design_load_rating) FROM bridges WHERE location = 'downtown');
gretelai_synthetic_text_to_sql
CREATE TABLE Sales (sale_id INT PRIMARY KEY, menu_item VARCHAR(50), sale_quantity INT, sale_price DECIMAL(5,2), sale_date DATE); CREATE TABLE Menu (menu_item VARCHAR(50) PRIMARY KEY, menu_item_category VARCHAR(50));
What is the total sales revenue for each menu item in the "appetizer" category from the past month?
SELECT m.menu_item, SUM(s.sale_quantity * s.sale_price) FROM Sales s JOIN Menu m ON s.menu_item = m.menu_item WHERE m.menu_item_category = 'appetizer' AND s.sale_date >= DATEADD(month, -1, GETDATE()) GROUP BY m.menu_item;
gretelai_synthetic_text_to_sql
CREATE TABLE Company_Projects_NY (Company TEXT, Project_ID INT, Sustainable BOOLEAN, Timeline INT); INSERT INTO Company_Projects_NY (Company, Project_ID, Sustainable, Timeline) VALUES ('XYZ Construction', 1, true, 365), ('XYZ Construction', 2, true, 420), ('ABC Construction', 3, true, 450), ('ABC Construction', 4, false, 500), ('Smith & Sons', 5, true, 400), ('Smith & Sons', 6, false, 440), ('Green Builders', 7, true, 380), ('Green Builders', 8, true, 425), ('Green Builders', 9, false, 475);
What are the names and average project timelines for companies that have worked on both sustainable and non-sustainable projects in the state of New York, grouped by sustainability status?
SELECT cp.Sustainable, cp.Company, AVG(cp.Timeline) FROM Company_Projects_NY cp WHERE cp.Sustainable = true OR cp.Sustainable = false GROUP BY cp.Sustainable, cp.Company;
gretelai_synthetic_text_to_sql
CREATE TABLE aquatic_farms (id INT, name TEXT, country TEXT); INSERT INTO aquatic_farms (id, name, country) VALUES (1, 'Farm A', 'Canada'), (2, 'Farm B', 'USA'), (3, 'Farm C', 'Canada'), (4, 'Farm D', 'Mexico');
How many aquatic farms are in each country?
SELECT country, COUNT(*) FROM aquatic_farms GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE volunteers (id INT, name TEXT, country TEXT, signup_date DATE); INSERT INTO volunteers (id, name, country, signup_date) VALUES (1, 'Alice Johnson', 'Canada', '2021-06-10'), (2, 'Bob Brown', 'Canada', '2021-05-02'), (3, 'Charlie Green', 'Canada', '2021-08-25');
How many volunteers signed up in Canada between May 1st and August 31st, 2021?
SELECT COUNT(*) FROM volunteers WHERE country = 'Canada' AND signup_date BETWEEN '2021-05-01' AND '2021-08-31';
gretelai_synthetic_text_to_sql
CREATE TABLE Sales (SaleID INT, Game VARCHAR(50), Platform VARCHAR(50), Revenue INT, SalesDate DATE); INSERT INTO Sales (SaleID, Game, Platform, Revenue, SalesDate) VALUES (1, 'Beat Saber', 'Oculus', 50, '2023-02-12'); INSERT INTO Sales (SaleID, Game, Platform, Revenue, SalesDate) VALUES (2, 'Superhot VR', 'HTC Vive', 75, '2023-04-15');
What is the total revenue generated by VR games in Q2 2023?
SELECT SUM(Revenue) FROM Sales WHERE Platform = 'VR' AND QUARTER(SalesDate) = 2;
gretelai_synthetic_text_to_sql
CREATE TABLE military_bases (id INT, base_name TEXT, country TEXT, num_soldiers INT); INSERT INTO military_bases (id, base_name, country, num_soldiers) VALUES (1, 'Fort Bragg', 'USA', 54000), (2, 'Camp Bastion', 'UK', 28000), (3, 'Camp Taji', 'Iraq', 15000);
What is the maximum number of soldiers at a military base?
SELECT MAX(num_soldiers) as max_soldiers FROM military_bases;
gretelai_synthetic_text_to_sql
CREATE TABLE bay_of_bengal_species (species_name TEXT, location TEXT, conservation_status TEXT); INSERT INTO bay_of_bengal_species (species_name, location, conservation_status) VALUES ('Bengal Fin Whale', 'Bay of Bengal', 'Endangered'), ('Irrawaddy Dolphin', 'Bay of Bengal', 'Vulnerable');
How many marine species have been found in the Bay of Bengal and their conservation status.
SELECT COUNT(*), conservation_status FROM bay_of_bengal_species GROUP BY conservation_status;
gretelai_synthetic_text_to_sql
CREATE TABLE patients (patient_id INT, religion VARCHAR(50), therapy_outcome INT, medication_outcome INT);
What is the average improvement score after therapy and medication, grouped by religion?
SELECT religion, AVG(therapy_outcome) AS avg_therapy_score, AVG(medication_outcome) AS avg_medication_score FROM patients WHERE therapy_outcome IS NOT NULL AND medication_outcome IS NOT NULL GROUP BY religion;
gretelai_synthetic_text_to_sql
CREATE TABLE CountryIncidents (Country varchar(50), IncidentID int, IncidentDate date); INSERT INTO CountryIncidents (Country, IncidentID, IncidentDate) VALUES ('USA', 1, '2021-05-01'), ('USA', 2, '2021-04-01'), ('UK', 3, '2021-03-01');
Find the most recent cybersecurity incident for each country.
SELECT Country, MAX(IncidentDate) as MaxDate FROM CountryIncidents GROUP BY Country;
gretelai_synthetic_text_to_sql
CREATE TABLE customers (customer_id INT, first_name VARCHAR(50), last_name VARCHAR(50), email VARCHAR(100), phone_number VARCHAR(15), created_at TIMESTAMP);
Update the phone number for a customer in the customers table
UPDATE customers SET phone_number = '5559876543' WHERE customer_id = 1001;
gretelai_synthetic_text_to_sql
CREATE TABLE FairTradeFactories (FactoryID int, Country varchar(50));
Which country has the highest number of fair trade certified factories?
SELECT Country, COUNT(FactoryID) AS FactoryCount FROM FairTradeFactories GROUP BY Country ORDER BY FactoryCount DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE new_york_disaster_stats (id INT, disaster_type TEXT, disaster_date DATE); INSERT INTO new_york_disaster_stats (id, disaster_type, disaster_date) VALUES (1, 'Flood', '2021-01-01'), (2, 'Tornado', '2021-02-01'), (3, 'Earthquake', '2021-03-01');
how many natural disasters were reported in New York in 2021?
SELECT COUNT(*) FROM new_york_disaster_stats WHERE YEAR(disaster_date) = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE customer_preferences (customer_id INT, item_id INT, preference_score INT); INSERT INTO customer_preferences (customer_id, item_id, preference_score) VALUES (101, 1, 90), (101, 2, 80), (101, 3, 85), (102, 1, 75), (102, 4, 95);
Update the preference score for customer 101 and menu item 1 to 100
UPDATE customer_preferences SET preference_score = 100 WHERE customer_id = 101 AND item_id = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE students (id INT, region TEXT, start_year INT); CREATE TABLE publications (id INT, student_id INT, year INT); INSERT INTO students (id, region, start_year) VALUES (1, 'India', 2019), (2, 'China', 2020), (3, 'Japan', 2018); INSERT INTO publications (id, student_id, year) VALUES (1, 1, 2022), (2, 3, 2022), (3, 2, 2021);
How many publications were made by graduate students from 'Asia' in 2022?
SELECT COUNT(*) FROM publications JOIN students ON publications.student_id = students.id WHERE students.region = 'China' AND publications.year = 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE donors_australia (id INT, donor_name TEXT, country TEXT, organization_category TEXT, donation_date DATE); INSERT INTO donors_australia (id, donor_name, country, organization_category, donation_date) VALUES (1, 'Olivia Brown', 'Australia', 'Arts and Culture', '2020-04-16'); INSERT INTO donors_australia (id, donor_name, country, organization_category, donation_date) VALUES (2, 'William Taylor', 'Australia', 'Arts and Culture', '2020-06-02');
How many unique donors have contributed to arts and culture organizations in Australia in H1 of 2020?
SELECT COUNT(DISTINCT donor_name) FROM donors_australia WHERE country = 'Australia' AND organization_category = 'Arts and Culture' AND QUARTER(donation_date) = 1 OR QUARTER(donation_date) = 2 AND YEAR(donation_date) = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE highways (highway_id INT, highway_name VARCHAR(50), state VARCHAR(50), speed_limit INT);
List all the highways in Texas, along with their speed limit.
SELECT highway_name, speed_limit FROM highways WHERE state = 'Texas';
gretelai_synthetic_text_to_sql
CREATE TABLE ai_recommendations (id INT, recommendation_type TEXT, revenue FLOAT, recommendation_date DATE); INSERT INTO ai_recommendations (id, recommendation_type, revenue, recommendation_date) VALUES (1, 'AI Hotel', 700, '2022-01-03'), (2, 'AI Recommendation', 800, '2022-02-05');
What is the total revenue from AI-powered hotel recommendations, segmented by month?
SELECT MONTH(recommendation_date) AS month, SUM(revenue) FROM ai_recommendations WHERE recommendation_type = 'AI Hotel' GROUP BY month;
gretelai_synthetic_text_to_sql
CREATE TABLE rigs (rig_id INT, rig_name VARCHAR(50), location VARCHAR(50), drilling_date DATE); INSERT INTO rigs (rig_id, rig_name, location, drilling_date) VALUES (1, 'Rig1', 'GulfOfMexico', '2020-01-01'), (2, 'Rig2', 'GulfOfMexico', '2019-01-01');
List all rigs in the 'GulfOfMexico' that have a drilling_date in 2020
SELECT * FROM rigs WHERE location = 'GulfOfMexico' AND YEAR(drilling_date) = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE Satellite_Missions (id INT PRIMARY KEY, mission_name VARCHAR(100), launch_date DATE, country VARCHAR(100)); INSERT INTO Satellite_Missions (id, mission_name, launch_date, country) VALUES (1, 'Starlink 1', '2018-05-24', 'USA'); INSERT INTO Satellite_Missions (id, mission_name, launch_date, country) VALUES (2, 'GSAT-30', '2020-01-17', 'India'); INSERT INTO Satellite_Missions (id, mission_name, launch_date, country) VALUES (5, 'HISAKI', '2013-09-14', 'Japan'); INSERT INTO Satellite_Missions (id, mission_name, launch_date, country) VALUES (6, 'Express-AM5', '2014-12-22', 'Russia');
List the missions launched by Japan and Russia.
SELECT mission_name FROM Satellite_Missions WHERE country IN ('Japan', 'Russia');
gretelai_synthetic_text_to_sql
CREATE TABLE MilitaryInnovationEurope (id INT, project VARCHAR(50), country VARCHAR(50), budget INT); INSERT INTO MilitaryInnovationEurope (id, project, country, budget) VALUES (1, 'Stealth Technology', 'UK', 12000000), (2, 'Cyber Warfare', 'Germany', 9000000), (3, 'Artificial Intelligence', 'France', 11000000);
What is the total number of military innovation projects and their average budget in Europe?
SELECT COUNT(*) AS total_projects, AVG(budget) AS avg_budget FROM MilitaryInnovationEurope;
gretelai_synthetic_text_to_sql
CREATE TABLE AccommodationHistory (studentID INT, accommodationType VARCHAR(50), startDate DATE, endDate DATE);
Which accommodations were provided to each student in the AccommodationHistory table?
SELECT studentID, GROUP_CONCAT(accommodationType) FROM AccommodationHistory GROUP BY studentID;
gretelai_synthetic_text_to_sql
CREATE TABLE customers (customer_id INT, region VARCHAR(255), financial_wellbeing DECIMAL(10,2));
Show total financial wellbeing of customers living in a specific region
SELECT SUM(financial_wellbeing) FROM customers WHERE region = 'Middle East';
gretelai_synthetic_text_to_sql
CREATE TABLE Warehouse (item VARCHAR(10), quantity INT); INSERT INTO Warehouse (item, quantity) VALUES ('A101', 50), ('B202', 75);
Update the warehouse stock for item 'A101' to 100 pieces
UPDATE Warehouse SET quantity = 100 WHERE item = 'A101';
gretelai_synthetic_text_to_sql
CREATE TABLE Aircraft (Name VARCHAR(255), Speed INT); INSERT INTO Aircraft (Name, Speed) VALUES ('F-15 Eagle', 1875), ('F-22 Raptor', 1550), ('F-35 Lightning II', 1200);
What is the name of the aircraft with the maximum speed?
SELECT Name FROM Aircraft ORDER BY Speed DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE autonomous_buses (bus_id INT, bus_type VARCHAR(50), operating_status VARCHAR(50), registration_country VARCHAR(50)); CREATE VIEW singapore_buses AS SELECT * FROM autonomous_buses WHERE registration_country = 'Singapore';
How many autonomous buses are operating in Singapore's public transportation system?
SELECT COUNT(*) FROM singapore_buses WHERE bus_type = 'autonomous';
gretelai_synthetic_text_to_sql
CREATE TABLE virtual_tours (id INT, hotel_id INT, country TEXT, engagements INT); INSERT INTO virtual_tours (id, hotel_id, country, engagements) VALUES (1, 1, 'France', 350), (2, 2, 'Italy', 420), (3, 3, 'Germany', 500), (4, 4, 'Spain', 200); CREATE TABLE hotels (id INT, name TEXT, region TEXT); INSERT INTO hotels (id, name, region) VALUES (1, 'Hotel V', 'Europe'), (2, 'Hotel W', 'Europe'), (3, 'Hotel X', 'Europe'), (4, 'Hotel Y', 'Europe');
Which hotel in the 'Europe' region has the highest number of virtual tour engagements?
SELECT hotel_id, MAX(engagements) FROM virtual_tours GROUP BY hotel_id ORDER BY MAX(engagements) DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE alternative_sentencing_usage (country VARCHAR(255), total_cases INT, alternative_sentencing INT, year INT); INSERT INTO alternative_sentencing_usage (country, total_cases, alternative_sentencing, year) VALUES ('United States', 120000, 25000, 2018), ('Germany', 90000, 18000, 2019), ('Canada', 75000, 15000, 2017), ('Australia', 60000, 12000, 2016), ('England', 45000, 9000, 2015), ('United States', 130000, 30000, 2020);
List the top 5 countries with the highest percentage of alternative sentencing usage in the criminal justice system between 2015 and 2020?
SELECT country, (alternative_sentencing / total_cases) * 100 AS percentage FROM alternative_sentencing_usage WHERE year BETWEEN 2015 AND 2020 ORDER BY percentage DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE schools (name VARCHAR(255), city VARCHAR(255), enrollment INT, public BOOLEAN); INSERT INTO schools (name, city, enrollment, public) VALUES ('PS 123', 'New York City', 1000, TRUE), ('Stuyvesant High School', 'New York City', 3500, TRUE);
How many public schools are there in New York City, and what is the total enrollment?
SELECT COUNT(*) FROM schools WHERE city = 'New York City' AND public = TRUE; SELECT SUM(enrollment) FROM schools WHERE city = 'New York City' AND public = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE hotels (hotel_id INT, hotel_name TEXT, country TEXT, rating FLOAT); CREATE TABLE ai_chatbots (hotel_id INT, chatbot_name TEXT); CREATE TABLE ai_recs (hotel_id INT, rec_engine TEXT); CREATE TABLE virtual_tours (tour_id INT, hotel_id INT, views INT); INSERT INTO hotels VALUES (1, 'Hotel A', 'USA', 4.5); INSERT INTO ai_chatbots VALUES (1); INSERT INTO ai_recs VALUES (1); INSERT INTO virtual_tours VALUES (1, 1, 100);
What is the average number of virtual tour views for hotels in the US that use AI chatbots and AI-powered recommendation engines?
SELECT AVG(virtual_tours.views) FROM hotels INNER JOIN ai_chatbots ON hotels.hotel_id = ai_chatbots.hotel_id INNER JOIN ai_recs ON hotels.hotel_id = ai_recs.hotel_id INNER JOIN virtual_tours ON hotels.hotel_id = virtual_tours.hotel_id WHERE hotels.country = 'USA';
gretelai_synthetic_text_to_sql
CREATE TABLE satellites (satellite_id INT, name VARCHAR(255), launch_country VARCHAR(255), launch_date DATE, max_altitude INT);
What is the maximum altitude reached by a satellite launched in the last 5 years?
SELECT MAX(max_altitude) as max_altitude FROM satellites WHERE launch_date >= DATE(NOW()) - INTERVAL 5 YEAR;
gretelai_synthetic_text_to_sql
CREATE TABLE Donations (donor_id INT, reserve VARCHAR(50), amount DECIMAL(10, 2), purpose VARCHAR(50)); INSERT INTO Donations (donor_id, reserve, amount, purpose) VALUES (1, 'AsianReserve', 500.00, 'TigerConservation'), (2, 'AfricanReserve', 300.00, 'LionConservation'), (3, 'AsianReserve', 700.00, 'TigerConservation');
What is the total amount of funds donated to the "AfricanReserve" for lion conservation?
SELECT SUM(amount) FROM Donations WHERE reserve = 'AfricanReserve' AND purpose = 'LionConservation';
gretelai_synthetic_text_to_sql
CREATE TABLE users (user_id INT, age INT, gender VARCHAR(50));CREATE TABLE posts (post_id INT, user_id INT, content TEXT, post_date DATE, region VARCHAR(50)); INSERT INTO users (user_id, age, gender) VALUES (1, 25, 'female'), (2, 35, 'male'); INSERT INTO posts (post_id, user_id, content, post_date, region) VALUES (1, 1, 'Sustainable fashion is the future', '2023-03-25', 'Africa'), (2, 1, 'Shop second-hand', '2023-03-23', 'Africa');
How many users have posted content related to "sustainable fashion" in Africa in the past month, and what is their average age?
SELECT AVG(age) as avg_age, COUNT(DISTINCT user_id) as num_users FROM users JOIN posts ON users.user_id = posts.user_id WHERE content LIKE '%sustainable fashion%' AND posts.region = 'Africa' AND post_date >= DATEADD(month, -1, CURRENT_DATE);
gretelai_synthetic_text_to_sql
CREATE TABLE species (name VARCHAR(255), conservation_priority FLOAT, region VARCHAR(255)); INSERT INTO species (name, conservation_priority, region) VALUES ('Clownfish', 0.9, 'Coral Triangle'), ('Sea Turtle', 0.85, 'Coral Triangle'), ('Giant Clam', 0.8, 'Coral Triangle'), ('Dugong', 0.75, 'Coral Triangle'), ('Shark', 0.7, 'Indo-Pacific'), ('Blue Whale', 0.65, 'North Pacific');
What is the average conservation priority of marine species in the Indo-Pacific region?
SELECT AVG(conservation_priority) FROM species WHERE region = 'Indo-Pacific';
gretelai_synthetic_text_to_sql
CREATE TABLE Claims (PolicyholderID INT, PolicyType VARCHAR(20), ClaimAmount DECIMAL(10, 2), Country VARCHAR(50)); INSERT INTO Claims VALUES (1, 'Auto', 5000, 'India'); INSERT INTO Claims VALUES (2, 'Home', 3000, 'India');
What is the average claim amount for policyholders from India, partitioned by policy type?
SELECT PolicyType, AVG(ClaimAmount) AS AvgClaimAmount FROM Claims WHERE Country = 'India' GROUP BY PolicyType;
gretelai_synthetic_text_to_sql
CREATE TABLE wearable_devices (id VARCHAR(10), member_id VARCHAR(10), device_type VARCHAR(20), purchase_date DATE); INSERT INTO wearable_devices (id, member_id, device_type, purchase_date) VALUES ('001', '001', 'smartwatch', '2022-02-01'), ('002', '002', 'fitness_tracker', '2022-01-15'), ('003', '001', 'heart_rate_monitor', '2022-03-01');
Delete the wearable device with ID 002 from the wearable_devices table.
DELETE FROM wearable_devices WHERE id = '002';
gretelai_synthetic_text_to_sql
CREATE TABLE malware_detections(id INT, timestamp TIMESTAMP, malware_type VARCHAR(255));
What are the top 3 most common types of malware detected in the last year?
SELECT malware_type, COUNT(*) as detection_count FROM malware_detections WHERE timestamp >= NOW() - INTERVAL 1 YEAR GROUP BY malware_type ORDER BY detection_count DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE policies (id INT, deductible INT); INSERT INTO policies (id, deductible) VALUES (1, 250), (2, 1000);CREATE TABLE claims (id INT, policy_id INT, amount DECIMAL(10,2)); INSERT INTO claims (id, policy_id, amount) VALUES (1, 1, 5000), (2, 1, 3000), (3, 2, 1000)
What is the total claim amount for policies with a deductible below 500?
SELECT SUM(claims.amount) FROM claims JOIN policies ON claims.policy_id = policies.id WHERE policies.deductible < 500;
gretelai_synthetic_text_to_sql
CREATE TABLE if not exists iot_sensors (id INT, location VARCHAR(255), temperature FLOAT, reading_time DATETIME); INSERT INTO iot_sensors (id, location, temperature, reading_time) VALUES (1, 'Texas', 25.6, '2022-01-01 10:00:00'), (2, 'California', 22.3, '2022-01-01 10:00:00');
What is the average temperature in Texas IoT sensor readings for the past week?
SELECT AVG(temperature) FROM iot_sensors WHERE location = 'Texas' AND reading_time BETWEEN DATE_SUB(NOW(), INTERVAL 1 WEEK) AND NOW();
gretelai_synthetic_text_to_sql
CREATE TABLE ticket_sales (sale_id INT, sale_amount DECIMAL(10, 2), exhibition_id INT); INSERT INTO ticket_sales (sale_id, sale_amount, exhibition_id) VALUES (1, 20.00, 4);
What is the total revenue generated by the "Temporary" exhibitions?
SELECT SUM(sale_amount) FROM ticket_sales JOIN exhibitions ON ticket_sales.exhibition_id = exhibitions.exhibition_id WHERE exhibitions.exhibition_type = 'Temporary';
gretelai_synthetic_text_to_sql
CREATE TABLE products(product_id INT, category VARCHAR(255), price DECIMAL(5,2));INSERT INTO products (product_id, category, price) VALUES (1, 'Lipstick', 10.99), (2, 'Eyeshadow', 15.99), (3, 'Blush', 8.99), (4, 'Foundation', 20.99), (5, 'Mascara', 12.99);
Delete all makeup products with a price below the average?
DELETE FROM products WHERE price < (SELECT AVG(price) FROM products);
gretelai_synthetic_text_to_sql
CREATE TABLE Games (GameID INT, GameName VARCHAR(50), Genre VARCHAR(10), ReleaseYear INT); INSERT INTO Games (GameID, GameName, Genre, ReleaseYear) VALUES (1, 'Game1', 'FPS', 2010), (2, 'Game2', 'RPG', 2015), (3, 'Game3', 'FPS', 2018), (4, 'Game4', 'RPG', 2020), (5, 'Game5', 'FPS', 2012);
What is the total number of FPS and RPG games released in each year?
SELECT ReleaseYear, SUM(CASE WHEN Genre = 'FPS' THEN 1 ELSE 0 END) AS FPS_Count, SUM(CASE WHEN Genre = 'RPG' THEN 1 ELSE 0 END) AS RPG_Count FROM Games GROUP BY ReleaseYear;
gretelai_synthetic_text_to_sql
CREATE TABLE graduate_students (id INT, name VARCHAR(50), department VARCHAR(50), year INT); INSERT INTO graduate_students (id, name, department, year) VALUES (1, 'Charlie', 'Mathematics', 2019), (2, 'Diana', 'Mathematics', 2020); CREATE TABLE academic_publications (id INT, student_id INT, title VARCHAR(100), year INT); INSERT INTO academic_publications (id, student_id, title, year) VALUES (1, 1, 'Paper 1', 2019), (2, 1, 'Paper 2', 2020), (3, 2, 'Paper 3', 2020);
How many graduate students published papers in the Mathematics department each year?
SELECT academic_publications.year, COUNT(DISTINCT academic_publications.student_id) FROM academic_publications JOIN graduate_students ON academic_publications.student_id = graduate_students.id WHERE graduate_students.department = 'Mathematics' GROUP BY academic_publications.year;
gretelai_synthetic_text_to_sql
CREATE TABLE Endangered_Species (ID INT, Name VARCHAR(50), Population INT, Status VARCHAR(50), Region VARCHAR(50)); INSERT INTO Endangered_Species VALUES (1, 'Snowy Owl', 1000, 'Least Concern', 'Arctic'); INSERT INTO Endangered_Species VALUES (2, 'Gyrfalcon', 2000, 'Least Concern', 'Arctic'); INSERT INTO Endangered_Species VALUES (3, 'Peregrine Falcon', 1500, 'Vulnerable', 'Arctic');
What is the total population of all endangered species in the Arctic?
SELECT SUM(Population) FROM Endangered_Species WHERE Status = 'Vulnerable' OR Status = 'Endangered' OR Status = 'Critically Endangered';
gretelai_synthetic_text_to_sql
CREATE TABLE Attendees_Event_Location_3 (event_name VARCHAR(255), location VARCHAR(255), attendees INT); INSERT INTO Attendees_Event_Location_3 (event_name, location, attendees) VALUES ('Dance Performance', 'New York', 120), ('Dance Performance', 'California', 50), ('Art Exhibition', 'New York', 75), ('Theater Play', 'California', 60);
What is the total number of people who attended 'Dance Performance' events in 'New York'?
SELECT SUM(attendees) FROM Attendees_Event_Location_3 WHERE event_name = 'Dance Performance' AND location = 'New York';
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), (2, 'Grand Coulee', 'Washington', 79, 168.3), (3, 'Oroville', 'California', 53, 235);
Update the 'height' of dams in the 'public_works' schema with an 'id' of 3 to 120 meters.
UPDATE dams SET height = 120 WHERE id = 3;
gretelai_synthetic_text_to_sql
CREATE TABLE patients (patient_id INT, age INT, gender VARCHAR(10), condition VARCHAR(255), ethnicity VARCHAR(255)); CREATE TABLE therapy_sessions (session_id INT, patient_id INT, therapist_id INT, session_date DATE, approach_id INT); CREATE TABLE therapy_approaches (approach_id INT, name VARCHAR(255)); CREATE TABLE communities (community_id INT, name VARCHAR(255), type VARCHAR(255));
What is the average age of patients with PTSD who have undergone exposure therapy in the Native American community?
SELECT AVG(patients.age) FROM patients JOIN therapy_sessions ON patients.patient_id = therapy_sessions.patient_id JOIN therapy_approaches ON therapy_sessions.approach_id = therapy_approaches.approach_id JOIN communities ON patients.community_id = communities.community_id WHERE patients.condition = 'PTSD' AND therapy_approaches.name = 'exposure therapy' AND communities.type = 'Native American';
gretelai_synthetic_text_to_sql
CREATE TABLE faculty_publications (id INT, name VARCHAR(50), department VARCHAR(50), papers_published INT, publication_year INT);
What is the minimum number of academic papers published by a faculty member in the past 10 years in the English department?
SELECT MIN(papers_published) FROM faculty_publications WHERE department = 'English' AND publication_year BETWEEN YEAR(CURRENT_DATE) - 10 AND YEAR(CURRENT_DATE);
gretelai_synthetic_text_to_sql
CREATE TABLE timber_production (id INT, year INT, volume FLOAT); INSERT INTO timber_production (id, year, volume) VALUES (1, 2020, 1200.5), (2, 2021, 1500.7), (3, 2022, 1700.3);
How many timber production records were inserted before 2022?
SELECT COUNT(*) FROM timber_production WHERE year < 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE fan_demographics (fan_id INT, fan_age INT); INSERT INTO fan_demographics (fan_id, fan_age) VALUES (1, 25), (2, 45), (3, 17), (4, 67), (5, 10), (6, 70);
How many fans are under 13, 13-18, and over 65 in the fan_demographics table?
SELECT CASE WHEN fan_age < 13 THEN 'Under 13' WHEN fan_age <= 18 THEN '13-18' ELSE 'Over 65' END as age_group, COUNT(*) as num_fans FROM fan_demographics GROUP BY age_group;
gretelai_synthetic_text_to_sql
CREATE TABLE animal_population (animal_id INT, animal_type VARCHAR(10), age INT); INSERT INTO animal_population (animal_id, animal_type, age) VALUES (1, 'gazelle', 4); INSERT INTO animal_population (animal_id, animal_type, age) VALUES (2, 'antelope', 6); INSERT INTO animal_population (animal_id, animal_type, age) VALUES (3, 'gazelle', 3);
List all animals and their ages from the 'animal_population' table, ordered by age in descending order.
SELECT * FROM animal_population ORDER BY age DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE Concerts (genre VARCHAR(255), city VARCHAR(255), tickets_sold INT);
What is the total number of tickets sold for classical concerts in London?
SELECT SUM(tickets_sold) FROM Concerts WHERE genre = 'classical' AND city = 'London';
gretelai_synthetic_text_to_sql
CREATE TABLE workshops (id INT, name TEXT, type TEXT, participation_rate FLOAT); INSERT INTO workshops (id, name, type, participation_rate) VALUES (1, 'WorkA', 'Underrepresented', 0.85), (2, 'WorkB', 'Underrepresented', 0.78), (3, 'WorkC', 'General', 0.92);
What is the maximum participation_rate in AI workshops for underrepresented communities?
SELECT MAX(participation_rate) FROM workshops WHERE type = 'Underrepresented';
gretelai_synthetic_text_to_sql
CREATE TABLE MuseumVisitors (museum_id INT, visitors INT); INSERT INTO MuseumVisitors (museum_id, visitors) VALUES (100, 5000), (101, 7000);
Find the difference in visitor counts between two museums
SELECT m1.museum_id, m1.visitors - m2.visitors as visitor_difference FROM MuseumVisitors m1, MuseumVisitors m2 WHERE m1.museum_id = 100 AND m2.museum_id = 101;
gretelai_synthetic_text_to_sql
CREATE TABLE news_staff (id INT, name TEXT, age INT, gender TEXT, position TEXT); INSERT INTO news_staff (id, name, age, gender, position) VALUES (1, 'Alex Brown', 45, 'Male', 'Editor'); INSERT INTO news_staff (id, name, age, gender, position) VALUES (2, 'Kim Lee', 35, 'Female', 'Reporter');
What is the average age of all editors in the news_staff table?
SELECT AVG(age) FROM news_staff WHERE position = 'Editor';
gretelai_synthetic_text_to_sql
CREATE TABLE EnergyProjects (id INT, name VARCHAR(50), location VARCHAR(50), type VARCHAR(50), capacity FLOAT); INSERT INTO EnergyProjects (id, name, location, type, capacity) VALUES (1, 'Solar Farm 1', 'California', 'Solar', 500.0), (2, 'Wind Farm 1', 'Texas', 'Wind', 650.0);
What are the details of renewable energy projects with a capacity of at least 600?
SELECT * FROM EnergyProjects WHERE capacity >= 600.0;
gretelai_synthetic_text_to_sql
CREATE TABLE promoted_tweets (tweet_id INT, user_id INT, click_date DATE);CREATE TABLE users (user_id INT, country VARCHAR(50));
What are the top 3 countries with the most number of users who have clicked on a promoted tweet in the past month?
SELECT u.country, COUNT(p.tweet_id) as num_clicks FROM users u JOIN promoted_tweets p ON u.user_id = p.user_id WHERE p.click_date >= DATE(NOW()) - INTERVAL 1 MONTH GROUP BY u.country ORDER BY num_clicks DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE country_harvest (country TEXT, harvest_date DATE, quantity INT); INSERT INTO country_harvest (country, harvest_date, quantity) VALUES ('Norway', '2022-01-01', 5000), ('Norway', '2022-01-02', 5500), ('Canada', '2022-01-01', 7000), ('Canada', '2022-01-02', 7500);
What is the total number of fish harvested from each country in the past month?
SELECT country, SUM(quantity) FROM country_harvest WHERE harvest_date >= DATE_SUB(CURDATE(), INTERVAL 1 MONTH) GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE users (id INT, name VARCHAR(255), spending INT, category VARCHAR(255), timestamp TIMESTAMP);
What is the total ad spending by users in the "tech" category for the current quarter?
SELECT SUM(spending) FROM users WHERE category = 'tech' AND timestamp BETWEEN DATE_SUB(CURDATE(), INTERVAL QUARTER(CURDATE()) - 1 QUARTER) AND CURDATE();
gretelai_synthetic_text_to_sql
CREATE TABLE game_sessions (user_id INT, game_name VARCHAR(10), login_date DATE); INSERT INTO game_sessions (user_id, game_name, login_date) VALUES (1, 'A', '2021-01-01'), (2, 'B', '2021-01-02');
Find the number of users who played game 'A' on January 1, 2021
SELECT COUNT(*) FROM game_sessions WHERE game_name = 'A' AND login_date = '2021-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE virtual_tour (id INT, co2_eq DECIMAL(10, 2), tour_id INT); INSERT INTO virtual_tour (id, co2_eq, tour_id) VALUES (1, 2.5, 1);
What is the average CO2 emission for virtual tours?
SELECT AVG(virtual_tour.co2_eq) FROM virtual_tour;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_species (name TEXT, affected_by_acidification BOOLEAN, ocean TEXT); CREATE TABLE ocean_regions (name TEXT, area FLOAT);
What is the total number of marine species affected by ocean acidification in the Atlantic Ocean?
SELECT COUNT(*) FROM marine_species WHERE affected_by_acidification = TRUE AND ocean = (SELECT name FROM ocean_regions WHERE area = 'Atlantic Ocean');
gretelai_synthetic_text_to_sql
CREATE TABLE student_mental_health (student_id INT, grade_level INT, year INT, score INT); INSERT INTO student_mental_health (student_id, grade_level, year, score) VALUES (1, 1, 2019, 70), (2, 2, 2019, 75), (3, 1, 2020, 72), (4, 2, 2020, 78), (5, 1, 2021, 74), (6, 2, 2021, 79);
What is the average mental health score for students in each grade level over the past 3 years?
SELECT grade_level, AVG(score) as avg_score FROM student_mental_health WHERE year BETWEEN 2019 AND 2021 GROUP BY grade_level;
gretelai_synthetic_text_to_sql
CREATE TABLE Menu (MenuID INT, Name VARCHAR(50), Type VARCHAR(50), VendorID INT); INSERT INTO Menu (MenuID, Name, Type, VendorID) VALUES (1, 'Veggie Burger', 'Vegan', 1), (2, 'Falafel Wrap', 'Vegan', 1), (3, 'Breadless Sandwich', 'Gluten-free', 2);
What is the total number of menu items offered by each vendor that are either 'Vegan' or 'Gluten-free'?
SELECT VendorID, COUNT(*) FROM Menu WHERE Type IN ('Vegan', 'Gluten-free') GROUP BY VendorID;
gretelai_synthetic_text_to_sql
CREATE TABLE ArtPieces (id INT, country VARCHAR(255), type VARCHAR(255), price FLOAT); INSERT INTO ArtPieces (id, country, type, price) VALUES (1, 'Italy', 'Painting', 2000), (2, 'France', 'Sculpture', 2500), (3, 'Spain', 'Painting', 1800);
What is the total number of traditional art pieces and their average price by country?
SELECT country, COUNT(*), AVG(price) FROM ArtPieces GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE ocean_floor_mapping_projects (project_id INT, project_name TEXT, station_id INT); INSERT INTO ocean_floor_mapping_projects (project_id, project_name, station_id) VALUES (1, 'Project 1', 1), (2, 'Project 2', 3), (3, 'Project 3', 2); CREATE TABLE marine_life_research_stations (station_id INT, station_name TEXT, depth FLOAT); INSERT INTO marine_life_research_stations (station_id, station_name, depth) VALUES (1, 'Station A', 2500.3), (2, 'Station B', 1800.5), (3, 'Station C', 3200.7);
Present the maximum depth of marine life research stations per ocean floor mapping project
SELECT p.project_name, MAX(m.depth) FROM ocean_floor_mapping_projects p JOIN marine_life_research_stations m ON p.station_id = m.station_id GROUP BY p.project_id;
gretelai_synthetic_text_to_sql
CREATE TABLE Emissions (Emission_ID INT, Country_Name VARCHAR(50), Year INT, CO2_Emissions INT); INSERT INTO Emissions (Emission_ID, Country_Name, Year, CO2_Emissions) VALUES (1, 'Thailand', 2019, 100), (2, 'Thailand', 2020, 120), (3, 'France', 2019, 150), (4, 'France', 2020, 180), (5, 'Brazil', 2019, 200), (6, 'Brazil', 2020, 250); CREATE TABLE Countries (Country_Name VARCHAR(50), Continent VARCHAR(30)); INSERT INTO Countries (Country_Name, Continent) VALUES ('Thailand', 'Asia'), ('France', 'Europe'), ('Brazil', 'South America');
What is the total CO2 emission per continent by year?
SELECT C.Continent, E.Year, SUM(E.CO2_Emissions) AS Total_Emissions FROM Emissions E JOIN Countries C ON E.Country_Name = C.Country_Name GROUP BY C.Continent, E.Year ORDER BY E.Year;
gretelai_synthetic_text_to_sql
CREATE TABLE ExcavationSites (SiteID INT PRIMARY KEY, Name VARCHAR(255), Country VARCHAR(255), StartDate DATE, EndDate DATE);
Add a new excavation site 'Machu Picchu' in Peru started in 1911.
INSERT INTO ExcavationSites (SiteID, Name, Country, StartDate, EndDate) VALUES (7, 'Machu Picchu', 'Peru', '1911-07-24', NULL);
gretelai_synthetic_text_to_sql
CREATE TABLE cities (city_id INT, city_name VARCHAR(255)); INSERT INTO cities VALUES (1, 'New York'), (2, 'Los Angeles'), (3, 'Chicago'), (4, 'Houston'), (5, 'Phoenix'); CREATE TABLE user_activity (user_id INT, city_id INT, posts_count INT);
What are the top 5 cities with the most user engagement on our platform, and the corresponding number of posts in each city?
SELECT c.city_name, SUM(ua.posts_count) as total_posts FROM cities c INNER JOIN user_activity ua ON c.city_id = ua.city_id GROUP BY c.city_name ORDER BY total_posts DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_species (id INT, species VARCHAR(255)); INSERT INTO marine_species (id, species) VALUES (1, 'Dolphin'), (2, 'Shark'); CREATE TABLE pollution_control (id INT, species_id INT, species VARCHAR(255)); INSERT INTO pollution_control (id, species_id, species) VALUES (1, 1, 'Whale'), (2, 2, 'Seal'), (3, 3, 'Turtle');
Identify marine species that are not present in the marine_species table.
SELECT pollution_control.species FROM pollution_control LEFT JOIN marine_species ON pollution_control.species_id = marine_species.id WHERE marine_species.id IS NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE customers (id INT, name TEXT); CREATE TABLE orders (id INT, customer_id INT, item_id INT, order_value DECIMAL, is_sustainable BOOLEAN); CREATE TABLE items (id INT, name TEXT, category TEXT);
How many customers have made purchases for both regular and sustainable fashion items?
SELECT COUNT(DISTINCT c.id) FROM customers c JOIN orders o ON c.id = o.customer_id JOIN items i ON o.item_id = i.id WHERE i.category IN ('regular', 'sustainable');
gretelai_synthetic_text_to_sql