context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE well_production (well_id INT, measurement_date DATE, production_rate FLOAT, location TEXT); INSERT INTO well_production (well_id, measurement_date, production_rate, location) VALUES (1, '2022-01-01', 500, 'USA'), (2, '2022-02-01', 700, 'Saudi Arabia'), (3, '2022-03-01', 600, 'Canada'), (4, '2022-02-01', 800, 'Iran'), (5, '2022-03-01', 900, 'Iraq');
What's the average production rate for wells in the Middle East in the last quarter?
SELECT AVG(production_rate) FROM well_production WHERE measurement_date >= DATEADD(quarter, -1, GETDATE()) AND location LIKE 'Middle East%';
gretelai_synthetic_text_to_sql
CREATE TABLE recycling_rates (city VARCHAR(20), year INT, recycling_rate FLOAT);INSERT INTO recycling_rates (city, year, recycling_rate) VALUES ('San Francisco', 2019, 0.65), ('San Francisco', 2020, 0.7), ('San Francisco', 2021, 0.75), ('Oakland', 2019, 0.55), ('Oakland', 2020, 0.6), ('Oakland', 2021, 0.65);
Find the city with the highest recycling rate in 2021
SELECT city FROM recycling_rates WHERE year = 2021 AND recycling_rate = (SELECT MAX(recycling_rate) FROM recycling_rates WHERE year = 2021);
gretelai_synthetic_text_to_sql
CREATE TABLE food_inspections (restaurant_id INT, inspection_date DATE);
Delete records in the food_inspections table where the inspection_date is before '2021-01-01'
DELETE FROM food_inspections WHERE inspection_date < '2021-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE schools (school_id INT, school_name VARCHAR(255), city VARCHAR(255)); CREATE TABLE student_mental_health (student_id INT, school_id INT, mental_health_score INT); INSERT INTO schools (school_id, school_name, city) VALUES (1, 'School A', 'City X'), (2, 'School B', 'City X'), (3, 'School C', 'City Y'); INSERT INTO student_mental_health (student_id, school_id, mental_health_score) VALUES (1, 1, 70), (2, 1, 80), (3, 2, 60), (4, 2, 75), (5, 3, 90), (6, 3, 85);
Which students have a higher mental health score than the average mental health score of their school?
SELECT student_id, mental_health_score, school_id, AVG(mental_health_score) OVER (PARTITION BY school_id) as avg_school_score FROM student_mental_health;
gretelai_synthetic_text_to_sql
CREATE TABLE mining_operations (operation_id INT, operation_name VARCHAR(50), location VARCHAR(50)); CREATE TABLE co2_emissions (operation_id INT, co2_emissions_tonnes INT); INSERT INTO mining_operations (operation_id, operation_name, location) VALUES (1, 'Operation A', 'USA'), (2, 'Operation B', 'Canada'), (3, 'Operation C', 'Mexico'), (4, 'Operation D', 'USA'); INSERT INTO co2_emissions (operation_id, co2_emissions_tonnes) VALUES (1, 1000), (2, 1500), (3, 500);
Which mining operations have no CO2 emissions data?
SELECT mining_operations.operation_name FROM mining_operations LEFT JOIN co2_emissions ON mining_operations.operation_id = co2_emissions.operation_id WHERE co2_emissions.operation_id IS NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE animals (id INT PRIMARY KEY, name VARCHAR(50), species VARCHAR(50), population INT); CREATE TABLE habitats (id INT PRIMARY KEY, name VARCHAR(50), location VARCHAR(50), size FLOAT, animal_id INT);
What is the total number of animals in each habitat, grouped by habitat size?
SELECT habitats.size, COUNT(DISTINCT animals.id) AS total_animals FROM animals INNER JOIN habitats ON animals.id = habitats.animal_id GROUP BY habitats.size;
gretelai_synthetic_text_to_sql
CREATE TABLE Artists (ArtistID int, ArtistName varchar(100), Nationality varchar(50)); INSERT INTO Artists (ArtistID, ArtistName, Nationality) VALUES (1, 'Pablo Picasso', 'Spanish'), (2, 'Jackson Pollock', 'American'), (3, 'Francis Bacon', 'Irish'); CREATE TABLE ExhibitedWorks (WorkID int, ArtistID int, MuseumID int); INSERT INTO ExhibitedWorks (WorkID, ArtistID, MuseumID) VALUES (1, 1, 2), (2, 2, 2), (3, 3, 2); CREATE TABLE Museums (MuseumID int, MuseumName varchar(100), Country varchar(50)); INSERT INTO Museums (MuseumID, MuseumName, Country) VALUES (1, 'Guggenheim Museum', 'USA'), (2, 'Tate Modern', 'UK');
List all artists and their respective countries who have had their works displayed in the Guggenheim Museum.
SELECT Artists.ArtistName, Artists.Nationality FROM Artists INNER JOIN ExhibitedWorks ON Artists.ArtistID = ExhibitedWorks.ArtistID INNER JOIN Museums ON ExhibitedWorks.MuseumID = Museums.MuseumID WHERE Museums.MuseumName = 'Guggenheim Museum';
gretelai_synthetic_text_to_sql
CREATE TABLE research_grants (id INT, student_type VARCHAR(10), amount DECIMAL(10,2)); INSERT INTO research_grants (id, student_type, amount) VALUES (1, 'Domestic', 15000.00), (2, 'International', 20000.00);
What are the total number of research grants awarded to domestic and international graduate students?
SELECT SUM(amount) FROM research_grants WHERE student_type IN ('Domestic', 'International');
gretelai_synthetic_text_to_sql
CREATE TABLE companies (id INT, sector TEXT, ESG_rating FLOAT); INSERT INTO companies (id, sector, ESG_rating) VALUES (1, 'technology', 78.2), (2, 'finance', 82.5), (3, 'technology', 84.6);
Increase the ESG rating by 5 for company with id 1.
UPDATE companies SET ESG_rating = ESG_rating + 5 WHERE id = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE Restaurants (RestaurantID int, Name varchar(50), Location varchar(50)); CREATE TABLE Menu (MenuID int, ItemName varchar(50), Category varchar(50)); CREATE TABLE MenuSales (MenuID int, RestaurantID int, QuantitySold int, Revenue decimal(5,2), SaleDate date); INSERT INTO Menu (MenuID, ItemName, Category) VALUES (2001, 'Organic Salad', 'Sustainable'), (2002, 'Free-range Chicken', 'Sustainable');
What is the total revenue and quantity sold for each sustainable category, including the total quantity sold, in Washington D.C. during the month of November 2021?
SELECT C.Category, SUM(M.Revenue) as Revenue, SUM(M.QuantitySold) as QuantitySold FROM Menu M JOIN MenuSales MS ON M.MenuID = MS.MenuID JOIN Restaurants R ON MS.RestaurantID = R.RestaurantID JOIN (SELECT * FROM Restaurants WHERE Location LIKE '%Washington D.C.%') C ON R.RestaurantID = C.RestaurantID WHERE MS.SaleDate >= '2021-11-01' AND MS.SaleDate <= '2021-11-30' AND M.Category IN ('Sustainable') GROUP BY C.Category;
gretelai_synthetic_text_to_sql
CREATE TABLE Districts (DistrictID INT, DistrictName VARCHAR(255)); CREATE TABLE Events (EventID INT, EventType VARCHAR(255), DistrictID INT, EventDate DATE);
How many community policing events occurred in each district in the last year?
SELECT DistrictName, COUNT(EventID) as EventsCount FROM Events e JOIN Districts d ON e.DistrictID = d.DistrictID WHERE EventDate >= DATEADD(year, -1, GETDATE()) AND EventType = 'Community Policing' GROUP BY DistrictName;
gretelai_synthetic_text_to_sql
CREATE TABLE HistoricalCommodityPrices (commodity VARCHAR(20), price FLOAT, date DATE);
What was the maximum and minimum price for 'Rice' and 'Wheat' in 'HistoricalCommodityPrices' table?
SELECT commodity, MAX(price) as max_price, MIN(price) as min_price FROM HistoricalCommodityPrices WHERE commodity IN ('Rice','Wheat') GROUP BY commodity;
gretelai_synthetic_text_to_sql
CREATE TABLE Environmental_Impact(Mine_Name TEXT, SO2_Emissions INT, Water_Consumption INT); INSERT INTO Environmental_Impact(Mine_Name, SO2_Emissions, Water_Consumption) VALUES('Tasiast', 700000, 1400000); INSERT INTO Environmental_Impact(Mine_Name, SO2_Emissions, Water_Consumption) VALUES('Katanga', 900000, 1800000);
What are the SO2 emissions for the 'Tasiast' and 'Katanga' mines?
SELECT SO2_Emissions FROM Environmental_Impact WHERE Mine_Name IN ('Tasiast', 'Katanga');
gretelai_synthetic_text_to_sql
CREATE TABLE wells (well_id varchar(10), region varchar(20), production_figures int); INSERT INTO wells (well_id, region, production_figures) VALUES ('W009', 'Arctic Ocean', 2800), ('W010', 'Arctic Ocean', 3100), ('W011', 'Arctic Ocean', 2900);
What is the average production figure for all wells located in the Arctic Ocean?
SELECT AVG(production_figures) FROM wells WHERE region = 'Arctic Ocean';
gretelai_synthetic_text_to_sql
CREATE TABLE shipping_lines (shipping_line_id INT, shipping_line_name VARCHAR(50), cargo_handling_time INT); INSERT INTO shipping_lines (shipping_line_id, shipping_line_name, cargo_handling_time) VALUES (1, 'SL1', 120), (2, 'SL2', 150), (3, 'SL3', 180);
What is the average cargo handling time for each shipping line?
SELECT shipping_line_name, AVG(cargo_handling_time) FROM shipping_lines GROUP BY shipping_line_name;
gretelai_synthetic_text_to_sql
CREATE TABLE donations (id INT, donor_name VARCHAR(50), donation_amount DECIMAL(10, 2), project_name VARCHAR(50), donation_date DATE); INSERT INTO donations (id, donor_name, donation_amount, project_name, donation_date) VALUES (1, 'John Doe', 500, 'Habitat Restoration', '2020-01-01'); INSERT INTO donations (id, donor_name, donation_amount, project_name, donation_date) VALUES (2, 'Jane Smith', 300, 'Community Education', '2019-12-31');
What is the total amount of donations received for the 'Habitat Restoration' project in 2020?;
SELECT SUM(donation_amount) FROM donations WHERE project_name = 'Habitat Restoration' AND YEAR(donation_date) = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE threat_actors (id INT, name VARCHAR); INSERT INTO threat_actors (id, name) VALUES (1, 'APT28'), (2, 'APT33'), (3, 'Lazarus Group'), (4, 'Cozy Bear');
Insert a new threat actor 'WinterLion' with id 5 into the threat_actors table
INSERT INTO threat_actors (id, name) VALUES (5, 'WinterLion');
gretelai_synthetic_text_to_sql
CREATE TABLE Defense_Projects(id INT, project_name VARCHAR(255), start_year INT, end_year INT); INSERT INTO Defense_Projects(id, project_name, start_year, end_year) VALUES (1, 'Project A', 2015, 2018), (2, 'Project B', 2016, 2019), (3, 'Project C', 2017, 2020), (4, 'Project D', 2018, 2021), (5, 'Project E', 2015, 2020), (6, 'Project F', 2016, 2017);
Update the end year of defense project 'Project F' to 2023.
UPDATE Defense_Projects SET end_year = 2023 WHERE project_name = 'Project F';
gretelai_synthetic_text_to_sql
CREATE TABLE hospitals (id INT PRIMARY KEY, name VARCHAR(255), rural BOOLEAN, num_beds INT); INSERT INTO hospitals (id, name, rural, num_beds) VALUES (1, 'Rural General Hospital', true, 50), (2, 'Urban Teaching Hospital', false, 200); CREATE TABLE medical_supplies (id INT PRIMARY KEY, hospital_id INT, name VARCHAR(255), quantity INT); INSERT INTO medical_supplies (id, hospital_id, name, quantity) VALUES (1, 1, 'Syringes', 500), (2, 1, 'Bandages', 300), (3, 2, 'Syringes', 1000), (4, 2, 'Bandages', 800);
What is the average quantity of medical supplies for rural hospitals?
SELECT AVG(m.quantity) FROM medical_supplies m INNER JOIN hospitals h ON m.hospital_id = h.id WHERE h.rural = true;
gretelai_synthetic_text_to_sql
CREATE TABLE r_and_d_expenditure_2021 (expenditure_id INT, drug_name VARCHAR(255), expenditure_date DATE, amount DECIMAL(10,2)); INSERT INTO r_and_d_expenditure_2021 (expenditure_id, drug_name, expenditure_date, amount) VALUES (1, 'DrugP', '2021-01-01', 12000), (2, 'DrugQ', '2021-01-02', 15000), (3, 'DrugR', '2021-01-03', 18000), (4, 'DrugP', '2021-01-04', 13000), (5, 'DrugQ', '2021-01-05', 16000), (6, 'DrugR', '2021-01-06', 19000);
What is the total R&D expenditure for each drug, ranked by the highest R&D expenditure first, for the year 2021?
SELECT drug_name, SUM(amount) as total_rd_expenditure FROM r_and_d_expenditure_2021 WHERE YEAR(expenditure_date) = 2021 GROUP BY drug_name ORDER BY total_rd_expenditure DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE transaction (transaction_id INT, sector VARCHAR(255), transaction_value DECIMAL(10,2), transaction_date DATE); INSERT INTO transaction (transaction_id, sector, transaction_value, transaction_date) VALUES (1, 'retail', 100.00, '2022-07-01'), (2, 'retail', 150.00, '2022-08-01');
What is the average transaction value in the retail sector in Q3 2022?
SELECT AVG(transaction_value) FROM transaction WHERE sector = 'retail' AND transaction_date BETWEEN '2022-07-01' AND '2022-09-30';
gretelai_synthetic_text_to_sql
CREATE TABLE exam_results (student_id INT, subject_area VARCHAR(50), passed BOOLEAN, exam_date DATE); INSERT INTO exam_results (student_id, subject_area, passed, exam_date) VALUES (1, 'Mathematics', true, '2021-12-01'), (2, 'Mathematics', false, '2021-11-01'), (3, 'Science', true, '2022-02-01'), (4, 'Science', false, '2021-09-01');
How many students have passed the exam in each subject area in the last academic year?
SELECT subject_area, COUNT(student_id) as num_students_passed FROM exam_results WHERE exam_date >= DATEADD(year, -1, CURRENT_TIMESTAMP) AND passed = true GROUP BY subject_area;
gretelai_synthetic_text_to_sql
CREATE TABLE if not exists salaries4 (id INT, industry TEXT, region TEXT, salary REAL);INSERT INTO salaries4 (id, industry, region, salary) VALUES (1, 'manufacturing', 'east', 50000), (2, 'retail', 'west', 60000), (3, 'manufacturing', 'east', 55000);
What is the average salary in the 'east' region?
SELECT AVG(salary) FROM salaries4 WHERE region = 'east';
gretelai_synthetic_text_to_sql
CREATE TABLE sales (sale_date DATE, salesperson VARCHAR(255), revenue FLOAT);
What is the average revenue per salesperson in Q1 2022?
SELECT salesperson, AVG(revenue) AS avg_revenue FROM sales WHERE sale_date BETWEEN '2022-01-01' AND '2022-03-31' GROUP BY salesperson;
gretelai_synthetic_text_to_sql
CREATE TABLE VeganMaterialsBrands (brand_name TEXT, revenue INT); INSERT INTO VeganMaterialsBrands (brand_name, revenue) VALUES ('Brand1', 1000), ('Brand2', 1500), ('Brand3', 2000), ('Brand4', 2500), ('Brand5', 3000);
What is the total revenue generated by brands that use vegan materials?
SELECT SUM(revenue) as total_revenue FROM VeganMaterialsBrands WHERE brand_name IN (SELECT brand_name FROM Materials WHERE material_type = 'vegan');
gretelai_synthetic_text_to_sql
CREATE TABLE volunteers (id INT, region VARCHAR(50), volunteer_type VARCHAR(50), registration_date DATE); INSERT INTO volunteers (id, region, volunteer_type, registration_date) VALUES (1, 'North', 'Disaster Response', '2019-12-20'), (2, 'South', 'Disaster Response', '2019-11-15'), (3, 'East', 'Disaster Response', '2020-01-03');
How many disaster response volunteers were there in each region as of January 1, 2020?
SELECT region, volunteer_type, COUNT(*) as total_volunteers FROM volunteers WHERE volunteer_type = 'Disaster Response' AND registration_date <= '2020-01-01' GROUP BY region, volunteer_type;
gretelai_synthetic_text_to_sql
CREATE TABLE EmployeeTraining2 (EmployeeID INT, Manager VARCHAR(50), TrainingType VARCHAR(50), CompletionDate DATE);
What is the number of employees who have completed training on unconscious bias, by manager?
SELECT Manager, COUNT(*) as Num_Employees FROM EmployeeTraining2 WHERE TrainingType = 'Unconscious Bias' GROUP BY Manager;
gretelai_synthetic_text_to_sql
CREATE TABLE Beneficiaries (BeneficiaryID INT, BeneficiaryName VARCHAR(50), Disability BOOLEAN, Initiative VARCHAR(50), Year INT, Region VARCHAR(50)); INSERT INTO Beneficiaries VALUES (1, 'Benef1', true, 'Initiative1', 2019, 'Central America'), (2, 'Benef2', true, 'Initiative2', 2020, 'Central America'), (3, 'Benef3', false, 'Initiative3', 2021, 'Central America'), (4, 'Benef4', true, 'Initiative4', 2020, 'Central America'), (5, 'Benef5', true, 'Initiative5', 2021, 'Central America');
How many people with disabilities have benefited from technology for social good in Central America in the last 3 years?
SELECT SUM(Disability) FROM Beneficiaries WHERE Region = 'Central America' AND Year BETWEEN 2019 AND 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE ErbiumMarketPrices (quarter VARCHAR(10), year INT, price DECIMAL(5,2)); INSERT INTO ErbiumMarketPrices (quarter, year, price) VALUES ('Q2', 2019, 85.00), ('Q2', 2019, 87.50), ('Q2', 2020, 90.00), ('Q2', 2020, 92.50), ('Q2', 2021, 95.00), ('Q2', 2021, 97.50);
What was the average market price of Erbium for the second quarter of each year from 2019 to 2021?
SELECT AVG(price) FROM ErbiumMarketPrices WHERE year IN (2019, 2020, 2021) AND quarter = 'Q2';
gretelai_synthetic_text_to_sql
CREATE TABLE market_trends (id INT, price DECIMAL(10,2), date DATE);
Insert a new record into the 'market_trends' table for a new crude oil price of $80 per barrel
INSERT INTO market_trends (id, price, date) VALUES (1, 80, CURDATE());
gretelai_synthetic_text_to_sql
CREATE TABLE HeritageSites (SiteID int, SiteName text); INSERT INTO HeritageSites (SiteID, SiteName) VALUES (1, 'Eiffel Tower'), (2, 'Mont Saint-Michel'), (3, 'Alhambra'); CREATE TABLE ArtHeritage (ArtID int, HeritageID int); INSERT INTO ArtHeritage (ArtID, HeritageID) VALUES (1, 1), (2, 2), (3, 3);
What are the heritage sites that do not have any associated artists?
SELECT HS.SiteName FROM HeritageSites HS LEFT JOIN ArtHeritage AH ON HS.SiteID = AH.HeritageID WHERE AH.HeritageID IS NULL;
gretelai_synthetic_text_to_sql
CREATE SCHEMA city; CREATE TABLE city.buses (id INT, fare DECIMAL); INSERT INTO city.buses (id, fare) VALUES (1, 2.50), (2, 1.75), (3, 3.00);
What is the minimum fare for buses in the 'city' schema, excluding fares greater than $3?
SELECT MIN(fare) FROM city.buses WHERE fare < 3;
gretelai_synthetic_text_to_sql
CREATE TABLE vessels (vessel_id INT, vessel_type VARCHAR(50)); CREATE TABLE containers (container_id INT, container_weight INT, vessel_id INT, shipped_date DATE); INSERT INTO vessels VALUES (1, 'Container Ship'); INSERT INTO vessels VALUES (2, 'Bulk Carrier'); INSERT INTO containers VALUES (1, 10, 1, '2022-03-01'); INSERT INTO containers VALUES (2, 15, 2, '2022-02-15'); INSERT INTO containers VALUES (3, 20, 1, '2022-01-10');
What is the total cargo weight transported by each vessel type in the last month, and what is the average weight per container for those shipments?
SELECT vessels.vessel_type, SUM(containers.container_weight) as total_weight, AVG(containers.container_weight) as avg_weight_per_container FROM vessels INNER JOIN containers ON vessels.vessel_id = containers.vessel_id WHERE containers.shipped_date > DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) GROUP BY vessels.vessel_type;
gretelai_synthetic_text_to_sql
CREATE TABLE diversity (company_id INT, underrepresented_minority BOOLEAN); INSERT INTO diversity (company_id, underrepresented_minority) VALUES (1, true); INSERT INTO diversity (company_id, underrepresented_minority) VALUES (2, false);
What is the average investment amount per round for companies founded by underrepresented minorities?
SELECT AVG(raised_amount) as avg_investment_per_round FROM investments JOIN diversity ON investments.company_id = diversity.company_id WHERE diversity.underrepresented_minority = true;
gretelai_synthetic_text_to_sql
CREATE TABLE attorneys (id INT, name VARCHAR(50), department VARCHAR(20), billable_hours DECIMAL(5,2)); INSERT INTO attorneys (id, name, department, billable_hours) VALUES (1, 'John Doe', 'criminal', 120.50); INSERT INTO attorneys (id, name, department, billable_hours) VALUES (2, 'Jane Smith', 'criminal', 150.75);
Select the average billable hours for attorneys in the 'criminal' department
SELECT AVG(billable_hours) FROM attorneys WHERE department = 'criminal';
gretelai_synthetic_text_to_sql
CREATE TABLE FundingSources (funding_source VARCHAR(50), amount INT, year INT); INSERT INTO FundingSources (funding_source, amount, year) VALUES ('Government Grant', 50000, 2022); INSERT INTO FundingSources (funding_source, amount, year) VALUES ('Private Donor', 25000, 2022); INSERT INTO FundingSources (funding_source, amount, year) VALUES ('Corporate Sponsor', 75000, 2022); INSERT INTO FundingSources (funding_source, amount, year) VALUES ('Youth Arts Initiative', 100000, 2022);
What is the total funding received by 'Youth Arts Initiative' in 2022?
SELECT SUM(amount) FROM FundingSources WHERE funding_source = 'Youth Arts Initiative' AND year = 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE satellite_image (id INT, field_id INT, image_url TEXT, anomaly BOOLEAN, timestamp TIMESTAMP);
Insert new records into the satellite image table for the past month with no anomalies.
INSERT INTO satellite_image (field_id, image_url, anomaly, timestamp) SELECT f.id, 'https://example.com/image.jpg', false, s.timestamp FROM field f CROSS JOIN generate_series(NOW() - INTERVAL '1 month', NOW(), INTERVAL '1 day') s(timestamp);
gretelai_synthetic_text_to_sql
CREATE TABLE production_costs (item_type VARCHAR(20), collection VARCHAR(20), cost NUMERIC(10,2)); INSERT INTO production_costs (item_type, collection, cost) VALUES ('cotton t-shirt', 'spring 2021', 15.99), ('cotton t-shirt', 'spring 2021', 17.49), ('cotton t-shirt', 'spring 2021', 16.99);
What is the average production cost of cotton t-shirts in the 'spring 2021' collection?
SELECT AVG(cost) FROM production_costs WHERE item_type = 'cotton t-shirt' AND collection = 'spring 2021';
gretelai_synthetic_text_to_sql
CREATE TABLE WeatherData (temp FLOAT, time DATETIME, crop VARCHAR(255));
What is the average temperature recorded for each crop type in the past month, grouped by day?
SELECT crop, DATE(time) as day, AVG(temp) FROM WeatherData WHERE time > DATE_SUB(CURRENT_TIMESTAMP(), INTERVAL 1 MONTH) GROUP BY crop, day;
gretelai_synthetic_text_to_sql
CREATE TABLE hotel_tech_adoption (hotel_id INT, hotel_region TEXT); INSERT INTO hotel_tech_adoption (hotel_id, hotel_region) VALUES (1, 'Asia'), (2, 'Europe'), (3, 'Asia'), (4, 'North America');
How many hotels in the 'hotel_tech_adoption' table are located in the 'Asia' region?
SELECT COUNT(*) FROM hotel_tech_adoption WHERE hotel_region = 'Asia';
gretelai_synthetic_text_to_sql
CREATE TABLE electric_vehicles (id INT, city VARCHAR(50), range FLOAT, timestamp TIMESTAMP);
What is the maximum range of electric vehicles in Seoul and Shanghai?
SELECT city, MAX(range) FROM electric_vehicles WHERE city IN ('Seoul', 'Shanghai') GROUP BY city;
gretelai_synthetic_text_to_sql
CREATE TABLE produce_suppliers (supplier_id INT, name VARCHAR(50), local BOOLEAN); CREATE TABLE produce_purchases (purchase_id INT, supplier_id INT, cost DECIMAL(10,2)); INSERT INTO produce_suppliers (supplier_id, name, local) VALUES (1, 'Farm Fresh', true), (2, 'Green Fields', false), (3, 'Local Harvest', true); INSERT INTO produce_purchases (purchase_id, supplier_id, cost) VALUES (1, 1, 50.00), (2, 1, 75.00), (3, 3, 60.00);
What is the total cost of produce sourced from local farms?
SELECT SUM(cost) FROM produce_purchases JOIN produce_suppliers ON produce_purchases.supplier_id = produce_suppliers.supplier_id WHERE produce_suppliers.local = true;
gretelai_synthetic_text_to_sql
CREATE TABLE Space_Missions (Mission VARCHAR(50), Duration INT, Launch_Date DATE); INSERT INTO Space_Missions (Mission, Duration, Launch_Date) VALUES ('Mission1', 123, '2021-01-01'), ('Mission2', 456, '2021-02-01'), ('Mission3', 789, '2021-03-01');
Determine the number of space missions launched per year, ranked by the number in descending order.
SELECT DATE_PART('year', Launch_Date) as Year, COUNT(*) as Mission_Count FROM Space_Missions GROUP BY Year ORDER BY Mission_Count DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE HighwayProjectsIL (State TEXT, Year INTEGER, ProjectType TEXT, NumberOfLanes INTEGER); INSERT INTO HighwayProjectsIL (State, Year, ProjectType, NumberOfLanes) VALUES ('Illinois', 2020, 'Highway', 4), ('Illinois', 2020, 'Highway', 6), ('Illinois', 2020, 'Highway', 8), ('Illinois', 2020, 'Highway', 10);
What was the maximum and minimum number of lanes for each type of highway project in Illinois in 2020?
SELECT ProjectType, MIN(NumberOfLanes) as MinLanes, MAX(NumberOfLanes) as MaxLanes FROM HighwayProjectsIL WHERE State = 'Illinois' AND Year = 2020 GROUP BY ProjectType;
gretelai_synthetic_text_to_sql
CREATE TABLE middle_east_patients (patient_id INT, therapy VARCHAR(20), condition VARCHAR(20)); INSERT INTO middle_east_patients (patient_id, therapy, condition) VALUES (1, 'Psychodynamic Therapy', 'Anxiety'), (2, 'CBT', 'Anxiety'), (3, 'DBT', 'Anxiety'), (4, 'NA', 'Depression'), (5, 'Psychodynamic Therapy', 'Anxiety');
What is the most common therapy approach used in the Middle East for patients with anxiety?
SELECT therapy, COUNT(*) AS count FROM middle_east_patients WHERE condition = 'Anxiety' GROUP BY therapy ORDER BY count DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE Donations (DonationID INT, DonationRegion TEXT, DonationAmount DECIMAL(10,2)); INSERT INTO Donations (DonationID, DonationRegion, DonationAmount) VALUES (1, 'Asia', 1000.00), (2, 'Africa', 1500.00), (3, 'Europe', 2000.00), (4, 'Asia', 500.00), (5, 'Africa', 800.00), (6, 'Europe', 1200.00);
What is the average donation amount per region, ordered by the highest amount?
SELECT AVG(DonationAmount) AS AvgDonation, DonationRegion FROM Donations GROUP BY DonationRegion ORDER BY AvgDonation DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE EquipmentMaintenance (id INT, type VARCHAR(255), cost FLOAT, date DATE);
Display the average monthly maintenance cost for each equipment type in the 'EquipmentMaintenance' table
SELECT type, AVG(cost) as avg_monthly_cost FROM EquipmentMaintenance WHERE date >= '2021-01-01' AND date <= '2021-12-31' GROUP BY type;
gretelai_synthetic_text_to_sql
CREATE TABLE intel_ops (op VARCHAR(255)); INSERT INTO intel_ops (op) VALUES ('communications_surveillance'), ('communications_jamming'), ('decoy'), ('interception'), ('analysis');
What are the intelligence operations with 'communications' in their name in the 'intel_ops' table?
SELECT op FROM intel_ops WHERE op LIKE '%communications%';
gretelai_synthetic_text_to_sql
CREATE TABLE teachers (teacher_id INT, teacher_name TEXT); INSERT INTO teachers (teacher_id, teacher_name) VALUES (1, 'Alice Johnson'), (2, 'Bob Smith'); CREATE TABLE workshops (workshop_id INT, year INT, hours_spent INT, teacher_id INT); INSERT INTO workshops (workshop_id, year, hours_spent, teacher_id) VALUES (1, 2022, 3, 2), (2, 2022, 4, 2), (3, 2022, 5, 3);
Who are the teachers who have not led any professional development workshops?
SELECT teacher_name FROM teachers WHERE teacher_id NOT IN (SELECT teacher_id FROM workshops);
gretelai_synthetic_text_to_sql
CREATE TABLE GeopoliticalRiskFactors (id INT PRIMARY KEY, equipment VARCHAR(50), risk_level VARCHAR(50)); INSERT INTO GeopoliticalRiskFactors (id, equipment, risk_level) VALUES (4, 'Patriot', 'High'); INSERT INTO EquipmentSales (id, contractor, equipment, sale_date, sale_amount) VALUES (6, 'Lockheed Martin', 'Javelin', '2021-02-01', 70000000);
What is the sale amount and contractor name for each equipment type with a high geopolitical risk level?
SELECT EquipmentSales.equipment, EquipmentSales.sale_amount, EquipmentSales.contractor FROM EquipmentSales INNER JOIN GeopoliticalRiskFactors ON EquipmentSales.equipment = GeopoliticalRiskFactors.equipment WHERE GeopoliticalRiskFactors.risk_level = 'High';
gretelai_synthetic_text_to_sql
CREATE TABLE Concerts (id INT, city VARCHAR(50), concert_date DATE, revenue DECIMAL(10,2));
What's the total revenue for concerts in Q1 2022, grouped by city?
SELECT city, SUM(revenue) FROM Concerts WHERE concert_date >= '2022-01-01' AND concert_date < '2022-04-01' GROUP BY city;
gretelai_synthetic_text_to_sql
CREATE TABLE grants (id INT, faculty_id INT, title VARCHAR(100), amount DECIMAL(10, 2)); INSERT INTO grants (id, faculty_id, title, amount) VALUES (1, 1, 'Research Grant 1', 50000), (2, 2, 'Research Grant 2', 75000), (3, 3, 'Research Grant 3', 80000); CREATE TABLE faculty (id INT, name VARCHAR(50), department VARCHAR(50)); INSERT INTO faculty (id, name, department) VALUES (1, 'Fiona', 'Natural Sciences'), (2, 'Gabriel', 'Computer Science'), (3, 'Heidi', 'Humanities');
What is the total number of research grants awarded to faculty members in the Natural Sciences department?
SELECT SUM(g.amount) FROM grants g JOIN faculty f ON g.faculty_id = f.id WHERE f.department = 'Natural Sciences';
gretelai_synthetic_text_to_sql
CREATE TABLE Safety_Testing (Vehicle_ID INT, Manufacturer VARCHAR(30), Model VARCHAR(20), Safety_Rating FLOAT);
What is the average safety rating of vehicles by 'Honda' in the Safety_Testing table?
SELECT AVG(Safety_Rating) FROM Safety_Testing WHERE Manufacturer = 'Honda';
gretelai_synthetic_text_to_sql
CREATE TABLE news (title VARCHAR(255), author VARCHAR(255), word_count INT, category VARCHAR(255)); INSERT INTO news (title, author, word_count, category) VALUES ('Sample News', 'James Brown', 800, 'International');
What is the minimum word count for articles in the 'international' category?
SELECT MIN(word_count) FROM news WHERE category = 'International';
gretelai_synthetic_text_to_sql
CREATE TABLE mobile_customers (customer_id INT, network_type VARCHAR(10)); INSERT INTO mobile_customers (customer_id, network_type) VALUES (1, '5G'), (2, '4G'), (3, '5G');
What is the percentage of mobile customers using 5G in the European region?
SELECT (COUNT(*) * 100.0 / (SELECT COUNT(*) FROM mobile_customers)) FROM mobile_customers WHERE network_type = '5G' AND country IN ('Germany', 'France', 'United Kingdom');
gretelai_synthetic_text_to_sql
CREATE TABLE marine_species (name varchar(255), region varchar(255), observations int); INSERT INTO marine_species (name, region, observations) VALUES ('Polar Bear', 'Arctic', 2500), ('Walrus', 'Arctic', 1200), ('Arctic Fox', 'Arctic', 800);
What is the total number of marine species observed in the Arctic region?
SELECT SUM(observations) FROM marine_species WHERE region = 'Arctic';
gretelai_synthetic_text_to_sql
CREATE TABLE transactions (transaction_id INT, transaction_date DATE, transaction_currency VARCHAR(3), transaction_amount DECIMAL(10,2));
What is the maximum transaction amount in GBP by day for the month of February 2022?
SELECT DATE(transaction_date) as transaction_day, MAX(transaction_amount) as maximum_transaction_amount FROM transactions WHERE transaction_date BETWEEN '2022-02-01' AND '2022-02-28' AND transaction_currency = 'GBP' GROUP BY transaction_day;
gretelai_synthetic_text_to_sql
CREATE TABLE waste_production (id INT, company TEXT, location TEXT, waste_amount FLOAT); INSERT INTO waste_production (id, company, location, waste_amount) VALUES (1, 'Michigan Mining Co', 'Michigan', 1500);
What is the total amount of waste produced by the mining sector in the state of Michigan?
SELECT SUM(waste_amount) FROM waste_production WHERE location = 'Michigan';
gretelai_synthetic_text_to_sql
CREATE TABLE Volunteers (VolunteerID int, VolunteerName varchar(50), ProgramID int, Hours decimal(10,2), VolunteerDate date); CREATE TABLE Programs (ProgramID int, ProgramName varchar(50), ProgramCategory varchar(50));
Which volunteers have contributed the most hours to the 'Environment' program in 2021?
SELECT VolunteerName, SUM(Hours) as TotalHours FROM Volunteers INNER JOIN Programs ON Volunteers.ProgramID = Programs.ProgramID WHERE ProgramName = 'Environment' AND YEAR(VolunteerDate) = 2021 GROUP BY VolunteerName ORDER BY TotalHours DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE volunteer_events (id INT, event_name TEXT, year INT, num_volunteers INT); INSERT INTO volunteer_events (id, event_name, year, num_volunteers) VALUES (1, 'Youth Mentoring Program', 2020, 120), (2, 'Feeding the Homeless', 2020, 180), (3, 'Climate Action Rally', 2020, 90);
Which community outreach events in '2020' had more than 100 volunteers?
SELECT event_name FROM volunteer_events WHERE year = 2020 AND num_volunteers > 100;
gretelai_synthetic_text_to_sql
CREATE TABLE defense_projects(id INT, project_name VARCHAR(50), start_date DATE, end_date DATE, status VARCHAR(20));
What is the total number of defense projects in Africa and their average duration?
SELECT 'Africa' AS continent, AVG(DATEDIFF(end_date, start_date)) AS avg_duration, COUNT(*) AS total_projects FROM defense_projects WHERE country IN (SELECT country FROM countries WHERE region = 'Africa');
gretelai_synthetic_text_to_sql
CREATE TABLE habitat (id INT, area FLOAT, status VARCHAR(20));
Delete all records from the habitat table where the status is not 'Protected'
DELETE FROM habitat WHERE status != 'Protected';
gretelai_synthetic_text_to_sql
CREATE TABLE spacecraft (id INT PRIMARY KEY, name VARCHAR(50), engine VARCHAR(50), status VARCHAR(10));
Get all spacecraft engines that are not decommissioned
SELECT engine FROM spacecraft WHERE status <> 'decommissioned';
gretelai_synthetic_text_to_sql
CREATE TABLE Programs (program_id INT, target_group VARCHAR(50), funding_amount DECIMAL(10,2), funding_date DATE); INSERT INTO Programs (program_id, target_group, funding_amount, funding_date) VALUES (1, 'youth', 5000.00, '2021-01-01'), (2, 'seniors', 7000.00, '2021-02-01'), (3, 'adults', 3000.00, '2021-03-01');
What was the total funding received by programs targeting 'youth'?
SELECT SUM(funding_amount) AS total_funding FROM Programs WHERE target_group = 'youth';
gretelai_synthetic_text_to_sql
CREATE TABLE OrganicFruitsPrices (fruit_name TEXT, country TEXT, price NUMERIC); INSERT INTO OrganicFruitsPrices (fruit_name, country, price) VALUES ('Apples', 'United States', 2.95);
What is the average retail price of organic apples sold in the United States?
SELECT AVG(price) FROM OrganicFruitsPrices WHERE fruit_name = 'Apples' AND country = 'United States';
gretelai_synthetic_text_to_sql
CREATE TABLE mars_missions (id INT, name VARCHAR(50), launch_date DATE, number_of_launches INT, success VARCHAR(50));
What is the minimum number of launches required for a successful Mars mission?
SELECT MIN(number_of_launches) FROM mars_missions WHERE success = 'Yes';
gretelai_synthetic_text_to_sql
CREATE TABLE DonorHistory (DonorID INT, Amount DECIMAL(10,2), FirstDonation DATE); INSERT INTO DonorHistory (DonorID, Amount, FirstDonation) VALUES (1, 500.00, '2021-04-15'), (2, 300.00, '2021-03-01'), (3, 250.00, '2021-05-05');
What is the total amount donated by new donors in the month of May 2021?
SELECT SUM(Amount) FROM DonorHistory INNER JOIN (SELECT DonorID FROM DonorHistory GROUP BY DonorID HAVING MIN(FirstDonation) >= '2021-05-01') AS NewDonors ON DonorHistory.DonorID = NewDonors.DonorID;
gretelai_synthetic_text_to_sql
CREATE TABLE fish_cages (id INT, farm_id INT, cage_number INT, fish_count INT); INSERT INTO fish_cages (id, farm_id, cage_number, fish_count) VALUES (1, 5, 1, 2000); INSERT INTO fish_cages (id, farm_id, cage_number, fish_count) VALUES (2, 5, 2, 3000); INSERT INTO fish_cages (id, farm_id, cage_number, fish_count) VALUES (3, 5, 3, 4000);
How many fish are there in each cage at the Canadian fish farm 'Farm Z'?
SELECT cage_number, fish_count FROM fish_cages WHERE farm_id = (SELECT id FROM fish_farms WHERE name = 'Farm Z' AND country = 'Canada' LIMIT 1);
gretelai_synthetic_text_to_sql
CREATE TABLE EmergencyCalls (id INT, region VARCHAR(20), response_time INT, date DATE);
What is the maximum response time for emergency calls in the "north" region in the last week?
SELECT MAX(response_time) FROM EmergencyCalls WHERE region = 'north' AND date >= DATE_SUB(CURDATE(), INTERVAL 1 WEEK);
gretelai_synthetic_text_to_sql
CREATE TABLE clients (client_id INT PRIMARY KEY, created_date DATE);
Find the number of new clients per week for the past 3 months
SELECT DATE_FORMAT(created_date, '%Y-%u') AS week, COUNT(DISTINCT client_id) FROM clients WHERE created_date >= DATE_SUB(NOW(), INTERVAL 3 MONTH) GROUP BY week;
gretelai_synthetic_text_to_sql
CREATE TABLE adaptation_projects (region VARCHAR(20), num_projects INT); INSERT INTO adaptation_projects (region, num_projects) VALUES ('americas', 10), ('europe', 7), ('africa', 5);
What is the total number of climate adaptation projects in the 'africa' region?
SELECT region, SUM(num_projects) FROM adaptation_projects WHERE region = 'africa' GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE farmer (id INT PRIMARY KEY, name VARCHAR(50), crop_id INT, country_id INT); CREATE TABLE crop (id INT PRIMARY KEY, name VARCHAR(50)); CREATE TABLE country (id INT PRIMARY KEY, name VARCHAR(50)); INSERT INTO crop (id, name) VALUES (1, 'Cassava'); INSERT INTO country (id, name) VALUES (1, 'Nigeria'), (2, 'Ghana'); INSERT INTO farmer (id, name, crop_id, country_id) VALUES (1, 'John Doe', 1, 1), (2, 'Jane Doe', 2, 2);
List all farmers who cultivate 'Cassava' and their corresponding countries.
SELECT f.name, c.name AS country_name FROM farmer f INNER JOIN crop c ON f.crop_id = c.id INNER JOIN country co ON f.country_id = co.id WHERE c.name = 'Cassava';
gretelai_synthetic_text_to_sql
CREATE TABLE safety_records (id INT, product_id INT, sourcing_country TEXT, incidents INT); INSERT INTO safety_records (id, product_id, sourcing_country, incidents) VALUES (1, 1, 'France', 2), (2, 2, 'Canada', 0), (3, 3, 'Germany', 1);
How many product safety incidents were reported for products sourced from France?
SELECT COUNT(*) FROM safety_records WHERE sourcing_country = 'France';
gretelai_synthetic_text_to_sql
CREATE TABLE agriculture_workers (id INT, name TEXT, sector TEXT, union_member BOOLEAN);
Calculate the percentage of union workers and non-union workers in the 'agriculture' sector.
SELECT CASE WHEN union_member THEN 'Union' ELSE 'Non-Union' END as worker_type, ROUND(COUNT(*) * 100.0 / (SELECT COUNT(*) FROM agriculture_workers), 2) as percentage FROM agriculture_workers WHERE sector = 'agriculture' GROUP BY union_member;
gretelai_synthetic_text_to_sql
CREATE TABLE contractor_timeline (id INT, contractor_name VARCHAR(50), project_id INT, start_date DATE, end_date DATE); INSERT INTO contractor_timeline (id, contractor_name, project_id, start_date, end_date) VALUES (1, 'Smith Construction', 1, '2022-01-01', '2022-06-01');
What is the average project timeline in months for contractors, and how many projects did they complete?
SELECT contractor_name, AVG(DATEDIFF(end_date, start_date)/30) as avg_timeline, COUNT(*) as num_projects FROM contractor_timeline GROUP BY contractor_name;
gretelai_synthetic_text_to_sql
CREATE TABLE News (news_id INT, title VARCHAR(255), publication_date DATE, author VARCHAR(255), independent_author BOOLEAN); INSERT INTO News (news_id, title, publication_date, author, independent_author) VALUES (1, 'News1', '2021-01-01', 'Author1', TRUE), (2, 'News2', '2021-02-10', 'Author2', FALSE), (3, 'News3', '2021-03-20', 'Author3', TRUE);
What is the total number of articles published by independent authors in the last year?
SELECT SUM(independent_author) FROM News WHERE independent_author = TRUE AND publication_date >= DATE_SUB(CURDATE(), INTERVAL 1 YEAR);
gretelai_synthetic_text_to_sql
CREATE TABLE startups (name TEXT, funding FLOAT); INSERT INTO startups (name, funding) VALUES ('StartupA', 5000000), ('StartupB', 7000000), ('StartupC', 6000000);
What is the maximum funding received by a biotech startup?
SELECT MAX(funding) FROM startups;
gretelai_synthetic_text_to_sql
CREATE TABLE if not exists continent (id INT, continent VARCHAR(20)); INSERT INTO continent (id, continent) VALUES (1, 'Africa'), (2, 'Asia'), (3, 'Europe'), (4, 'North America'), (5, 'South America'), (6, 'Oceania'); CREATE TABLE if not exists trips (id INT, trip_id INT, continent_id INT, duration INT);
What is the average trip duration for each continent?
SELECT c.continent, AVG(t.duration) FROM trips t JOIN continent c ON t.continent_id = c.id GROUP BY c.continent;
gretelai_synthetic_text_to_sql
CREATE TABLE MilitaryInnovation (Year INT, Funding FLOAT); INSERT INTO MilitaryInnovation (Year, Funding) VALUES (2015, 12000000);
What was the total military innovation funding in 2015?
SELECT Funding FROM MilitaryInnovation WHERE Year = 2015;
gretelai_synthetic_text_to_sql
CREATE TABLE trends_by_region (id INT PRIMARY KEY, region VARCHAR(255), trend_name VARCHAR(255), popularity_score INT);
Show the average popularity score for each region in 'trends_by_region' table
SELECT region, AVG(popularity_score) FROM trends_by_region GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE startup (id INT, name VARCHAR(100), industry VARCHAR(50), founder_native_american VARCHAR(3), funding FLOAT); INSERT INTO startup VALUES (1, 'StartupA', 'Agriculture', 'Yes', 1000000); INSERT INTO startup VALUES (2, 'StartupB', 'Tech', 'No', 7000000); INSERT INTO startup VALUES (3, 'StartupC', 'Agriculture', 'Yes', 1200000);
What is the total funding amount for startups founded by individuals who identify as Native American in the agriculture sector?
SELECT SUM(funding) FROM startup WHERE founder_native_american = 'Yes' AND industry = 'Agriculture';
gretelai_synthetic_text_to_sql
CREATE TABLE Claims (Claim_Amount NUMERIC, City TEXT); INSERT INTO Claims (Claim_Amount, City) VALUES (2500, 'New York'), (3000, 'Los Angeles'), (2000, 'San Francisco'), (1500, 'New York');
What is the maximum claim amount for each city?
SELECT City, MAX(Claim_Amount) FROM Claims GROUP BY City;
gretelai_synthetic_text_to_sql
CREATE TABLE mobile_subscribers (subscriber_id int, data_usage float, city varchar(20), subscription_type varchar(10)); INSERT INTO mobile_subscribers (subscriber_id, data_usage, city, subscription_type) VALUES (1, 3000, 'Seattle', 'postpaid'), (2, 4000, 'New York', 'postpaid'), (3, 2500, 'Seattle', 'prepaid'); CREATE TABLE network_towers (tower_id int, city varchar(20)); INSERT INTO network_towers (tower_id, city) VALUES (1, 'Seattle'), (2, 'New York'), (3, 'Chicago');
List the top 5 cities with the highest average monthly data usage for prepaid mobile customers.
SELECT city, AVG(data_usage) FROM mobile_subscribers WHERE subscription_type = 'prepaid' GROUP BY city ORDER BY AVG(data_usage) DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE ota (ota_id INT, ota_name TEXT, region TEXT, virtual_tour TEXT, engagements INT); INSERT INTO ota (ota_id, ota_name, region, virtual_tour, engagements) VALUES (1, 'TravelEase', 'Asia', 'yes', 10000), (2, 'VoyagePlus', 'Europe', 'yes', 12000), (3, 'ExploreNow', 'Asia', 'no', 8000);
Which online travel agencies (OTAs) have the highest number of virtual tour engagements in Asia?
SELECT ota_name, MAX(engagements) FROM ota WHERE region = 'Asia' AND virtual_tour = 'yes' GROUP BY ota_name
gretelai_synthetic_text_to_sql
CREATE TABLE financial_capability (id INT, name VARCHAR(20), score INT); INSERT INTO financial_capability (id, name, score) VALUES (1, 'JohnDoe', 70), (2, 'JaneDoe', 85), (3, 'MikeSmith', 90);
Update the financial capability score of 'JohnDoe' to 80 in the 'financial_capability' table.
UPDATE financial_capability SET score = 80 WHERE name = 'JohnDoe';
gretelai_synthetic_text_to_sql
CREATE TABLE renewable_energy_world (plant_id INT, location VARCHAR(100), capacity FLOAT); INSERT INTO renewable_energy_world VALUES (1, 'USA', 500), (2, 'Canada', 700), (3, 'Mexico', 600), (4, 'Brazil', 800), (5, 'India', 900);
What is the total installed capacity of renewable energy in the world?
SELECT SUM(capacity) as total_capacity FROM renewable_energy_world;
gretelai_synthetic_text_to_sql
CREATE TABLE travel_advisories (id INT, country TEXT, region TEXT, advisory TEXT, date DATE);
Insert a new travel advisory for Mexico into the travel_advisories table.
INSERT INTO travel_advisories (country, advisory) VALUES ('Mexico', 'Exercise caution due to increased crime rates.');
gretelai_synthetic_text_to_sql
CREATE TABLE employees (id INT, name VARCHAR(50), department VARCHAR(50)); INSERT INTO employees (id, name, department) VALUES (1, 'John Doe', 'manufacturing'), (2, 'Jane Smith', 'engineering'), (3, 'Alice Johnson', 'manufacturing');
Find the total number of employees in the "manufacturing" department
SELECT COUNT(*) FROM employees WHERE department = 'manufacturing';
gretelai_synthetic_text_to_sql
CREATE TABLE events (id INT, name TEXT, category TEXT, price DECIMAL(5,2), city TEXT); INSERT INTO events (id, name, category, price, city) VALUES (1, 'Concert', 'music', 50.00, 'New York'), (2, 'Jazz Festival', 'music', 35.00, 'Chicago'), (3, 'Rock Concert', 'music', 60.00, 'Los Angeles');
What is the average ticket price for events in the 'music' category, sorted by city?
SELECT city, AVG(price) as avg_price FROM events WHERE category = 'music' GROUP BY city ORDER BY avg_price;
gretelai_synthetic_text_to_sql
CREATE TABLE emergency_incidents_fl (id INT, city VARCHAR(255), incident_type VARCHAR(255), reported_date DATE);
What is the total number of emergency incidents reported in each city in the state of Florida by type?
SELECT city, incident_type, COUNT(*) as total_incidents FROM emergency_incidents_fl GROUP BY city, incident_type;
gretelai_synthetic_text_to_sql
CREATE TABLE products (product_id INT, is_circular BOOLEAN, country VARCHAR(20), quantity INT); INSERT INTO products (product_id, is_circular, country, quantity) VALUES (1, true, 'Developing', 10), (2, false, 'Developed', 20), (3, true, 'Developing', 30);
What is the minimum quantity of a product that is part of a circular supply chain and is produced in a developing country?
SELECT MIN(products.quantity) FROM products WHERE products.is_circular = true AND products.country = 'Developing';
gretelai_synthetic_text_to_sql
CREATE TABLE TV_Shows (show_id INT PRIMARY KEY, name VARCHAR(100), genre VARCHAR(50), release_year INT, seasons INT); INSERT INTO TV_Shows (show_id, name, genre, release_year, seasons) VALUES (1, 'Friends', 'Comedy', 1994, 10), (2, 'The Witcher', 'Fantasy', 2019, 1);
Delete the TV show 'Friends' from the 'TV_Shows' table if it has less than 6 seasons.
DELETE FROM TV_Shows WHERE name = 'Friends' AND seasons < 6;
gretelai_synthetic_text_to_sql
CREATE TABLE shipment (shipment_id VARCHAR(10), status VARCHAR(20), warehouse_id VARCHAR(10), carrier_name VARCHAR(30), shipped_date DATE);
Get the status and count of shipments for each warehouse_id from the shipment table grouped by status and warehouse_id
SELECT status, warehouse_id, COUNT(*) as count FROM shipment GROUP BY status, warehouse_id;
gretelai_synthetic_text_to_sql
CREATE TABLE fans (name VARCHAR(50), city VARCHAR(30), tickets_purchased INT); INSERT INTO fans (name, city, tickets_purchased) VALUES ('Alice', 'New York', 5), ('Bob', 'Los Angeles', 3);
What is the minimum and maximum number of tickets purchased by fans in the 'fans' table for each city?
SELECT city, MIN(tickets_purchased) AS min_tickets, MAX(tickets_purchased) AS max_tickets FROM fans GROUP BY city;
gretelai_synthetic_text_to_sql
CREATE TABLE community_development (id INT, region VARCHAR(255), gender VARCHAR(255), initiative_count INT, year INT); INSERT INTO community_development (id, region, gender, initiative_count, year) VALUES (1, 'Latin America', 'Female', 250, 2021), (2, 'Latin America', 'Male', 180, 2021), (3, 'Africa', 'Female', 300, 2021);
Number of community development initiatives, by region and gender, for the year 2021?
SELECT region, gender, SUM(initiative_count) as total_initiative_count FROM community_development WHERE year = 2021 GROUP BY region, gender;
gretelai_synthetic_text_to_sql
CREATE TABLE WindFarms (id INT, country VARCHAR(20), capacity FLOAT); INSERT INTO WindFarms (id, country, capacity) VALUES (1, 'Germany', 6.2), (2, 'Germany', 4.8), (3, 'Spain', 5.5);
How many wind farms are there in Germany with a capacity greater than 5 MW?
SELECT COUNT(*) FROM WindFarms WHERE country = 'Germany' AND capacity > 5;
gretelai_synthetic_text_to_sql
CREATE TABLE green_buildings (project_name VARCHAR(50), country VARCHAR(50), renewable_energy_source VARCHAR(50)); INSERT INTO green_buildings (project_name, country, renewable_energy_source) VALUES ('ProjectD', 'US', 'Solar');
Update the renewable energy source for 'ProjectD' in the US to 'Geothermal'.
UPDATE green_buildings SET renewable_energy_source = 'Geothermal' WHERE project_name = 'ProjectD' AND country = 'US';
gretelai_synthetic_text_to_sql
CREATE TABLE SpaceDebris (id INT PRIMARY KEY, name VARCHAR(255), type VARCHAR(255), mass FLOAT, orbit_date DATE);
What is the total mass of space debris in orbit around Earth?
SELECT SUM(mass) as total_mass FROM SpaceDebris WHERE orbit_date = (SELECT MAX(orbit_date) FROM SpaceDebris);
gretelai_synthetic_text_to_sql
CREATE TABLE Games (GameID INT, Title VARCHAR(50), Genre VARCHAR(20), Platform VARCHAR(10)); CREATE TABLE VRGames (GameID INT, Designer VARCHAR(50)); INSERT INTO Games (GameID, Title, Genre, Platform) VALUES (1, 'CyberSphere', 'Action', 'PC'); INSERT INTO VRGames (GameID, Designer) VALUES (1, 'John Doe');
List all virtual reality (VR) games and their designers.
SELECT Games.Title, VRGames.Designer FROM Games INNER JOIN VRGames ON Games.GameID = VRGames.GameID WHERE Games.Platform = 'VR';
gretelai_synthetic_text_to_sql
CREATE TABLE sales (id INT, restaurant_id INT, sale_date DATE, sales DECIMAL(10,2)); CREATE VIEW day_sales AS SELECT restaurant_id, EXTRACT(DOW FROM sale_date) as day_of_week, SUM(sales) as total_sales FROM sales GROUP BY restaurant_id, day_of_week;
What is the revenue by day of the week for all restaurants?
SELECT d.day_of_week, SUM(ds.total_sales) as total_sales FROM day_sales ds JOIN day_sales d ON ds.day_of_week = d.day_of_week GROUP BY d.day_of_week;
gretelai_synthetic_text_to_sql