context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE carbon_sequestration (species VARCHAR(255), sequestration_rate DECIMAL(5,2));
Find the top 3 tree species with the highest carbon sequestration rate.
SELECT species, sequestration_rate FROM carbon_sequestration ORDER BY sequestration_rate DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE healthcare_facilities (id INT, name TEXT, region TEXT, type TEXT); INSERT INTO healthcare_facilities (id, name, region, type) VALUES (1, 'Hospital A', 'north', 'hospital'); INSERT INTO healthcare_facilities (id, name, region, type) VALUES (2, 'Clinic A', 'north', 'clinic'); INSERT INTO healthcare_facilities (id, name, region, type) VALUES (3, 'Dental Clinic A', 'north', 'dental_clinic');
List the unique types of healthcare facilities in the 'north' region, excluding dental clinics.
SELECT DISTINCT type FROM healthcare_facilities WHERE region = 'north' AND type != 'dental_clinic';
gretelai_synthetic_text_to_sql
CREATE TABLE Museums (MuseumID INT, Name TEXT, Country TEXT);CREATE TABLE GiftShops (GiftShopID INT, MuseumID INT, Revenue INT);
What is the total revenue generated by all gift shops in Asia?
SELECT SUM(GiftShops.Revenue) FROM Museums INNER JOIN GiftShops ON Museums.MuseumID = GiftShops.MuseumID WHERE Museums.Country = 'Asia';
gretelai_synthetic_text_to_sql
CREATE TABLE local_articles (id INT, title VARCHAR(100), publication_year INT, author_local BOOLEAN, event_local BOOLEAN); INSERT INTO local_articles (id, title, publication_year, author_local, event_local) VALUES (1, 'Article1', 2021, TRUE, TRUE), (2, 'Article2', 2020, FALSE, TRUE), (3, 'Article3', 2021, TRUE, FALSE);
What is the total number of articles written by local authors about local events in 2021?
SELECT COUNT(*) FROM local_articles WHERE publication_year = 2021 AND author_local = TRUE AND event_local = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE climate_finance_projects (project_id INT, project_name VARCHAR(255), location VARCHAR(255), budget DECIMAL(10,2)); INSERT INTO climate_finance_projects (project_id, project_name, location, budget) VALUES (1, 'Renewable Energy in India', 'India', 2000000.00), (2, 'Energy Efficiency in China', 'China', 3000000.00), (3, 'Climate Resilience in Indonesia', 'Indonesia', 1000000.00);
What is the minimum budget for a single climate finance project in Asia?
SELECT MIN(budget) FROM climate_finance_projects WHERE location = 'Asia';
gretelai_synthetic_text_to_sql
CREATE TABLE ElectricVehicleAdoption (Vehicle VARCHAR(255), MPG INT); INSERT INTO ElectricVehicleAdoption (Vehicle, MPG) VALUES ('TeslaModel3', 120), ('TeslaModelS', 105), ('NissanLeaf', 115), ('ChevroletBolt', 128), ('RivianR1T', 65), ('AudiETron', 75);
Count the number of vehicles in the 'ElectricVehicleAdoption' table for each MPG range (0-50, 51-100, 101-150, 151-200).
SELECT (CASE WHEN MPG BETWEEN 0 AND 50 THEN '0-50' WHEN MPG BETWEEN 51 AND 100 THEN '51-100' WHEN MPG BETWEEN 101 AND 150 THEN '101-150' ELSE '151-200' END) as MPGRange, COUNT(*) as VehicleCount FROM ElectricVehicleAdoption GROUP BY MPGRange;
gretelai_synthetic_text_to_sql
CREATE TABLE football_stadiums (stadium_id INT, stadium_name VARCHAR(50), capacity INT, city VARCHAR(50), country VARCHAR(50));
Add a new record to the 'football_stadiums' table for a stadium with a capacity of 70000 located in 'Los Angeles', 'USA'
INSERT INTO football_stadiums (stadium_id, stadium_name, capacity, city, country) VALUES (1, 'Los Angeles Stadium', 70000, 'Los Angeles', 'USA');
gretelai_synthetic_text_to_sql
CREATE TABLE movies (id INT, title TEXT, release_year INT, country TEXT, user_rating DECIMAL(3,2));
Which movies were released in the US between 2015-2017 and received a user rating higher than 3.5?
SELECT title FROM movies WHERE release_year BETWEEN 2015 AND 2017 AND country = 'USA' AND user_rating > 3.5;
gretelai_synthetic_text_to_sql
CREATE TABLE properties (id INT, city VARCHAR(50), coowners INT, sustainable_urbanism BOOLEAN); INSERT INTO properties VALUES (1, 'NYC', 2, TRUE); INSERT INTO properties VALUES (2, 'NYC', 1, FALSE); INSERT INTO properties VALUES (3, 'LA', 3, TRUE); INSERT INTO properties VALUES (4, 'LA', 1, FALSE); INSERT INTO properties VALUES (5, 'Chicago', 1, TRUE);
List all co-owned properties in cities with sustainable urbanism policies
SELECT city FROM properties WHERE coowners > 1 AND sustainable_urbanism = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE drug_approval(drug_name TEXT, approval_date DATE, approval_agency TEXT); INSERT INTO drug_approval(drug_name, approval_date, approval_agency) VALUES('DrugC', '2020-06-06', 'EMA');
List all drugs approved by the EMA in 2020
SELECT drug_name FROM drug_approval WHERE approval_agency = 'EMA' AND approval_date BETWEEN '2020-01-01' AND '2020-12-31';
gretelai_synthetic_text_to_sql
CREATE TABLE nba_teams (team_id INT, team_name VARCHAR(255)); INSERT INTO nba_teams (team_id, team_name) VALUES (1, 'Atlanta Hawks'), (2, 'Boston Celtics'); CREATE TABLE nba_games (game_id INT, home_team_id INT, away_team_id INT);
Find the total number of games played by each team in the 'nba_games' table.
SELECT home_team_id AS team_id, COUNT(*) AS total_games FROM nba_games GROUP BY home_team_id UNION ALL SELECT away_team_id, COUNT(*) FROM nba_games GROUP BY away_team_id;
gretelai_synthetic_text_to_sql
CREATE TABLE FarmStock (farm_id INT, date DATE, action VARCHAR(10), quantity INT); INSERT INTO FarmStock (farm_id, date, action, quantity) VALUES (3, '2021-01-01', 'added', 300), (3, '2021-01-05', 'added', 250);
What is the total number of fish added to the Shrimp farm in 2021?
SELECT SUM(quantity) total_fish FROM FarmStock WHERE farm_id = 3 AND YEAR(date) = 2021 AND action = 'added';
gretelai_synthetic_text_to_sql
CREATE TABLE volunteer_signups (id INT, volunteer_id INT, program_id INT, signup_date DATE); INSERT INTO volunteer_signups (id, volunteer_id, program_id, signup_date) VALUES (1, 201, 1001, '2021-01-01'), (2, 202, 1002, '2021-02-01'), (3, 203, 1001, '2021-03-01'); CREATE TABLE programs (id INT, name VARCHAR); INSERT INTO programs (id, name) VALUES (1001, 'Education'), (1002, 'Environment'); CREATE TABLE volunteers (id INT, name VARCHAR); INSERT INTO volunteers (id, name) VALUES (201, 'Alice Johnson'), (202, 'Bob Brown'), (203, 'Charlie Green');
How many volunteers signed up for each program in 2021?
SELECT p.name as program_name, COUNT(vs.program_id) as num_volunteers FROM volunteer_signups vs JOIN programs p ON vs.program_id = p.id WHERE YEAR(vs.signup_date) = 2021 GROUP BY vs.program_id;
gretelai_synthetic_text_to_sql
CREATE TABLE orders (id INT, brand VARCHAR(20), region VARCHAR(20), order_amount DECIMAL(5,2)); INSERT INTO orders (id, brand, region, order_amount) VALUES (1, 'Brand A', 'Africa', 150.99), (2, 'Brand B', 'Europe', 204.55), (3, 'Brand A', 'Africa', 125.44);
What is the sum of orders placed with ethical fashion brands in Africa?
SELECT SUM(order_amount) FROM orders WHERE brand IN ('Brand A', 'Brand C') AND region = 'Africa';
gretelai_synthetic_text_to_sql
CREATE TABLE industrial_sectors (id INT, sector VARCHAR(255)); INSERT INTO industrial_sectors (id, sector) VALUES (1, 'Manufacturing'), (2, 'Mining'), (3, 'Construction'), (4, 'Residential'); CREATE TABLE water_consumption (year INT, sector_id INT, consumption INT); INSERT INTO water_consumption (year, sector_id, consumption) VALUES (2019, 4, 8000), (2020, 4, 9000);
Delete all records related to water consumption in the residential sector for the year 2019.
DELETE FROM water_consumption WHERE sector_id = (SELECT id FROM industrial_sectors WHERE sector = 'Residential') AND year = 2019;
gretelai_synthetic_text_to_sql
CREATE TABLE Cases (CaseID INT, ClientID INT, Outcome TEXT); CREATE TABLE CaseAttorneys (CaseID INT, AttorneyID INT); CREATE TABLE Attorneys (AttorneyID INT, Name TEXT); CREATE TABLE Clients (ClientID INT, Region TEXT); INSERT INTO Cases (CaseID, ClientID, Outcome) VALUES (1, 1, 'Settled'); INSERT INTO CaseAttorneys (CaseID, AttorneyID) VALUES (1, 1); INSERT INTO Attorneys (AttorneyID, Name) VALUES (1, 'Liam Smith'); INSERT INTO Clients (ClientID, Region) VALUES (1, 'Northeast');
List all cases with a 'Settled' outcome, their corresponding attorney's name, and the client's region.
SELECT Clients.Region, Attorneys.Name, Cases.Outcome FROM Cases INNER JOIN CaseAttorneys ON Cases.CaseID = CaseAttorneys.CaseID INNER JOIN Attorneys ON CaseAttorneys.AttorneyID = Attorneys.AttorneyID INNER JOIN Clients ON Cases.ClientID = Clients.ClientID WHERE Cases.Outcome = 'Settled';
gretelai_synthetic_text_to_sql
CREATE TABLE camp (camp_id INT, name VARCHAR(50), location VARCHAR(50), population INT); INSERT INTO camp (camp_id, name, location, population) VALUES (1, 'Camp A', 'City A', 500), (2, 'Camp B', 'City B', 700), (3, 'Camp C', 'City C', 300);
What is the name and location of the refugee camp with the highest population?
SELECT name, location FROM camp ORDER BY population DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE military_personnel (id INT, name VARCHAR(50), branch VARCHAR(20), rank VARCHAR(20), country VARCHAR(50)); INSERT INTO military_personnel (id, name, branch, rank, country) VALUES (1, 'John Doe', 'army', 'Colonel', 'USA');
What is the total number of military personnel in the 'army' branch?
SELECT COUNT(*) FROM military_personnel WHERE branch = 'army';
gretelai_synthetic_text_to_sql
CREATE TABLE temperature_records (record_id INTEGER, month INTEGER, temperature FLOAT, ocean TEXT);
What is the minimum temperature ever recorded in the Southern Ocean, grouped by measurement month?
SELECT month, MIN(temperature) FROM temperature_records WHERE ocean = 'Southern Ocean' GROUP BY month;
gretelai_synthetic_text_to_sql
CREATE TABLE companies (id INT, name TEXT, country TEXT, founding_year INT, total_funding FLOAT, people_of_color_founded INT); INSERT INTO companies (id, name, country, founding_year, total_funding, people_of_color_founded) VALUES (1, 'Acme Corp', 'USA', 2010, 20000000.0, 0);
What is the percentage of companies founded by people of color, per country?
SELECT country, 100.0 * AVG(people_of_color_founded) / COUNT(*) AS percentage_founded_by_people_of_color FROM companies GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE space_debris (debris_type VARCHAR(30), mass FLOAT, debris_id INT); INSERT INTO space_debris VALUES ('Fuel Tank', 1500.20, 1), ('Upper Stage', 3000.50, 2), ('Payload Adapter', 700.30, 3), ('Instrument', 100.10, 4);
What is the total mass of space debris grouped by the debris type in the space_debris table?
SELECT debris_type, SUM(mass) OVER (PARTITION BY debris_type) FROM space_debris;
gretelai_synthetic_text_to_sql
CREATE VIEW Carbon_Footprint AS SELECT product_id, product_name, (transportation_emissions + production_emissions + packaging_emissions) AS total_carbon_footprint FROM Products; INSERT INTO Products (product_id, product_name, transportation_emissions, production_emissions, packaging_emissions) VALUES (401, 'T-Shirt', 5, 10, 1); INSERT INTO Products (product_id, product_name, transportation_emissions, production_emissions, packaging_emissions) VALUES (402, 'Jeans', 8, 12, 2); INSERT INTO Products (product_id, product_name, transportation_emissions, production_emissions, packaging_emissions) VALUES (403, 'Hoodie', 10, 15, 3);
What is the average carbon footprint of products in the Carbon_Footprint view?
SELECT AVG(total_carbon_footprint) FROM Carbon_Footprint;
gretelai_synthetic_text_to_sql
CREATE TABLE donations (donation_id INT, donor_id INT, donation_amount DECIMAL(10,2)); INSERT INTO donations VALUES (1, 1, 500.00), (2, 2, 300.00), (3, 3, 800.00), (4, 1, 200.00), (5, 2, 400.00), (6, 3, 100.00);
Find the percentage of donations made by each donor relative to the total donations received.
SELECT donor_id, donation_amount, PERCENT_RANK() OVER (ORDER BY SUM(donation_amount) ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) as donation_percentage FROM donations GROUP BY donor_id;
gretelai_synthetic_text_to_sql
CREATE TABLE humanitarian_assistance (assistance_id INT PRIMARY KEY, assistance_type VARCHAR(50), country VARCHAR(50), year INT); INSERT INTO humanitarian_assistance (assistance_id, assistance_type, country, year) VALUES (1, 'Food Aid', 'Kenya', 2016), (2, 'Water Supply', 'Pakistan', 2017), (3, 'Medical Aid', 'Syria', 2018);
Delete records in the "humanitarian_assistance" table for "Medical Aid" in Syria from 2018
DELETE FROM humanitarian_assistance WHERE assistance_type = 'Medical Aid' AND country = 'Syria' AND year = 2018;
gretelai_synthetic_text_to_sql
CREATE TABLE fertilizer_usage (crop_type TEXT, fertilizer_amount INTEGER, application_date DATE); INSERT INTO fertilizer_usage (crop_type, fertilizer_amount, application_date) VALUES ('Corn', 50, '2022-01-01'), ('Soybeans', 30, '2022-01-01'), ('Corn', 55, '2022-01-02');
Find total fertilizer usage for each crop type
SELECT crop_type, SUM(fertilizer_amount) FROM fertilizer_usage GROUP BY crop_type;
gretelai_synthetic_text_to_sql
CREATE TABLE MenuItems (menu_item_id INT, name VARCHAR(255), price DECIMAL(5,2), is_vegan BOOLEAN); INSERT INTO MenuItems (menu_item_id, name, price, is_vegan) VALUES (1, 'Burger', 12.99, false), (2, 'Steak', 25.99, false), (3, 'Fries', 3.99, true);
What is the average price of vegan menu items?
SELECT AVG(price) FROM MenuItems WHERE is_vegan = true;
gretelai_synthetic_text_to_sql
CREATE TABLE biotech_startups (id INT PRIMARY KEY, name VARCHAR(255), total_funding DECIMAL(10,2), founding_year INT, country VARCHAR(255));
What is the total amount of funding raised by biotech startups in the top 3 countries with the most funding, grouped by their founding year?
SELECT founding_year, country, SUM(total_funding) FROM biotech_startups WHERE country IN (SELECT country FROM biotech_startups GROUP BY country ORDER BY SUM(total_funding) DESC LIMIT 3) GROUP BY founding_year, country;
gretelai_synthetic_text_to_sql
CREATE TABLE posts (post_id INT, user_id INT, post_type VARCHAR(20), time_spent FLOAT, posted_at TIMESTAMP); INSERT INTO posts (post_id, user_id, post_type, time_spent, posted_at) VALUES (1, 101, 'Text', 300.0, '2021-01-01 12:00:00'), (2, 102, 'Image', 600.0, '2021-01-02 13:00:00');
What is the average time spent on each post by users from France, grouped by post type and day of the week?
SELECT post_type, DATE_PART('dow', posted_at) AS day_of_week, AVG(time_spent) AS avg_time_spent FROM posts WHERE country = 'France' GROUP BY post_type, day_of_week;
gretelai_synthetic_text_to_sql
CREATE TABLE drought_impact (customer_id INT, year INT, impact_level TEXT); INSERT INTO drought_impact (customer_id, year, impact_level) VALUES (1, 2019, 'severe'), (1, 2020, 'moderate'), (2, 2019, 'none'), (3, 2020, 'severe'), (3, 2019, 'moderate'), (4, 2018, 'severe'), (4, 2019, 'severe');
How many customers were impacted by droughts in each year?
SELECT year, COUNT(DISTINCT customer_id) as num_impacted_customers FROM drought_impact GROUP BY year;
gretelai_synthetic_text_to_sql
CREATE SCHEMA if not exists africa_schema_2;CREATE TABLE africa_schema_2.african_mines (id INT, name VARCHAR, role VARCHAR, salary DECIMAL);INSERT INTO africa_schema_2.african_mines (id, name, role, salary) VALUES (1, 'G engineer', 'Engineer', 60000.00), (2, 'K engineer', 'Engineer', 75000.00);
What is the minimum salary for engineers in 'african_mines'?
SELECT MIN(salary) FROM africa_schema_2.african_mines WHERE role = 'Engineer';
gretelai_synthetic_text_to_sql
CREATE TABLE ocean_acidification (region TEXT, level FLOAT); INSERT INTO ocean_acidification (region, level) VALUES ('Atlantic Ocean', 7.5), ('Pacific Ocean', 7.9), ('Indian Ocean', 7.6);
What is the maximum ocean acidification level in the Pacific Ocean?
SELECT MAX(level) FROM ocean_acidification WHERE region = 'Pacific Ocean';
gretelai_synthetic_text_to_sql
CREATE TABLE Albums (AlbumID INT, AlbumName VARCHAR(50), ReleaseYear INT, Sales INT);
What is the average sales for albums released in the 2010s?
SELECT AVG(Sales) as AverageSales FROM Albums WHERE ReleaseYear BETWEEN 2010 AND 2019;
gretelai_synthetic_text_to_sql
CREATE TABLE digital_assets (id INT, name VARCHAR(255), transaction_volume DECIMAL(10, 2), country VARCHAR(255)); INSERT INTO digital_assets (id, name, transaction_volume, country) VALUES (1, 'Asset 1', 1000.50, 'Nigeria'), (2, 'Asset 2', 1500.25, 'South Africa'), (3, 'Asset 3', 2000.00, 'Egypt'); CREATE TABLE transactions (id INT, digital_asset_id INT, transaction_date DATE); INSERT INTO transactions (id, digital_asset_id, transaction_date) VALUES (1, 1, '2022-01-01'), (2, 2, '2022-01-05'), (3, 3, '2022-01-10');
What's the total transaction volume for digital assets in Africa in the last month?
SELECT SUM(transaction_volume) FROM digital_assets JOIN transactions ON digital_assets.id = transactions.digital_asset_id WHERE transaction_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) AND country IN ('Nigeria', 'South Africa', 'Egypt');
gretelai_synthetic_text_to_sql
CREATE SCHEMA commentsdata; CREATE TABLE comments_per_post(post_id INT, interest_group VARCHAR(255), comments INT); INSERT INTO commentsdata.comments_per_post (post_id, interest_group, comments) VALUES (1, 'travel', 20); INSERT INTO commentsdata.comments_per_post (post_id, interest_group, comments) VALUES (2, 'travel', 30);
What was the total number of comments on posts in the 'travel' interest group in February 2022?
SELECT SUM(comments) FROM commentsdata.comments_per_post WHERE interest_group = 'travel' AND post_date >= '2022-02-01' AND post_date <= '2022-02-28';
gretelai_synthetic_text_to_sql
CREATE TABLE hospitals (id INT, name TEXT, location TEXT, beds INT, rural BOOLEAN); INSERT INTO hospitals (id, name, location, beds, rural) VALUES (1, 'Hospital A', 'Arkansas', 100, true), (2, 'Hospital B', 'Arkansas', 150, true);
What is the minimum number of hospital beds in rural hospitals of Arkansas?
SELECT MIN(beds) FROM hospitals WHERE location = 'Arkansas' AND rural = true;
gretelai_synthetic_text_to_sql
CREATE TABLE chain_restaurants.menu_items (menu_item_id INT, name TEXT, category TEXT); INSERT INTO chain_restaurants.menu_items (menu_item_id, name, category) VALUES (1, 'Cheeseburger', 'Meat'), (2, 'Fish Tacos', 'Seafood'), (3, 'Chicken Caesar Salad', 'Poultry');
Display the names of restaurants in the 'chain_restaurants' schema that do not serve any vegan dishes.
SELECT name FROM chain_restaurants.menu_items WHERE category NOT LIKE '%Vegan%';
gretelai_synthetic_text_to_sql
CREATE TABLE renewable_energy (region VARCHAR(20), energy_source VARCHAR(20), capacity INT, year INT); INSERT INTO renewable_energy (region, energy_source, capacity, year) VALUES ('New England', 'Solar', 1000, 2022), ('New England', 'Wind', 2000, 2022), ('New England', 'Hydro', 3000, 2022);
List all the renewable energy sources and their corresponding capacities in MW for the region of New England in 2022.
SELECT energy_source, capacity FROM renewable_energy WHERE region = 'New England' AND year = 2022;
gretelai_synthetic_text_to_sql
CREATE SCHEMA SpaceMissionsCost;CREATE TABLE ESA_Missions (MissionID INT, Agency VARCHAR(50), Cost FLOAT);INSERT INTO ESA_Missions VALUES (1, 'ESA', 1500000000), (2, 'ESA', 1800000000), (3, 'ESA', 2000000000);
What was the total cost of ESA missions between 2010 and 2020?
SELECT SUM(Cost) FROM ESA_Missions WHERE Agency = 'ESA' AND LaunchYear BETWEEN 2010 AND 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE tv_shows (id INT, title VARCHAR(50), country VARCHAR(50), budget DECIMAL(10,2));
List all countries with a TV show budget over $10M.
SELECT DISTINCT country FROM tv_shows WHERE budget > 10000000;
gretelai_synthetic_text_to_sql
CREATE TABLE Sales (Sale_ID INT, Strain TEXT, Retail_Price DECIMAL); INSERT INTO Sales (Sale_ID, Strain, Retail_Price) VALUES (1, 'White Widow', 18.00); CREATE TABLE Dispensaries (Dispensary_ID INT, Dispensary_Name TEXT, State TEXT); INSERT INTO Dispensaries (Dispensary_ID, Dispensary_Name, State) VALUES (1, 'Washington Weed', 'WA');
Rank the strains of cannabis flower by their average retail price per gram, in descending order in Washington.
SELECT Strain, AVG(Retail_Price) as Avg_Price, RANK() OVER (ORDER BY AVG(Retail_Price) DESC) as Rank FROM Sales JOIN Dispensaries ON Sales.State = Dispensaries.State WHERE State = 'WA' GROUP BY Strain;
gretelai_synthetic_text_to_sql
CREATE TABLE safety_tests_detailed (vehicle_model VARCHAR(10), safety_rating INT, year INT, test_number INT);
What is the difference in safety ratings between the latest and earliest tests for vehicle model 'M3'?
SELECT MAX(year) - MIN(year) AS years_diff, MAX(safety_rating) - MIN(safety_rating) AS safety_rating_diff FROM safety_tests_detailed WHERE vehicle_model = 'M3';
gretelai_synthetic_text_to_sql
CREATE TABLE employee_training (employee_id INT, training_date DATE, topic VARCHAR(50));
How many employees have been trained in circular economy principles since the beginning of the program?
SELECT COUNT(*) FROM employee_training WHERE topic = 'Circular Economy';
gretelai_synthetic_text_to_sql
CREATE TABLE Sensor (id INT, sensor_id INT, location VARCHAR(255)); INSERT INTO Sensor (id, sensor_id, location) VALUES (1, 1003, 'DE-BW');
What is the count of IoT sensors in "DE-BW" and "CH-AG"?
SELECT COUNT(DISTINCT sensor_id) FROM Sensor WHERE location IN ('DE-BW', 'CH-AG');
gretelai_synthetic_text_to_sql
CREATE TABLE Cosmetics (ProductID INT, ProductName VARCHAR(50), Price DECIMAL(5,2), IsCrueltyFree BIT); INSERT INTO Cosmetics (ProductID, ProductName, Price, IsCrueltyFree) VALUES (1, 'Lipstick', 15.99, 1), (2, 'Mascara', 12.49, 1), (3, 'Foundation', 25.99, 0);
What is the average price of cosmetic products that are cruelty-free certified?
SELECT AVG(Price) FROM Cosmetics WHERE IsCrueltyFree = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE solar_projects (id INT PRIMARY KEY, project_name VARCHAR(255), location VARCHAR(255), capacity_mw FLOAT, completion_date DATE);
What is the average capacity of completed solar projects?
SELECT AVG(capacity_mw) FROM solar_projects WHERE completion_date IS NOT NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE patents (id INT, country VARCHAR(50), filed_date DATE, patent_type VARCHAR(50)); INSERT INTO patents (id, country, filed_date, patent_type) VALUES (1, 'Iran', '2020-01-01', 'Military Tech'); INSERT INTO patents (id, country, filed_date, patent_type) VALUES (2, 'Saudi Arabia', '2019-05-01', 'Military Tech');
What is the total number of military technology patents filed by countries in the Middle East region in the last 2 years?
SELECT COUNT(*) FROM patents WHERE country IN ('Iran', 'Iraq', 'Saudi Arabia', 'Turkey', 'United Arab Emirates') AND filed_date >= (SELECT DATE_SUB(CURRENT_DATE, INTERVAL 2 YEAR)) AND patent_type = 'Military Tech';
gretelai_synthetic_text_to_sql
CREATE TABLE restaurants (id INT, name TEXT, location TEXT, offers_sustainable_seafood BOOLEAN); INSERT INTO restaurants (id, name, location, offers_sustainable_seafood) VALUES (1, 'Restaurant A', 'Texas', TRUE), (2, 'Restaurant B', 'Texas', FALSE), (3, 'Restaurant C', 'Texas', TRUE), (4, 'Restaurant D', 'California', FALSE), (5, 'Restaurant E', 'Texas', TRUE); CREATE TABLE orders (id INT, restaurant_id INT, revenue DECIMAL(5,2)); INSERT INTO orders (id, restaurant_id, revenue) VALUES (1, 1, 500.00), (2, 1, 700.00), (3, 2, 600.00), (4, 3, 1200.00), (5, 4, 900.00), (6, 5, 800.00);
What is the total revenue generated by restaurants in Texas offering sustainable seafood?
SELECT SUM(revenue) FROM restaurants INNER JOIN orders ON restaurants.id = orders.restaurant_id WHERE offers_sustainable_seafood = TRUE AND location = 'Texas';
gretelai_synthetic_text_to_sql
CREATE TABLE rural_infrastructure (id INT, name VARCHAR(50), type VARCHAR(50), budget FLOAT); INSERT INTO rural_infrastructure (id, name, type, budget) VALUES (1, 'Solar Irrigation', 'Agricultural Innovation', 150000.00), (2, 'Wind Turbines', 'Rural Infrastructure', 200000.00), (3, 'Drip Irrigation', 'Agricultural Innovation', 110000.00);
What are the names of the agricultural innovation projects in the 'rural_infrastructure' table that have a budget between 100000 and 200000?
SELECT name FROM rural_infrastructure WHERE type = 'Agricultural Innovation' AND budget > 100000 AND budget < 200000;
gretelai_synthetic_text_to_sql
CREATE TABLE wearable_tech (user_id INT, heart_rate INT, country VARCHAR(50)); INSERT INTO wearable_tech (user_id, heart_rate, country) VALUES (1, 70, 'South Korea'), (2, 75, 'South Korea'), (3, 80, 'South Korea'), (4, 65, 'South Korea'), (5, 60, 'South Korea'), (6, 55, 'South Korea');
What is the minimum heart rate of users from South Korea?
SELECT MIN(heart_rate) FROM wearable_tech WHERE country = 'South Korea';
gretelai_synthetic_text_to_sql
CREATE TABLE green_buildings (building_id INT, building_name VARCHAR(255), city VARCHAR(255), certification_date DATE);
List all green building certifications that have been issued in the city of Toronto.
SELECT building_name FROM green_buildings WHERE city = 'Toronto';
gretelai_synthetic_text_to_sql
CREATE TABLE Warehouses (id INT, warehouse_name VARCHAR(50), warehouse_location VARCHAR(50), warehouse_capacity INT); INSERT INTO Warehouses (id, warehouse_name, warehouse_location, warehouse_capacity) VALUES (1, 'London Warehouse', 'England', 5000), (2, 'Berlin Warehouse', 'Germany', 6000), (3, 'Paris Warehouse', 'France', 4000);
List all warehouses in Europe and their respective capacities.
SELECT warehouse_name, warehouse_capacity FROM Warehouses WHERE warehouse_location IN ('England', 'Germany', 'France');
gretelai_synthetic_text_to_sql
CREATE TABLE projects (id INT, CO2_reduction_tons INT); INSERT INTO projects (id, CO2_reduction_tons) VALUES (1, 1500), (2, 1200), (3, 500), (4, 2500);
Delete projects that have a CO2 emission reduction lower than 1500 metric tons.
DELETE FROM projects WHERE CO2_reduction_tons < 1500;
gretelai_synthetic_text_to_sql
autonomous_vehicles
List all the autonomous vehicles from the US
SELECT * FROM autonomous_vehicles WHERE country = 'United States';
gretelai_synthetic_text_to_sql
CREATE TABLE regions (id INT PRIMARY KEY, name VARCHAR(255));CREATE TABLE countries (id INT PRIMARY KEY, name VARCHAR(255), region_id INT, FOREIGN KEY (region_id) REFERENCES regions(id));CREATE TABLE tourism (id INT PRIMARY KEY, country_id INT, visitors INT, FOREIGN KEY (country_id) REFERENCES countries(id));CREATE TABLE biodiversity (id INT PRIMARY KEY, country_id INT, score INT, FOREIGN KEY (country_id) REFERENCES countries(id));
What is the average number of visitors to South American countries with the highest biodiversity score?
SELECT AVG(visitors) FROM tourism JOIN countries ON tourism.country_id = countries.id JOIN biodiversity ON countries.id = biodiversity.country_id WHERE biodiversity.score = (SELECT MAX(score) FROM biodiversity WHERE region_id = (SELECT id FROM regions WHERE name = 'South America'));
gretelai_synthetic_text_to_sql
CREATE TABLE ResilienceProjects (ProjectID int, Budget decimal(10,2), Year int); INSERT INTO ResilienceProjects (ProjectID, Budget, Year) VALUES (1, 500000, 2022), (2, 750000, 2022), (3, 600000, 2023);
What is the total budget for all resilience projects in 2022?
SELECT SUM(Budget) FROM ResilienceProjects WHERE Year = 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE solar_projects (project_id INT, project_name VARCHAR(255), completion_date DATE);
How many solar power projects were completed in the year 2020?
SELECT COUNT(*) FROM solar_projects WHERE YEAR(completion_date) = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE missions (mission_id INT, name VARCHAR(50), space_agency VARCHAR(50), launch_date DATE);
How many missions were launched by each space agency in 2020?
SELECT space_agency, COUNT(*) FROM missions WHERE EXTRACT(YEAR FROM launch_date) = 2020 GROUP BY space_agency;
gretelai_synthetic_text_to_sql
CREATE TABLE daily_production (id INT, country VARCHAR(255), mineral VARCHAR(255), date DATE, quantity INT); INSERT INTO daily_production (id, country, mineral, date, quantity) VALUES (1, 'Bolivia', 'Silver', '2022-01-01', 50), (2, 'Bolivia', 'Silver', '2022-01-02', 60), (3, 'Bolivia', 'Silver', '2022-01-03', 70);
What is the daily production rate of silver in Bolivia?
SELECT date, AVG(quantity) as daily_production_rate FROM daily_production WHERE country = 'Bolivia' AND mineral = 'Silver' GROUP BY date;
gretelai_synthetic_text_to_sql
CREATE TABLE smart_cities_2 (initiative_id INT, initiative_name TEXT, region TEXT); INSERT INTO smart_cities_2 (initiative_id, initiative_name, region) VALUES (1, 'Smart City A', 'South America'), (2, 'Smart City B', 'South America');
What is the total number of smart city initiatives in South America?
SELECT COUNT(*) FROM smart_cities_2 WHERE region = 'South America';
gretelai_synthetic_text_to_sql
CREATE TABLE broadband_subscribers (subscriber_id INT, subscriber_name VARCHAR(255), subscribe_date DATE, country VARCHAR(255));
How many broadband subscribers have there been in each country in the past month?
SELECT country, COUNT(subscriber_id) as total_subscribers FROM broadband_subscribers WHERE subscribe_date >= DATE_SUB(CURDATE(), INTERVAL 1 MONTH) GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE Bridges (id INT, name VARCHAR(100), length FLOAT, designer VARCHAR(100));
List the names of all bridges designed by the firm "Structural Integrity Inc." that have a length greater than 500 meters.
SELECT name FROM Bridges WHERE designer = 'Structural Integrity Inc.' AND length > 500;
gretelai_synthetic_text_to_sql
CREATE TABLE plants (plant_id INT, plant_name VARCHAR(50), department VARCHAR(50)); INSERT INTO plants (plant_id, plant_name, department) VALUES (1, 'PlantA', 'Manufacturing'), (2, 'PlantB', 'Engineering'), (3, 'PlantC', 'Manufacturing');
What is the total number of employees working in the 'Manufacturing' department across all plants?
SELECT SUM(plant_count) FROM (SELECT COUNT(*) AS plant_count FROM plants WHERE department = 'Manufacturing' GROUP BY plant_name) AS plant_summary;
gretelai_synthetic_text_to_sql
CREATE TABLE events (event_id INT, event_name VARCHAR(50), city VARCHAR(30), funding_source VARCHAR(30)); INSERT INTO events (event_id, event_name, city, funding_source) VALUES (1, 'Theater Play', 'Chicago', 'Local Arts Agency'), (2, 'Art Exhibit', 'New York', 'Private Donors'), (3, 'Music Festival', 'Chicago', 'Local Arts Agency'), (4, 'Dance Performance', 'Chicago', 'Local Arts Agency');
Show cities with the highest number of arts events funded by "Local Arts Agency"
SELECT city, COUNT(*) as num_events FROM events WHERE funding_source = 'Local Arts Agency' GROUP BY city ORDER BY num_events DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE film_representation (id INT, country VARCHAR(50), film_title VARCHAR(100), representation_score INT); INSERT INTO film_representation (id, country, film_title, representation_score) VALUES (1, 'Nigeria', 'Movie1', 75), (2, 'South Africa', 'Movie2', 85);
Update the representation data for films in Africa.
UPDATE film_representation SET representation_score = 90 WHERE country = 'Africa';
gretelai_synthetic_text_to_sql
CREATE TABLE Companies (id INT, name TEXT, industry TEXT, total_funding FLOAT, num_investments INT); INSERT INTO Companies (id, name, industry, total_funding, num_investments) VALUES (1, 'Acme Inc', 'Software', 2500000, 2), (2, 'Beta Corp', 'Software', 5000000, 1), (3, 'Gamma Startup', 'Hardware', 1000000, 3), (4, 'Delta LLC', 'Hardware', 2000000, 1);
Find the industry with the highest average total funding per company for companies that have had more than 1 investment round.
SELECT industry, AVG(total_funding) AS industry_avg_funding FROM Companies WHERE num_investments > 1 GROUP BY industry ORDER BY industry_avg_funding DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE texas_water_usage (id INT, building_type VARCHAR(20), day VARCHAR(10), consumption FLOAT); INSERT INTO texas_water_usage (id, building_type, day, consumption) VALUES (1, 'Residential', 'Monday', 1000), (2, 'Residential', 'Tuesday', 1500);
Find the minimum and maximum daily water consumption for residential buildings in Texas.
SELECT MIN(consumption), MAX(consumption) FROM texas_water_usage WHERE building_type = 'Residential';
gretelai_synthetic_text_to_sql
CREATE TABLE CommunityHealthWorker (ID INT, Name TEXT); INSERT INTO CommunityHealthWorker (ID, Name) VALUES (1, 'Leilani Kawakami'); INSERT INTO CommunityHealthWorker (ID, Name) VALUES (2, 'Kekoa Keliipaakaua'); INSERT INTO CommunityHealthWorker (ID, Name) VALUES (3, 'Noelani Ahia'); CREATE TABLE PatientCommunityHealthWorker (PatientID INT, CommunityHealthWorkerID INT, Ethnicity TEXT);
Identify the top three community health workers with the most unique patients served who identify as Native Hawaiian or Other Pacific Islander, along with the number of patients they have served.
SELECT CommunityHealthWorkerID, COUNT(DISTINCT PatientID) as PatientsServed FROM PatientCommunityHealthWorker WHERE Ethnicity = 'Native Hawaiian or Other Pacific Islander' GROUP BY CommunityHealthWorkerID ORDER BY PatientsServed DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE rural_infrastructure (id INT, project_name VARCHAR(255), budget FLOAT, state VARCHAR(50)); INSERT INTO rural_infrastructure (id, project_name, budget, state) VALUES (1, 'Road Maintenance', 95000.00, 'Bahia'), (2, 'Water Supply System', 120000.00, 'Bahia'), (3, 'Sanitation Services', 110000.00, 'Bahia');
What is the minimum budget for rural infrastructure projects in Brazil's Bahia state?
SELECT MIN(budget) FROM rural_infrastructure WHERE state = 'Bahia'
gretelai_synthetic_text_to_sql
CREATE TABLE country_grants (id INT, country VARCHAR(255), grant_amount INT); INSERT INTO country_grants (id, country, grant_amount) VALUES (1, 'USA', 100000), (2, 'Canada', 75000), (3, 'Mexico', 50000), (4, 'USA', 125000);
What is the total amount of research grants awarded to each country?
SELECT country, SUM(grant_amount) as total_grants FROM country_grants GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE circular_economy (initiative_type VARCHAR(50), year INT, initiative_count INT); INSERT INTO circular_economy (initiative_type, year, initiative_count) VALUES ('Composting', 2021, 50), ('Reuse', 2021, 40), ('Recycling', 2021, 60), ('Reduce', 2021, 30);
Circular economy initiatives count by type in 2021?
SELECT initiative_type, initiative_count FROM circular_economy WHERE year = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE inclusive_housing (id INT, community TEXT, price FLOAT); INSERT INTO inclusive_housing (id, community, price) VALUES (1, 'Sunshine Gardens', 250000), (2, 'Rainbow Village', 300000), (3, 'Harmony Heights', 275000), (4, 'Diversity Estates', 400000);
List the top 3 most affordable inclusive housing communities by median property price.
SELECT community, price FROM (SELECT community, price, ROW_NUMBER() OVER (ORDER BY price) rn FROM inclusive_housing) tmp WHERE rn <= 3;
gretelai_synthetic_text_to_sql
CREATE TABLE eco_friendly_products (product_id INT, product_name TEXT, price DECIMAL); INSERT INTO eco_friendly_products (product_id, product_name, price) VALUES (1, 'Organic Cotton Shirt', 30), (2, 'Bamboo Toothbrush', 5);
What is the minimum price of eco-friendly products?
SELECT MIN(price) FROM eco_friendly_products;
gretelai_synthetic_text_to_sql
CREATE TABLE tours (tour_id INT, name TEXT, city TEXT, country TEXT, carbon_footprint DECIMAL(5,2)); INSERT INTO tours (tour_id, name, city, country, carbon_footprint) VALUES (7, 'Amsterdam Canals Tour', 'Amsterdam', 'Netherlands', 2.5);
What is the average carbon footprint of tours in Amsterdam?
SELECT AVG(carbon_footprint) FROM tours WHERE city = 'Amsterdam';
gretelai_synthetic_text_to_sql
CREATE TABLE workplaces (id INT, state VARCHAR(2), safety_issues INT); INSERT INTO workplaces (id, state, safety_issues) VALUES (1, 'NY', 10), (2, 'CA', 5), (3, 'TX', 15), (4, 'FL', 8);
What is the average number of safety issues in workplaces per state?
SELECT state, AVG(safety_issues) OVER (PARTITION BY state) AS avg_safety_issues FROM workplaces;
gretelai_synthetic_text_to_sql
CREATE TABLE Sports (sport_id INT, sport_name VARCHAR(50)); CREATE TABLE Tickets (ticket_id INT, sport_id INT, quantity INT, purchase_date DATE);
Create a view showing the number of tickets sold per quarter for each sport.
CREATE VIEW quarterly_sales AS SELECT sport_id, EXTRACT(QUARTER FROM purchase_date) as quarter, EXTRACT(YEAR FROM purchase_date) as year, SUM(quantity) as total_sales FROM Tickets GROUP BY sport_id, quarter, year;
gretelai_synthetic_text_to_sql
CREATE TABLE vessels (id INT, name TEXT, length FLOAT, year INT, region TEXT); INSERT INTO vessels (id, name, length, year, region) VALUES (1, 'Vessel A', 65.2, 2020, 'Mediterranean Sea'), (2, 'Vessel B', 48.9, 2020, 'Mediterranean Sea'), (3, 'Vessel C', 70.1, 2019, 'Mediterranean Sea');
How many vessels were reported in the Mediterranean Sea in 2020 with a length greater than 50 meters?
SELECT COUNT(*) FROM vessels WHERE region = 'Mediterranean Sea' AND length > 50 AND year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE engineer_grants (researcher_id INT, researcher_gender VARCHAR(10), grant_amount DECIMAL(10,2)); INSERT INTO engineer_grants (researcher_id, researcher_gender, grant_amount) VALUES (1, 'Female', 50000.00), (2, 'Male', 75000.00), (3, 'Female', 60000.00);
What is the average grant amount awarded to female researchers in the College of Engineering?
SELECT AVG(grant_amount) FROM engineer_grants WHERE researcher_gender = 'Female';
gretelai_synthetic_text_to_sql
CREATE TABLE inventory(id INT PRIMARY KEY, product VARCHAR(50), quantity INT, organic BOOLEAN, product_type VARCHAR(50)); INSERT INTO inventory(id, product, quantity, organic, product_type) VALUES (1, 'apples', 100, TRUE, 'fruit'), (2, 'bananas', 200, FALSE, 'fruit'), (3, 'oranges', 150, TRUE, 'fruit'), (4, 'carrots', 250, TRUE, 'vegetable'), (5, 'broccoli', 300, FALSE, 'vegetable'); CREATE TABLE product_types(id INT PRIMARY KEY, type VARCHAR(50)); INSERT INTO product_types(id, type) VALUES (1, 'fruit'), (2, 'vegetable'), (3, 'meat'), (4, 'dairy');
Determine the percentage of organic products in the inventory for each product type.
SELECT pt.type, AVG(CASE WHEN i.organic THEN 100.0 ELSE 0.0 END) AS percentage_organic FROM inventory i JOIN product_types pt ON i.product_type = pt.type GROUP BY pt.type;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_life_research(id INT, species VARCHAR(50), population INT); INSERT INTO marine_life_research(id, species, population) VALUES (1, 'Beluga Whale', 250), (2, 'Whale Shark', 300), (3, 'Dolphin', 600), (4, 'Yellowfin Tuna', 500);
What is the total population of marine life research data entries for species that have the word 'Tuna' in their name?
SELECT SUM(population) FROM marine_life_research WHERE species LIKE '%Tuna%';
gretelai_synthetic_text_to_sql
CREATE TABLE Inventory (InventoryID INT, Product TEXT, Price DECIMAL, State TEXT); INSERT INTO Inventory (InventoryID, Product, Price, State) VALUES (1, 'Cannabis Flower', 15.00, 'Washington'); INSERT INTO Inventory (InventoryID, Product, Price, State) VALUES (2, 'Cannabis Flower', 20.00, 'Washington');
What is the average price per gram of cannabis flower in Washington?
SELECT AVG(Price) FROM Inventory WHERE Product = 'Cannabis Flower' AND State = 'Washington';
gretelai_synthetic_text_to_sql
CREATE TABLE depth_zones (id INT, depth_zone TEXT, species_count INT); INSERT INTO depth_zones (id, depth_zone, species_count) VALUES (1, '0-1000m', 500), (2, '1000-2000m', 300), (3, '2000-3000m', 150);
What is the trend of marine species richness in different depth zones?
SELECT depth_zone, AVG(species_count) OVER (ORDER BY depth_zone ROWS BETWEEN UNBOUNDED PRECEDING AND 1 PRECEDING) AS avg_species_count FROM depth_zones;
gretelai_synthetic_text_to_sql
CREATE TABLE hospitalizations (id INT, cause_illness VARCHAR(255), year INT); INSERT INTO hospitalizations VALUES (1, 'Pneumonia', 2020), (2, 'Heart disease', 2020), (3, 'Pneumonia', 2020);
What is the number of hospitalizations by cause of illness in 2020?
SELECT cause_illness, COUNT(*) AS hospitalizations FROM hospitalizations WHERE year = 2020 GROUP BY cause_illness;
gretelai_synthetic_text_to_sql
CREATE TABLE Depots (DepotID INT, DepotName VARCHAR(50)); CREATE TABLE Vehicles (VehicleID INT, DepotID INT, VehicleType VARCHAR(50), IsWheelchairAccessible BIT); INSERT INTO Depots (DepotID, DepotName) VALUES (1, 'DepotA'), (2, 'DepotB'), (3, 'DepotC'); INSERT INTO Vehicles (VehicleID, DepotID, VehicleType, IsWheelchairAccessible) VALUES (1, 1, 'Bus', 1), (2, 1, 'Bus', 0), (3, 2, 'Tram', 1), (4, 2, 'Tram', 1), (5, 3, 'Bus', 0);
How many wheelchair-accessible vehicles are available in each depot?
SELECT D.DepotName, COUNT(V.VehicleID) AS WheelchairAccessibleVehicles FROM Depots D JOIN Vehicles V ON D.DepotID = V.DepotID WHERE V.IsWheelchairAccessible = 1 GROUP BY D.DepotName;
gretelai_synthetic_text_to_sql
CREATE TABLE programs (id INT, type VARCHAR(20)); INSERT INTO programs (id, type) VALUES (1, 'Painting'), (2, 'Sculpture'), (3, 'Music'); CREATE TABLE funding (id INT, program_id INT, source VARCHAR(25)); INSERT INTO funding (id, program_id, source) VALUES (1, 1, 'Grant 1'), (2, 1, 'Grant 2'), (3, 2, 'Donation'), (4, 3, 'Sponsorship'), (5, 3, 'Crowdfunding');
Find the number of unique funding sources supporting visual arts programs and music events.
SELECT COUNT(DISTINCT f.source) FROM funding f WHERE f.program_id IN (SELECT p.id FROM programs p WHERE p.type IN ('Visual Arts', 'Music'));
gretelai_synthetic_text_to_sql
CREATE TABLE community_development (id INT, initiative_type VARCHAR(50), budget INT, start_year INT); INSERT INTO community_development (id, initiative_type, budget, start_year) VALUES (1, 'Education', 50000, 2020); INSERT INTO community_development (id, initiative_type, budget, start_year) VALUES (2, 'Housing', 75000, 2019);
What is the total budget for community development initiatives in 'community_development' table, grouped by year?
SELECT start_year, SUM(budget) FROM community_development GROUP BY start_year;
gretelai_synthetic_text_to_sql
CREATE TABLE Vehicle_Types (Id INT, Name VARCHAR(50)); CREATE TABLE Vehicle_Releases (Id INT, Name VARCHAR(50), Release_Date DATE, Origin_Country VARCHAR(50), CO2_Emission INT, Vehicle_Type_Id INT);
What is the average CO2 emission of hybrid vehicles in the United Kingdom?
SELECT AVG(CO2_Emission) FROM Vehicle_Releases WHERE Vehicle_Type_Id = (SELECT Id FROM Vehicle_Types WHERE Name = 'Hybrid') AND Origin_Country = 'United Kingdom';
gretelai_synthetic_text_to_sql
CREATE TABLE electric_scooters (id INT, scooter_type VARCHAR(255), range INT); INSERT INTO electric_scooters (id, scooter_type, range) VALUES (1, 'Stand-Up', 20);
What is the minimum range of electric scooters in the "electric_scooters" table?
SELECT MIN(range) FROM electric_scooters WHERE scooter_type = 'Stand-Up';
gretelai_synthetic_text_to_sql
CREATE TABLE rd_expenditure (id INT, drug_name VARCHAR(255), region VARCHAR(255), expenditure DECIMAL(10,2), expenditure_year INT); INSERT INTO rd_expenditure (id, drug_name, region, expenditure, expenditure_year) VALUES (1, 'DrugF', 'North America', 50000, 2018); INSERT INTO rd_expenditure (id, drug_name, region, expenditure, expenditure_year) VALUES (2, 'DrugF', 'North America', 60000, 2019);
What are the total R&D expenditures for a specific drug in the past 5 years, regardless of region?
SELECT SUM(expenditure) FROM rd_expenditure WHERE drug_name = 'DrugF' AND expenditure_year BETWEEN (YEAR(CURRENT_DATE) - 5) AND YEAR(CURRENT_DATE);
gretelai_synthetic_text_to_sql
CREATE TABLE security_incidents (id INT, country VARCHAR(255), incident_time TIMESTAMP); INSERT INTO security_incidents (id, country, incident_time) VALUES (1, 'USA', '2022-02-03 12:30:00'), (2, 'Canada', '2022-02-01 14:15:00'), (3, 'Mexico', '2022-02-05 09:20:00');
What are the top 3 countries where most security incidents occurred in the past month?
SELECT country, COUNT(*) as count FROM security_incidents WHERE incident_time >= DATE_SUB(CURRENT_TIMESTAMP(), INTERVAL 1 MONTH) GROUP BY country ORDER BY count DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE products (product_id INT, segment VARCHAR(20), price DECIMAL(5,2)); INSERT INTO products (product_id, segment, price) VALUES (1, 'Natural', 15.99), (2, 'Organic', 20.99), (3, 'Natural', 12.49);
What is the total price of products in the Organic segment?
SELECT SUM(price) FROM products WHERE segment = 'Organic';
gretelai_synthetic_text_to_sql
CREATE TABLE products (product_id INT, product_type VARCHAR(50), price DECIMAL(5,2)); INSERT INTO products VALUES (1, 'Organic Skincare', 35.99), (2, 'Organic Skincare', 20.99), (3, 'Natural Makeup', 15.49), (4, 'Natural Makeup', 22.50), (5, 'Organic Skincare', 50.00), (6, 'Natural Makeup', 9.99), (7, 'Cruelty-Free', 12.35), (8, 'Organic Skincare', 14.55), (9, 'Cruelty-Free', 18.99), (10, 'Cruelty-Free', 25.00);
What is the maximum price of organic skincare products?
SELECT MAX(p.price) FROM products p WHERE p.product_type = 'Organic Skincare';
gretelai_synthetic_text_to_sql
CREATE TABLE chemical_production_new2 (id INT PRIMARY KEY, chemical_name VARCHAR(50), quantity INT, production_date DATE);
Find the chemical with the lowest quantity produced in the last 30 days.
SELECT chemical_name, MIN(quantity) as min_quantity FROM chemical_production_new2 WHERE production_date > CURDATE() - INTERVAL 30 DAY GROUP BY chemical_name LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE legal_aid (id INT, state VARCHAR(20), year INT, case_number INT); INSERT INTO legal_aid (id, state, year, case_number) VALUES (1, 'Texas', 2021, 123), (2, 'California', 2020, 456), (3, 'Texas', 2021, 789);
How many legal aid cases were opened in the state of Texas in 2021?
SELECT SUM(case_number) FROM legal_aid WHERE state = 'Texas' AND year = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE ArtistWorks (id INT, artist VARCHAR(50), domain VARCHAR(50), quantity INT); INSERT INTO ArtistWorks (id, artist, domain, quantity) VALUES (1, 'Banksy', 'Contemporary', 30), (2, 'Shepard Fairey', 'Contemporary', 40), (3, 'Yayoi Kusama', 'Contemporary', 50);
Who is the most prolific artist in the contemporary art domain?
SELECT artist, MAX(quantity) FROM ArtistWorks WHERE domain = 'Contemporary';
gretelai_synthetic_text_to_sql
CREATE TABLE clinical_trials (drug_name TEXT, year INTEGER, trial_count INTEGER);
Identify the number of clinical trials per year for a specific drug.
SELECT year, COUNT(*) AS trials_per_year FROM clinical_trials WHERE drug_name = 'DrugX' GROUP BY year ORDER BY year;
gretelai_synthetic_text_to_sql
CREATE TABLE artist (artist_id INT, artist_name VARCHAR(50), followers INT); INSERT INTO artist (artist_id, artist_name, followers) VALUES (1, 'Artist A', 120000), (2, 'Artist B', 80000); CREATE TABLE song (song_id INT, song_name VARCHAR(50), artist_id INT); INSERT INTO song (song_id, song_name, artist_id) VALUES (1, 'Song 1', 1), (2, 'Song 2', 2), (3, 'Song 3', 1);
How many songs were released by artists who have more than 100k followers on a social media platform?
SELECT COUNT(s.song_id) FROM song s JOIN artist a ON s.artist_id = a.artist_id WHERE a.followers > 100000;
gretelai_synthetic_text_to_sql
CREATE TABLE community_engagement (id INT PRIMARY KEY, site_id INT, status VARCHAR(255));
Update the community engagement status of a heritage site
UPDATE community_engagement SET status = 'Active' WHERE site_id = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE VirtualTourism (TourismID int, Location varchar(50), JobsCreated int); INSERT INTO VirtualTourism (TourismID, Location, JobsCreated) VALUES (1, 'India', 500); INSERT INTO VirtualTourism (TourismID, Location, JobsCreated) VALUES (2, 'Japan', 600); INSERT INTO VirtualTourism (TourismID, Location, JobsCreated) VALUES (3, 'Brazil', 700);
How many jobs have been created by virtual tourism in India, Japan, and Brazil?
SELECT SUM(JobsCreated) FROM VirtualTourism WHERE Location IN ('India', 'Japan', 'Brazil')
gretelai_synthetic_text_to_sql
CREATE TABLE clean_energy_policy_trends (id INT, policy_type VARCHAR(255), start_year INT, end_year INT, description TEXT);
Update the 'end_year' of all records in the 'clean_energy_policy_trends' table where the 'policy_type' is 'Standard' to 2028
UPDATE clean_energy_policy_trends SET end_year = 2028 WHERE policy_type = 'Standard';
gretelai_synthetic_text_to_sql
CREATE TABLE departments (id INT, name VARCHAR(255)); INSERT INTO departments (id, name) VALUES (1, 'HR'), (2, 'Operations'), (3, 'Engineering'); CREATE TABLE employees (id INT, name VARCHAR(255), department_id INT); INSERT INTO employees (id, name, department_id) VALUES (1, 'John', 2), (2, 'Jane', 3), (3, 'Mike', 1), (4, 'Lucy', 2);
What's the total number of employees by department for the mining company?
SELECT e.department_id, COUNT(e.id) as total FROM employees e GROUP BY e.department_id;
gretelai_synthetic_text_to_sql