context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE Maintenance_Requests (id INT, region VARCHAR(50), status VARCHAR(50), maintenance_count INT);
How many military equipment maintenance requests are pending in the Asia-Pacific region?
SELECT region, SUM(maintenance_count) FROM Maintenance_Requests WHERE region = 'Asia-Pacific' AND status = 'pending' GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE transportation (id INT, project_name VARCHAR(50), location VARCHAR(50), cost FLOAT); INSERT INTO transportation (id, project_name, location, cost) VALUES (1, 'Bridge', 'Los Angeles', 3000000); INSERT INTO transportation (id, project_name, location, cost) VALUES (2, 'Highway', 'Chicago', 12000000);
What is the average cost of projects in the 'transportation' table?
SELECT AVG(cost) FROM transportation;
gretelai_synthetic_text_to_sql
CREATE TABLE spacecraft (id INT, name VARCHAR(255), launch_date DATE, mass FLOAT);
What is the total mass (in kilograms) of all spacecraft that have been launched since 2010?
SELECT SUM(mass) FROM spacecraft WHERE launch_date >= '2010-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE suppliers (supplier_id INT, name VARCHAR(255), email VARCHAR(255), phone VARCHAR(20));CREATE TABLE 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', 'info...
Provide a list of all suppliers that have not provided any materials in the last 12 months.
SELECT suppliers.name, suppliers.email, suppliers.phone FROM suppliers LEFT JOIN materials ON suppliers.supplier_id = materials.supplier_id JOIN dates ON dates.date >= DATE_SUB(CURRENT_DATE, INTERVAL 12 MONTH) GROUP BY suppliers.name, suppliers.email, suppliers.phone HAVING COUNT(materials.material_id) = 0;
gretelai_synthetic_text_to_sql
CREATE TABLE community_initiatives (id INT, country VARCHAR(50), initiative VARCHAR(50), expenditure DECIMAL(10,2)); INSERT INTO community_initiatives (id, country, initiative, expenditure) VALUES (1, 'India', 'Healthcare Center', 150000.00), (2, 'India', 'Education Building', 200000.00), (3, 'India', 'Community Hall',...
List the top 3 community development initiatives in India by expenditure.
SELECT initiative, SUM(expenditure) AS total_expenditure FROM community_initiatives WHERE country = 'India' GROUP BY initiative ORDER BY total_expenditure DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE employee_demographics (id INT, employee_id INT, department_id INT, gender VARCHAR(10)); INSERT INTO employee_demographics (id, employee_id, department_id, gender) VALUES (1, 1, 1, 'Female'), (2, 2, 1, 'Male'), (3, 3, 2, 'Female'), (4, 4, 2, 'Non-binary'), (5, 5, 3, 'Male');
What is the percentage of female and male employees by department?
SELECT department_id, gender, COUNT(*) * 100.0 / (SELECT COUNT(*) FROM employee_demographics WHERE department_id = departments.id) as percentage FROM employee_demographics JOIN departments ON employee_demographics.department_id = departments.id GROUP BY department_id, gender;
gretelai_synthetic_text_to_sql
CREATE TABLE cultivators (cultivator_id INT, name TEXT, state TEXT); INSERT INTO cultivators (cultivator_id, name, state) VALUES (1, 'Cultivator A', 'Nevada'), (2, 'Cultivator B', 'Nevada'), (3, 'Cultivator C', 'California'); CREATE TABLE harvests (harvest_id INT, cultivator_id INT, flower_weight INT); INSERT INTO harv...
What is the total weight of cannabis flowers produced by each cultivator in Nevada, ordered by weight from highest to lowest?
SELECT c.name, SUM(h.flower_weight) AS total_weight FROM cultivators c JOIN harvests h ON c.cultivator_id = h.cultivator_id WHERE c.state = 'Nevada' GROUP BY c.name ORDER BY total_weight DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE Sales (SaleID INT, VendorID INT, QuantitySold INT, IsEcoFriendly INT, SaleDate DATE); INSERT INTO Sales VALUES (1, 1, 50, 1, '2020-01-01'), (2, 1, 75, 1, '2020-01-02'), (3, 2, 100, 0, '2020-01-01'); CREATE TABLE Vendor (VendorID INT, VendorName VARCHAR(50), Location VARCHAR(50)); INSERT INTO Vendor VALUES ...
Find the average quantity of eco-friendly products sold, partitioned by quarter and vendor location, ordered by vendor name?
SELECT VendorName, TO_CHAR(SaleDate, 'YYYY-Q') AS Quarter, AVG(QuantitySold) OVER (PARTITION BY VendorID, Location, Quarter ORDER BY VendorName) AS AvgQuantity FROM Sales JOIN Vendor ON Sales.VendorID = Vendor.VendorID WHERE IsEcoFriendly = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE donors (donor_id INT, donor_name TEXT, country TEXT, total_donation_amount FLOAT); INSERT INTO donors (donor_id, donor_name, country, total_donation_amount) VALUES (1, 'Juan Rodriguez', 'Mexico', 4000.00), (2, 'Natalia Ivanova', 'Russia', 5000.00), (3, 'Pedro Garcia', 'Brazil', 2500.00);
Delete all records of donors from Russia.
DELETE FROM donors WHERE country = 'Russia';
gretelai_synthetic_text_to_sql
CREATE TABLE renewable_energy (id INT, country VARCHAR(255), source VARCHAR(255)); INSERT INTO renewable_energy (id, country, source) VALUES (1, 'Germany', 'wind'), (2, 'France', 'solar'), (3, 'Germany', 'solar'), (4, 'France', 'wind'), (5, 'Germany', 'hydro'), (6, 'France', 'hydro');
How many renewable energy sources are installed in each country?
SELECT country, COUNT(DISTINCT source) as num_sources FROM renewable_energy GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE CulturalCompetency (WorkerID INT, TrainingHours INT); INSERT INTO CulturalCompetency (WorkerID, TrainingHours) VALUES (1, 20), (2, 25), (3, 30), (4, 35), (5, 40);
What is the total number of cultural competency training hours by community health worker?
SELECT WorkerID, SUM(TrainingHours) as TotalTrainingHours FROM CulturalCompetency GROUP BY WorkerID;
gretelai_synthetic_text_to_sql
CREATE TABLE fish_stock (id INT, species VARCHAR(255), stocking_density FLOAT, biomass FLOAT); INSERT INTO fish_stock (id, species, stocking_density, biomass) VALUES (1, 'Salmon', 50.0, 60000.0), (2, 'Salmon', 45.0, 45000.0), (3, 'Tilapia', 30.0, 30000.0), (4, 'Tilapia', 35.0, 55000.0);
What is the minimum stocking density of fish for each species in the 'fish_stock' table, where the total biomass exceeds 50000?
SELECT species, MIN(stocking_density) FROM fish_stock GROUP BY species HAVING SUM(biomass) > 50000;
gretelai_synthetic_text_to_sql
CREATE TABLE Workers (ID INT, Age INT, Gender VARCHAR(10), Industry VARCHAR(20)); INSERT INTO Workers (ID, Age, Gender, Industry) VALUES (1, 42, 'Female', 'Textile'), (2, 35, 'Male', 'Textile'), (3, 45, 'Female', 'Textile'), (4, 52, 'Male', 'Food Processing'), (5, 60, 'Male', 'Food Processing');
Update the records of all workers in the 'Food Processing' industry who are male and over 40 years old, changing their industry to 'Agriculture'.
UPDATE Workers SET Industry = 'Agriculture' WHERE Industry = 'Food Processing' AND Gender = 'Male' AND Age > 40;
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (donor_id INT, donor_name VARCHAR(50), total_donation_amount DECIMAL(10,2), last_donation_date DATE); CREATE TABLE Donations (donation_id INT, donor_id INT, donation_amount DECIMAL(10,2), donation_date DATE, program_id INT);
Who were the top 3 donors in terms of total donation amount to education programs in 2021?
SELECT donor_name, SUM(donation_amount) as total_donation_amount FROM Donors d JOIN Donations don ON d.donor_id = don.donor_id WHERE program_id IN (SELECT program_id FROM Programs WHERE category = 'education') AND YEAR(donation_date) = 2021 GROUP BY donor_name ORDER BY total_donation_amount DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE worker_patient_data (worker_id INT, patients_served INT); INSERT INTO worker_patient_data (worker_id, patients_served) VALUES (1, 50); INSERT INTO worker_patient_data (worker_id, patients_served) VALUES (2, 75);
What is the maximum number of patients served by a community health worker?
SELECT MAX(patients_served) FROM worker_patient_data;
gretelai_synthetic_text_to_sql
CREATE TABLE workforce (workforce_id INT, mine_id INT, employee_name VARCHAR(50), gender VARCHAR(10)); INSERT INTO workforce (workforce_id, mine_id, employee_name, gender) VALUES (1, 1, 'John Doe', 'Male'), (2, 1, 'Jane Smith', 'Female'), (3, 2, 'Bob Johnson', 'Male'), (4, 3, 'Alice Williams', 'Female'), (5, 3, 'Charli...
How many employees of each gender work in mining operations, for operations with more than 100 employees?
SELECT mine_id, gender, COUNT(*) as employee_count FROM workforce WHERE (SELECT COUNT(*) FROM workforce w WHERE w.mine_id = workforce.mine_id) > 100 GROUP BY mine_id, gender;
gretelai_synthetic_text_to_sql
CREATE TABLE fish_farms (id INT, name TEXT, country TEXT, biomass FLOAT); CREATE TABLE country_oceans (country TEXT, ocean TEXT); INSERT INTO fish_farms (id, name, country, biomass) VALUES (1, 'Farm I', 'Pacific Ocean Country', 150), (2, 'Farm J', 'Pacific Ocean Country', 180), (3, 'Farm K', 'Atlantic Ocean Country', 1...
Find the total biomass of fish in farms located in the Pacific Ocean.
SELECT SUM(biomass) FROM fish_farms FF JOIN country_oceans CO ON FF.country = CO.country WHERE CO.ocean = 'Pacific Ocean';
gretelai_synthetic_text_to_sql
CREATE TABLE infrastructure_dept_budget (city VARCHAR(50), budget INT); INSERT INTO infrastructure_dept_budget (city, budget) VALUES ('CityA', 600000), ('CityB', 400000), ('CityC', 700000);
Which cities in the 'infrastructure' department budget table have a budget over 500000?
SELECT city FROM infrastructure_dept_budget WHERE budget > 500000;
gretelai_synthetic_text_to_sql
CREATE TABLE Cultivars (id INT, name TEXT, type TEXT);CREATE TABLE Inventory (id INT, cultivar_id INT, quantity INT, dispensary_id INT);CREATE TABLE Sales (id INT, inventory_id INT, quantity INT, sale_date DATE); INSERT INTO Cultivars (id, name, type) VALUES (1, 'Cultivar A', 'Indica'); INSERT INTO Inventory (id, culti...
What is the total quantity of each indica cultivar sold in Massachusetts in Q4 2022?
SELECT c.name, SUM(sales.quantity) as total_quantity_sold FROM Cultivars c JOIN Inventory i ON c.id = i.cultivar_id JOIN Sales sales ON i.id = sales.inventory_id WHERE c.type = 'Indica' AND i.dispensary_id IN (SELECT id FROM Dispensaries WHERE state = 'Massachusetts') AND sales.sale_date BETWEEN '2022-10-01' AND '2022-...
gretelai_synthetic_text_to_sql
CREATE TABLE biosensor_patents (id INT, filed_date DATE); INSERT INTO biosensor_patents (id, filed_date) VALUES (1, '2021-07-01'), (2, '2021-08-15'), (3, '2021-09-30');
Which biosensor technology patents were filed after June 30, 2021?
SELECT * FROM biosensor_patents WHERE filed_date > '2021-06-30';
gretelai_synthetic_text_to_sql
CREATE TABLE vessels (vessel_name VARCHAR(255), flag_state VARCHAR(255), registration_year INT); INSERT INTO vessels (vessel_name, flag_state, registration_year) VALUES ('FV Tropic', 'Panama', 2010), ('FV Atlantic Queen', 'Ecuador', 2012), ('FV Ocean Warrior', 'Spain', 2011);
Which countries have registered the most vessels for illegal, unreported, and unregulated fishing?
SELECT flag_state, COUNT(*) as num_vessels FROM vessels WHERE registration_year BETWEEN 2010 AND 2022 GROUP BY flag_state ORDER BY num_vessels DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE PropertySizes (PropertyID INT, Size INT, Neighborhood VARCHAR(20), Policy INT); INSERT INTO PropertySizes (PropertyID, Size, Neighborhood, Policy) VALUES (1, 1200, 'GreenTowers', 0), (2, 1500, 'SustainableVillage', 1), (3, 900, 'GreenTowers', 1);
Determine the change in average property size in 'GreenTowers' and 'SustainableVillage' neighborhoods before and after inclusive housing policies.
SELECT Neighborhood, AVG(Size) - LAG(AVG(Size)) OVER (PARTITION BY Neighborhood ORDER BY Policy) AS AvgSizeChange FROM PropertySizes GROUP BY Neighborhood, Policy ORDER BY Neighborhood, Policy;
gretelai_synthetic_text_to_sql
CREATE TABLE AircraftMaintenance (company TEXT, maintenance_date DATE, maintenance_cost FLOAT); INSERT INTO AircraftMaintenance (company, maintenance_date, maintenance_cost) VALUES ('AeroTech Inc.', '2022-01-10', 200000), ('AeroTech Inc.', '2022-03-15', 300000), ('AeroTech Inc.', '2022-03-30', 150000);
What is the total spent on aircraft maintenance by AeroTech Inc. in Q1 2022?
SELECT SUM(maintenance_cost) FROM AircraftMaintenance WHERE company = 'AeroTech Inc.' AND maintenance_date BETWEEN '2022-01-01' AND '2022-03-31';
gretelai_synthetic_text_to_sql
CREATE TABLE safety_inspections (id INT, vessel_name VARCHAR(50), type VARCHAR(50), region VARCHAR(50), date DATE); INSERT INTO safety_inspections (id, vessel_name, type, region, date) VALUES (1, 'Fishing Vessel A', 'Fishing Vessel', 'Southern Ocean', '2019-01-01'), (2, 'Fishing Vessel B', 'Fishing Vessel', 'Southern O...
How many safety inspections were conducted for fishing vessels in the Southern Ocean in the last 3 years?
SELECT type, COUNT(*) FROM safety_inspections WHERE region = 'Southern Ocean' AND date >= DATE_SUB(CURDATE(), INTERVAL 3 YEAR) AND type = 'Fishing Vessel' GROUP BY type;
gretelai_synthetic_text_to_sql
CREATE TABLE garment_manufacturers (manufacturer VARCHAR(50), quantity INT, sales DECIMAL(10,2), date DATE);
What is the number of garments produced by each manufacturer and their total sales in Q4 2022?
SELECT manufacturer, SUM(quantity) AS total_quantity, SUM(sales) AS total_sales FROM garment_manufacturers WHERE date >= '2022-10-01' AND date < '2023-01-01' GROUP BY manufacturer;
gretelai_synthetic_text_to_sql
CREATE TABLE posts (id INT, user_id INT, content TEXT);
Insert a new post with content 'Hello, world!' for user with ID 789
INSERT INTO posts (user_id, content) VALUES (789, 'Hello, world!');
gretelai_synthetic_text_to_sql
CREATE TABLE criminal_justice_reform (initiative_id INT, initiative_type VARCHAR(20), funding_source VARCHAR(20)); INSERT INTO criminal_justice_reform (initiative_id, initiative_type, funding_source) VALUES (1, 'Prison Reform', 'Government'), (2, 'Bail Reform', 'Non-profit');
What is the total number of criminal justice reform initiatives by type and funding source?
SELECT initiative_type, funding_source, COUNT(*) as total_initiatives FROM criminal_justice_reform GROUP BY initiative_type, funding_source;
gretelai_synthetic_text_to_sql
CREATE TABLE donors (id INT, name TEXT, age INT); INSERT INTO donors (id, name, age) VALUES (1, 'John Doe', 35), (2, 'Jane Smith', 28); CREATE TABLE contributions (donor_id INT, initiative_type TEXT); INSERT INTO contributions (donor_id, initiative_type) VALUES (1, 'education'), (1, 'healthcare'), (2, 'education');
What's the list of donors who have contributed to both education and healthcare initiatives?
SELECT donors.name FROM donors INNER JOIN contributions c1 ON donors.id = c1.donor_id INNER JOIN contributions c2 ON donors.id = c2.donor_id WHERE c1.initiative_type = 'education' AND c2.initiative_type = 'healthcare';
gretelai_synthetic_text_to_sql
CREATE TABLE highways (id INT, name TEXT, length_km FLOAT, location TEXT, built YEAR); INSERT INTO highways (id, name, length_km, location, built) VALUES (1, 'Autobahn A9', 530.5, 'Germany', 1936); INSERT INTO highways (id, name, length_km, location, built) VALUES (2, 'I-90', 498.7, 'USA', 1956);
Update the length of Autobahn A9 to 550 km.
UPDATE highways SET length_km = 550 WHERE name = 'Autobahn A9';
gretelai_synthetic_text_to_sql
CREATE TABLE Players (PlayerID int, PlayerName varchar(50), CharacterID int, WinRate decimal(5,2)); INSERT INTO Players (PlayerID, PlayerName, CharacterID, WinRate) VALUES (1, 'John', 1, 0.55), (2, 'Emma', 1, 0.62), (3, 'Liam', 2, 0.71), (4, 'Olivia', 2, 0.68), (5, 'Noah', 3, 0.64); CREATE TABLE Characters (CharacterID...
Which players have the highest win rate in the game "AwesomeLeague" for each character?
SELECT c.CharacterName, MAX(p.WinRate) as HighestWinRate FROM Players p JOIN Characters c ON p.CharacterID = c.CharacterID GROUP BY c.CharacterName;
gretelai_synthetic_text_to_sql
CREATE TABLE sales (product_id INT, country_name VARCHAR(20), sale_date DATE); INSERT INTO sales (product_id, country_name, sale_date) VALUES (1, 'USA', '2021-01-01'), (2, 'Canada', '2021-01-02'), (3, 'Mexico', '2021-02-01'), (4, 'Brazil', '2021-03-01');
How many products were sold in each country in 2021?
SELECT country_name, EXTRACT(MONTH FROM sale_date) AS month, COUNT(*) FROM sales GROUP BY country_name, month;
gretelai_synthetic_text_to_sql
CREATE TABLE EconomicImpact (id INT, name TEXT, country TEXT, initiative TEXT); INSERT INTO EconomicImpact (id, name, country, initiative) VALUES (1, 'Tokyo Green Spaces Expansion', 'Tokyo', 'Community Engagement'), (2, 'Tokyo Sustainable Business Program', 'Tokyo', 'Local Sourcing');
Which local economic impact initiatives were implemented in Tokyo?
SELECT DISTINCT initiative FROM EconomicImpact WHERE country = 'Tokyo';
gretelai_synthetic_text_to_sql
CREATE TABLE City (Id INT PRIMARY KEY, Name VARCHAR(50), Population INT, Country VARCHAR(50)); INSERT INTO City (Id, Name, Population, Country) VALUES (1, 'Jakarta', 10000000, 'Indonesia'); INSERT INTO City (Id, Name, Population, Country) VALUES (2, 'Surabaya', 2800000, 'Indonesia'); INSERT INTO City (Id, Name, Populat...
What is the difference in population between the most and least populous cities in 'Indonesia' and 'Brazil'?
SELECT Country, MAX(Population) - MIN(Population) as PopulationDifference FROM City WHERE Country IN ('Indonesia', 'Brazil') GROUP BY Country;
gretelai_synthetic_text_to_sql
CREATE TABLE online_learning (id INT, user_id INT, online_date DATE, online_time INT); INSERT INTO online_learning (id, user_id, online_date, online_time) VALUES (1, 1001, '2022-01-01', 60); INSERT INTO online_learning (id, user_id, online_date, online_time) VALUES (2, 1001, '2022-01-03', 90); INSERT INTO online_learni...
What is the running total of 'online_time' for each user, for the 'online_learning' database, ordered by user_id and date?
SELECT user_id, online_date, online_time, SUM(online_time) OVER (PARTITION BY user_id ORDER BY online_date) as running_total FROM online_learning;
gretelai_synthetic_text_to_sql
CREATE TABLE restaurant (restaurant_id INT, revenue INT); INSERT INTO restaurant (restaurant_id, revenue) VALUES (1, 5000), (2, 6000), (3, 7000), (4, 4000);
List all restaurants that have a revenue above the average revenue.
SELECT restaurant_id, revenue FROM restaurant WHERE revenue > (SELECT AVG(revenue) FROM restaurant);
gretelai_synthetic_text_to_sql
CREATE TABLE well_production (well_id INT, measurement_date DATE, production_rate FLOAT); INSERT INTO well_production (well_id, measurement_date, production_rate) VALUES (1, '2022-01-01', 500), (1, '2022-02-01', 550), (1, '2022-03-01', 600), (2, '2022-01-01', 700), (2, '2022-02-01', 650), (2, '2022-03-01', 750), (3, '2...
What are the top 3 wells with the highest production rate in the last 3 months?
SELECT well_id, MAX(production_rate) FROM well_production WHERE measurement_date >= DATEADD(month, -3, GETDATE()) GROUP BY well_id ORDER BY MAX(production_rate) DESC LIMIT 3
gretelai_synthetic_text_to_sql
CREATE TABLE electric_trains (train_id INT, journey_start_time TIMESTAMP, journey_end_time TIMESTAMP, journey_distance_km DECIMAL(5,2), journey_duration_minutes INT); INSERT INTO electric_trains (train_id, journey_start_time, journey_end_time, journey_distance_km, journey_duration_minutes) VALUES (1, '2022-06-01 10:00:...
What is the average speed in km/h for electric trains in Madrid, during trips with a duration greater than 60 minutes?
SELECT AVG(journey_distance_km/journey_duration_minutes*60) FROM electric_trains WHERE journey_duration_minutes > 60;
gretelai_synthetic_text_to_sql
CREATE SCHEMA gov_service;CREATE TABLE gov_service.citizen_feedback (quarter INT, satisfaction_score FLOAT); INSERT INTO gov_service.citizen_feedback (quarter, satisfaction_score) VALUES (1, 8.2), (2, 8.5), (3, 8.3), (4, 8.4);
What is the average citizen satisfaction score for public service delivery in Q1 and Q2 2022?
SELECT AVG(satisfaction_score) FROM gov_service.citizen_feedback WHERE quarter IN (1, 2);
gretelai_synthetic_text_to_sql
CREATE TABLE products (product_id INT, product_name VARCHAR(255), recycled_materials DECIMAL(10,2));
What percentage of our products are made with recycled materials?
SELECT ROUND(AVG(recycled_materials) * 100, 2) as percentage FROM products;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_protected_areas (id INT, name VARCHAR(255), size FLOAT, region VARCHAR(255)); INSERT INTO marine_protected_areas (id, name, size, region) VALUES (1, 'Great Barrier Reef', 344400.0, 'Pacific'); INSERT INTO marine_protected_areas (id, name, size, region) VALUES (2, 'Galapagos Marine Reserve', 133000.0...
How many marine protected areas are there in the Pacific Ocean region with a size greater than 50,000 square kilometers?
SELECT COUNT(*) FROM marine_protected_areas WHERE region = 'Pacific' AND size > 50000;
gretelai_synthetic_text_to_sql
CREATE TABLE forests_mx (id INT, name VARCHAR(50), state VARCHAR(50), public BOOLEAN); INSERT INTO forests_mx (id, name, state, public) VALUES (1, 'Bosque de Chapultepec', 'Ciudad de México', false); CREATE TABLE harvests_mx (id INT, forest_id INT, year INT, volume FLOAT); INSERT INTO harvests_mx (id, forest_id, year, ...
What is the total volume of timber harvested in the year 2021 in Mexico, categorized by state?
SELECT f.state, SUM(h.volume) FROM harvests_mx h JOIN forests_mx f ON h.forest_id = f.id WHERE h.year = 2021 GROUP BY f.state;
gretelai_synthetic_text_to_sql
CREATE TABLE organizations (id INT, name VARCHAR(255)); INSERT INTO organizations (id, name) VALUES (1, 'Amnesty International'), (2, 'Greenpeace'), (3, 'Oxfam'); CREATE TABLE personnel (id INT, organization_id INT, personnel_type VARCHAR(255), quantity INT, join_date DATE, location VARCHAR(255)); INSERT INTO personnel...
What's the total number of volunteers and staff by each organization in 'South America' in 2022?
SELECT organization_id, SUM(quantity) as total_personnel FROM personnel WHERE YEAR(join_date) = 2022 AND location = 'South America' GROUP BY organization_id;
gretelai_synthetic_text_to_sql
CREATE TABLE mental_health_facilities (facility_id INT, name VARCHAR(50), county VARCHAR(25)); INSERT INTO mental_health_facilities (facility_id, name, county) VALUES (1, 'Example MHF', 'Los Angeles County'); INSERT INTO mental_health_facilities (facility_id, name, county) VALUES (2, 'Another MHF', 'New York County'); ...
What is the total number of mental health facilities in each county?
SELECT county, COUNT(*) FROM mental_health_facilities GROUP BY county;
gretelai_synthetic_text_to_sql
CREATE TABLE sustainable_tourism_certifications (id INT, continent VARCHAR(255), certification_count INT); INSERT INTO sustainable_tourism_certifications (id, continent, certification_count) VALUES (1, 'Asia', 100), (2, 'Europe', 150), (3, 'Africa', 75), (4, 'North America', 200), (5, 'South America', 125), (6, 'Austra...
What is the total number of sustainable tourism certifications in Africa?
SELECT certification_count as total_certifications FROM sustainable_tourism_certifications WHERE continent = 'Africa';
gretelai_synthetic_text_to_sql
CREATE TABLE Meals (meal_name VARCHAR(50), calories INT, price INT, vegan BOOLEAN); INSERT INTO Meals (meal_name, calories, price, vegan) VALUES ('Lentil Soup', 300, 12, true), ('Veggie Burger', 500, 15, true), ('Chickpea Salad', 400, 13, true), ('Pizza', 800, 20, false);
What is the maximum price of vegan dishes served in 'VeganVille'?
SELECT MAX(price) FROM Meals WHERE meal_name LIKE 'VeganVille%' AND vegan = true
gretelai_synthetic_text_to_sql
CREATE TABLE Farmers (id INT, name VARCHAR(255), location VARCHAR(255)); CREATE TABLE Farmer_Crops (farmer_id INT, crop_type VARCHAR(255), area FLOAT); INSERT INTO Farmers (id, name, location) VALUES (1, 'Farmer A', 'India'), (2, 'Farmer B', 'India'), (3, 'Farmer C', 'India'); INSERT INTO Farmer_Crops (farmer_id, crop_...
Who are the top 3 farmers in India by total area of crops?
SELECT f.name, SUM(fc.area) as total_area FROM Farmers f INNER JOIN Farmer_Crops fc ON f.id = fc.farmer_id GROUP BY f.name ORDER BY total_area DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE ai_papers(id INT PRIMARY KEY, title VARCHAR(50), researcher_id INT); INSERT INTO ai_papers (id, title, researcher_id) VALUES (1, 'Explainable AI', 2), (2, 'AI Safety', 3), (3, 'AI Ethics', 1), (4, 'Explainable AI for AI Safety', 3);
What papers have been published on Explainable AI?
SELECT * FROM ai_papers WHERE title LIKE '%Explainable AI%';
gretelai_synthetic_text_to_sql
CREATE TABLE garment_info_2022 AS SELECT * FROM garment_info WHERE garment_info.info_date BETWEEN '2022-01-01' AND '2022-12-31'; ALTER TABLE garment_info_2022 ADD COLUMN garment_category VARCHAR(50); UPDATE garment_info_2022 SET garment_category = CASE WHEN garment_type = 'Shirt' THEN 'Tops' WHEN garment_type = 'Pants'...
What was the average sustainability score for each garment category by country in 2022, excluding accessories?
SELECT country, garment_category, AVG(sustainability_score) FROM garment_info_2022 WHERE garment_category != 'Accessories' GROUP BY country, garment_category;
gretelai_synthetic_text_to_sql
CREATE TABLE digital_divide_projects (id INT, project_name VARCHAR(50), location VARCHAR(50), budget INT); INSERT INTO digital_divide_projects (id, project_name, location, budget) VALUES (1, 'Internet Access Expansion', 'Brazil', 100000), (2, 'Broadband Connectivity', 'Argentina', 150000), (3, 'Digital Literacy Program...
Find the average budget for digital divide projects in South America.
SELECT AVG(budget) FROM digital_divide_projects WHERE location LIKE 'South%';
gretelai_synthetic_text_to_sql
CREATE TABLE vehicle_types (type_id INT, type_name TEXT); CREATE TABLE fleet (vehicle_id INT, vehicle_type_id INT, license_plate TEXT); CREATE TABLE failures (failure_id INT, vehicle_id INT, failure_time TIMESTAMP); INSERT INTO vehicle_types VALUES (1, 'Bus'), (2, 'Tram'), (3, 'Train'); INSERT INTO fleet VALUES (1, 1, ...
What is the average time between failures for all vehicles?
SELECT AVG(TIMESTAMPDIFF(MINUTE, failures.failure_time, LEAD(failures.failure_time) OVER (ORDER BY failures.failure_time))) AS avg_time_between_failures FROM failures;
gretelai_synthetic_text_to_sql
CREATE TABLE FishBiomass (Region TEXT, Species TEXT, Biomass FLOAT); INSERT INTO FishBiomass (Region, Species, Biomass) VALUES ('North Atlantic', 'Herring', 2500000), ('North Atlantic', 'Mackerel', 3000000), ('North Atlantic', 'Cod', 1500000), ('North Atlantic', 'Haddock', 1000000), ('North Atlantic', 'Pollock', 200000...
what is the total biomass of fish in the North Atlantic?
SELECT SUM(Biomass) FROM FishBiomass WHERE Region = 'North Atlantic';
gretelai_synthetic_text_to_sql
CREATE TABLE autonomous_vehicles (vehicle_id INT, make VARCHAR(50), model VARCHAR(50), safety_tests INT); INSERT INTO autonomous_vehicles (vehicle_id, make, model, safety_tests) VALUES (1, 'Waymo', 'Pacifica', 0), (2, 'Tesla', 'Model 3', 1), (3, 'Nissan', 'Leaf', 2);
Find the number of safety test failures for 'autonomous_vehicles' table
SELECT COUNT(*) FROM autonomous_vehicles WHERE safety_tests < 50;
gretelai_synthetic_text_to_sql
CREATE TABLE renewable_energy (project_name VARCHAR(255), region VARCHAR(255), year INT, investment FLOAT); INSERT INTO renewable_energy (project_name, region, year, investment) VALUES ('Solar Project X', 'Peru', 2010, 5000000), ('Wind Farm Y', 'Brazil', 2011, 8000000), ('Geothermal Plant Z', 'Chile', 2012, 12000000), ...
What is the total investment in renewable energy projects in Latin America between 2010 and 2015?
SELECT SUM(investment) FROM renewable_energy WHERE region LIKE 'Latin%' AND year BETWEEN 2010 AND 2015;
gretelai_synthetic_text_to_sql
CREATE TABLE countries (country VARCHAR(255), region VARCHAR(255), life_expectancy DECIMAL(5,2), year INT); INSERT INTO countries (country, region, life_expectancy, year) VALUES ('Afghanistan', 'Asia', 64.8, 2020), ('Bangladesh', 'Asia', 72.6, 2020);
What is the average life expectancy in Asian countries in 2020?
SELECT AVG(life_expectancy) FROM countries WHERE region = 'Asia' AND year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE drug_sales (drug_category VARCHAR(255), sale_date DATE, sales DECIMAL(10, 2)); INSERT INTO drug_sales (drug_category, sale_date, sales) VALUES ('Drug Category X', '2022-04-01', 12000), ('Drug Category Y', '2022-05-03', 15000), ('Drug Category Z', '2022-10-15', 14000), ('Drug Category W', '2022-11-22', 1400...
List the top 3 drug categories with the highest sales in the last 9 months, including ties.
SELECT drug_category, DENSE_RANK() OVER (ORDER BY SUM(sales) DESC) as rank FROM drug_sales WHERE sale_date >= DATEADD(month, -9, GETDATE()) GROUP BY drug_category HAVING COUNT(*) > 1;
gretelai_synthetic_text_to_sql
CREATE TABLE package_middle_east (id INT, package_weight FLOAT, shipped_from VARCHAR(20), shipped_to VARCHAR(20), shipped_date DATE); INSERT INTO package_middle_east (id, package_weight, shipped_from, shipped_to, shipped_date) VALUES (1, 4.5, 'Saudi Arabia', 'UAE', '2022-02-03');
What is the maximum weight of packages shipped between countries in the Middle East in the last week?
SELECT MAX(package_weight) FROM package_middle_east WHERE shipped_from LIKE 'Middle East%' AND shipped_to LIKE 'Middle East%' AND shipped_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 WEEK);
gretelai_synthetic_text_to_sql
CREATE VIEW asia_hotels AS SELECT * FROM hotels WHERE continent = 'Asia'; CREATE VIEW ai_adopters AS SELECT hotel_id FROM ai_tech WHERE adoption_date IS NOT NULL;
What is the percentage of hotels in the 'asia_hotels' view that have adopted AI technology?
SELECT COUNT(*) * 100.0 / (SELECT COUNT(*) FROM asia_hotels) as percentage FROM ai_adopters;
gretelai_synthetic_text_to_sql
CREATE TABLE vulnerabilities (id INT, date DATE, severity VARCHAR(10), ip VARCHAR(15), country VARCHAR(30)); INSERT INTO vulnerabilities (id, date, severity, ip, country) VALUES (1, '2021-01-01', 'high', '192.168.1.100', 'United States');
What is the total number of critical vulnerabilities by country, ordered by the number of vulnerabilities?
SELECT country, severity, COUNT(*) as vulnerability_count FROM vulnerabilities WHERE severity = 'critical' GROUP BY country ORDER BY vulnerability_count DESC;
gretelai_synthetic_text_to_sql
CREATE SCHEMA if not exists biotech;CREATE TABLE if not exists biotech.startups(id INT, name STRING, location STRING, funding FLOAT);INSERT INTO biotech.startups(id, name, location, funding) VALUES (1, 'StartupA', 'Australia', 7000000.00), (2, 'StartupB', 'Australia', 8000000.00), (3, 'StartupC', 'US', 20000000.00);
What is the minimum funding received by a biotech startup in Australia?
SELECT MIN(funding) FROM biotech.startups WHERE location = 'Australia';
gretelai_synthetic_text_to_sql
CREATE TABLE StudentPublications (id INT, name VARCHAR(255), department VARCHAR(255), publications INT, graduation_year INT);
List the top 5 graduate students with the highest number of research publications in the School of Engineering, ordered by total publications in descending order. Include their names, total publications, and graduation year.
SELECT name, SUM(publications) as total_publications, graduation_year FROM StudentPublications WHERE department LIKE 'Engineering%' GROUP BY name, graduation_year ORDER BY total_publications DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE glacier_data (glacier VARCHAR(50), year INT, area FLOAT);
What is the total area of Arctic glaciers that have retreated since 2010?
SELECT SUM(area) FROM glacier_data WHERE year >= 2010 AND area IS NOT NULL AND glacier IS NOT NULL AND area < 0;
gretelai_synthetic_text_to_sql
CREATE TABLE gas_reserves (well_name VARCHAR(255), reserve_volume INT, reserve_type VARCHAR(255), location VARCHAR(255)); INSERT INTO gas_reserves (well_name, reserve_volume, reserve_type, location) VALUES ('Well A', 1000000, 'Shale Gas', 'USA'); INSERT INTO gas_reserves (well_name, reserve_volume, reserve_type, locati...
List the gas reserves, ranked by volume, for each reserve type in the USA.
SELECT well_name, reserve_volume, reserve_type, location, ROW_NUMBER() OVER (PARTITION BY reserve_type ORDER BY reserve_volume DESC) as rank FROM gas_reserves WHERE location = 'USA'
gretelai_synthetic_text_to_sql
CREATE TABLE investment_data (customer_id INT, sector VARCHAR(20), investment FLOAT); INSERT INTO investment_data (customer_id, sector, investment) VALUES (1, 'technology', 5000), (2, 'financial services', 8000), (3, 'financial services', 3000); CREATE TABLE customer_data (customer_id INT, name VARCHAR(20), region VARC...
What is the average investment in the financial services sector for customers in the eastern region?
SELECT AVG(investment) FROM investment_data INNER JOIN customer_data ON investment_data.customer_id = customer_data.customer_id WHERE sector = 'financial services' AND customer_data.region = 'east';
gretelai_synthetic_text_to_sql
CREATE TABLE irrigation_system (id INT PRIMARY KEY, farm_id INT, system_type VARCHAR(50), install_date DATE); INSERT INTO irrigation_system (id, farm_id, system_type, install_date) VALUES (4, 3, 'Drip', '2019-03-25'); INSERT INTO irrigation_system (id, farm_id, system_type, install_date) VALUES (5, 4, 'Sprinkler', '202...
Which farms have a drip irrigation system installed?
SELECT farm_id FROM irrigation_system WHERE system_type = 'Drip';
gretelai_synthetic_text_to_sql
CREATE TABLE green_buildings (id INT, square_footage FLOAT, energy_rating INT);
Insert a new property into the 'green_buildings' table with a square footage of 1500 and energy rating of 70.
INSERT INTO green_buildings (id, square_footage, energy_rating) VALUES (1, 1500, 70);
gretelai_synthetic_text_to_sql
CREATE TABLE Games (GameID INT, GameName VARCHAR(20), Category VARCHAR(10), TotalHoursPlayed INT); INSERT INTO Games (GameID, GameName, Category, TotalHoursPlayed) VALUES (1, 'Game1', 'Action', 12); INSERT INTO Games (GameID, GameName, Category, TotalHoursPlayed) VALUES (2, 'Game2', 'Mobile', 5); INSERT INTO Games (Gam...
List the names of Mobile games that have been played for less than 10 hours in total.
SELECT GameName FROM Games WHERE Category = 'Mobile' AND TotalHoursPlayed < 10;
gretelai_synthetic_text_to_sql
CREATE TABLE artists (artist_id INT, genre VARCHAR(10), followers INT); INSERT INTO artists (artist_id, genre, followers) VALUES (1, 'Latin', 100000), (2, 'Pop', 200000), (3, 'Latin', 150000);
What is the maximum number of followers for Latin music artists on Spotify?
SELECT MAX(followers) FROM artists WHERE genre = 'Latin';
gretelai_synthetic_text_to_sql
CREATE TABLE machines (id INT PRIMARY KEY, name VARCHAR(255), manufacturer VARCHAR(255), type VARCHAR(255), year INT); INSERT INTO machines (id, name, manufacturer, type, year) VALUES (1, 'Machine A', 'Manufacturer X', 'CNC', 2017), (2, 'Machine B', 'Manufacturer Y', '3D Printing', 2021), (3, 'Machine C', 'Manufacturer...
What is the total number of machines for each manufacturer, and the latest model year for each manufacturer?
SELECT manufacturer, COUNT(*) as total_machines, MAX(year) as latest_model FROM machines GROUP BY manufacturer;
gretelai_synthetic_text_to_sql
CREATE TABLE rescue_center (id INT, animal_name VARCHAR(50), date_admitted DATE, region VARCHAR(20)); INSERT INTO rescue_center (id, animal_name, date_admitted, region) VALUES (1, 'Fox', '2021-01-05', 'Mountain'); INSERT INTO rescue_center (id, animal_name, date_admitted, region) VALUES (2, 'Eagle', '2021-06-10', 'Fore...
How many animals were admitted to the rescue center in the 'Forest' region?;
SELECT COUNT(animal_name) FROM rescue_center WHERE region = 'Forest';
gretelai_synthetic_text_to_sql
CREATE TABLE country_products (country VARCHAR(255), product_id INT, quantity INT, ethical_labor BOOLEAN, FOREIGN KEY (product_id) REFERENCES products(id));
How many products are manufactured in each country with ethical labor practices?
SELECT country, SUM(quantity) FROM country_products WHERE ethical_labor = TRUE GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE workers (id INT, name VARCHAR(255), industry VARCHAR(255), salary DECIMAL(10,2)); CREATE TABLE unions (id INT, worker_id INT, union VARCHAR(255)); INSERT INTO workers (id, name, industry, salary) VALUES (1, 'David Williams', 'transportation', 70000.00);
What is the average salary of workers in the 'transportation' industry who are part of a union?
SELECT AVG(workers.salary) FROM workers INNER JOIN unions ON workers.id = unions.worker_id WHERE workers.industry = 'transportation' AND unions.union = 'yes';
gretelai_synthetic_text_to_sql
CREATE SCHEMA if not exists rural_dev; use rural_dev; CREATE TABLE if not exists rural_infrastructure_projects (id INT, project_name VARCHAR(255), country VARCHAR(255), budget FLOAT, PRIMARY KEY (id));
List all rural infrastructure projects in Oceania with a budget greater than $1 million.
SELECT project_name, country, budget FROM rural_dev.rural_infrastructure_projects WHERE country LIKE 'Oceania%' AND budget > 1000000;
gretelai_synthetic_text_to_sql
CREATE TABLE cultural_competency_training (id INT PRIMARY KEY, organization_name VARCHAR(50), training_title TEXT, training_date DATE);
Show organizations that provided training in 2023
SELECT DISTINCT organization_name FROM cultural_competency_training WHERE training_date >= '2023-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE events (id INT, event_name VARCHAR(100), event_type VARCHAR(100), visitor_rural BOOLEAN, attendance INT, event_date DATE);
Find the top 3 events with the highest number of attendees from rural areas in the last 2 years, including their total attendee count.
SELECT event_name, SUM(attendance) AS total_attendance FROM events WHERE visitor_rural = TRUE AND event_date >= DATE_SUB(CURDATE(), INTERVAL 2 YEAR) GROUP BY event_name ORDER BY total_attendance DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE factories (id INT, name VARCHAR(255));CREATE TABLE factory_machines (factory_id INT, machine_id INT);
Show the number of machines in each factory, including factories with no machines.
SELECT factories.name, COUNT(factory_machines.machine_id) AS machine_count FROM factories LEFT JOIN factory_machines ON factories.id = factory_machines.factory_id GROUP BY factories.id;
gretelai_synthetic_text_to_sql
CREATE TABLE budgets (id INT, region TEXT, program TEXT, amount FLOAT); INSERT INTO budgets (id, region, program, amount) VALUES (1, 'African', 'Healthcare', 1000000.00), (2, 'Asian', 'Education', 1500000.00), (3, 'African', 'Transportation', 800000.00), (4, 'European', 'Energy', 1200000.00);
What is the total budget allocated for healthcare programs in the African region?
SELECT SUM(amount) FROM budgets WHERE region = 'African' AND program = 'Healthcare';
gretelai_synthetic_text_to_sql
CREATE TABLE month (month_id INT, month_name TEXT); CREATE TABLE professional_development (professional_development_id INT, month_id INT, num_hours INT); INSERT INTO month (month_id, month_name) VALUES (1, 'January'), (2, 'February'), (3, 'March'), (4, 'April'), (5, 'May'), (6, 'June'), (7, 'July'), (8, 'August'), (9, ...
What is the average number of hours of professional development workshops held per month?
SELECT month_name, AVG(num_hours) FROM professional_development INNER JOIN month ON professional_development.month_id = month.month_id GROUP BY month_name;
gretelai_synthetic_text_to_sql
CREATE TABLE Genre (GenreID INT, Genre VARCHAR(50)); INSERT INTO Genre VALUES (1, 'Pop'), (2, 'Rock'), (3, 'Jazz');
What is the total number of streams for artists in the 'Pop' genre?
SELECT COUNT(*) FROM Streams JOIN Artists ON Streams.ArtistID = Artists.ArtistID WHERE Artists.Genre = 'Pop';
gretelai_synthetic_text_to_sql
CREATE TABLE procedures (procedure_id INT, procedure_name TEXT, hospital_id INT); INSERT INTO procedures (procedure_id, procedure_name, hospital_id) VALUES (1, 'Procedure A', 1); CREATE TABLE hospitals (hospital_id INT, hospital_name TEXT, beds INT, rural BOOLEAN, state_id INT); INSERT INTO hospitals (hospital_id, hosp...
List the top 10 most common procedures performed in rural hospitals, ordered by the number of occurrences in descending order.
SELECT procedures.procedure_name, COUNT(procedures.procedure_id) procedure_count FROM procedures JOIN hospitals ON procedures.hospital_id = hospitals.hospital_id AND hospitals.rural = true GROUP BY procedures.procedure_name ORDER BY procedure_count DESC LIMIT 10;
gretelai_synthetic_text_to_sql
CREATE TABLE technology_accessibility_impact (person_id INT, region VARCHAR(20)); INSERT INTO technology_accessibility_impact (person_id, region) VALUES (1, 'South America'), (2, 'Africa'), (3, 'Asia'), (4, 'South America');
What is the total number of people who have benefited from technology accessibility initiatives in South America?
SELECT COUNT(*) FROM technology_accessibility_impact WHERE region = 'South America';
gretelai_synthetic_text_to_sql
CREATE TABLE city_waste_generation(city VARCHAR(50), year INT, population INT, amount FLOAT); INSERT INTO city_waste_generation(city, year, population, amount) VALUES('CityC', 2022, 200000, 250000), ('CityC', 2021, 195000, 245000), ('CityD', 2022, 220000, 280000), ('CityD', 2021, 215000, 275000);
What is the average waste generation in kg per capita for 'CityC' and 'CityD' in 2022?
SELECT w.city, AVG(w.amount/c.population) FROM city_waste_generation w JOIN (SELECT city, SUM(population) AS population FROM city_waste_generation WHERE year = 2022 GROUP BY city) c ON w.city = c.city WHERE w.year = 2022 GROUP BY w.city;
gretelai_synthetic_text_to_sql
CREATE TABLE clinics (id INT, name VARCHAR(50), location VARCHAR(50)); CREATE TABLE patient_satisfaction (clinic_id INT, score INT); INSERT INTO clinics (id, name, location) VALUES (1, 'Clinic A', 'California'), (2, 'Clinic B', 'California'); INSERT INTO patient_satisfaction (clinic_id, score) VALUES (1, 90), (2, 95);
What is the name and location of the rural clinic with the highest patient satisfaction score in California?
SELECT clinics.name, clinics.location FROM clinics JOIN (SELECT clinic_id, MAX(score) as max_score FROM patient_satisfaction GROUP BY clinic_id) AS subquery ON clinics.id = subquery.clinic_id;
gretelai_synthetic_text_to_sql
CREATE TABLE PermitsByDay (PermitID int, Date date, State varchar(25)); INSERT INTO PermitsByDay (PermitID, Date, State) VALUES (4, '2021-01-01', 'CA'), (5, '2021-02-01', 'CA'), (6, '2021-03-01', 'CA');
How many building permits were issued per day in CA in 2021?
SELECT DATEPART(YEAR, Date) AS Year, DATEPART(MONTH, Date) AS Month, DATEPART(DAY, Date) AS Day, COUNT(*) AS PermitsIssued FROM PermitsByDay WHERE State = 'CA' AND YEAR(Date) = 2021 GROUP BY DATEPART(YEAR, Date), DATEPART(MONTH, Date), DATEPART(DAY, Date);
gretelai_synthetic_text_to_sql
CREATE TABLE Artworks (ArtworkID INT, Name VARCHAR(100), Artist VARCHAR(100), YearCreated INT, TotalSales DECIMAL(10,2)); INSERT INTO Artworks (ArtworkID, Name, Artist, YearCreated, TotalSales) VALUES (1, 'The Persistence of Memory', 'Salvador Dalí', 1931, 500000);
What was the most popular artwork in the 18th century by total sales?
SELECT Name, TotalSales FROM (SELECT Name, TotalSales, ROW_NUMBER() OVER (ORDER BY TotalSales DESC) as rn FROM Artworks WHERE YearCreated BETWEEN 1701 AND 1800) tmp WHERE rn = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE algorand_network (network_name VARCHAR(20), node_count INT); INSERT INTO algorand_network (network_name, node_count) VALUES ('Algorand', 1000);
How many nodes are present on the Algorand network?
SELECT node_count FROM algorand_network WHERE network_name = 'Algorand';
gretelai_synthetic_text_to_sql
CREATE TABLE Exhibition (id INT, title VARCHAR(255), art_count INT);
List all exhibitions with more than 50 artworks.
SELECT title FROM Exhibition WHERE art_count > 50;
gretelai_synthetic_text_to_sql
CREATE TABLE traditional_music_south_america (id INT, genre VARCHAR(30), performer VARCHAR(30), country VARCHAR(15)); INSERT INTO traditional_music_south_america (id, genre, performer, country) VALUES (1, 'Samba', 'Beth Carvalho', 'Brazil'), (2, 'Cumbia', 'Totó la Momposina', 'Colombia'), (3, 'Andean', 'Los Kjarkas', '...
List the traditional music genres and their performers in South America.
SELECT genre, performer FROM traditional_music_south_america;
gretelai_synthetic_text_to_sql
CREATE TABLE household_water_consumption (id INT, state VARCHAR(20), water_consumption FLOAT); INSERT INTO household_water_consumption (id, state, water_consumption) VALUES (1, 'New_York', 150), (2, 'New_York', 200), (3, 'Texas', 120);
What is the minimum water consumption per household in the state of New York?
SELECT state, MIN(water_consumption) FROM household_water_consumption WHERE state = 'New York';
gretelai_synthetic_text_to_sql
CREATE TABLE Hires (HireDate DATE); INSERT INTO Hires (HireDate) VALUES ('2021-01-01'), ('2021-02-01'), ('2021-03-01'), ('2022-01-01'), ('2022-02-01');
What is the number of new hires by month for the last two years, including months with no new hires?
SELECT DATE_FORMAT(HireDate, '%Y-%m') as Month, COUNT(*) as New_Hires FROM Hires WHERE HireDate >= DATE_SUB(CURRENT_DATE, INTERVAL 24 MONTH) GROUP BY Month ORDER BY Month;
gretelai_synthetic_text_to_sql
CREATE TABLE rural_infrastructure (id INT, state VARCHAR(50), project_type VARCHAR(50), status VARCHAR(50)); INSERT INTO rural_infrastructure (id, state, project_type, status) VALUES (1, 'New South Wales', 'Roads', 'Completed'), (2, 'Victoria', 'Irrigation', 'In Progress'), (3, 'Queensland', 'Rural Electrification', 'C...
How many rural infrastructure projects have been completed in each state of Australia?
SELECT state, COUNT(*) as completed_projects FROM rural_infrastructure WHERE status = 'Completed' GROUP BY state;
gretelai_synthetic_text_to_sql
CREATE TABLE Infrastructure_Projects (id INT, name VARCHAR(100), state VARCHAR(50), cost FLOAT); INSERT INTO Infrastructure_Projects (id, name, state, cost) VALUES (1, 'Seawall Upgrade', 'California', 5000000); INSERT INTO Infrastructure_Projects (id, name, state, cost) VALUES (2, 'Road Repaving', 'California', 2000000...
What is the maximum and minimum cost of projects in 'California'?
SELECT MIN(cost), MAX(cost) FROM Infrastructure_Projects WHERE state = 'California';
gretelai_synthetic_text_to_sql
CREATE TABLE operator_production (operator_id INT, production_quantity INT, date DATE); INSERT INTO operator_production (operator_id, production_quantity, date) VALUES (1, 500, '2022-01-01'); INSERT INTO operator_production (operator_id, production_quantity, date) VALUES (2, 600, '2022-01-02');
Who are the top five operators with the highest production quantity?
SELECT operator_id, SUM(production_quantity) as total_production FROM operator_production GROUP BY operator_id ORDER BY total_production DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE MilitaryTech (id INT, name VARCHAR(50), type VARCHAR(50), country VARCHAR(50), cost FLOAT); INSERT INTO MilitaryTech (id, name, type, country, cost) VALUES (1, 'F-35 Lightning II', 'Fighter', 'USA', 1010000000);
What is the average cost of military technologies with more than 2 instances?
SELECT type, AVG(cost) FROM MilitaryTech GROUP BY type HAVING COUNT(*) > 2;
gretelai_synthetic_text_to_sql
CREATE TABLE MilitaryTechnology (Id INT PRIMARY KEY, Country VARCHAR(50), Name VARCHAR(50), Year INT);
Find countries where all military technologies are newer than 2010
SELECT Country FROM MilitaryTechnology GROUP BY Country HAVING MIN(Year) > 2010;
gretelai_synthetic_text_to_sql
CREATE TABLE subway (line_id INT, city VARCHAR(50), daily_ridership INT); INSERT INTO subway (line_id, city, daily_ridership) VALUES (1, 'Tokyo', 300000), (2, 'Tokyo', 450000), (3, 'Tokyo', 400000), (4, 'Tokyo', 500000);
What is the average daily ridership for each subway line in Tokyo?
SELECT line_id, city, AVG(daily_ridership) FROM subway GROUP BY line_id, city;
gretelai_synthetic_text_to_sql
CREATE TABLE Events (event_id INT, event_name VARCHAR(255)); INSERT INTO Events (event_id, event_name) VALUES (1, 'Annual Festival'), (2, 'Community Fair'); CREATE TABLE Audience (audience_id INT, event_id INT, community_representation VARCHAR(50), total_attendees INT); INSERT INTO Audience (audience_id, event_id, comm...
What percentage of attendees at the 'Community Fair' event identify as part of the LGBTQ+ community?
SELECT e.event_name, a.community_representation, (COUNT(a.audience_id) * 100.0 / SUM(a.total_attendees)) AS percentage FROM Events e JOIN Audience a ON e.event_id = a.event_id WHERE e.event_name = 'Community Fair' AND a.community_representation = 'LGBTQ+' GROUP BY e.event_name, a.community_representation;
gretelai_synthetic_text_to_sql
CREATE TABLE menu_sustainability (id INT PRIMARY KEY, menu_item VARCHAR(255), sustainability_rating DECIMAL(3,2)); CREATE TABLE menu_items (id INT PRIMARY KEY, menu_item VARCHAR(255), is_sustainable BOOLEAN, price DECIMAL(5,2));
Find the total revenue generated from sustainable menu items
SELECT SUM(price) FROM menu_items mi JOIN menu_sustainability ms ON mi.menu_item = ms.menu_item WHERE ms.sustainability_rating >= 0.75 AND mi.is_sustainable = true;
gretelai_synthetic_text_to_sql
CREATE TABLE games (game_id INT, game_type VARCHAR(10)); INSERT INTO games (game_id, game_type) VALUES (1, 'Hockey'); CREATE TABLE sales (sale_id INT, game_id INT, revenue DECIMAL(5,2), quantity INT); INSERT INTO sales (sale_id, game_id, revenue, quantity) VALUES (1, 1, 100.00, 2), (2, 1, 125.00, 3), (3, 1, 150.00, 1);
What is the average ticket price for hockey games?
SELECT AVG(sales.revenue/sales.quantity) FROM sales JOIN games ON sales.game_id = games.game_id WHERE games.game_type = 'Hockey';
gretelai_synthetic_text_to_sql
CREATE TABLE gas_production (country text, year integer, daily_gas_production real); INSERT INTO gas_production (country, year, daily_gas_production) VALUES ('USA', 2020, 2739.73), ('Russia', 2020, 2191.78), ('Iran', 2020, 1369.86), ('China', 2020, 821.92), ('Qatar', 2020, 607.14);
What is the average daily gas production for the top 3 gas producing countries?
SELECT AVG(daily_gas_production) FROM (SELECT daily_gas_production FROM gas_production WHERE country IN ('USA', 'Russia', 'Iran') ORDER BY daily_gas_production DESC LIMIT 3) subquery;
gretelai_synthetic_text_to_sql
CREATE TABLE Cases (ID INT, CaseNumber INT, DateOpened DATE, DateClosed DATE, Resolution VARCHAR(255)); INSERT INTO Cases (ID, CaseNumber, DateOpened, DateClosed, Resolution) VALUES (1, 12345, '2022-01-01', '2022-03-15', 'Mediation'), (2, 67890, '2022-02-15', '2022-04-30', 'Fine'), (3, 111213, '2022-03-28', NULL, 'Prob...
What is the percentage of cases that were resolved through mediation, out of all cases closed in the past year?
SELECT (SUM(CASE WHEN Resolution = 'Mediation' THEN 1 ELSE 0 END) * 100.0 / COUNT(*)) as PercentageResolvedThroughMediation FROM Cases WHERE DateClosed IS NOT NULL AND DateClosed >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR);
gretelai_synthetic_text_to_sql