context
stringlengths 11
9.12k
| question
stringlengths 0
1.06k
| SQL
stringlengths 2
4.44k
| source
stringclasses 28
values |
|---|---|---|---|
CREATE TABLE cosmetics_sales (id INT, product VARCHAR(50), units_sold INT, revenue FLOAT, sale_date DATE); INSERT INTO cosmetics_sales (id, product, units_sold, revenue, sale_date) VALUES (1, 'Lipstick', 45, 342.75, '2021-01-01'); INSERT INTO cosmetics_sales (id, product, units_sold, revenue, sale_date) VALUES (2, 'Mascara', 34, 235.65, '2021-01-02');
|
How many units of each product were sold in the first week of 2021, grouped by product and sale date?
|
SELECT product, sale_date, SUM(units_sold) as total_units_sold FROM cosmetics_sales WHERE sale_date BETWEEN '2021-01-01' AND '2021-01-07' GROUP BY product, sale_date;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE safety_tests (id INT PRIMARY KEY, company VARCHAR(255), brand VARCHAR(255), test_location VARCHAR(255), test_date DATE, safety_rating INT);
|
Show the number of safety tests performed by each company, broken down by brand
|
SELECT company, brand, COUNT(*) as total_tests FROM safety_tests GROUP BY company, brand;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Vessels (VesselID INT, VesselName TEXT, FuelType TEXT, EngineStatus TEXT); INSERT INTO Vessels (VesselID, VesselName, FuelType, EngineStatus) VALUES (1, 'Sea Tiger', 'LNG', 'Operational'), (2, 'Ocean Wave', 'Diesel', 'Operational'), (3, 'River Queen', 'LNG', 'Operational'), (4, 'Harbor Breeze', 'Diesel', 'Operational');
|
Update the fuel type of vessels using LNG engines to 'LNG-powered' and provide a count of such vessels.
|
UPDATE Vessels SET FuelType = 'LNG-powered' WHERE FuelType = 'LNG'; SELECT COUNT(*) FROM Vessels WHERE FuelType = 'LNG-powered';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE calls (customer_id INT, call_type VARCHAR(10), call_date DATE); INSERT INTO calls (customer_id, call_type, call_date) VALUES (1, 'international', '2022-01-01'), (2, 'domestic', '2022-01-01'); CREATE TABLE customer_types (customer_id INT, plan_type VARCHAR(10)); INSERT INTO customer_types (customer_id, plan_type) VALUES (1, 'postpaid'), (2, 'prepaid'); CREATE TABLE dates (call_date DATE); INSERT INTO dates (call_date) VALUES ('2022-01-01');
|
How many customers have made international calls in the last month and how many of them are postpaid?
|
SELECT COUNT(DISTINCT c.customer_id) AS international_calls, SUM(ct.plan_type = 'postpaid') AS postpaid_international_calls FROM calls c JOIN customer_types ct ON c.customer_id = ct.customer_id JOIN dates d ON c.call_date = d.call_date WHERE c.call_date >= CURDATE() - INTERVAL 1 MONTH AND c.call_type = 'international';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE cybersecurity_budget (id INT, year INT, amount INT, country TEXT); INSERT INTO cybersecurity_budget (id, year, amount, country) VALUES (1, 2020, 5000000, 'USA'), (2, 2020, 6000000, 'Canada'), (3, 2019, 4000000, 'Mexico');
|
What is the minimum budget allocated to cybersecurity operations in the Americas?
|
SELECT MIN(amount) FROM cybersecurity_budget WHERE country IN ('USA', 'Canada', 'Mexico') AND year = 2020;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ocean_health (date DATE, location VARCHAR(255), dissolved_oxygen FLOAT);
|
What is the maximum dissolved oxygen level for each location in 2021?
|
SELECT location, MAX(dissolved_oxygen) AS max_dissolved_oxygen FROM ocean_health WHERE date BETWEEN '2021-01-01' AND '2021-12-31' GROUP BY location;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Peacekeeping_Contributions (Nation VARCHAR(50), Continent VARCHAR(50), Role VARCHAR(50), Personnel INT); INSERT INTO Peacekeeping_Contributions (Nation, Continent, Role, Personnel) VALUES ('Burkina Faso', 'Africa', 'Peacekeeper', 850), ('Egypt', 'Africa', 'Peacekeeper', 1200), ('Kenya', 'Africa', 'Peacekeeper', 950);
|
What is the average number of peacekeeping personnel contributed by each African nation?
|
SELECT AVG(Personnel) FROM Peacekeeping_Contributions WHERE Continent = 'Africa';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE sales_oceania (sale_id INT, garment_category VARCHAR(50), sale_date DATE, total_sales DECIMAL(10, 2), region VARCHAR(50));
|
What is the total sales revenue for each garment category in the Oceania region in Q3 2022?
|
SELECT garment_category, SUM(total_sales) FROM sales_oceania WHERE garment_category IN ('Tops', 'Bottoms', 'Dresses', 'Outerwear') AND sale_date BETWEEN '2022-07-01' AND '2022-09-30' AND region = 'Oceania' GROUP BY garment_category;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE brand_rating (brand VARCHAR(255), product_count INT, total_rating FLOAT); INSERT INTO brand_rating (brand, product_count, total_rating) VALUES ('Lush', 100, 460), ('The Body Shop', 75, 315), ('Sephora', 150, 570);
|
What is the average rating for each brand's products?
|
SELECT brand, (total_rating * 100.0 / (product_count * 5.0)) as avg_rating FROM brand_rating;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Chemicals (id INT, name VARCHAR(255), quantity FLOAT); CREATE TABLE Production (id INT, chemical_id INT, plant_id INT, production_date DATE);
|
What is the total quantity of a specific chemical produced at each plant in the past month?
|
SELECT Production.plant_id, Chemicals.name, SUM(Chemicals.quantity) as total_quantity FROM Chemicals INNER JOIN Production ON Chemicals.id = Production.chemical_id WHERE Chemicals.name = 'Acetone' AND Production.production_date >= DATEADD(month, -1, GETDATE()) GROUP BY Production.plant_id, Chemicals.name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE animal_population (id INT, species VARCHAR(50), population INT, endangered BOOLEAN);
|
What is the total number of animals in the animal_population table, broken down by species and endangered status, for animals that are not endangered?
|
SELECT species, endangered, SUM(population) FROM animal_population WHERE endangered = FALSE GROUP BY species, endangered;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE exploration_projects (id INT, name TEXT, location TEXT, region TEXT); INSERT INTO exploration_projects (id, name, location, region) VALUES (1, 'Project A', 'Guam Trench', 'Pacific'); INSERT INTO exploration_projects (id, name, location, region) VALUES (2, 'Project B', 'Mariana Trench', 'Pacific'); INSERT INTO exploration_projects (id, name, location, region) VALUES (3, 'Project C', 'New Hebrides Trench', 'Pacific');
|
List all countries with deep-sea exploration projects in the Pacific Ocean.
|
SELECT DISTINCT location FROM exploration_projects WHERE region = 'Pacific';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE drugs (drug_id INT, drug_name VARCHAR(255), manufacturer VARCHAR(255), approval_status VARCHAR(255), market_availability VARCHAR(255)); INSERT INTO drugs (drug_id, drug_name, manufacturer, approval_status, market_availability) VALUES (1, 'DrugX', 'ManufacturerA', 'Approved', 'Available in EU'), (2, 'DrugY', 'ManufacturerB', 'Approved', 'Not available in UK'); CREATE TABLE sales (sale_id INT, drug_id INT, sale_amount DECIMAL(10,2), sale_tax DECIMAL(10,2), country VARCHAR(255)); INSERT INTO sales (sale_id, drug_id, sale_amount, sale_tax, country) VALUES (1, 1, 0.00, 0.00, 'UK');
|
Identify drugs approved in the EU, but not yet available in the UK market.
|
SELECT d.drug_name FROM drugs d JOIN sales s ON d.drug_id = s.drug_id WHERE d.approval_status = 'Approved' AND d.market_availability = 'Available in EU' AND s.country != 'UK' GROUP BY d.drug_name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE concerts (id INT, genre VARCHAR(20), revenue DECIMAL(10, 2)); INSERT INTO concerts (id, genre, revenue) VALUES (1, 'Rock', 50000.00), (2, 'Pop', 75000.00), (3, 'Hip Hop', 60000.00), (4, 'Rock', 45000.00);
|
What is the total revenue generated from concert ticket sales by genre?
|
SELECT genre, SUM(revenue) as total_revenue FROM concerts GROUP BY genre;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE donations (id INT, country VARCHAR(50), amount FLOAT, donation_date DATE); INSERT INTO donations (id, country, amount, donation_date) VALUES (1, 'USA', 200, '2020-01-01'), (2, 'Canada', 150, '2020-01-02'), (3, 'Mexico', 75, '2020-01-03');
|
Which countries have the highest average donation amount in the last 3 years?
|
SELECT country, AVG(amount) FROM donations WHERE donation_date BETWEEN '2019-01-01' AND '2022-12-31' GROUP BY country ORDER BY AVG(amount) DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Manufacturing_Plant_A (Substance_Name VARCHAR(255), Quantity INT); INSERT INTO Manufacturing_Plant_A (Substance_Name, Quantity) VALUES ('Ethanol', 500), ('Methanol', 300), ('Propanol', 200);
|
What are the names and quantities of all chemical substances produced by the 'Manufacturing Plant A'?
|
SELECT Substance_Name, Quantity FROM Manufacturing_Plant_A;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE TextileEmployees (EmployeeID INT, Company VARCHAR(50), Country VARCHAR(50), Industry VARCHAR(50)); INSERT INTO TextileEmployees (EmployeeID, Company, Country, Industry) VALUES (1, 'Company A', 'Bangladesh', 'Textile'), (2, 'Company B', 'India', 'Textile'), (3, 'Company C', 'China', 'Textile');
|
What is the total number of employees in the textile industry by country?
|
SELECT Country, COUNT(*) as TotalEmployees FROM TextileEmployees WHERE Industry = 'Textile' GROUP BY Country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Garments(id INT, category VARCHAR(20), retail_price DECIMAL(5,2)); INSERT INTO Garments(id, category, retail_price) VALUES (1, 'Vintage_Styles', 100.00), (2, 'Vintage_Styles', 150.00);
|
What is the maximum retail price for garments in the 'Vintage_Styles' category?
|
SELECT MAX(retail_price) FROM Garments WHERE category = 'Vintage_Styles';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE fabric_usage (id INT, supplier VARCHAR(50), fabric_type VARCHAR(50), quantity INT, sustainability_rating INT); INSERT INTO fabric_usage (id, supplier, fabric_type, quantity, sustainability_rating) VALUES (1, 'Supplier1', 'Cotton', 500, 80); INSERT INTO fabric_usage (id, supplier, fabric_type, quantity, sustainability_rating) VALUES (2, 'Supplier2', 'Polyester', 300, 50); INSERT INTO fabric_usage (id, supplier, fabric_type, quantity, sustainability_rating) VALUES (3, 'Supplier1', 'Hemp', 700, 90);
|
Get the total quantity of unsustainable fabrics used
|
SELECT SUM(quantity) FROM fabric_usage WHERE sustainability_rating < 80;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ocean_floors(name VARCHAR(255), depth INT);INSERT INTO ocean_floors(name, depth) VALUES ('Mariana Trench', 36070), ('Puerto Rico Trench', 8648);
|
What is the average depth of the Mariana Trench and the Puerto Rico Trench?
|
SELECT AVG(depth) FROM ocean_floors WHERE name IN ('Mariana Trench', 'Puerto Rico Trench');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE international_tourists (id INT, continent VARCHAR(50), country VARCHAR(50), visitors INT, co2_emission INT, visit_date DATE); INSERT INTO international_tourists (id, continent, country, visitors, co2_emission, visit_date) VALUES (1, 'Europe', 'France', 3000, 1500, '2022-01-01'); INSERT INTO international_tourists (id, continent, country, visitors, co2_emission, visit_date) VALUES (2, 'Europe', 'France', 2500, 1400, '2021-01-01');
|
What was the change in CO2 emissions per continent between 2021 and 2022?
|
SELECT a.continent, (a.co2_emission - b.co2_emission) as co2_emission_change FROM international_tourists a INNER JOIN international_tourists b ON a.continent = b.continent WHERE a.visit_date = '2022-01-01' AND b.visit_date = '2021-01-01';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE carbon_prices (id INT, country VARCHAR(50), price FLOAT, start_date DATE, end_date DATE); INSERT INTO carbon_prices (id, country, price, start_date, end_date) VALUES (1, 'Japan', 20.0, '2023-01-01', '2023-12-31'); INSERT INTO carbon_prices (id, country, price, start_date, end_date) VALUES (2, 'India', 15.5, '2023-01-01', '2023-12-31');
|
What is the carbon price for Japan and India on January 1, 2023?
|
SELECT country, price FROM carbon_prices WHERE start_date <= '2023-01-01' AND end_date >= '2023-01-01' AND country IN ('Japan', 'India');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE bioprocess_engineers (name TEXT, salary FLOAT, location TEXT); INSERT INTO bioprocess_engineers (name, salary, location) VALUES ('EngrA', 80000, 'San Francisco'); INSERT INTO bioprocess_engineers (name, salary, location) VALUES ('EngrB', 90000, 'Berkeley');
|
Find the average salary of bioprocess engineers working in the Bay Area.
|
SELECT AVG(salary) FROM bioprocess_engineers WHERE location = 'San Francisco';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE if not exists carbon_offsets (offset_id int, name varchar(255), expiration_date date); INSERT INTO carbon_offsets (offset_id, name, expiration_date) VALUES (1, 'Carbon Offset Initiative 1', '2014-12-31'), (2, 'Carbon Offset Initiative 2', '2016-01-01');
|
Delete carbon offset initiatives in the 'carbon_offsets' table that have an expiration date older than 2015-01-01.
|
DELETE FROM carbon_offsets WHERE expiration_date < '2015-01-01';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE clinical_trials (id INT, company VARCHAR(255), department VARCHAR(255), trial_status VARCHAR(255), fda_approval_date DATE); INSERT INTO clinical_trials (id, company, department, trial_status, fda_approval_date) VALUES (1, 'Big Pharma Inc.', 'Neurology', 'Successful', '2012-04-02'), (2, 'Big Pharma Inc.', 'Neurology', 'Failed', '2013-07-08'), (3, 'Small Pharma Inc.', 'Oncology', 'Successful', '2015-09-10');
|
What is the number of clinical trials conducted by Big Pharma Inc. in the neurology department that were successful and approved by the FDA between 2010 and 2015?
|
SELECT COUNT(*) FROM clinical_trials WHERE company = 'Big Pharma Inc.' AND department = 'Neurology' AND trial_status = 'Successful' AND fda_approval_date BETWEEN '2010-01-01' AND '2015-12-31';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE production_rates (rate_id INT, chemical VARCHAR(20), production_rate INT, measurement_date DATE); INSERT INTO production_rates (rate_id, chemical, production_rate, measurement_date) VALUES (1, 'P', 500, '2021-01-01'), (2, 'P', 700, '2021-01-02'), (3, 'Q', 600, '2021-01-01'), (4, 'R', 900, '2021-01-03');
|
What is the average daily production rate of chemical 'R'?
|
SELECT AVG(production_rate) FROM production_rates WHERE chemical = 'R';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE carbon_offsets (initiative_id INT, initiative_name TEXT, offset_amount FLOAT); INSERT INTO carbon_offsets (initiative_id, initiative_name, offset_amount) VALUES (1, 'Tree Planting A', 5000.0), (2, 'Energy Efficiency B', 3000.0), (3, 'Waste Reduction C', 2000.0);
|
Show the carbon offset initiatives and their corresponding offset amounts in descending order from the 'carbon_offsets' table
|
SELECT initiative_name, offset_amount FROM carbon_offsets ORDER BY offset_amount DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE military_innovation (id INT, country VARCHAR(255), innovation VARCHAR(255));
|
List all military innovation records for 'Country Y'
|
SELECT * FROM military_innovation WHERE country = 'Country Y';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Arctic_Stations (station_name text, country text); CREATE TABLE Species_Observations (station_name text, species_id integer); CREATE TABLE Species (species_id integer, species_name text); INSERT INTO Arctic_Stations (station_name, country) VALUES ('Station A', 'Canada'), ('Station B', 'Greenland'), ('Station C', 'Norway'); INSERT INTO Species_Observations (station_name, species_id) VALUES ('Station A', 101), ('Station A', 102), ('Station B', 103), ('Station C', 101), ('Station C', 104); INSERT INTO Species (species_id, species_name) VALUES (101, 'Polar Bear'), (102, 'Narwhal'), (103, 'Greenland Shark'), (104, 'Arctic Fox');
|
List all marine research stations in the Arctic with their associated country and number of species observed.
|
SELECT Arctic_Stations.station_name, Arctic_Stations.country, COUNT(DISTINCT Species.species_id) AS number_of_species FROM Arctic_Stations LEFT JOIN Species_Observations ON Arctic_Stations.station_name = Species_Observations.station_name LEFT JOIN Species ON Species_Observations.species_id = Species.species_id WHERE Arctic_Stations.station_name IN ('Station A', 'Station B', 'Station C') GROUP BY Arctic_Stations.station_name, Arctic_Stations.country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE r_and_d_expenditure (company VARCHAR(50), year INT, expenditure FLOAT); INSERT INTO r_and_d_expenditure (company, year, expenditure) VALUES ('PharmaCorp', 2018, 20000000), ('PharmaCorp', 2019, 25000000), ('BioTech', 2018, 18000000), ('BioTech', 2019, 22000000);
|
What was the R&D expenditure for a specific company, 'PharmaCorp', in the year 2019?
|
SELECT expenditure as rd_expenditure FROM r_and_d_expenditure WHERE company = 'PharmaCorp' AND year = 2019;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE MentalHealthParity (ID INT PRIMARY KEY, PatientID INT, Procedure VARCHAR(20), Cost INT);
|
What is the average mental health parity cost for each procedure type?
|
SELECT Procedure, AVG(Cost) as AverageCost FROM MentalHealthParity GROUP BY Procedure;
|
gretelai_synthetic_text_to_sql
|
CREATE SCHEMA donations; CREATE TABLE donations (donation_id INT, donation_date DATE, donation_amount DECIMAL(10, 2), donor_city VARCHAR(255)); INSERT INTO donations (donation_id, donation_date, donation_amount, donor_city) VALUES (1, '2021-01-01', 50.00, 'New York'), (2, '2021-02-03', 100.00, 'Los Angeles'), (3, '2021-03-05', 25.00, 'Chicago'), (4, '2021-04-07', 75.00, 'Houston');
|
What is the average donation amount by city for the year 2021?
|
SELECT donor_city, AVG(donation_amount) as avg_donation FROM donations WHERE donation_date >= '2021-01-01' AND donation_date < '2022-01-01' GROUP BY donor_city;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE forestry.harvested_trees (id INT, species VARCHAR(50), volume FLOAT);
|
Get the total volume of timber produced by 'Quercus' species in the 'forestry' DB.
|
SELECT SUM(volume) FROM forestry.harvested_trees WHERE species = 'Quercus';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE social_good_tech (tech_name VARCHAR(50), accessibility_feature VARCHAR(50)); INSERT INTO social_good_tech VALUES ('TechA', 'Screen Reader'), ('TechA', 'Closed Captions'), ('TechB', 'Voice Command'), ('TechC', 'Keyboard Navigation');
|
Which accessibility features are available in social_good_tech table?
|
SELECT accessibility_feature FROM social_good_tech;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE union_members (id INT, name VARCHAR, state VARCHAR, union_since DATE); INSERT INTO union_members (id, name, state, union_since) VALUES (3, 'Mike Johnson', 'WA', '2016-09-01'); INSERT INTO union_members (id, name, state, union_since) VALUES (4, 'Alice Davis', 'WA', '2019-11-25');
|
What is the union seniority of members in WA?
|
SELECT name, state, union_since, ROW_NUMBER() OVER (PARTITION BY state ORDER BY union_since DESC) as seniority FROM union_members WHERE state = 'WA';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Production (id INT, strain TEXT, state TEXT, price_per_gram FLOAT); INSERT INTO Production (id, strain, state, price_per_gram) VALUES (1, 'Strain X', 'MI', 6.00), (2, 'Strain Y', 'MI', 8.00), (3, 'Strain Z', 'MI', 4.00);
|
What was the average price per gram for each strain grown in Michigan in 2020?
|
SELECT strain, AVG(price_per_gram) FROM Production WHERE state = 'MI' GROUP BY strain;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE articles (id INT, title VARCHAR(255), publish_date DATE, section VARCHAR(255), newspaper VARCHAR(255)); INSERT INTO articles (id, title, publish_date, section, newspaper) VALUES (1, 'Article1', '2022-01-01', 'Section1', 'The New York Times'), (2, 'Article2', '2022-01-05', 'Section2', 'The New York Times');
|
How many articles were published in 'The New York Times' in January 2022, categorized by section?
|
SELECT section, COUNT(*) FROM articles WHERE newspaper = 'The New York Times' AND publish_date >= '2022-01-01' AND publish_date < '2022-02-01' GROUP BY section;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE customer_accounts (customer_id INT, country TEXT, balance DECIMAL(10,2)); INSERT INTO customer_accounts (customer_id, country, balance) VALUES (1, 'United States', 12000.00), (2, 'Canada', 8000.00), (3, 'Mexico', 9000.00);
|
Who are the customers in the United States with a balance greater than $10,000?
|
SELECT customer_id, country, balance FROM customer_accounts WHERE country = 'United States' AND balance > 10000.00;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE VolunteerHours (VolunteerHoursID INT, VolunteerID INT, Hours INT, Month INT, Year INT, Country TEXT); INSERT INTO VolunteerHours (VolunteerHoursID, VolunteerID, Hours, Month, Year, Country) VALUES (1, 1, 10, 1, 2022, 'Australia'), (2, 2, 15, 2, 2022, 'Australia');
|
What is the maximum number of hours volunteered per month for volunteers in Australia?
|
SELECT Country, MAX(Hours) FROM VolunteerHours WHERE Month = 1 AND Year = 2022 AND Country = 'Australia' GROUP BY Country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE rare_earth_elements (element TEXT); INSERT INTO rare_earth_elements VALUES ('Neodymium'), ('Praseodymium'), ('Dysprosium'); CREATE TABLE extraction_data (year INT, company_name TEXT, element TEXT, quantity INT); INSERT INTO extraction_data (year, company_name, element, quantity) VALUES (2019, 'XYZ Mining', 'Neodymium', 1200), (2019, 'LMN Mining', 'Praseodymium', 900), (2019, 'OPQ Mining', 'Dysprosium', 1800);
|
Count the number of rare earth elements extracted by companies from Oceania in 2019?
|
SELECT SUM(quantity) as total_quantity FROM extraction_data WHERE year = 2019 AND company_name IN (SELECT company_name FROM mining_locations WHERE region = 'Oceania');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Military_Equipment_Sales(id INT, country VARCHAR(50), equipment_type VARCHAR(50), sale_value FLOAT); INSERT INTO Military_Equipment_Sales(id, country, equipment_type, sale_value) VALUES (1, 'Indonesia', 'Aircraft', 30000000), (2, 'Singapore', 'Vehicles', 20000000);
|
What is the total military equipment sales value to ASEAN countries?
|
SELECT SUM(sale_value) FROM Military_Equipment_Sales WHERE country IN ('Indonesia', 'Singapore', 'Malaysia', 'Philippines', 'Thailand', 'Brunei', 'Vietnam', 'Cambodia', 'Laos', 'Myanmar');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Military_Equipment_Sales (supplier VARCHAR(255), region VARCHAR(255), equipment VARCHAR(255), quantity INT, sale_price DECIMAL(10,2), sale_year INT);
|
What is the total quantity of communication equipment sold by XYZ Corp to African countries in 2023?
|
SELECT SUM(quantity) FROM Military_Equipment_Sales WHERE supplier = 'XYZ Corp' AND region = 'Africa' AND equipment = 'communication' AND sale_year = 2023;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Unions (UnionID int, UnionName varchar(50), Type varchar(50)); INSERT INTO Unions VALUES (101, 'Union A', 'Public'), (102, 'Union B', 'Private'), (103, 'Union C', 'Mixed'); CREATE TABLE Violations (ViolationID int, ViolationDate date, UnionID int, FinedAmount int); INSERT INTO Violations VALUES (1, '2020-01-01', 101, 5000), (2, '2019-06-15', 102, 7000), (3, '2018-12-20', 103, 8000);
|
What is the total number of workplace safety violations, grouped by union, in the last 3 years?
|
SELECT u.UnionName, COUNT(v.ViolationID) FROM Unions u INNER JOIN Violations v ON u.UnionID = v.UnionID WHERE v.ViolationDate >= DATE_SUB(CURDATE(), INTERVAL 3 YEAR) GROUP BY u.UnionName;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE garment (garment_id INT, garment_type VARCHAR(255), cost FLOAT); INSERT INTO garment (garment_id, garment_type, cost) VALUES (1, 'T-Shirt', 10.0), (2, 'Jeans', 20.0), (3, 'Jackets', 30.0);
|
Update the garment table to reflect the new cost for each garment type.
|
UPDATE garment SET cost = CASE garment_type WHEN 'T-Shirt' THEN 11.0 WHEN 'Jeans' THEN 22.0 WHEN 'Jackets' THEN 33.0 ELSE cost END;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Artifacts (ArtifactName VARCHAR(50), SiteName VARCHAR(50), AnalysisResult VARCHAR(50)); INSERT INTO Artifacts (ArtifactName, SiteName, AnalysisResult) VALUES ('ArtifactC1', 'Site13', 'ResultC1'), ('ArtifactC2', 'Site14', 'ResultC2'), ('ArtifactD1', 'Site15', 'ResultD1');
|
List all artifacts with their respective analysis results, excluding those from 'Site13'.
|
SELECT ArtifactName, AnalysisResult FROM Artifacts WHERE SiteName != 'Site13';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE countries (country_id INT, country TEXT); INSERT INTO countries (country_id, country) VALUES (1, 'India'); CREATE TABLE virtual_tours (tour_id INT, country_id INT, views INT, revenue FLOAT); INSERT INTO virtual_tours (tour_id, country_id, views, revenue) VALUES (1, 1, 500, 200.0), (2, 1, 600, 300.0);
|
What is the revenue generated by virtual tours in India?
|
SELECT SUM(revenue) FROM virtual_tours WHERE country_id = (SELECT country_id FROM countries WHERE country = 'India');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE pollution_timeline (id INT, incident_date DATE, level FLOAT); INSERT INTO pollution_timeline (id, incident_date, level) VALUES (1, '2021-01-01', 5.5), (2, '2021-02-01', 6.2), (3, '2021-03-01', 7.0);
|
What is the density of pollution incidents in the last year, ordered by date?
|
SELECT incident_date, COUNT(*) OVER (PARTITION BY DATE_TRUNC('year', incident_date) ORDER BY incident_date) AS density FROM pollution_timeline ORDER BY incident_date;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE network_investments (investment_id INT, amount FLOAT, region VARCHAR(20));
|
Insert new network infrastructure investment records for the Northeast region.
|
INSERT INTO network_investments (investment_id, amount, region) VALUES (1, 50000.0, 'Northeast'), (2, 60000.0, 'Northeast'), (3, 45000.0, 'Northeast');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE startups (id INT, name TEXT, industry TEXT, founders TEXT, funding FLOAT); INSERT INTO startups (id, name, industry, founders, funding) VALUES (1, 'AntarcticEnergy', 'Renewable Energy', 'Antarctica', 3000000);
|
What is the minimum funding received by startups founded by individuals from Antarctica in the renewable energy sector?
|
SELECT MIN(funding) FROM startups WHERE industry = 'Renewable Energy' AND founders = 'Antarctica';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE businesses (id INT, name VARCHAR(255), city VARCHAR(255), category VARCHAR(255)); INSERT INTO businesses (id, name, city, category) VALUES (1, 'Eco-Friendly Cafe', 'New York', 'Food'), (2, 'Sustainable Clothing Store', 'New York', 'Retail');
|
Delete the record for the 'Eco-Friendly Cafe' in New York from the businesses table.
|
DELETE FROM businesses WHERE name = 'Eco-Friendly Cafe' AND city = 'New York';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE community_policing_centers (id INT, center_name TEXT, location TEXT); INSERT INTO community_policing_centers (id, center_name, location) VALUES (1, 'Center A', 'Urban'), (2, 'Center B', 'Rural'), (3, 'Center C', 'Urban'), (4, 'Center D', 'Suburban'); CREATE TABLE incidents (id INT, center_id INT, incident_type TEXT, incident_count INT); INSERT INTO incidents (id, center_id, incident_type, incident_count) VALUES (1, 1, 'Traffic Accident', 30), (2, 1, 'Theft', 40), (3, 2, 'Traffic Accident', 10), (4, 2, 'Theft', 5), (5, 3, 'Traffic Accident', 50), (6, 3, 'Theft', 60), (7, 4, 'Traffic Accident', 20), (8, 4, 'Theft', 25);
|
What is the total number of traffic accidents and thefts in community policing centers located in urban areas?
|
SELECT SUM(incident_count) AS total_incidents FROM incidents i JOIN community_policing_centers c ON i.center_id = c.id WHERE c.location = 'Urban' AND incident_type IN ('Traffic Accident', 'Theft');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE MilitaryPersonnel (id INT, name VARCHAR(255), branch VARCHAR(255), personnel_count INT); INSERT INTO MilitaryPersonnel (id, name, branch, personnel_count) VALUES (1, 'Li Wei', 'Ground Forces', 800000), (2, 'Zhang Li', 'Air Force', 450000), (3, 'Wang Xiao', 'Navy', 300000);
|
What is the number of military personnel in each branch of the Chinese military?
|
SELECT branch, personnel_count FROM MilitaryPersonnel WHERE branch IN ('Ground Forces', 'Air Force', 'Navy') GROUP BY branch;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE bank (id INT, name VARCHAR(50), type VARCHAR(50)); INSERT INTO bank (id, name, type) VALUES (1, 'Green Bank', 'Shariah-compliant'), (2, 'Fair Lending Bank', 'Socially Responsible'), (3, 'Community Bank', 'Socially Responsible'); CREATE TABLE loans (bank_id INT, amount DECIMAL(10,2), type VARCHAR(50)); INSERT INTO loans (bank_id, amount, type) VALUES (1, 12000.00, 'Shariah-compliant'), (1, 15000.00, 'Shariah-compliant'), (2, 10000.00, 'Socially Responsible'), (2, 11000.00, 'Socially Responsible'), (3, 13000.00, 'Socially Responsible'), (3, 14000.00, 'Socially Responsible');
|
Find the top 2 banks with the highest average loan amount for socially responsible loans and their respective types?
|
SELECT bank_id, AVG(amount) as avg_loan_amount, type FROM loans WHERE type = 'Socially Responsible' GROUP BY bank_id, type ORDER BY avg_loan_amount DESC LIMIT 2;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Festivals (id INT, name VARCHAR(255), year INT, attendance INT);
|
List all music festivals that have had a higher attendance rate than Coachella since 2010.
|
SELECT name FROM Festivals WHERE attendance > (SELECT attendance FROM Festivals WHERE name = 'Coachella' AND year = 2010) AND year >= 2010;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE patient_outcomes (id INT, patient_id INT, treatment_name TEXT, improvement_status TEXT, country TEXT);
|
What is the percentage of patients in Canada who experienced improvement after group therapy?
|
SELECT (COUNT(*) * 100.0 / (SELECT COUNT(*) FROM patient_outcomes WHERE country = 'Canada')) AS percentage FROM patient_outcomes WHERE treatment_name = 'Group Therapy' AND improvement_status = 'Improved' AND country = 'Canada';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE age_groups (age_id INT, age_group VARCHAR(20), student_id INT, enrollment_type VARCHAR(20), enrollment_date DATE); INSERT INTO age_groups (age_id, age_group, student_id, enrollment_type, enrollment_date) VALUES (1, '18-24', 1, 'Lifelong Learning', '2022-01-01'), (2, '25-34', 2, 'Professional Development', '2022-02-01'), (3, '35-44', 3, 'Lifelong Learning', '2022-03-01'), (4, '45-54', 4, 'Professional Development', '2022-04-01'), (5, '55-64', 5, 'Lifelong Learning', '2022-05-01');
|
What is the total number of students enrolled in lifelong learning courses by age group?
|
SELECT age_group, COUNT(*) as total_enrollments FROM age_groups WHERE enrollment_type = 'Lifelong Learning' GROUP BY age_group;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE WindFarms ( FarmID INT, Name VARCHAR(255), Country VARCHAR(255), InstalledCapacity FLOAT ); CREATE TABLE SolarFarms ( FarmID INT, Name VARCHAR(255), Country VARCHAR(255), InstalledCapacity FLOAT );
|
Find the total installed capacity of Wind Farms and Solar Farms in each country?
|
SELECT Country, SUM(InstalledCapacity) FROM WindFarms WHERE Country = 'Italy' GROUP BY Country; SELECT Country, SUM(InstalledCapacity) FROM SolarFarms WHERE Country = 'Italy' GROUP BY Country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Events (event_id INT, event_location VARCHAR(20), event_type VARCHAR(20), num_attendees INT, funding_source VARCHAR(20)); INSERT INTO Events (event_id, event_location, event_type, num_attendees, funding_source) VALUES (1, 'New York', 'Concert', 500, 'Government'), (2, 'Los Angeles', 'Theater', 300, 'Private'), (3, 'Chicago', 'Exhibition', 400, 'Corporate'), (4, 'San Francisco', 'Workshop', 200, 'Government'), (5, 'Seattle', 'Exhibition', 150, 'Corporate');
|
What is the total number of attendees for events funded by the "Government" or "Corporate" funding sources, excluding 'Workshops'?
|
SELECT SUM(num_attendees) FROM Events WHERE funding_source IN ('Government', 'Corporate') AND event_type <> 'Workshop';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE police_on_duty (id INT, city VARCHAR(20), shift INT, officers_on_duty INT); INSERT INTO police_on_duty (id, city, shift, officers_on_duty) VALUES (1, 'Chicago', 1, 500), (2, 'Chicago', 2, 600), (3, 'Chicago', 3, 550), (4, 'New York', 1, 700);
|
What is the maximum number of police officers on duty per shift in the city of Chicago?
|
SELECT MAX(officers_on_duty) FROM police_on_duty WHERE city = 'Chicago';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE arctic_temperature (year INT, temperature FLOAT, other_data TEXT);
|
What is the average temperature recorded in the 'arctic_temperature' table for each year, and how many records were collected in each of those years?
|
SELECT t1.year, AVG(t1.temperature) as avg_temp, COUNT(t1.temperature) as record_count FROM arctic_temperature t1 GROUP BY t1.year;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE trees (tree_id INT, region_id INT, year INT, num_trees INT); INSERT INTO trees (tree_id, region_id, year, num_trees) VALUES (1, 3, 2018, 2000), (2, 1, 2018, 3000), (3, 2, 2018, 1500), (4, 4, 2018, 2500), (5, 3, 2019, 2200), (6, 1, 2019, 3500);
|
For each year, find the total number of trees in each region and rank them in descending order of total trees.
|
SELECT region_id, year, SUM(num_trees) AS total_trees, RANK() OVER (PARTITION BY year ORDER BY SUM(num_trees) DESC) AS tree_rank FROM trees GROUP BY region_id, year ORDER BY year, tree_rank ASC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE vehicle (id INT PRIMARY KEY, name VARCHAR(255), production_date DATE, model_year INT); INSERT INTO vehicle (id, name, production_date, model_year) VALUES (1, 'Tesla Model Y', '2022-03-14', 2022), (2, 'Volvo XC40 Recharge', '2022-08-16', 2022), (3, 'Ford Mustang Mach-E', '2022-10-18', 2022);
|
Insert records for new electric vehicle models launched in 2022.
|
INSERT INTO vehicle (name, production_date, model_year) VALUES ('Hyundai Ioniq 5', '2022-09-01', 2022), ('Kia EV6', '2022-11-01', 2022);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE seoul_routes(route_number text, district text);
|
How many public transportation routes serve each district in Seoul?
|
SELECT district, COUNT(DISTINCT route_number) FROM seoul_routes GROUP BY district;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Players (PlayerID INT, PlayerAge INT, GameName VARCHAR(20)); INSERT INTO Players (PlayerID, PlayerAge, GameName) VALUES (1, 25, 'Galactic Conquest'), (2, 30, 'Galactic Conquest'), (3, 22, 'Starship Command'), (4, 35, 'Starship Command'), (5, 28, 'Galactic Conquest'), (6, 33, 'Starship Command');
|
Find the number of users who have played "Starship Command" and "Galactic Conquest", and their respective rank in each game based on age.
|
SELECT GameName, PlayerAge, ROW_NUMBER() OVER (PARTITION BY GameName ORDER BY PlayerAge DESC) AS AgeRank FROM Players WHERE GameName IN ('Starship Command', 'Galactic Conquest');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE counties (county_id INT, county_name VARCHAR(255)); CREATE TABLE community_policing (event_id INT, event_date DATE, county_id INT); INSERT INTO counties VALUES (1, 'Los Angeles'), (2, 'San Francisco'); INSERT INTO community_policing VALUES (1, '2020-01-01', 1), (2, '2020-02-01', 2);
|
What is the total number of community policing events in each county over time?
|
SELECT county_id, DATE_TRUNC('month', event_date) as month, COUNT(*) as num_events FROM community_policing GROUP BY county_id, month ORDER BY county_id, month
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE sales (sale_id INT, dispensary_name VARCHAR(255), product_name VARCHAR(255), weight FLOAT, state VARCHAR(255), sale_date DATE); INSERT INTO sales (sale_id, dispensary_name, product_name, weight, state, sale_date) VALUES (1, 'Dispensary X', 'Flower A', 10.5, 'WA', '2021-07-01'), (2, 'Dispensary X', 'Flower B', 7.2, 'WA', '2021-09-15');
|
What is the total weight of cannabis flower sold by dispensary 'Dispensary X' in Washington in Q3 2021?
|
SELECT SUM(weight) FROM sales WHERE dispensary_name = 'Dispensary X' AND product_name LIKE 'Flower%' AND state = 'WA' AND sale_date BETWEEN '2021-07-01' AND '2021-09-30';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE salesperson_sizes (id INT, salesperson TEXT, size TEXT, quantity INT, date DATE);
|
How many items of each size were sold by each salesperson last month?
|
SELECT salesperson, size, SUM(quantity) FROM salesperson_sizes WHERE EXTRACT(MONTH FROM date) = MONTH(CURDATE()) - 1 GROUP BY salesperson, size;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Exhibitions (id INT, city VARCHAR(20), visitor_age INT); INSERT INTO Exhibitions (id, city, visitor_age) VALUES (1, 'New York', 35), (2, 'Chicago', 45), (3, 'New York', 28);
|
What was the average age of visitors who attended exhibitions in New York and Chicago?
|
SELECT AVG(visitor_age) FROM Exhibitions WHERE city IN ('New York', 'Chicago');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE companies (id INT, name TEXT, industry TEXT, founding_year INT, founder_gender TEXT); CREATE TABLE funding_rounds (id INT, company_id INT, round_type TEXT, amount INT); INSERT INTO companies (id, name, industry, founding_year, founder_gender) VALUES (1, 'Healthera', 'Healthcare', 2015, 'Female'); INSERT INTO companies (id, name, industry, founding_year, founder_gender) VALUES (2, 'Vira Health', 'Healthcare', 2018, 'Female'); INSERT INTO funding_rounds (id, company_id, round_type, amount) VALUES (1, 1, 'Seed', 1000000);
|
List the names of startups that have not raised any funding yet.
|
SELECT companies.name FROM companies LEFT JOIN funding_rounds ON companies.id = funding_rounds.company_id WHERE funding_rounds.id IS NULL;
|
gretelai_synthetic_text_to_sql
|
See context
|
What is the risk score for each policyholder?
|
SELECT * FROM policyholder_risk_scores;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE PublicHearings (HearingID INT, District TEXT, HearingDate DATE); INSERT INTO PublicHearings (HearingID, District, HearingDate) VALUES (1, 'District1', '2023-01-01'), (2, 'District2', '2023-02-15'), (3, 'District1', '2023-03-01');
|
Find the number of public hearings held in each district in the last 3 months
|
SELECT District, COUNT(*) FROM PublicHearings WHERE HearingDate >= DATEADD(month, -3, GETDATE()) GROUP BY District;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE FarmData (id INT, country VARCHAR(50), year INT, dissolved_oxygen FLOAT); INSERT INTO FarmData (id, country, year, dissolved_oxygen) VALUES (1, 'France', 2020, 7.5), (2, 'Spain', 2020, 6.8), (3, 'France', 2019, 7.3), (4, 'Spain', 2020, 6.9);
|
What is the average dissolved oxygen level (in mg/L) for all aquaculture farms in France and Spain, for the year 2020?
|
SELECT AVG(dissolved_oxygen) FROM FarmData WHERE country IN ('France', 'Spain') AND year = 2020;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE participants (participant_id INT, name VARCHAR(50), email VARCHAR(50), phone VARCHAR(20)); CREATE TABLE workshops (workshop_id INT, name VARCHAR(50), city VARCHAR(50), workshop_type VARCHAR(50)); CREATE TABLE registration (registration_id INT, participant_id INT, workshop_id INT); INSERT INTO participants (participant_id, name, email, phone) VALUES (1, 'James Lee', 'jlee@example.com', '1234567890'); INSERT INTO workshops (workshop_id, name, city, workshop_type) VALUES (1, 'Writing Workshop', 'Sydney', 'Writing'); INSERT INTO registration (registration_id, participant_id, workshop_id) VALUES (1, 1, 1);
|
Update the phone number of a participant who registered for a writing workshop in Sydney.
|
UPDATE participants SET phone = '0987654321' WHERE participant_id = 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE chemical_products (id INT, name TEXT, category TEXT); INSERT INTO chemical_products (id, name, category) VALUES (1, 'Product A', 'Category X'), (2, 'Product B', 'Category Y'), (3, 'Product C', 'Category Z'); CREATE TABLE wastes (id INT, product_id INT, amount INT); INSERT INTO wastes (id, product_id, amount) VALUES (1, 1, 500), (2, 1, 300), (3, 2, 700), (4, 3, 200);
|
List the total waste generated by each chemical product category.
|
SELECT chemical_products.category, SUM(wastes.amount) FROM chemical_products JOIN wastes ON chemical_products.id = wastes.product_id GROUP BY chemical_products.category;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE dental_clinics (clinic_id INT, state TEXT, income_level TEXT); INSERT INTO dental_clinics (clinic_id, state, income_level) VALUES (1, 'Texas', 'Low-income');
|
How many dental clinics are there in the state of Texas that serve low-income patients?
|
SELECT COUNT(*) FROM dental_clinics WHERE state = 'Texas' AND income_level = 'Low-income';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE medical_devices (id INT, name VARCHAR(255), last_assessment_date DATE, severity_score INT);
|
Insert a new record of a vulnerability assessment for a medical device with ID 4, last assessment date of 2021-12-15, and severity score of 6.
|
INSERT INTO medical_devices (id, name, last_assessment_date, severity_score) VALUES (4, 'Medical Device 4', '2021-12-15', 6);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE city_budgets (city VARCHAR(255), sector VARCHAR(255), budget INT); INSERT INTO city_budgets
|
Delete all records of police department budget from 'City D'
|
DELETE FROM city_budgets WHERE city = 'City D' AND sector = 'police department'
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Policyholders (ID INT, Age INT, State VARCHAR(50)); INSERT INTO Policyholders (ID, Age, State) VALUES (1, 35, 'California'), (2, 45, 'Texas'), (3, 30, 'California'), (4, 50, 'New York'), (5, 40, 'Texas'), (6, 25, 'California');
|
What is the average age of policyholders living in Texas and California?
|
SELECT State, AVG(Age) FROM Policyholders WHERE State IN ('California', 'Texas') GROUP BY State;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE customers (customer_id INT, customer_name VARCHAR(50), ethical_supplier BOOLEAN, locally_sourced BOOLEAN); INSERT INTO customers (customer_id, customer_name, ethical_supplier, locally_sourced) VALUES (1, 'Customer J', TRUE, TRUE), (2, 'Customer K', FALSE, FALSE), (3, 'Customer L', TRUE, FALSE), (4, 'Customer M', FALSE, TRUE); CREATE TABLE purchases (purchase_id INT, customer_id INT, product_id INT, supplier_id INT); INSERT INTO purchases (purchase_id, customer_id, product_id, supplier_id) VALUES (1, 1, 1, 1), (2, 2, 2, 2), (3, 3, 3, 3), (4, 4, 4, 4), (5, 1, 2, 1), (6, 3, 3, 2), (7, 4, 1, 3), (8, 2, 4, 4);
|
Identify the top 3 customers who have made the most purchases from ethical and locally sourced suppliers.
|
SELECT c.customer_name, COUNT(p.customer_id) AS total_purchases FROM purchases p JOIN customers c ON p.customer_id = c.customer_id WHERE c.ethical_supplier = TRUE AND c.locally_sourced = TRUE GROUP BY c.customer_name ORDER BY total_purchases DESC LIMIT 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE step_counts (id INT, user_id INT, step_count INT, date DATE); INSERT INTO step_counts (id, user_id, step_count, date) VALUES (1, 1, 10000, '2022-06-01'), (2, 1, 10000, '2022-06-02'), (3, 2, 5000, '2022-05-15'), (4, 3, 12000, '2022-06-20');
|
What is the average age of users who achieved their step goal 3 days in a row?
|
SELECT AVG(user_age) FROM (SELECT AVG(y.age) as user_age FROM users x INNER JOIN step_counts y ON x.id = y.user_id WHERE (SELECT COUNT(*) FROM step_counts z WHERE z.user_id = y.user_id AND z.date BETWEEN y.date - 2 AND y.date) = 3) subquery;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE country (name VARCHAR(255), PRIMARY KEY (name)); INSERT INTO country (name) VALUES ('Canada'), ('USA'), ('Mexico'), ('Brazil'), ('Argentina'), ('Chile'), ('UK'), ('France'), ('Germany'), ('Spain'), ('Italy'), ('Australia'), ('China'), ('India'), ('Russia'), ('Japan'); CREATE TABLE climate_finance_initiatives (initiative_name VARCHAR(255), location VARCHAR(255)); INSERT INTO climate_finance_initiatives (initiative_name, location) VALUES ('Initiative 1', 'Canada'), ('Initiative 2', 'USA'), ('Initiative 3', 'Mexico'), ('Initiative 4', 'Brazil'), ('Initiative 5', 'Argentina'), ('Initiative 6', 'Chile'), ('Initiative 7', 'UK'), ('Initiative 8', 'France'), ('Initiative 9', 'Germany'), ('Initiative 10', 'Spain'), ('Initiative 11', 'Italy'), ('Initiative 12', 'Australia'), ('Initiative 13', 'China'), ('Initiative 14', 'India'), ('Initiative 15', 'Russia'), ('Initiative 16', 'Japan');
|
How many climate finance initiatives have been launched in each country?
|
SELECT c.name, COUNT(*) FROM climate_finance_initiatives i JOIN country c ON i.location = c.name GROUP BY c.name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Museums (id INT, name VARCHAR(50), city VARCHAR(50)); CREATE TABLE Artworks (id INT, museum_id INT, title VARCHAR(50), year INT, artist VARCHAR(50)); INSERT INTO Museums (id, name, city) VALUES (1, 'National Museum of Women in the Arts', 'Washington D.C.'); INSERT INTO Artworks (id, museum_id, title, year, artist) VALUES (1, 1, 'Artwork 1', 2000, 'Artist 1'); INSERT INTO Artworks (id, museum_id, title, year, artist) VALUES (2, 1, 'Artwork 2', 2005, 'Artist 2');
|
What is the total number of artworks in the collection of the National Museum of Women in the Arts?
|
SELECT COUNT(*) FROM Artworks WHERE museum_id = 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE producers (id INT PRIMARY KEY, name VARCHAR(50), element VARCHAR(10), production_year INT, quantity INT); INSERT INTO producers (id, name, element, production_year, quantity) VALUES (1, 'ABC Corp', 'Dysprosium', 2019, 1200); INSERT INTO producers (id, name, element, production_year, quantity) VALUES (2, 'DEF Industries', 'Terbium', 2020, 800); INSERT INTO producers (id, name, element, production_year, quantity) VALUES (3, 'GHI Mining', 'Dysprosium', 2020, 1600); INSERT INTO producers (id, name, element, production_year, quantity) VALUES (4, 'JKL Corp', 'Terbium', 2019, 900);
|
What is the total production of Dysprosium and Terbium for each producer in 2019 and 2020?
|
SELECT name AS producer, element, SUM(quantity) AS total_production FROM producers WHERE production_year IN (2019, 2020) AND (element = 'Dysprosium' OR element = 'Terbium') GROUP BY name, element;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE projects (id INT PRIMARY KEY, name VARCHAR(255), location VARCHAR(255), budget DECIMAL(10,2));CREATE VIEW high_budget_projects AS SELECT * FROM projects WHERE budget >= 1000000;
|
Which projects in Sub-Saharan Africa have budgets greater than $1,000,000?
|
SELECT * FROM high_budget_projects WHERE location = 'Sub-Saharan Africa';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ClientDemographics ( ClientID INT, ClientName VARCHAR(50), Age INT, Gender VARCHAR(50), Race VARCHAR(50), BillingAmount DECIMAL(10,2) ); INSERT INTO ClientDemographics (ClientID, ClientName, Age, Gender, Race, BillingAmount) VALUES (1, 'John Doe', 35, 'Male', 'White', 5000.00), (2, 'Jane Doe', 45, 'Female', 'Asian', 7000.00), (3, 'Bob Smith', 50, 'Male', 'Black', 6000.00), (4, 'Alice Johnson', 40, 'Female', 'Hispanic', 8000.00), (5, 'David Williams', 55, 'Male', 'White', 9000.00);
|
What is the total billing amount for clients by age group?
|
SELECT CASE WHEN Age < 35 THEN 'Under 35' WHEN Age < 50 THEN '35-49' ELSE '50 and Above' END AS AgeGroup, SUM(BillingAmount) AS TotalBillingAmount FROM ClientDemographics GROUP BY AgeGroup;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE asia_cybersecurity_budget (id INT, country VARCHAR(255), year INT, budget FLOAT); INSERT INTO asia_cybersecurity_budget (id, country, year, budget) VALUES (1, 'China', 2020, 85.0), (2, 'Japan', 2020, 90.0), (3, 'South Korea', 2020, 95.0), (4, 'India', 2020, 80.0), (5, 'Singapore', 2020, 75.0);
|
What was the maximum cybersecurity budget for any Asian country in 2020?
|
SELECT MAX(budget) FROM asia_cybersecurity_budget WHERE year = 2020;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE deployments (dapp_name VARCHAR(20), deployment_date DATE, smart_contract_count INT); INSERT INTO deployments (dapp_name, deployment_date, smart_contract_count) VALUES ('App1', '2021-01-01', 1500), ('App2', '2021-02-01', 2000), ('App3', '2021-03-01', 2500), ('App4', '2021-04-01', 1000);
|
List the top 3 decentralized applications with the highest number of smart contract deployments in a specified time period.
|
SELECT dapp_name, smart_contract_count FROM deployments ORDER BY smart_contract_count DESC LIMIT 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE cities (city_id INT, city_name VARCHAR(100), country_id INT); INSERT INTO cities VALUES (1, 'NYC', 1), (2, 'Toronto', 2), (3, 'Mexico City', 3); CREATE TABLE green_buildings (building_id INT, city_id INT, wind_speed FLOAT); INSERT INTO green_buildings VALUES (1, 1, 10), (2, 1, 12), (3, 2, 8), (4, 3, 15);
|
What is the average wind speed in cities with green buildings?
|
SELECT c.city_name, AVG(gb.wind_speed) as avg_wind_speed FROM cities c JOIN green_buildings gb ON c.city_id = gb.city_id GROUP BY c.city_name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE green_infrastructure (id INT, country VARCHAR(50), investment FLOAT); INSERT INTO green_infrastructure (id, country, investment) VALUES (1, 'Canada', 4000000); INSERT INTO green_infrastructure (id, country, investment) VALUES (2, 'Mexico', 3500000);
|
What is the total investment in green infrastructure in Canada and Mexico?
|
SELECT SUM(investment) FROM green_infrastructure WHERE country IN ('Canada', 'Mexico');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE urban_area (name TEXT, population INT, landfill_capacity FLOAT); INSERT INTO urban_area (name, population, landfill_capacity) VALUES ('City A', 700000, 500), ('City B', 600000, 650), ('City C', 550000, 700);
|
What is the maximum landfill capacity in urban areas with a population greater than 500,000?
|
SELECT MAX(landfill_capacity) FROM urban_area WHERE population > 500000;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE farm_activities (region VARCHAR(50), crop VARCHAR(50), planting_date DATE); INSERT INTO farm_activities VALUES ('West Coast', 'Wheat', '2022-04-01'); INSERT INTO farm_activities VALUES ('West Coast', 'Corn', '2022-05-01'); INSERT INTO farm_activities VALUES ('East Coast', 'Rice', '2022-06-01');
|
What is the earliest planting date for each crop in 'farm_activities' table?
|
SELECT crop, MIN(planting_date) AS earliest_planting FROM farm_activities GROUP BY crop;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE GreenBuildings (BuildingID INT, BuildingName VARCHAR(255), Region VARCHAR(255), EnergyEfficiencyRating FLOAT); INSERT INTO GreenBuildings (BuildingID, BuildingName, Region, EnergyEfficiencyRating) VALUES (1, 'Green Building 1', 'Region F', 95.0);
|
What is the maximum energy efficiency rating of Green buildings in 'Region F'?
|
SELECT MAX(EnergyEfficiencyRating) FROM GreenBuildings WHERE Region = 'Region F';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE events (id INT, name VARCHAR(255), city VARCHAR(255), participants INT); INSERT INTO events (id, name, city, participants) VALUES (1, 'Virtual Cultural Heritage', 'Tokyo', 3500), (2, 'Sustainable Architecture Tour', 'Tokyo', 2000);
|
Update the number of participants for the 'Virtual Cultural Heritage' event in Tokyo.
|
UPDATE events SET participants = 4000 WHERE name = 'Virtual Cultural Heritage' AND city = 'Tokyo';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE LandfillCapacity (capacity_id INT, region VARCHAR(255), capacity DECIMAL(10,2)); INSERT INTO LandfillCapacity (capacity_id, region, capacity) VALUES (1, 'North', 2500), (2, 'South', 3000), (3, 'East', 1800), (4, 'West', 2200);
|
What is the maximum landfill capacity in the West region?
|
SELECT MAX(capacity) FROM LandfillCapacity WHERE region = 'West';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Donors (donor_id INT, donation_date DATE); INSERT INTO Donors (donor_id, donation_date) VALUES (1, '2019-07-01'), (2, '2019-07-15'), (3, '2019-08-01'), (4, '2019-09-01'), (5, '2019-07-05'), (6, '2019-10-01'), (7, '2019-09-15'), (8, '2019-08-15');
|
How many unique donors made donations in Q3 2019?
|
SELECT COUNT(DISTINCT donor_id) FROM Donors WHERE QUARTER(donation_date) = 3 AND YEAR(donation_date) = 2019;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE energy_prices (id INT PRIMARY KEY, source VARCHAR(50), price_per_mwh FLOAT, date DATE); INSERT INTO energy_prices (id, source, price_per_mwh, date) VALUES (1, 'Wind', 35.5, '2022-01-01'), (2, 'Solar', 40.2, '2022-01-02'), (3, 'Wind', 32.0, '2022-01-03');
|
What is the minimum price per MWh for each energy source in a given date range?
|
SELECT source, MIN(price_per_mwh) FROM energy_prices WHERE date BETWEEN '2022-01-01' AND '2022-01-03' GROUP BY source;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE AgriculturalProjects (id INT, name VARCHAR(50), cost FLOAT, start_date DATE, end_date DATE, region VARCHAR(50)); INSERT INTO AgriculturalProjects (id, name, cost, start_date, end_date, region) VALUES (1, 'Irrigation System', 50000, '2021-01-01', '2021-12-31', 'Rural Alabama'); INSERT INTO AgriculturalProjects (id, name, cost, start_date, end_date, region) VALUES (2, 'Greenhouse Construction', 80000, '2021-04-01', '2021-12-31', 'Rural Alaska');
|
List the name and cost of the top 2 most expensive agricultural projects in Rural Alaska, ordered by cost.
|
SELECT name, cost FROM (SELECT name, cost, ROW_NUMBER() OVER (PARTITION BY region ORDER BY cost DESC) as Rank FROM AgriculturalProjects WHERE region = 'Rural Alaska') AS Subquery WHERE Rank <= 2 ORDER BY cost DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE IF NOT EXISTS decentralized_applications (dapp_id INT PRIMARY KEY, name VARCHAR(100), tx_id INT, category VARCHAR(50), blockchain VARCHAR(50), FOREIGN KEY (tx_id) REFERENCES blockchain_transactions(tx_id)); CREATE TABLE IF NOT EXISTS blockchain_transactions (tx_id INT PRIMARY KEY, blockchain VARCHAR(50)); INSERT INTO blockchain_transactions (tx_id, blockchain) VALUES (1, 'Cardano');
|
What are the total number of transactions for each decentralized application that has been deployed on the Cardano blockchain?
|
SELECT dapp_name, COUNT(dapp_id) FROM decentralized_applications da JOIN blockchain_transactions bt ON da.tx_id = bt.tx_id WHERE bt.blockchain = 'Cardano' GROUP BY dapp_name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE tv_shows (id INT, title VARCHAR(100), genre VARCHAR(50), release_year INT, marketing_spend INT); INSERT INTO tv_shows (id, title, genre, release_year, marketing_spend) VALUES (1, 'ShowA', 'Comedy', 2015, 5000000); INSERT INTO tv_shows (id, title, genre, release_year, marketing_spend) VALUES (2, 'ShowB', 'Comedy', 2015, 7000000);
|
Find the total marketing spend for TV shows in the Comedy genre for the year 2015.
|
SELECT SUM(marketing_spend) FROM tv_shows WHERE genre = 'Comedy' AND release_year = 2015;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Warehouse (id INT, name VARCHAR(20), city VARCHAR(20)); INSERT INTO Warehouse (id, name, city) VALUES (1, 'Nairobi Warehouse', 'Nairobi'); CREATE TABLE Packages (id INT, warehouse_id INT, delivery_time INT, status VARCHAR(20)); INSERT INTO Packages (id, warehouse_id, delivery_time, status) VALUES (1, 1, 5, 'shipped'), (2, 1, 7, 'shipped'), (3, 1, 6, 'processing');
|
What is the minimum delivery time for packages shipped to 'Nairobi'?
|
SELECT MIN(delivery_time) FROM Packages WHERE warehouse_id = (SELECT id FROM Warehouse WHERE city = 'Nairobi') AND status = 'shipped';
|
gretelai_synthetic_text_to_sql
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.