context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE marine_life (species_name TEXT, location TEXT, biomass FLOAT); INSERT INTO marine_life (species_name, location, biomass) VALUES ('Salmon', 'Pacific Ocean', 5.0), ('Blue Whale', 'Pacific Ocean', 200.0);
What is the total biomass (in tons) of all marine life in the Pacific Ocean?
SELECT SUM(biomass) FROM marine_life WHERE location = 'Pacific Ocean';
gretelai_synthetic_text_to_sql
CREATE TABLE research_grants (id INT, grant_date DATE, amount DECIMAL(10,2)); INSERT INTO research_grants (id, grant_date, amount) VALUES (1, '2021-01-01', 5000), (2, '2021-03-01', 7000), (3, '2020-02-01', 3000);
How many research grants were awarded in the last two years?
SELECT COUNT(*) FROM research_grants WHERE grant_date >= DATE_SUB(CURRENT_DATE, INTERVAL 2 YEAR);
gretelai_synthetic_text_to_sql
CREATE TABLE student (id INT, department_id INT, graduation_date DATE); INSERT INTO student (id, department_id, graduation_date) VALUES (1, 1, '2022-05-01'), (2, 1, '2021-05-01'), (3, 2, '2020-05-01');
What is the average time to graduation by department?
SELECT department.name, AVG(DATEDIFF(graduation_date, student.enrollment_date)) as avg_time_to_graduation FROM department LEFT JOIN student ON department.id = student.department_id GROUP BY department.name;
gretelai_synthetic_text_to_sql
CREATE TABLE SmartCities.Buildings (id INT, has_solar_panels BOOLEAN, energy_consumption FLOAT); INSERT INTO SmartCities.Buildings (id, has_solar_panels, energy_consumption) VALUES (1, true, 1200.5), (2, false, 800.2), (3, true, 900.7), (4, false, 700.3), (5, true, 600.0);
Determine the average energy consumption of buildings with solar panel installations in the 'SmartCities' schema.
SELECT AVG(energy_consumption) FROM SmartCities.Buildings WHERE has_solar_panels = true;
gretelai_synthetic_text_to_sql
CREATE TABLE charging_stations (station_id INT, type VARCHAR(20), city VARCHAR(20)); INSERT INTO charging_stations (station_id, type, city) VALUES (1, 'Car', 'Jakarta'), (2, 'Bike', 'Jakarta'), (3, 'Car', 'Jakarta'), (4, 'Bike', 'Jakarta');
How many charging stations for electric vehicles are there in Jakarta?
SELECT city, COUNT(*) FROM charging_stations WHERE city = 'Jakarta' GROUP BY city;
gretelai_synthetic_text_to_sql
CREATE TABLE disasters (id INT, disaster_name VARCHAR(50), start_date DATE, end_date DATE); INSERT INTO disasters (id, disaster_name, start_date, end_date) VALUES (1, 'Nepal Earthquake', '2015-04-25', '2015-05-03'), (2, 'Ebola Outbreak', '2014-12-29', '2016-06-10'), (3, 'Hurricane Matthew', '2016-09-28', '2016-10-09'),...
List all the disasters that occurred between January 2015 and December 2016.
SELECT disaster_name FROM disasters WHERE start_date BETWEEN '2015-01-01' AND '2016-12-31';
gretelai_synthetic_text_to_sql
CREATE TABLE nat_sec_threats (id INT, threat_name VARCHAR(255), country VARCHAR(255), threat_date DATE);
What are the details of the national security threats that originated from a specific country, say 'Russia', from the 'nat_sec_threats' table?
SELECT * FROM nat_sec_threats WHERE country = 'Russia';
gretelai_synthetic_text_to_sql
CREATE TABLE cultivators (id INT, name TEXT, state TEXT); INSERT INTO cultivators (id, name, state) VALUES (1, 'Cultivator A', 'California'); INSERT INTO cultivators (id, name, state) VALUES (2, 'Cultivator B', 'California'); CREATE TABLE strains (cultivator_id INT, name TEXT, type TEXT, year INT, potency INT); INSERT ...
Which cultivators in California had the highest average potency for their Indica strains in 2022?
SELECT c.name as cultivator_name, AVG(s.potency) as average_potency FROM cultivators c INNER JOIN strains s ON c.id = s.cultivator_id WHERE c.state = 'California' AND s.type = 'Indica' AND s.year = 2022 GROUP BY c.name ORDER BY average_potency DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE military_transactions (id INT, country VARCHAR(255), year INT, technology VARCHAR(255)); INSERT INTO military_transactions (id, country, year, technology) VALUES (4, 'Russia', 2019, 'Military Cyber Warfare Systems'), (5, 'Iran', 2019, 'Military Cyber Warfare Systems');
Which countries acquired military cyber warfare systems in 2019?
SELECT DISTINCT country FROM military_transactions WHERE technology = 'Military Cyber Warfare Systems' AND year = 2019;
gretelai_synthetic_text_to_sql
CREATE TABLE bus_routes (id INT, name VARCHAR(50), type VARCHAR(10), length DECIMAL(5,2), fare DECIMAL(5,2)); INSERT INTO bus_routes (id, name, type, length, fare) VALUES (1, 'Line 1A', 'Bus', 12.3, 2.5), (2, 'Line 2B', 'Tram', 15.8, 3.2);
What is the average daily fare collected by bus and tram routes?
SELECT type, AVG(fare) FROM bus_routes WHERE type IN ('Bus', 'Tram') GROUP BY type;
gretelai_synthetic_text_to_sql
CREATE TABLE threat_intelligence_v2 (id INT, name VARCHAR(255), ip_address VARCHAR(50), threat_level VARCHAR(10)); INSERT INTO threat_intelligence_v2 (id, name, ip_address, threat_level) VALUES (4, 'APT35', '172.20.0.1', 'Low'), (5, 'APT36', '10.1.1.1', 'High'), (6, 'APT37', '192.168.2.1', 'Medium');
What are the unique threat levels in the 'threat_intelligence_v2' table?
SELECT DISTINCT threat_level FROM threat_intelligence_v2;
gretelai_synthetic_text_to_sql
CREATE TABLE incidents (incident_id INT, incident_date DATE, severity INT);
How many security incidents were reported in the last 30 days, and what was the average severity level?
SELECT COUNT(*) as incident_count, AVG(severity) as avg_severity FROM incidents WHERE incident_date >= NOW() - INTERVAL 30 DAY;
gretelai_synthetic_text_to_sql
CREATE TABLE ticket_prices (ticket_id INT, game_id INT, price DECIMAL(5,2));
What is the total revenue from ticket sales for games with an attendance of more than 5000 people?
SELECT SUM(price * quantity) FROM ticket_sales JOIN ticket_prices ON ticket_sales.ticket_id = ticket_prices.ticket_id WHERE (SELECT COUNT(DISTINCT fan_id) FROM fans WHERE game_id = ticket_sales.game_id) > 5000;
gretelai_synthetic_text_to_sql
CREATE TABLE Streams (StreamID INT, TrackID INT, PlatformID INT, Date DATE, Streams INT); INSERT INTO Streams (StreamID, TrackID, PlatformID, Date, Streams) VALUES (1, 1, 1, '2022-01-01', 100);
What is the total number of streams for hip-hop tracks on Spotify, grouped by quarter?
SELECT EXTRACT(QUARTER FROM Date) as Quarter, SUM(Streams) as TotalStreams FROM Streams JOIN Tracks ON Streams.TrackID = Tracks.TrackID JOIN StreamingPlatforms ON Streams.PlatformID = StreamingPlatforms.PlatformID WHERE Genre = 'Hip-Hop' AND PlatformName = 'Spotify' GROUP BY Quarter;
gretelai_synthetic_text_to_sql
CREATE TABLE sales_data_2 (sale_id INT, product_id INT, sale_date DATE, price DECIMAL(5,2), quantity INT); INSERT INTO sales_data_2 (sale_id, product_id, sale_date, price, quantity) VALUES (6, 1, '2021-02-01', 12.50, 10), (7, 2, '2021-03-02', 13.00, 15), (8, 3, '2021-04-03', 12.75, 12), (9, 4, '2021-05-04', 45.00, 5), ...
Determine the total sales revenue for each month of the year
SELECT DATE_FORMAT(sale_date, '%Y-%m') AS month, SUM(price * quantity) AS total_sales_revenue FROM sales_data_2 GROUP BY month;
gretelai_synthetic_text_to_sql
CREATE TABLE Vessels (vessel_name VARCHAR(255)); INSERT INTO Vessels (vessel_name) VALUES ('VesselI'), ('VesselJ'); CREATE TABLE Maintenance (vessel_name VARCHAR(255), maintenance_start_date DATE, maintenance_end_date DATE); INSERT INTO Maintenance (vessel_name, maintenance_start_date, maintenance_end_date) VALUES ('Ve...
Calculate the total downtime (in hours) for 'VesselI' during its maintenance periods in Q3 of 2020.
SELECT SUM(DATEDIFF(hour, maintenance_start_date, maintenance_end_date)) FROM Maintenance WHERE vessel_name = 'VesselI' AND maintenance_start_date BETWEEN '2020-07-01' AND '2020-09-30';
gretelai_synthetic_text_to_sql
CREATE TABLE products_history (product_id INT, product_name TEXT, creation_date DATE);
How many financial products have been created in the last year?
SELECT COUNT(*) FROM products_history WHERE products_history.creation_date >= DATEADD(year, -1, CURRENT_DATE);
gretelai_synthetic_text_to_sql
CREATE TABLE Chemicals (chemical_id INT, chemical_name VARCHAR(20), last_updated DATE); CREATE TABLE Safety_Protocols (protocol_id INT, chemical_id INT, protocol_description VARCHAR(100));
List all chemicals and their safety protocols that were last updated before 2020-01-01.
SELECT Chemicals.chemical_name, Safety_Protocols.protocol_description FROM Chemicals INNER JOIN Safety_Protocols ON Chemicals.chemical_id = Safety_Protocols.chemical_id WHERE Chemicals.last_updated < '2020-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE network_usage (usage_id INT, subscriber_id INT, usage_date DATE, usage_type VARCHAR(50), usage_duration INT);
Update a network usage record's usage type and duration in the network_usage table
UPDATE network_usage SET usage_type = 'Broadband', usage_duration = 200 WHERE usage_id = 3001;
gretelai_synthetic_text_to_sql
CREATE TABLE SpaceMissions (mission_name VARCHAR(30), astronaut_nationality VARCHAR(20), duration INT); INSERT INTO SpaceMissions (mission_name, astronaut_nationality, duration) VALUES ('Mission3', 'UK', 300);
What is the maximum duration of space missions for astronauts from the UK?
SELECT MAX(duration) FROM SpaceMissions WHERE astronaut_nationality = 'UK';
gretelai_synthetic_text_to_sql
CREATE TABLE users (user_id INT, username VARCHAR(255), category VARCHAR(255), follower_count INT, post_count INT); INSERT INTO users (user_id, username, category, follower_count, post_count) VALUES (1, 'user1', 'content_creator', 60000, 35), (2, 'user2', 'politician', 20000, 30), (3, 'user3', 'content_creator', 70000,...
What is the total number of followers for users in the 'content_creator' category who have posted more than 30 times and have a follower count greater than 50000?
SELECT SUM(follower_count) FROM users WHERE category = 'content_creator' AND post_count > 30 AND follower_count > 50000;
gretelai_synthetic_text_to_sql
CREATE TABLE Charging_Stations (id INT, charging_station_id INT, operator VARCHAR(255), location VARCHAR(255), num_chargers INT, num_ports INT, power_level INT);
What are the top 5 busiest charging station locations with more than 7 charging stations and power level greater than 60?
SELECT location, COUNT(*) as num_ports FROM Charging_Stations WHERE num_chargers > 7 AND power_level > 60 GROUP BY location ORDER BY num_ports DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE spacecraft (id INT, name VARCHAR(50), manufacturer VARCHAR(50), mass FLOAT, launch_date DATE); INSERT INTO spacecraft (id, name, manufacturer, mass, launch_date) VALUES (1, 'New Glenn', 'Blue Origin', 720000.0, '2025-01-01'); INSERT INTO spacecraft (id, name, manufacturer, mass, launch_date) VALUES (2, 'Sh...
What is the average mass (in kg) of all spacecraft that have been used in space missions, excluding any spacecraft that have not yet been launched?
SELECT AVG(mass) FROM spacecraft WHERE launch_date IS NOT NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE festivals (id INT, artist_name VARCHAR(255)); INSERT INTO festivals (id, artist_name) VALUES (1, 'Taylor Swift'), (2, 'BTS'), (3, 'Taylor Swift'), (4, 'Ariana Grande');
Display the number of unique artists who have performed at music festivals
SELECT COUNT(DISTINCT artist_name) as num_unique_artists FROM festivals;
gretelai_synthetic_text_to_sql
CREATE TABLE energy_antarctica (year INT, energy_consumption INT); INSERT INTO energy_antarctica VALUES (2017, 100), (2018, 110), (2019, 120);
What is the total energy consumption in Antarctica for the last 3 years?
SELECT SUM(energy_consumption) FROM energy_antarctica WHERE year BETWEEN 2017 AND 2019;
gretelai_synthetic_text_to_sql
CREATE TABLE usage(customer_id INT, data_usage INT, usage_date DATE); CREATE TABLE customers(id INT, type VARCHAR(10), region VARCHAR(10));
What is the minimum data usage for postpaid mobile customers in the West region in the past month?
SELECT MIN(usage.data_usage) FROM usage JOIN customers ON usage.customer_id = customers.id WHERE customers.type = 'postpaid' AND customers.region = 'West' AND usage.usage_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH);
gretelai_synthetic_text_to_sql
CREATE TABLE sources (id INT PRIMARY KEY, source_name VARCHAR(50));
Add a new textile source 'Fair Trade Certified Organic Cotton' to the 'sources' table
INSERT INTO sources (id, source_name) VALUES (1, 'Fair Trade Certified Organic Cotton');
gretelai_synthetic_text_to_sql
CREATE TABLE renewable_energy_projects (id INT, project_name TEXT, country TEXT, technology TEXT, installed_capacity FLOAT); INSERT INTO renewable_energy_projects (id, project_name, country, technology, installed_capacity) VALUES (1, 'WindFarm1', 'green_country', 'wind', 300.0), (2, 'SolarPlant1', 'solar_country', 'sol...
What is the maximum installed capacity of wind projects in 'green_country'?
SELECT MAX(installed_capacity) FROM renewable_energy_projects WHERE country = 'green_country' AND technology = 'wind';
gretelai_synthetic_text_to_sql
CREATE TABLE donors (id INT, name VARCHAR(50), total_donations DECIMAL(10,2), donation_year INT); INSERT INTO donors (id, name, total_donations, donation_year) VALUES (1, 'John Doe', 500.00, 2020), (2, 'Jane Smith', 750.00, 2019), (3, 'Mike Johnson', 300.00, 2021);
What is the average donation amount per donor, partitioned by year and ordered by total donation amount?
SELECT donation_year, AVG(total_donations) avg_donation, RANK() OVER (PARTITION BY donation_year ORDER BY avg_donation DESC) donor_rank FROM donors GROUP BY donation_year ORDER BY donation_year, avg_donation DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE dishes (dish_id INT, dish_name VARCHAR(50), dish_type VARCHAR(20), calorie_count INT, added_date DATE); INSERT INTO dishes (dish_id, dish_name, dish_type, calorie_count, added_date) VALUES (1, 'Veggie Delight', 'vegan', 300, '2021-05-01'), (2, 'Tofu Stir Fry', 'vegan', 450, '2021-05-02'), (3, 'Chickpea Cur...
Display the dishes and their calorie counts in the order they were added, for vegan dishes only.
SELECT dish_name, calorie_count FROM dishes WHERE dish_type = 'vegan' ORDER BY added_date;
gretelai_synthetic_text_to_sql
CREATE TABLE humanitarian_assistance (id INT, operation VARCHAR(255), region VARCHAR(255), budget DECIMAL(10,2));
What is the average budget for humanitarian assistance operations for each region?
SELECT region, AVG(budget) FROM humanitarian_assistance GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE materials (id INT, name VARCHAR(50), quantity INT, country VARCHAR(50)); INSERT INTO materials (id, name, quantity, country) VALUES (1, 'organic cotton', 1000, 'India'), (2, 'recycled polyester', 1500, 'China'), (3, 'hemp', 500, 'Brazil');
What is the total quantity of sustainable materials in Brazil?
SELECT SUM(quantity) FROM materials WHERE country = 'Brazil' AND name LIKE '%sustainable%';
gretelai_synthetic_text_to_sql
CREATE TABLE Buildings (id INT, sector VARCHAR(20), CO2_emission FLOAT); INSERT INTO Buildings (id, sector, CO2_emission) VALUES (1, 'Renewable', 50.5), (2, 'Non-Renewable', 80.0);
What is the average CO2 emission of buildings in the renewable energy sector?
SELECT AVG(CO2_emission) FROM Buildings WHERE sector = 'Renewable';
gretelai_synthetic_text_to_sql
CREATE TABLE student_exams (student_id INT, district_id INT, exam_date DATE); INSERT INTO student_exams (student_id, district_id, exam_date) VALUES (1, 101, '2022-01-01'), (2, 101, '2022-01-05'), (3, 102, '2022-01-03'), (4, 102, '2022-01-07'), (5, 103, '2022-01-02');
What is the number of days between each student's exam date, ordered by district_id and then by the number of days between exams?
SELECT student_id, district_id, exam_date, exam_date - LAG(exam_date) OVER (PARTITION BY district_id ORDER BY student_id) as days_between_exams FROM student_exams ORDER BY district_id, days_between_exams;
gretelai_synthetic_text_to_sql
CREATE TABLE visitor_stats (id INT PRIMARY KEY, visitor_country VARCHAR(50), year INT, month INT, num_visitors INT); INSERT INTO visitor_stats (id, visitor_country, year, month, num_visitors) VALUES (1, 'Canada', 2019, 6, 15000); INSERT INTO visitor_stats (id, visitor_country, year, month, num_visitors) VALUES (2, 'Can...
What is the maximum number of visitors to Greece from Canada in a single month?
SELECT MAX(num_visitors) FROM visitor_stats WHERE visitor_country = 'Canada' AND year = 2019 AND month IS NOT NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE Accommodations (SchoolName VARCHAR(255), Student VARCHAR(255), Accommodation VARCHAR(255)); INSERT INTO Accommodations (SchoolName, Student, Accommodation) VALUES ('SchoolA', 'Student1', 'Extra Time'), ('SchoolA', 'Student2', 'Reader'), ('SchoolB', 'Student3', 'Extra Time');
What is the total number of accommodations provided for students with learning disabilities in each school?
SELECT SchoolName, COUNT(*) as TotalAccommodations FROM Accommodations WHERE Accommodation LIKE '%Learning Disability%' GROUP BY SchoolName;
gretelai_synthetic_text_to_sql
CREATE TABLE vehicles (vehicle_id INT, make TEXT, model TEXT, year INT, type TEXT, city_name TEXT);
What is the market share of electric vehicles in the top 10 most populous cities in China?
SELECT city_name, SUM(CASE WHEN type = 'Electric' THEN 1 ELSE 0 END) / COUNT(*) FROM vehicles GROUP BY city_name ORDER BY COUNT(*) DESC LIMIT 10;
gretelai_synthetic_text_to_sql
CREATE TABLE transactions (id INT, client_id INT, transaction_amount DECIMAL(10,2), transaction_date DATE); INSERT INTO transactions (id, client_id, transaction_amount, transaction_date) VALUES (1, 1, 500.00, '2022-01-01'), (2, 2, 800.00, '2022-01-02'), (3, 1, 1200.00, '2022-01-03'); CREATE TABLE clients (id INT, name ...
What is the total transaction amount for each client?
SELECT clients.id, clients.name, SUM(transactions.transaction_amount) FROM clients INNER JOIN transactions ON clients.id = transactions.client_id GROUP BY clients.id;
gretelai_synthetic_text_to_sql
CREATE TABLE Projects (id INT, name VARCHAR(255), status VARCHAR(255), start_date DATE); INSERT INTO Projects (id, name, status, start_date) VALUES (1, 'Bridge Construction', 'Not Started', '2023-01-01'); INSERT INTO Projects (id, name, status, start_date) VALUES (2, 'Road Widening', 'In Progress', '2022-06-01'); CREAT...
What are the structural materials used in the projects that have not started yet?
SELECT m.name FROM Materials m JOIN Projects p ON m.name = 'Steel' WHERE p.start_date > CURDATE() AND p.status = 'Not Started';
gretelai_synthetic_text_to_sql
CREATE TABLE products (product_id INT PRIMARY KEY, cruelty_free BOOLEAN); INSERT INTO products (product_id, cruelty_free) VALUES (1, true), (2, true), (3, false), (4, true);
What is the total number of cruelty-free certified products?
SELECT COUNT(*) FROM products WHERE cruelty_free = true;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_protected_areas (name VARCHAR(255), area_id INT, depth FLOAT, size INT, country VARCHAR(255)); INSERT INTO marine_protected_areas (name, area_id, depth, size, country) VALUES ('Cinque Terre Marine Protected Area', 15, 10, 3800, 'Italy'), ('Kornati National Park', 16, 100, 22000, 'Croatia');
What is the total size of marine protected areas in the Mediterranean Sea?
SELECT SUM(size) FROM marine_protected_areas WHERE country = 'Mediterranean Sea';
gretelai_synthetic_text_to_sql
CREATE TABLE dispensary_sales (id INT, strain VARCHAR(255), quantity INT, revenue FLOAT);
What are the top 3 strains sold in 'dispensary_sales' table?
SELECT strain, SUM(quantity) as total_quantity FROM dispensary_sales GROUP BY strain ORDER BY total_quantity DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE astronauts(name TEXT, missions INTEGER, days_in_space REAL); INSERT INTO astronauts(name, missions, days_in_space) VALUES('Neil Armstrong', 1, 265.5), ('Buzz Aldrin', 1, 216.4);
What is the maximum number of days spent in space by an astronaut?
SELECT MAX(days_in_space) FROM astronauts;
gretelai_synthetic_text_to_sql
CREATE TABLE Donations (DonorID int, DonationDate date, Amount decimal(10,2)); INSERT INTO Donations (DonorID, DonationDate, Amount) VALUES (1, '2021-01-01', 500.00), (2, '2021-02-15', 300.00);
What is the total amount donated by top 5 donors in 2021?
SELECT SUM(Amount) as TotalDonation FROM (SELECT DonorID, SUM(Amount) as Amount FROM Donations WHERE YEAR(DonationDate) = 2021 GROUP BY DonorID ORDER BY Amount DESC LIMIT 5) as TopDonors;
gretelai_synthetic_text_to_sql
CREATE TABLE GovernmentBudget (id INT, department VARCHAR(50), program VARCHAR(50), budget DECIMAL(10,2)); INSERT INTO GovernmentBudget (id, department, program, budget) VALUES (1, 'Education', 'Elementary School', 50000), (2, 'Education', 'High School', 120000), (3, 'Education', 'College', 200000), (4, 'Healthcare', '...
What is the total budget allocated for education programs in the "GovernmentBudget" table, for each department, where the budget was over $100,000?
SELECT department, SUM(budget) as total_budget FROM GovernmentBudget WHERE budget > 100000 AND program LIKE '%Education%' GROUP BY department;
gretelai_synthetic_text_to_sql
CREATE TABLE cybersecurity_incidents (id INT, name VARCHAR(255), severity_level INT, reported_date DATE, department_id INT); CREATE TABLE government_departments (id INT, name VARCHAR(255)); INSERT INTO cybersecurity_incidents (id, name, severity_level, reported_date, department_id) VALUES (1, 'Incident A', 4, '2022-01-...
What is the total number of cybersecurity incidents and their corresponding severity levels, along with the government departments responsible for addressing them in the last 24 months?
SELECT COUNT(id) as total_incidents, i.severity_level, d.name as department_name FROM cybersecurity_incidents i JOIN government_departments d ON i.department_id = d.id WHERE i.reported_date >= DATE_SUB(CURRENT_DATE, INTERVAL 24 MONTH) GROUP BY i.severity_level, d.name;
gretelai_synthetic_text_to_sql
CREATE TABLE DeletedInitiatives (Initiative VARCHAR(50), Department VARCHAR(50), DeleteDate DATE); INSERT INTO DeletedInitiatives (Initiative, Department, DeleteDate) VALUES ('Food Aid Program', 'Social Welfare', '2022-01-18'), ('Job Training Program', 'Social Welfare', '2022-03-05'), ('Housing Assistance', 'Social Wel...
How many 'Social Welfare' initiatives were deleted from the database in Q1 of 2022?
SELECT COUNT(*) FROM DeletedInitiatives WHERE Department = 'Social Welfare' AND DeleteDate >= '2022-01-01' AND DeleteDate < '2022-04-01';
gretelai_synthetic_text_to_sql
CREATE TABLE warehouse_stats (warehouse_id VARCHAR(5), avg_weight DECIMAL(5,2)); INSERT INTO warehouse_stats (warehouse_id, avg_weight) VALUES ('LA', 2.5), ('NY', 3.0), ('CH', 2.0), ('MI', 1.5), ('AT', 4.0);
What is the average package weight for each warehouse?
SELECT warehouse_id, avg_weight FROM warehouse_stats;
gretelai_synthetic_text_to_sql
CREATE TABLE Employees (EmployeeID INT, Salary INT, Department VARCHAR(50));
Find the average salary of employees in each department, ranked by the average salary in descending order, and display the top 3 departments.
SELECT Department, AVG(Salary) AS AvgSalary FROM Employees GROUP BY Department ORDER BY AvgSalary DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE Exhibitions (id INT, city VARCHAR(255), visitors INT, year INT); INSERT INTO Exhibitions (id, city, visitors, year) VALUES (1, 'New York', 2500, 2018), (2, 'Los Angeles', 1800, 2019), (3, 'Chicago', 2200, 2018), (4, 'San Francisco', 1500, 2019), (5, 'Miami', 1200, 2018), (6, 'Tokyo', 1900, 2018), (7, 'Toky...
What is the total number of visitors who attended exhibitions in Tokyo, grouped by year?
SELECT year, SUM(visitors) FROM Exhibitions WHERE city = 'Tokyo' GROUP BY year;
gretelai_synthetic_text_to_sql
CREATE TABLE Members (member_id INT, membership_date DATE); INSERT INTO Members (member_id, membership_date) VALUES (1, '2022-01-01'), (2, '2022-02-15'), (3, '2022-03-05');
Find the number of new museum members per month
SELECT EXTRACT(MONTH FROM membership_date) as month, COUNT(*) as new_members FROM Members GROUP BY month;
gretelai_synthetic_text_to_sql
CREATE VIEW contractor_info AS SELECT contractor_name FROM defense_contracts;
List all the unique defense contractor names from the contractor_info view.
SELECT DISTINCT contractor_name FROM contractor_info;
gretelai_synthetic_text_to_sql
CREATE TABLE autonomous_test_vehicles (vehicle_id INT, make VARCHAR(50), model VARCHAR(50), autonomy_level INT);
What is the total number of autonomous and semi-autonomous vehicles in the 'autonomous_test_vehicles' table?
SELECT COUNT(*) FROM autonomous_test_vehicles WHERE autonomy_level IN (1, 2, 3, 4, 5);
gretelai_synthetic_text_to_sql
CREATE TABLE emergency_equipment (eid INT, did INT, cost DECIMAL(10, 2), PRIMARY KEY(eid), FOREIGN KEY (did) REFERENCES districts(did));
What is the total cost of emergency equipment for each district?
SELECT d.name, SUM(ee.cost) as total_cost FROM districts d JOIN emergency_equipment ee ON d.did = ee.did GROUP BY d.name;
gretelai_synthetic_text_to_sql
CREATE TABLE carbon_pricing (id INT, country VARCHAR(255), scheme VARCHAR(255), revenue FLOAT); INSERT INTO carbon_pricing (id, country, scheme, revenue) VALUES (1, 'United States', 'ETS', 2000000); INSERT INTO carbon_pricing (id, country, scheme, revenue) VALUES (2, 'United States', 'Carbon Tax', 1500000); INSERT INTO...
Calculate the total carbon pricing revenue for the United States and China.
SELECT SUM(revenue) FROM carbon_pricing WHERE country IN ('United States', 'China');
gretelai_synthetic_text_to_sql
CREATE TABLE Menu (menu_name VARCHAR(20), item_name VARCHAR(30), price DECIMAL(5,2)); INSERT INTO Menu (menu_name, item_name, price) VALUES ('Dinner', 'Seafood Paella', 21.99);
Delete the 'Seafood Paella' from the 'Dinner' menu
DELETE FROM Menu WHERE menu_name = 'Dinner' AND item_name = 'Seafood Paella';
gretelai_synthetic_text_to_sql
CREATE TABLE donations (donation_id INT, donation_amount DECIMAL(10,2), social_impact_project VARCHAR(255), donation_date DATE); INSERT INTO donations (donation_id, donation_amount, social_impact_project, donation_date) VALUES (1, 200, 'Education', '2020-07-01'), (2, 300, 'Healthcare', '2020-08-05'), (3, 150, 'Environm...
What is the average donation amount per social impact project in H2 2020?
SELECT AVG(donation_amount) FROM donations WHERE YEAR(donation_date) = 2020 AND MONTH(donation_date) > 6 GROUP BY social_impact_project;
gretelai_synthetic_text_to_sql
CREATE TABLE AISafety (id INT, incident_sector VARCHAR(50), incident_type VARCHAR(50)); INSERT INTO AISafety (id, incident_sector, incident_type) VALUES (1, 'Healthcare', 'Data Privacy'), (2, 'Healthcare', 'Medical Error'), (3, 'Finance', 'Financial Loss'), (4, 'Healthcare', 'Unintended Consequence'), (5, 'Healthcare',...
What is the total number of AI safety incidents reported in the healthcare sector, and what is the maximum number of incidents reported for a single incident type?
SELECT incident_sector, COUNT(incident_type) as incident_count FROM AISafety WHERE incident_sector = 'Healthcare' GROUP BY incident_sector; SELECT MAX(incident_count) as max_incidents FROM (SELECT incident_sector, COUNT(incident_type) as incident_count FROM AISafety WHERE incident_sector = 'Healthcare' GROUP BY inciden...
gretelai_synthetic_text_to_sql
CREATE TABLE Contracts (id INT, country VARCHAR(255), value FLOAT);
Show the total value of defense contracts for each country in the 'Contracts' table, sorted by the total value in descending order
SELECT country, SUM(value) as total_value FROM Contracts GROUP BY country ORDER BY total_value DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE PreservationProjects (id INT, name TEXT, country TEXT, revenue FLOAT); INSERT INTO PreservationProjects (id, name, country, revenue) VALUES (1, 'Roman Colosseum Restoration', 'Italy', 5000000), (2, 'Florence Museum Renovation', 'Italy', 7000000);
What is the total revenue of cultural heritage preservation projects in Italy?
SELECT SUM(revenue) FROM PreservationProjects WHERE country = 'Italy';
gretelai_synthetic_text_to_sql
CREATE TABLE sales (id INT, category VARCHAR(255), subcategory VARCHAR(255), gender VARCHAR(50), material VARCHAR(50), country VARCHAR(50), quantity INT); INSERT INTO sales (id, category, subcategory, gender, material, country, quantity) VALUES (1, 'Tops', 'Hoodies', 'Unisex', 'Organic Cotton', 'Japan', 40); INSERT INT...
What is the total quantity of unisex organic cotton hoodies sold in Japan?
SELECT SUM(quantity) FROM sales WHERE category = 'Tops' AND subcategory = 'Hoodies' AND gender = 'Unisex' AND material = 'Organic Cotton' AND country = 'Japan';
gretelai_synthetic_text_to_sql
CREATE TABLE data_usage (usage_id INT, data_usage INT, usage_date DATE);
What is the total data usage for the month?
SELECT SUM(data_usage) FROM data_usage WHERE usage_date BETWEEN '2022-01-01' AND '2022-01-31';
gretelai_synthetic_text_to_sql
CREATE TABLE EthicalFashion.GarmentSales (garment_id INT, selling_price DECIMAL(5,2), production_region VARCHAR(20)); INSERT INTO EthicalFashion.GarmentSales (garment_id, selling_price, production_region) VALUES (1, 55.99, 'Asia'), (2, 44.49, 'Africa'), (3, 77.50, 'South America');
Identify the garments with the highest selling price, per production region?
SELECT garment_id, selling_price, production_region, ROW_NUMBER() OVER (PARTITION BY production_region ORDER BY selling_price DESC) AS rank FROM EthicalFashion.GarmentSales;
gretelai_synthetic_text_to_sql
CREATE TABLE plants (plant_id INT, plant_name VARCHAR(50), department VARCHAR(50), production_output INT); INSERT INTO plants (plant_id, plant_name, department, production_output) VALUES (1, 'PlantA', 'Manufacturing', 500), (2, 'PlantB', 'Engineering', 700), (3, 'PlantC', 'Manufacturing', 600), (4, 'PlantD', 'Manufactu...
What is the average production output of plants in the 'Manufacturing' department?
SELECT AVG(production_output) FROM plants WHERE department = 'Manufacturing';
gretelai_synthetic_text_to_sql
CREATE TABLE MentalHealthParityRegulations (State VARCHAR(20), Year INT, Regulation VARCHAR(100)); INSERT INTO MentalHealthParityRegulations (State, Year, Regulation) VALUES ('California', 2018, 'Regulation 1'), ('California', 2019, 'Regulation 2'), ('Texas', 2017, 'Regulation A'), ('Texas', 2018, 'Regulation B'), ('Ne...
Identify the state with the lowest number of mental health parity regulations implemented.
SELECT State, MIN(RegulationCount) AS LowestCount FROM (SELECT State, COUNT(*) AS RegulationCount FROM MentalHealthParityRegulations GROUP BY State) AS RegulationCounts GROUP BY State;
gretelai_synthetic_text_to_sql
CREATE TABLE co2_emissions (building_id INT, building_name VARCHAR(255), city VARCHAR(255), co2_emissions_tons_per_sqm DECIMAL); INSERT INTO co2_emissions (building_id, building_name, city, co2_emissions_tons_per_sqm) VALUES (1, 'Green Building 1', 'NYC', 0.5); INSERT INTO co2_emissions (building_id, building_name, cit...
What is the maximum and minimum CO2 emissions (in tons) per square meter of building area for each city?
SELECT city, MAX(co2_emissions_tons_per_sqm) as max_co2_emissions_tons_per_sqm, MIN(co2_emissions_tons_per_sqm) as min_co2_emissions_tons_per_sqm FROM co2_emissions GROUP BY city;
gretelai_synthetic_text_to_sql
CREATE TABLE circular_economy_initiatives (initiative_id INT PRIMARY KEY, organization_id INT, initiative_date DATE);
How many circular economy initiatives were implemented by each organization?
SELECT organization_id, COUNT(*) FROM circular_economy_initiatives GROUP BY organization_id;
gretelai_synthetic_text_to_sql
CREATE TABLE hotel_ratings (hotel_id INT, hotel_name TEXT, country TEXT, stars INT, rating FLOAT); INSERT INTO hotel_ratings (hotel_id, hotel_name, country, stars, rating) VALUES (1, 'Hotel Royal', 'USA', 4, 8.5), (2, 'Hotel Paris', 'France', 5, 9.0), (3, 'Hotel Tokyo', 'Japan', 4, 8.7), (4, 'Hotel Rome', 'Italy', 3, 7...
What is the distribution of hotel ratings for hotels in a given star range?
SELECT stars, COUNT(*) as hotel_count, AVG(rating) as avg_rating FROM hotel_ratings WHERE stars BETWEEN 3 AND 5 GROUP BY stars;
gretelai_synthetic_text_to_sql
CREATE TABLE countries (country VARCHAR(255)); INSERT INTO countries (country) VALUES ('USA'), ('China'), ('Russia'), ('India'); CREATE VIEW national_security AS SELECT c.country, n.strategy VARCHAR(255) FROM countries c CROSS JOIN (SELECT 'strategy1' AS strategy UNION ALL SELECT 'strategy2' UNION ALL SELECT 'strategy3...
Identify the number of unique cybersecurity strategies for each country in the 'national_security' table.
SELECT c.country, COUNT(DISTINCT n.strategy) FROM countries c INNER JOIN national_security n ON c.country = n.country GROUP BY c.country;
gretelai_synthetic_text_to_sql
CREATE TABLE virtual_tours (tour_id INT, hotel_name TEXT, country TEXT, engagement_rate FLOAT); INSERT INTO virtual_tours (tour_id, hotel_name, country, engagement_rate) VALUES (1, 'Hotel E', 'Mexico', 0.04), (2, 'Hotel F', 'Mexico', 0.06), (3, 'Hotel G', 'Mexico', 0.05);
What is the virtual tour engagement rate for each hotel in Mexico, ordered by engagement rate in descending order?
SELECT country, hotel_name, engagement_rate FROM virtual_tours WHERE country = 'Mexico' ORDER BY engagement_rate DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE menu_item_sales(menu_item VARCHAR(50), sale_date DATE, quantity INT); INSERT INTO menu_item_sales VALUES ('Burger', '2022-01-01', 50), ('Pizza', '2022-01-01', 30), ('Salad', '2022-01-01', 20), ('Burger', '2022-01-02', 60), ('Pizza', '2022-01-02', 40), ('Salad', '2022-01-02', 30), ('Burger', '2022-01-03', 4...
How many of each menu item were sold per day in the past week?
SELECT menu_item, sale_date, SUM(quantity) AS total_sold FROM menu_item_sales WHERE sale_date >= CURRENT_DATE - INTERVAL '7 days' GROUP BY menu_item, sale_date ORDER BY sale_date, total_sold DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (DonorID INT, Name TEXT, DonationAmount DECIMAL);
What is the minimum donation amount?
SELECT MIN(DonationAmount) FROM Donors;
gretelai_synthetic_text_to_sql
CREATE TABLE initiatives (id INT, name VARCHAR(50), region VARCHAR(50)); INSERT INTO initiatives (id, name, region) VALUES (1, 'Green Building 1', 'Latin America'), (2, 'Smart City Initiative', 'North America'), (3, 'Renewable Energy Project', 'Asia'), (4, 'Green Building 2', 'Caribbean');
List all green building initiatives in Latin America and the Caribbean?
SELECT * FROM initiatives WHERE region IN ('Latin America', 'Caribbean');
gretelai_synthetic_text_to_sql
CREATE TABLE Spacecraft_Manufacturers_4 (Country VARCHAR(50), Spacecraft_Name VARCHAR(50), Manufacturing_Date DATE); INSERT INTO Spacecraft_Manufacturers_4 (Country, Spacecraft_Name, Manufacturing_Date) VALUES ('Japan', 'Kounotori 8', '2020-09-10'); INSERT INTO Spacecraft_Manufacturers_4 (Country, Spacecraft_Name, Manu...
What is the maximum spacecraft manufacturing date for each country?
SELECT Country, MAX(Manufacturing_Date) as Maximum_Manufacturing_Date FROM Spacecraft_Manufacturers_4 GROUP BY Country;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_species (species_id INT, species_name VARCHAR(50)); CREATE TABLE biomass_measurements (measurement_id INT, species_id INT, biomass DECIMAL(10,2)); INSERT INTO marine_species (species_id, species_name) VALUES (1, 'Polar Cod'), (2, 'Greenland Shark'), (3, 'Hooded Seal'); INSERT INTO biomass_measuremen...
What is the total biomass of each marine species in the Arctic?
SELECT species_name, SUM(biomass) as total_biomass FROM biomass_measurements JOIN marine_species ON biomass_measurements.species_id = marine_species.species_id GROUP BY species_name;
gretelai_synthetic_text_to_sql
CREATE TABLE sales (id INT, item_id INT, material VARCHAR(255), revenue DECIMAL(5,2)); INSERT INTO sales (id, item_id, material, revenue) VALUES (1, 1, 'Organic Cotton', 150.00), (2, 2, 'Recycled Polyester', 120.00), (3, 3, 'Hemp', 80.00);
What is the total revenue of sustainable material sales?
SELECT SUM(revenue) FROM sales WHERE material IN ('Organic Cotton', 'Recycled Polyester', 'Hemp');
gretelai_synthetic_text_to_sql
CREATE TABLE grant (id INT, faculty_id INT); INSERT INTO grant (id, faculty_id) VALUES (1, 1), (2, 2), (3, 3); CREATE TABLE faculty (id INT, name TEXT); INSERT INTO faculty (id, name) VALUES (1, 'Alice'), (2, 'Bob'), (3, 'Charlie'), (4, 'Diana');
List the names of all faculty members who have not received a research grant.
SELECT name FROM faculty WHERE id NOT IN (SELECT faculty_id FROM grant);
gretelai_synthetic_text_to_sql
CREATE TABLE Exhibitions (exhibition_name VARCHAR(255), theme VARCHAR(255), visitor_count INT); INSERT INTO Exhibitions (exhibition_name, theme, visitor_count) VALUES ('Impressionist', 'Impressionism', 2000), ('Cubist', 'Cubism', 1500), ('Surrealist', 'Surrealism', 1800);
Which art movement has the highest average visitor count?
SELECT theme, AVG(visitor_count) as avg_visitor_count FROM Exhibitions GROUP BY theme ORDER BY avg_visitor_count DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE shared_scooters( scooter_id INT, availability_status VARCHAR(50), availability_date DATE, city VARCHAR(50));
What is the total number of shared scooters available in Los Angeles on August 15, 2022?
SELECT COUNT(*) FROM shared_scooters WHERE availability_status = 'available' AND availability_date = '2022-08-15' AND city = 'Los Angeles';
gretelai_synthetic_text_to_sql
CREATE TABLE recycling_rates (user_type VARCHAR(10), state VARCHAR(20), recycling_rate FLOAT);
What is the percentage of water recycling for industrial users in Utah?
SELECT 100.0 * SUM(CASE WHEN user_type = 'industrial' THEN recycling_rate END) / SUM(recycling_rate) FROM recycling_rates WHERE state = 'Utah';
gretelai_synthetic_text_to_sql
CREATE TABLE events (event_id INT, name VARCHAR(50), type VARCHAR(50), attendance INT, country VARCHAR(50)); INSERT INTO events (event_id, name, type, attendance, country) VALUES (1, 'Art Exhibit', 'Painting', 1500, 'Spain'); INSERT INTO events (event_id, name, type, attendance, country) VALUES (2, 'Theater Performance...
What is the total attendance at events in the 'events' table for each country?
SELECT country, SUM(attendance) as total_attendance FROM events GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE MoMAVisitors (VisitorID int, VisitorName varchar(100), VisitDate date, MuseumName varchar(100)); INSERT INTO MoMAVisitors (VisitorID, VisitorName, VisitDate, MuseumName) VALUES (1, 'Visitor A', '2022-01-01', 'Museum of Modern Art'), (2, 'Visitor B', '2022-03-01', 'Museum of Modern Art'), (3, 'Visitor C', '...
What is the total number of visitors to the Museum of Modern Art in New York from January to June 2022?
SELECT COUNT(*) FROM MoMAVisitors WHERE MuseumName = 'Museum of Modern Art' AND MONTH(VisitDate) BETWEEN 1 AND 6 AND YEAR(VisitDate) = 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE green_building_certifications (id INT, name VARCHAR(255), year_established INT); INSERT INTO green_building_certifications (id, name, year_established) VALUES (1, 'LEED', 1993), (2, 'BREEAM', 1990), (3, 'Green Star', 2002);
List all green building certifications and their corresponding year of establishment, ordered by year of establishment in ascending order.
SELECT * FROM green_building_certifications ORDER BY year_established ASC;
gretelai_synthetic_text_to_sql
CREATE TABLE aircraft (aircraft_id INT, model VARCHAR(100), manufacturer VARCHAR(100)); CREATE TABLE safety_records (record_id INT, aircraft_id INT, incident_count INT); INSERT INTO aircraft (aircraft_id, model, manufacturer) VALUES (1, 'Aeromodel X1', 'AeroCo'); INSERT INTO aircraft (aircraft_id, model, manufacturer) ...
What is the total incident count for each aircraft model?
SELECT aircraft.model, SUM(safety_records.incident_count) FROM aircraft INNER JOIN safety_records ON aircraft.aircraft_id = safety_records.aircraft_id GROUP BY aircraft.model;
gretelai_synthetic_text_to_sql
CREATE TABLE cb_agreements (id INT, union TEXT, employer TEXT, expiration_date DATE); INSERT INTO cb_agreements (id, union, employer, expiration_date) VALUES (1, 'AFL-CIO', 'Tesla', '2023-04-01'); INSERT INTO cb_agreements (id, union, employer, expiration_date) VALUES (2, 'UAW', 'Ford', '2023-05-15');
Identify the collective bargaining agreements that will expire in the next 6 months, ordered by expiration date.
SELECT * FROM cb_agreements WHERE expiration_date BETWEEN CURDATE() AND DATE_ADD(CURDATE(), INTERVAL 6 MONTH) ORDER BY expiration_date;
gretelai_synthetic_text_to_sql
CREATE TABLE Buildings (building_id INT, name VARCHAR(50), building_type VARCHAR(50));CREATE TABLE Units (unit_id INT, building_id INT, square_footage INT);
What is the difference in square footage between the largest and smallest units in each building, ordered by building type and then by difference?
SELECT b.building_type, b.name, MAX(u.square_footage) - MIN(u.square_footage) as square_footage_difference FROM Units u JOIN Buildings b ON u.building_id = b.building_id GROUP BY b.building_type, b.name ORDER BY b.building_type, square_footage_difference;
gretelai_synthetic_text_to_sql
CREATE TABLE AdvocacyByDisability (AdvocacyID INT, AdvocacyName VARCHAR(50), DisabilityType VARCHAR(50), Budget DECIMAL(10,2)); INSERT INTO AdvocacyByDisability (AdvocacyID, AdvocacyName, DisabilityType, Budget) VALUES (1, 'Inclusive Education', 'Physical Disability', 25000), (2, 'Accessible Employment', 'Intellectual ...
What is the total budget allocated for policy advocacy initiatives per disability type?
SELECT DisabilityType, SUM(Budget) as TotalBudget FROM AdvocacyByDisability GROUP BY DisabilityType;
gretelai_synthetic_text_to_sql
CREATE TABLE crop_rainfall_2 (crop_type VARCHAR(255), rainfall DECIMAL(5,2), record_date DATE); INSERT INTO crop_rainfall_2 (crop_type, rainfall, record_date) VALUES ('corn', 25.0, '2022-02-01'), ('soybeans', 30.0, '2022-02-02'), ('corn', 22.0, '2022-02-03'), ('soybeans', 28.0, '2022-02-04');
Find the total rainfall for each crop type in the past 60 days.
SELECT c.crop_type, SUM(rainfall) AS total_rainfall FROM crop_rainfall_2 c JOIN (SELECT CURDATE() - INTERVAL 60 DAY AS start_date) d ON c.record_date >= d.start_date GROUP BY c.crop_type;
gretelai_synthetic_text_to_sql
CREATE TABLE habitat (id INT, name VARCHAR(255), area FLOAT); INSERT INTO habitat (id, name, area) VALUES (1, 'Habitat1', 123.45); INSERT INTO habitat (id, name, area) VALUES (2, 'Habitat2', 234.56); CREATE TABLE region (id INT, name VARCHAR(255), habitat_id INT); INSERT INTO region (id, name, habitat_id) VALUES (1, 'R...
What is the total area of all wildlife habitats in the forestry database?
SELECT SUM(h.area) FROM habitat h JOIN region r ON h.id = r.habitat_id;
gretelai_synthetic_text_to_sql
CREATE TABLE users (id INT, name VARCHAR(255), email VARCHAR(255)); CREATE TABLE tracks (id INT, title VARCHAR(255), artist VARCHAR(255), genre VARCHAR(255)); CREATE TABLE streams (id INT, track_id INT, user_id INT, region VARCHAR(255), revenue DECIMAL(10,2), timestamp TIMESTAMP);
Insert a new record for a hip-hop song streamed in Canada by a user with ID 12345. The revenue generated is $0.99 and the timestamp is 2022-03-01 14:30:00.
INSERT INTO streams (id, track_id, user_id, region, revenue, timestamp) VALUES (DEFAULT, (SELECT id FROM tracks WHERE title = 'New Song' AND artist = 'Artist Name'), 12345, 'Canada', 0.99, '2022-03-01 14:30:00');
gretelai_synthetic_text_to_sql
CREATE TABLE TrainRoutes (RouteID INT, RouteName VARCHAR(50), TravelTime INT);
What is the minimum travel time for a specific train route?
SELECT MIN(TravelTime) FROM TrainRoutes WHERE RouteName = 'Circle Line';
gretelai_synthetic_text_to_sql
CREATE TABLE Employees (EmployeeID INT, Department VARCHAR(255), Community VARCHAR(255)); INSERT INTO Employees (EmployeeID, Department, Community) VALUES (1, 'Environmental', 'Historically Underrepresented Community A'), (2, 'Environmental', 'Represented Community'), (3, 'Environmental', 'Historically Underrepresented...
How many employees in the Environmental department are from historically underrepresented communities?
SELECT Department, SUM(CASE WHEN Community IN ('Historically Underrepresented Community A', 'Historically Underrepresented Community B') THEN 1 ELSE 0 END) FROM Employees GROUP BY Department;
gretelai_synthetic_text_to_sql
CREATE TABLE publications (id INT, title TEXT, date DATE, methodology TEXT); CREATE VIEW explainable_ai AS SELECT * FROM publications WHERE methodology IS NOT NULL;
Show the number of explainable AI methodologies published per year.
SELECT EXTRACT(YEAR FROM date) as year, COUNT(*) as num_publications FROM explainable_ai GROUP BY year ORDER BY year;
gretelai_synthetic_text_to_sql
CREATE TABLE building_energy_efficiency_history (building_id INT, city VARCHAR(255), rating_year INT, rating FLOAT); INSERT INTO building_energy_efficiency_history (building_id, city, rating_year, rating) VALUES (1, 'City X', 2019, 70), (2, 'City X', 2020, 75), (3, 'City X', 2021, 80), (4, 'City Z', 2019, 85), (5, 'Cit...
What was the average energy efficiency rating for buildings in 'City X' over the last 3 years?
SELECT AVG(rating) as avg_rating FROM building_energy_efficiency_history WHERE city = 'City X' AND rating_year BETWEEN 2019 AND 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE IncidentReports (id INT, incident_name VARCHAR(50), severity VARCHAR(10), incident_date DATE); INSERT INTO IncidentReports (id, incident_name, severity, incident_date) VALUES (1, 'Incident1', 'High', '2021-08-01'), (2, 'Incident2', 'Medium', '2021-07-15'), (3, 'Incident3', 'Low', '2021-06-01'), (4, 'Incide...
What is the earliest date a security incident was reported in the 'IncidentReports' table?
SELECT MIN(incident_date) as earliest_date FROM IncidentReports;
gretelai_synthetic_text_to_sql
CREATE TABLE Games (GameID INT, GameName VARCHAR(100), TeamID INT); CREATE TABLE Teams (TeamID INT, TeamName VARCHAR(100), Country VARCHAR(100)); CREATE TABLE TicketSales (SaleID INT, GameID INT, Quantity INT);
Insert new ticket sales records for a game into the TicketSales table.
INSERT INTO TicketSales (SaleID, GameID, Quantity) SELECT sales.SaleID, games.GameID, sales.Quantity FROM (SELECT 1 AS SaleID, 10 AS GameID, 250 AS Quantity UNION ALL SELECT 2 AS SaleID, 10 AS GameID, 350 AS Quantity) sales JOIN Games games ON sales.GameID = games.GameID;
gretelai_synthetic_text_to_sql
CREATE TABLE stocks (id INT, symbol VARCHAR(10), region VARCHAR(20), return DECIMAL(5,4)); INSERT INTO stocks (id, symbol, region, return) VALUES (1, 'AAPL', 'Asia', 0.0234); INSERT INTO stocks (id, symbol, region, return) VALUES (2, 'GOOG', 'America', 0.0187); INSERT INTO stocks (id, symbol, region, return) VALUES (3,...
What is the average daily return for all stocks in the 'Asia' region, ordered by return in descending order?
SELECT region, AVG(return) as avg_return FROM stocks WHERE region = 'Asia' GROUP BY region ORDER BY avg_return DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE company (id INT, name TEXT, industry TEXT, founder_ethnicity TEXT, founding_date DATE);CREATE TABLE funding (id INT, company_id INT, amount INT); INSERT INTO company (id, name, industry, founder_ethnicity, founding_date) VALUES (1, 'ShopEco', 'E-commerce', 'Latinx', '2021-05-12');
Insert a new company in the e-commerce sector founded by a Latinx individual in 2021, and update the funding records.
INSERT INTO funding (id, company_id, amount) VALUES (1, 1, 750000);
gretelai_synthetic_text_to_sql
CREATE TABLE threat_intelligence (id INT, threat_level INT, threat_date DATE); INSERT INTO threat_intelligence (id, threat_level, threat_date) VALUES (1, 5, '2022-01-01'), (2, 3, '2022-01-02'), (3, 7, '2022-01-03');
Calculate the average threat level for the last 30 days
SELECT AVG(threat_level) FROM threat_intelligence WHERE threat_date >= CURDATE() - INTERVAL 30 DAY;
gretelai_synthetic_text_to_sql
CREATE TABLE Employees (EmployeeID INT, Gender VARCHAR(10), Department VARCHAR(20)); INSERT INTO Employees (EmployeeID, Gender, Department) VALUES (1, 'Female', 'IT'), (2, 'Male', 'IT'), (3, 'Non-binary', 'HR'), (4, 'Male', 'Finance'), (5, 'Non-binary', 'IT'), (6, 'Genderqueer', 'IT'), (7, 'Male', 'IT'), (8, 'Female', ...
List all employees and their corresponding department, sorted by department in ascending order and then by employee ID in ascending order.
SELECT EmployeeID, Department FROM Employees ORDER BY Department ASC, EmployeeID ASC;
gretelai_synthetic_text_to_sql