context
stringlengths 11
9.12k
| question
stringlengths 0
1.06k
| SQL
stringlengths 2
4.44k
| source
stringclasses 28
values |
|---|---|---|---|
CREATE TABLE Researchers (id INT PRIMARY KEY, name VARCHAR(100), expertise VARCHAR(100), affiliation VARCHAR(100)); INSERT INTO Researchers (id, name, expertise, affiliation) VALUES (1, 'Jane Doe', 'Biodiversity', 'University of Toronto');
|
Who are the researchers with expertise in biodiversity or resource management?
|
SELECT r.name FROM Researchers r WHERE r.expertise IN ('Biodiversity', 'Resource Management');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Education (country VARCHAR(255), num_services INT); INSERT INTO Education (country, num_services) VALUES ('Syria', 1000), ('Yemen', 800), ('Afghanistan', 1200); CREATE TABLE Legal_Support (country VARCHAR(255), num_services INT); INSERT INTO Legal_Support (country, num_services) VALUES ('Syria', 500), ('Yemen', 700), ('Iraq', 900);
|
What's the total number of 'Education' and 'Legal Support' services provided in 'Syria' and 'Yemen'?
|
SELECT SUM(num_services) FROM (SELECT num_services FROM Education WHERE country IN ('Syria', 'Yemen') UNION ALL SELECT num_services FROM Legal_Support WHERE country IN ('Syria', 'Yemen')) AS combined_countries;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE infrastructure_projects (id INT, country VARCHAR(255), project VARCHAR(255), cost FLOAT, year INT); INSERT INTO infrastructure_projects (id, country, project, cost, year) VALUES (1, 'Philippines', 'Road Construction', 5000000, 2021), (2, 'Philippines', 'Bridge Building', 3000000, 2021), (3, 'Indonesia', 'Irrigation System', 7000000, 2021);
|
What was the total cost of all infrastructure projects in the Philippines in 2021?
|
SELECT SUM(cost) FROM infrastructure_projects WHERE country = 'Philippines' AND year = 2021;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE products (product_id INT, name VARCHAR(255), price DECIMAL(5,2), certification VARCHAR(255));
|
What is the average price of Vegan certified products?
|
SELECT AVG(price) FROM products WHERE certification = 'Vegan';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE tourism_revenue (year INT, city TEXT, revenue FLOAT); INSERT INTO tourism_revenue (year, city, revenue) VALUES (2021, 'Barcelona', 200000), (2022, 'Barcelona', 250000);
|
What is the total revenue of sustainable tourism in Barcelona in 2021?
|
SELECT SUM(revenue) FROM tourism_revenue WHERE city = 'Barcelona' AND year = 2021;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE forestry_data.young_forest (tree_id INT, species VARCHAR(50), age INT, height INT, location VARCHAR(50));CREATE TABLE forestry_data.mature_forest (tree_id INT, species VARCHAR(50), age INT, height INT, location VARCHAR(50));CREATE TABLE forestry_data.protected_zone (tree_id INT, species VARCHAR(50), age INT, height INT, location VARCHAR(50));CREATE TABLE forestry_data.no_management_zone (tree_id INT, species VARCHAR(50), age INT, height INT, location VARCHAR(50));
|
What is the total number of trees in the forestry_data schema, excluding trees that are in the no_management_zone table?
|
SELECT COUNT(*) FROM forestry_data.young_forest UNION ALL SELECT COUNT(*) FROM forestry_data.mature_forest EXCEPT SELECT COUNT(*) FROM forestry_data.no_management_zone;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE impact_investments_education (id INT, sector VARCHAR(20), investment_amount FLOAT); INSERT INTO impact_investments_education (id, sector, investment_amount) VALUES (1, 'Education', 100000.0), (2, 'Education', 120000.0), (3, 'Education', 150000.0);
|
Maximum impact investment amount in the education sector?
|
SELECT MAX(investment_amount) FROM impact_investments_education WHERE sector = 'Education';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE personal_auto (policy_id INT, claim_amount DECIMAL(10,2)); INSERT INTO personal_auto (policy_id, claim_amount) VALUES (1, 250.50), (2, 400.75), (3, 120.00);
|
What is the average claim amount for policies in the 'personal_auto' table?
|
SELECT AVG(claim_amount) FROM personal_auto;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE wind_turbines (id INT, region VARCHAR(20), power_output FLOAT); INSERT INTO wind_turbines (id, region, power_output) VALUES (1, 'Northeast', 3.4), (2, 'Midwest', 4.2), (3, 'Northeast', 5.1), (4, 'South', 2.9);
|
What is the minimum power output of a wind turbine in the 'Northeast' region?
|
SELECT MIN(power_output) FROM wind_turbines WHERE region = 'Northeast';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE news_stories (id INT, title VARCHAR(100), date DATE, topic VARCHAR(50), publication_id INT);CREATE TABLE publications (id INT, country VARCHAR(50)); INSERT INTO news_stories VALUES (1, 'Climate crisis', '2022-01-01', 'Climate change', 1); INSERT INTO publications VALUES (1, 'The New York Times');
|
How many news stories have been published about climate change in the past year, grouped by the publication's country?
|
SELECT publications.country, COUNT(news_stories.id) FROM news_stories INNER JOIN publications ON news_stories.publication_id = publications.id WHERE news_stories.date >= DATEADD(year, -1, GETDATE()) AND news_stories.topic = 'Climate change' GROUP BY publications.country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE regions (id INT, name VARCHAR(50)); INSERT INTO regions (id, name) VALUES (1, 'Pacific Northwest'); CREATE TABLE timber_harvest (id INT, region_id INT, year INT, volume FLOAT); INSERT INTO timber_harvest (id, region_id, year, volume) VALUES (1, 1, 2022, 1200.5);
|
What is the total volume of timber harvested in '2022' from the 'Pacific Northwest' region?
|
SELECT SUM(volume) FROM timber_harvest WHERE region_id = 1 AND year = 2022;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE hotels (id INT, name TEXT, country TEXT, revenue FLOAT, reviews INT);
|
What is the minimum revenue of hotels in Japan that have more than 100 reviews?
|
SELECT MIN(revenue) FROM hotels WHERE country = 'Japan' AND reviews > 100;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE departments(id INT, department TEXT);CREATE TABLE employees(id INT, name TEXT, department TEXT, labor_hours INT, training_date DATE);INSERT INTO departments(id, department) VALUES (1, 'Department A'), (2, 'Department B'), (3, 'Department C'); INSERT INTO employees(id, name, department, labor_hours, training_date) VALUES (1, 'Employee 1', 'Department A', 10, '2021-01-10'), (2, 'Employee 2', 'Department B', 15, '2021-02-15'), (3, 'Employee 3', 'Department A', 20, '2021-03-20'), (4, 'Employee 4', 'Department C', 25, '2021-04-25'), (5, 'Employee 5', 'Department B', 30, '2021-05-30'), (6, 'Employee 6', 'Department C', 35, '2021-06-30'), (7, 'Employee 7', 'Department A', 40, '2021-07-31'), (8, 'Employee 8', 'Department B', 45, '2021-08-31'), (9, 'Employee 9', 'Department C', 50, '2021-09-30'), (10, 'Employee 10', 'Department A', 55, '2021-10-31');
|
What is the total number of labor hours spent on workforce development programs for each department in the past year?
|
SELECT department, SUM(labor_hours) as total_labor_hours FROM employees WHERE training_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR) GROUP BY department;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Species ( id INT PRIMARY KEY, name VARCHAR(50), family VARCHAR(50), conservation_status VARCHAR(50)); CREATE TABLE Threats ( id INT PRIMARY KEY, species_id INT, threat_type VARCHAR(50), severity VARCHAR(50)); CREATE TABLE Protection_Programs ( id INT PRIMARY KEY, species_id INT, program_name VARCHAR(50), start_year INT, end_year INT);
|
What are the endangered species with no protection programs in place?
|
SELECT Species.name FROM Species LEFT JOIN Protection_Programs ON Species.id = Protection_Programs.species_id WHERE Species.conservation_status = 'Endangered' AND Protection_Programs.id IS NULL;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE EnergyStorage (technology TEXT, capacity INT); INSERT INTO EnergyStorage (technology, capacity) VALUES ('Lithium-ion', 3000), ('Lead-acid', 2000);
|
Which energy storage technology has the highest capacity in the EnergyStorage table?
|
SELECT technology, capacity FROM EnergyStorage ORDER BY capacity DESC LIMIT 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE boston_fire_stations (id INT, station_name VARCHAR(20), location VARCHAR(20)); INSERT INTO boston_fire_stations (id, station_name, location) VALUES (1, 'Station 1', 'Boston'), (2, 'Station 2', 'Boston');
|
What is the total number of fire stations in Boston?
|
SELECT COUNT(*) FROM boston_fire_stations;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE players (id INT, age INT, country VARCHAR(255)); INSERT INTO players (id, age, country) VALUES (1, 25, 'USA'), (2, 30, 'Canada'), (3, 35, 'Mexico'); CREATE TABLE games (id INT, name VARCHAR(255), category VARCHAR(255)); INSERT INTO games (id, name, category) VALUES (1, 'GameA', 'VR'), (2, 'GameB', 'Non-VR'), (3, 'GameC', 'VR'); CREATE TABLE player_games (player_id INT, game_id INT); INSERT INTO player_games (player_id, game_id) VALUES (1, 1), (2, 1), (3, 1), (1, 3), (2, 3);
|
What is the average age of players who play VR games, grouped by their country?
|
SELECT p.country, AVG(p.age) as avg_age FROM players p JOIN player_games pg ON p.id = pg.player_id JOIN games g ON pg.game_id = g.id WHERE g.category = 'VR' GROUP BY p.country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE patient_demographics (patient_id INT, gender VARCHAR(10)); INSERT INTO patient_demographics (patient_id, gender) VALUES (1, 'Female');
|
How many patients have been treated by gender?
|
SELECT gender, COUNT(*) FROM patient_demographics GROUP BY gender;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE asian_conservation_areas (id INT, name VARCHAR(255), area_size FLOAT, funding FLOAT);
|
What is the average habitat preservation funding per square kilometer for each Asian conservation area?
|
SELECT aca.name, AVG(aca.funding / aca.area_size) as avg_funding_per_sq_km FROM asian_conservation_areas aca GROUP BY aca.name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE broadband_subscribers (subscriber_id INT, speed FLOAT, state VARCHAR(20)); INSERT INTO broadband_subscribers (subscriber_id, speed, state) VALUES (1, 75, 'Florida'), (2, 150, 'Florida');
|
What is the minimum broadband speed for customers in the state of Florida?
|
SELECT MIN(speed) FROM broadband_subscribers WHERE state = 'Florida';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE energy_storage (energy_type VARCHAR(50), capacity FLOAT); INSERT INTO energy_storage (energy_type, capacity) VALUES ('Batteries', 45.6), ('Flywheels', 32.7), ('Batteries', 54.3);
|
Calculate the average energy storage capacity for each energy type
|
SELECT energy_type, AVG(capacity) FROM energy_storage GROUP BY energy_type;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE wells (well_id INT, well_name VARCHAR(50), region VARCHAR(20)); INSERT INTO wells (well_id, well_name, region) VALUES (1, 'Well A', 'onshore'); INSERT INTO wells (well_id, well_name, region) VALUES (2, 'Well B', 'offshore'); INSERT INTO wells (well_id, well_name, region) VALUES (3, 'Well C', 'onshore');
|
How many wells are there in each region?
|
SELECT region, COUNT(*) FROM wells GROUP BY region;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Claims (ClaimID INT, PolicyID INT, Amount INT, Region VARCHAR(10)); INSERT INTO Claims (ClaimID, PolicyID, Amount, Region) VALUES (1, 101, 500, 'North'); INSERT INTO Claims (ClaimID, PolicyID, Amount, Region) VALUES (2, 102, 750, 'South');
|
What is the total claim amount for the 'South' region?
|
SELECT SUM(Amount) FROM Claims WHERE Region = 'South';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE attorneys (attorney_id INT, specialty VARCHAR(255)); CREATE TABLE billing (bill_id INT, attorney_id INT, amount DECIMAL(10,2));
|
What is the average billing amount for attorneys in the 'billing' table, grouped by their specialty?
|
SELECT a.specialty, AVG(b.amount) FROM attorneys a INNER JOIN billing b ON a.attorney_id = b.attorney_id GROUP BY a.specialty;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE usage_data (subscriber_id INT, region VARCHAR(20), country VARCHAR(20), usage_gb DECIMAL(10,2)); INSERT INTO usage_data (subscriber_id, region, country, usage_gb) VALUES (1, 'West', NULL, 10.5), (2, NULL, 'Canada', 7.3);
|
What is the combined data usage in GB for the 'West' region and 'Canada' country for the last month?
|
SELECT SUM(usage_gb) FROM usage_data WHERE region = 'West' OR country = 'Canada' AND usage_date >= DATE_SUB(CURDATE(), INTERVAL 1 MONTH);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE songs (id INT, title TEXT, length FLOAT, genre TEXT); INSERT INTO songs (id, title, length, genre) VALUES (1, 'Song1', 3.2, 'classical'), (2, 'Song2', 4.1, 'rock'), (3, 'Song3', 3.8, 'pop'), (4, 'Song4', 2.1, 'classical'), (5, 'Song5', 5.3, 'classical');
|
What is the total duration of all classical songs?
|
SELECT SUM(length) FROM songs WHERE genre = 'classical';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE CityNews (id INT, reader_age INT, preference VARCHAR(20)); CREATE TABLE DailyDigest (id INT, reader_age INT, preference VARCHAR(20));
|
What is the average age of readers who prefer digital newspapers in 'CityNews' and 'DailyDigest'?
|
SELECT AVG(cn.reader_age) as avg_age FROM CityNews cn INNER JOIN DailyDigest dd ON cn.id = dd.id WHERE cn.preference = 'digital' AND dd.preference = 'digital';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Manufacturer_Stats (Manufacturer_ID INT, Avg_Engine_Power DECIMAL(5,2), Aircraft_Count INT, Satellites_Count INT);
|
What is the average engine power level for each manufacturer, and how many aircraft and satellites have been produced by them?
|
SELECT Manufacturers.Manufacturer, AVG(Engines.Power_Level) AS Avg_Engine_Power, COUNT(DISTINCT Aircraft.Aircraft_ID) AS Aircraft_Count, COUNT(DISTINCT Satellites.Satellite_ID) AS Satellites_Count FROM Manufacturers LEFT JOIN Engines ON Manufacturers.Manufacturer_ID = Engines.Manufacturer_ID LEFT JOIN Aircraft ON Manufacturers.Manufacturer_ID = Aircraft.Manufacturer_ID LEFT JOIN Satellites ON Manufacturers.Manufacturer_ID = Satellites.Manufacturer_ID GROUP BY Manufacturers.Manufacturer_ID;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Manufacturers (ManufacturerID INT, ManufacturerName VARCHAR(50), Region VARCHAR(50), FairTrade VARCHAR(5));
|
Insert a new manufacturer 'SustainableFabrics' in the 'Americas' region with 'No' FairTrade status.
|
INSERT INTO Manufacturers (ManufacturerID, ManufacturerName, Region, FairTrade) VALUES (5, 'SustainableFabrics', 'Americas', 'No');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Aircraft (AircraftID INT, AircraftName VARCHAR(50), ManufacturerID INT, Type VARCHAR(50));
|
What are the names of the aircraft manufactured by companies located in the USA, excluding military aircraft?
|
SELECT AircraftName FROM Aircraft JOIN AircraftManufacturers ON Aircraft.ManufacturerID = AircraftManufacturers.ID WHERE Type != 'Military' AND Country = 'USA';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE MarsRovers (Id INT, Name VARCHAR(50), Operator VARCHAR(50), LaunchYear INT); INSERT INTO MarsRovers (Id, Name, Operator, LaunchYear) VALUES (1, 'Sojourner', 'NASA', 1996), (2, 'Spirit', 'NASA', 2003), (3, 'Opportunity', 'NASA', 2003), (4, 'Curiosity', 'NASA', 2011), (5, 'Perseverance', 'NASA', 2020);
|
How many Mars rovers has NASA deployed?
|
SELECT COUNT(*) FROM MarsRovers WHERE Operator = 'NASA';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE students (student_id INT, name TEXT, department TEXT); INSERT INTO students (student_id, name, department) VALUES (1, 'Alice Johnson', 'Computer Science'), (2, 'Bob Brown', 'Education'); CREATE TABLE grants (grant_id INT, student_id INT, department TEXT, amount INT); INSERT INTO grants (grant_id, student_id, department, amount) VALUES (1, 1, 'Health', 5000), (2, 2, 'Education', 15000);
|
Which graduate students have received research grants from the department of Education in the amount greater than $10,000?
|
SELECT s.name, g.amount FROM students s INNER JOIN grants g ON s.student_id = g.student_id WHERE g.department = 'Education' AND g.amount > 10000;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE travel_advisories (id INT, country VARCHAR(50), issue_date DATE); INSERT INTO travel_advisories (id, country, issue_date) VALUES (1, 'Japan', '2022-01-05'), (2, 'Japan', '2021-12-10'), (3, 'Japan', '2021-07-20');
|
How many travel advisories were issued for Japan in the last 6 months?
|
SELECT COUNT(*) FROM travel_advisories WHERE country = 'Japan' AND issue_date >= DATE_SUB(CURDATE(), INTERVAL 6 MONTH);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE incidents(id INT, date DATE, severity VARCHAR(10), country VARCHAR(50), attack_vector VARCHAR(50)); INSERT INTO incidents(id, date, severity, country, attack_vector) VALUES (1, '2021-01-01', 'high', 'Egypt', 'malware'), (2, '2021-01-02', 'medium', 'South Africa', 'phishing');
|
What is the daily count and average severity of high incidents in Africa?
|
SELECT date, COUNT(*) as total_incidents, AVG(severity = 'high'::int) as avg_high_severity FROM incidents WHERE country = 'Africa' GROUP BY date ORDER BY date;
|
gretelai_synthetic_text_to_sql
|
CREATE SCHEMA if not exists biotech;CREATE TABLE if not exists biotech.startups(id INT, name TEXT, location TEXT, funding FLOAT);INSERT INTO biotech.startups (id, name, location, funding) VALUES (1, 'StartupA', 'US', 5000000), (2, 'StartupB', 'UK', 3000000), (3, 'StartupC', 'UK', 4000000);
|
What is the total funding received by each biotech startup?
|
SELECT name, SUM(funding) FROM biotech.startups GROUP BY name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE donors (id INT PRIMARY KEY, name VARCHAR(50), donation_amount DECIMAL(10,2), donation_date DATE); CREATE TABLE program_funding (donor_id INT, program_name VARCHAR(50), funding_year INT);
|
How many unique donors funded the 'Youth Art Education' program in 2021?
|
SELECT COUNT(DISTINCT donor_id) AS num_unique_donors FROM donors INNER JOIN program_funding ON donors.id = program_funding.donor_id WHERE program_name = 'Youth Art Education' AND funding_year = 2021;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE CancerData (State VARCHAR(255), CancerType VARCHAR(255), Cases DECIMAL(10,2)); INSERT INTO CancerData (State, CancerType, Cases) VALUES ('State A', 'Breast', 1200.00), ('State A', 'Lung', 1100.00), ('State A', 'Colon', 800.00), ('State B', 'Breast', 1400.00), ('State B', 'Lung', 1000.00), ('State B', 'Colon', 1100.00);
|
What is the most common type of cancer in each state, and how many cases were reported for that type of cancer?
|
SELECT State, CancerType, Cases FROM CancerData WHERE (State, CancerType) IN (SELECT State, MAX(Cases) FROM CancerData GROUP BY State);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Customers (CustomerID INT, Age INT, PreferredFabric TEXT); INSERT INTO Customers (CustomerID, Age, PreferredFabric) VALUES (1, 25, 'Organic Cotton'), (2, 35, 'Recycled Polyester'), (3, 45, 'Hemp'), (4, 55, 'Polyester');
|
How many customers in each age group have made a purchase in the past year, grouped by their preferred sustainable fabric type?
|
SELECT PreferredFabric, Age, COUNT(DISTINCT Customers.CustomerID) FROM Customers INNER JOIN Purchases ON Customers.CustomerID = Purchases.CustomerID WHERE Purchases.PurchaseDate BETWEEN '2021-01-01' AND '2022-12-31' GROUP BY PreferredFabric, Age;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE if not exists sales (id INT PRIMARY KEY, product_id INT, purchase_date DATE, quantity INT, price DECIMAL(5,2)); INSERT INTO sales (id, product_id, purchase_date, quantity, price) VALUES (1, 1, '2022-01-01', 5, 12.99); CREATE TABLE if not exists product (id INT PRIMARY KEY, name TEXT, brand_id INT, price DECIMAL(5,2)); INSERT INTO product (id, name, brand_id, price) VALUES (1, 'Solid Shampoo Bar', 1, 12.99); CREATE TABLE if not exists brand (id INT PRIMARY KEY, name TEXT, category TEXT, country TEXT); INSERT INTO brand (id, name, category, country) VALUES (1, 'Lush', 'Cosmetics', 'United Kingdom');
|
What are the total sales for a specific brand?
|
SELECT SUM(quantity * price) FROM sales JOIN product ON sales.product_id = product.id JOIN brand ON product.brand_id = brand.id WHERE brand.name = 'Lush';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE natural_disasters (id INT, disaster_date DATE, response_time INT); INSERT INTO natural_disasters (id, disaster_date, response_time) VALUES (1, '2019-07-01', 12), (2, '2019-08-01', 15), (3, '2019-12-25', 18);
|
Calculate the average response time for natural disasters in the second half of 2019
|
SELECT AVG(response_time) as avg_response_time FROM natural_disasters WHERE disaster_date BETWEEN '2019-07-01' AND '2019-12-31';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE heritage_sites (id INT, site_name VARCHAR(255), country VARCHAR(255), year INT); INSERT INTO heritage_sites (id, site_name, country, year) VALUES (1, 'Taj Mahal', 'India', 1653), (2, 'Machu Picchu', 'Peru', 1460);
|
How many heritage sites are there in each country?
|
SELECT country, COUNT(*) FROM heritage_sites GROUP BY country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE clients (client_id INT, name VARCHAR(50)); CREATE TABLE transactions (transaction_id INT, client_id INT, date DATE); INSERT INTO clients (client_id, name) VALUES (1, 'John Doe'), (2, 'Jane Smith'); INSERT INTO transactions (transaction_id, client_id, date) VALUES (1, 1, '2021-01-01'), (2, 1, '2021-01-15'), (3, 2, '2021-01-30');
|
How many transactions were made by each client in Q1 of 2021?
|
SELECT c.client_id, c.name, COUNT(*) FROM clients c INNER JOIN transactions t ON c.client_id = t.client_id WHERE t.date BETWEEN '2021-01-01' AND '2021-03-31' GROUP BY c.client_id, c.name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE projects (id INT, name VARCHAR(255), sector VARCHAR(255), project_start_date DATE);
|
What is the percentage of projects in the 'Renewable Energy' sector for each year since 2018?
|
SELECT YEAR(project_start_date) AS year, (COUNT(*) FILTER (WHERE sector = 'Renewable Energy')) * 100.0 / COUNT(*) AS percentage FROM projects WHERE YEAR(project_start_date) >= 2018 GROUP BY year;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE sales (id INT, location VARCHAR(20), quantity INT, price DECIMAL(5,2)); INSERT INTO sales (id, location, quantity, price) VALUES (1, 'Northeast', 50, 12.99), (2, 'Midwest', 75, 19.99), (3, 'West', 35, 14.49);
|
Find the total revenue for the West coast region.
|
SELECT SUM(quantity * price) AS total_revenue FROM sales WHERE location = 'West';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE sales (strain_type VARCHAR(10), state VARCHAR(20), total_sales INT); INSERT INTO sales (strain_type, state, total_sales) VALUES ('sativa', 'California', 500); INSERT INTO sales (strain_type, state, total_sales) VALUES ('sativa', 'Colorado', 400); INSERT INTO sales (strain_type, state, total_sales) VALUES ('sativa', 'Washington', 300); INSERT INTO sales (strain_type, state, total_sales) VALUES ('sativa', 'Oregon', 200); INSERT INTO sales (strain_type, state, total_sales) VALUES ('sativa', 'Nevada', 100);
|
List the top 5 states with the highest total sales of sativa strains.
|
SELECT state, SUM(total_sales) AS total_sales FROM sales WHERE strain_type = 'sativa' GROUP BY state ORDER BY total_sales DESC LIMIT 5;
|
gretelai_synthetic_text_to_sql
|
CREATE SCHEMA workouts; CREATE TABLE workout_durations (workout_id INT, workout_name VARCHAR(50), duration INT, duration_unit VARCHAR(10), workout_date DATE); INSERT INTO workout_durations VALUES (1, 'Yoga', 60, 'minutes', '2022-04-01'), (2, 'Cycling', 45, 'minutes', '2022-04-02'), (3, 'Pilates', 45, 'minutes', '2022-04-03'), (4, 'Running', 30, 'minutes', '2022-04-04'), (5, 'Swimming', 60, 'minutes', '2022-04-05');
|
List the top 5 most popular workouts by duration in April 2022.'
|
SELECT workout_name, SUM(duration) as total_duration FROM workouts.workout_durations WHERE workout_date >= '2022-04-01' AND workout_date <= '2022-04-30' GROUP BY workout_name ORDER BY total_duration DESC LIMIT 5;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE factories (factory_id INT, department VARCHAR(255), worker_count INT, average_salary DECIMAL(10,2)); INSERT INTO factories VALUES (1, 'textiles', 50, 2500.00), (2, 'metalwork', 30, 3000.00);
|
Update the average salary for the 'metalwork' department in the 'factory1' to 3200.00.
|
UPDATE factories SET average_salary = 3200.00 WHERE factory_id = 1 AND department = 'metalwork';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE user_registrations (registration_time TIMESTAMP); INSERT INTO user_registrations (registration_time) VALUES ('2021-01-01 10:30:00'), ('2021-01-01 12:20:00'), ('2021-01-01 13:10:00'), ('2021-01-02 09:05:00'), ('2021-01-02 10:40:00'), ('2021-01-02 11:35:00');
|
What is the number of users registered in each hour of the day?
|
SELECT EXTRACT(HOUR FROM registration_time) AS hour, COUNT(*) FROM user_registrations GROUP BY hour;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE network_investments (investment_id INT, investment_amount DECIMAL(10,2), investment_date DATE, sector VARCHAR(255));
|
What is the total network investment in the telecom sector for the current year?
|
SELECT SUM(investment_amount) as total_investment FROM network_investments WHERE sector = 'telecom' AND investment_date >= DATE_SUB(CURDATE(), INTERVAL 1 YEAR);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE cases (case_id INT, client_id INT, outcome VARCHAR(10)); CREATE TABLE clients (client_id INT, age INT, gender VARCHAR(6), income DECIMAL(10,2)); INSERT INTO cases (case_id, client_id, outcome) VALUES (1, 1, 'Positive'), (2, 2, 'Negative'); INSERT INTO clients (client_id, age, gender, income) VALUES (1, 35, 'Female', 50000.00), (2, 45, 'Male', 60000.00);
|
What are the client demographics for cases with a positive outcome?
|
SELECT c.age, c.gender, c.income FROM clients c JOIN cases cs ON c.client_id = cs.client_id WHERE cs.outcome = 'Positive';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE DanceForms (id INT, name VARCHAR(50), region VARCHAR(50)); INSERT INTO DanceForms (id, name, region) VALUES (1, 'Bomba', 'Caribbean'), (2, 'Plena', 'Caribbean'), (3, 'Merengue', 'Caribbean'), (4, 'Bachata', 'Caribbean'), (5, 'Salsa', 'Caribbean'); CREATE TABLE Dancers (id INT, dance_form_id INT, name VARCHAR(50), annual_participants INT); INSERT INTO Dancers (id, dance_form_id, name, annual_participants) VALUES (1, 1, 'Ana', 2500), (2, 2, 'Ben', 1800), (3, 3, 'Carla', 1200), (4, 4, 'Diego', 2300), (5, 5, 'Elena', 1900);
|
Which traditional dances in the Caribbean region have more than 2000 annual participants?
|
SELECT df.name, df.region FROM DanceForms df JOIN Dancers d ON df.id = d.dance_form_id WHERE d.annual_participants > 2000;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE packages (route_id INT, route_name VARCHAR(255), shipped_qty INT, shipped_year INT); INSERT INTO packages (route_id, route_name, shipped_qty, shipped_year) VALUES (1, 'NYC to LA', 500, 2021), (2, 'LA to NYC', 550, 2021), (3, 'NYC to CHI', 400, 2021);
|
Find the top 3 routes with the most packages shipped in 2021?
|
SELECT route_name, SUM(shipped_qty) as total_shipped FROM packages WHERE shipped_year = 2021 GROUP BY route_name ORDER BY total_shipped DESC LIMIT 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE budget (category TEXT, year INT, amount INT); INSERT INTO budget (category, year, amount) VALUES ('intelligence operations', 2022, 10000000); INSERT INTO budget (category, year, amount) VALUES ('military technology', 2022, 15000000);
|
What is the total budget for intelligence operations for the year 2022?
|
SELECT SUM(amount) FROM budget WHERE category = 'intelligence operations' AND year = 2022;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ExhibitionLocations (exhibition_id INT, city VARCHAR(20), visitor_count INT); INSERT INTO ExhibitionLocations (exhibition_id, city, visitor_count) VALUES (1, 'Tokyo', 50), (2, 'Tokyo', 75), (3, 'Seoul', 100), (4, 'Paris', 120);
|
Calculate the total visitor count for exhibitions held in Tokyo and Seoul.
|
SELECT SUM(visitor_count) FROM ExhibitionLocations WHERE city IN ('Tokyo', 'Seoul');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ai_ethics_trainings (id INT PRIMARY KEY, date DATE, topic VARCHAR(255), description VARCHAR(255));
|
Update the "topic" of the training with id 1 in the "ai_ethics_trainings" table to 'AI bias and fairness'
|
WITH updated_data AS (UPDATE ai_ethics_trainings SET topic = 'AI bias and fairness' WHERE id = 1 RETURNING *) SELECT * FROM updated_data;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE imports (id INT, country VARCHAR(50), Terbium_imported FLOAT, importer_id INT, datetime DATETIME); INSERT INTO imports (id, country, Terbium_imported, importer_id, datetime) VALUES (1, 'China', 120.0, 500, '2017-01-01 10:00:00'), (2, 'Japan', 90.0, 350, '2017-02-15 14:30:00');
|
Find the total quantity of Terbium imported to Asian countries before 2018 and the number of unique importers.
|
SELECT country, SUM(Terbium_imported) AS total_Terbium, COUNT(DISTINCT importer_id) AS unique_importers FROM imports WHERE YEAR(datetime) < 2018 AND Terbium_imported IS NOT NULL AND country LIKE 'Asia%' GROUP BY country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE warehouse (id VARCHAR(5), name VARCHAR(10), location VARCHAR(15)); INSERT INTO warehouse (id, name, location) VALUES ('W01', 'BOS', 'Boston'), ('W02', 'NYC', 'New York'), ('W03', 'SEA', 'Seattle'); CREATE TABLE shipment (id INT, warehouse_id VARCHAR(5), destination VARCHAR(10), weight INT, shipped_date DATE); INSERT INTO shipment (id, warehouse_id, destination, weight, shipped_date) VALUES (1, 'SEA', 'NYC', 100, '2022-01-05'), (2, 'SEA', 'LAX', 200, '2022-01-10'), (3, 'SEA', 'CHI', 150, '2022-01-15'), (4, 'NYC', 'MIA', 50, '2022-01-20');
|
How many items were shipped from each warehouse in January 2022?
|
SELECT w.location, COUNT(s.id) FROM shipment s JOIN warehouse w ON s.warehouse_id = w.id WHERE s.shipped_date >= '2022-01-01' AND s.shipped_date < '2022-02-01' GROUP BY w.location;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE vehicle (id INT PRIMARY KEY, name VARCHAR(255), production_date DATE); INSERT INTO vehicle (id, name, production_date) VALUES (1, 'Tesla Model S', '2012-06-22'), (2, 'Nissan Leaf', NULL), (3, 'Chevrolet Bolt', '2016-12-13');
|
Delete records of vehicles with missing production dates.
|
DELETE FROM vehicle WHERE production_date IS NULL;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE if not exists wind_projects (project_id integer, project_start_date date, co2_emission_reduction_tons integer); INSERT INTO wind_projects (project_id, project_start_date, co2_emission_reduction_tons) VALUES (1, '2021-01-01', 1000), (2, '2021-06-01', 2000), (3, '2021-12-31', 1500);
|
What is the average CO2 emission reduction (in metric tons) for wind projects that came online in 2021?
|
SELECT AVG(co2_emission_reduction_tons) as avg_reduction FROM wind_projects WHERE project_start_date BETWEEN '2021-01-01' AND '2021-12-31';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE SupplyChainTransparency(supplier_id INT, supplier_country VARCHAR(50), is_organic BOOLEAN);
|
Which countries have the lowest number of suppliers with organic products in the SupplyChainTransparency table?
|
SELECT supplier_country, COUNT(*) as num_suppliers FROM SupplyChainTransparency WHERE is_organic = TRUE GROUP BY supplier_country ORDER BY num_suppliers ASC LIMIT 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE sales (product_line VARCHAR(10), date DATE, revenue FLOAT); INSERT INTO sales (product_line, date, revenue) VALUES ('Premium', '2021-07-01', 6000), ('Basic', '2021-07-01', 4000), ('Premium', '2021-07-02', 7000), ('Basic', '2021-07-02', 5000);
|
What was the total revenue for the "Premium" product line in Q3 2021?
|
SELECT SUM(revenue) FROM sales WHERE product_line = 'Premium' AND date BETWEEN '2021-07-01' AND '2021-09-30';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE safety_records (safety_record_id INT, vessel_id INT, safety_inspection_date DATE); INSERT INTO safety_records (safety_record_id, vessel_id, safety_inspection_date) VALUES (1, 1, '2022-03-01'), (2, 3, '2022-05-15'), (3, 5, NULL);
|
Delete safety records with missing safety_inspection_date
|
DELETE FROM safety_records WHERE safety_inspection_date IS NULL;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Licenses (LicenseID INT, State TEXT, Type TEXT); INSERT INTO Licenses (LicenseID, State, Type) VALUES (1, 'Colorado', 'Production'); INSERT INTO Licenses (LicenseID, State, Type) VALUES (2, 'Oregon', 'Production');
|
How many production licenses were issued in Colorado and Oregon?
|
SELECT COUNT(*) FROM Licenses WHERE State IN ('Colorado', 'Oregon') AND Type = 'Production';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Volunteers (VolunteerID INT, VolunteerName TEXT, Department TEXT, Hours DECIMAL); INSERT INTO Volunteers (VolunteerID, VolunteerName, Department, Hours) VALUES (1, 'Alice', 'Environment', 50), (2, 'Bob', 'Marketing', 25), (3, 'Charlie', 'Environment', 75), (4, 'David', 'Arts', 100);
|
What is the name of the volunteer with the most hours in the 'Environment' department?
|
SELECT VolunteerName FROM Volunteers WHERE Department = 'Environment' AND Hours = (SELECT MAX(Hours) FROM Volunteers WHERE Department = 'Environment');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Transactions (transactionID int, transactionDate datetime, retailSector varchar(255)); INSERT INTO Transactions VALUES (1, '2022-01-01', 'ethical labor practices');
|
List all the transactions that occurred in the last month in the ethical labor practices retail sector.
|
SELECT * FROM Transactions WHERE transactionDate >= DATE_SUB(NOW(), INTERVAL 1 MONTH) AND retailSector = 'ethical labor practices';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Disinformation (ID INT, Topic TEXT, Date DATE); INSERT INTO Disinformation (ID, Topic, Date) VALUES (1, 'Politics', '2022-01-01'), (2, 'Health', '2022-01-05'), (3, 'Politics', '2022-01-07');
|
Identify the most common disinformation topic in the past week.
|
SELECT Topic, COUNT(*) as Count FROM Disinformation WHERE Date >= DATEADD(week, -1, CURRENT_DATE) GROUP BY Topic ORDER BY Count DESC LIMIT 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Wages (id INT, worker_id INT, country VARCHAR(255), wage DECIMAL(10,2)); INSERT INTO Wages (id, worker_id, country, wage) VALUES (1, 3001, 'Vietnam', 120.00), (2, 3002, 'Cambodia', 150.00), (3, 3003, 'Vietnam', 130.00);
|
Update the wage for garment worker with ID 3002 to $160.00
|
UPDATE Wages SET wage = 160.00 WHERE worker_id = 3002;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE diagnoses (id INT, patient_id INT, condition VARCHAR(255)); CREATE TABLE patients (id INT, age INT, country VARCHAR(255)); INSERT INTO diagnoses (id, patient_id, condition) VALUES (1, 1, 'Anxiety'), (2, 2, 'Depression'), (3, 3, 'Bipolar'); INSERT INTO patients (id, age, country) VALUES (1, 35, 'USA'), (2, 42, 'Canada'), (3, 28, 'Mexico'), (4, 22, 'USA'), (5, 31, 'Canada');
|
What is the most common age range for patients diagnosed with anxiety?
|
SELECT FLOOR(age / 10) * 10 AS age_range, COUNT(*) FROM patients JOIN diagnoses ON patients.id = diagnoses.patient_id WHERE condition = 'Anxiety' GROUP BY age_range ORDER BY COUNT(*) DESC LIMIT 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Candidates (CandidateID INT, Community VARCHAR(30), HireDate DATE); INSERT INTO Candidates (CandidateID, Community, HireDate) VALUES (4, 'Underrepresented', '2022-03-15');
|
How many candidates from underrepresented communities were hired in the last year?
|
SELECT COUNT(*) FROM Candidates WHERE Community = 'Underrepresented' AND HireDate BETWEEN DATE_SUB(CURDATE(), INTERVAL 1 YEAR) AND CURDATE();
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE WildlifeSightings (id INT, territory VARCHAR(20), animal VARCHAR(20), sighted_date DATE); INSERT INTO WildlifeSightings (id, territory, animal, sighted_date) VALUES (1, 'Yukon', 'Moose', '2021-07-01'); INSERT INTO WildlifeSightings (id, territory, animal, sighted_date) VALUES (2, 'Northwest Territories', 'Caribou', '2021-08-10');
|
What is the total number of wildlife sightings in Yukon and Northwest Territories?
|
SELECT SUM(signcount) FROM (SELECT CASE WHEN territory IN ('Yukon', 'Northwest Territories') THEN 1 ELSE 0 END AS signcount FROM WildlifeSightings) AS subquery;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ports (id INT, name VARCHAR(50), country VARCHAR(20), location VARCHAR(50)); INSERT INTO ports (id, name, country, location) VALUES (1, 'Port of Tokyo', 'Japan', 'Tokyo'); INSERT INTO ports (id, name, country, location) VALUES (2, 'Port of San Francisco', 'USA', 'San Francisco');
|
Update the 'location' column to 'San Francisco Bay Area' in the 'ports' table for the port with id = 2
|
UPDATE ports SET location = 'San Francisco Bay Area' WHERE id = 2;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Aircraft (Id INT, Name VARCHAR(50), Manufacturer VARCHAR(50), FlightHours INT); INSERT INTO Aircraft (Id, Name, Manufacturer, FlightHours) VALUES (1, '737-100', 'Boeing', 30000), (2, '737-200', 'Boeing', 50000), (3, '737-300', 'Boeing', 70000), (4, '737-400', 'Boeing', 80000), (5, '737-500', 'Boeing', 90000), (6, '737-600', 'Boeing', 100000), (7, '737-700', 'Boeing', 120000), (8, '737-800', 'Boeing', 140000), (9, '737-900', 'Boeing', 160000);
|
What is the total number of flight hours for all Boeing 737 aircraft?
|
SELECT SUM(FlightHours) FROM Aircraft WHERE Name LIKE '737%' AND Manufacturer = 'Boeing';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE labor_practices (country VARCHAR(255), ethical_practice BOOLEAN); INSERT INTO labor_practices (country, ethical_practice) VALUES ('US', TRUE), ('China', FALSE), ('Bangladesh', FALSE), ('Italy', TRUE);
|
Which countries have the highest and lowest usage of ethical labor practices?
|
SELECT country, CASE WHEN ethical_practice = TRUE THEN 'High' ELSE 'Low' END as labor_practice_rank FROM labor_practices;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE company_sales (id INT, company VARCHAR(100), sustainable_materials BOOLEAN, revenue DECIMAL(10,2)); INSERT INTO company_sales (id, company, sustainable_materials, revenue) VALUES (1, 'Company A', TRUE, 1000000), (2, 'Company B', FALSE, 500000), (3, 'Company C', TRUE, 2000000);
|
What is the total revenue of companies that use sustainable materials?
|
SELECT SUM(revenue) FROM company_sales WHERE sustainable_materials = TRUE;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE veteran_hires (id INT, hire_number VARCHAR(255), industry VARCHAR(255), job_title VARCHAR(255), date DATE);
|
What is the total number of veteran hires in the defense industry in the last quarter, broken down by job title?
|
SELECT industry, job_title, COUNT(*) FROM veteran_hires WHERE industry = 'defense' AND date >= DATE_SUB(CURRENT_DATE, INTERVAL 3 MONTH) GROUP BY industry, job_title;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Region (RegionID INT, RegionName TEXT); CREATE TABLE Fish (FishID INT, RegionID INT, BirthDate DATE, Weight DECIMAL); INSERT INTO Region VALUES (1, 'North'); INSERT INTO Region VALUES (2, 'South'); INSERT INTO Fish VALUES (1, 1, '2021-01-01', 5.0); INSERT INTO Fish VALUES (2, 1, '2021-02-01', 6.0); INSERT INTO Fish VALUES (3, 2, '2021-03-01', 7.0);
|
What is the total biomass of fish in the ocean by region and month?
|
SELECT RegionName, EXTRACT(MONTH FROM BirthDate) AS Month, SUM(Weight) AS TotalBiomass FROM Region INNER JOIN Fish ON Region.RegionID = Fish.RegionID GROUP BY RegionName, Month;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE aquafarms (id INT, name TEXT); INSERT INTO aquafarms (id, name) VALUES (1, 'Farm A'), (2, 'Farm B'), (3, 'Farm C'), (6, 'Farm F'); CREATE TABLE mortality_data (aquafarm_id INT, species TEXT, mortality_quantity INT, timestamp TIMESTAMP);
|
What is the mortality rate of fish per day for each species at Farm F?
|
SELECT species, DATE(timestamp) AS date, AVG(mortality_quantity) AS avg_mortality_rate FROM mortality_data JOIN aquafarms ON mortality_data.aquafarm_id = aquafarms.id WHERE aquafarm_id = 6 GROUP BY species, date;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE workers_gender_dept (id INT, name VARCHAR(50), department VARCHAR(50), gender VARCHAR(50)); INSERT INTO workers_gender_dept (id, name, department, gender) VALUES (1, 'John Doe', 'manufacturing', 'male'), (2, 'Jane Smith', 'engineering', 'female'), (3, 'Alice Johnson', 'engineering', 'female'), (4, 'Bob Brown', 'manufacturing', 'male'), (5, 'Charlie Green', 'manufacturing', 'non-binary');
|
Determine the percentage of workers who are female in each department
|
SELECT department, (COUNT(*) FILTER (WHERE gender = 'female') * 100.0 / COUNT(*)) as female_percentage FROM workers_gender_dept GROUP BY department;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE water_usage (id INT PRIMARY KEY, region VARCHAR(20), usage INT);
|
Delete all records from the 'water_usage' table where the 'region' is 'Northeast'
|
DELETE FROM water_usage WHERE region = 'Northeast';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE readers (id INT, name VARCHAR(50), age INT, gender VARCHAR(10), country VARCHAR(50));
|
How many female readers are there in 'readers' table?
|
SELECT COUNT(*) FROM readers WHERE gender = 'female';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE student_enrollment (student_id INT, school_id INT, enrollment_date DATE);
|
How many students were enrolled in each school at the end of the last month?
|
SELECT school_id, COUNT(student_id) FROM student_enrollment WHERE enrollment_date < DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) AND school_id IS NOT NULL GROUP BY school_id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE attorneys (attorney_id INT, name VARCHAR(50), last_name VARCHAR(20)); INSERT INTO attorneys (attorney_id, name, last_name) VALUES (1, 'Jane Smith', 'Smith'), (2, 'Michael Johnson', 'Johnson'); CREATE TABLE cases (case_id INT, attorney_id INT, case_outcome VARCHAR(10)); INSERT INTO cases (case_id, attorney_id, case_outcome) VALUES (1, 1, 'Won'), (2, 1, 'Won'), (3, 2, 'Lost');
|
What is the percentage of cases won by attorneys who have a last name starting with the letter 'S'?
|
SELECT 100.0 * COUNT(*) / (SELECT COUNT(*) FROM cases) FROM cases JOIN attorneys ON cases.attorney_id = attorneys.attorney_id WHERE attorneys.last_name LIKE 'S%' AND cases.case_outcome = 'Won';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE stop_sequence (stop_id INT, stop_sequence INT, route_id INT); INSERT INTO stop_sequence (stop_id, stop_sequence, route_id) VALUES (1001, 1, 104), (1002, 2, 104), (1003, 3, 104), (1004, 4, 104), (1005, 5, 104), (1006, 6, 104), (1007, 7, 104);
|
Identify the top 5 most frequently accessed bus stops along a route (route_id 104)?
|
SELECT stop_sequence, stop_id, COUNT(*) as access_count FROM stop_sequence WHERE route_id = 104 GROUP BY stop_sequence ORDER BY access_count DESC LIMIT 5;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE satellites_launch (satellite_id INT, launch_company VARCHAR(50), launch_year INT); INSERT INTO satellites_launch (satellite_id, launch_company, launch_year) VALUES (1, 'China', 2015), (2, 'China', 2017), (3, 'India', 2016), (4, 'India', 2020);
|
What is the total number of satellites launched by China and India between 2015 and 2022?
|
SELECT SUM(launch_company IN ('China', 'India')) FROM satellites_launch WHERE launch_year BETWEEN 2015 AND 2022;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE accessibility_budget (id INT PRIMARY KEY, initiative VARCHAR(255), community VARCHAR(255), state VARCHAR(255), budget DECIMAL(10,2), date DATE);
|
What is the total budget for accessibility initiatives for the Deaf community in New York in the last 12 months?
|
SELECT SUM(budget) FROM accessibility_budget WHERE initiative = 'accessibility' AND community = 'Deaf' AND state = 'New York' AND date >= DATE_SUB(CURDATE(), INTERVAL 12 MONTH);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Policy (PolicyID INT, PolicyholderID INT, Product VARCHAR(10), LastActive DATE); INSERT INTO Policy (PolicyID, PolicyholderID, Product, LastActive) VALUES (1, 1, 'Auto', '2022-01-01'), (2, 2, 'Home', '2021-01-01'), (3, 3, 'Auto', '2022-05-09'), (4, 4, 'Home', '2021-04-04'), (5, 5, 'Auto', '2021-12-12');
|
Delete policies that have been inactive for the last 6 months.
|
DELETE FROM Policy WHERE LastActive < DATEADD(MONTH, -6, GETDATE());
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE if not exists carbon_offsets (initiative_id INT, initiative_name VARCHAR(255), location VARCHAR(255), offset_amount INT);
|
What is the total number of carbon offset initiatives in the 'carbon_offsets' table, by location?
|
SELECT location, COUNT(*) as total_initiatives FROM carbon_offsets GROUP BY location;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE MilitaryTech (id INT, name VARCHAR(255), type VARCHAR(255), country VARCHAR(255), year INT); INSERT INTO MilitaryTech (id, name, type, country, year) VALUES (1, 'F-15', 'Fighter', 'USA', 1976), (2, 'MiG-29', 'Fighter', 'Russia', 1982);
|
What is the distribution of military technologies by country based on year?
|
SELECT country, type, year, NTILE(3) OVER(ORDER BY year) as tercile FROM MilitaryTech;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE smart_contracts (smart_contract_id INT, digital_asset VARCHAR(20), smart_contract_name VARCHAR(30), transaction_amount DECIMAL(10,2), transaction_time DATETIME);
|
Which smart contract has the highest total transaction amount, partitioned by day?
|
SELECT smart_contract_name, SUM(transaction_amount) as total_transaction_amount, DATE_TRUNC('day', transaction_time) as day FROM smart_contracts GROUP BY smart_contract_name, day ORDER BY total_transaction_amount DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE AccommodationsByDisability (AccommodationID INT, AccommodationName VARCHAR(50), DisabilityType VARCHAR(50), Number INT); INSERT INTO AccommodationsByDisability (AccommodationID, AccommodationName, DisabilityType, Number) VALUES (1, 'Sign Language Interpretation', 'Hearing Loss', 500), (2, 'Wheelchair Access', 'Physical Disability', 700), (3, 'Braille Materials', 'Visual Impairment', 350), (4, 'Adaptive Equipment', 'Physical Disability', 600), (5, 'Assistive Technology', 'Intellectual Disability', 400), (6, 'Sensory Rooms', 'Autism Spectrum Disorder', 300);
|
What is the number of accommodations provided per disability type, ordered by the most accommodated?
|
SELECT DisabilityType, SUM(Number) as TotalAccommodations, ROW_NUMBER() OVER (ORDER BY SUM(Number) DESC) as Rank FROM AccommodationsByDisability GROUP BY DisabilityType;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE chemical_waste (plant_id INT, plant_name TEXT, location TEXT, daily_waste_amount FLOAT); INSERT INTO chemical_waste (plant_id, plant_name, location, daily_waste_amount) VALUES (1, 'Plant F', 'CA-ON', 12.3), (2, 'Plant G', 'CA-QC', 15.5), (3, 'Plant H', 'CA-BC', 10.8), (4, 'Plant I', 'US-NY', 14.2), (5, 'Plant J', 'MX-MX', 8.9);
|
What is the maximum amount of chemical waste produced daily by chemical plants in Canada, grouped by province?
|
SELECT location, MAX(daily_waste_amount) as max_daily_waste_amount FROM chemical_waste WHERE location LIKE 'CA-%' GROUP BY location;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE labels (id INT, product VARCHAR(255), is_fragrance_free BOOLEAN, is_vegan BOOLEAN); INSERT INTO labels (id, product, is_fragrance_free, is_vegan) VALUES (1, 'Lotion', true, true), (2, 'Shampoo', false, false), (3, 'Conditioner', true, true), (4, 'Body Wash', false, false), (5, 'Deodorant', true, false);
|
Delete products with both fragrance-free and vegan labels.
|
DELETE FROM labels WHERE is_fragrance_free = true AND is_vegan = true;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE students (id INT, name VARCHAR(255)); CREATE TABLE mental_health_training (id INT, student_id INT, completed_date DATE); INSERT INTO students (id, name) VALUES (1, 'Student G'), (2, 'Student H'), (3, 'Student I'); INSERT INTO mental_health_training (id, student_id, completed_date) VALUES (1, 1, '2021-06-01'), (2, 2, NULL), (3, 3, '2020-12-15');
|
What are the details of students who have not completed their mandatory mental health training in the last year?
|
SELECT s.name, m.completed_date FROM students s LEFT JOIN mental_health_training m ON s.id = m.student_id WHERE m.completed_date IS NULL AND m.completed_date < DATEADD(year, -1, GETDATE());
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE users (id INT, age INT, country VARCHAR(255), followers INT); INSERT INTO users (id, age, country, followers) VALUES (1, 25, 'Italy', 500), (2, 30, 'Nigeria', 600), (3, 35, 'Argentina', 700), (4, 40, 'Poland', 800);
|
What is the average number of followers for users in a given age range?
|
SELECT AVG(followers) FROM users WHERE age BETWEEN 25 AND 35;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE fire_incidents (id INT, incident_date DATE, response_time INT); INSERT INTO fire_incidents (id, incident_date, response_time) VALUES (1, '2022-02-01', 20), (2, '2022-02-02', 25), (3, '2022-02-03', 30);
|
What is the total number of fire incidents in February 2022?
|
SELECT COUNT(*) FROM fire_incidents WHERE incident_date BETWEEN '2022-02-01' AND '2022-02-28';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE vessels (id INT, name TEXT, type TEXT, gps_position TEXT); CREATE TABLE gps_positions (id INT, latitude FLOAT, longitude FLOAT, country TEXT, distance_from_shore FLOAT);
|
What is the minimum and maximum distance from shore for vessels in the Pacific Ocean, grouped by vessel type?
|
SELECT v.type, MIN(g.distance_from_shore), MAX(g.distance_from_shore) FROM vessels v JOIN gps_positions g ON v.gps_position = g.id WHERE g.country = 'Pacific Ocean' GROUP BY v.type;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE mining_operations (id INT, name VARCHAR(50), type VARCHAR(20), location VARCHAR(50)); INSERT INTO mining_operations (id, name, type, location) VALUES (1, 'Mining Operation 1', 'Coal', 'Zimbabwe'), (2, 'Mining Operation 2', 'Gold', 'Zimbabwe');
|
Find the number of coal and gold mining operations in Zimbabwe?
|
SELECT type, COUNT(*) FROM mining_operations WHERE location = 'Zimbabwe' GROUP BY type;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE clients (id INT, age INT, financial_wellbeing_score INT); CREATE TABLE loans (id INT, client_id INT, is_socially_responsible BOOLEAN); INSERT INTO clients (id, age, financial_wellbeing_score) VALUES (1, 27, 7), (2, 35, 8), (3, 23, 6), (4, 31, 9), (5, 45, 10); INSERT INTO loans (id, client_id, is_socially_responsible) VALUES (1, 1, true), (2, 1, false), (3, 2, true), (4, 3, false), (5, 4, true), (6, 5, true);
|
What is the average financial wellbeing score of clients in the age group 25-34 who have taken socially responsible loans?
|
SELECT AVG(c.financial_wellbeing_score) as avg_score FROM clients c JOIN loans l ON c.id = l.client_id WHERE c.age BETWEEN 25 AND 34 AND l.is_socially_responsible = true;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE reporters (id INT, name VARCHAR(50), gender VARCHAR(10), age INT, country VARCHAR(50)); CREATE TABLE published_stories (reporter_id INT, news_id INT);
|
List the names of all journalists who have never published a news story.
|
SELECT r.name FROM reporters r LEFT JOIN published_stories ps ON r.id = ps.reporter_id WHERE ps.news_id IS NULL;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE donations (donation_id INT, donor_type TEXT, sector TEXT, donation_amount FLOAT); INSERT INTO donations (donation_id, donor_type, sector, donation_amount) VALUES (1, 'individual', 'education', 100.00), (2, 'corporate', 'education', 5000.00);
|
What is the minimum donation amount given by individual donors in the 'education' sector?
|
SELECT MIN(donation_amount) FROM donations WHERE donor_type = 'individual' AND sector = 'education';
|
gretelai_synthetic_text_to_sql
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.