context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE hotel_reviews (id INT PRIMARY KEY, hotel_name VARCHAR(50), user_rating FLOAT, review_date DATE, hotel_location VARCHAR(50), virtual_tour_engagements INT); INSERT INTO hotel_reviews (id, hotel_name, user_rating, review_date, hotel_location, virtual_tour_engagements) VALUES (1, 'Urban Retreat', 4.6, '2022-03...
What is the average rating of hotels in urban areas with more than 3 virtual tour engagements?
SELECT hotel_location, AVG(user_rating) FROM hotel_reviews WHERE virtual_tour_engagements > 3 GROUP BY hotel_location HAVING COUNT(*) > 1;
gretelai_synthetic_text_to_sql
CREATE TABLE cargo (id INT, type VARCHAR(20), origin VARCHAR(20), destination VARCHAR(20), weight FLOAT); INSERT INTO cargo (id, type, origin, destination, weight) VALUES (1, 'Containers', 'China', 'USA', 1000.0); INSERT INTO cargo (id, type, origin, destination, weight) VALUES (2, 'Dangerous Goods', 'China', 'Japan', ...
Delete records in the 'cargo' table where the type is 'General Cargo' and the origin is 'Brazil'
DELETE FROM cargo WHERE type = 'General Cargo' AND origin = 'Brazil';
gretelai_synthetic_text_to_sql
CREATE TABLE art_pieces (piece_id INT, artist_name VARCHAR(50), artist_gender VARCHAR(10), artist_ethnicity VARCHAR(20), movement VARCHAR(20)); INSERT INTO art_pieces (piece_id, artist_name, artist_gender, artist_ethnicity, movement) VALUES (1, 'Claude Monet', 'Male', 'French', 'Impressionism'); INSERT INTO art_pieces ...
How many art pieces were created by female artists from the 'Impressionism' movement?
SELECT COUNT(*) FROM art_pieces WHERE artist_gender = 'Female' AND movement = 'Impressionism';
gretelai_synthetic_text_to_sql
CREATE TABLE ei_scores (plant_id INT, score FLOAT); INSERT INTO ei_scores (plant_id, score) VALUES (1, 87.3), (2, 78.9), (3, 91.5), (4, 65.2), (5, 85.6), (6, 94.1); CREATE TABLE plants (id INT, name TEXT, location TEXT, PRIMARY KEY (id)); INSERT INTO plants (id, name, location) VALUES (1, 'PlantA', 'DE'), (2, 'PlantB',...
What is the maximum environmental impact score for chemical manufacturing plants in the EU?
SELECT MAX(score) FROM ei_scores INNER JOIN plants ON ei_scores.plant_id = plants.id WHERE location LIKE 'EU%';
gretelai_synthetic_text_to_sql
CREATE TABLE manufacturers (manufacturer_id INT, manufacturer_name VARCHAR(255));CREATE TABLE garments (garment_id INT, garment_name VARCHAR(255), manufacturer_id INT, price DECIMAL(10,2), is_organic BOOLEAN);
What is the average price of organic cotton garments per manufacturer?
SELECT m.manufacturer_name, AVG(g.price) AS avg_price FROM garments g JOIN manufacturers m ON g.manufacturer_id = m.manufacturer_id WHERE g.is_organic = TRUE GROUP BY m.manufacturer_name;
gretelai_synthetic_text_to_sql
CREATE TABLE recycling_rates (country VARCHAR(255), recycling_rate FLOAT); INSERT INTO recycling_rates (country, recycling_rate) VALUES ('Germany', 66.1);
What is the recycling rate in Germany?
SELECT recycling_rate FROM recycling_rates WHERE country = 'Germany';
gretelai_synthetic_text_to_sql
CREATE TABLE field_start_date (field VARCHAR(50), start_date DATE); INSERT INTO field_start_date (field, start_date) VALUES ('Ekofisk', '2015-01-01'); INSERT INTO field_start_date (field, start_date) VALUES ('Statfjord', '2016-01-01'); INSERT INTO field_start_date (field, start_date) VALUES ('Gullfaks', '2017-01-01'); ...
List the fields that started production after 2015
SELECT field FROM field_start_date WHERE start_date > '2015-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE Dispensaries (id INT, name TEXT, state TEXT);CREATE TABLE Products (id INT, dispensary_id INT, thc_content DECIMAL);
What is the average THC content of products sold by each dispensary in Alaska?
SELECT D.name, AVG(P.thc_content) FROM Dispensaries D JOIN Products P ON D.id = P.dispensary_id WHERE D.state = 'Alaska' GROUP BY D.id;
gretelai_synthetic_text_to_sql
CREATE TABLE missions (mission_name VARCHAR(255), mission_director VARCHAR(255), total_cost DECIMAL(10,2)); INSERT INTO missions (mission_name, mission_director, total_cost) VALUES ('Mission1', 'Dir1', 150000.00), ('Mission2', 'Dir2', 200000.00), ('Mission3', 'Dir3', 120000.00), ('Mission4', 'Dir1', 180000.00), ('Missi...
Who are the mission directors that have overseen missions with a total cost greater than $200,000?
SELECT DISTINCT mission_director FROM missions WHERE total_cost > 200000.00;
gretelai_synthetic_text_to_sql
CREATE TABLE defense_projects(project_id INT, project_name VARCHAR(50), duration INT, cost FLOAT); INSERT INTO defense_projects VALUES (1, 'Project A', 36, 5000000), (2, 'Project B', 24, 4000000), (3, 'Project C', 18, 3000000);
What is the total cost of defense projects with a duration greater than 24 months?
SELECT SUM(cost) FROM defense_projects WHERE duration > 24;
gretelai_synthetic_text_to_sql
CREATE TABLE Machine_Production (Machine_ID INT, Production_Date DATE, Production_Rate INT); INSERT INTO Machine_Production (Machine_ID, Production_Date, Production_Rate) VALUES (1, '2022-01-01', 50), (1, '2022-01-02', 55), (2, '2022-01-01', 60), (2, '2022-01-03', 65);
What was the average production rate per machine for the month of January 2022?
SELECT AVG(Production_Rate) FROM (SELECT Production_Rate, ROW_NUMBER() OVER(PARTITION BY Machine_ID ORDER BY Production_Date) as rn FROM Machine_Production WHERE Production_Date >= '2022-01-01' AND Production_Date < '2022-02-01' AND Machine_ID IN (1,2)) tmp WHERE rn = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE if not exists bus_fares (id INT, city VARCHAR(20), avg_fare DECIMAL(3,2)); INSERT INTO bus_fares (id, city, avg_fare) VALUES (1, 'Rio de Janeiro', 2.20), (2, 'Sao Paulo', 2.50);
Delete the record for the bus fare in Rio de Janeiro
DELETE FROM bus_fares WHERE city = 'Rio de Janeiro';
gretelai_synthetic_text_to_sql
CREATE TABLE yearly_dives (year INT, depth FLOAT); INSERT INTO yearly_dives (year, depth) VALUES (2017, 6500), (2018, 6600), (2019, 6700), (2020, 6800), (2021, 6900);
What was the minimum deep-sea exploration depth by year?
SELECT year, MIN(depth) FROM yearly_dives;
gretelai_synthetic_text_to_sql
CREATE SCHEMA if not exists biotech;CREATE TABLE if not exists biotech.genetic_research(id INT, name STRING, location STRING);INSERT INTO biotech.genetic_research(id, name, location) VALUES (1, 'InstituteA', 'Germany'), (2, 'InstituteB', 'US'), (3, 'InstituteC', 'UK');
List the names and locations of genetic research institutions in Germany.
SELECT name, location FROM biotech.genetic_research WHERE location = 'Germany';
gretelai_synthetic_text_to_sql
CREATE TABLE companies (company_id INT, company_name VARCHAR(255), state VARCHAR(255));CREATE TABLE patents (patent_id INT, company_id INT, filed_date DATE);
Display the number of patents filed by companies in each state
SELECT c.state, COUNT(c.company_id) FROM companies c INNER JOIN patents p ON c.company_id = p.company_id GROUP BY c.state;
gretelai_synthetic_text_to_sql
CREATE TABLE ProductionData (year INT, element TEXT, production INT); INSERT INTO ProductionData (year, element, production) VALUES (2017, 'Lanthanum', 1000); INSERT INTO ProductionData (year, element, production) VALUES (2018, 'Lanthanum', 1500); INSERT INTO ProductionData (year, element, production) VALUES (2019, 'La...
Find the total production of Lanthanum and Yttrium for each year?
SELECT year, SUM(production) as total_production FROM ProductionData WHERE element IN ('Lanthanum', 'Yttrium') GROUP BY year;
gretelai_synthetic_text_to_sql
CREATE TABLE ocean_trenches (name TEXT, average_depth REAL); INSERT INTO ocean_trenches (name, average_depth) VALUES ('Mariana Trench', 10994), ('Tonga Trench', 10820), ('Kuril-Kamchatka Trench', 10542), ('Philippine Trench', 10540), ('Kermadec Trench', 10047);
What is the average depth of all oceanic trenches?
SELECT AVG(average_depth) FROM ocean_trenches;
gretelai_synthetic_text_to_sql
CREATE TABLE pollution_control (initiative_id INT, ocean TEXT); INSERT INTO pollution_control (initiative_id, ocean) VALUES (1, 'North Pacific'), (2, 'South Atlantic'), (3, 'Indian Ocean'), (4, 'North Pacific'), (5, 'Arctic Ocean');
How many pollution control initiatives are present in the North Pacific Ocean?
SELECT COUNT(*) FROM pollution_control WHERE ocean = 'North Pacific';
gretelai_synthetic_text_to_sql
CREATE TABLE companies (id INT, name TEXT, founder_country TEXT, is_active BOOLEAN);
What is the success rate of startups founded by people from each country?
SELECT founder_country, 100.0 * AVG(CASE WHEN is_active THEN 1.0 ELSE 0.0 END) as success_rate FROM companies GROUP BY founder_country;
gretelai_synthetic_text_to_sql
CREATE TABLE financial_products (bank VARCHAR(50), product VARCHAR(50), apr FLOAT); INSERT INTO financial_products (bank, product, apr) VALUES ('Al-Rahman Bank', 'Home Mortgage', 4.5), ('Al-Rahman Bank', 'Car Loan', 6.0), ('Al-Rahman Bank', 'Personal Loan', 7.5);
List all the financial products offered by Al-Rahman Bank with their corresponding annual percentage rates.
SELECT bank, product, apr FROM financial_products WHERE bank = 'Al-Rahman Bank';
gretelai_synthetic_text_to_sql
CREATE TABLE Sensors (SensorID varchar(5), SensorName varchar(10), LastDataSent timestamp); INSERT INTO Sensors (SensorID, SensorName, LastDataSent) VALUES ('1', 'Sensor 1', '2022-06-22 12:30:00'), ('2', 'Sensor 2', '2022-06-25 16:45:00'), ('3', 'Sensor 3', '2022-06-28 09:10:00');
Find the number of sensors that have not sent data in the past week and the number of sensors that have sent data in the past week.
SELECT COUNT(*) FROM (SELECT SensorName FROM Sensors WHERE LastDataSent < NOW() - INTERVAL '7 days' UNION SELECT SensorName FROM Sensors WHERE LastDataSent > NOW() - INTERVAL '7 days') AS Subquery;
gretelai_synthetic_text_to_sql
CREATE TABLE patents_monthly (id INT, year INT, month INT, granted BOOLEAN); INSERT INTO patents_monthly (id, year, month, granted) VALUES (1, 2015, 1, TRUE), (2, 2016, 2, TRUE), (3, 2017, 3, FALSE), (4, 2018, 4, TRUE), (5, 2019, 5, FALSE), (6, 2020, 6, TRUE);
How many legal technology patents were granted per month in 2019?
SELECT p.year, p.month, COUNT(p.id) AS total_patents FROM patents_monthly p WHERE p.granted = TRUE AND p.year = 2019 GROUP BY p.year, p.month;
gretelai_synthetic_text_to_sql
CREATE TABLE treatment_plants (id INT PRIMARY KEY, name VARCHAR(255), capacity INT, plant_type VARCHAR(255)); CREATE TABLE wastewater (id INT PRIMARY KEY, treatment_plant_id INT, volume_treated FLOAT, treatment_date DATE);
What is the average volume of wastewater treated per day in 2022, for treatment plants with a capacity of over 1,000,000 liters?
SELECT AVG(w.volume_treated/DATEDIFF('2022-12-31', '2022-01-01')) as avg_daily_volume_treated FROM treatment_plants t JOIN wastewater w ON t.id = w.treatment_plant_id WHERE t.capacity > 1000000;
gretelai_synthetic_text_to_sql
CREATE TABLE Studios (studio_id INT, studio_name VARCHAR(255), country VARCHAR(255)); INSERT INTO Studios (studio_id, studio_name, country) VALUES (1, 'Studio G', 'USA'), (2, 'Studio H', 'USA'), (3, 'Studio I', 'Canada'); CREATE TABLE Movies (movie_id INT, movie_name VARCHAR(255), studio_id INT, release_year INT); INSE...
How many movies were released by each studio in 2020 and 2021?
SELECT s.studio_name, COUNT(*) as movies_in_2020_and_2021 FROM Studios s JOIN Movies t ON s.studio_id = t.studio_id WHERE t.release_year IN (2020, 2021) GROUP BY s.studio_id, s.studio_name;
gretelai_synthetic_text_to_sql
CREATE TABLE MetroStations (station VARCHAR(20), num_escalators INT, num_elevators INT); INSERT INTO MetroStations (station, num_escalators, num_elevators) VALUES ('Station A', 5, 2), ('Station B', 3, 3), ('Station C', 6, 1);
find the total number of escalators and elevators in each metro station
SELECT station, SUM(num_escalators + num_elevators) as total FROM MetroStations GROUP BY station;
gretelai_synthetic_text_to_sql
CREATE TABLE rainfall (country VARCHAR(20), rainfall INT); INSERT INTO rainfall VALUES ('Kenya', 800), ('Kenya', 900), ('Ethiopia', 1200), ('Ethiopia', 1100);
What is the average rainfall in Kenya and Ethiopia?
SELECT AVG(rainfall) FROM rainfall WHERE country = 'Kenya' UNION SELECT AVG(rainfall) FROM rainfall WHERE country = 'Ethiopia'
gretelai_synthetic_text_to_sql
CREATE TABLE clients (client_id INT, name TEXT, dob DATE, branch TEXT);CREATE TABLE accounts (account_id INT, client_id INT, account_type TEXT, balance DECIMAL);INSERT INTO clients VALUES (8, 'Sophia Taylor', '1992-08-30', 'Chicago');INSERT INTO accounts VALUES (108, 8, 'Checking', 4000);
What is the standard deviation of balance for clients with checking accounts in the Chicago branch?
SELECT STDEV(accounts.balance) FROM clients INNER JOIN accounts ON clients.client_id = accounts.client_id WHERE accounts.account_type = 'Checking' AND clients.branch = 'Chicago';
gretelai_synthetic_text_to_sql
CREATE TABLE ZipCodes (ZipCodeID INT, ZipCode VARCHAR(255)); CREATE TABLE AmbulanceDispatches (DispatchID INT, DispatchType VARCHAR(255), ZipCodeID INT, DispatchDate DATE, DispatchTime INT);
Find the total number of ambulance dispatches and the average response time for ambulance services in each zip code area over the last three months.
SELECT ZipCode, COUNT(DispatchID) as TotalDispatches, AVG(DispatchTime) as AvgResponseTime FROM AmbulanceDispatches d JOIN ZipCodes z ON d.ZipCodeID = z.ZipCodeID WHERE d.DispatchDate >= DATEADD(month, -3, GETDATE()) AND d.DispatchType = 'Ambulance' GROUP BY ZipCode;
gretelai_synthetic_text_to_sql
CREATE TABLE climate_finance_projects (project_id INT, project_name VARCHAR(255), allocation DECIMAL(10,2), year INT, month INT); INSERT INTO climate_finance_projects (project_id, project_name, allocation, year, month) VALUES (1, 'Green Bond Issue', 10000000, 2021, 1), (2, 'Carbon Tax Implementation', 7000000, 2021, 2)...
What is the average allocation for climate finance projects in the first half of 2021?
SELECT AVG(allocation) FROM climate_finance_projects WHERE year = 2021 AND month BETWEEN 1 AND 6;
gretelai_synthetic_text_to_sql
CREATE TABLE employees (id INT, name VARCHAR(50), team VARCHAR(50), salary FLOAT); INSERT INTO employees (id, name, team, salary) VALUES (1, 'Alice', 'Ethical AI', 70000.00), (2, 'Bob', 'Data Science', 75000.00), (3, 'Charlie', 'Ethical AI', 72000.00);
What is the average salary of developers in the Ethical AI team?
SELECT AVG(salary) FROM employees WHERE team = 'Ethical AI' AND position = 'Developer';
gretelai_synthetic_text_to_sql
CREATE TABLE media_content (id INT, title VARCHAR(255), release_year INT, runtime INT, genre VARCHAR(255), format VARCHAR(50), country VARCHAR(255), director VARCHAR(255));
What is the total runtime of movies and TV shows in the 'Action' genre, and how many unique directors are there?
SELECT genre, SUM(runtime) AS total_runtime, COUNT(DISTINCT director) AS unique_directors FROM media_content WHERE genre = 'Action' GROUP BY genre;
gretelai_synthetic_text_to_sql
CREATE TABLE waste_generation (city VARCHAR(20), year INT, daily_waste_generation FLOAT);INSERT INTO waste_generation (city, year, daily_waste_generation) VALUES ('San Francisco', 2019, 3.2), ('San Francisco', 2020, 3.5), ('San Francisco', 2021, 3.7), ('Oakland', 2019, 2.8), ('Oakland', 2020, 3.1), ('Oakland', 2021, 3....
Determine the total waste generation for the year 2020 for all cities
SELECT SUM(daily_waste_generation * 365) FROM waste_generation WHERE year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE company_scores (id INT, company VARCHAR(255), esg_score FLOAT, year INT); INSERT INTO company_scores (id, company, esg_score, year) VALUES (15, 'Sustainable Futures', 88, 2021); INSERT INTO company_scores (id, company, esg_score, year) VALUES (16, 'Sustainable Futures', 92, 2020);
Find the average ESG score for 'Sustainable Futures' in 2021.
SELECT AVG(esg_score) FROM company_scores WHERE company = 'Sustainable Futures' AND year = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE climate_finance_initiatives (id INT PRIMARY KEY, name VARCHAR(50), location VARCHAR(50), budget DECIMAL(10,2));CREATE VIEW v_middle_east_north_africa_finance_initiatives AS SELECT cfi.name, cfi.location, cfi.budget FROM climate_finance_initiatives cfi WHERE cfi.location LIKE 'Middle East%' OR cfi.location ...
List the top 3 climate finance initiatives with the highest budget in the Middle East and North Africa, ordered by budget.
SELECT * FROM v_middle_east_north_africa_finance_initiatives ORDER BY budget DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE CityPerformances (City VARCHAR(20), ArtPerformance VARCHAR(30), Performances INT); INSERT INTO CityPerformances VALUES ('Portland', 'Hula', 2), ('Portland', 'Flamenco', 3), ('Seattle', 'Bharatanatyam', 1); CREATE VIEW ArtPerformanceCount AS SELECT City, ArtPerformance, COUNT(*) AS Performances FROM CityPer...
Show the name and number of art performances in each city.
SELECT v.City, v.ArtPerformance, v.Performances FROM CityPerformances c JOIN ArtPerformanceCount v ON c.City = v.City AND c.ArtPerformance = v.ArtPerformance;
gretelai_synthetic_text_to_sql
CREATE TABLE Languages (LanguageID int, LanguageName text, Status text); INSERT INTO Languages (LanguageID, LanguageName, Status) VALUES (1, 'Quechua', 'Endangered'), (2, 'Spanish', 'Safe'), (3, 'Mandarin', 'Safe');
How many languages in the database are considered endangered?
SELECT COUNT(*) FROM Languages WHERE Status = 'Endangered';
gretelai_synthetic_text_to_sql
CREATE TABLE green_buildings (building_id INT, city VARCHAR(255), energy_consumption FLOAT);
What is the total energy consumption of green buildings in the 'green_buildings' table?
SELECT SUM(energy_consumption) FROM green_buildings WHERE city IN (SELECT city FROM (SELECT DISTINCT city FROM green_buildings) AS unique_cities);
gretelai_synthetic_text_to_sql
CREATE TABLE project_timeline (project_id INT, state VARCHAR(2), type VARCHAR(20), timeline INT); INSERT INTO project_timeline (project_id, state, type, timeline) VALUES (1, 'CA', 'Green', 365);
What is the average project timeline for green building projects in California?
SELECT AVG(timeline) FROM project_timeline WHERE state = 'CA' AND type = 'Green';
gretelai_synthetic_text_to_sql
CREATE TABLE water_conservation(household_id INT, state VARCHAR(50), score INT, year INT); INSERT INTO water_conservation(household_id, state, score, year) VALUES (1, 'Florida', 85, 2020), (2, 'Florida', 90, 2020);
What is the average water conservation score for households in the state of Florida for the year 2020?
SELECT AVG(score) FROM water_conservation WHERE state = 'Florida' AND year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_region (id INT, region_name VARCHAR(50), min_ocean_ph FLOAT, max_ocean_ph FLOAT); INSERT INTO marine_region (id, region_name, min_ocean_ph, max_ocean_ph) VALUES (1, 'Atlantic Ocean', 7.5, 8.1), (2, 'Pacific Ocean', 7.6, 8.2);
Add a new record for the 'Indian Ocean' to the 'marine_region' table.
INSERT INTO marine_region (region_name, min_ocean_ph, max_ocean_ph) VALUES ('Indian Ocean', 7.4, 8.3);
gretelai_synthetic_text_to_sql
CREATE TABLE missions (agency VARCHAR(255), mission_name VARCHAR(255), start_date DATE, end_date DATE); INSERT INTO missions (agency, mission_name, start_date, end_date) VALUES ('ESA', 'MarsMission1', '2012-06-18', '2015-02-03'); INSERT INTO missions (agency, mission_name, start_date, end_date) VALUES ('NASA', 'MarsMis...
What is the maximum duration of any Mars mission?
SELECT MAX(DATEDIFF(end_date, start_date)) FROM missions WHERE mission_name LIKE '%Mars%';
gretelai_synthetic_text_to_sql
CREATE TABLE rural_clinics (id INT, region VARCHAR(255), name VARCHAR(255), patient_volume INT); INSERT INTO rural_clinics (id, region, name, patient_volume) VALUES (1, 'Appalachian', 'Clinic A', 50), (2, 'Great Plains', 'Clinic B', 75), (3, 'Mississippi Delta', 'Clinic C', 100);
What is the name of the rural clinic with the lowest patient volume in the Appalachian region?
SELECT name FROM rural_clinics WHERE region = 'Appalachian' ORDER BY patient_volume ASC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE districts (id INT, district_name VARCHAR(255));CREATE TABLE emergencies (id INT, district_id INT, response_time INT);INSERT INTO districts (id, district_name) VALUES (1, 'Downtown'), (2, 'East Austin'), (3, 'West Austin');INSERT INTO emergencies (id, district_id, response_time) VALUES (1, 1, 450), (2, 1, 4...
What is the average response time for emergency calls by district in the city of Austin?
SELECT d.district_name, AVG(e.response_time) avg_response_time FROM districts d JOIN emergencies e ON d.id = e.district_id GROUP BY d.id;
gretelai_synthetic_text_to_sql
CREATE TABLE excavation_sites (id INT, name VARCHAR(255)); CREATE TABLE artifacts (id INT, excavation_site_id INT, year INT, type VARCHAR(255));
Find the earliest year an artifact was excavated from each excavation site.
SELECT es.name, MIN(a.year) as min_year FROM excavation_sites es JOIN artifacts a ON es.id = a.excavation_site_id GROUP BY es.name;
gretelai_synthetic_text_to_sql
CREATE TABLE products (id INT, name VARCHAR(255), price FLOAT, carbohydrates_grams FLOAT); INSERT INTO products (id, name, price, carbohydrates_grams) VALUES (1, 'Product M', 18.0, 25.0); INSERT INTO products (id, name, price, carbohydrates_grams) VALUES (2, 'Product N', 12.0, 30.0); INSERT INTO products (id, name, pri...
What is the average carbohydrate content for products with a price greater than 15?
SELECT AVG(carbohydrates_grams) AS avg_carbohydrates_grams FROM products WHERE price > 15;
gretelai_synthetic_text_to_sql
CREATE TABLE CommunityHealthWorkers (WorkerID INT, Age INT, Race VARCHAR(25)); INSERT INTO CommunityHealthWorkers (WorkerID, Age, Race) VALUES (1, 35, 'Hispanic'), (2, 42, 'African American'), (3, 50, 'Caucasian'); CREATE TABLE HealthEquityTraining (WorkerID INT, Completed BOOLEAN); INSERT INTO HealthEquityTraining (Wo...
How many community health workers have completed health equity training by race?
SELECT c.Race, COUNT(*) AS CompletedHealthEquityTraining FROM CommunityHealthWorkers c INNER JOIN HealthEquityTraining t ON c.WorkerID = t.WorkerID WHERE t.Completed = TRUE GROUP BY c.Race;
gretelai_synthetic_text_to_sql
CREATE TABLE scandium_production (year INT, country TEXT, production_quantity INT); INSERT INTO scandium_production (year, country, production_quantity) VALUES (2018, 'China', 1200), (2019, 'China', 1500), (2020, 'China', 1800), (2021, 'China', 2000), (2018, 'India', 800), (2019, 'India', 900), (2020, 'India', 1100), (...
What is the total production quantity of scandium in China and India for the year 2020?
SELECT SUM(production_quantity) FROM scandium_production WHERE country IN ('China', 'India') AND year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (DonorID INT, DonorName TEXT, Industry TEXT); INSERT INTO Donors (DonorID, DonorName, Industry) VALUES (1, 'John Doe', 'Technology'), (2, 'Jane Smith', 'Finance'), (3, 'Leung Li', 'Technology'), (4, 'Kim Jae', 'Retail'); CREATE TABLE Donations (DonationID INT, DonorID INT, DonationAmount INT); INSER...
What is the average donation amount made by donors in the finance industry?
SELECT AVG(DonationAmount) FROM Donations JOIN Donors ON Donations.DonorID = Donors.DonorID WHERE Donors.Industry = 'Finance';
gretelai_synthetic_text_to_sql
CREATE TABLE space_exploration (mission_name VARCHAR(50), launch_date DATE, max_speed NUMERIC(8,2)); INSERT INTO space_exploration VALUES ('Apollo 10', '1969-05-18', 39665.00), ('Mariner 2', '1962-08-27', 42800.00), ('New Horizons', '2006-01-19', 58786.00);
What is the average speed of spacecraft in the space_exploration table, ordered by their launch dates?
SELECT AVG(max_speed) OVER (ORDER BY launch_date) FROM space_exploration;
gretelai_synthetic_text_to_sql
CREATE TABLE Cooperatives(CoopID INT, CoopName VARCHAR(50));
Delete the 'Cooperatives' table
DROP TABLE Cooperatives;
gretelai_synthetic_text_to_sql
CREATE TABLE job_applications (application_id INT, name TEXT, job_title TEXT, application_date DATE); INSERT INTO job_applications (application_id, name, job_title, application_date) VALUES (1, 'Alice', 'HR Manager', '2022-01-01'), (2, 'Bob', 'Software Engineer', '2022-01-05'), (3, 'Charlie', 'Software Engineer', '2022...
What is the number of job applications received, by job title, in the last month?
SELECT job_title, COUNT(*) AS num_applications FROM job_applications WHERE application_date >= DATEADD(month, -1, GETDATE()) GROUP BY job_title;
gretelai_synthetic_text_to_sql
CREATE TABLE sales (id INT, garment_type VARCHAR(20), color VARCHAR(20), price DECIMAL(10, 2), quantity INT);
What are the top 3 best-selling garment types in terms of revenue?
SELECT garment_type, SUM(price * quantity) AS revenue FROM sales GROUP BY garment_type ORDER BY revenue DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE funding (id INT, company_id INT, amount DECIMAL(10, 2)); CREATE TABLE company (id INT, name VARCHAR(255), industry VARCHAR(255)); INSERT INTO company (id, name, industry) VALUES (1, 'Fintech Inc', 'finance'), (2, 'Startup Corp', 'tech'), (3, 'Green Inc', 'green'); INSERT INTO funding (id, company_id, amoun...
What is the average funding amount for companies in the "green" industry?
SELECT AVG(amount) FROM funding INNER JOIN company ON funding.company_id = company.id WHERE company.industry = 'green';
gretelai_synthetic_text_to_sql
CREATE TABLE menu_items (item_id INT, item_name TEXT, category TEXT, price DECIMAL(5,2));
Delete all menu items in the 'side_dishes' category
DELETE FROM menu_items WHERE category = 'side_dishes';
gretelai_synthetic_text_to_sql
CREATE TABLE marcellus_shale_gas_production (year INT, region VARCHAR(20), production_volume INT); INSERT INTO marcellus_shale_gas_production (year, region, production_volume) VALUES (2015, 'Marcellus Shale', 4000000), (2016, 'Marcellus Shale', 4500000), (2017, 'Marcellus Shale', 5000000), (2018, 'Marcellus Shale', 550...
How much natural gas was extracted from the Marcellus Shale in 2019?
SELECT production_volume FROM marcellus_shale_gas_production WHERE year = 2019 AND region = 'Marcellus Shale';
gretelai_synthetic_text_to_sql
CREATE TABLE sales (sale_id INT, product_id INT, quantity INT, non_toxic BOOLEAN); CREATE TABLE products (product_id INT, product_name VARCHAR(255), category VARCHAR(255)); INSERT INTO sales (sale_id, product_id, quantity, non_toxic) VALUES (1, 1, 100, true), (2, 2, 75, false), (3, 3, 50, true); INSERT INTO products (p...
Find the number of non-toxic skincare products that have been sold more than 100 times
SELECT COUNT(*) FROM sales JOIN products ON sales.product_id = products.product_id WHERE sales.quantity > 100 AND sales.non_toxic = true;
gretelai_synthetic_text_to_sql
CREATE TABLE conservation_status (id INT, species_name VARCHAR(50), status VARCHAR(20)); INSERT INTO conservation_status (id, species_name, status) VALUES (1, 'Green Sea Turtle', 'Least Concern'), (2, 'Clownfish', 'Least Concern'), (3, 'Bottlenose Dolphin', 'Data Deficient'), (4, 'Blue Whale', 'Critically Endangered');
List all marine species and their conservation statuses that have a conservation status of 'Critically Endangered'.
SELECT species_name, status FROM conservation_status WHERE status = 'Critically Endangered';
gretelai_synthetic_text_to_sql
CREATE SCHEMA if not exists genetics; CREATE TABLE if not exists genetics.projects (id INT, name VARCHAR(100), start_date DATE); INSERT INTO genetics.projects (id, name, start_date) VALUES (1, 'ProjectX', '2020-01-01'), (2, 'ProjectY', '2019-01-01'), (11, 'ProjectZ', '2021-01-01');
List the names of genetic research projects with an ID greater than 10 and their respective start dates.
SELECT id, name, start_date FROM genetics.projects WHERE id > 10;
gretelai_synthetic_text_to_sql
CREATE TABLE Exhibitions (id INT, city VARCHAR(20), visitors INT); CREATE TABLE VisitorExhibitions (visitor_id INT, exhibition_id INT); INSERT INTO Exhibitions (id, city, visitors) VALUES (1, 'Paris', 3000), (2, 'London', 4000), (3, 'New York', 5000); INSERT INTO VisitorExhibitions (visitor_id, exhibition_id) VALUES (1...
Find the number of unique visitors per exhibition in descending order.
SELECT e.city, COUNT(DISTINCT v.id) AS unique_visitors FROM Exhibitions e JOIN VisitorExhibitions ve ON e.id = ve.exhibition_id JOIN Visitors v ON ve.visitor_id = v.id GROUP BY e.id ORDER BY unique_visitors DESC
gretelai_synthetic_text_to_sql
CREATE TABLE Shipments(id INT, mode VARCHAR(50), source VARCHAR(50), destination VARCHAR(50), delivery_time DATE); INSERT INTO Shipments(id, mode, source, destination, delivery_time) VALUES (1, 'air', 'Egypt', 'Argentina', '2022-05-01');
List the names and delivery times of all shipments that were sent by air from Egypt to Argentina.
SELECT Shipments.mode, Shipments.source, Shipments.destination, Shipments.delivery_time FROM Shipments WHERE Shipments.mode = 'air' AND Shipments.source = 'Egypt' AND Shipments.destination = 'Argentina';
gretelai_synthetic_text_to_sql
CREATE TABLE indigenous_food_systems (system_id INT, system_name TEXT, area FLOAT); INSERT INTO indigenous_food_systems (system_id, system_name, area) VALUES (1, 'Acorn Farming', 12.5), (2, 'Maple Syrup Production', 18.7), (3, 'Bison Ranching', 25.0);
What is the maximum area (in hectares) of an indigenous food system?
SELECT MAX(area) FROM indigenous_food_systems;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_mammals (name TEXT, region TEXT); INSERT INTO marine_mammals (name, region) VALUES ('Blue Whale', 'Indian Ocean'); INSERT INTO marine_mammals (name, region) VALUES ('Dugong', 'Indian Ocean');
Which marine mammal species have been observed in the 'Indian Ocean'?'
SELECT name FROM marine_mammals WHERE region = 'Indian Ocean';
gretelai_synthetic_text_to_sql
CREATE TABLE regions (id INT, region TEXT, population INT); INSERT INTO regions (id, region, population) VALUES (1, 'Region 1', 700000), (2, 'Region 2', 850000), (3, 'Region 3', 650000); CREATE TABLE emergency_incidents (id INT, region TEXT, incident_type TEXT, incident_count INT); INSERT INTO emergency_incidents (id, ...
What is the total number of emergency incidents reported in each region, broken down by incident type, and the total population of that region?
SELECT region, incident_type, SUM(incident_count) AS total_incidents, population FROM regions r JOIN emergency_incidents e ON r.region = e.region GROUP BY region, incident_type;
gretelai_synthetic_text_to_sql
CREATE TABLE Vessels (Id INT, Name VARCHAR(50), Type VARCHAR(50), MaxSpeed DECIMAL(5,2)); INSERT INTO Vessels VALUES (1, 'VesselA', 'Cargo', 25.5), (2, 'VesselB', 'Tanker', 18.3);
Update the maximum speed of the vessel 'VesselA' to 27.5 knots.
UPDATE Vessels SET MaxSpeed = 27.5 WHERE Name = 'VesselA';
gretelai_synthetic_text_to_sql
CREATE TABLE PlayerVR (PlayerID INT, VRSessionDate DATE); INSERT INTO PlayerVR (PlayerID, VRSessionDate) VALUES (1, '2021-04-01'), (2, '2021-06-01'), (3, '2021-02-01'), (4, '2021-05-01');
Delete the records of players who have not played any VR games in the last 3 months.
DELETE FROM PlayerVR WHERE PlayerID IN (SELECT PlayerID FROM PlayerVR WHERE VRSessionDate < DATE_SUB(CURDATE(), INTERVAL 3 MONTH));
gretelai_synthetic_text_to_sql
CREATE TABLE weapons_produced (company TEXT, quantity INT, production_date DATE); INSERT INTO weapons_produced (company, quantity, production_date) VALUES ('ACME', 150, '2022-01-01'); INSERT INTO weapons_produced (company, quantity, production_date) VALUES ('ACME', 160, '2022-01-02');
What is the average quantity of weapons produced monthly by company 'ACME'?
SELECT AVG(quantity) FROM weapons_produced WHERE company = 'ACME' AND EXTRACT(MONTH FROM production_date) = EXTRACT(MONTH FROM CURRENT_DATE);
gretelai_synthetic_text_to_sql
CREATE TABLE products (product_id INT, product_name VARCHAR(255), certification VARCHAR(255));INSERT INTO products VALUES (1,'Product A','recycled'),(2,'Product B','fair_trade'),(3,'Product C','organic'),(4,'Product D','recycled'),(5,'Product E','fair_trade'),(6,'Product F','recycled, fair_trade');
What is the total quantity of products that are both 'recycled' and 'fair_trade' certified?
SELECT SUM(quantity) FROM products WHERE certification IN ('recycled', 'fair_trade') GROUP BY certification HAVING COUNT(DISTINCT certification) = 2
gretelai_synthetic_text_to_sql
CREATE TABLE autonomous_vehicles (id INT PRIMARY KEY, make VARCHAR(50), model VARCHAR(50), year INT, top_speed INT);
Find the minimum top speed of autonomous vehicles in the 'autonomous_vehicles' table
SELECT MIN(top_speed) FROM autonomous_vehicles;
gretelai_synthetic_text_to_sql
CREATE TABLE satellite_missions (id INT, mission_name VARCHAR(255), organization VARCHAR(255), cost FLOAT, duration FLOAT); INSERT INTO satellite_missions (id, mission_name, organization, cost, duration) VALUES (1, 'Sentinel-1A', 'European Space Agency', 150000000, 780), (2, 'Sentinel-1B', 'European Space Agency', 1500...
What is the total cost of satellite missions organized by each organization?
SELECT organization, SUM(cost) as total_cost FROM satellite_missions GROUP BY organization;
gretelai_synthetic_text_to_sql
CREATE TABLE product_safety_records (id INT PRIMARY KEY, product_name VARCHAR(100), safety_rating INT, inspection_date DATE); CREATE TABLE cruelty_free_certification (id INT PRIMARY KEY, product_name VARCHAR(100), certification_date DATE, certification_status VARCHAR(10)); INSERT INTO cruelty_free_certification (id, pr...
Which cruelty-free certified products have had their latest certification date within the last year?
SELECT product_name FROM cruelty_free_certification cfc INNER JOIN (SELECT product_name, MAX(certification_date) as max_certification_date FROM cruelty_free_certification WHERE certification_date >= NOW() - INTERVAL 1 YEAR GROUP BY product_name) cfc2 ON cfc.product_name = cfc2.product_name WHERE cfc.certification_statu...
gretelai_synthetic_text_to_sql
CREATE TABLE news_articles (id INT, title VARCHAR(100), section VARCHAR(50), publication_date DATE); INSERT INTO news_articles (id, title, section, publication_date) VALUES (1, 'Article 1', 'international', '2022-01-01'), (2, 'Article 2', 'national', '2022-02-01'), (3, 'Article 3', 'national', '2022-02-07'), (4, 'Artic...
How many news articles were published in the 'culture' section in the last month?
SELECT COUNT(*) FROM news_articles WHERE section = 'culture' AND publication_date >= DATE_SUB(CURDATE(), INTERVAL 1 MONTH);
gretelai_synthetic_text_to_sql
CREATE TABLE Players (PlayerID INT, Age INT, GamePlatform VARCHAR(10), Country VARCHAR(20));CREATE TABLE ESportsEvents (EventID INT, PlayerID INT);
Which countries have the highest average age of players participating in ESports events on PC platforms?
SELECT ev.Country, AVG(p.Age) as AvgAge FROM Players p INNER JOIN ESportsEvents e ON p.PlayerID = e.PlayerID WHERE p.GamePlatform = 'PC' GROUP BY ev.Country ORDER BY AvgAge DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE community_health_workers (id INT, age INT); INSERT INTO community_health_workers (id, age) VALUES (1, 35), (2, 40), (3, 30), (4, 45), (5, 50);
How many community health workers are there in total, and what is the maximum age among them?
SELECT COUNT(*) AS total_workers, MAX(age) AS max_age FROM community_health_workers;
gretelai_synthetic_text_to_sql
CREATE TABLE Buses (route_id INT, region VARCHAR(20), maintenance_frequency INT); INSERT INTO Buses (route_id, region, maintenance_frequency) VALUES (1, 'Northpoint', 45), (2, 'Northpoint', 60), (3, 'Northpoint', 75);
What is the maximum maintenance frequency for buses in the 'Northpoint' region?
SELECT MAX(maintenance_frequency) FROM Buses WHERE region = 'Northpoint';
gretelai_synthetic_text_to_sql
CREATE TABLE species_count (id INT, species_name VARCHAR, biome VARCHAR, animal_count INT);
Determine the most common animal species in the Arctic Ocean.
SELECT species_name FROM (SELECT species_name, biome, animal_count, RANK() OVER (PARTITION BY biome ORDER BY animal_count DESC) as rank FROM species_count WHERE biome = 'Ocean') as subquery WHERE rank = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE RecyclingRates (rate_id INT, quarter DATE, recycling_rate DECIMAL(5,2)); INSERT INTO RecyclingRates (rate_id, quarter, recycling_rate) VALUES (1, '2020-01-01', 0.35), (2, '2020-04-01', 0.40), (3, '2020-07-01', 0.38), (4, '2020-10-01', 0.42), (5, '2021-01-01', 0.45);
What is the average recycling rate per quarter for the last 2 years?
SELECT AVG(recycling_rate) FROM RecyclingRates WHERE quarter >= DATE_SUB('2020-01-01', INTERVAL 2 YEAR) GROUP BY QUARTER(quarter);
gretelai_synthetic_text_to_sql
CREATE TABLE company (id INT, name VARCHAR(50), industry VARCHAR(50), founding_year INT); INSERT INTO company (id, name, industry, founding_year) VALUES (1, 'Acme Inc', 'Tech', 2018), (2, 'Beta Corp', 'Finance', 2019); CREATE TABLE funding (id INT, company_id INT, amount INT); INSERT INTO funding (id, company_id, amoun...
What's the average funding amount per industry for companies founded in 2018?
SELECT industry, AVG(amount) FROM company JOIN funding ON company.id = funding.company_id WHERE founding_year = 2018 GROUP BY industry;
gretelai_synthetic_text_to_sql
CREATE TABLE Restaurants (RestaurantID INT, Name VARCHAR(50)); CREATE TABLE Menu (MenuID INT, RestaurantID INT, Item VARCHAR(50), Price DECIMAL(10,2), PreviousPrice DECIMAL(10,2));
Calculate the revenue increase or decrease for each menu item after a price change.
SELECT M.Item, CASE WHEN M.Price > M.PreviousPrice THEN 'Increase' ELSE 'Decrease' END as PriceChange, M.Price - M.PreviousPrice as PriceDifference FROM Menu M;
gretelai_synthetic_text_to_sql
CREATE TABLE streams (album_name TEXT, artist_name TEXT, streams_in_first_week INT); INSERT INTO streams (album_name, artist_name, streams_in_first_week) VALUES ('Future Nostalgia', 'Dua Lipa', 220000), ('Be', 'BTS', 300000), ('30', 'Adele', 280000);
How many streams did Dua Lipa's latest album receive in its first week?
SELECT streams_in_first_week FROM streams WHERE album_name = 'Future Nostalgia' AND artist_name = 'Dua Lipa';
gretelai_synthetic_text_to_sql
CREATE TABLE fishing_vessels (id INT, name VARCHAR(255), sea VARCHAR(255), length FLOAT); INSERT INTO fishing_vessels (id, name, sea, length) VALUES (1, 'Vessel A', 'North Pacific', 50.5); INSERT INTO fishing_vessels (id, name, sea, length) VALUES (2, 'Vessel B', 'Barents Sea', 60.3); INSERT INTO fishing_vessels (id, n...
What is the minimum length of fishing vessels in the North Pacific and Barents Seas?
SELECT MIN(length) FROM fishing_vessels WHERE sea IN ('North Pacific', 'Barents Sea');
gretelai_synthetic_text_to_sql
CREATE TABLE tv_shows (id INT, name VARCHAR(100), genre VARCHAR(50), runtime INT);
How many TV shows in the "tv_shows" table have the word "documentary" in their genre?
SELECT COUNT(*) FROM tv_shows WHERE genre LIKE '%documentary%';
gretelai_synthetic_text_to_sql
CREATE TABLE job_roles (id INT, role VARCHAR(20), sector VARCHAR(20), wage FLOAT); INSERT INTO job_roles (id, role, sector, wage) VALUES (1, 'intern', 'technology', 13.00), (2, 'developer', 'technology', 35.00), (3, 'intern', 'technology', 12.50), (4, 'manager', 'technology', 45.00);
How many 'interns' are there in the 'technology' sector, and what is the minimum wage for this group?
SELECT COUNT(*), MIN(wage) FROM job_roles WHERE role = 'intern' AND sector = 'technology';
gretelai_synthetic_text_to_sql
CREATE TABLE Pacific_Ocean (ocean_floor_location text, point_longitude numeric, point_latitude numeric, point_temperature numeric);
What is the average temperature of the ocean floor in the Pacific Ocean?
SELECT AVG(point_temperature) FROM Pacific_Ocean WHERE ocean_floor_location = 'Pacific Ocean';
gretelai_synthetic_text_to_sql
CREATE TABLE species (id INT, name VARCHAR(50), habitat_type VARCHAR(50), habitat_depth FLOAT);
Find the average depth of all marine species habitats.
SELECT AVG(habitat_depth) FROM species;
gretelai_synthetic_text_to_sql
CREATE TABLE safety_ratings (application VARCHAR(255), rating FLOAT); INSERT INTO safety_ratings (application, rating) VALUES ('App1', 0.85); INSERT INTO safety_ratings (application, rating) VALUES ('App2', 0.92); INSERT INTO safety_ratings (application, rating) VALUES ('App3', 0.78);
Which explainable AI applications have the highest safety ratings?
SELECT application, rating, RANK() OVER (ORDER BY rating DESC) as rank FROM safety_ratings WHERE rank <= 1 AND application IN (SELECT application FROM explainable_ai);
gretelai_synthetic_text_to_sql
CREATE TABLE climate_mitigation (id INT, country VARCHAR(50), year INT, efforts VARCHAR(50)); INSERT INTO climate_mitigation (id, country, year, efforts) VALUES (1, 'India', 2019, 'reforestation');
Which countries in Asia have not reported any climate mitigation efforts in the last 3 years?
SELECT country FROM climate_mitigation WHERE year >= (YEAR(CURRENT_DATE) - 3) AND efforts IS NULL GROUP BY country HAVING COUNT(*) = (YEAR(CURRENT_DATE) - 3);
gretelai_synthetic_text_to_sql
CREATE TABLE companies (id INT, sector TEXT, ESG_rating FLOAT);
Insert new company with id 4, sector 'renewable_energy', ESG 85.
INSERT INTO companies (id, sector, ESG_rating) VALUES (4, 'renewable_energy', 85);
gretelai_synthetic_text_to_sql
CREATE TABLE artists (name VARCHAR(50), genre VARCHAR(50)); INSERT INTO artists (name, genre) VALUES ('Beyoncé', 'Pop'), ('Drake', 'Hip Hop'); CREATE TABLE concerts (artist_name VARCHAR(50), venue VARCHAR(50), ticket_price DECIMAL(5,2)); INSERT INTO concerts (artist_name, venue, ticket_price) VALUES ('Beyoncé', 'Madiso...
What is the average concert ticket price for a Beyoncé concert?
SELECT AVG(ticket_price) AS avg_ticket_price FROM concerts WHERE artist_name = 'Beyoncé';
gretelai_synthetic_text_to_sql
CREATE TABLE Canada (City VARCHAR(50), Population INT, HigherEducation FLOAT); INSERT INTO Canada (City, Population, HigherEducation) VALUES ('Toronto', 29337400, 63.2), ('Montreal', 4221000, 59.1), ('Vancouver', 2632000, 60.8), ('Calgary', 1481000, 61.5), ('Edmonton', 1400000, 61.9), ('Ottawa', 1323783, 65.3), ('Quebe...
What is the percentage of the population in Canada who have completed higher education?
SELECT (SUM(HigherEducation * Population) / SUM(Population)) * 100 AS Percentage FROM Canada;
gretelai_synthetic_text_to_sql
CREATE TABLE Workers (ID INT, Age INT, Gender VARCHAR(10), Salary DECIMAL(5,2), Industry VARCHAR(20)); INSERT INTO Workers (ID, Age, Gender, Salary, Industry) VALUES (1, 42, 'Female', 50000.00, 'Textile'); INSERT INTO Workers (ID, Age, Gender, Salary, Industry) VALUES (2, 35, 'Male', 55000.00, 'Textile'); INSERT INTO W...
Update the salary of all workers in the 'Metalworking' industry who are female and under 35 years old to $70,000.
UPDATE Workers SET Salary = 70000.00 WHERE Industry = 'Metalworking' AND Gender = 'Female' AND Age < 35;
gretelai_synthetic_text_to_sql
CREATE TABLE RuralClinics (ClinicID int, ClinicName varchar(50), State varchar(2)); CREATE TABLE HealthcareProfessionals (ProfessionalID int, ProfessionalName varchar(50), ClinicID int); INSERT INTO RuralClinics (ClinicID, ClinicName, State) VALUES (1, 'Rural Clinic A', 'TX'), (2, 'Rural Clinic B', 'TX'); INSERT INTO H...
What is the total number of rural clinics and their respective healthcare professionals in Texas?
SELECT RuralClinics.State, COUNT(DISTINCT RuralClinics.ClinicID) AS ClinicCount, COUNT(DISTINCT HealthcareProfessionals.ProfessionalID) AS ProfessionalCount FROM RuralClinics JOIN HealthcareProfessionals ON RuralClinics.ClinicID = HealthcareProfessionals.ClinicID WHERE RuralClinics.State = 'TX'
gretelai_synthetic_text_to_sql
CREATE TABLE test_flights (manufacturer VARCHAR(20), test_flights INT); INSERT INTO test_flights (manufacturer, test_flights) VALUES ('Boeing', 50), ('Airbus', 40), ('Lockheed Martin', 30);
What is the number of test flights conducted by each aircraft manufacturer?
SELECT manufacturer, test_flights FROM test_flights;
gretelai_synthetic_text_to_sql
CREATE TABLE security_incidents (id INT, country VARCHAR(50), incident_count INT, incident_date DATE); INSERT INTO security_incidents (id, country, incident_count, incident_date) VALUES (1, 'USA', 25, '2022-01-01'), (2, 'Canada', 10, '2022-01-02');
What are the top 5 countries with the most security incidents in the last month?
SELECT country, SUM(incident_count) as total_incidents FROM security_incidents WHERE incident_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) GROUP BY country ORDER BY total_incidents DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE middle_east_oil_production (month INT, year INT, region VARCHAR(50), oil_production FLOAT);CREATE TABLE middle_east_gas_production (month INT, year INT, region VARCHAR(50), gas_production FLOAT); INSERT INTO middle_east_oil_production VALUES (1, 2019, 'Middle East', 13000000); INSERT INTO middle_east_oil_p...
What are the monthly production figures for oil and gas in the Middle East region for the year 2019?
SELECT month, AVG(oil_production) AS avg_oil_production, AVG(gas_production) AS avg_gas_production FROM middle_east_oil_production INNER JOIN middle_east_gas_production ON middle_east_oil_production.month = middle_east_gas_production.month WHERE middle_east_oil_production.year = 2019 AND middle_east_oil_production.regi...
gretelai_synthetic_text_to_sql
CREATE TABLE if not exists countries (country_name text); INSERT INTO countries (country_name) VALUES ('Australia');
Update the name of the country 'Australia' to 'Australia (Oceania)' in the countries table.
UPDATE countries SET country_name = 'Australia (Oceania)' WHERE country_name = 'Australia';
gretelai_synthetic_text_to_sql
CREATE TABLE shariah_finance_uae (id INT, transaction_type VARCHAR(255), transaction_amount DECIMAL(10,2)); INSERT INTO shariah_finance_uae (id, transaction_type, transaction_amount) VALUES (1, 'Murabaha', 5000.00), (2, 'Ijara', 7000.00), (3, 'Takaful', 3000.00);
What is the average transaction amount for Shariah-compliant finance in the UAE?
SELECT AVG(transaction_amount) FROM shariah_finance_uae;
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (donor_id INT, donation_amount DECIMAL, country TEXT);
What is the average donation size in Mexico?
SELECT AVG(donation_amount) FROM Donors WHERE country = 'Mexico';
gretelai_synthetic_text_to_sql
CREATE TABLE salmon_farms (id INT, name VARCHAR(50), location VARCHAR(50), water_temp DECIMAL(5,2)); INSERT INTO salmon_farms (id, name, location, water_temp) VALUES (1, 'Farm A', 'Norway', 8.5), (2, 'Farm B', 'Chile', 14.2), (3, 'Farm C', 'Scotland', 6.8);
What is the average water temperature in February for all salmon farms?
SELECT AVG(water_temp) FROM salmon_farms WHERE MONTH(location_data) = 2 AND location = 'salmon farms';
gretelai_synthetic_text_to_sql
CREATE TABLE factory_labor (factory VARCHAR(255), country VARCHAR(255), labor_cost DECIMAL(5,2)); INSERT INTO factory_labor (factory, country, labor_cost) VALUES ('Factory1', 'Vietnam', 4.00), ('Factory2', 'Vietnam', 4.50), ('Factory3', 'Vietnam', 5.00); CREATE TABLE circular_economy (factory VARCHAR(255), practice VAR...
Update the labor cost of factories in Vietnam that have not implemented circular economy practices to $5.00.
UPDATE factory_labor SET labor_cost = 5.00 WHERE country = 'Vietnam' AND factory NOT IN (SELECT factory FROM circular_economy WHERE practice = 'yes');
gretelai_synthetic_text_to_sql
CREATE TABLE Farmers(FarmerID INT, Name VARCHAR(50), Location VARCHAR(50));CREATE TABLE OrganicFruits(FruitID INT, FarmerID INT, Type VARCHAR(50), Quantity INT);INSERT INTO Farmers VALUES (1, 'John Doe', 'Pacific Northwest');INSERT INTO OrganicFruits VALUES (1, 1, 'Apple', 200), (2, 1, 'Orange', 150);
What is the total quantity of organic apples and oranges supplied by farmers in the Pacific Northwest region?
SELECT Quantity FROM OrganicFruits WHERE Type IN ('Apple', 'Orange') AND FarmerID IN (SELECT FarmerID FROM Farmers WHERE Location = 'Pacific Northwest')
gretelai_synthetic_text_to_sql