context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE patients (id INT, age INT, gender TEXT, state TEXT, disease TEXT); INSERT INTO patients (id, age, gender, state, disease) VALUES (1, 18, 'Female', 'Australia', 'Chlamydia'); INSERT INTO patients (id, age, gender, state, disease) VALUES (2, 30, 'Male', 'Australia', 'Chlamydia');
What is the minimum age of patients who tested positive for chlamydia in Australia?
SELECT MIN(age) FROM patients WHERE state = 'Australia' AND disease = 'Chlamydia';
gretelai_synthetic_text_to_sql
CREATE TABLE route (route_id INT, route_name TEXT, avg_speed DECIMAL); INSERT INTO route (route_id, route_name, avg_speed) VALUES (1, 'Route1', 25.00), (2, 'Route2', 30.00), (3, 'Route3', 20.00), (4, 'Route4', 35.00), (5, 'Route5', 40.00);
What is the average speed for each bus route?
SELECT route_name, avg_speed FROM route ORDER BY avg_speed DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE fair_labor_certifications(company VARCHAR(50), certification VARCHAR(50), obtained_date DATE);
What is the number of fair labor certifications obtained by each company?
SELECT company, COUNT(DISTINCT certification) FROM fair_labor_certifications GROUP BY company;
gretelai_synthetic_text_to_sql
CREATE TABLE offenders (id INT, gender VARCHAR(10), sentence_length INT);CREATE TABLE convictions (id INT, offender_id INT, crime VARCHAR(50));
What is the average sentence length for offenders who have been convicted of a specific crime, by gender?
SELECT AVG(offenders.sentence_length) as avg_sentence, offenders.gender FROM offenders INNER JOIN convictions ON offenders.id = convictions.offender_id WHERE crime = 'Robbery' GROUP BY offenders.gender;
gretelai_synthetic_text_to_sql
CREATE TABLE hospitals (id INT, name TEXT, city TEXT, state TEXT, beds INT); INSERT INTO hospitals (id, name, city, state, beds) VALUES (1, 'General Hospital', 'Miami', 'Florida', 500); INSERT INTO hospitals (id, name, city, state, beds) VALUES (2, 'Memorial Hospital', 'Boston', 'Massachusetts', 600);
What is the maximum number of beds in hospitals by state?
SELECT state, MAX(beds) as max_beds FROM hospitals GROUP BY state;
gretelai_synthetic_text_to_sql
CREATE TABLE stations (station_id INT, station_name VARCHAR(255), line_id INT);CREATE TABLE complaints (complaint_id INT, station_id INT, complaint_type VARCHAR(255), complaint_date DATETIME);
What is the total number of complaints filed for each station in the Paris Metro?
SELECT s.station_id, s.station_name, COUNT(c.complaint_id) as total_complaints FROM stations s JOIN complaints c ON s.station_id = c.station_id GROUP BY s.station_id, s.station_name;
gretelai_synthetic_text_to_sql
CREATE TABLE cases (id INT, year INT, restorative_justice BOOLEAN);
What is the maximum number of cases resolved in the cases table in a single year?
SELECT MAX(COUNT(*)) FROM cases GROUP BY year;
gretelai_synthetic_text_to_sql
CREATE TABLE Artworks (ArtworkID INT, Region TEXT); INSERT INTO Artworks (ArtworkID, Region) VALUES (1, 'Europe'), (2, 'Europe'), (3, 'Asia'), (4, 'Asia'), (5, 'Americas');
How many artworks were sold in each region?
SELECT Region, COUNT(*) as ArtworksSold FROM Artworks GROUP BY Region;
gretelai_synthetic_text_to_sql
CREATE TABLE news_programs (id INT, title VARCHAR(255), release_year INT, views INT, country VARCHAR(50), duration INT); INSERT INTO news_programs (id, title, release_year, views, country, duration) VALUES (1, 'News1', 2010, 10000, 'Canada', 30), (2, 'News2', 2015, 15000, 'Canada', 45), (3, 'News3', 2020, 20000, 'US', 60); INSERT INTO news_programs (id, title, release_year, views, country, duration) VALUES (4, 'News4', 2005, 20000, 'US', 45), (5, 'News5', 2018, 25000, 'US', 60), (6, 'News6', 2021, 30000, 'Canada', 45);
What is the average duration of news programs in Canada and the US?
SELECT AVG(duration) FROM news_programs WHERE country = 'Canada' UNION SELECT AVG(duration) FROM news_programs WHERE country = 'US';
gretelai_synthetic_text_to_sql
CREATE SCHEMA renewable_energy; CREATE TABLE projects (project_name VARCHAR(255), region VARCHAR(255), project_type VARCHAR(255)); INSERT INTO projects (project_name, region, project_type) VALUES ('Sunrise Solar Farm', 'Asia', 'Solar'), ('Windy Solar Park', 'Europe', 'Solar'), ('Solar Bliss Ranch', 'North America', 'Solar'), ('Hydroelectric Dam', 'South America', 'Hydroelectric');
Identify the number of renewable energy projects in the 'Asia' and 'Europe' regions, excluding hydroelectric projects.
SELECT region, COUNT(*) FROM renewable_energy.projects WHERE region IN ('Asia', 'Europe') AND project_type != 'Hydroelectric' GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE communication_strategies (strategy VARCHAR(50), location VARCHAR(50), reduction_emissions INT); INSERT INTO communication_strategies (strategy, location, reduction_emissions) VALUES ('Public transportation campaigns', 'Southeast Asia', 500000), ('Tree planting drives', 'Southeast Asia', 300000), ('Solar energy awareness programs', 'Southeast Asia', 250000);
Identify the communication strategies that led to a significant reduction in carbon emissions in Southeast Asia?
SELECT strategy, reduction_emissions FROM communication_strategies WHERE location = 'Southeast Asia' AND reduction_emissions > 300000;
gretelai_synthetic_text_to_sql
CREATE TABLE Volunteers (VolunteerID int, VolunteerName varchar(50), Country varchar(50), JoinDate date);
How many volunteers from Asia joined our programs in Q2 of 2022?
SELECT COUNT(*) FROM Volunteers WHERE Country LIKE 'Asia%' AND QUARTER(JoinDate) = 2;
gretelai_synthetic_text_to_sql
CREATE TABLE animal_population (id INT, animal_name VARCHAR(50), population INT, region VARCHAR(50)); INSERT INTO animal_population VALUES (1, 'Elephant', 15000, 'Africa'); CREATE TABLE endangered_species (id INT, animal_name VARCHAR(50), population INT, region VARCHAR(50)); INSERT INTO endangered_species VALUES (1, 'Rhino', 1000, 'Africa'); CREATE TABLE recovering_species (id INT, animal_name VARCHAR(50), population INT, region VARCHAR(50)); INSERT INTO recovering_species VALUES (1, 'Lion', 2000, 'Africa');
Count the number of animals in 'animal_population' table that are not present in 'endangered_species' or 'recovering_species' tables in Africa.
SELECT population FROM animal_population WHERE animal_name NOT IN (SELECT animal_name FROM endangered_species WHERE region = 'Africa') AND animal_name NOT IN (SELECT animal_name FROM recovering_species WHERE region = 'Africa');
gretelai_synthetic_text_to_sql
CREATE TABLE AseanPeacekeepingOperations (id INT, operation_name VARCHAR(255), operation_start_date DATE, operation_end_date DATE);
How many peacekeeping operations were conducted by ASEAN in the last 3 years, ordered by date?
SELECT * FROM (SELECT *, ROW_NUMBER() OVER (ORDER BY operation_start_date DESC) as rn FROM AseanPeacekeepingOperations WHERE organization = 'ASEAN' AND operation_start_date >= DATEADD(year, -3, CURRENT_DATE)) x WHERE rn = 1;
gretelai_synthetic_text_to_sql
CREATE TABLE customers (customer_id INT, name VARCHAR(50), country VARCHAR(50), network_type VARCHAR(50), data_usage FLOAT, usage_date DATE); INSERT INTO customers (customer_id, name, country, network_type, data_usage, usage_date) VALUES (1, 'John Doe', 'USA', '4G', 45.6, '2022-01-01'), (2, 'Jane Smith', 'Canada', '5G', 30.9, '2022-02-01'), (3, 'Mike Johnson', 'Mexico', '4G', 60.7, '2022-03-01');
What is the average data usage, in GB, for customers in each country, in the last 6 months, partitioned by network type?
SELECT country, network_type, AVG(data_usage) as avg_data_usage FROM customers WHERE usage_date >= DATEADD(month, -6, GETDATE()) GROUP BY country, network_type;
gretelai_synthetic_text_to_sql
CREATE TABLE production (id INT, factory VARCHAR(255), country VARCHAR(255), cost DECIMAL(10,2), production_date DATE); INSERT INTO production (id, factory, country, cost, production_date) VALUES (1, 'Fabric Inc', 'Vietnam', 120.00, '2021-06-01'), (2, 'Stitch Time', 'USA', 150.00, '2021-06-15');
What is the total production cost of garments in Vietnam for the month of June 2021?
SELECT SUM(cost) FROM production WHERE country = 'Vietnam' AND MONTH(production_date) = 6 AND YEAR(production_date) = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE green_buildings (id INT, city VARCHAR(20)); INSERT INTO green_buildings (id, city) VALUES (1, 'Seattle'), (2, 'Portland');
Find the total number of green buildings in the city of Seattle.
SELECT COUNT(*) FROM green_buildings WHERE city = 'Seattle';
gretelai_synthetic_text_to_sql
CREATE TABLE mine (id INT, name VARCHAR(50), location VARCHAR(50));CREATE TABLE coal_mine (mine_id INT, amount INT);CREATE TABLE iron_mine (mine_id INT, amount INT);
Show the names and locations of mines where the total amount of coal mined is greater than the total amount of iron mined.
SELECT m.name, m.location FROM mine m INNER JOIN coal_mine c ON m.id = c.mine_id INNER JOIN iron_mine i ON m.id = i.mine_id GROUP BY m.id, m.name, m.location HAVING SUM(c.amount) > SUM(i.amount);
gretelai_synthetic_text_to_sql
CREATE TABLE employees (id INT, name VARCHAR(50), job_title VARCHAR(50), gender VARCHAR(10)); INSERT INTO employees (id, name, job_title, gender) VALUES (1, 'John Doe', 'Software Engineer', 'Male'), (2, 'Jane Smith', 'Marketing Manager', 'Female'), (3, 'Mike Johnson', 'Data Analyst', 'Male'), (4, 'Sara Connor', 'Project Manager', 'Non-binary');
List the unique job titles held by employees who identify as female or non-binary.
SELECT DISTINCT job_title FROM employees WHERE gender IN ('Female', 'Non-binary');
gretelai_synthetic_text_to_sql
CREATE TABLE transactions (id INT, account_id INT, transaction_date DATE, transaction_amount DECIMAL(10,2)); CREATE TABLE accounts (id INT, state VARCHAR(50));
Determine the maximum and minimum transaction amounts for accounts in Florida in the past month.
SELECT MAX(transaction_amount) as max_transaction, MIN(transaction_amount) as min_transaction FROM transactions t JOIN accounts a ON t.account_id = a.id WHERE a.state = 'Florida' AND t.transaction_date >= DATEADD(month, -1, CURRENT_DATE);
gretelai_synthetic_text_to_sql
CREATE TABLE clean_energy_policy_trends (id INT, policy_name VARCHAR(100), description TEXT, start_date DATE);
Which clean energy policy trends were implemented in 2018, ordered by the policy id?
SELECT * FROM clean_energy_policy_trends WHERE YEAR(start_date) = 2018 ORDER BY id;
gretelai_synthetic_text_to_sql
CREATE TABLE workforce (workforce_id INT, mine_id INT, employee_name VARCHAR(50), gender VARCHAR(10), country VARCHAR(20)); INSERT INTO workforce (workforce_id, mine_id, employee_name, gender, country) VALUES (1, 1, 'Juan Lopez', 'Male', 'Mexico'), (2, 1, 'Maria Rodriguez', 'Female', 'Mexico'), (3, 2, 'Peter Jackson', 'Male', 'Canada'), (4, 3, 'Emily White', 'Female', 'USA'), (5, 3, 'Alex Brown', 'Non-binary', 'USA'), (6, 4, 'Fatima Ahmed', 'Female', 'Pakistan'), (7, 4, 'Ahmed Raza', 'Male', 'Pakistan'), (8, 5, 'Minh Nguyen', 'Non-binary', 'Vietnam'), (9, 5, 'Hoa Le', 'Female', 'Vietnam');
What is the percentage of female and non-binary employees in the mining industry, per country, for operations with more than 100 employees?
SELECT country, gender, COUNT(*) as employee_count, ROUND(COUNT(*) * 100.0 / SUM(COUNT(*)) OVER (PARTITION BY country), 2) as percentage FROM workforce WHERE (SELECT COUNT(*) FROM workforce w WHERE w.mine_id = workforce.mine_id) > 100 GROUP BY country, gender;
gretelai_synthetic_text_to_sql
CREATE TABLE hotels (hotel_id INT, name TEXT, category TEXT, rating FLOAT); INSERT INTO hotels (hotel_id, name, category, rating) VALUES (1, 'Hotel X', 'luxury', 4.5), (2, 'Hotel Y', 'budget', 3.2);
What is the average hotel rating in the 'luxury' category?
SELECT AVG(rating) FROM hotels WHERE category = 'luxury';
gretelai_synthetic_text_to_sql
CREATE TABLE AgeGroups (id INT, age_range VARCHAR(20), total_donors INT); INSERT INTO AgeGroups (id, age_range, total_donors) VALUES (1, '18-24', 1000), (2, '25-34', 2000), (3, '35-44', 3000); CREATE TABLE Donors (id INT, age_group INT, donation_id INT); INSERT INTO Donors (id, age_group, donation_id) VALUES (1, 1, 1001), (2, 2, 1002), (3, 3, 1003); CREATE TABLE Donations (id INT, donor_id INT, amount DECIMAL(10,2)); INSERT INTO Donations (id, donor_id, amount) VALUES (1001, 1, 50.00), (1002, 2, 75.00), (1003, 3, 100.00);
What is the percentage of donations made by each age group?
SELECT g.age_range, SUM(d.amount) / SUM(ag.total_donors) * 100 as percentage FROM Donors g JOIN Donations d ON g.id = d.donor_id JOIN AgeGroups ag ON g.age_group = ag.id GROUP BY g.age_range;
gretelai_synthetic_text_to_sql
CREATE TABLE sales (id INT, brand VARCHAR(255), country VARCHAR(255), sales_amount DECIMAL(10, 2), sale_date DATE);
What is the total revenue of cosmetics sold in the US in Q1 2022, grouped by brand?
SELECT brand, SUM(sales_amount) FROM sales WHERE country = 'US' AND sale_date BETWEEN '2022-01-01' AND '2022-03-31' GROUP BY brand;
gretelai_synthetic_text_to_sql
CREATE TABLE StudentAccommodations (StudentID INT, StudentName VARCHAR(255), DisabilityType VARCHAR(255), AccommodationType VARCHAR(255)); INSERT INTO StudentAccommodations (StudentID, StudentName, DisabilityType, AccommodationType) VALUES (1, 'John Doe', 'Visual Impairment', 'Sign Language Interpretation'), (2, 'Jane Smith', 'Hearing Impairment', 'Assistive Listening Devices'), (3, 'Mike Brown', 'Learning Disability', 'Assistive Technology');
Insert a new record for a student with a physical disability who requires mobility assistance accommodations.
INSERT INTO StudentAccommodations (StudentID, StudentName, DisabilityType, AccommodationType) VALUES (4, 'Sara Johnson', 'Physical Disability', 'Mobility Assistance');
gretelai_synthetic_text_to_sql
CREATE TABLE quality_control (id INT, test_type VARCHAR(255), test_result VARCHAR(255), defect_count INT, shift VARCHAR(255));
Update the 'quality_control' table and set the 'test_result' to 'Failed' for all records with 'defect_count' greater than 5
UPDATE quality_control SET test_result = 'Failed' WHERE defect_count > 5;
gretelai_synthetic_text_to_sql
CREATE TABLE asian_wind_farms (id INT, country VARCHAR(255), name VARCHAR(255), capacity FLOAT); INSERT INTO asian_wind_farms (id, country, name, capacity) VALUES (1, 'China', 'Wind Farm A', 250), (2, 'India', 'Wind Farm B', 300), (3, 'Japan', 'Wind Farm C', 150), (4, 'South Korea', 'Wind Farm D', 200);
What is the minimum installed capacity of a wind farm in Asia?
SELECT MIN(capacity) FROM asian_wind_farms;
gretelai_synthetic_text_to_sql
CREATE TABLE bank_mortgages (mortgage_id INT, bank_id INT, mortgage_amount DECIMAL(10, 2)); INSERT INTO bank_mortgages (mortgage_id, bank_id, mortgage_amount) VALUES (1, 1, 5000.00), (2, 1, 7000.00), (3, 2, 10000.00), (4, 2, 12000.00), (5, 3, 8000.00); CREATE TABLE banks (bank_id INT, bank_name VARCHAR(50), location VARCHAR(50)); INSERT INTO banks (bank_id, bank_name, location) VALUES (1, 'ABC Bank', 'Indonesia'), (2, 'Islamic Mortgage Bank', 'Malaysia'), (3, 'Shariah Finance Ltd', 'UAE');
What is the total amount of Shariah-compliant mortgages issued by each bank, partitioned by bank and ordered by the total amount?
SELECT bank_id, SUM(mortgage_amount) OVER (PARTITION BY bank_id) AS total_mortgage_amount, bank_name, location FROM bank_mortgages JOIN banks ON bank_mortgages.bank_id = banks.bank_id ORDER BY total_mortgage_amount DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE agri_innovation_south_africa (project VARCHAR(50), country VARCHAR(50), start_year INT, end_year INT); INSERT INTO agri_innovation_south_africa (project, country, start_year, end_year) VALUES ('Precision Agriculture', 'South Africa', 2012, 2014), ('Climate-smart Farming', 'South Africa', 2015, 2018), ('Organic Farming', 'South Africa', 2016, 2018);
How many agricultural innovation projects were initiated in South Africa between 2012 and 2018?
SELECT COUNT(*) FROM agri_innovation_south_africa WHERE country = 'South Africa' AND start_year BETWEEN 2012 AND 2018 AND end_year BETWEEN 2012 AND 2018;
gretelai_synthetic_text_to_sql
CREATE TABLE players (id INT, age INT, game_genre VARCHAR(20)); INSERT INTO players (id, age, game_genre) VALUES (1, 25, 'racing'), (2, 30, 'rpg'), (3, 22, 'shooter');
What is the most popular game genre among players aged 25-30?
SELECT game_genre, COUNT(*) AS count FROM players WHERE age BETWEEN 25 AND 30 GROUP BY game_genre ORDER BY count DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE HazardousWaste (Region VARCHAR(50), WasteQuantity INT); INSERT INTO HazardousWaste (Region, WasteQuantity) VALUES ('World', 15000000), ('Europe', 1500000), ('North America', 5000000), ('Asia', 6000000);
What is the total amount of hazardous waste generated in the world, and how does that compare to the amount of hazardous waste generated in Europe?
SELECT Region, WasteQuantity FROM HazardousWaste WHERE Region IN ('World', 'Europe');
gretelai_synthetic_text_to_sql
CREATE TABLE states (state_id INT, state_name VARCHAR(50)); CREATE TABLE military_bases (base_id INT, base_name VARCHAR(50), state_id INT); INSERT INTO states VALUES (1, 'Alabama'), (2, 'Alaska'), (3, 'Arizona'); INSERT INTO military_bases VALUES (1, 'Fort Rucker', 1), (2, 'Fort Wainwright', 2), (3, 'Fort Huachuca', 3);
How many military bases are located in each state in the 'military_bases' and 'states' tables?
SELECT s.state_name, COUNT(m.base_id) as bases_in_state FROM states s JOIN military_bases m ON s.state_id = m.state_id GROUP BY s.state_name;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_protected_areas (name VARCHAR(255), location VARCHAR(255), area_size FLOAT); INSERT INTO marine_protected_areas (name, location, area_size) VALUES ('Ross Sea Marine Protected Area', 'Antarctica', 1599800.0), ('Papahānaumokuākea Marine National Monument', 'USA', 1397970.0), ('Great Barrier Reef Marine Park', 'Australia', 344400.0);
List the marine protected areas in descending order of area size.
SELECT name, location, area_size FROM (SELECT name, location, area_size, ROW_NUMBER() OVER (ORDER BY area_size DESC) as rn FROM marine_protected_areas) t WHERE rn <= 3;
gretelai_synthetic_text_to_sql
CREATE TABLE project_timelines (project_id INT, state VARCHAR(2), building_type VARCHAR(20), project_timeline INT); INSERT INTO project_timelines (project_id, state, building_type, project_timeline) VALUES (1, 'NY', 'Residential', 180), (2, 'NY', 'Commercial', 240), (3, 'NY', 'Residential', 200);
What is the average project timeline for sustainable commercial building projects in New York?
SELECT AVG(project_timeline) FROM project_timelines WHERE state = 'NY' AND building_type = 'Commercial';
gretelai_synthetic_text_to_sql
CREATE TABLE cases (case_id INT, category VARCHAR(255), billing_amount FLOAT); INSERT INTO cases (case_id, category, billing_amount) VALUES (1, 'Civil', 5000), (2, 'Criminal', 3000), (3, 'Civil', 7000), (4, 'Criminal', 4000), (5, 'Civil', 8000);
What is the total billing amount for cases in the criminal category?
SELECT SUM(billing_amount) FROM cases WHERE category = 'Criminal';
gretelai_synthetic_text_to_sql
CREATE TABLE SolarProjects (id INT, project_name TEXT, location TEXT, capacity INT);
What is the total capacity for solar projects in 'SolarProjects' table, by city?
SELECT location, SUM(capacity) FROM SolarProjects WHERE project_type = 'Solar' GROUP BY location;
gretelai_synthetic_text_to_sql
CREATE TABLE ai_models (id INT PRIMARY KEY, name VARCHAR(255), type VARCHAR(255), accuracy DECIMAL(5, 4), developer_id INT); INSERT INTO ai_models (id, name, type, accuracy, developer_id) VALUES (1, 'Deep Learning Model', 'Classification', 0.96, 1), (2, 'Random Forest Model', 'Regression', 0.88, 2), (3, 'Naive Bayes Model', 'Classification', 0.91, 3); CREATE TABLE developers (id INT PRIMARY KEY, name VARCHAR(255), country VARCHAR(255)); INSERT INTO developers (id, name, country) VALUES (1, 'Rajesh Patel', 'India'), (2, 'Marie Curie', 'France'), (3, 'Alice Thompson', 'Canada');
Who are the developers of AI models that have an accuracy greater than 0.95 and are from India?
SELECT developers.name FROM ai_models INNER JOIN developers ON ai_models.developer_id = developers.id WHERE accuracy > 0.95 AND developers.country = 'India';
gretelai_synthetic_text_to_sql
CREATE TABLE peacekeeping_operations (operation_id INT, operation_name VARCHAR(255), start_year INT, end_year INT); INSERT INTO peacekeeping_operations (operation_id, operation_name, start_year, end_year) VALUES (1, 'MINUSTAH', 2004, 2017), (2, 'MONUSCO', 2010, 2021), (3, 'UNMISS', 2011, 2021);
Delete peacekeeping operations that lasted longer than 3 years.
DELETE FROM peacekeeping_operations WHERE end_year - start_year > 3;
gretelai_synthetic_text_to_sql
CREATE TABLE biotech_startups (name TEXT, funding FLOAT, date DATE); INSERT INTO biotech_startups (name, funding, date) VALUES ('StartupA', 5000000, '2022-01-05'); INSERT INTO biotech_startups (name, funding, date) VALUES ('StartupB', 7000000, '2022-03-10');
What is the maximum funding received by a biotech startup in Q1 2022?
SELECT MAX(funding) FROM biotech_startups WHERE date BETWEEN '2022-01-01' AND '2022-03-31';
gretelai_synthetic_text_to_sql
CREATE TABLE clients (client_id INT, name VARCHAR(50), account_type VARCHAR(50));
Update the account type of clients who have recently upgraded their services.
UPDATE clients SET account_type = 'Premium' WHERE client_id IN (SELECT client_id FROM (SELECT client_id, ROW_NUMBER() OVER(ORDER BY client_id) AS rn FROM clients WHERE account_type = 'Basic') AS sq WHERE rn <= 10);
gretelai_synthetic_text_to_sql
CREATE TABLE dishes (dish_id INT, dish_name VARCHAR(50), dish_type VARCHAR(20), calorie_count INT); INSERT INTO dishes (dish_id, dish_name, dish_type, calorie_count) VALUES (1, 'Veggie Delight', 'vegan', 300), (2, 'Tofu Stir Fry', 'vegan', 450), (3, 'Chickpea Curry', 'vegan', 500);
What is the average calorie count per dish for vegan dishes?
SELECT AVG(calorie_count) FROM dishes WHERE dish_type = 'vegan';
gretelai_synthetic_text_to_sql
CREATE TABLE facility_sizes (id INT, facility VARCHAR(20), size INT, state VARCHAR(2), license_date DATE); INSERT INTO facility_sizes (id, facility, size, state, license_date) VALUES (1, 'Emerald Garden', 12000, 'OR', '2021-02-15'), (2, 'Sunny Meadows', 8000, 'OR', '2021-12-20'), (3, 'Green Valley', 15000, 'OR', '2021-03-05');
What is the average size of cannabis cultivation facilities in Oregon with a license issued in 2021?
SELECT AVG(size) FROM facility_sizes WHERE state = 'OR' AND license_date >= '2021-01-01' AND license_date < '2022-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (DonorID int, DonorName varchar(100), Country varchar(50), DonationDate date, AmountDonated decimal(10,2)); INSERT INTO Donors (DonorID, DonorName, Country, DonationDate, AmountDonated) VALUES (1, 'Juan Pérez', 'Mexico', '2022-01-01', 500.00), (2, 'María Rodríguez', 'Brazil', '2022-02-01', 750.00);
What is the average donation amount from Latin America?
SELECT AVG(AmountDonated) as AverageDonation FROM Donors WHERE Country IN ('Argentina', 'Bolivia', 'Brazil', 'Chile', 'Colombia', 'Costa Rica', 'Cuba', 'Ecuador', 'El Salvador', 'Guatemala', 'Honduras', 'Mexico', 'Nicaragua', 'Panama', 'Paraguay', 'Peru', 'Uruguay', 'Venezuela');
gretelai_synthetic_text_to_sql
CREATE TABLE recycling_rates (id INT, city VARCHAR(255), state VARCHAR(255), country VARCHAR(255), rate DECIMAL(5,2));
Update the 'rate' of the recycling in 'Sydney', 'New South Wales', 'Australia' to 0.55
UPDATE recycling_rates SET rate = 0.55 WHERE city = 'Sydney' AND state = 'New South Wales' AND country = 'Australia';
gretelai_synthetic_text_to_sql
CREATE TABLE events (event_id INT, event_name VARCHAR(50), city VARCHAR(30), attendance INT); INSERT INTO events (event_id, event_name, city, attendance) VALUES (1, 'Theater Play', 'New York', 200), (2, 'Art Exhibit', 'Los Angeles', 300);
List all cities with their total attendance and average attendance per event
SELECT city, SUM(attendance) as total_attendance, AVG(attendance) as avg_attendance_per_event FROM events GROUP BY city;
gretelai_synthetic_text_to_sql
CREATE TABLE users (id INT, name VARCHAR(50), country VARCHAR(2), followers INT); INSERT INTO users (id, name, country, followers) VALUES (1, 'Alice', 'US', 1000), (2, 'Bob', 'IN', 2000), (3, 'Charlie', 'CA', 1500);
What is the maximum number of followers for users from India?
SELECT MAX(users.followers) as max_followers FROM users WHERE users.country = 'IN';
gretelai_synthetic_text_to_sql
CREATE TABLE salmon_farm (id INT, location VARCHAR(20), avg_growth_rate DECIMAL(5,2)); INSERT INTO salmon_farm (id, location, avg_growth_rate) VALUES (1, 'Norway', 2.3);
What is the average growth rate of salmon in the Norwegian aquaculture industry?
SELECT avg(avg_growth_rate) FROM salmon_farm WHERE location = 'Norway';
gretelai_synthetic_text_to_sql
CREATE TABLE departments (id INT PRIMARY KEY, name VARCHAR(255)); CREATE TABLE teachers (id INT PRIMARY KEY, department_id INT, has_completed_pd_course BOOLEAN);
How many teachers in each department have completed professional development courses?
SELECT d.name, COUNT(t.id) FROM teachers t JOIN departments d ON t.department_id = d.id WHERE t.has_completed_pd_course = TRUE GROUP BY t.department_id;
gretelai_synthetic_text_to_sql
CREATE TABLE lipstick_sales (sale_id INT, product_id INT, sale_quantity INT, is_cruelty_free BOOLEAN, sale_date DATE, country VARCHAR(20)); INSERT INTO lipstick_sales VALUES (1, 25, 7, true, '2021-06-12', 'US'); INSERT INTO lipstick_sales VALUES (2, 26, 3, true, '2021-06-12', 'US');
What is the most popular cruelty-free lipstick in the US in 2021?
SELECT product_id, MAX(sale_quantity) FROM lipstick_sales WHERE is_cruelty_free = true AND country = 'US' AND sale_date BETWEEN '2021-01-01' AND '2021-12-31' GROUP BY product_id;
gretelai_synthetic_text_to_sql
CREATE TABLE initiative_budgets (country VARCHAR(50), year INT, budget INT); INSERT INTO initiative_budgets (country, year, budget) VALUES ('India', 2021, 1200000), ('Bangladesh', 2021, 900000), ('Pakistan', 2021, 750000);
Identify the top 3 countries with the highest budget for community development initiatives in 2021.
SELECT country, SUM(budget) as total_budget FROM initiative_budgets WHERE year = 2021 GROUP BY country ORDER BY total_budget DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE SecurityIncidents (incident_id INT, status VARCHAR(10), assets_impacted INT, timestamp TIMESTAMP); INSERT INTO SecurityIncidents (incident_id, status, assets_impacted, timestamp) VALUES (1, 'Open', 2, '2022-01-01 10:00:00');
List all security incidents with their status and the number of unique assets impacted, ordered by the number of assets impacted in descending order?
SELECT incident_id, status, COUNT(DISTINCT assets_impacted) as unique_assets_impacted FROM SecurityIncidents GROUP BY incident_id, status ORDER BY unique_assets_impacted DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE team_stats (id INT, team TEXT, goals INT, season INT); INSERT INTO team_stats (id, team, goals, season) VALUES (1, 'Real Madrid', 60, 2022), (2, 'Barcelona', 55, 2022), (3, 'Atletico Madrid', 50, 2022);
How many goals has each team scored in the current season?
SELECT team, SUM(goals) FROM team_stats GROUP BY team HAVING season = 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE materials (material_id INT, site_id INT, quantity INT);
Find the total quantity of materials used at each manufacturing site, ordered from the most to the least used.
SELECT s.site_name, SUM(quantity) as total_quantity FROM materials m JOIN sites s ON m.site_id = s.site_id GROUP BY site_id ORDER BY total_quantity DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE mental_health.patients (patient_id INT, first_name VARCHAR(50), last_name VARCHAR(50), age INT, gender VARCHAR(50), country VARCHAR(50)); INSERT INTO mental_health.patients (patient_id, first_name, last_name, age, gender, country) VALUES (4, 'Ravi', 'Kumar', 35, 'Male', 'India'); CREATE TABLE mental_health.treatments (treatment_id INT, patient_id INT, therapist_id INT, treatment_type VARCHAR(50), country VARCHAR(50)); INSERT INTO mental_health.treatments (treatment_id, patient_id, therapist_id, treatment_type, country) VALUES (5, 4, 401, 'ECT', 'India');
Insert a new record of a patient from India who received electroconvulsive therapy (ECT)?
INSERT INTO mental_health.treatments (treatment_id, patient_id, therapist_id, treatment_type, country) VALUES (5, (SELECT patient_id FROM mental_health.patients WHERE first_name = 'Ravi' AND last_name = 'Kumar' AND country = 'India'), 401, 'ECT', 'India');
gretelai_synthetic_text_to_sql
CREATE TABLE exoplanet_discoveries (id INT, discovery_method VARCHAR(50), discovery_tool VARCHAR(50), exoplanet_count INT);
What is the total number of exoplanets discovered by the Kepler Space Telescope?
SELECT SUM(exoplanet_count) FROM exoplanet_discoveries WHERE discovery_tool = 'Kepler Space Telescope';
gretelai_synthetic_text_to_sql
CREATE TABLE TravelStats (VisitorID INT, Destination VARCHAR(20), VisitYear INT); INSERT INTO TravelStats (VisitorID, Destination, VisitYear) VALUES (1, 'New York', 2021), (2, 'London', 2021), (3, 'Paris', 2021), (4, 'New York', 2021);
Find the most popular destination for US visitors in 2021, excluding New York.
SELECT Destination, COUNT(*) AS Popularity FROM TravelStats WHERE VisitYear = 2021 AND Destination != 'New York' GROUP BY Destination ORDER BY Popularity DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE financial_wellbeing(customer_id INT, score DECIMAL(3, 1), measure_date DATE); INSERT INTO financial_wellbeing VALUES (1, 75, '2022-01-15'), (2, 80, '2022-04-01'), (3, 70, '2022-03-05'), (4, 85, '2022-05-12');
Compute the percentage of customers who improved their financial wellbeing score from the previous quarter.
SELECT COUNT(*) * 100.0 / SUM(COUNT(*)) OVER () AS pct FROM (SELECT customer_id, score, measure_date, LAG(score) OVER (PARTITION BY customer_id ORDER BY measure_date) AS prev_score FROM financial_wellbeing) t WHERE prev_score IS NOT NULL AND score > prev_score;
gretelai_synthetic_text_to_sql
CREATE TABLE startups (id INT, name VARCHAR(100), location VARCHAR(100), funding FLOAT); INSERT INTO startups (id, name, location, funding) VALUES (1, 'StartupD', 'Argentina', 3000000); INSERT INTO startups (id, name, location, funding) VALUES (2, 'StartupE', 'Argentina', 4000000);
What is the average funding for biotech startups in Argentina?
SELECT AVG(funding) FROM startups WHERE location = 'Argentina';
gretelai_synthetic_text_to_sql
CREATE TABLE avg_practitioners (id INT, art VARCHAR(50), practitioners INT); INSERT INTO avg_practitioners (id, art, practitioners) VALUES (1, 'Inuit carving', 700); INSERT INTO avg_practitioners (id, art, practitioners) VALUES (2, 'Māori tattooing', 300);
What is the average number of practitioners for each traditional art?
SELECT art, AVG(practitioners) FROM avg_practitioners;
gretelai_synthetic_text_to_sql
CREATE TABLE EmployeeDiversity (EmployeeID INT, Identity VARCHAR(50), Department VARCHAR(50)); INSERT INTO EmployeeDiversity (EmployeeID, Identity, Department) VALUES (1, 'Woman', 'Engineering'), (2, 'Man', 'Marketing');
What is the total number of employees who identify as women in the engineering department?
SELECT COUNT(*) FROM EmployeeDiversity WHERE Identity = 'Woman' AND Department = 'Engineering';
gretelai_synthetic_text_to_sql
CREATE TABLE Volunteers (id INT, name TEXT, country TEXT, hours FLOAT, quarter TEXT, year INT); INSERT INTO Volunteers (id, name, country, hours, quarter, year) VALUES (1, 'Alice', 'USA', 5.0, 'Q3', 2021), (2, 'Bob', 'Canada', 7.5, 'Q3', 2021), (3, 'Eve', 'Canada', 3.0, 'Q3', 2021), (4, 'Frank', 'USA', 6.0, 'Q2', 2021), (5, 'Grace', 'USA', 8.0, 'Q2', 2021);
How many volunteers contributed more than 5 hours in each quarter of 2021?
SELECT quarter, COUNT(*) FROM Volunteers WHERE hours > 5 GROUP BY quarter;
gretelai_synthetic_text_to_sql
CREATE TABLE energy_storage (id INT, source VARCHAR(20), country VARCHAR(20), capacity FLOAT, timestamp DATE); INSERT INTO energy_storage (id, source, country, capacity, timestamp) VALUES (1, 'Solar', 'Germany', 55000, '2022-01-01'), (2, 'Wind', 'Germany', 72000, '2022-01-01'), (3, 'Hydro', 'Germany', 38000, '2022-01-01');
What is the energy storage capacity (in MWh) for each renewable energy source in Germany as of 2022-01-01?
SELECT source, capacity FROM energy_storage WHERE country = 'Germany' AND timestamp = '2022-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE Vessels (VesselID INT, VesselName TEXT, AverageSpeed DECIMAL(5,2)); CREATE TABLE Voyages (VoyageID INT, VesselID INT, DepartureDate DATE); INSERT INTO Vessels (VesselID, VesselName, AverageSpeed) VALUES (1, 'Vessel1', 15.5), (2, 'Vessel2', 18.2); INSERT INTO Voyages (VoyageID, VesselID, DepartureDate) VALUES (1, 1, '2022-01-01'), (2, 2, '2022-01-05');
What is the average speed of vessels that departed from Port A in January 2022?
SELECT AVG(Vessels.AverageSpeed) FROM Vessels INNER JOIN Voyages ON Vessels.VesselID = Voyages.VesselID WHERE YEAR(Voyages.DepartureDate) = 2022 AND MONTH(Voyages.DepartureDate) = 1 AND Voyages.DeparturePort = 'Port A';
gretelai_synthetic_text_to_sql
CREATE TABLE teams (id INT PRIMARY KEY, name VARCHAR(50), sport VARCHAR(20), city VARCHAR(30)); CREATE TABLE players (id INT PRIMARY KEY, name VARCHAR(50), age INT, sport VARCHAR(20), team VARCHAR(30)); INSERT INTO teams (id, name, sport, city) VALUES (1, 'Manchester United', 'Soccer', 'Manchester'), (2, 'Real Madrid', 'Soccer', 'Madrid'); INSERT INTO players (id, name, age, sport, team) VALUES (1, 'David De Gea', 31, 'Soccer', 'Manchester United'), (2, 'Casemiro', 30, 'Soccer', 'Real Madrid');
List all the teams in the 'Soccer' sport, along with the number of players in each team.
SELECT teams.name, COUNT(players.id) FROM teams INNER JOIN players ON teams.name = players.team WHERE teams.sport = 'Soccer' GROUP BY teams.name;
gretelai_synthetic_text_to_sql
CREATE TABLE customer_accounts (id INT, customer_type VARCHAR(20), account_balance DECIMAL(10, 2)); INSERT INTO customer_accounts (id, customer_type, account_balance) VALUES (1, 'Premium', 25000.00), (2, 'Standard', 15000.00), (3, 'Premium', 30000.00);
What is the maximum balance for premium customers?
SELECT MAX(account_balance) FROM customer_accounts WHERE customer_type = 'Premium';
gretelai_synthetic_text_to_sql
CREATE TABLE initiatives (id INT, sustainable BOOLEAN, city VARCHAR(20)); INSERT INTO initiatives (id, sustainable, city) VALUES (1, TRUE, 'Rome'), (2, TRUE, 'Rome'), (3, FALSE, 'Rome');
What is the percentage of sustainable urbanism initiatives in Rome?
SELECT 100.0 * COUNT(*) FILTER (WHERE sustainable = TRUE) / COUNT(*) FROM initiatives WHERE city = 'Rome';
gretelai_synthetic_text_to_sql
CREATE TABLE Teachers (TeacherID INT, Name VARCHAR(100), Subject VARCHAR(50));
Insert data into 'Teachers' table with values (1, 'Jamila Thompson', 'Math'), (2, 'Carlos Lee', 'Science')
INSERT INTO Teachers (TeacherID, Name, Subject) VALUES (1, 'Jamila Thompson', 'Math'), (2, 'Carlos Lee', 'Science');
gretelai_synthetic_text_to_sql
CREATE TABLE vulnerabilities (system_id INT, system_name VARCHAR(100), cve_count INT); INSERT INTO vulnerabilities (system_id, system_name, cve_count) VALUES (1, 'Server01', 20), (2, 'Workstation01', 15), (3, 'Firewall01', 5), (4, 'Router01', 12), (5, 'Switch01', 8), (6, 'Printer01', 3);
What are the total CVE counts for each system in the 'vulnerabilities' table?
SELECT system_name, SUM(cve_count) as total_cve_count FROM vulnerabilities GROUP BY system_name;
gretelai_synthetic_text_to_sql
CREATE TABLE MakeupSales (ProductID INT, ProductType VARCHAR(20), IsEcoFriendly BOOLEAN, Revenue DECIMAL(10,2), SaleDate DATE); INSERT INTO MakeupSales (ProductID, ProductType, IsEcoFriendly, Revenue, SaleDate) VALUES (1, 'Lipstick', TRUE, 50.00, '2022-01-15'); INSERT INTO MakeupSales (ProductID, ProductType, IsEcoFriendly, Revenue, SaleDate) VALUES (2, 'Eyeshadow', TRUE, 75.00, '2022-02-20'); INSERT INTO MakeupSales (ProductID, ProductType, IsEcoFriendly, Revenue, SaleDate) VALUES (3, 'Foundation', TRUE, 60.00, '2022-03-05'); INSERT INTO MakeupSales (ProductID, ProductType, IsEcoFriendly, Revenue, SaleDate) VALUES (4, 'Blush', TRUE, 80.00, '2022-04-10');
Determine the monthly sales growth of eco-friendly makeup products in the last year.
SELECT EXTRACT(MONTH FROM SaleDate) AS Month, AVG(Revenue) AS AverageRevenue, LAG(AVG(Revenue)) OVER (ORDER BY EXTRACT(MONTH FROM SaleDate)) AS PreviousMonthAverage FROM MakeupSales WHERE ProductType = 'Makeup' AND IsEcoFriendly = TRUE GROUP BY EXTRACT(MONTH FROM SaleDate) ORDER BY EXTRACT(MONTH FROM SaleDate);
gretelai_synthetic_text_to_sql
CREATE TABLE tourism_activities(activity_id INT, name TEXT, location TEXT, revenue FLOAT); INSERT INTO tourism_activities (activity_id, name, location, revenue) VALUES (1, 'Eco-Trekking', 'Indonesia', 15000), (2, 'Coral Reef Snorkeling', 'Philippines', 20000), (3, 'Cultural Cooking Class', 'Thailand', 10000);
What is the average revenue per sustainable tourism activity in Southeast Asia?
SELECT AVG(revenue) FROM tourism_activities WHERE location LIKE 'Southeast%' AND sustainable = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE VeganIngredients (id INT, name VARCHAR(50), quantity INT); INSERT INTO VeganIngredients (id, name, quantity) VALUES (1, 'Tofu', 1000), (2, 'Cashews', 1500), (3, 'Nutritional Yeast', 800);
What is the total quantity of vegan ingredients in our inventory?
SELECT SUM(quantity) FROM VeganIngredients;
gretelai_synthetic_text_to_sql
CREATE TABLE garment_materials (id INT, garment_name VARCHAR(255), material_name VARCHAR(255), production_cost DECIMAL(10,2));
Display the names of all garments that are made from sustainable materials and cost less than $50.
SELECT garment_name FROM garment_materials WHERE material_name IN (SELECT material_name FROM sustainable_materials) AND production_cost < 50;
gretelai_synthetic_text_to_sql
CREATE TABLE user_engagements (user_id INT, engagement_topic VARCHAR(50), job_title VARCHAR(50)); INSERT INTO user_engagements (user_id, engagement_topic, job_title) VALUES (1, 'social justice', 'Human Rights Lawyer'), (2, 'technology', 'Software Engineer'), (3, 'social justice', 'Social Worker'), (4, 'education', 'Teacher'), (5, 'social justice', 'Community Organizer'), (6, 'healthcare', 'Doctor');
What are the unique job titles of users who have engaged with posts about social justice but have not applied to any jobs in the non-profit sector.
SELECT job_title FROM user_engagements WHERE engagement_topic = 'social justice' AND user_id NOT IN (SELECT user_id FROM user_engagements WHERE job_title LIKE '%non-profit%');
gretelai_synthetic_text_to_sql
CREATE TABLE product_cruelty (product_id INTEGER, product_category VARCHAR(20), is_cruelty_free BOOLEAN); INSERT INTO product_cruelty (product_id, product_category, is_cruelty_free) VALUES (1, 'Makeup', true), (2, 'Makeup', false), (3, 'Skincare', true), (4, 'Skincare', false);
How many products in each category are not cruelty-free?
SELECT product_category, COUNT(*) FROM product_cruelty WHERE is_cruelty_free = false GROUP BY product_category;
gretelai_synthetic_text_to_sql
CREATE TABLE transactions (id INT, transaction_date DATE, country VARCHAR(255), amount DECIMAL(10,2)); INSERT INTO transactions (id, transaction_date, country, amount) VALUES (1, '2022-01-01', 'USA', 100.00), (2, '2022-01-02', 'Canada', 200.00), (3, '2022-01-03', 'USA', 300.00);
What is the total transaction amount for each day in January 2022, for transactions that occurred in the United States?
SELECT transaction_date, SUM(amount) FROM transactions WHERE transaction_date BETWEEN '2022-01-01' AND '2022-01-31' AND country = 'USA' GROUP BY transaction_date;
gretelai_synthetic_text_to_sql
CREATE TABLE deep_sea_expeditions (expedition_name VARCHAR(255), depth FLOAT, ocean VARCHAR(255));
What is the maximum depth of all deep-sea expeditions in the Southern Ocean?
SELECT MAX(depth) FROM deep_sea_expeditions WHERE ocean = 'Southern';
gretelai_synthetic_text_to_sql
CREATE TABLE organizations (id INT, name VARCHAR(50), type VARCHAR(30)); CREATE TABLE grants (id INT, org_id INT, amount INT, date DATE, purpose VARCHAR(30)); INSERT INTO organizations (id, name, type) VALUES (1, 'ABC Nonprofit', 'social impact assessment'), (2, 'DEF Nonprofit', 'capacity building'), (3, 'GHI Nonprofit', 'fundraising'); INSERT INTO grants (id, org_id, amount, date, purpose) VALUES (1, 1, 10000, '2023-03-01', 'social impact assessment'), (2, 2, 5000, '2022-12-15', 'program delivery'), (3, 3, 7500, '2023-02-05', 'fundraising'); INSERT INTO grants (id, org_id, amount, date, purpose) VALUES (4, 1, 15000, '2023-06-15', 'social impact assessment');
Which organizations have received grants for social impact assessment in the current year?
SELECT organizations.name FROM organizations INNER JOIN grants ON organizations.id = grants.org_id WHERE YEAR(grants.date) = YEAR(GETDATE()) AND organizations.type = 'social impact assessment';
gretelai_synthetic_text_to_sql
CREATE TABLE public_transportation (transport_id INT, type VARCHAR(20), city VARCHAR(20)); INSERT INTO public_transportation (transport_id, type, city) VALUES (1, 'Bus', 'Rio de Janeiro'), (2, 'Tram', 'Rio de Janeiro'), (3, 'Train', 'Rio de Janeiro');
Add a new autonomous bus to the public transportation fleet in Rio de Janeiro.
INSERT INTO public_transportation (transport_id, type, city) VALUES (4, 'Autonomous Bus', 'Rio de Janeiro');
gretelai_synthetic_text_to_sql
CREATE TABLE teacher_pd (teacher_id INT, workshop_name VARCHAR(255), date DATE); INSERT INTO teacher_pd (teacher_id, workshop_name, date) VALUES (1, 'Open Pedagogy', '2023-06-01'); CREATE VIEW summer_2023_pd AS SELECT teacher_id, COUNT(*) as num_workshops FROM teacher_pd WHERE date BETWEEN '2023-06-01' AND '2023-08-31' GROUP BY teacher_id;
What is the minimum number of workshops attended by a teacher in 'Summer 2023'?
SELECT MIN(num_workshops) as min_workshops FROM summer_2023_pd;
gretelai_synthetic_text_to_sql
CREATE SCHEMA art; CREATE TABLE art_pieces (art_id INT, art_name VARCHAR(255), artist_name VARCHAR(255), artist_gender VARCHAR(10), medium VARCHAR(50), creation_date DATE); INSERT INTO art.art_pieces (art_id, art_name, artist_name, artist_gender, medium, creation_date) VALUES (1, 'Painting', 'Sarah Johnson', 'Female', 'Oil', '2018-01-01'), (2, 'Sculpture', 'Mia Kim', 'Female', 'Bronze', '2019-05-15'), (3, 'Print', 'Jamie Lee', 'Female', 'Woodcut', '2020-12-31'), (4, 'Installation', 'David Park', 'Male', 'Mixed Media', '2020-06-01'), (5, 'Painting', 'David Park', 'Male', 'Watercolor', '2019-12-31');
What is the number of art pieces created by male and female artists in each medium?
SELECT medium, artist_gender, COUNT(*) as count FROM art.art_pieces GROUP BY medium, artist_gender;
gretelai_synthetic_text_to_sql
CREATE TABLE artists (artist_id INT, name VARCHAR(100), genre VARCHAR(50)); CREATE TABLE concert_artists (concert_id INT, artist_id INT); INSERT INTO artists (artist_id, name, genre) VALUES (101, 'Taylor Swift', 'Pop'), (102, 'Billie Eilish', 'Pop'), (103, 'The Weeknd', 'R&B'); INSERT INTO concert_artists (concert_id, artist_id) VALUES (1, 101), (2, 102), (3, 101);
Delete artists who have never held a concert.
DELETE FROM artists WHERE artist_id NOT IN (SELECT artist_id FROM concert_artists);
gretelai_synthetic_text_to_sql
CREATE TABLE production (year INT, element VARCHAR(10), quantity INT); INSERT INTO production (year, element, quantity) VALUES (2015, 'Praseodymium', 1200), (2016, 'Praseodymium', 1400), (2017, 'Praseodymium', 1500), (2018, 'Praseodymium', 1700), (2019, 'Praseodymium', 1800), (2020, 'Praseodymium', 2000), (2021, 'Praseodymium', 2200);
What was the maximum production of Praseodymium in 2018?
SELECT MAX(quantity) FROM production WHERE element = 'Praseodymium' AND year = 2018;
gretelai_synthetic_text_to_sql
CREATE TABLE menu (menu_id INT, item_name VARCHAR(255), category VARCHAR(255), price DECIMAL(5,2), inventory_count INT, last_updated TIMESTAMP);CREATE TABLE orders (order_id INT, menu_id INT, order_date TIMESTAMP, quantity INT, PRIMARY KEY (order_id), FOREIGN KEY (menu_id) REFERENCES menu(menu_id));
What is the percentage of total orders for each category in the past month?
SELECT category, SUM(quantity) as total_orders, 100.0 * SUM(quantity) / (SELECT SUM(quantity) FROM orders WHERE order_date >= CURRENT_DATE - INTERVAL '1 month') as percentage_of_total FROM orders JOIN menu ON orders.menu_id = menu.menu_id WHERE order_date >= CURRENT_DATE - INTERVAL '1 month' GROUP BY category;
gretelai_synthetic_text_to_sql
CREATE TABLE initiative (id INT, name TEXT, location TEXT, economic_diversification_impact INT, year INT); INSERT INTO initiative (id, name, location, economic_diversification_impact, year) VALUES (1, 'Handicraft Training', 'Egypt', 50, 2017), (2, 'Agricultural Training', 'Nigeria', 70, 2018), (3, 'IT Training', 'Kenya', 90, 2019), (4, 'Fishery Training', 'South Africa', 60, 2020);
What is the economic diversification impact of community development initiatives in Africa in 2020?
SELECT economic_diversification_impact FROM initiative WHERE location LIKE 'Africa%' AND year = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE Menu (dish_id INT, dish_name VARCHAR(100), dish_type VARCHAR(20)); INSERT INTO Menu (dish_id, dish_name, dish_type) VALUES (1, 'Quinoa Salad', 'Vegetarian'); INSERT INTO Menu (dish_id, dish_name, dish_type) VALUES (2, 'Grilled Chicken', 'Non-Vegetarian');
Find the number of vegetarian and non-vegetarian dishes in the menu
SELECT SUM(CASE WHEN dish_type = 'Vegetarian' THEN 1 ELSE 0 END) AS vegetarian_dishes, SUM(CASE WHEN dish_type = 'Non-Vegetarian' THEN 1 ELSE 0 END) AS non_vegetarian_dishes FROM Menu;
gretelai_synthetic_text_to_sql
CREATE TABLE MilitaryTech (Tech_Name VARCHAR(255), Tech_Type VARCHAR(255), Development_Cost INT, Fiscal_Year INT); INSERT INTO MilitaryTech (Tech_Name, Tech_Type, Development_Cost, Fiscal_Year) VALUES ('F-35 Fighter Jet', 'Aircraft', 100000000, 2020); INSERT INTO MilitaryTech (Tech_Name, Tech_Type, Development_Cost, Fiscal_Year) VALUES ('Zumwalt-Class Destroyer', 'Ship', 7000000000, 2015);
Show all military technology and their respective development costs from the 'MilitaryTech' table
SELECT * FROM MilitaryTech;
gretelai_synthetic_text_to_sql
CREATE TABLE Fabric_Types (fabric_type VARCHAR(255), usage_percentage DECIMAL(5,2)); INSERT INTO Fabric_Types (fabric_type, usage_percentage) VALUES ('Cotton', 50.00), ('Polyester', 30.00), ('Wool', 10.00), ('Silk', 5.00), ('Linen', 5.00);
What percentage of each fabric type is used in textile sourcing?
SELECT fabric_type, usage_percentage FROM Fabric_Types;
gretelai_synthetic_text_to_sql
CREATE TABLE ai_models (model_id INT, model_name TEXT, explainability_score FLOAT);
Find the maximum explainability score for AI models in the 'ai_models' table.
SELECT MAX(explainability_score) FROM ai_models;
gretelai_synthetic_text_to_sql
CREATE TABLE bike_sharing (id INT, city VARCHAR(50), users INT); INSERT INTO bike_sharing (id, city, users) VALUES (1, 'Seoul', 500000), (2, 'NYC', 300000), (3, 'Barcelona', 200000);
How many public bike-sharing users are there in Seoul?
SELECT users FROM bike_sharing WHERE city = 'Seoul';
gretelai_synthetic_text_to_sql
CREATE TABLE donations (id INT, donor_id INT, category VARCHAR(255), amount DECIMAL(10, 2)); INSERT INTO donations (id, donor_id, category, amount) VALUES (1, 1, 'healthcare', 1000), (2, 1, 'education', 2000), (3, 2, 'healthcare', 500), (4, 2, 'healthcare', 1500), (5, 3, 'education', 3000);
How many unique donors are there for each category?
SELECT category, COUNT(DISTINCT donor_id) AS unique_donors FROM donations GROUP BY category;
gretelai_synthetic_text_to_sql
CREATE TABLE Properties(id INT, size FLOAT, city VARCHAR(20), coown INT);INSERT INTO Properties(id, size, city, coown) VALUES (1, 1200, 'Seattle', 2003), (2, 1500, 'Seattle', 2010), (3, 1000, 'Portland', 2015), (4, 2000, 'SanFrancisco', 2005), (5, 1000, 'Austin', 2020), (6, 1200, 'Seattle', 2008);
Find properties that have been co-owned for more than 5 years, and their respective average sizes.
SELECT a.coown, AVG(a.size) FROM Properties a WHERE a.coown < 2021 GROUP BY a.coown;
gretelai_synthetic_text_to_sql
CREATE TABLE Researchers (id INT, name VARCHAR(100), organization VARCHAR(100), expertise VARCHAR(100), publications INT); INSERT INTO Researchers (id, name, organization, expertise, publications) VALUES (1, 'Jane Doe', 'Polar Research Institute', 'Climate Change', 20); INSERT INTO Researchers (id, name, organization, expertise, publications) VALUES (2, 'Jim Brown', 'Polar Research Institute', 'Biodiversity', 18); INSERT INTO Researchers (id, name, organization, expertise, publications) VALUES (3, 'Alex Smith', 'Arctic Biodiversity Center', 'Climate Change', 16); INSERT INTO Researchers (id, name, organization, expertise, publications) VALUES (4, 'Jessica Johnson', 'Arctic Biodiversity Center', 'Biodiversity', 22);
Which organizations have researchers specialized in both climate change and biodiversity with at least 15 publications?
SELECT DISTINCT organization FROM Researchers WHERE (expertise = 'Climate Change' AND expertise = 'Biodiversity' AND publications >= 15)
gretelai_synthetic_text_to_sql
CREATE TABLE incident_rates (id INT, industry TEXT, country TEXT, incident_count INT, total_workplaces INT); INSERT INTO incident_rates (id, industry, country, incident_count, total_workplaces) VALUES (1, 'Technology', 'UK', 100, 1000), (2, 'Manufacturing', 'UK', 200, 2000), (3, 'Retail', 'UK', 150, 1500);
List the top 3 industries in the UK with the highest workplace safety incident rates in the past year, in descending order.
SELECT industry, SUM(incident_count) as total_incidents FROM incident_rates WHERE country = 'UK' GROUP BY industry ORDER BY total_incidents DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE hospitals (state varchar(2), hospital_name varchar(25), num_beds int); INSERT INTO hospitals (state, hospital_name, num_beds) VALUES ('NY', 'NY Presbyterian', 2001), ('CA', 'UCLA Medical', 3012), ('TX', 'MD Anderson', 1543), ('FL', 'Mayo Clinic FL', 2209);
Determine the hospital with the highest number of beds per state, and display the hospital name and the difference between the highest and second highest number of beds.
SELECT hospital_name as highest_bed_hospital, MAX(num_beds) - LEAD(MAX(num_beds)) OVER (ORDER BY MAX(num_beds) DESC) as bed_difference FROM hospitals GROUP BY state HAVING MAX(num_beds) > LEAD(MAX(num_beds)) OVER (ORDER BY MAX(num_beds) DESC);
gretelai_synthetic_text_to_sql
CREATE TABLE grant (id INT, year INT, amount DECIMAL(10, 2)); CREATE TABLE student (id INT, gender VARCHAR(10)); INSERT INTO grant (id, year, amount) VALUES (1, 2019, 50000), (2, 2020, 75000), (3, 2019, 30000); INSERT INTO student (id, gender) VALUES (1, 'Female'), (2, 'Male'), (3, 'Female');
What is the total amount of grants awarded by gender?
SELECT student.gender, SUM(grant.amount) as total_grant_amount FROM grant CROSS JOIN student GROUP BY student.gender;
gretelai_synthetic_text_to_sql
CREATE TABLE stays (id INT, patient_id INT, length INT, condition TEXT); CREATE TABLE conditions (id INT, name TEXT); INSERT INTO conditions (id, name) VALUES (1, 'Eating Disorder');
What is the average length of hospital stays for patients with eating disorders?
SELECT AVG(length) FROM stays WHERE condition = 'Eating Disorder';
gretelai_synthetic_text_to_sql
CREATE TABLE heritage_sites(id INT, site_name TEXT, community_engagement FLOAT); INSERT INTO heritage_sites VALUES (1, 'Mesa Verde National Park', 4.2), (2, 'Yosemite National Park', 3.8);
List all heritage sites along with their community engagement scores.
SELECT site_name, community_engagement FROM heritage_sites;
gretelai_synthetic_text_to_sql
CREATE TABLE articles (id INT, title VARCHAR(255), content TEXT, topic VARCHAR(255), publisher_country VARCHAR(255));
What is the percentage of articles about media representation, published by news outlets based in the USA?
SELECT (COUNT(*) FILTER (WHERE topic = 'media representation' AND publisher_country = 'USA')) * 100.0 / COUNT(*) FROM articles;
gretelai_synthetic_text_to_sql
CREATE TABLE solar_projects (id INT, name VARCHAR(100), country VARCHAR(50), capacity_mw FLOAT); INSERT INTO solar_projects (id, name, country, capacity_mw) VALUES (1, 'Solar Project 1', 'USA', 75.6), (2, 'Solar Project 2', 'USA', 40.2);
List all Solar Projects in the United States with a capacity over 50 MW
SELECT * FROM solar_projects WHERE country = 'USA' AND capacity_mw > 50;
gretelai_synthetic_text_to_sql