context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE Manufacturers (id INT, name VARCHAR(255)); INSERT INTO Manufacturers (id, name) VALUES (1, 'Wayve'); INSERT INTO Manufacturers (id, name) VALUES (2, 'Cruise'); CREATE TABLE Autonomous_Vehicles (id INT, manufacturer_id INT, city_id INT, year INT, units INT); INSERT INTO Autonomous_Vehicles (id, manufacturer...
Which manufacturers produced autonomous vehicles in cities 1 or 2 in the year 2022, and what is the total number of units produced?
SELECT Manufacturers.name, SUM(Autonomous_Vehicles.units) FROM Manufacturers JOIN Autonomous_Vehicles ON Manufacturers.id = Autonomous_Vehicles.manufacturer_id WHERE (Autonomous_Vehicles.city_id = 1 OR Autonomous_Vehicles.city_id = 2) AND Autonomous_Vehicles.year = 2022 GROUP BY Manufacturers.name;
gretelai_synthetic_text_to_sql
CREATE TABLE Carbon_Offset_Initiatives (id INT, initiative_name VARCHAR(50), district VARCHAR(50)); INSERT INTO Carbon_Offset_Initiatives (id, initiative_name, district) VALUES (1, 'Tree Planting', 'Downtown'), (2, 'Recycling Program', 'Uptown'), (3, 'Solar Panels', 'Suburbs'), (4, 'Green Roofs', NULL);
Which smart city districts have no carbon offset initiatives?
SELECT district FROM Carbon_Offset_Initiatives WHERE district IS NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE Products (id INT, name VARCHAR(255), is_cruelty_free BOOLEAN, rating INT);
Increase the rating of products that are cruelty-free by 1.
UPDATE Products SET rating = rating + 1 WHERE is_cruelty_free = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE bike_stations (station_id INT, station_name VARCHAR(50), station_city VARCHAR(50));
List all cities in the database that have a bike-sharing program.
SELECT DISTINCT station_city FROM bike_stations WHERE station_name LIKE '%bike-sharing%';
gretelai_synthetic_text_to_sql
CREATE TABLE media_library (id INT, type VARCHAR(10), title VARCHAR(50), length FLOAT, source VARCHAR(50)); INSERT INTO media_library (id, type, title, length, source) VALUES (1, 'article', 'Sample Article 1', 5.5, 'BBC'); INSERT INTO media_library (id, type, title, length, source) VALUES (2, 'video', 'Sample Video 1',...
What are the distinct sources of articles and videos in the 'media_library'?
SELECT DISTINCT source FROM media_library WHERE type IN ('article', 'video');
gretelai_synthetic_text_to_sql
CREATE TABLE album_sales (id INT, album_name VARCHAR(50), artist_name VARCHAR(50), genre VARCHAR(20), revenue FLOAT);
Show the total revenue for each music genre in descending order.
SELECT genre, SUM(revenue) AS total_revenue FROM album_sales GROUP BY genre ORDER BY total_revenue DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE Company (id INT, name TEXT, industry TEXT, founding_date DATE, gender TEXT); INSERT INTO Company (id, name, industry, founding_date, gender) VALUES (1, 'Acme Inc', 'Tech', '2016-01-02', 'Female'); INSERT INTO Company (id, name, industry, founding_date, gender) VALUES (2, 'Wright Startups', 'Transport', '20...
What is the average funding amount for female-led companies founded after 2016?
SELECT Company.gender, AVG(Funding.amount) FROM Company INNER JOIN Funding ON Company.id = Funding.company_id WHERE Company.founding_date > '2016-01-01' AND Company.gender = 'Female' GROUP BY Company.gender;
gretelai_synthetic_text_to_sql
CREATE TABLE Ingredients (IngredientID int, IngredientName varchar(50), Quantity int, ExpirationDate date, SupplierID int); INSERT INTO Ingredients (IngredientID, IngredientName, Quantity, ExpirationDate, SupplierID) VALUES (1, 'Lettuce', 50, '2023-01-01', 1), (2, 'Tomatoes', 75, '2023-01-15', 1), (3, 'Chicken', 100, '...
What is the total quantity of expired ingredients for each supplier?
SELECT S.SupplierName, SUM(I.Quantity) as TotalExpiredIngredients FROM Ingredients I INNER JOIN Suppliers S ON I.SupplierID = S.SupplierID WHERE I.ExpirationDate < CURDATE() GROUP BY S.SupplierName;
gretelai_synthetic_text_to_sql
CREATE TABLE haynesville_shale_gas_production (year INT, region VARCHAR(20), production_volume INT); INSERT INTO haynesville_shale_gas_production (year, region, production_volume) VALUES (2015, 'Haynesville Shale', 3000000), (2016, 'Haynesville Shale', 3300000), (2017, 'Haynesville Shale', 3600000), (2018, 'Haynesville...
How much natural gas was extracted from the Haynesville Shale in 2020?
SELECT production_volume FROM haynesville_shale_gas_production WHERE year = 2020 AND region = 'Haynesville Shale';
gretelai_synthetic_text_to_sql
CREATE TABLE asian_sustainable_hotels (id INT, name TEXT, country TEXT, reviews INT); INSERT INTO asian_sustainable_hotels (id, name, country, reviews) VALUES (1, 'Eco-Retreat', 'Japan', 80), (2, 'Green-Resort', 'Thailand', 70), (3, 'Nature-Lodge', 'Indonesia', 90);
What is the minimum number of reviews for sustainable hotels in Asia?
SELECT MIN(reviews) as min_reviews FROM asian_sustainable_hotels;
gretelai_synthetic_text_to_sql
CREATE TABLE cities (name TEXT, population INTEGER, state TEXT); INSERT INTO cities (name, population, state) VALUES ('CityA', 50000, 'Colorado'), ('CityB', 75000, 'Colorado'), ('CityC', 60000, 'Colorado'), ('CityD', 80000, 'Colorado'), ('CityE', 45000, 'Colorado');
What is the name and population of the city with the largest population in Colorado?
SELECT name, population FROM cities WHERE state = 'Colorado' ORDER BY population DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE county (name VARCHAR(50), population INT, avg_distance_to_care FLOAT); INSERT INTO county (name, population, avg_distance_to_care) VALUES ('Greenfield', 4000, 25.3); INSERT INTO county (name, population, avg_distance_to_care) VALUES ('Pineville', 5000, 31.1); INSERT INTO county (name, population, avg_dista...
What is the average distance traveled for healthcare services by residents in the rural county of "Greenfield"?
SELECT AVG(avg_distance_to_care) FROM county WHERE name = 'Greenfield';
gretelai_synthetic_text_to_sql
CREATE TABLE music_albums (id INT, album_name VARCHAR(50), release_year INT);
Update the release year of album id 2 to 2022 in the music_albums table
UPDATE music_albums SET release_year = 2022 WHERE id = 2;
gretelai_synthetic_text_to_sql
CREATE TABLE ocean_temperature (location VARCHAR(255), temperature FLOAT, date DATE);
What is the maximum surface temperature recorded in the Red Sea?
SELECT MAX(temperature) FROM ocean_temperature WHERE location = 'Red Sea';
gretelai_synthetic_text_to_sql
CREATE TABLE Research (id INT, project VARCHAR(255), location VARCHAR(255), start_date DATE, end_date DATE); INSERT INTO Research (id, project, location, start_date, end_date) VALUES (5, 'Indian Ocean Research', 'Indian Ocean', '2021-01-01', '2021-06-30'); INSERT INTO Research (id, project, location, start_date, end_da...
What is the average duration of marine research projects in the Indian Ocean?
SELECT location, AVG(DATEDIFF(end_date, start_date)) as average_duration FROM Research WHERE location = 'Indian Ocean' GROUP BY location;
gretelai_synthetic_text_to_sql
CREATE TABLE australian_plant_additions (date DATE, plant_id INT); INSERT INTO australian_plant_additions (date, plant_id) VALUES ('2020-01-01', 100), ('2020-02-01', 101), ('2020-03-01', 102), ('2020-04-01', 103);
How many water treatment plants were added in each month in Australia?
SELECT EXTRACT(MONTH FROM date) AS month, COUNT(plant_id) AS plants_added FROM australian_plant_additions GROUP BY month;
gretelai_synthetic_text_to_sql
CREATE TABLE animal_population (animal_id INT, animal_name VARCHAR(50), program VARCHAR(50)); INSERT INTO animal_population (animal_id, animal_name, program) VALUES (1, 'Grizzly Bear', 'habitat_preservation'), (2, 'Gray Wolf', 'community_education');
Calculate the total number of animals in the 'habitat_preservation' program
SELECT COUNT(*) FROM animal_population WHERE program = 'habitat_preservation';
gretelai_synthetic_text_to_sql
CREATE TABLE Wells (WellID INT, WellName VARCHAR(50), ProductionRate FLOAT, Location VARCHAR(50)); INSERT INTO Wells (WellID, WellName, ProductionRate, Location) VALUES (1, 'Well A', 500, 'Onshore'), (2, 'Well B', 600, 'Offshore'), (3, 'Well C', 700, 'Onshore');
What is the average production rate per well for offshore wells?
SELECT AVG(ProductionRate) AS AvgProductionRate FROM Wells WHERE Location = 'Offshore';
gretelai_synthetic_text_to_sql
CREATE TABLE clients (client_id INT, segment VARCHAR(20)); INSERT INTO clients (client_id, segment) VALUES (1, 'High Value'), (2, 'Low Value'), (3, 'High Value'); CREATE TABLE accounts (account_number INT, client_id INT, balance DECIMAL(10,2)); INSERT INTO accounts (account_number, client_id, balance) VALUES (1, 1, 100...
What is the average account balance for clients in the 'High Value' segment?
SELECT AVG(a.balance) FROM accounts a INNER JOIN clients c ON a.client_id = c.client_id WHERE c.segment = 'High Value';
gretelai_synthetic_text_to_sql
CREATE TABLE space_debris (id INT, name VARCHAR(255), mass FLOAT, type VARCHAR(255)); INSERT INTO space_debris (id, name, mass, type) VALUES (1, 'Dead Satellite 1', 1500.0, 'Intact'), (2, 'Rocket Stage 1', 500.0, 'Inoperable'), (3, 'Fractured Debris 1', 20.0, 'Unknown');
What is the total mass of space debris in orbit?
SELECT SUM(mass) FROM space_debris;
gretelai_synthetic_text_to_sql
CREATE TABLE department (id INT, name TEXT); INSERT INTO department (id, name) VALUES (1, 'Operations'), (2, 'Engineering'), (3, 'HR'); CREATE TABLE employee (id INT, name TEXT, department_id INT, sexual_orientation TEXT); INSERT INTO employee (id, name, department_id, sexual_orientation) VALUES (1, 'John Doe', 1, 'Het...
What is the percentage of employees who identify as LGBTQ+ in each department?
SELECT department_id, sexual_orientation, COUNT(*) as num_employees, ROUND(COUNT(*) * 100.0 / (SELECT COUNT(*) FROM employee WHERE department_id = department.id), 2) as percentage FROM employee WHERE sexual_orientation LIKE '%LGBTQ%' GROUP BY department_id, sexual_orientation;
gretelai_synthetic_text_to_sql
CREATE TABLE bi_annual_chemicals (manufacturer_id INT, chemical_id INT, chemical_type VARCHAR(50), quarter INT, weight FLOAT); INSERT INTO bi_annual_chemicals (manufacturer_id, chemical_id, chemical_type, quarter, weight) VALUES (1, 1, 'Acid', 1, 150.5), (1, 1, 'Acid', 2, 155.6), (1, 1, 'Acid', 3, 160.3), (1, 1, 'Acid'...
Calculate the percentage change in weight of each chemical produced by the same manufacturer, between the last two quarters of the year
SELECT a.manufacturer_id, a.chemical_id, a.chemical_type, a.quarter, a.weight, b.weight, ((a.weight - b.weight) / b.weight) * 100 as percentage_change FROM bi_annual_chemicals a JOIN bi_annual_chemicals b ON a.manufacturer_id = b.manufacturer_id AND a.chemical_id = b.chemical_id WHERE a.quarter = 4 AND b.quarter = 3;
gretelai_synthetic_text_to_sql
CREATE TABLE student_mental_health (student_id INT, mental_health_score INT, measurement_date DATE); INSERT INTO student_mental_health (student_id, mental_health_score, measurement_date) VALUES (1, 70, '2022-01-01'), (1, 75, '2022-01-02'), (2, 60, '2022-01-01'), (2, 65, '2022-01-02'), (3, 80, '2022-01-01'), (3, 85, '20...
Which students have a higher mental health score than their previous record?
SELECT student_id, mental_health_score, measurement_date, LAG(mental_health_score) OVER (PARTITION BY student_id ORDER BY measurement_date) as prev_score FROM student_mental_health;
gretelai_synthetic_text_to_sql
CREATE TABLE CoOwnership (id INT, property_id INT, coowner VARCHAR(30), contact_info VARCHAR(50)); CREATE TABLE Property (id INT, city VARCHAR(20)); INSERT INTO CoOwnership (id, property_id, coowner, contact_info) VALUES (1, 1001, 'Alex', 'alex@email.com'), (2, 1001, 'Jamie', 'jamie@email.com'); INSERT INTO Property (i...
List all property co-ownerships in the "InclusiveCity" schema, including co-owners' names and contact information.
SELECT CoOwnership.coowner, CoOwnership.contact_info, Property.city FROM CoOwnership INNER JOIN Property ON CoOwnership.property_id = Property.id WHERE Property.city = 'InclusiveCity';
gretelai_synthetic_text_to_sql
CREATE TABLE pollution (id INT, location VARCHAR(255), pollutant_level INT, date DATE); INSERT INTO pollution (id, location, pollutant_level, date) VALUES (1, 'Norway', 50, '2021-01-01'), (2, 'Sweden', 60, '2022-01-01');
What is the location with the highest average pollutant level in 2022?
SELECT location, AVG(pollutant_level) as avg_pollutant FROM pollution WHERE date >= '2022-01-01' AND date <= '2022-12-31' GROUP BY location ORDER BY avg_pollutant DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE products (product_id INT, product_name VARCHAR(255), product_category VARCHAR(255)); INSERT INTO products (product_id, product_name, product_category) VALUES (1, 'Product A', 'Category X'), (2, 'Product B', 'Category X'), (3, 'Product C', 'Category Y'), (4, 'Product D', 'Category Y'); CREATE TABLE producti...
Get the average monthly production output for each product category
SELECT product_category, AVG(production_output) as avg_monthly_output FROM production p JOIN products pr ON p.product_id = pr.product_id GROUP BY product_category, EXTRACT(MONTH FROM production_date), EXTRACT(YEAR FROM production_date);
gretelai_synthetic_text_to_sql
CREATE TABLE oceans (name TEXT, depth FLOAT, surface_area FLOAT); INSERT INTO oceans (name, depth, surface_area) VALUES ('Pacific Ocean', 4000, 165200000); INSERT INTO oceans (name, depth, surface_area) VALUES ('Atlantic Ocean', 3500, 82300000); INSERT INTO oceans (name, depth, surface_area) VALUES ('Indian Ocean', 350...
What is the minimum depth of the Indian Ocean?
SELECT MIN(depth) FROM oceans WHERE name = 'Indian Ocean';
gretelai_synthetic_text_to_sql
CREATE TABLE drug_approvals (year INT, drug_name VARCHAR(255)); INSERT INTO drug_approvals (year, drug_name) VALUES ('2013', 'DrugA'), ('2014', 'DrugB'), ('2015', 'DrugC');
Delete drug approvals from 2014.
DELETE FROM drug_approvals WHERE year = 2014;
gretelai_synthetic_text_to_sql
CREATE TABLE donors (donor_id INT, donor_name TEXT, donation_amount FLOAT, cause TEXT, donation_date DATE);
List the donations made by 'Jane Smith' to healthcare causes in 2020.
SELECT * FROM donors WHERE donor_name = 'Jane Smith' AND cause = 'Healthcare' AND donation_date BETWEEN '2020-01-01' AND '2020-12-31';
gretelai_synthetic_text_to_sql
CREATE TABLE Green_Buildings (id INT, project_name VARCHAR(50), construction_year INT); INSERT INTO Green_Buildings (id, project_name, construction_year) VALUES (1, 'Solar Tower', 2010), (2, 'Wind Powered Hotel', 2020), (3, 'Eco-friendly Apartments', 1999);
Delete green building projects that were constructed before 2000.
DELETE FROM Green_Buildings WHERE construction_year < 2000;
gretelai_synthetic_text_to_sql
CREATE TABLE oil_production (id INT, well_name VARCHAR(50), location VARCHAR(50), company VARCHAR(50), production_type VARCHAR(10), production_quantity INT, production_date DATE, company_headquarters VARCHAR(50)); INSERT INTO oil_production VALUES (5, 'Well T', 'Russia', 'ABC Oil', 'Oil', 500000, '2021-01-01', 'Moscow'...
List the total oil production in Russia by companies with headquarters in Moscow for 2021
SELECT SUM(production_quantity) FROM oil_production WHERE location = 'Russia' AND production_type = 'Oil' AND company_headquarters = 'Moscow' AND production_date BETWEEN '2021-01-01' AND '2021-12-31';
gretelai_synthetic_text_to_sql
CREATE TABLE donors (donor_id INT, donor_name TEXT, donation_amount DECIMAL(10,2), country TEXT); INSERT INTO donors (donor_id, donor_name, donation_amount, country) VALUES (1, 'John Doe', 500.00, 'United States'); INSERT INTO donors (donor_id, donor_name, donation_amount, country) VALUES (2, 'Jane Smith', 300.00, 'Can...
What is the maximum donation amount from donors living in 'India'?
SELECT MAX(donation_amount) FROM donors WHERE country = 'India';
gretelai_synthetic_text_to_sql
CREATE TABLE factories (factory_id INT, location VARCHAR(50), labor_cost DECIMAL(10,2)); INSERT INTO factories (factory_id, location, labor_cost) VALUES (1, 'Buenos Aires', 500), (2, 'Lima', 450), (3, 'Mexico City', 520); CREATE TABLE products_factories (product_id INT, factory_id INT); INSERT INTO products_factories (...
What is the total revenue for products made in Latin America?
SELECT SUM(sales.revenue) FROM sales JOIN products_factories ON sales.product_id = products_factories.product_id JOIN factories ON products_factories.factory_id = factories.factory_id WHERE factories.location LIKE '%Latin America%';
gretelai_synthetic_text_to_sql
CREATE TABLE MilitaryTechnology (id INT, country VARCHAR(255), program VARCHAR(255), budget FLOAT); INSERT INTO MilitaryTechnology (id, country, program, budget) VALUES (1, 'United Kingdom', 'F-35B Lightning II', 3500000); INSERT INTO MilitaryTechnology (id, country, program, budget) VALUES (2, 'United Kingdom', 'Type ...
What is the budget for each military technology program in the United Kingdom?
SELECT program, budget FROM MilitaryTechnology WHERE country = 'United Kingdom';
gretelai_synthetic_text_to_sql
CREATE TABLE habitat (id INT, location TEXT, size FLOAT); CREATE TABLE animal_population (id INT, habitat_id INT, animal_count INT);
What is the total number of animals in habitats located in Africa and Australia?
SELECT SUM(ap.animal_count) FROM animal_population ap INNER JOIN habitat h ON ap.habitat_id = h.id WHERE h.location IN ('Africa', 'Australia');
gretelai_synthetic_text_to_sql
CREATE TABLE Locations (LocId INT, Type VARCHAR(50)); CREATE TABLE Crimes (CrimeId INT, LocId INT, Date DATE);
How many crimes were committed in each type of location?
SELECT L.Type, COUNT(C.CrimeId) FROM Locations L INNER JOIN Crimes C ON L.LocId = C.LocId GROUP BY L.Type;
gretelai_synthetic_text_to_sql
CREATE TABLE mobile_usage (subscriber_id INT, usage_date DATE, data_usage FLOAT); INSERT INTO mobile_usage (subscriber_id, usage_date, data_usage) VALUES (1, '2022-01-01', 2.5), (1, '2022-02-01', 3.0), (2, '2022-01-01', 4.0), (2, '2022-02-01', 4.5), (3, '2022-01-01', 5.0);
Find the top 5 mobile subscribers with the highest total data usage for the past year, partitioned by quarter and sorted by subscriber_id?
SELECT subscriber_id, SUM(data_usage) as total_data_usage FROM mobile_usage WHERE usage_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR) GROUP BY subscriber_id, QUARTER(usage_date) ORDER BY total_data_usage DESC, subscriber_id;
gretelai_synthetic_text_to_sql
CREATE TABLE visitors (id INT, country VARCHAR(255), exhibition_id INT); INSERT INTO visitors (id, country, exhibition_id) VALUES (1, 'United States', 1), (2, 'Canada', 1), (3, 'Mexico', 1), (4, 'United States', 2), (5, 'Canada', 2), (6, 'Brazil', 2), (7, 'United States', 3), (8, 'Canada', 3), (9, 'France', 4), (10, 'G...
Which country has the most visitors in the 'Historical' exhibitions category?
SELECT country, SUM(visits) FROM visitors v JOIN exhibitions e ON v.exhibition_id = e.id WHERE e.type = 'Historical' GROUP BY country ORDER BY SUM(visits) DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE concerts (id INT, artist VARCHAR(50), city VARCHAR(50), revenue FLOAT); INSERT INTO concerts (id, artist, city, revenue) VALUES (1, 'Elton John', 'New York', 30000.0), (2, 'Elton John', 'Los Angeles', 40000.0);
What is the total revenue generated by Elton John in New York and Los Angeles?
SELECT SUM(revenue) FROM concerts WHERE artist = 'Elton John' AND (city = 'New York' OR city = 'Los Angeles');
gretelai_synthetic_text_to_sql
CREATE TABLE news_reports (id INT, title VARCHAR(255), author VARCHAR(255), publication_date DATE, topic VARCHAR(255));
Which authors have published the most articles on a particular topic in the 'news_reports' table?
SELECT author, topic, COUNT(*) as total_articles FROM news_reports GROUP BY author, topic ORDER BY total_articles DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE solar_power_plants (id INT, name TEXT, region TEXT, capacity_mw FLOAT); INSERT INTO solar_power_plants (id, name, region, capacity_mw) VALUES (1, 'Solar Plant A', 'north', 125.8); INSERT INTO solar_power_plants (id, name, region, capacity_mw) VALUES (2, 'Solar Plant B', 'south', 180.3);
Which solar power plants in the 'north' region have a capacity greater than 100 MW?
SELECT name, capacity_mw FROM solar_power_plants WHERE region = 'north' AND capacity_mw > 100;
gretelai_synthetic_text_to_sql
CREATE TABLE Bakken_Formation (well_id INT, production_bbl INT); INSERT INTO Bakken_Formation (well_id, production_bbl) VALUES (1, 1200000), (2, 800000), (3, 1500000), (4, 500000);
How many wells are located in the Bakken Formation with production greater than 1,000,000 BBL?
SELECT COUNT(*) FROM Bakken_Formation WHERE production_bbl > 1000000;
gretelai_synthetic_text_to_sql
CREATE SCHEMA if not exists biosensor_tech;CREATE TABLE if not exists biosensor_tech.projects (id INT PRIMARY KEY, name VARCHAR(255), location VARCHAR(255), sensitivity DECIMAL(5, 2)); INSERT INTO biosensor_tech.projects (id, name, location, sensitivity) VALUES (1, 'ProjectE', 'UK', 0.0012), (2, 'ProjectF', 'USA', 0.00...
Update the sensitivity of project H in the biosensor_tech schema to 0.0017.
UPDATE biosensor_tech.projects SET sensitivity = 0.0017 WHERE id = 4;
gretelai_synthetic_text_to_sql
CREATE TABLE donors (id INT, name TEXT, country TEXT, donation_amount DECIMAL(10,2), donation_date DATE); INSERT INTO donors (id, name, country, donation_amount, donation_date) VALUES (1, 'John Doe', 'USA', 500.00, '2020-01-01'); INSERT INTO donors (id, name, country, donation_amount, donation_date) VALUES (2, 'Jane Sm...
How many unique donors are there in the database?
SELECT COUNT(DISTINCT id) FROM donors;
gretelai_synthetic_text_to_sql
CREATE TABLE warehouse (id INT PRIMARY KEY, name VARCHAR(255), num_pallets INT, num_units INT);
Add 5 new pallets with 100 units each to the 'ABC' warehouse
INSERT INTO warehouse (id, name, num_pallets, num_units) SELECT id, 'ABC', 5, 100 * 5 FROM (SELECT id FROM warehouse WHERE name = 'ABC' LIMIT 1) subquery;
gretelai_synthetic_text_to_sql
CREATE TABLE wells (well_id INT, well_name VARCHAR(50), production_volume FLOAT, location VARCHAR(50)); INSERT INTO wells VALUES (1, 'Well A', 1000, 'Gulf of Mexico'); INSERT INTO wells VALUES (2, 'Well B', 1500, 'Alaska North Slope');
Find the average production volume of wells in the Gulf of Mexico
SELECT AVG(production_volume) FROM wells WHERE location = 'Gulf of Mexico';
gretelai_synthetic_text_to_sql
CREATE TABLE if not exists unions (id INT, union_name VARCHAR, number_of_members INT); INSERT INTO unions (id, union_name, number_of_members) VALUES (1, 'Teamsters', 1500000), (2, 'SEIU', 2000000), (3, 'UFW', 50000), (4, 'UNITE HERE', 300000), (5, 'Local 1199', 400000);
How many members are in the 'Local 1199' union?
SELECT SUM(number_of_members) FROM unions WHERE union_name = 'Local 1199';
gretelai_synthetic_text_to_sql
CREATE TABLE seal_populations (id INT, region TEXT, year INT, population INT);
Determine the total population of seals in the North Pacific
SELECT SUM(population) FROM seal_populations WHERE region = 'North Pacific' AND year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE Policy (PolicyNumber INT, PolicyholderName VARCHAR(50)); CREATE TABLE Claim (ClaimID INT, PolicyNumber INT, ClaimDate DATE, ClaimAmount DECIMAL(10,2)); INSERT INTO Policy VALUES (1, 'Ayo Fayose'), (2, 'Peter Jackson'); INSERT INTO Claim VALUES (1, 1, '2021-07-01', 6000), (2, 1, '2021-08-01', 4000), (3, 2, ...
What is the policy number with the highest claim amount in the last 6 months?
SELECT PolicyNumber, MAX(ClaimAmount) as MaxClaimAmount FROM Claim WHERE ClaimDate >= DATEADD(MONTH, -6, GETDATE()) GROUP BY PolicyNumber ORDER BY MaxClaimAmount DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE players (id INT, name VARCHAR(50), age INT, sport VARCHAR(50), team VARCHAR(50)); INSERT INTO players (id, name, age, sport, team) VALUES (1, 'David Beckham', 44, 'MLS', 'Galaxy'); INSERT INTO players (id, name, age, sport, team) VALUES (2, 'Thierry Henry', 42, 'MLS', 'Red Bulls');
Who is the oldest soccer player in the MLS?
SELECT name FROM players WHERE sport = 'MLS' AND age = (SELECT MAX(age) FROM players WHERE sport = 'MLS');
gretelai_synthetic_text_to_sql
CREATE TABLE company (id INT, name TEXT, founding_year INT, founding_location TEXT); INSERT INTO company (id, name, founding_year, founding_location) VALUES (1, 'InnoThai', 2019, 'Bangkok'); INSERT INTO company (id, name, founding_year, founding_location) VALUES (2, 'VietStart', 2021, 'Ho Chi Minh City'); INSERT INTO c...
How many startups were founded in Southeast Asia each year?
SELECT founding_location, COUNT(*) FROM company GROUP BY founding_year, founding_location HAVING founding_location LIKE 'Southeast%';
gretelai_synthetic_text_to_sql
CREATE SCHEMA if not exists biosensors;CREATE TABLE if not exists biosensors.measurements (id INT PRIMARY KEY, location VARCHAR(100), temperature FLOAT); INSERT INTO biosensors.measurements (id, location, temperature) VALUES (1, 'Sydney', 25.3), (2, 'Melbourne', 24.1), (3, 'Brisbane', 26.2), (4, 'Perth', 23.7), (5, 'Ad...
What is the maximum biosensor temperature recorded in Australia?
SELECT MAX(temperature) FROM biosensors.measurements WHERE location = 'Australia';
gretelai_synthetic_text_to_sql
CREATE TABLE investment_strategies (id INT, strategy_name VARCHAR(50)); INSERT INTO investment_strategies (id, strategy_name) VALUES (1, 'Value Investing'), (2, 'Growth Investing'); CREATE TABLE transactions (strategy_id INT, transaction_amount DECIMAL(10,2)); INSERT INTO transactions (strategy_id, transaction_amount) ...
What is the total transaction amount for each investment strategy?
SELECT i.strategy_name, SUM(t.transaction_amount) as total_transaction_amount FROM investment_strategies i JOIN transactions t ON i.id = t.strategy_id GROUP BY i.strategy_name;
gretelai_synthetic_text_to_sql
CREATE TABLE environmental_impact (id INT, mine_id INT, co2_emissions INT, water_consumption INT); INSERT INTO environmental_impact (id, mine_id, co2_emissions, water_consumption) VALUES (1, 1, 200, 1000); INSERT INTO environmental_impact (id, mine_id, co2_emissions, water_consumption) VALUES (2, 2, 250, 1200); INSERT ...
What is the total environmental impact and number of surveys for each mine related to gold extraction?
SELECT m.name, m.mineral, SUM(e.co2_emissions + e.water_consumption) as total_environmental_impact, COUNT(g.id) as total_surveys FROM mines m LEFT JOIN environmental_impact e ON m.id = e.mine_id LEFT JOIN geological_survey g ON m.id = g.mine_id WHERE m.mineral = 'Gold' GROUP BY m.name, m.mineral;
gretelai_synthetic_text_to_sql
CREATE TABLE academic_publications (id INT, title VARCHAR(100), journal VARCHAR(50), publication_year INT); INSERT INTO academic_publications VALUES (1, 'Artificial Intelligence for Autonomous Systems', 'Journal of Machine Learning', 2018), (2, 'Deep Learning Techniques for Image Recognition', 'Journal of Machine Learn...
Delete all academic publications with a title containing 'Deep Learning'.
DELETE FROM academic_publications WHERE title LIKE '%Deep Learning%';
gretelai_synthetic_text_to_sql
CREATE TABLE news_articles (article_id INT, author_name VARCHAR(50), title VARCHAR(100), published_date DATE);
Count the number of articles with 'investigative' in the title from the 'news_articles' table
SELECT COUNT(*) as articles_with_investigative FROM news_articles WHERE title ILIKE '%investigative%';
gretelai_synthetic_text_to_sql
CREATE TABLE OceanFloorMapping ( Location NVARCHAR(50), MapDate DATETIME, Depth FLOAT, Area NVARCHAR(50)); INSERT INTO OceanFloorMapping (Location, MapDate, Depth, Area) VALUES ('Mariana Trench', '2021-07-15 12:30:00', 10994, 'Pacific Ocean'); INSERT INTO OceanFloorMapping (Location, MapDate, Depth, Area) VALUES ('Sohm...
Retrieve the depth measurements for each ocean area, ordered by map date, partitioned by ocean area, specifically for the Indian Ocean.
SELECT Area, MapDate, Depth, ROW_NUMBER() OVER (PARTITION BY Area ORDER BY MapDate) as DepthRank FROM OceanFloorMapping WHERE Area = 'Indian Ocean'
gretelai_synthetic_text_to_sql
CREATE TABLE tourism_stats (country VARCHAR(50), year INT, visitors INT); INSERT INTO tourism_stats (country, year, visitors) VALUES ('Japan', 2020, 8000000), ('Japan', 2021, 9000000);
What is the total number of tourists who visited Japan in 2020 and 2021?
SELECT SUM(visitors) FROM tourism_stats WHERE country = 'Japan' AND year IN (2020, 2021);
gretelai_synthetic_text_to_sql
CREATE TABLE crops (id INT PRIMARY KEY, name VARCHAR(50), scientific_name VARCHAR(50), growth_season VARCHAR(20), family VARCHAR(25), region VARCHAR(25)); INSERT INTO crops (id, name, scientific_name, growth_season, family, region) VALUES (1, 'Wheat', 'Triticum aestivum', 'Cool', 'Poaceae', 'Northwest'); INSERT INTO cr...
Which crops are grown in the Northwest and what is their scientific name?
SELECT name, scientific_name FROM crops WHERE region = 'Northwest';
gretelai_synthetic_text_to_sql
CREATE TABLE fan_location (fan_id INT, city VARCHAR(50));
Find the number of fans who attended games in the last 60 days and lived in the same city as the team
SELECT COUNT(DISTINCT fan_id) FROM fan_attendance JOIN fan_location ON fan_attendance.fan_id = fan_location.fan_id JOIN team_data ON fan_location.city = team_data.city WHERE fan_attendance.game_date >= CURDATE() - INTERVAL 60 DAY;
gretelai_synthetic_text_to_sql
CREATE TABLE menu (item_id INT, item_name VARCHAR(50), category VARCHAR(50), cuisine VARCHAR(50), price DECIMAL(5,2)); CREATE VIEW unique_items_per_cuisine AS SELECT cuisine, COUNT(DISTINCT item_id) as num_items FROM menu GROUP BY cuisine;
Find the number of unique menu items in each cuisine type.
SELECT * FROM unique_items_per_cuisine;
gretelai_synthetic_text_to_sql
CREATE TABLE HealthEquity (ID INT, Metric VARCHAR(50), State VARCHAR(50), Score INT); INSERT INTO HealthEquity (ID, Metric, State, Score) VALUES (1, 'Metric 1', 'California', 85); INSERT INTO HealthEquity (ID, Metric, State, Score) VALUES (2, 'Metric 2', 'California', 90);
What is the health equity metric score for California?
SELECT Score FROM HealthEquity WHERE State = 'California' AND Metric = 'Metric 1';
gretelai_synthetic_text_to_sql
CREATE TABLE producers (id INT, name TEXT, neodymium_prod FLOAT); INSERT INTO producers (id, name, neodymium_prod) VALUES (1, 'China', 145000.0), (2, 'Malaysia', 2200.0), (3, 'Australia', 1200.0);
What are the top 3 producers of Neodymium in 2020?
SELECT name, neodymium_prod FROM producers WHERE YEAR(production_date) = 2020 ORDER BY neodymium_prod DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE HealthStats (Year INT, Disease VARCHAR(20), State VARCHAR(20), Cases INT); INSERT INTO HealthStats (Year, Disease, State, Cases) VALUES (2018, 'Cancer', 'California', 50000); INSERT INTO HealthStats (Year, Disease, State, Cases) VALUES (2020, 'Obesity', 'California', 35000);
Find the number of Obesity cases recorded in California in 2020.
SELECT SUM(Cases) FROM HealthStats WHERE Disease = 'Obesity' AND State = 'California' AND Year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE charging_stations (id INT PRIMARY KEY, station_name VARCHAR(50), location VARCHAR(50), num_charging_points INT);
Add a new record to the 'charging_stations' table
INSERT INTO charging_stations (station_name, location, num_charging_points) VALUES ('Green Park', 'NYC', 10);
gretelai_synthetic_text_to_sql
CREATE TABLE Sales (sale_id INT PRIMARY KEY, sale_date DATE, item_sold VARCHAR(255), quantity INT, sale_price DECIMAL(5,2));
What are the total sales for each item on a given day?
SELECT item_sold, SUM(quantity * sale_price) FROM Sales WHERE sale_date = '2022-01-01' GROUP BY item_sold;
gretelai_synthetic_text_to_sql
CREATE TABLE veteran_employment (employee_id INT, industry_sector VARCHAR(50), employment_date DATE, is_veteran BOOLEAN);
What is the total number of veterans employed in the defense industry in the United States as of January 2022?
SELECT COUNT(employee_id) FROM veteran_employment WHERE industry_sector LIKE '%defense%' AND employment_date = '2022-01-01' AND is_veteran = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE energy_efficiency (date DATE, country VARCHAR(255), energy_efficiency_index FLOAT); INSERT INTO energy_efficiency (date, country, energy_efficiency_index) VALUES ('2022-01-01', 'Argentina', 80), ('2022-01-01', 'Chile', 85), ('2022-01-01', 'Colombia', 95);
What is the maximum energy efficiency index for Argentina, Chile, and Colombia between 2022-01-01 and 2022-12-31?
SELECT country, MAX(energy_efficiency_index) as max_energy_efficiency_index FROM energy_efficiency WHERE date BETWEEN '2022-01-01' AND '2022-12-31' GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE programs( id INT PRIMARY KEY NOT NULL, program_name VARCHAR(50), location VARCHAR(50), budget DECIMAL(10, 2) );
Create a table named 'programs' with columns for program name, location, and budget
CREATE TABLE programs( id INT PRIMARY KEY NOT NULL, program_name VARCHAR(50), location VARCHAR(50), budget DECIMAL(10, 2) );
gretelai_synthetic_text_to_sql
CREATE TABLE harvest_data (id INT PRIMARY KEY, farm_id INT, yield FLOAT, date DATE);
Delete all records from the table "harvest_data" where the "farm_id" is 3
DELETE FROM harvest_data WHERE farm_id = 3;
gretelai_synthetic_text_to_sql
CREATE TABLE climate_mitigation (project_id INT, project_name VARCHAR(100), start_year INT, end_year INT, region VARCHAR(50), status VARCHAR(50));
List all climate mitigation projects in Southeast Asia that have been completed.
SELECT project_id, project_name FROM climate_mitigation WHERE region = 'Southeast Asia' AND end_year IS NOT NULL;
gretelai_synthetic_text_to_sql
CREATE TABLE sales (id INT, product_id INT, sales_amount DECIMAL(10,2)); INSERT INTO sales (id, product_id, sales_amount) VALUES (1, 1, 100.00), (2, 1, 120.00), (3, 2, 75.00);
What are the total sales of lipsticks and eyeshadows?
SELECT SUM(sales_amount) as total_sales FROM sales WHERE product_id IN (SELECT id FROM product WHERE category IN ('Lipstick', 'Eyeshadow'));
gretelai_synthetic_text_to_sql
CREATE TABLE ticket_sales (sale_id INT, sale_date DATE, quantity INT);
How many tickets were sold in each quarter of the last year?
SELECT DATEPART(quarter, ts.sale_date) as quarter, COUNT(ts.quantity) as num_tickets FROM ticket_sales ts WHERE ts.sale_date >= DATEADD(year, -1, GETDATE()) GROUP BY DATEPART(quarter, ts.sale_date);
gretelai_synthetic_text_to_sql
CREATE TABLE properties (id INT, property_id INT, city TEXT, inclusive BOOLEAN, size INT); INSERT INTO properties (id, property_id, city, inclusive, size) VALUES (1, 101, 'Austin', FALSE, 1200), (2, 102, 'Seattle', TRUE, 900), (3, 103, 'Seattle', TRUE, 1100), (4, 104, 'Austin', TRUE, 1300);
What is the average size of properties in the city of Seattle for properties with inclusive housing policies?
SELECT AVG(size) FROM properties WHERE city = 'Seattle' AND inclusive = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE boroughs (bid INT, borough_name VARCHAR(255)); CREATE TABLE crimes (cid INT, bid INT, crime_count INT);
What is the total number of crimes committed in each borough, sorted by crime count?
SELECT b.borough_name, SUM(c.crime_count) AS total_crime_count FROM boroughs b INNER JOIN crimes c ON b.bid = c.bid GROUP BY b.borough_name ORDER BY total_crime_count DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE Levees (id INT, name VARCHAR(100), length FLOAT, state VARCHAR(50), resilience_rating INT); INSERT INTO Levees (id, name, length, state, resilience_rating) VALUES (1, 'Mississippi River Levee', 217.0, 'Louisiana', 8);
What is the name, length, and resilience rating of all levees in the state of Louisiana with a length greater than 10 kilometers?
SELECT name, length, resilience_rating FROM Levees WHERE state = 'Louisiana' AND length > 10000;
gretelai_synthetic_text_to_sql
CREATE TABLE EVSpecs (Id INT, Make VARCHAR(50), Model VARCHAR(50), Torque INT);
What is the average torque of electric vehicles in the 'EVSpecs' database produced by Audi?
SELECT AVG(Torque) FROM EVSpecs WHERE Make = 'Audi';
gretelai_synthetic_text_to_sql
CREATE TABLE workshops_by_state(id INT, state TEXT, workshop_count INT); INSERT INTO workshops_by_state VALUES (1, 'California', 5), (2, 'Texas', 3), (3, 'New York', 4), (4, 'Florida', 6);
What is the total number of traditional arts and crafts workshops held in each state?
SELECT state, workshop_count FROM workshops_by_state;
gretelai_synthetic_text_to_sql
CREATE TABLE concert_tickets (ticket_id int, venue_id int, ticket_price decimal, timestamp datetime, country varchar(255), artist_id int); INSERT INTO concert_tickets (ticket_id, venue_id, ticket_price, timestamp, country, artist_id) VALUES (1, 789, 50.00, '2022-06-01 12:00:00', 'United States', 101);
What is the total revenue generated by concert ticket sales for each artist?
SELECT artist_id, SUM(ticket_price) as total_revenue FROM concert_tickets WHERE timestamp BETWEEN '2022-01-01' AND '2022-12-31' GROUP BY artist_id;
gretelai_synthetic_text_to_sql
CREATE TABLE volunteers (id INT PRIMARY KEY, gender VARCHAR(10), hours_volunteered INT, signup_date DATE); INSERT INTO volunteers (id, gender, hours_volunteered, signup_date) VALUES (1, 'male', 5, '2022-03-15');
Find the average number of hours volunteered per month for each gender in 2022.
SELECT gender, EXTRACT(MONTH FROM signup_date) AS month, AVG(hours_volunteered) FROM volunteers WHERE signup_date BETWEEN '2022-01-01' AND '2022-12-31' GROUP BY gender, month;
gretelai_synthetic_text_to_sql
CREATE TABLE vulnerabilities (id INT, name TEXT, description TEXT, severity TEXT, date_discovered DATE); INSERT INTO vulnerabilities (id, name, description, severity, date_discovered) VALUES (1, 'SQL Injection', 'Unauthorized SQL code execution', 'Critical', '2022-01-01');
What are the top 5 most common vulnerabilities in the last month?
SELECT name, COUNT(*) as count FROM vulnerabilities WHERE date_discovered >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) GROUP BY name ORDER BY count DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE accessible_platforms (service_type VARCHAR(50), usage_date DATE, platform_location VARCHAR(50)); INSERT INTO accessible_platforms (service_type, usage_date, platform_location) VALUES ('Wheelchair Ramp', '2021-01-01', 'Purple Line'), ('Wheelchair Ramp', '2021-01-05', 'Purple Line'), ('Service Animal', '2021...
Show the number of accessible services used on 'Purple Line' platforms each month
SELECT EXTRACT(MONTH FROM usage_date), COUNT(*) FROM accessible_platforms WHERE service_type = 'Wheelchair Ramp' AND platform_location = 'Purple Line' GROUP BY EXTRACT(MONTH FROM usage_date);
gretelai_synthetic_text_to_sql
CREATE TABLE CrueltyFree (id INT, product_id INT, certification_date DATE, is_certified BOOLEAN); INSERT INTO CrueltyFree (id, product_id, certification_date, is_certified) VALUES (1, 1, '2020-01-01', true), (2, 1, '2021-01-01', true), (3, 2, '2020-01-01', false), (4, 2, '2021-01-01', false);
What is the total number of cruelty-free certified products for each year?
SELECT EXTRACT(YEAR FROM certification_date) as year, COUNT(DISTINCT product_id) as total_certified FROM CrueltyFree WHERE is_certified = true GROUP BY year;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_protected_areas (id INT, pollution_level INT);
Determine the maximum and minimum pollution levels recorded in marine protected areas
SELECT MIN(pollution_level), MAX(pollution_level) FROM marine_protected_areas;
gretelai_synthetic_text_to_sql
CREATE TABLE DysprosiumMines (region VARCHAR(20), country VARCHAR(20)); INSERT INTO DysprosiumMines (region, country) VALUES ('RegionA', 'Country1'), ('RegionB', 'Country2');
List all the distinct regions where dysprosium is mined.
SELECT DISTINCT region FROM DysprosiumMines;
gretelai_synthetic_text_to_sql
USE biotech; CREATE TABLE if not exists projects (id INT, name VARCHAR(255), country VARCHAR(255), success BOOLEAN); INSERT INTO projects (id, name, country, success) VALUES (1, 'Project1', 'Brazil', true), (2, 'Project2', 'Colombia', false), (3, 'Project3', 'Brazil', true), (4, 'Project4', 'Argentina', true);
What is the success rate of bioprocess engineering projects in Brazil?
SELECT COUNT(*) / (SELECT COUNT(*) FROM projects WHERE country = 'Brazil') FROM projects WHERE country = 'Brazil';
gretelai_synthetic_text_to_sql
CREATE TABLE faculty_publications (faculty_id INT, faculty_name VARCHAR(255), publication_year INT, is_first_author BOOLEAN, country_of_origin VARCHAR(255)); INSERT INTO faculty_publications (faculty_id, faculty_name, publication_year, is_first_author, country_of_origin) VALUES (21, 'Rajesh Patel', 2018, TRUE, 'India')...
What is the total number of publications authored by faculty members from India, ranked by the total number in descending order?
SELECT faculty_name, COUNT(*) AS total_publications FROM faculty_publications WHERE country_of_origin = 'India' GROUP BY faculty_name ORDER BY total_publications DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE Artists (ArtistID INT, Name VARCHAR(100), Age INT, Genre VARCHAR(50)); INSERT INTO Artists (ArtistID, Name, Age, Genre) VALUES (1, 'John Doe', 35, 'R&B'); INSERT INTO Artists (ArtistID, Name, Age, Genre) VALUES (2, 'Jane Smith', 28, 'R&B');
What is the average age of all R&B artists in the database?
SELECT AVG(Age) FROM Artists WHERE Genre = 'R&B';
gretelai_synthetic_text_to_sql
CREATE TABLE football_fans (id INT, match_id INT, country VARCHAR(255), age INT); INSERT INTO football_fans (id, match_id, country, age) VALUES (1, 1, 'USA', 25), (2, 1, 'Canada', 30), (3, 2, 'Mexico', 22), (4, 2, 'USA', 28), (5, 3, 'Canada', 35), (6, 3, 'USA', 27);
How many fans from each country attended the football matches?
SELECT country, COUNT(*) as fans_count FROM football_fans GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE restaurants (restaurant_id INT, city VARCHAR(255)); CREATE TABLE menus (menu_id INT, restaurant_id INT, total_revenue DECIMAL(10,2)); INSERT INTO restaurants VALUES (1, 'New York'); INSERT INTO restaurants VALUES (2, 'Los Angeles'); INSERT INTO menus VALUES (1, 1, 5000); INSERT INTO menus VALUES (2, 1, 700...
What is the total revenue for each restaurant, including the sum of revenues from all menus, for the month of January 2021, grouped by city?
SELECT r.city, SUM(m.total_revenue) as total_revenue FROM restaurants r INNER JOIN menus m ON r.restaurant_id = m.restaurant_id WHERE MONTH(m.order_date) = 1 GROUP BY r.city;
gretelai_synthetic_text_to_sql
CREATE TABLE travel_advisories (id INT, level INT, destination VARCHAR(50)); INSERT INTO travel_advisories (id, level, destination) VALUES (1, 2, 'Brazil'); INSERT INTO travel_advisories (id, level, destination) VALUES (2, 3, 'Argentina'); INSERT INTO travel_advisories (id, level, destination) VALUES (3, 1, 'Chile');
Delete destinations with a travel advisory level greater than 3.
DELETE FROM travel_advisories WHERE level > 3;
gretelai_synthetic_text_to_sql
CREATE TABLE PopulationData (country VARCHAR(50), year INT, population INT); INSERT INTO PopulationData (country, year, population) VALUES ('Brazil', 1990, 160000000), ('Brazil', 2020, 210000000); CREATE TABLE CO2Emissions (country VARCHAR(50), year INT, co2_emission INT); INSERT INTO CO2Emissions (country, year, co2_e...
What is the average CO2 emission per capita for each country in South America since 1990?
SELECT country, AVG(co2_emission/population) as 'Average CO2 Emission per Capita' FROM CO2Emissions INNER JOIN PopulationData ON CO2Emissions.country = PopulationData.country WHERE year >= 1990 AND continent = 'South America' GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE biotech_startups(id INT, company_name TEXT, location TEXT, funding_amount DECIMAL(10,2), quarter INT, year INT);
Update the location for a biotech startup in Q1 2022.
UPDATE biotech_startups SET location = 'USA' WHERE id = 1 AND quarter = 1 AND year = 2022;
gretelai_synthetic_text_to_sql
CREATE SCHEMA if not exists bioprocessing;CREATE TABLE if not exists bioprocessing.projects (id INT PRIMARY KEY, name VARCHAR(100), region VARCHAR(100)); INSERT INTO bioprocessing.projects (id, name, region) VALUES (1, 'ProjA', 'Singapore'), (2, 'ProjB', 'Tokyo'), (3, 'ProjC', 'Seoul'), (4, 'ProjD', 'Sydney'), (5, 'Pro...
How many bioprocess engineering projects are in the Asia Pacific region?
SELECT COUNT(*) FROM bioprocessing.projects WHERE region = 'Asia Pacific';
gretelai_synthetic_text_to_sql
CREATE TABLE crops (id INT, name TEXT, production INT, year INT, country TEXT); INSERT INTO crops (id, name, production, year, country) VALUES (1, 'Rice', 15000, 2018, 'India'); INSERT INTO crops (id, name, production, year, country) VALUES (2, 'Rice', 12000, 2018, 'China');
Find the total production of 'Rice' for 'Asian' countries in 2018?
SELECT SUM(production) as total_production, country FROM crops WHERE name = 'Rice' AND year = 2018 AND country IN ('India', 'China') GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE ai_researchers (id INT, name VARCHAR(100), published_papers INT); INSERT INTO ai_researchers (id, name, published_papers) VALUES (1, 'Alice', 3), (2, 'Bob', 0), (3, 'Charlotte', 2), (4, 'David', 1), (5, 'Eva', 0);
Find the number of papers published by each researcher, ordered by the number of papers in descending order.
SELECT name, published_papers FROM ai_researchers ORDER BY published_papers DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE mars_rovers (name VARCHAR(50), launch_year INT, agency VARCHAR(50));INSERT INTO mars_rovers (name, launch_year, agency) VALUES ('Sojourner', 1997, 'NASA'), ('Spirit', 2004, 'NASA'), ('Opportunity', 2004, 'NASA'), ('Curiosity', 2012, 'NASA'), ('Perseverance', 2021, 'NASA');
List the names of all Mars rovers launched by NASA.
SELECT name FROM mars_rovers WHERE agency = 'NASA';
gretelai_synthetic_text_to_sql
CREATE TABLE lifelong_learning_courses (course_id INT, course_name VARCHAR(50)); INSERT INTO lifelong_learning_courses VALUES (1, 'Course 1'), (2, 'Course 2'), (3, 'Course 3'); CREATE TABLE student_enrollment (student_id INT, course_id INT); INSERT INTO student_enrollment VALUES (1, 1), (1, 2), (2, 2), (2, 3), (3, 1), ...
Find the number of students who have ever enrolled in each lifelong learning course.
SELECT course_id, course_name, COUNT(DISTINCT student_id) as enrollment_count FROM lifelong_learning_courses JOIN student_enrollment ON lifelong_learning_courses.course_id = student_enrollment.course_id GROUP BY course_id, course_name;
gretelai_synthetic_text_to_sql
CREATE TABLE forests (id INT, name VARCHAR(255), hectares FLOAT, country VARCHAR(255)); INSERT INTO forests (id, name, hectares, country) VALUES (1, 'Tropical Rainforest', 250000.0, 'Brazil'), (2, 'Temperate Rainforest', 150000.0, 'Canada'), (3, 'Mediterranean Forest', 100000.0, 'Spain'), (4, 'Boreal Forest', 2000000.0...
Which forests have a unique tree species not found in any other forest?
SELECT forests.name FROM forests INNER JOIN forest_trees ON forests.id = forest_trees.id WHERE forest_trees.forest_species NOT IN (SELECT forest_trees.forest_species FROM forest_trees EXCEPT SELECT forest_trees.forest_species FROM forest_trees LIMIT 1 OFFSET 1);
gretelai_synthetic_text_to_sql
CREATE TABLE rural_projects (id INT, province VARCHAR(255), project_type VARCHAR(255), region VARCHAR(255), start_date DATE);
Show the names and start dates of all rural projects in the "Mindanao" region from the "rural_projects" table
SELECT project_type, start_date FROM rural_projects WHERE region = 'Mindanao';
gretelai_synthetic_text_to_sql