context
stringlengths 11
9.12k
| question
stringlengths 0
1.06k
| SQL
stringlengths 2
4.44k
| source
stringclasses 28
values |
|---|---|---|---|
CREATE TABLE teams (team_id INT, team_name VARCHAR(100), country VARCHAR(50)); INSERT INTO teams (team_id, team_name, country) VALUES (1, 'Barcelona', 'Spain'), (2, 'Bayern Munich', 'Germany'); CREATE TABLE matches (match_id INT, team_home_id INT, team_away_id INT, tickets_sold INT); INSERT INTO matches (match_id, team_home_id, team_away_id, tickets_sold) VALUES (1, 1, 2, 5000), (2, 2, 1, 6000);
|
Find the top 3 countries with the highest average ticket sales for football matches.
|
SELECT country, AVG(tickets_sold) as avg_sales FROM matches m JOIN teams t1 ON m.team_home_id = t1.team_id JOIN teams t2 ON m.team_away_id = t2.team_id GROUP BY country ORDER BY avg_sales DESC LIMIT 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE projects (id INT, state VARCHAR(20), size INT, sustainable BOOLEAN); INSERT INTO projects (id, state, size, sustainable) VALUES (1, 'California', 2000, TRUE), (2, 'California', 3000, FALSE), (3, 'New York', 2500, TRUE);
|
What is the total square footage of sustainable urbanism projects in the state of California?
|
SELECT SUM(size) FROM projects WHERE state = 'California' AND sustainable = TRUE;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE pacific_fish (id INT, species VARCHAR(255), biomass FLOAT); INSERT INTO pacific_fish (id, species, biomass) VALUES (1, 'Tuna', 200.0), (2, 'Salmon', 150.0), (3, 'Cod', 120.0);
|
Find the total biomass of fish species in the Pacific Ocean that are above the average biomass.
|
SELECT SUM(biomass) FROM pacific_fish WHERE biomass > (SELECT AVG(biomass) FROM pacific_fish);
|
gretelai_synthetic_text_to_sql
|
VESSEL(vessel_id, vessel_name); TRIP(voyage_id, trip_date, vessel_id, fuel_consumption)
|
Summarize the total fuel consumption by each vessel in a given month
|
SELECT v.vessel_id, v.vessel_name, DATEPART(year, t.trip_date) AS year, DATEPART(month, t.trip_date) AS month, SUM(t.fuel_consumption) AS total_fuel_consumption FROM VESSEL v JOIN TRIP t ON v.vessel_id = t.vessel_id WHERE t.trip_date BETWEEN '2022-01-01' AND '2022-12-31' GROUP BY v.vessel_id, v.vessel_name, DATEPART(year, t.trip_date), DATEPART(month, t.trip_date);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE users (id INT, country VARCHAR(255), last_update DATE);
|
How many users from India have updated their profile information in the last week?
|
SELECT COUNT(*) FROM users WHERE country = 'India' AND last_update >= DATE_SUB(CURDATE(), INTERVAL 1 WEEK);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ratings (id INT, mine_type VARCHAR(20), assessment_rating FLOAT); INSERT INTO ratings (id, mine_type, assessment_rating) VALUES (1, 'Open-pit', 80), (2, 'Underground', 85), (3, 'Open-pit', 82), (4, 'Underground', 88), (5, 'Open-pit', 83), (6, 'Underground', 87);
|
What is the average environmental impact assessment rating per mine type?
|
SELECT mine_type, AVG(assessment_rating) AS avg_rating FROM ratings GROUP BY mine_type ORDER BY avg_rating DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE subscriber_tech (subscriber_id INT, subscription_start_date DATE, technology VARCHAR(50), subscription_fee DECIMAL(10, 2)); INSERT INTO subscriber_tech (subscriber_id, subscription_start_date, technology, subscription_fee) VALUES (1, '2020-01-01', 'Fiber', 50.00), (2, '2019-06-15', 'Cable', 40.00), (5, '2021-02-20', 'LTE', 30.00), (6, '2022-03-15', 'LTE', 25.00), (7, '2020-06-01', 'Fiber', 60.00);
|
What is the average subscription fee for 'Fiber' technology in the 'subscriber_tech' table?
|
SELECT AVG(subscription_fee) as avg_fee FROM subscriber_tech WHERE technology = 'Fiber';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE rd_expenditure (rd_site TEXT, therapeutic_area TEXT, expenditure INTEGER); INSERT INTO rd_expenditure (rd_site, therapeutic_area, expenditure) VALUES ('SiteA', 'oncology', 50000000), ('SiteB', 'oncology', 60000000), ('SiteC', 'oncology', 45000000), ('SiteD', 'oncology', 70000000), ('SiteE', 'oncology', 55000000);
|
Which R&D sites have the highest total R&D expenditure for oncology drugs?
|
SELECT rd_site, SUM(expenditure) as total_expenditure FROM rd_expenditure WHERE therapeutic_area = 'oncology' GROUP BY rd_site ORDER BY total_expenditure DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE donations (id INT, program_category VARCHAR(255), amount DECIMAL(10, 2)); INSERT INTO donations (id, program_category, amount) VALUES (1, 'Education', 5000), (2, 'Health', 7000), (3, 'Education', 3000), (4, 'Health', 8000), (5, 'Environment', 6000);
|
What are the total donation amounts by program category?
|
SELECT program_category, SUM(amount) AS total_donation FROM donations GROUP BY program_category;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Donors (DonorID INT, DonorName TEXT, Continent TEXT, Amount DECIMAL(10,2)); INSERT INTO Donors (DonorID, DonorName, Continent, Amount) VALUES (1, 'DonorD', 'Africa', 1200.00), (2, 'DonorE', 'Europe', 2200.00);
|
Add a new donor, DonorI from Oceania with a donation of 2750.00
|
INSERT INTO Donors (DonorName, Continent, Amount) VALUES ('DonorI', 'Oceania', 2750.00);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE gulf_of_mexico (id INT, well_name VARCHAR(255), drill_date DATE, production_oil INT);
|
How many wells were drilled in the Gulf of Mexico before 2010, and what is the total amount of oil they produced?
|
SELECT COUNT(*) as total_wells, SUM(production_oil) as total_oil_produced FROM gulf_of_mexico WHERE drill_date < '2010-01-01';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE accidents (id INT, site_name VARCHAR(50), date DATE, accident_type VARCHAR(50)); INSERT INTO accidents (id, site_name, date, accident_type) VALUES (1, 'Site X', '2018-03-15', 'Explosion');
|
What is the number of mining accidents caused by 'explosions' in the 'Europe' region, in the last 5 years?
|
SELECT COUNT(*) AS accidents_count FROM accidents WHERE site_name LIKE 'Europe' AND accident_type = 'Explosion' AND date >= DATE_SUB(CURDATE(), INTERVAL 5 YEAR);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE climate_finance(project_name TEXT, region TEXT, source TEXT, budget FLOAT); INSERT INTO climate_finance(project_name, region, source, budget) VALUES ('Project V', 'Canada', 'Government Grant', 500000.00), ('Project W', 'USA', 'Private Investment', 600000.00), ('Project X', 'Canada', 'Carbon Tax', 700000.00);
|
What is the total budget for climate finance sources used for projects in North America, and the number of unique sources?
|
SELECT SUM(budget), COUNT(DISTINCT source) FROM climate_finance WHERE region = 'North America';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE DefenseProjects (project_id INT, project_name VARCHAR(50), start_date DATE, end_date DATE, negotiation_status VARCHAR(50), geopolitical_risk_score INT, project_region VARCHAR(50)); INSERT INTO DefenseProjects (project_id, project_name, start_date, end_date, negotiation_status, geopolitical_risk_score, project_region) VALUES (5, 'Project D', '2022-02-01', '2024-12-31', 'Negotiating', 8, 'Asia'), (6, 'Project E', '2021-06-15', '2023-05-01', 'Completed', 5, 'Asia'), (7, 'Project F', '2022-07-22', '2027-06-30', 'Planning', 7, 'Europe');
|
List the defense projects and their respective start and end dates, along with the contract negotiation status, that have a geopolitical risk score above 6, ordered by the geopolitical risk score in descending order, for projects in the Asia region.
|
SELECT project_name, start_date, end_date, negotiation_status, geopolitical_risk_score FROM DefenseProjects WHERE geopolitical_risk_score > 6 AND project_region = 'Asia' ORDER BY geopolitical_risk_score DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE restaurants (id INT, name VARCHAR(255), city VARCHAR(255), score INT); INSERT INTO restaurants (id, name, city, score) VALUES (1, 'Restaurant A', 'City A', 90), (2, 'Restaurant B', 'City B', 85), (3, 'Restaurant C', 'City A', 95);
|
Determine the average food safety inspection scores for restaurants in each city.
|
SELECT city, AVG(score) FROM restaurants GROUP BY city;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE products (product_id INT, name VARCHAR(255)); INSERT INTO products (product_id, name) VALUES (1, 'Pre-rolls'); CREATE TABLE dispensaries (dispensary_id INT, name VARCHAR(255)); INSERT INTO dispensaries (dispensary_id, name) VALUES (3, 'Sunshine'); CREATE TABLE sales (sale_id INT, product_id INT, dispensary_id INT, quantity INT, sale_date DATE); INSERT INTO sales (sale_id, product_id, dispensary_id, quantity, sale_date) VALUES (10, 1, 3, 4, '2022-04-15');
|
How many times was 'Pre-rolls' product sold in 'Sunshine' dispensary in April 2022?
|
SELECT SUM(quantity) FROM sales WHERE product_id = (SELECT product_id FROM products WHERE name = 'Pre-rolls') AND dispensary_id = (SELECT dispensary_id FROM dispensaries WHERE name = 'Sunshine') AND sale_date BETWEEN '2022-04-01' AND '2022-04-30';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE building_permits (permit_id INT, city VARCHAR(20), year INT, permits_issued INT); INSERT INTO building_permits (permit_id, city, year, permits_issued) VALUES (1, 'Seattle', 2020, 5000), (2, 'Seattle', 2019, 4500), (3, 'New York', 2020, 7000), (4, 'Los Angeles', 2020, 6000);
|
What is the average number of building permits issued per year in the city of New York?
|
SELECT city, AVG(permits_issued) FROM building_permits WHERE city = 'New York' GROUP BY city;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE shared_bikes (bike_id INT, city VARCHAR(20), is_electric BOOLEAN); INSERT INTO shared_bikes (bike_id, city, is_electric) VALUES (1, 'New York', true), (2, 'Chicago', true), (3, 'New York', false);
|
Update the is_electric column to false for all records in the shared_bikes table in New York.
|
UPDATE shared_bikes SET is_electric = false WHERE city = 'New York';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE DailyStreams (StreamID int, SongID int, StreamCount int, StreamDate date); INSERT INTO DailyStreams (StreamID, SongID, StreamCount, StreamDate) VALUES (1, 1, 1000, '2023-02-01'), (2, 2, 2000, '2023-02-02'), (3, 3, 1500, '2023-02-03');
|
What is the average number of streams per day for each song?
|
SELECT Songs.SongName, AVG(DailyStreams.StreamCount) as AverageStreamsPerDay FROM Songs INNER JOIN DailyStreams ON Songs.SongID = DailyStreams.SongID GROUP BY Songs.SongName;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE patients (patient_id INT, has_ptsd BOOLEAN, treatment_date DATE, country VARCHAR(50)); INSERT INTO patients (patient_id, has_ptsd, treatment_date, country) VALUES (1, TRUE, '2022-01-01', 'Germany'), (2, FALSE, '2021-12-25', 'Germany'), (3, TRUE, '2022-03-15', 'Canada');
|
How many patients with PTSD were treated in Germany in the last 6 months?
|
SELECT COUNT(*) FROM patients WHERE has_ptsd = TRUE AND treatment_date >= '2021-07-01' AND country = 'Germany';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE FarmLocation (LocationID INT, FarmName VARCHAR(50), Country VARCHAR(50), AvgStockLevel DECIMAL(5,2)); INSERT INTO FarmLocation (LocationID, FarmName, Country, AvgStockLevel) VALUES (1, 'FishFirst Farm', 'United States', 450.00); INSERT INTO FarmLocation (LocationID, FarmName, Country, AvgStockLevel) VALUES (2, 'Seafood Surprise', 'Canada', 500.00); INSERT INTO FarmLocation (LocationID, FarmName, Country, AvgStockLevel) VALUES (3, 'Ocean Oasis', 'Australia', 300.00);
|
List the top 3 countries with the highest average fish stock levels.
|
SELECT Country, AvgStockLevel FROM FarmLocation ORDER BY AvgStockLevel DESC LIMIT 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE workouts (id INT, workout_date DATE, activity_type VARCHAR(50), duration INT); INSERT INTO workouts (id, workout_date, activity_type, duration) VALUES (1, '2022-01-01', 'strength', 60), (2, '2022-01-02', 'cardio', 45), (3, '2022-01-03', 'strength', 75), (4, '2022-01-04', 'yoga', 60), (5, '2022-01-05', 'strength', 90), (6, '2022-01-06', 'cardio', 45), (7, '2022-01-07', 'strength', 80), (8, '2022-01-08', 'yoga', 50);
|
What is the total number of 'strength' workouts for each day of the week in January 2022?
|
SELECT DATE_FORMAT(workout_date, '%W') AS day_of_week, COUNT(*) AS total_workouts FROM workouts WHERE activity_type = 'strength' AND DATE_FORMAT(workout_date, '%Y-%m') = '2022-01' GROUP BY day_of_week;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE incident_resolution (id INT, timestamp TIMESTAMP, category VARCHAR(255), incident_type VARCHAR(255), resolution_time INT); INSERT INTO incident_resolution (id, timestamp, category, incident_type, resolution_time) VALUES (1, '2022-04-01 10:00:00', 'Phishing', 'Insider Threats', 120), (2, '2022-04-01 10:00:00', 'Malware', 'Insider Threats', 240);
|
Display the total number of security incidents and their respective resolution times for each category in the last quarter.
|
SELECT category, incident_type, SUM(resolution_time) as total_resolution_time, COUNT(*) as incident_count FROM incident_resolution WHERE timestamp >= DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 3 MONTH) GROUP BY category, incident_type;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE shipments (id INT, origin_country VARCHAR(255), destination_continent VARCHAR(255), weight FLOAT); INSERT INTO shipments (id, origin_country, destination_continent, weight) VALUES (1, 'India', 'Asia', 800.0), (2, 'India', 'Europe', 900.0); CREATE TABLE countries (country VARCHAR(255), continent VARCHAR(255)); INSERT INTO countries (country, continent) VALUES ('India', 'Asia');
|
What is the total weight of shipments from a given country to each continent?
|
SELECT origin_country, destination_continent, SUM(weight) as total_weight FROM shipments JOIN countries ON origin_country = country GROUP BY origin_country, destination_continent;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE satellite_deployment (id INT, satellite_name VARCHAR(255), satellite_type VARCHAR(255), country VARCHAR(255), launch_date DATE);
|
Delete all records in the satellite_deployment table where satellite_type is 'LEO' and country is 'USA'
|
DELETE FROM satellite_deployment WHERE satellite_type = 'LEO' AND country = 'USA';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE countries (id INT, name VARCHAR(50), region VARCHAR(50)); INSERT INTO countries (id, name, region) VALUES (1, 'Germany', 'DACH'), (2, 'Austria', 'DACH'), (3, 'Switzerland', 'DACH'); CREATE TABLE videos (id INT, type VARCHAR(50)); INSERT INTO videos (id, type) VALUES (1, 'News'), (2, 'Entertainment'); CREATE TABLE user_video_view (user_id INT, video_id INT, watch_time INT);
|
What is the average watch time of news videos in the DACH region (Germany, Austria, Switzerland)?
|
SELECT AVG(uvv.watch_time) as avg_watch_time FROM user_video_view uvv JOIN videos v ON uvv.video_id = v.id JOIN (SELECT id FROM countries WHERE region = 'DACH') c ON 1=1 WHERE v.type = 'News';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE water_usage (year INT, sector VARCHAR(20), usage INT); INSERT INTO water_usage (year, sector, usage) VALUES (2020, 'residential', 12000), (2020, 'commercial', 15000), (2020, 'industrial', 20000), (2021, 'residential', 11000), (2021, 'commercial', 14000), (2021, 'industrial', 18000);
|
What is the average water usage in the commercial sector over the past two years?
|
SELECT AVG(usage) FROM water_usage WHERE sector = 'commercial' AND year IN (2020, 2021);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE teams (id INT PRIMARY KEY, name VARCHAR(50), city VARCHAR(50), mascot VARCHAR(50));
|
Add a new 'team' record for 'San Francisco Green'
|
INSERT INTO teams (id, name, city, mascot) VALUES (101, 'San Francisco Green', 'San Francisco', 'Green Dragons');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Farm ( FarmID INT, FarmName VARCHAR(255) ); CREATE TABLE Stock ( StockID INT, FarmID INT, FishSpecies VARCHAR(255), Weight DECIMAL(10,2), StockDate DATE ); INSERT INTO Farm (FarmID, FarmName) VALUES (1, 'Farm A'), (2, 'Farm B'), (3, 'Farm C'), (4, 'Farm D'); INSERT INTO Stock (StockID, FarmID, FishSpecies, Weight, StockDate) VALUES (1, 1, 'Tilapia', 5.5, '2022-01-01'), (2, 1, 'Salmon', 12.3, '2022-01-02'), (3, 2, 'Tilapia', 6.0, '2022-01-03'), (4, 2, 'Catfish', 8.2, '2022-01-04');
|
Identify the top 2 aquaculture farms with the highest biomass of fish in a given year?
|
SELECT FarmName, SUM(Weight) OVER (PARTITION BY FarmID) as TotalBiomass, RANK() OVER (ORDER BY SUM(Weight) DESC) as Rank FROM Stock JOIN Farm ON Stock.FarmID = Farm.FarmID WHERE DATE_TRUNC('year', StockDate) = 2022 GROUP BY FarmName, TotalBiomass HAVING Rank <= 2;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE sales (id INT, restaurant_id INT, sales DECIMAL(5,2)); INSERT INTO sales (id, restaurant_id, sales) VALUES (1, 1, 100.00), (2, 1, 200.00), (3, 2, 150.00), (4, 3, 50.00), (5, 4, 300.00);
|
What is the daily revenue for 'Restaurant D'?
|
SELECT SUM(sales) FROM sales WHERE restaurant_id = 4 GROUP BY DATE(time);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE volunteers (volunteer_id INT, volunteer_name TEXT, city TEXT); CREATE TABLE program_assignments (program_id INT, program_name TEXT, volunteer_id INT);
|
Identify the total number of volunteers and their assigned programs by city from 'volunteers' and 'program_assignments' tables
|
SELECT volunteers.city, COUNT(DISTINCT volunteers.volunteer_id) as total_volunteers, COUNT(program_assignments.program_id) as assigned_programs FROM volunteers LEFT JOIN program_assignments ON volunteers.volunteer_id = program_assignments.volunteer_id GROUP BY volunteers.city;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE incidents (id INT, department VARCHAR(255), incident_date DATE); INSERT INTO incidents (id, department, incident_date) VALUES (1, 'HR', '2022-01-15'), (2, 'IT', '2022-02-20'), (3, 'HR', '2022-03-05'); SELECT CURDATE(), DATE_SUB(CURDATE(), INTERVAL 3 MONTH) INTO @current_date, @start_date; SELECT COUNT(*) FROM incidents WHERE department = 'HR' AND incident_date BETWEEN @start_date AND @current_date;
|
What is the total number of security incidents in the last quarter for the HR department?
|
SELECT COUNT(*) FROM incidents WHERE department = 'HR' AND incident_date BETWEEN DATE_SUB(CURDATE(), INTERVAL 3 MONTH) AND CURDATE();
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE company_founding (company_name VARCHAR(255), founder_minority VARCHAR(10)); INSERT INTO company_founding VALUES ('Acme Inc', 'Yes'); INSERT INTO company_founding VALUES ('Beta Corp', 'No'); INSERT INTO company_founding VALUES ('Charlie LLC', 'Yes'); INSERT INTO company_founding VALUES ('Delta Co', 'No');
|
Count the number of companies founded by underrepresented minorities
|
SELECT COUNT(*) FROM company_founding WHERE company_founding.founder_minority = 'Yes';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE yield_data (harvest_date DATE, crop_type TEXT, yield_per_acre FLOAT); INSERT INTO yield_data (harvest_date, crop_type, yield_per_acre) VALUES ('2021-11-01', 'Corn', 180), ('2021-11-01', 'Soybeans', 60), ('2021-12-01', 'Corn', 190);
|
Show yield data for the past harvest season
|
SELECT yield_per_acre FROM yield_data WHERE harvest_date >= DATE(NOW()) - INTERVAL 1 YEAR;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE construction_labor (worker_id INT, hours_worked INT);
|
Delete the construction labor record for worker with ID 5678
|
DELETE FROM construction_labor WHERE worker_id = 5678;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE underwater_canyons (canyon_name TEXT, max_depth_m INT); INSERT INTO underwater_canyons (canyon_name, max_depth_m) VALUES ('Milwaukee Deep', 8380), ('Sirena Deep', 9816), ('Tonga Trench', 10882);
|
What is the maximum depth recorded for any underwater canyon?
|
SELECT MAX(max_depth_m) FROM underwater_canyons;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE country_streams (stream_id INT, country VARCHAR(255), user_id INT, streams_amount INT);
|
What is the average number of streams per user in each country?
|
SELECT country, AVG(streams_amount) FROM country_streams GROUP BY country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE cultural_events (id INT, name VARCHAR(255), state VARCHAR(255), attendance INT);
|
What is the maximum and minimum number of attendees at cultural events in each state, grouped by state?
|
SELECT state, MAX(attendance) AS max_attendance, MIN(attendance) AS min_attendance FROM cultural_events GROUP BY state;
|
gretelai_synthetic_text_to_sql
|
athlete_demographics
|
Show average age of athletes by sport
|
SELECT sport, AVG(age) as avg_age FROM athlete_demographics GROUP BY sport;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE FairTradeCoffee (id INT, origin VARCHAR(50), year INT, quantity INT); INSERT INTO FairTradeCoffee (id, origin, year, quantity) VALUES (1, 'Colombia', 2019, 1000), (2, 'Colombia', 2020, 1500), (3, 'Ethiopia', 2019, 800), (4, 'Ethiopia', 2020, 1200);
|
Get the number of fair-trade coffee beans imported from Colombia in 2020.
|
SELECT COUNT(*) FROM FairTradeCoffee WHERE origin = 'Colombia' AND year = 2020;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE cause_percentage (cause VARCHAR(50), country VARCHAR(50), donation DECIMAL(10,2)); INSERT INTO cause_percentage (cause, country, donation) VALUES ('Global Health', 'Brazil', 3000.00), ('Education', 'Argentina', 4000.00), ('Environment', 'Mexico', 5000.00), ('Animal Welfare', 'Colombia', 6000.00);
|
What is the percentage of total donations made by each cause in Latin America?
|
SELECT cause, (SUM(donation) / (SELECT SUM(donation) FROM cause_percentage WHERE country IN ('Brazil', 'Argentina', 'Mexico', 'Colombia'))) * 100 AS percentage FROM cause_percentage WHERE country IN ('Brazil', 'Argentina', 'Mexico', 'Colombia') GROUP BY cause;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE users (id INT, name TEXT); CREATE TABLE user_actions (id INT, user_id INT, action TEXT, album_id INT, platform TEXT); CREATE TABLE albums (id INT, title TEXT, artist_id INT, platform TEXT); CREATE TABLE artists (id INT, name TEXT); CREATE VIEW taylor_swift_users AS SELECT DISTINCT user_id FROM user_actions JOIN albums a ON user_actions.album_id = a.id JOIN artists ar ON a.artist_id = ar.id WHERE ar.name = 'Taylor Swift';
|
Find the number of unique users who have streamed or downloaded music by the artist 'Taylor Swift'.
|
SELECT COUNT(DISTINCT user_id) FROM taylor_swift_users;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE sales_data (sale_id INT, product VARCHAR(255), country VARCHAR(255), sales FLOAT); INSERT INTO sales_data (sale_id, product, country, sales) VALUES (1, 'ProductA', 'USA', 4000), (2, 'ProductB', 'Brazil', 5000), (3, 'ProductC', 'India', 6000), (4, 'ProductD', 'China', 7000);
|
What are the sales figures for each country?
|
SELECT country, SUM(sales) FROM sales_data GROUP BY country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Programs (program_id INT, budget DECIMAL(10,2), start_date DATE);
|
Add a new program with program_id 201 and a budget of 12000 starting from 2022-01-01.
|
INSERT INTO Programs (program_id, budget, start_date) VALUES (201, 12000, '2022-01-01');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE readers (id INT, age INT, gender VARCHAR(10), country VARCHAR(50), news_preference VARCHAR(50)); INSERT INTO readers (id, age, gender, country, news_preference) VALUES (1, 50, 'Male', 'Australia', 'Political'), (2, 30, 'Female', 'Australia', 'Political');
|
Find the difference between the maximum and minimum age of readers who prefer political news in Australia.
|
SELECT MAX(age) - MIN(age) diff FROM readers WHERE country = 'Australia' AND news_preference = 'Political';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE vessels (id INT, name VARCHAR(255), imo INT); CREATE TABLE inspections (id INT, vessel_id INT, inspection_date DATE);
|
What is the average time between inspections per vessel?
|
SELECT v.name, AVG(DATEDIFF(i2.inspection_date, i.inspection_date)) as avg_time_between_inspections FROM inspections i JOIN inspections i2 ON i.vessel_id = i2.vessel_id AND i.id < i2.id JOIN vessels v ON i.vessel_id = v.id GROUP BY v.name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Astronauts (AstronautID INT, Name VARCHAR(50), Nationality VARCHAR(50));CREATE TABLE MedicalCheckups (CheckupID INT, AstronautID INT, Date DATE); INSERT INTO Astronauts (AstronautID, Name, Nationality) VALUES (1, 'Rajesh Kumar', 'India'), (2, 'Kavita Patel', 'India'); INSERT INTO MedicalCheckups (CheckupID, AstronautID, Date) VALUES (1, 1, '2022-01-01'), (2, 1, '2022-02-01'), (3, 2, '2022-03-01');
|
How many medical checkups did astronauts from India have before their space missions?
|
SELECT COUNT(m.CheckupID) FROM MedicalCheckups m INNER JOIN Astronauts a ON m.AstronautID = a.AstronautID WHERE a.Nationality = 'India';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE digital_assets (id INT, name VARCHAR, issue_country VARCHAR); INSERT INTO digital_assets (id, name, issue_country) VALUES (1, 'CryptoCoin', 'United States'), (2, 'DigiToken', 'Japan'), (3, 'BitAsset', 'China'), (4, 'EtherCoin', 'China'), (5, 'RippleToken', 'India'), (6, 'LiteCoin', 'Canada'), (7, 'MoneroCoin', 'Germany');
|
Find the top 3 countries with the most digital assets issued.
|
SELECT issue_country, COUNT(*) as num_assets FROM digital_assets GROUP BY issue_country ORDER BY num_assets DESC LIMIT 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE products (product_id INT, product_name VARCHAR(255), region VARCHAR(50), sales FLOAT, certified_cruelty_free BOOLEAN); INSERT INTO products (product_id, product_name, region, sales, certified_cruelty_free) VALUES (1, 'Lipstick A', 'Europe', 5000, true), (2, 'Foundation B', 'Asia', 7000, false), (3, 'Mascara C', 'Europe', 6000, true), (4, 'Eye-shadow D', 'America', 8000, false), (5, 'Blush E', 'Europe', 4000, true);
|
What are the top 3 cruelty-free certified cosmetic products by sales in the European market?
|
SELECT product_name, sales FROM products WHERE region = 'Europe' AND certified_cruelty_free = true ORDER BY sales DESC LIMIT 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE revenue(id INT, contractor VARCHAR(50), revenue NUMERIC, quarter INT);
|
What was the total military equipment sales revenue for contractor Z in Q2 2022?
|
SELECT SUM(revenue) FROM revenue WHERE contractor = 'Z' AND quarter = 2;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ocean_acidification_indian (location text, level numeric); INSERT INTO ocean_acidification_indian (location, level) VALUES ('Indian Ocean', 8.1), ('Southern Ocean', 8.2);
|
What is the minimum ocean acidification level in the Indian Ocean?
|
SELECT MIN(level) FROM ocean_acidification_indian WHERE location = 'Indian Ocean';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ResearchExpeditions(expedition VARCHAR(50), co2_emission FLOAT);INSERT INTO ResearchExpeditions(expedition, co2_emission) VALUES('Expedition 1', 10000.0), ('Expedition 2', 15000.0), ('Expedition 3', 20000.0), ('Expedition 4', 12000.0);
|
What is the total CO2 emission for each research expedition?
|
SELECT expedition, SUM(co2_emission) FROM ResearchExpeditions GROUP BY expedition;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE initiatives (initiative_name VARCHAR(50), region VARCHAR(50), budget INT); INSERT INTO initiatives (initiative_name, region, budget) VALUES ('Waste to Energy', 'South', 2000000), ('Recycling', 'South', 2500000), ('Composting', 'South', 1500000);
|
Identify the circular economy initiatives that have a higher budget allocation than 'Waste to Energy' program in the 'South' region.
|
SELECT initiative_name, budget FROM initiatives WHERE region = 'South' AND budget > (SELECT budget FROM initiatives WHERE initiative_name = 'Waste to Energy') AND initiative_name != 'Waste to Energy';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Players (PlayerID INT, PlayerAge INT, GameName VARCHAR(255), Country VARCHAR(255)); INSERT INTO Players (PlayerID, PlayerAge, GameName, Country) VALUES (1, 22, 'Space Conquerors', 'India'); INSERT INTO Players (PlayerID, PlayerAge, GameName, Country) VALUES (2, 28, 'Space Conquerors', 'United States');
|
What is the average age of players who have played 'Space Conquerors' and are from India?
|
SELECT AVG(PlayerAge) FROM (SELECT PlayerAge FROM Players WHERE GameName = 'Space Conquerors' AND Country = 'India') AS Subquery;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE movie_budget (id INT, movie TEXT, director TEXT, budget INT); INSERT INTO movie_budget (id, movie, director, budget) VALUES (1, 'Movie4', 'Director1', 1000000); INSERT INTO movie_budget (id, movie, director, budget) VALUES (2, 'Movie5', 'Director2', 1200000); INSERT INTO movie_budget (id, movie, director, budget) VALUES (3, 'Movie6', 'Director1', 1500000);
|
What is the total production budget for movies by director?
|
SELECT director, SUM(budget) as total_budget FROM movie_budget GROUP BY director;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE refugees (id INT PRIMARY KEY, name VARCHAR(50), arrival_date DATE, region VARCHAR(50)); INSERT INTO refugees (id, name, arrival_date, region) VALUES (1, 'Ahmed', '2020-01-01', 'Middle East'), (2, 'Sofia', '2020-05-10', 'Europe'), (3, 'Hiroshi', '2019-12-31', 'Asia');
|
How many refugees arrived in each region in 2020?
|
SELECT region, COUNT(*) as num_refugees FROM refugees WHERE YEAR(arrival_date) = 2020 GROUP BY region;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE production (year INT, region VARCHAR(10), element VARCHAR(10), quantity INT); INSERT INTO production (year, region, element, quantity) VALUES (2015, 'Oceania', 'Yttrium', 1200), (2016, 'Oceania', 'Yttrium', 1400), (2017, 'Oceania', 'Yttrium', 1500), (2018, 'Oceania', 'Yttrium', 1700), (2019, 'Oceania', 'Yttrium', 1800);
|
What was the average Yttrium production in Oceania between 2016 and 2018?
|
SELECT AVG(quantity) FROM production WHERE element = 'Yttrium' AND region = 'Oceania' AND year BETWEEN 2016 AND 2018;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Vehicles (Id INT, Name TEXT, Type TEXT, SafetyRating INT, ReleaseDate DATE);
|
Insert a new record for the 2022 Tesla Model X with a safety rating of 5 and a release date of 2022-02-22.
|
INSERT INTO Vehicles (Name, Type, SafetyRating, ReleaseDate) VALUES ('2022 Tesla Model X', 'Electric', 5, '2022-02-22');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE shared_ev (vehicle_id INT, trip_id INT, trip_start_time TIMESTAMP, trip_end_time TIMESTAMP, start_latitude DECIMAL(9,6), start_longitude DECIMAL(9,6), end_latitude DECIMAL(9,6), end_longitude DECIMAL(9,6), distance DECIMAL(10,2), max_speed DECIMAL(5,2));
|
What is the maximum speed reached by an electric vehicle in a shared fleet in San Francisco?
|
SELECT MAX(max_speed) FROM shared_ev WHERE start_longitude BETWEEN -122.6 AND -121.9 AND start_latitude BETWEEN 37.6 AND 38.1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE policyholders (id INT, name TEXT, state TEXT); CREATE TABLE policies (id INT, policyholder_id INT, issue_date DATE, claim_amount FLOAT); INSERT INTO policyholders (id, name, state) VALUES (1, 'Sophia Thompson', 'MI'); INSERT INTO policies (id, policyholder_id, issue_date, claim_amount) VALUES (1, 1, '2019-11-15', 800.00);
|
Find the total claim amount for policyholders in 'Michigan' who have policies issued in 2019 and having a claim amount greater than $750.
|
SELECT SUM(claim_amount) FROM policies INNER JOIN policyholders ON policies.policyholder_id = policyholders.id WHERE issue_date >= '2019-01-01' AND issue_date < '2020-01-01' AND claim_amount > 750 AND policyholders.state = 'MI';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE warehouses (id INT, warehouse_name VARCHAR(50), country VARCHAR(50), capacity INT, current_inventory INT);
|
Add a new record to the "warehouses" table with the following data: warehouse_name = "Mumbai Warehouse", country = "India", capacity = 5000, and current_inventory = 3000
|
INSERT INTO warehouses (id, warehouse_name, country, capacity, current_inventory) VALUES (1, 'Mumbai Warehouse', 'India', 5000, 3000);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE programs (id INT PRIMARY KEY, program_name VARCHAR(255), region_id INT, is_financial_wellbeing BOOLEAN, monthly_cost DECIMAL(5,2)); CREATE TABLE regions (id INT PRIMARY KEY, name VARCHAR(255), country VARCHAR(255)); CREATE VIEW program_views AS SELECT programs.id, programs.program_name, programs.region_id, programs.is_financial_wellbeing, programs.monthly_cost, regions.country FROM programs INNER JOIN regions ON TRUE;
|
List the financial wellbeing programs in Africa with the lowest average monthly cost.
|
SELECT program_views.program_name, program_views.monthly_cost FROM program_views WHERE program_views.is_financial_wellbeing = TRUE AND regions.country = 'Africa' ORDER BY program_views.monthly_cost ASC LIMIT 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE water_resources (id INT, quantity INT, country TEXT, half INT, year INT); INSERT INTO water_resources (id, quantity, country, half, year) VALUES (1, 600, 'Syria', 1, 2021), (2, 400, 'Syria', 2, 2021), (3, 500, 'Syria', 1, 2021);
|
How many water resources were distributed in Syria in H1 2021?
|
SELECT SUM(quantity) FROM water_resources WHERE country = 'Syria' AND half = 1 AND year = 2021;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE startups (id INT, name TEXT, founder TEXT, country TEXT, funding FLOAT); INSERT INTO startups (id, name, founder, country, funding) VALUES (1, 'Acme', 'John Doe', 'USA', 500000.00); INSERT INTO startups (id, name, founder, country, funding) VALUES (2, 'Beta Corp', 'Jane Smith', 'Canada', 750000.00); INSERT INTO startups (id, name, founder, country, funding) VALUES (3, 'Gamma Inc', 'Alice', 'India', 300000.00); INSERT INTO startups (id, name, founder, country, funding) VALUES (4, 'Delta', 'Bob', 'USA', 800000.00);
|
What is the total funding for startups founded by individuals from each country?
|
SELECT country, SUM(funding) FROM startups GROUP BY country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE carbon_prices (region TEXT, price FLOAT); INSERT INTO carbon_prices (region, price) VALUES ('European Union Emissions Trading System', 25.0);
|
What is the carbon price in the European Union Emissions Trading System?
|
SELECT price FROM carbon_prices WHERE region = 'European Union Emissions Trading System';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE marine_research_projects (id INT PRIMARY KEY, project_name VARCHAR(255), region VARCHAR(255));
|
Add a new marine research project in the Atlantic Ocean
|
INSERT INTO marine_research_projects (id, project_name, region) VALUES (1, 'Exploring Atlantic Depths', 'Atlantic Ocean');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE public_libraries (library_id INT, library_name TEXT, city TEXT, state TEXT, wi_fi_access BOOLEAN); INSERT INTO public_libraries (library_id, library_name, city, state, wi_fi_access) VALUES (1, 'Seattle Central Library', 'Seattle', 'Washington', TRUE); INSERT INTO public_libraries (library_id, library_name, city, state, wi_fi_access) VALUES (2, 'The Seattle Public Library - Ballard Branch', 'Seattle', 'Washington', TRUE); INSERT INTO public_libraries (library_id, library_name, city, state, wi_fi_access) VALUES (3, 'The Seattle Public Library - Green Lake Branch', 'Seattle', 'Washington', FALSE);
|
What is the number of public libraries in Seattle, Washington that offer free Wi-Fi access?
|
SELECT COUNT(*) FROM public_libraries WHERE city = 'Seattle' AND state = 'Washington' AND wi_fi_access = TRUE;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE threat_intelligence (id INT, date DATE, source VARCHAR(20), category VARCHAR(20), country VARCHAR(20)); INSERT INTO threat_intelligence (id, date, source, category, country) VALUES (1, '2021-01-01', 'internal', 'malware', 'Russia'); INSERT INTO threat_intelligence (id, date, source, category, country) VALUES (2, '2021-01-02', 'external', 'phishing', 'China');
|
What is the number of external threat intelligence sources, by category and country?
|
SELECT category, country, COUNT(*) as external_count FROM threat_intelligence WHERE source = 'external' GROUP BY category, country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE green_buildings (id INT, name VARCHAR(255), category VARCHAR(255), carbon_offsets FLOAT, budget FLOAT); INSERT INTO green_buildings (id, name, category, carbon_offsets, budget) VALUES (1, 'Solar Tower 1', 'solar', 500.0, 4000000.0); INSERT INTO green_buildings (id, name, category, carbon_offsets, budget) VALUES (2, 'Solar Tower 2', 'solar', 800.0, 3000000.0); INSERT INTO green_buildings (id, name, category, carbon_offsets, budget) VALUES (3, 'Wind Farm 1', 'wind', 1000.0, 6000000.0);
|
Calculate the average carbon offset for each green building project category, excluding projects with a budget over 5 million?
|
SELECT category, AVG(carbon_offsets) AS avg_carbon_offsets FROM green_buildings WHERE budget <= 5000000 GROUP BY category;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE tourism_stats (destination VARCHAR(255), year INT, visitors INT); INSERT INTO tourism_stats (destination, year, visitors) VALUES ('Japan', 2019, 15000000), ('Canada', 2019, 23000000), ('France', 2019, 24000000);
|
List the destinations that had more visitors than the average number of visitors in 2019
|
SELECT destination FROM tourism_stats WHERE visitors > (SELECT AVG(visitors) FROM tourism_stats WHERE year = 2019);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE TicketSales (TicketID INT, GameID INT, Team VARCHAR(20), SaleDate DATE, Quantity INT); INSERT INTO TicketSales (TicketID, GameID, Team, SaleDate, Quantity) VALUES (1, 1, 'Bears', '2023-07-01', 600);
|
How many tickets were sold for the away games of the 'Bears' in the second half of the 2023 season?
|
SELECT SUM(Quantity) FROM TicketSales WHERE Team = 'Bears' AND SaleDate BETWEEN '2023-07-01' AND '2023-12-31' AND GameID NOT IN (SELECT GameID FROM Game WHERE HomeTeam = 'Bears');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE MilitaryTech (TechID INT, TechName VARCHAR(50), LastInspection DATE); INSERT INTO MilitaryTech (TechID, TechName, LastInspection) VALUES (1, 'Fighter Jet', '2022-02-01'), (2, 'Tank', '2022-03-10'), (3, 'Submarine', '2022-04-15'), (4, 'Radar System', '2022-05-20'), (5, 'Missile System', '2022-06-25');
|
Update all military technology records with a last inspection date within the last month.
|
UPDATE MilitaryTech SET LastInspection = GETDATE() WHERE LastInspection >= DATEADD(month, -1, GETDATE());
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE military_equipment_manufacturing (equipment_type VARCHAR(255), year INT, unit_count INT, manufacturer VARCHAR(255)); INSERT INTO military_equipment_manufacturing (equipment_type, year, unit_count, manufacturer) VALUES ('Tank', 2018, 200, 'General Dynamics'), ('Tank', 2019, 250, 'General Dynamics'), ('Tank', 2020, 300, 'General Dynamics'), ('Aircraft', 2018, 500, 'Lockheed Martin'), ('Aircraft', 2019, 600, 'Lockheed Martin'), ('Aircraft', 2020, 700, 'Lockheed Martin'), ('Ship', 2018, 50, 'Boeing'), ('Ship', 2019, 60, 'Boeing'), ('Ship', 2020, 70, 'Boeing'), ('Helicopter', 2018, 150, 'Bell Helicopter'), ('Helicopter', 2019, 175, 'Bell Helicopter'), ('Helicopter', 2020, 200, 'Bell Helicopter');
|
What is the number of military equipment units manufactured each year by company?
|
SELECT manufacturer, year, SUM(unit_count) FROM military_equipment_manufacturing GROUP BY manufacturer, year;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE cargo ( id INT PRIMARY KEY, container_id INT, location VARCHAR(255), container_type VARCHAR(255) ); INSERT INTO cargo (id, container_id, location, container_type) VALUES (1, 101, 'Port A', 'reefer'), (2, 102, 'Port B', 'dry'), (3, 103, 'Port C', 'reefer');
|
What are the names of the containers with a type of 'reefer' and their respective current location in the cargo table?
|
SELECT c.container_id, c.location, c.container_type FROM cargo c JOIN shipping_container sc ON c.container_id = sc.id WHERE c.container_type = 'reefer';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Events (event_id INT, category VARCHAR(255), price DECIMAL(5,2)); INSERT INTO Events (event_id, category, price) VALUES (1, 'Concert', 50.99), (2, 'Sports', 30.50), (3, 'Theater', 75.00);
|
What is the average ticket price for each event category?
|
SELECT category, AVG(price) FROM Events GROUP BY category;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE police_interventions (id INT, borough VARCHAR(20), year INT, half INT, interventions INT); INSERT INTO police_interventions (id, borough, year, half, interventions) VALUES (1, 'Queens', 2021, 2, 80); INSERT INTO police_interventions (id, borough, year, half, interventions) VALUES (2, 'Queens', 2021, 2, 85);
|
What is the total number of police interventions in the borough of Queens in the second half of 2021?
|
SELECT SUM(interventions) FROM police_interventions WHERE borough = 'Queens' AND year = 2021 AND half = 2;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE canada_energy_production (year INT, production_quantity INT); INSERT INTO canada_energy_production (year, production_quantity) VALUES (2015, 50000), (2016, 55000), (2017, 60000), (2018, 65000), (2019, 70000), (2020, 75000);
|
What is the total energy production from renewable energy sources in Canada in 2020?
|
SELECT production_quantity FROM canada_energy_production WHERE year = 2020;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Space_Agencies (ID INT, Agency VARCHAR(50), Country VARCHAR(50), Total_Spacecraft INT); INSERT INTO Space_Agencies (ID, Agency, Country, Total_Spacecraft) VALUES (1, 'European Space Agency', 'Europe', 50), (2, 'National Aeronautics and Space Administration', 'USA', 200), (3, 'Roscosmos', 'Russia', 150), (4, 'China National Space Administration', 'China', 100), (5, 'Indian Space Research Organisation', 'India', 75);
|
What is the total number of spacecraft launched by the European Space Agency?
|
SELECT Total_Spacecraft FROM Space_Agencies WHERE Agency = 'European Space Agency';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE hashtags (id INT, hashtag VARCHAR(255), post_id INT, PRIMARY KEY (id)); INSERT INTO hashtags (id, hashtag, post_id) VALUES (1, '#tech', 5001), (2, '#food', 3002), (3, '#travel', 4003);
|
What was the most popular hashtag in the past week, and how many posts used it?
|
SELECT hashtag, COUNT(post_id) AS post_count FROM hashtags WHERE post_id IN (SELECT post_id FROM posts WHERE DATE(post_date) > DATE_SUB(CURRENT_DATE, INTERVAL 1 WEEK)) GROUP BY hashtag ORDER BY post_count DESC LIMIT 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE threat_intel (ip_address VARCHAR(20), threat_level VARCHAR(20), last_seen DATE); INSERT INTO threat_intel (ip_address, threat_level, last_seen) VALUES ('192.168.1.1', 'low', '2021-03-01'), ('10.0.0.1', 'high', '2021-02-10');
|
List all IP addresses and their threat levels from the last month
|
SELECT ip_address, threat_level FROM threat_intel WHERE last_seen >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE industrial_buildings (id INT, zip_code VARCHAR(10), state VARCHAR(50), energy_consumption FLOAT, building_age INT); INSERT INTO industrial_buildings (id, zip_code, state, energy_consumption, building_age) VALUES (1, '10001', 'New York', 5000, 5); INSERT INTO industrial_buildings (id, zip_code, state, energy_consumption, building_age) VALUES (2, '10002', 'New York', 5500, 10);
|
What is the average energy consumption of industrial buildings in New York, grouped by zip code and building age?
|
SELECT zip_code, building_age, AVG(energy_consumption) AS avg_energy_consumption FROM industrial_buildings WHERE state = 'New York' GROUP BY zip_code, building_age;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE deep_sea_expeditions (expedition_name TEXT, funding_org TEXT); INSERT INTO deep_sea_expeditions (expedition_name, funding_org) VALUES ('Atlantis Expedition', 'National Oceanic and Atmospheric Administration'), ('Triton Expedition', 'National Geographic'), ('Poseidon Expedition', 'Woods Hole Oceanographic Institution');
|
Show the total number of deep-sea expeditions funded by each organization.
|
SELECT funding_org, COUNT(*) FROM deep_sea_expeditions GROUP BY funding_org;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE customers (customer_id INT, customer_name VARCHAR(255)); CREATE TABLE menu_items (menu_item_id INT, menu_category VARCHAR(255), item_name VARCHAR(255), is_sustainable BOOLEAN); CREATE TABLE orders (order_id INT, customer_id INT, menu_item_id INT, order_date DATE, order_price INT);
|
List the top 5 customers by spending on sustainable ingredients?
|
SELECT c.customer_name, SUM(o.order_price) as total_spend FROM customers c JOIN orders o ON c.customer_id = o.customer_id JOIN menu_items mi ON o.menu_item_id = mi.menu_item_id WHERE mi.is_sustainable = TRUE GROUP BY c.customer_name ORDER BY total_spend DESC LIMIT 5;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE volunteers (id INT, name TEXT, country TEXT, hours_served INT);
|
What is the total number of volunteer hours served in Q2 of 2022?
|
SELECT SUM(hours_served) FROM volunteers WHERE QUARTER(volunteer_date) = 2 AND YEAR(volunteer_date) = 2022;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE chemical_sites (id INT, site_name VARCHAR(50), country VARCHAR(50), total_waste FLOAT); INSERT INTO chemical_sites (id, site_name, country, total_waste) VALUES (1, 'Site A', 'USA', 150.5), (2, 'Site B', 'Canada', 125.7), (3, 'Site C', 'USA', 200.3), (4, 'Site D', 'Mexico', 75.9);
|
What is the average chemical waste produced per site, partitioned by country and ordered by the highest average?
|
SELECT country, AVG(total_waste) as avg_waste FROM chemical_sites GROUP BY country ORDER BY avg_waste DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE community_education (id INT, name VARCHAR(50), city VARCHAR(50), state VARCHAR(2), country VARCHAR(50));
|
Add data to 'community_education' table
|
INSERT INTO community_education (id, name, city, state, country) VALUES (1, 'GreenLife', 'San Juan', 'PR', 'Puerto Rico');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE subway_routes (region VARCHAR(10), num_routes INT); INSERT INTO subway_routes (region, num_routes) VALUES ('north', 12), ('south', 9), ('east', 8), ('west', 10), ('central', 15);
|
What is the average number of subway routes per region?
|
SELECT AVG(num_routes) FROM subway_routes;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ingredients (ingredient_id INT, name TEXT, sourcing_country TEXT, source_date DATE); INSERT INTO ingredients (ingredient_id, name, sourcing_country, source_date) VALUES (1, 'Water', 'China', '2021-01-01'), (2, 'Glycerin', 'France', '2021-02-15'), (3, 'Retinol', 'USA', '2020-12-10');
|
Delete the records of ingredients that were sourced in China in 2021.
|
DELETE FROM ingredients WHERE sourcing_country = 'China' AND source_date >= '2021-01-01' AND source_date <= '2021-12-31';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE data_breaches (breach_id INT, sector TEXT, year INT); INSERT INTO data_breaches (breach_id, sector, year) VALUES (1, 'Retail', 2019), (2, 'Retail', 2020), (3, 'Financial', 2019), (4, 'Financial', 2020), (5, 'Healthcare', 2019);
|
How many data breaches occurred in the retail sector in 2019 and 2020?
|
SELECT sector, COUNT(*) FROM data_breaches WHERE sector = 'Retail' AND year IN (2019, 2020) GROUP BY sector;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE customers (id INT, name VARCHAR(255)); INSERT INTO customers (id, name) VALUES (1, 'John Doe'), (2, 'Jane Smith'); CREATE TABLE orders (id INT, customer_id INT, dish_id INT); INSERT INTO orders (id, customer_id, dish_id) VALUES (1, 1, 1), (2, 1, 2), (3, 2, 2), (4, 2, 3); CREATE TABLE dishes (id INT, name VARCHAR(255), cuisine VARCHAR(255)); INSERT INTO dishes (id, name, cuisine) VALUES (1, 'Pizza Margherita', 'Italian'), (2, 'Vegan Tacos', 'Mexican'), (3, 'Chana Masala', 'Indian');
|
List all the customers who have ordered dishes from multiple cuisines.
|
SELECT DISTINCT o1.customer_id FROM orders o1 INNER JOIN orders o2 ON o1.customer_id = o2.customer_id WHERE o1.dish_id != o2.dish_id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Employees (EmployeeID INT, Gender VARCHAR(10), Department VARCHAR(20), Salary DECIMAL(10,2)); INSERT INTO Employees (EmployeeID, Gender, Department, Salary) VALUES (1, 'Male', 'IT', 70000.00), (2, 'Female', 'IT', 68000.00), (3, 'Female', 'IT', 72000.00);
|
What is the maximum salary for female employees in the IT department?
|
SELECT MAX(Salary) FROM Employees WHERE Gender = 'Female' AND Department = 'IT';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE City (id INT, name VARCHAR(50)); INSERT INTO City (id, name) VALUES (1, 'New York'); INSERT INTO City (id, name) VALUES (2, 'Los Angeles'); INSERT INTO City (id, name) VALUES (3, 'Delhi'); INSERT INTO City (id, name) VALUES (4, 'Mumbai'); INSERT INTO City (id, name) VALUES (5, 'Tokyo'); CREATE TABLE Policy (id INT, name VARCHAR(50), city_id INT, category VARCHAR(50), budget DECIMAL(10,2), start_date DATE, end_date DATE); INSERT INTO Policy (id, name, city_id, category, budget, start_date, end_date) VALUES (1, 'Education', 3, 'Education', 1200000, '2021-01-01', '2023-12-31'); INSERT INTO Policy (id, name, city_id, category, budget, start_date, end_date) VALUES (2, 'Healthcare', 3, 'Healthcare', 1500000, '2020-01-01', '2022-12-31'); INSERT INTO Policy (id, name, city_id, category, budget, start_date, end_date) VALUES (3, 'Transportation', 4, 'Transportation', 2000000, '2019-01-01', '2024-12-31'); INSERT INTO Policy (id, name, city_id, category, budget, start_date, end_date) VALUES (4, 'Education', 4, 'Education', 1800000, '2020-01-01', '2023-12-31');
|
Which policies were implemented in 'Delhi' or 'Mumbai' between 2018 and 2021?
|
SELECT name, start_date FROM Policy JOIN City ON Policy.city_id = City.id WHERE City.name IN ('Delhi', 'Mumbai') AND YEAR(start_date) BETWEEN 2018 AND 2021;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE city_budgets (city varchar(50), year int, service varchar(50), budget int); INSERT INTO city_budgets (city, year, service, budget) VALUES ('Atlanta', 2022, 'Public Safety', 15000000), ('Atlanta', 2023, 'Public Safety', 16000000), ('Boston', 2022, 'Public Safety', 20000000), ('Boston', 2023, 'Public Safety', 21000000), ('Denver', 2022, 'Public Safety', 12000000), ('Denver', 2023, 'Public Safety', 13000000);
|
What is the average budget allocated for public safety in the cities of Atlanta, Boston, and Denver for the years 2022 and 2023?
|
SELECT AVG(budget) FROM city_budgets WHERE (city = 'Atlanta' OR city = 'Boston' OR city = 'Denver') AND service = 'Public Safety' AND (year = 2022 OR year = 2023);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE turkey_factories (factory_id INT, factory_name VARCHAR(50), factory_size INT, co2_emission INT); INSERT INTO turkey_factories VALUES (1, 'Factory X', 10, 1200); INSERT INTO turkey_factories VALUES (2, 'Factory Y', 15, 1500); INSERT INTO turkey_factories VALUES (3, 'Factory Z', 20, 1800);
|
What is the average CO2 emission of textile factories in Turkey, grouped by factory size and sorted in ascending order?
|
SELECT factory_size, AVG(co2_emission) as avg_emission FROM turkey_factories GROUP BY factory_size ORDER BY avg_emission ASC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE cities (city_name VARCHAR(255), budget INT); INSERT INTO cities (city_name, budget) VALUES ('Los Angeles', 1000000), ('New York', 2000000);
|
What is the total budget allocated for education and healthcare services in the city of Los Angeles?
|
SELECT SUM(budget) FROM cities WHERE city_name IN ('Los Angeles') AND service IN ('education', 'healthcare');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE DisasterTeams (Country VARCHAR(20), TeamID INT); INSERT INTO DisasterTeams (Country, TeamID) VALUES ('Afghanistan', 10), ('Syria', 15), ('Iraq', 20), ('Jordan', 25), ('Lebanon', 30);
|
How many disaster response teams are present in each country?
|
SELECT Country, COUNT(TeamID) as NumTeams FROM DisasterTeams GROUP BY Country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE dissolved_oxygen (location VARCHAR(255), level FLOAT, date DATE);
|
What is the minimum dissolved oxygen level recorded in the Mediterranean Sea?
|
SELECT MIN(level) FROM dissolved_oxygen WHERE location = 'Mediterranean Sea';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE labor_costs_2 (project_id INT, project_type VARCHAR(20), city VARCHAR(20), year INT, cost FLOAT); INSERT INTO labor_costs_2 (project_id, project_type, city, year, cost) VALUES (13, 'Commercial', 'Miami', 2019, 250000), (14, 'Residential', 'Miami', 2020, 180000), (15, 'Commercial', 'Tampa', 2018, 220000);
|
What is the maximum labor cost for commercial construction projects in Miami, Florida in 2019?
|
SELECT MAX(cost) FROM labor_costs_2 WHERE project_type = 'Commercial' AND city = 'Miami' AND year = 2019;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Events (EventID INT, EventName VARCHAR(20), EventCategory VARCHAR(20));CREATE TABLE FundingSources (FundingSourceID INT, FundingSourceName VARCHAR(20));CREATE TABLE EventFunding (EventID INT, FundingSourceID INT, FundingAmount INT);CREATE TABLE Attendees (AttendeeID INT, Age INT, EventID INT);
|
What is the average age of attendees at events in the 'Theater' category that received funding from 'Corporate Sponsors'?
|
SELECT AVG(A.Age) AS Avg_Age FROM Events E INNER JOIN EventFunding EF ON E.EventID = EF.EventID INNER JOIN FundingSources FS ON EF.FundingSourceID = FS.FundingSourceID INNER JOIN Attendees A ON E.EventID = A.EventID WHERE E.EventCategory = 'Theater' AND FS.FundingSourceName = 'Corporate Sponsors';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE customers (customer_id INT, customer_name VARCHAR(255), city VARCHAR(255)); CREATE TABLE transactions (transaction_id INT, customer_id INT, transaction_date DATE, transaction_value DECIMAL(10,2)); INSERT INTO customers (customer_id, customer_name, city) VALUES (1, 'John Doe', 'New York'), (2, 'Jane Smith', 'Los Angeles'), (3, 'Bob Johnson', 'Chicago'); INSERT INTO transactions (transaction_id, customer_id, transaction_date, transaction_value) VALUES (1, 1, '2021-01-01', 100.00), (2, 1, '2021-01-05', 200.00), (3, 2, '2021-01-03', 50.00);
|
List the top 5 customers by transaction count and total transaction value in H1 2021.
|
SELECT c.customer_name, COUNT(t.transaction_id) as transaction_count, SUM(t.transaction_value) as total_transaction_value FROM customers c INNER JOIN transactions t ON c.customer_id = t.customer_id WHERE t.transaction_date BETWEEN '2021-01-01' AND '2021-06-30' GROUP BY c.customer_name ORDER BY transaction_count DESC, total_transaction_value DESC LIMIT 5;
|
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.