context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE SustainableClothing (clothing_id INT, clothing_name VARCHAR(50), price DECIMAL(5,2), quantity INT); CREATE TABLE ClothingSales (sale_id INT, clothing_id INT, sale_country VARCHAR(50)); INSERT INTO SustainableClothing (clothing_id, clothing_name, price, quantity) VALUES (1, 'Organic Cotton Shirt', 25.00, 100), (2, 'Recycled Polyester Pants', 30.00, 75), (3, 'Tencel Jacket', 40.00, 50); INSERT INTO ClothingSales (sale_id, clothing_id, sale_country) VALUES (1, 1, 'USA'), (2, 2, 'Canada'), (3, 3, 'Mexico');
What is the total revenue generated from sustainable clothing sales in North America?
SELECT SUM(s.price * s.quantity) FROM SustainableClothing s INNER JOIN ClothingSales cs ON s.clothing_id = cs.clothing_id WHERE cs.sale_country = 'North America';
gretelai_synthetic_text_to_sql
CREATE TABLE maritime_safety_incidents (region text, vessel_id integer); INSERT INTO maritime_safety_incidents (region, vessel_id) VALUES ('North Atlantic', 123), ('North Pacific', 456), ('Mediterranean', 789);
Which vessels were involved in maritime safety incidents in the Mediterranean?
SELECT vessel_id FROM maritime_safety_incidents WHERE region = 'Mediterranean';
gretelai_synthetic_text_to_sql
CREATE TABLE research_grants (id INT, category TEXT, title TEXT, funding_amount INT); INSERT INTO research_grants (id, category, title, funding_amount) VALUES (1, 'Machine Learning', 'Deep Learning', 100000), (2, 'Machine Learning', 'Reinforcement Learning', 150000), (3, 'Theoretical Computer Science', 'Graph Theory', 75000), (4, 'Theoretical Computer Science', 'Combinatorics', 60000);
What is the average funding amount for each grant category?
SELECT category, AVG(funding_amount) FROM research_grants GROUP BY category;
gretelai_synthetic_text_to_sql
CREATE TABLE restaurant_inspections_2 (restaurant_name VARCHAR(255), location VARCHAR(255), score INTEGER, inspection_date DATE); INSERT INTO restaurant_inspections_2 (restaurant_name, location, score, inspection_date) VALUES ('Restaurant A', 'California', 90, '2021-07-01'), ('Restaurant B', 'California', 85, '2021-08-01');
What was the average food safety score for restaurants in California in the second half of 2021?
SELECT AVG(score) FROM restaurant_inspections_2 WHERE location = 'California' AND MONTH(inspection_date) >= 7 AND YEAR(inspection_date) = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE farmers (id INT PRIMARY KEY, name VARCHAR(255), country VARCHAR(255), regenerative_practices BOOLEAN); INSERT INTO farmers (id, name, country, regenerative_practices) VALUES (1, 'John Doe', 'Canada', true), (2, 'Jane Smith', 'Canada', false), (3, 'Mike Johnson', 'Canada', true);
How many farmers in Canada have adopted regenerative agriculture practices?
SELECT COUNT(*) FROM farmers WHERE country = 'Canada' AND regenerative_practices = true;
gretelai_synthetic_text_to_sql
CREATE TABLE users (id INT, country VARCHAR(255), followers INT); CREATE TABLE posts (id INT, user_id INT, hashtags VARCHAR(255), post_date DATE);
What is the minimum number of followers for users from the United Kingdom who have posted about #sports in the last month?
SELECT MIN(users.followers) FROM users INNER JOIN posts ON users.id = posts.user_id WHERE users.country = 'United Kingdom' AND hashtags LIKE '%#sports%' AND post_date >= DATE_SUB(CURDATE(), INTERVAL 1 MONTH);
gretelai_synthetic_text_to_sql
CREATE TABLE donors (donor_id INT, donation_amount DECIMAL(10,2), donation_year INT); INSERT INTO donors (donor_id, donation_amount, donation_year) VALUES (1, 5000.00, 2020), (2, 3000.00, 2019), (3, 7000.00, 2020);
Delete all records for donor_id 3.
DELETE FROM donors WHERE donor_id = 3;
gretelai_synthetic_text_to_sql
CREATE TABLE drugs (id INT, name VARCHAR(50), department VARCHAR(50), rd_expenditure FLOAT); INSERT INTO drugs (id, name, department, rd_expenditure) VALUES (1, 'DrugA', 'Neurology', 2000000), (2, 'DrugB', 'Neurology', 2500000), (3, 'DrugC', 'Cardiology', 1500000);
What is the maximum R&D expenditure for drugs in the neurology department?
SELECT department, MAX(rd_expenditure) as max_rd_expenditure FROM drugs WHERE department = 'Neurology' GROUP BY department;
gretelai_synthetic_text_to_sql
CREATE TABLE suppliers (supplier_id INT, name VARCHAR(255), email VARCHAR(255), phone VARCHAR(20));CREATE TABLE recycled_materials (material_id INT, name VARCHAR(255), supplier_id INT, quantity_supplied INT);CREATE TABLE dates (date DATE);INSERT INTO suppliers (supplier_id, name, email, phone) VALUES (1, 'Green Supplies', '[email protected]', '1234567890'), (2, 'Eco Resources', '[email protected]', '0987654321');INSERT INTO recycled_materials (material_id, name, supplier_id, quantity_supplied) VALUES (1, 'Recycled Cotton', 1, 1500), (2, 'Recycled Polyester', 2, 2000);INSERT INTO dates (date) VALUES ('2021-07-01'), ('2021-08-01'), ('2021-09-01'), ('2021-10-01'), ('2021-11-01'), ('2021-12-01');
List all suppliers that provide recycled materials, along with their contact information and the quantity of recycled materials supplied in the last 6 months.
SELECT suppliers.name, suppliers.email, suppliers.phone, SUM(recycled_materials.quantity_supplied) as total_quantity_supplied FROM suppliers JOIN recycled_materials ON suppliers.supplier_id = recycled_materials.supplier_id JOIN dates ON dates.date >= DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH) WHERE recycled_materials.name IN ('Recycled Cotton', 'Recycled Polyester') GROUP BY suppliers.name, suppliers.email, suppliers.phone;
gretelai_synthetic_text_to_sql
CREATE TABLE heritage_sites (id INT, site_name VARCHAR(255), country VARCHAR(255), region VARCHAR(255), category VARCHAR(255)); INSERT INTO heritage_sites (id, site_name, country, region, category) VALUES (1, 'Acropolis', 'Greece', 'Europe', 'Architecture'), (2, 'Angkor Wat', 'Cambodia', 'Asia', 'Architecture'); CREATE VIEW heritage_sites_by_region AS SELECT region, COUNT(*) as site_count FROM heritage_sites GROUP BY region;
What are the top 3 regions with the highest number of heritage sites?
SELECT region, site_count FROM heritage_sites_by_region ORDER BY site_count DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE landfill_capacity_state (state varchar(255), capacity float, current_capacity float); INSERT INTO landfill_capacity_state (state, capacity, current_capacity) VALUES ('California', 10000000, 5000000);
What is the current landfill capacity in the state of California?
SELECT current_capacity FROM landfill_capacity_state WHERE state = 'California'
gretelai_synthetic_text_to_sql
CREATE TABLE safety_testing (id INT, vehicle VARCHAR(50), make VARCHAR(50), country VARCHAR(50), score INT); INSERT INTO safety_testing VALUES (1, 'Model X', 'Tesla', 'USA', 90); INSERT INTO safety_testing VALUES (2, 'Model 3', 'Tesla', 'USA', 95); INSERT INTO safety_testing VALUES (3, 'e-Tron', 'Audi', 'Germany', 88);
Show vehicle safety testing results for vehicles manufactured in Germany
SELECT * FROM safety_testing WHERE country = 'Germany';
gretelai_synthetic_text_to_sql
CREATE TABLE carbon_emissions (id INT, country VARCHAR(50), carbon_emissions FLOAT, recorded_date DATE); INSERT INTO carbon_emissions (id, country, carbon_emissions, recorded_date) VALUES (1, 'China', 3000000, '2022-04-01'), (2, 'United States', 2000000, '2022-04-01'), (3, 'India', 1500000, '2022-04-01'), (4, 'Russia', 1000000, '2022-04-01'), (5, 'Japan', 800000, '2022-04-01');
What is the total carbon emission for the top 3 carbon-emitting countries in April 2022?
SELECT SUM(carbon_emissions) FROM carbon_emissions WHERE recorded_date = '2022-04-01' ORDER BY carbon_emissions DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE Clients (ClientID INT, FirstName VARCHAR(20), LastName VARCHAR(20), State VARCHAR(20));
Delete clients from state 'NY' in the Clients table
WITH cte AS (DELETE FROM Clients WHERE State = 'NY') SELECT * FROM cte;
gretelai_synthetic_text_to_sql
CREATE TABLE travel_advisories (id INT, country TEXT, advisory TEXT, date DATE); INSERT INTO travel_advisories (id, country, advisory, date) VALUES (1, 'Thailand', 'Protest in Bangkok', '2022-05-01');
List all travel advisories for Southeast Asian countries in the past month.
SELECT country, advisory, date FROM travel_advisories WHERE date >= DATEADD(month, -1, CURRENT_DATE) AND country IN ('Thailand', 'Cambodia', 'Vietnam', 'Laos', 'Myanmar', 'Malaysia', 'Indonesia', 'Philippines', 'Singapore', 'Brunei');
gretelai_synthetic_text_to_sql
CREATE TABLE products (product_id INT, product_name TEXT, supply_chain TEXT); CREATE TABLE prices (price_id INT, product_id INT, price DECIMAL);
Find the average price of products sourced from circular supply chains?
SELECT AVG(prices.price) FROM products JOIN prices ON products.product_id = prices.product_id WHERE products.supply_chain = 'Circular';
gretelai_synthetic_text_to_sql
CREATE TABLE EducationPrograms (program_id INT, city VARCHAR(20), funding_source VARCHAR(20), year INT); INSERT INTO EducationPrograms (program_id, city, funding_source, year) VALUES (1, 'New York', 'Cultural Trust', 2021), (2, 'Miami', 'Cultural Trust', 2021), (3, 'Chicago', 'Cultural Trust', 2021), (4, 'New York', 'Arts Foundation', 2021);
Identify the top 3 cities with the highest number of arts education programs funded by 'Cultural Trust' in 2021.
SELECT city, COUNT(*) as program_count FROM EducationPrograms WHERE funding_source = 'Cultural Trust' AND year = 2021 GROUP BY city ORDER BY program_count DESC LIMIT 3
gretelai_synthetic_text_to_sql
CREATE TABLE Meals (meal_category TEXT, meal_id INT); CREATE TABLE Sales (sale_id INT, meal_id INT, sale_quantity INT);
Calculate the total number of meals sold for each meal category in the 'Meals' and 'Sales' tables.
SELECT Meals.meal_category, SUM(Sales.sale_quantity) FROM Meals INNER JOIN Sales ON Meals.meal_id = Sales.meal_id GROUP BY Meals.meal_category;
gretelai_synthetic_text_to_sql
CREATE TABLE oil_platforms (platform_id INT PRIMARY KEY, platform_name VARCHAR(255), water_depth_ft INT, operational_status VARCHAR(50));
Delete records from the 'oil_platforms' table where the platform_name = 'Bering Sea Rig 1'
DELETE FROM oil_platforms WHERE platform_name = 'Bering Sea Rig 1';
gretelai_synthetic_text_to_sql
CREATE TABLE oceans (ocean_name VARCHAR(50), avg_depth NUMERIC(10,2)); INSERT INTO oceans VALUES ('Indian Ocean', 3962.19);
Update the average depth of the 'Indian Ocean' to 4000 meters.
UPDATE oceans SET avg_depth = 4000 WHERE ocean_name = 'Indian Ocean';
gretelai_synthetic_text_to_sql
CREATE TABLE company (id INT, name TEXT, founder_ethnicity TEXT); INSERT INTO company (id, name, founder_ethnicity) VALUES (1, 'Acme Inc', 'Latinx'), (2, 'Beta Corp', 'White'), (3, 'Gamma PLC', 'Latinx'); CREATE TABLE investment (id INT, company_id INT, amount INT); INSERT INTO investment (id, company_id, amount) VALUES (1, 1, 50000), (2, 1, 100000), (3, 3, 75000);
Show the average amount of funds raised by companies founded by Latinx individuals.
SELECT AVG(amount) FROM investment JOIN company ON investment.company_id = company.id WHERE company.founder_ethnicity = 'Latinx'
gretelai_synthetic_text_to_sql
CREATE TABLE Vendors (VendorID INT, VendorName TEXT, Country TEXT);CREATE TABLE Countries (Country TEXT, Population INT); INSERT INTO Vendors VALUES (1, 'VendorK', 'India'), (2, 'VendorL', 'Canada'), (3, 'VendorM', 'Brazil'); INSERT INTO Countries VALUES ('India', 1380004383), ('Canada', 38005238), ('Brazil', 212559417);
Show the total revenue of vendors located in countries with more than 50 million inhabitants.
SELECT SUM(Price) FROM Vendors v JOIN (SELECT Country FROM Countries WHERE Population > 50000000) c ON v.Country = c.Country;
gretelai_synthetic_text_to_sql
CREATE TABLE dams (id INT, name VARCHAR(50), location VARCHAR(50), elevation DECIMAL(5,2)); INSERT INTO dams (id, name, location, elevation) VALUES (1, 'Hudson Hope Dam', 'British Columbia', 654.25);
Calculate the average elevation of dams in 'British Columbia'
SELECT AVG(elevation) FROM dams WHERE location = 'British Columbia';
gretelai_synthetic_text_to_sql
CREATE TABLE safety_incidents_2 (id INT, union_name VARCHAR(255), industry VARCHAR(255), incident_count INT); INSERT INTO safety_incidents_2 (id, union_name, industry, incident_count) VALUES (1, 'Ironworkers', 'construction', 10), (2, 'Bricklayers', 'construction', 15);
What is the total number of workplace safety incidents for 'construction' industry unions?
SELECT SUM(incident_count) FROM safety_incidents_2 WHERE industry = 'construction';
gretelai_synthetic_text_to_sql
CREATE TABLE CottonSales (SaleID INT, SupplierName TEXT, Material TEXT, Quantity INT); INSERT INTO CottonSales (SaleID, SupplierName, Material, Quantity) VALUES (701, 'GreenFabrics', 'Organic Cotton', 50), (702, 'GreenFabrics', 'Conventional Cotton', 75), (703, 'EcoWeave', 'Organic Cotton', 60), (704, 'EcoWeave', 'Conventional Cotton', 40), (705, 'StandardTextiles', 'Organic Cotton', 30), (706, 'StandardTextiles', 'Conventional Cotton', 70);
Find the difference between sales of organic cotton and conventional cotton.
SELECT SUM(Quantity) FROM CottonSales WHERE Material = 'Organic Cotton'
gretelai_synthetic_text_to_sql
CREATE TABLE PlayerDemographics (PlayerID INT, Age INT, Gender VARCHAR(10), VRGamePlayer BOOLEAN); INSERT INTO PlayerDemographics (PlayerID, Age, Gender, VRGamePlayer) VALUES (1, 25, 'Male', true), (2, 30, 'Female', false), (3, 22, 'Non-binary', true), (4, 45, 'Female', true);
What is the total number of players who are female and play VR games?
SELECT COUNT(*) FROM PlayerDemographics WHERE Gender = 'Female' AND VRGamePlayer = true;
gretelai_synthetic_text_to_sql
CREATE TABLE Astronauts (AstronautID INT, FirstName VARCHAR(50), LastName VARCHAR(50), Nationality VARCHAR(50), Missions INT); INSERT INTO Astronauts (AstronautID, FirstName, LastName, Nationality, Missions) VALUES (3, 'Naoko', 'Yamazaki', 'Japan', 3);
Identify astronauts from Japan who have not participated in any mission.
SELECT AstronautID, FirstName, LastName FROM Astronauts WHERE Nationality = 'Japan' AND Missions = 0;
gretelai_synthetic_text_to_sql
CREATE TABLE SafetyAudits (audit_id INT, audit_date DATE, transaction_type VARCHAR(255), transaction_amount DECIMAL(10,2)); INSERT INTO SafetyAudits (audit_id, audit_date, transaction_type, transaction_amount) VALUES (1, '2022-01-01', 'Audit Fee', 500.00), (2, '2022-01-10', 'Algorithm Update', 0.00), (3, '2022-01-15', 'Audit Fee', 500.00), (4, '2022-02-01', 'Algorithm Update', 0.00), (5, '2022-02-15', 'Audit Fee', 500.00);
Show the transaction history of AI safety audits in the last 30 days, ordered by the date of the transaction in descending order.
SELECT * FROM SafetyAudits WHERE audit_date >= DATEADD(day, -30, GETDATE()) ORDER BY audit_date DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE micro_mobility (id INT, vehicle_type VARCHAR(20), quantity INT); INSERT INTO micro_mobility (id, vehicle_type, quantity) VALUES (1, 'ebike', 300), (2, 'escooter', 500); CREATE TABLE public_transportation (id INT, vehicle_type VARCHAR(20), quantity INT); INSERT INTO public_transportation (id, vehicle_type, quantity) VALUES (1, 'autonomous_bus', 200), (2, 'manual_bus', 800), (3, 'tram', 1000); CREATE TABLE fleet_inventory (id INT, ev_type VARCHAR(20), quantity INT); INSERT INTO fleet_inventory (id, ev_type, quantity) VALUES (1, 'electric_car', 50), (2, 'hybrid_car', 30), (3, 'electric_truck', 10), (4, 'hybrid_truck', 20);
List the number of autonomous buses, electric bikes, and electric scooters in their respective tables.
SELECT 'autonomous_bus' AS vehicle_type, SUM(quantity) AS total FROM public_transportation WHERE vehicle_type = 'autonomous_bus' UNION ALL SELECT 'ebike', SUM(quantity) FROM micro_mobility WHERE vehicle_type = 'ebike' UNION ALL SELECT 'electric_bike', SUM(quantity) FROM fleet_inventory WHERE ev_type = 'electric_bike';
gretelai_synthetic_text_to_sql
CREATE TABLE BudgetRegions (Region VARCHAR(255), Budget INT); INSERT INTO BudgetRegions (Region, Budget) VALUES ('Asia', 25000), ('Africa', 20000), ('SouthAmerica', 15000);
What is the percentage of total conservation budget spent on each region, ordered by the budget percentage in descending order?
SELECT Region, 100.0 * SUM(Budget) FILTER (WHERE Region = Region) / SUM(Budget) OVER () as BudgetPercentage FROM BudgetRegions GROUP BY Region ORDER BY BudgetPercentage DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE shipments (shipment_id INT, warehouse_id VARCHAR(5), quantity INT, cancelled BOOLEAN); CREATE TABLE warehouses (warehouse_id VARCHAR(5), city VARCHAR(5), state VARCHAR(3)); INSERT INTO shipments VALUES (1, 'LAX', 200, FALSE), (2, 'NYC', 300, TRUE), (3, 'LAX', 100, FALSE), (4, 'JFK', 50, FALSE); INSERT INTO warehouses VALUES ('LAX', 'Los', ' Angeles'), ('NYC', 'New', ' York'), ('JFK', 'New', ' York');
What is the total number of shipments for each warehouse, excluding cancelled shipments?
SELECT warehouses.warehouse_id, COUNT(shipments.shipment_id) FROM warehouses LEFT JOIN shipments ON warehouses.warehouse_id = shipments.warehouse_id WHERE NOT shipments.cancelled GROUP BY warehouses.warehouse_id;
gretelai_synthetic_text_to_sql
CREATE TABLE Astrobiology_Missions (id INT PRIMARY KEY, name TEXT, start_date DATE, end_date DATE, objective TEXT); INSERT INTO Astrobiology_Missions (id, name, start_date, end_date, objective) VALUES (3, 'Kepler', '2009-03-07', '2018-10-30', 'Exoplanet Exploration'); INSERT INTO Astrobiology_Missions (id, name, start_date, end_date, objective) VALUES (4, 'TESS', '2018-04-18', 'Active', 'Exoplanet Exploration');
Which astrobiology missions have an objective related to exoplanet exploration?
SELECT Astrobiology_Missions.name, Astrobiology_Missions.objective FROM Astrobiology_Missions WHERE Astrobiology_Missions.objective LIKE '%exoplanet%';
gretelai_synthetic_text_to_sql
CREATE TABLE infrastructure_projects (id INT, name VARCHAR(50), cost DECIMAL(10,2), country VARCHAR(50), completion_status VARCHAR(10), start_date DATE); INSERT INTO infrastructure_projects (id, name, cost, country, completion_status, start_date) VALUES (1, 'Rural Road', 12000.00, 'Mexico', 'Completed', '2020-01-01'); INSERT INTO infrastructure_projects (id, name, cost, country, completion_status, start_date) VALUES (2, 'Irrigation System', 35000.00, 'Brazil', 'In Progress', '2021-03-15');
Identify rural infrastructure projects with their completion status and start dates from the 'rural_development' database
SELECT name, completion_status, start_date FROM infrastructure_projects;
gretelai_synthetic_text_to_sql
CREATE TABLE artifact_tikal (artifact_id INTEGER, site_name TEXT, artifact_type TEXT, age INTEGER); INSERT INTO artifact_tikal (artifact_id, site_name, artifact_type, age) VALUES (1, 'Tikal', 'Pottery', 1200), (2, 'Tikal', 'Stone', 800), (3, 'Tikal', 'Ceramic', 1500), (4, 'Tikal', 'Bone', 1100), (5, 'Tikal', 'Stone', 900), (6, 'Tikal', 'Stone', 1300);
show the total number of artifacts excavated from site 'Tikal'
SELECT COUNT(*) FROM artifact_tikal WHERE site_name = 'Tikal';
gretelai_synthetic_text_to_sql
CREATE TABLE energy_efficiency (country VARCHAR(20), score FLOAT); INSERT INTO energy_efficiency (country, score) VALUES ('India', 65.1), ('India', 65.5), ('China', 72.8), ('China', 73.1);
What is the average energy efficiency score in India and China?
SELECT AVG(score) as avg_score, country FROM energy_efficiency GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE affordable_housing (property_id INT, address VARCHAR(255), city VARCHAR(255), state VARCHAR(255), zip_code VARCHAR(10), rent FLOAT); CREATE TABLE property_ownership (property_id INT, owner_name VARCHAR(255), owner_type VARCHAR(255), shares FLOAT); CREATE VIEW co_owned_properties AS SELECT property_id, owner_name, owner_type, shares FROM property_ownership WHERE shares > 1.0 GROUP BY property_id; CREATE VIEW affordable_co_owned_properties AS SELECT a.* FROM affordable_housing a INNER JOIN co_owned_properties cop ON a.property_id = cop.property_id;
Add a new view named 'affordable_co_owned_properties' that shows co-owned properties in the 'affordable_housing' table
CREATE VIEW affordable_co_owned_properties AS SELECT a.* FROM affordable_housing a INNER JOIN co_owned_properties cop ON a.property_id = cop.property_id;
gretelai_synthetic_text_to_sql
CREATE TABLE patient (patient_id INT, age INT, gender VARCHAR(10), city VARCHAR(20)); INSERT INTO patient (patient_id, age, gender, city) VALUES (1, 5, 'Female', 'Chicago'); INSERT INTO patient (patient_id, age, gender, city) VALUES (2, 10, 'Male', 'Chicago');
What is the percentage of patients in Chicago who have not received the flu vaccine this year?
SELECT 100.0 * SUM(CASE WHEN flu_vaccine_date IS NULL THEN 1 ELSE 0 END) OVER (PARTITION BY city ORDER BY patient_id DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) / COUNT(*) OVER (PARTITION BY city ORDER BY patient_id DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS percentage FROM patient WHERE city = 'Chicago';
gretelai_synthetic_text_to_sql
CREATE TABLE Venues (VenueID INT, VenueName VARCHAR(50)); CREATE TABLE Events (EventID INT, VenueID INT, EventDate DATE); CREATE TABLE EventAttendance (EventID INT, AudienceID INT); CREATE TABLE Audience (AudienceID INT, AudienceName VARCHAR(50)); INSERT INTO Venues (VenueID, VenueName) VALUES (1, 'Museum'), (2, 'Theater'), (3, 'Concert Hall'); INSERT INTO Events (EventID, VenueID, EventDate) VALUES (1, 1, '2021-01-01'), (2, 1, '2021-02-01'), (3, 2, '2021-03-01'); INSERT INTO EventAttendance (EventID, AudienceID) VALUES (1, 1), (1, 2), (2, 1), (2, 3), (3, 1), (3, 2); INSERT INTO Audience (AudienceID, AudienceName) VALUES (1, 'Alice'), (2, 'Bob'), (3, 'Charlie');
How many unique audience members have attended events at each venue?
SELECT v.VenueName, COUNT(DISTINCT ea.AudienceID) as NumUniqueAudienceMembers FROM Venues v INNER JOIN Events e ON v.VenueID = e.VenueID INNER JOIN EventAttendance ea ON e.EventID = ea.EventID GROUP BY v.VenueName;
gretelai_synthetic_text_to_sql
CREATE TABLE circular_economy (city VARCHAR(20), year INT, initiative VARCHAR(30)); INSERT INTO circular_economy (city, year, initiative) VALUES ('Toronto', 2022, 'Waste Reduction Plan'), ('Toronto', 2022, 'Composting Pilot'), ('Toronto', 2022, 'Recycling Education Program');
Insert records of circular economy initiatives in the city of Toronto in 2022.
INSERT INTO circular_economy (city, year, initiative) VALUES ('Toronto', 2022, 'Waste Reduction Plan'), ('Toronto', 2022, 'Composting Pilot'), ('Toronto', 2022, 'Recycling Education Program');
gretelai_synthetic_text_to_sql
athlete_stats; athlete_demographics
Find the number of games played by athletes named 'John'
SELECT athlete_stats.athlete_id, COUNT(athlete_stats.games_played) as games_played_count FROM athlete_stats INNER JOIN athlete_demographics ON athlete_stats.athlete_id = athlete_demographics.id WHERE athlete_demographics.name = 'John' GROUP BY athlete_stats.athlete_id;
gretelai_synthetic_text_to_sql
CREATE TABLE ai_safety_algorithms_2 (id INT, algorithm_name VARCHAR(30)); INSERT INTO ai_safety_algorithms_2 (id, algorithm_name) VALUES (1, 'SafeAI 1.1'); INSERT INTO ai_safety_algorithms_2 (id, algorithm_name) VALUES (2, 'SafeAI 2.1'); INSERT INTO ai_safety_algorithms_2 (id, algorithm_name) VALUES (3, 'SafeAI 3.1'); INSERT INTO ai_safety_algorithms_2 (id, algorithm_name) VALUES (4, 'SafeAI 4.1'); CREATE TABLE ai_bias_mitigation_transaction_lists (algorithm_id INT); INSERT INTO ai_bias_mitigation_transaction_lists (algorithm_id) VALUES (1); INSERT INTO ai_bias_mitigation_transaction_lists (algorithm_id) VALUES (3);
Determine the AI safety algorithms that have at least one transaction but are not included in any AI bias mitigation transaction lists.
SELECT algorithm_name FROM ai_safety_algorithms_2 WHERE id IN (SELECT id FROM transactions) AND id NOT IN (SELECT algorithm_id FROM ai_bias_mitigation_transaction_lists);
gretelai_synthetic_text_to_sql
CREATE TABLE Artists (ArtistID INT, Name VARCHAR(100), Nationality VARCHAR(50), BirthDate DATE); INSERT INTO Artists VALUES (1, 'Pablo Picasso', 'Spanish', '1881-10-25'); INSERT INTO Artists VALUES (2, 'Claude Monet', 'French', '1840-11-14'); CREATE TABLE Artwork (ArtworkID INT, Title VARCHAR(100), Price FLOAT, ArtistID INT); INSERT INTO Artwork VALUES (1, 'Guernica', 2000000, 1); INSERT INTO Artwork VALUES (2, 'Water Lilies', 1500000, 2);
What is the total value of artwork created by artists born in the 19th century?
SELECT SUM(A.Price) FROM Artwork A JOIN Artists AR ON A.ArtistID = AR.ArtistID WHERE YEAR(AR.BirthDate) BETWEEN 1800 AND 1899;
gretelai_synthetic_text_to_sql
CREATE TABLE OilWells (WellID VARCHAR(10), Production FLOAT, Location VARCHAR(50));
What is the maximum production of a well in 'Texas'?
SELECT MAX(Production) FROM OilWells WHERE Location = 'Texas';
gretelai_synthetic_text_to_sql
CREATE TABLE Streaming (id INT, artist VARCHAR(50), streams INT, country VARCHAR(50)); INSERT INTO Streaming (id, artist, streams, country) VALUES (1, 'Sia', 1000000, 'Australia'), (2, 'Taylor Swift', 2000000, 'USA'), (3, 'Drake', 3000000, 'Canada');
What is the maximum number of streams for any artist from Canada?
SELECT MAX(streams) FROM Streaming WHERE country = 'Canada';
gretelai_synthetic_text_to_sql
CREATE TABLE teacher (teacher_id INT, teacher_name VARCHAR(50)); CREATE TABLE workshop (workshop_id INT, workshop_name VARCHAR(50)); CREATE TABLE attendance (teacher_id INT, workshop_id INT); INSERT INTO teacher (teacher_id, teacher_name) VALUES (1, 'John Smith'), (2, 'Jane Doe'); INSERT INTO workshop (workshop_id, workshop_name) VALUES (1, 'Open Pedagogy 101'), (2, 'Advanced Open Pedagogy'); INSERT INTO attendance (teacher_id, workshop_id) VALUES (1, 1), (2, 1);
Which teachers have attended professional development workshops on open pedagogy?
SELECT teacher.teacher_name FROM teacher INNER JOIN attendance ON teacher.teacher_id = attendance.teacher_id INNER JOIN workshop ON attendance.workshop_id = workshop.workshop_id WHERE workshop.workshop_name = 'Open Pedagogy 101';
gretelai_synthetic_text_to_sql
CREATE TABLE rd(country varchar(20), year int, expenditure int); INSERT INTO rd(country, year, expenditure) VALUES('US', 2019, 10000), ('US', 2020, 12000), ('Canada', 2019, 8000), ('Canada', 2020, 9000);
Which countries spent the most on R&D in '2019' and '2020'?
SELECT country, SUM(expenditure) FROM rd WHERE year IN (2019, 2020) GROUP BY country
gretelai_synthetic_text_to_sql
CREATE TABLE maintenance (maintenance_id INT, vehicle_id INT, date DATE, description VARCHAR(255));
Create a table named "maintenance" with columns "maintenance_id", "vehicle_id", "date", and "description".
CREATE TABLE maintenance (maintenance_id INT, vehicle_id INT, date DATE, description VARCHAR(255));
gretelai_synthetic_text_to_sql
CREATE TABLE products (product_id INT, quantity INT, certifications VARCHAR(50)); INSERT INTO products (product_id, quantity, certifications) VALUES (1, 10, 'organic, fair trade'), (2, 20, 'organic'), (3, 15, 'fair trade'), (4, 5, 'organic, non-gmo');
What is the minimum quantity of a product that is both organic and fair trade?
SELECT MIN(quantity) FROM products WHERE certifications LIKE '%organic, fair trade%';
gretelai_synthetic_text_to_sql
CREATE TABLE Donations (id INT, user VARCHAR(255), amount DECIMAL(10, 2)); INSERT INTO Donations (id, user, amount) VALUES (1, 'John', 50.00), (2, 'Jane', 75.00);
What is the maximum donation amount in the Donations table?
SELECT MAX(amount) FROM Donations;
gretelai_synthetic_text_to_sql
CREATE TABLE shipments (id INT, source VARCHAR(20), destination VARCHAR(20), weight FLOAT); INSERT INTO shipments (id, source, destination, weight) VALUES (1, 'China', 'United States', 50.5), (2, 'China', 'Canada', 30.3), (3, 'Mexico', 'United States', 45.6), (4, 'Canada', 'United States', 25.8), (5, 'Canada', 'Mexico', 38.2), (6, 'Mexico', 'Canada', 40.1), (7, 'Brazil', 'United States', 70.0);
What is the maximum weight of a shipment to the United States?
SELECT MAX(weight) FROM shipments WHERE destination = 'United States';
gretelai_synthetic_text_to_sql
CREATE TABLE fish_processing_plants (id INT, name TEXT, region TEXT); CREATE TABLE plant_connections (id INT, plant_id INT, farm_id INT); INSERT INTO fish_processing_plants (id, name, region) VALUES (1, 'Plant A', 'Southeast Asia'), (2, 'Plant B', 'Southeast Asia'), (3, 'Plant C', 'North America'); INSERT INTO plant_connections (id, plant_id, farm_id) VALUES (1, 1, 1), (2, 1, 2), (3, 2, 3), (4, 3, 4);
List the names and locations of fish processing plants in Southeast Asia and their connected fish farms.
SELECT FPP.name, FPP.region, TF.name AS farm_name FROM fish_processing_plants FPP JOIN plant_connections PC ON FPP.id = PC.plant_id JOIN tilapia_farms TF ON PC.farm_id = TF.id WHERE FPP.region = 'Southeast Asia';
gretelai_synthetic_text_to_sql
CREATE TABLE farmland (id INT, farmland_name VARCHAR(255), province VARCHAR(255), country VARCHAR(255), is_organic BOOLEAN); INSERT INTO farmland (id, farmland_name, province, country, is_organic) VALUES (1, 'Farmland 1', 'Ontario', 'Canada', true); INSERT INTO farmland (id, farmland_name, province, country, is_organic) VALUES (2, 'Farmland 2', 'Quebec', 'Canada', false);
What is the total area of organic farmland in Canada by province?
SELECT province, SUM(CASE WHEN is_organic THEN 1 ELSE 0 END) AS total_organic_farmland FROM farmland WHERE country = 'Canada' GROUP BY province;
gretelai_synthetic_text_to_sql
CREATE TABLE Donations (ID INT, DonorState TEXT, DonationAmount DECIMAL(10,2)); INSERT INTO Donations (ID, DonorState, DonationAmount) VALUES (1, 'California', 100.00), (2, 'New York', 200.00), (3, 'Texas', 150.00);
What is the total donation amount by state?
SELECT DonorState, SUM(DonationAmount) as TotalDonation FROM Donations GROUP BY DonorState;
gretelai_synthetic_text_to_sql
CREATE TABLE Suppliers (id INT PRIMARY KEY, name VARCHAR(255), location VARCHAR(255)); INSERT INTO Suppliers (id, name, location) VALUES (1, 'Supplier A', 'California'), (2, 'Supplier B', 'New York'), (3, 'Supplier C', 'Texas');
List all suppliers from 'California' in the 'Suppliers' table
SELECT name FROM Suppliers WHERE location = 'California';
gretelai_synthetic_text_to_sql
CREATE TABLE tech_acquisitions (country VARCHAR(50), year INT, tech_type VARCHAR(50), quantity INT); INSERT INTO tech_acquisitions (country, year, tech_type, quantity) VALUES ('USA', 2018, 'Aircraft', 1200), ('USA', 2019, 'Aircraft', 1300), ('USA', 2020, 'Aircraft', 1350), ('USA', 2021, 'Aircraft', 1400), ('China', 2018, 'Aircraft', 800), ('China', 2019, 'Aircraft', 850), ('China', 2020, 'Aircraft', 900), ('China', 2021, 'Aircraft', 950), ('USA', 2018, 'Vessels', 300), ('USA', 2019, 'Vessels', 350), ('USA', 2020, 'Vessels', 375), ('USA', 2021, 'Vessels', 400), ('China', 2018, 'Vessels', 500), ('China', 2019, 'Vessels', 550), ('China', 2020, 'Vessels', 600), ('China', 2021, 'Vessels', 650);
Provide a summary of military technology acquisitions by the USA and China between 2018 and 2021
SELECT country, year, SUM(quantity) as total_quantity FROM tech_acquisitions WHERE country IN ('USA', 'China') AND tech_type = 'Aircraft' GROUP BY country, year; SELECT country, year, SUM(quantity) as total_quantity FROM tech_acquisitions WHERE country IN ('USA', 'China') AND tech_type = 'Vessels' GROUP BY country, year;
gretelai_synthetic_text_to_sql
CREATE TABLE DefenseProjects (project_id INT, region VARCHAR(50), project_cost DECIMAL(10, 2)); INSERT INTO DefenseProjects (project_id, region, project_cost) VALUES (1, 'Y', 1000000.00); INSERT INTO DefenseProjects (project_id, region, project_cost) VALUES (2, 'Z', 2000000.00);
What is the total number of defense projects and their total cost for each region?
SELECT region, COUNT(*) as total_projects, SUM(project_cost) as total_cost FROM DefenseProjects GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE rural_infrastructure (id INT, project_name TEXT, sector TEXT, country TEXT, completion_date DATE); INSERT INTO rural_infrastructure (id, project_name, sector, country, completion_date) VALUES (1, 'Rural Road Construction', 'Infrastructure', 'Colombia', '2017-04-23'), (2, 'Irrigation System Upgrade', 'Infrastructure', 'Colombia', '2018-06-12'), (3, 'Rural Electrification', 'Infrastructure', 'Colombia', '2017-11-15');
How many rural infrastructure projects were completed in Colombia in 2017?
SELECT COUNT(*) FROM rural_infrastructure WHERE country = 'Colombia' AND completion_date LIKE '2017-%';
gretelai_synthetic_text_to_sql
CREATE TABLE Baltic_Sea (phosphate FLOAT, month DATE); INSERT INTO Baltic_Sea (phosphate, month) VALUES (0.25, '2022-05-01'); INSERT INTO Baltic_Sea (phosphate, month) VALUES (0.32, '2022-05-15');
Calculate the average phosphate levels in the Baltic Sea for the month of May.
SELECT AVG(phosphate) FROM Baltic_Sea WHERE month = '2022-05-01';
gretelai_synthetic_text_to_sql
CREATE TABLE Equipment (EquipmentID INT, EquipmentName VARCHAR(100)); INSERT INTO Equipment (EquipmentID, EquipmentName) VALUES (1, 'Tank'), (2, 'Missile'), (3, 'Drone'); CREATE TABLE Risks (RiskID INT, EquipmentID INT, RiskLevel VARCHAR(10)); INSERT INTO Risks (RiskID, EquipmentID, RiskLevel) VALUES (1, 1, 'Medium'), (2, 2, 'High'); CREATE VIEW EquipmentWithRisks AS SELECT Equipment.EquipmentName, Risks.RiskLevel FROM Equipment LEFT JOIN Risks ON Equipment.EquipmentID = Risks.EquipmentID;
Show geopolitical risk assessments for all equipment
SELECT EquipmentName, RiskLevel FROM EquipmentWithRisks;
gretelai_synthetic_text_to_sql
CREATE TABLE sales (id INT, artwork_id INT, location TEXT, price DECIMAL(5,2)); INSERT INTO sales (id, artwork_id, location, price) VALUES (1, 1, 'Paris', 1000.00), (2, 2, 'London', 2000.00), (3, 3, 'Paris', 3000.00);
What is the total value of artwork sales in Paris?
SELECT SUM(price) FROM sales WHERE location = 'Paris';
gretelai_synthetic_text_to_sql
CREATE TABLE FoodAssistance (id INT, person_name VARCHAR(50), person_age INT, country VARCHAR(50), assistance_date DATE); INSERT INTO FoodAssistance (id, person_name, person_age, country, assistance_date) VALUES (1, 'John Doe', 25, 'Yemen', '2021-05-02');
What is the total number of people who have received food assistance in Yemen, and what is their average age?
SELECT COUNT(DISTINCT FoodAssistance.person_name) AS total_people, AVG(FoodAssistance.person_age) AS avg_age FROM FoodAssistance WHERE FoodAssistance.country = 'Yemen';
gretelai_synthetic_text_to_sql
CREATE TABLE marine_incidents (id INT, incident_date DATE, cargo_type_id INT, containers_lost INT); CREATE TABLE cargo_types (cargo_type_id INT, cargo_type VARCHAR(50));
Calculate the total number of containers lost at sea, grouped by cargo type and month.
SELECT ct.cargo_type, DATE_FORMAT(mi.incident_date, '%Y-%m') as time_period, SUM(mi.containers_lost) as total_lost FROM marine_incidents mi JOIN cargo_types ct ON mi.cargo_type_id = ct.cargo_type_id GROUP BY ct.cargo_type, time_period;
gretelai_synthetic_text_to_sql
CREATE TABLE materials (material_id INT, material_name TEXT, country_of_origin TEXT); INSERT INTO materials (material_id, material_name, country_of_origin) VALUES (1, 'Organic Cotton', 'India'), (2, 'Hemp', 'France'), (3, 'Recycled Polyester', 'China'), (4, 'Tencel', 'Austria');
Which countries produce the most sustainable materials?
SELECT country_of_origin, COUNT(*) as material_count FROM materials GROUP BY country_of_origin ORDER BY material_count DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE facility (id INT, name VARCHAR(255)); CREATE TABLE emission_record (id INT, facility_id INT, record_date DATE, gas_type VARCHAR(255), emission_volume INT); INSERT INTO facility (id, name) VALUES (1, 'Facility A'), (2, 'Facility B'), (3, 'Facility C'), (4, 'Facility D'); INSERT INTO emission_record (id, facility_id, record_date, gas_type, emission_volume) VALUES (1, 1, '2022-01-01', 'CO2', 50), (2, 1, '2022-02-01', 'CH4', 30), (3, 2, '2022-01-01', 'CO2', 75), (4, 2, '2022-02-01', 'N2O', 40), (5, 3, '2022-01-01', 'CO2', 100), (6, 3, '2022-02-01', 'N2O', 80), (7, 4, '2022-01-01', 'CO2', 120), (8, 4, '2022-02-01', 'CH4', 90);
What are the total greenhouse gas emissions for each facility in the past year, and what percentage of the total emissions do the top three facilities contribute?
SELECT f.name, SUM(er.emission_volume) as total_emissions, (SUM(er.emission_volume) / (SELECT SUM(emission_volume) FROM emission_record WHERE record_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR)) * 100) as pct_of_total FROM facility f INNER JOIN emission_record er ON f.id = er.facility_id WHERE er.record_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR) GROUP BY f.name ORDER BY total_emissions DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE mining_permits (id INT PRIMARY KEY, permit_number VARCHAR(255), company_name VARCHAR(255), mine_location VARCHAR(255), element_type VARCHAR(255));
What are the mining permits for Terbium?
SELECT * FROM mining_permits WHERE element_type = 'Terbium';
gretelai_synthetic_text_to_sql
CREATE SCHEMA events; CREATE TABLE events (event_id INT, event_name VARCHAR(255), event_date DATE, age_group VARCHAR(255), tickets_sold INT); INSERT INTO events (event_id, event_name, event_date, age_group, tickets_sold) VALUES (1, 'Concert', '2023-05-15', '0-17', 50), (2, 'Theater', '2023-06-20', '18-35', 100), (3, 'Workshop', '2023-07-10', '36-55', 75);
What is the total number of tickets sold by age group for a specific event?
SELECT age_group, SUM(tickets_sold) as total_tickets_sold FROM events WHERE event_date = '2023-05-15' GROUP BY age_group;
gretelai_synthetic_text_to_sql
CREATE TABLE users (user_id INT, followers INT, following INT, join_date DATE); INSERT INTO users (user_id, followers, following, join_date) VALUES (1, 1000, 500, '2020-06-15'); CREATE TABLE posts (post_id INT, user_id INT, post_text TEXT, post_date DATE); INSERT INTO posts (post_id, user_id, post_text, post_date) VALUES (1, 123, '#fitness', '2021-07-25');
What is the average number of daily followers gained by users who posted the hashtag '#fitness' in the last month?
SELECT AVG(follower_diff) FROM ( SELECT DATEDIFF(day, join_date, post_date) as days_since_join, user_id, (SELECT followers FROM users WHERE users.user_id = posts.user_id) - (SELECT followers FROM users WHERE users.user_id = posts.user_id - 1) as follower_diff FROM posts WHERE post_date >= DATEADD(month, -1, GETDATE()) AND post_text LIKE '%#fitness%' ) as post_follower_data;
gretelai_synthetic_text_to_sql
CREATE TABLE workouts (id INT, user_id INT, duration INT, date DATE, heart_rate INT, exercise_type VARCHAR(50)); INSERT INTO workouts (id, user_id, duration, date, heart_rate, exercise_type) VALUES (1, 101, 60, '2022-06-01', 120, 'yoga'), (2, 102, 45, '2022-06-01', 130, 'running'), (3, 101, 75, '2022-06-02', 115, 'yoga');
What is the maximum heart rate recorded for users while doing yoga?
SELECT MAX(heart_rate) FROM workouts WHERE exercise_type = 'yoga';
gretelai_synthetic_text_to_sql
CREATE TABLE customers(id INT, country VARCHAR(255), total_spend DECIMAL(10, 2)); INSERT INTO customers(id, country, total_spend) VALUES (1, 'Nigeria', 1500.00), (2, 'Egypt', 2000.00), (3, 'South Africa', 2500.00);
Who is the top customer in terms of total spend from Africa?
SELECT country FROM customers WHERE total_spend = (SELECT MAX(total_spend) FROM customers WHERE country IN ('Nigeria', 'Egypt', 'South Africa'));
gretelai_synthetic_text_to_sql
CREATE TABLE games (game_id INT, name VARCHAR(50)); CREATE TABLE modes (mode_id INT, name VARCHAR(50)); CREATE TABLE results (result_id INT, player_id INT, game_id INT, mode_id INT, wins INT);
Show players with the most wins in specific game modes
SELECT r.player_id, p.name, g.name AS game_name, m.name AS mode_name, SUM(r.wins) AS total_wins FROM results r JOIN players p ON r.player_id = p.player_id JOIN games g ON r.game_id = g.game_id JOIN modes m ON r.mode_id = m.mode_id GROUP BY r.player_id, g.name, m.name ORDER BY total_wins DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE Employees(id INT, name VARCHAR(50), department VARCHAR(50), position VARCHAR(50), salary FLOAT, full_time BOOLEAN, gender VARCHAR(50), start_date DATE);
What is the minimum and maximum salary for each position in the Mining department?
SELECT position, MIN(salary) AS Min_Salary, MAX(salary) AS Max_Salary FROM Employees WHERE department = 'Mining' GROUP BY position;
gretelai_synthetic_text_to_sql
CREATE TABLE accounts (id INT, name VARCHAR(255), location VARCHAR(255)); CREATE TABLE posts (id INT, account_id INT, content TEXT, likes INT, timestamp TIMESTAMP); INSERT INTO accounts (id, name, location) VALUES (1, 'user1', 'Canada'); INSERT INTO posts (id, account_id, content, likes, timestamp) VALUES (1, 1, 'post1 #sustainability', 50, '2022-01-01 12:00:00');
What is the average number of likes on posts containing the hashtag #sustainability in the month of January 2022, for accounts located in Canada?
SELECT AVG(likes) FROM posts JOIN accounts ON posts.account_id = accounts.id WHERE posts.timestamp >= '2022-01-01' AND posts.timestamp < '2022-02-01' AND posts.content LIKE '%#sustainability%' AND accounts.location = 'Canada';
gretelai_synthetic_text_to_sql
CREATE TABLE ocean_floors (id INTEGER, name VARCHAR(255), location VARCHAR(255), depth INTEGER);
What is the average depth of the ocean floor in the 'Arctic Ocean'?
SELECT AVG(depth) FROM ocean_floors WHERE location = 'Arctic Ocean';
gretelai_synthetic_text_to_sql
CREATE TABLE Autonomous_Vehicles (Company VARCHAR(50), Country VARCHAR(50), Year_Introduced INT); INSERT INTO Autonomous_Vehicles (Company, Country, Year_Introduced) VALUES ('Waymo', 'USA', 2009); INSERT INTO Autonomous_Vehicles (Company, Country, Year_Introduced) VALUES ('NuTonomy', 'Singapore', 2016); INSERT INTO Autonomous_Vehicles (Company, Country, Year_Introduced) VALUES ('Baidu', 'China', 2015);
What is the total number of autonomous vehicles introduced by companies in the USA and China?
SELECT SUM(CASE WHEN Country IN ('USA', 'China') THEN 1 ELSE 0 END) FROM Autonomous_Vehicles;
gretelai_synthetic_text_to_sql
CREATE TABLE ind_water_usage (industry VARCHAR(255), state VARCHAR(255), year INT, consumption FLOAT); INSERT INTO ind_water_usage (industry, state, year, consumption) VALUES ('Manufacturing', 'California', 2020, 12000000), ('Agriculture', 'California', 2020, 25000000), ('Mining', 'California', 2020, 5000000);
What is the total water consumption by each industrial sector in California in 2020?'
SELECT industry, SUM(consumption) as total_consumption FROM ind_water_usage WHERE state = 'California' AND year = 2020 GROUP BY industry;
gretelai_synthetic_text_to_sql
CREATE TABLE company (id INT, name TEXT, industry TEXT, founding_year INT); INSERT INTO company (id, name, industry, founding_year) VALUES (1, 'Acme Corp', 'Tech', 2010); CREATE TABLE investment (id INT, company_id INT, funding_amount INT, investment_year INT); INSERT INTO investment (id, company_id, funding_amount, investment_year) VALUES (1, 1, 5000000, 2015);
List the top 3 industries with the most funding in the last 5 years, ordered by funding amount.
SELECT industry, SUM(funding_amount) as total_funding FROM company JOIN investment ON company.id = investment.company_id WHERE investment_year >= (SELECT YEAR(CURRENT_DATE) - 5) GROUP BY industry ORDER BY total_funding DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE Employees (EmployeeID INT, FirstName VARCHAR(50), LastName VARCHAR(50), Department VARCHAR(50), HireDate DATE, Gender VARCHAR(10));
How many women have been hired in the Sales department since January 2020?
SELECT COUNT(*) as TotalHired FROM Employees WHERE Department = 'Sales' AND Gender = 'Female' AND HireDate >= '2020-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE VolunteerHours (VolunteerHoursID INT PRIMARY KEY, VolunteerID INT, Hours DECIMAL(10, 2), VolunteerDate DATE);
Update the hours volunteered in the 'VolunteerHours' table
UPDATE VolunteerHours SET Hours = 4.00 WHERE VolunteerHoursID = 401;
gretelai_synthetic_text_to_sql
CREATE TABLE industrial_sectors (id INT, sector VARCHAR(255)); INSERT INTO industrial_sectors (id, sector) VALUES (1, 'Manufacturing'), (2, 'Mining'), (3, 'Construction'), (4, 'Residential'); CREATE TABLE water_consumption (year INT, sector_id INT, consumption INT); INSERT INTO water_consumption (year, sector_id, consumption) VALUES (2019, 4, 8000), (2020, 4, 9000);
Update the water consumption records for 2020 in the residential sector to reflect a 10% reduction.
UPDATE water_consumption SET consumption = consumption * 0.9 WHERE year = 2020 AND sector_id = (SELECT id FROM industrial_sectors WHERE sector = 'Residential');
gretelai_synthetic_text_to_sql
CREATE TABLE defense_innovations(country VARCHAR(50), year INT, type VARCHAR(50), description VARCHAR(255)); INSERT INTO defense_innovations(country, year, type, description) VALUES('Singapore', 2021, 'Artificial Intelligence', 'Development of AI-powered border surveillance system'), ('Indonesia', 2020, 'Cybersecurity', 'Establishment of a national cybersecurity center'), ('Malaysia', 2019, 'Robotics', 'Production of military drones for reconnaissance'), ('Philippines', 2018, 'Electronic Warfare', 'Implementation of electronic warfare systems on naval vessels');
List the defense technology innovations developed by ASEAN countries in the past 3 years.
SELECT country, type, description FROM defense_innovations WHERE country IN ('Singapore', 'Indonesia', 'Malaysia', 'Philippines', 'Thailand', 'Brunei', 'Vietnam', 'Cambodia', 'Laos', 'Myanmar', 'Singapore') AND year BETWEEN 2019 AND 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE africa_legal_tech (id INT, company VARCHAR(255), num_patents INT); INSERT INTO africa_legal_tech (id, company, num_patents) VALUES (1, 'Company A', 3), (2, 'Company B', 5), (3, 'Company C', 1);CREATE TABLE asia_legal_tech (id INT, company VARCHAR(255), num_patents INT); INSERT INTO asia_legal_tech (id, company, num_patents) VALUES (1, 'Company X', 8), (2, 'Company Y', 4), (3, 'Company Z', 6);
What is the distribution of legal tech patents by companies in Africa and Asia?
SELECT company, COUNT(*) AS num_patents FROM africa_legal_tech GROUP BY company UNION ALL SELECT company, COUNT(*) AS num_patents FROM asia_legal_tech GROUP BY company;
gretelai_synthetic_text_to_sql
CREATE TABLE Mil_Tech (tech_id INT, tech_name VARCHAR(50), tech_year INT, tech_type VARCHAR(50)); INSERT INTO Mil_Tech (tech_id, tech_name, tech_year, tech_type) VALUES (1, 'Stealth Fighter', 2019, 'Aircraft'); INSERT INTO Mil_Tech (tech_id, tech_name, tech_year, tech_type) VALUES (2, 'Carrier Battlegroup', 2017, 'Naval');
What are the names and types of military technologies developed in '2019' according to the 'Mil_Tech' table?
SELECT tech_name, tech_type FROM Mil_Tech WHERE tech_year = 2019;
gretelai_synthetic_text_to_sql
CREATE TABLE MilitaryEquipmentSales (equipment_id INT, customer_country VARCHAR(50), sale_price DECIMAL(10,2)); INSERT INTO MilitaryEquipmentSales (equipment_id, customer_country, sale_price) VALUES (1, 'Canada', 750000.00), (2, 'Australia', 900000.00);
What is the average military equipment sale price for Canadian and Australian customers?
SELECT AVG(sale_price) FROM MilitaryEquipmentSales WHERE customer_country = 'Canada' INTERSECT SELECT AVG(sale_price) FROM MilitaryEquipmentSales WHERE customer_country = 'Australia'
gretelai_synthetic_text_to_sql
CREATE TABLE menus (id INT, name VARCHAR(255), category VARCHAR(255), price DECIMAL(10,2), COST DECIMAL(10,2), PRIMARY KEY(id)); INSERT INTO menus VALUES (1, 'Pizza Margherita', 'Pizza', 9.99, 3.50), (2, 'Chicken Alfredo', 'Pasta', 12.49, 4.50), (3, 'California Roll', 'Sushi', 8.99, 2.50), (4, 'Seasonal Fruit Bowl', 'Starters', 7.99, 2.00);
What is the total cost of inventory for all menu items?
SELECT SUM(cost) as total_cost FROM menus;
gretelai_synthetic_text_to_sql
CREATE TABLE initiatives (id INT, initiative_name VARCHAR(100), country VARCHAR(50), budget FLOAT, start_date DATE, end_date DATE); INSERT INTO initiatives (id, initiative_name, country, budget, start_date, end_date) VALUES (1, 'Green Villages', 'Bolivia', 250000, '2017-01-01', '2018-12-31'), (2, 'Solar Energy for All', 'Bolivia', 300000, '2018-01-01', '2019-12-31'), (3, 'Water for Life', 'Bolivia', 350000, '2019-01-01', '2020-12-31'), (4, 'Education for All', 'Bolivia', 400000, '2018-07-01', '2019-06-30');
Which community development initiatives in Bolivia had the highest budget in 2018?
SELECT initiative_name, budget FROM initiatives WHERE country = 'Bolivia' AND YEAR(start_date) = 2018 OR YEAR(end_date) = 2018 ORDER BY budget DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE HealthcareFacilities (ID INT, Name TEXT, ZipCode TEXT, City TEXT, State TEXT, Capacity INT); INSERT INTO HealthcareFacilities (ID, Name, ZipCode, City, State, Capacity) VALUES (1, 'General Hospital', '12345', 'Anytown', 'NY', 500), (2, 'Community Clinic', '67890', 'Othertown', 'NY', 100);
find the number of healthcare facilities and the number of unique ZIP codes in the HealthcareFacilities table, using an EXCEPT operator
SELECT COUNT(*) FROM HealthcareFacilities EXCEPT SELECT COUNT(DISTINCT ZipCode) FROM HealthcareFacilities;
gretelai_synthetic_text_to_sql
CREATE TABLE CulturalCompetencyTraining (Id INT, Area VARCHAR(5), Quarter INT, Year INT, Sessions INT); INSERT INTO CulturalCompetencyTraining (Id, Area, Quarter, Year, Sessions) VALUES (1, 'Urban', 2, 2021, 150), (2, 'Rural', 2, 2021, 120), (3, 'Urban', 1, 2021, 140), (4, 'Suburban', 1, 2021, 130), (5, 'Urban', 3, 2021, 160);
What is the total number of cultural competency training sessions conducted in urban areas in Q2 2021?
SELECT Area, SUM(Sessions) as TotalSessions FROM CulturalCompetencyTraining WHERE Area = 'Urban' AND Quarter = 2 AND Year = 2021 GROUP BY Area;
gretelai_synthetic_text_to_sql
CREATE TABLE forests (id INT, name VARCHAR(50), hectares DECIMAL(5,2), year_planted INT, is_protected BOOLEAN, PRIMARY KEY (id)); INSERT INTO forests (id, name, hectares, year_planted, is_protected) VALUES (1, 'Forest A', 123.45, 1990, true), (2, 'Forest B', 654.32, 1985, false), (3, 'Forest C', 456.78, 2010, true), (4, 'Forest D', 903.45, 1980, false); CREATE TABLE wildlife (id INT, forest_id INT, species VARCHAR(50), PRIMARY KEY (id)); INSERT INTO wildlife (id, forest_id, species) VALUES (1, 1, 'Bear'), (2, 1, 'Eagle'), (3, 3, 'Wolf'), (4, 3, 'Deer');
Count the number of wildlife species in protected forests
SELECT COUNT(w.id) FROM wildlife w INNER JOIN forests f ON w.forest_id = f.id WHERE f.is_protected = true;
gretelai_synthetic_text_to_sql
CREATE TABLE ArtistRevenue (id INT, artist_name VARCHAR(50), revenue DECIMAL(10,2), year INT); INSERT INTO ArtistRevenue (id, artist_name, revenue, year) VALUES (1, 'Picasso', 20000, 2020), (2, 'Van Gogh', 15000, 2020), (3, 'Dali', 25000, 2020), (4, 'Matisse', 18000, 2020), (5, 'Monet', 19000, 2019);
What was the maximum revenue generated by any artist in 2020?
SELECT MAX(revenue) FROM ArtistRevenue WHERE year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE regional_membership_fees (region VARCHAR(50), avg_fee DECIMAL(5,2)); INSERT INTO regional_membership_fees (region, avg_fee) VALUES ('NY', 55.00), ('CA', 45.00);
How many members have a membership fee less than the average membership fee for their region?
SELECT COUNT(*) FROM memberships INNER JOIN (SELECT region, AVG(membership_fee) AS avg_fee FROM memberships GROUP BY region) AS regional_avg_fees ON memberships.region = regional_avg_fees.region WHERE memberships.membership_fee < regional_avg_fees.avg_fee;
gretelai_synthetic_text_to_sql
CREATE TABLE military_sales (id INT, region VARCHAR, year INT, value FLOAT);
Get the total value of military equipment sales to 'Asia-Pacific' region in 2020
SELECT SUM(value) FROM military_sales WHERE region = 'Asia-Pacific' AND year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE Projects (ProjectID int, ProjectName varchar(255), State varchar(255), StartDate date, EndDate date, IsSustainable bit);
What is the average project timeline for sustainable building projects in Texas?
SELECT AVG(DATEDIFF(EndDate, StartDate)) as AvgTimeline FROM Projects WHERE State = 'Texas' AND IsSustainable = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE pumped_hydro_storage (id INT, name TEXT, country TEXT, capacity FLOAT); INSERT INTO pumped_hydro_storage (id, name, country, capacity) VALUES (1, 'Kannagawa', 'Japan', 245), (2, 'Okuyoshino', 'Japan', 270), (3, 'Shimizu', 'Japan', 300), (4, 'Okutataragi', 'Japan', 336);
What is the minimum energy storage capacity of pumped hydro storage plants in Japan?
SELECT MIN(capacity) FROM pumped_hydro_storage WHERE country = 'Japan';
gretelai_synthetic_text_to_sql
CREATE TABLE Dispensaries (id INT, name VARCHAR(255), city VARCHAR(255), state VARCHAR(255));CREATE TABLE Inventory (id INT, dispensary_id INT, weight DECIMAL(10, 2), product_type VARCHAR(255), month INT, year INT);INSERT INTO Dispensaries (id, name, city, state) VALUES (1, 'Seattle Cannabis Co', 'Seattle', 'WA');INSERT INTO Inventory (id, dispensary_id, weight, product_type, month, year) VALUES (1, 1, 50, 'vape', 4, 2022);
What was the total weight of cannabis vape cartridges sold by dispensaries in the city of Seattle in the month of April 2022?
SELECT d.name, SUM(i.weight) as total_weight FROM Dispensaries d JOIN Inventory i ON d.id = i.dispensary_id WHERE d.city = 'Seattle' AND i.product_type = 'vape' AND i.month = 4 AND i.year = 2022 GROUP BY d.name;
gretelai_synthetic_text_to_sql
CREATE TABLE historical_sites (site_id INT, country VARCHAR(50), annual_visitors INT); INSERT INTO historical_sites (site_id, country, annual_visitors) VALUES (1, 'Egypt', 500000), (2, 'Egypt', 700000), (3, 'Morocco', 600000);
What is the minimum number of annual visitors to historical sites in Egypt?
SELECT MIN(hs.annual_visitors) FROM historical_sites hs WHERE hs.country = 'Egypt';
gretelai_synthetic_text_to_sql
CREATE TABLE providers (provider_id INT PRIMARY KEY AUTO_INCREMENT, first_name VARCHAR(50), last_name VARCHAR(50), gender VARCHAR(10), ethnicity VARCHAR(50), state VARCHAR(20));
Determine the top 3 states with the most providers in the 'providers' table, ordered by the number of providers in descending order.
SELECT state, COUNT(*) as num_providers FROM providers GROUP BY state ORDER BY num_providers DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE drug_approval_2 (drug_name TEXT, approval_date DATE, market TEXT); INSERT INTO drug_approval_2 (drug_name, approval_date, market) VALUES ('DrugA', '2017-01-01', 'Canadian'), ('DrugB', '2018-01-01', 'Canadian'), ('DrugC', '2019-01-01', 'Canadian');
What is the average drug approval time for 'DrugA' in the Canadian market?
SELECT AVG(DATEDIFF('2022-01-01', approval_date)) AS avg_approval_time FROM drug_approval_2 WHERE drug_name = 'DrugA' AND market = 'Canadian';
gretelai_synthetic_text_to_sql
CREATE TABLE Infrastructure (InfrastructureID INT, Type VARCHAR(20), Country VARCHAR(20), Status VARCHAR(20));
Update 'Infrastructure' table and set 'Status' to 'Completed' for records where 'Type' is 'Pipeline' and 'Country' is 'Canada'
UPDATE Infrastructure SET Status = 'Completed' WHERE Type = 'Pipeline' AND Country = 'Canada';
gretelai_synthetic_text_to_sql
CREATE TABLE volunteers (id INT, name TEXT, age INT); CREATE TABLE projects (id INT, name TEXT, location TEXT); INSERT INTO volunteers VALUES (1, 'John Doe', 25), (2, 'Jane Smith', 30); INSERT INTO projects VALUES (1, 'Clean Water', 'Kenya'), (2, 'Education', 'Uganda');
What's the total number of volunteers who worked on projects in Kenya and Uganda?
SELECT COUNT(*) FROM volunteers v INNER JOIN projects p ON v.id = p.volunteer_id WHERE p.location IN ('Kenya', 'Uganda');
gretelai_synthetic_text_to_sql
CREATE TABLE vr_games (game_id INT, genre VARCHAR(10), vr BOOLEAN);
How many VR games have been designed by players who are younger than 25 and have participated in an esports event?
SELECT COUNT(*) FROM vr_games INNER JOIN (SELECT player_id FROM players INNER JOIN esports_participants ON players.player_id = esports_participants.player_id WHERE players.age < 25) AS younger_players ON vr_games.game_id = younger_players.player_id WHERE vr_games.vr = TRUE;
gretelai_synthetic_text_to_sql