context
stringlengths 11
9.12k
| question
stringlengths 0
1.06k
| SQL
stringlengths 2
4.44k
| source
stringclasses 28
values |
|---|---|---|---|
CREATE TABLE if not exists car_share (id INT, state VARCHAR(20), car_type VARCHAR(20), quantity INT);INSERT INTO car_share (id, state, car_type, quantity) VALUES (1, 'California', 'electric_car', 1000), (2, 'California', 'hybrid_car', 800), (3, 'Oregon', 'electric_car', 600), (4, 'Oregon', 'hybrid_car', 500);
|
What is the minimum number of electric cars in the state of California?
|
SELECT MIN(quantity) FROM car_share WHERE state = 'California' AND car_type = 'electric_car';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE products (id INT PRIMARY KEY, name VARCHAR(100), category VARCHAR(50), price DECIMAL(5,2));
|
Update the name of the product with id 3 to 'Vegan Cheese'
|
UPDATE products SET name = 'Vegan Cheese' WHERE id = 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE SpaceMissions (id INT, name VARCHAR(50), company VARCHAR(50), duration INT); INSERT INTO SpaceMissions (id, name, company, duration) VALUES (1, 'Apollo 11', 'StarCorp', 195), (2, 'Apollo 13', 'StarCorp', 142), (3, 'Apollo 17', 'StarCorp', 301);
|
What is the maximum duration of space missions conducted by 'StarCorp'?
|
SELECT MAX(duration) FROM SpaceMissions WHERE company = 'StarCorp';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE TV_Shows (show_id INT PRIMARY KEY, name VARCHAR(100), genre VARCHAR(50)); CREATE TABLE Ratings (year INT, show_id INT, rank INT, PRIMARY KEY (year, show_id)); INSERT INTO TV_Shows (show_id, name, genre) VALUES (1, 'The Crown', 'Drama'), (2, 'Stranger Things', 'Sci-fi'); INSERT INTO Ratings (year, show_id, rank) VALUES (2020, 1, 5), (2021, 2, 8);
|
Find the names of TV shows that have never been in the Top 10 most-watched list for any given year.
|
SELECT name FROM TV_Shows WHERE show_id NOT IN (SELECT show_id FROM Ratings WHERE rank <= 10);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE employee_roles(emp_id INT, dept_id INT, role_id INT); INSERT INTO employee_roles VALUES (1, 1, 1), (2, 1, 2), (3, 2, 1), (4, 2, 2), (5, 3, 1);
|
Count the number of employees in each department, excluding any managers
|
SELECT d.dept_name, COUNT(e.emp_id) as num_employees FROM departments d JOIN employee_roles e ON d.dept_id = e.dept_id WHERE e.role_id != 1 GROUP BY d.dept_name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE consumer_preferences (consumer_id INT, country VARCHAR(50), favorite_product VARCHAR(100), is_cruelty_free BOOLEAN); INSERT INTO consumer_preferences (consumer_id, country, favorite_product, is_cruelty_free) VALUES (1, 'United States', 'Nourishing Face Cream', true), (2, 'France', 'Hydrating Body Lotion', false);
|
Which consumers prefer 'cruelty-free' products in 'France'?
|
SELECT consumer_id FROM consumer_preferences WHERE country = 'France' AND is_cruelty_free = true;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ocean_salinity (id INT, year INT, hemisphere VARCHAR(50), avg_salinity FLOAT); INSERT INTO ocean_salinity (id, year, hemisphere, avg_salinity) VALUES (1, 2020, 'Northern Hemisphere', 35); INSERT INTO ocean_salinity (id, year, hemisphere, avg_salinity) VALUES (2, 2020, 'Southern Hemisphere', 34.7);
|
What is the average salinity of the ocean in each hemisphere?
|
SELECT hemisphere, AVG(avg_salinity) FROM ocean_salinity GROUP BY hemisphere;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE vehicles (vehicle_id INT, vehicle_type TEXT); INSERT INTO vehicles (vehicle_id, vehicle_type) VALUES (1, 'Tram'), (2, 'Bus'), (3, 'Train'), (4, 'Electric Bus'); CREATE TABLE maintenance (maintenance_id INT, vehicle_id INT, maintenance_date DATE); INSERT INTO maintenance (maintenance_id, vehicle_id, maintenance_date) VALUES (1, 1, '2017-01-01'), (2, 1, '2018-01-01'), (3, 2, '2019-01-01'), (4, 4, '2021-01-01');
|
Remove all vehicle maintenance records for electric buses.
|
DELETE FROM maintenance WHERE vehicle_id IN (SELECT vehicle_id FROM vehicles WHERE vehicle_type = 'Electric Bus');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE vessel_positions (id INT, vessel_id INT, timestamp TIMESTAMP, longitude FLOAT, latitude FLOAT); INSERT INTO vessel_positions (id, vessel_id, timestamp, longitude, latitude) VALUES (1, 1, '2021-03-01 12:34:56', -66.13374, 43.64831); INSERT INTO vessel_positions (id, vessel_id, timestamp, longitude, latitude) VALUES (2, 1, '2021-03-02 08:21:15', -61.04312, 45.36298);
|
How many hours did the vessel 'Vessel1' spend near the coast of Canada?
|
SELECT TIMESTAMPDIFF(HOUR, MIN(timestamp), MAX(timestamp)) FROM vessel_positions WHERE vessel_id = 1 AND longitude BETWEEN -141.00024 AND -52.63551;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE employees (id INT, department VARCHAR(20), salary DECIMAL(10, 2)); INSERT INTO employees (id, department, salary) VALUES (1, 'management', 75000.00), (2, 'mining', 60000.00), (3, 'geology', 65000.00);
|
What is the maximum salary in the 'management' department?
|
SELECT MAX(salary) FROM employees WHERE department = 'management';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE employees (id INT, name VARCHAR(50), department VARCHAR(20), salary DECIMAL(10, 2)); INSERT INTO employees (id, name, department, salary) VALUES (1, 'John Doe', 'manufacturing', 50000.00), (2, 'Jane Smith', 'engineering', 60000.00), (3, 'Alice Johnson', 'HR', 55000.00), (4, 'Bob Brown', 'quality control', 52000.00), (5, 'Charlie Davis', 'sales', 65000.00);
|
What is the average salary of employees in the 'sales' department?
|
SELECT AVG(salary) FROM employees WHERE department = 'sales';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE mining_operations (id INT, location VARCHAR(50), operation_type VARCHAR(50), monthly_co2_emission INT); INSERT INTO mining_operations (id, location, operation_type, monthly_co2_emission) VALUES (1, 'Peru', 'Gold', 10000), (2, 'Mexico', 'Gold', 15000), (3, 'Chile', 'Copper', 20000);
|
What is the total CO2 emission from gold and copper mining operations in Peru and Mexico?
|
SELECT SUM(CASE WHEN operation_type IN ('Gold', 'Copper') AND location IN ('Peru', 'Mexico') THEN monthly_co2_emission ELSE 0 END) as total_emission FROM mining_operations;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE policy_analyses_2 (id INT, community TEXT, location TEXT, analyses_count INT); INSERT INTO policy_analyses_2 (id, community, location, analyses_count) VALUES (1, 'Indigenous A', 'urban', 3), (2, 'Indigenous B', 'rural', 5), (3, 'Indigenous A', 'urban', 2);
|
What is the total number of public health policy analyses conducted for indigenous communities, grouped by location?
|
SELECT location, SUM(analyses_count) FROM policy_analyses_2 WHERE community LIKE '%Indigenous%' GROUP BY location;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE sales (store_location VARCHAR(50), sale_date DATE, revenue DECIMAL(10,2));
|
What was the average monthly sales revenue for each store location in Canada in 2020?
|
SELECT store_location, AVG(revenue) as avg_monthly_revenue FROM sales WHERE country = 'Canada' AND sale_date BETWEEN '2020-01-01' AND '2020-12-31' GROUP BY store_location;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE worker_patient_data_total (worker_id INT, patients_served INT); INSERT INTO worker_patient_data_total (worker_id, patients_served) VALUES (1, 50); INSERT INTO worker_patient_data_total (worker_id, patients_served) VALUES (2, 75);
|
What is the total number of patients served by community health workers?
|
SELECT SUM(patients_served) FROM worker_patient_data_total;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE hospital (hospital_id INT, hospital_name TEXT, state TEXT, num_of_beds INT, has_maternity_ward BOOLEAN); INSERT INTO hospital (hospital_id, hospital_name, state, num_of_beds, has_maternity_ward) VALUES (1, 'UCLA Medical Center', 'California', 500, true); INSERT INTO hospital (hospital_id, hospital_name, state, num_of_beds, has_maternity_ward) VALUES (2, 'NYU Langone Health', 'New York', 800, true);
|
How many hospitals in New York have more than 500 beds?
|
SELECT COUNT(*) FROM hospital WHERE state = 'New York' AND num_of_beds > 500;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE co2_emissions (id INT, company TEXT, location TEXT, timestamp TIMESTAMP, co2_emission FLOAT); INSERT INTO co2_emissions (id, company, location, timestamp, co2_emission) VALUES (1, 'Texas Mining Inc', 'Texas', '2018-01-01 12:00:00', 1200);
|
What is the total CO2 emission of the mining sector in the state of Texas in the last 5 years?
|
SELECT SUM(co2_emission) FROM co2_emissions WHERE location = 'Texas' AND EXTRACT(YEAR FROM timestamp) >= EXTRACT(YEAR FROM CURRENT_DATE) - 5;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE conservation_program (id INT PRIMARY KEY, animal_name VARCHAR, num_animals INT); INSERT INTO conservation_program (id, animal_name, num_animals) VALUES (1, 'Tiger', 300), (2, 'Panda', 150), (3, 'Rhino', 70), (4, 'Elephant', 450);
|
Update animal count in 'conservation_program' for Panda
|
UPDATE conservation_program SET num_animals = 200 WHERE animal_name = 'Panda';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE vessels (id INT, name VARCHAR(255), country VARCHAR(255), capacity INT, year_built INT); INSERT INTO vessels (id, name, country, capacity, year_built) VALUES (1, 'Vessel1', 'China', 10000, 2005), (2, 'Vessel2', 'Japan', 12000, 2008), (3, 'Vessel3', 'South Korea', 8000, 2012);
|
What is the total capacity of vessels in the vessels table that were built before 2010?
|
SELECT SUM(capacity) as total_capacity_before_2010 FROM vessels WHERE year_built < 2010;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE EnvironmentalViolations (ViolationID INT, ViolationDate DATE, Description VARCHAR(255), FineAmount DECIMAL(10,2), MineID INT);
|
Delete all environmental violations that occurred before 2010 and provide a summary.
|
WITH pre_2010 AS (DELETE FROM EnvironmentalViolations WHERE ViolationDate < '2010-01-01' RETURNING *) SELECT COUNT(*) as ViolationsDeleted FROM pre_2010;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ocean_temperatures (ocean TEXT, temperature FLOAT);
|
What is the average temperature in the Atlantic Ocean?
|
SELECT AVG(temperature) FROM ocean_temperatures WHERE ocean = 'Atlantic Ocean';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE hotel_stats (year INT, continent TEXT, occupancy DECIMAL(5,2)); INSERT INTO hotel_stats (year, continent, occupancy) VALUES (2020, 'South America', 0.65), (2021, 'South America', 0.72), (2022, 'South America', 0.75);
|
Calculate the average hotel occupancy rate in South America for the last 2 years.
|
SELECT AVG(occupancy) as avg_occupancy FROM hotel_stats WHERE continent = 'South America' AND year >= (SELECT MAX(year) - 2);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE species (species_id INT, name TEXT, location TEXT); INSERT INTO species (species_id, name, location) VALUES (1, 'Starfish', 'Atlantic'), (2, 'Jellyfish', 'Atlantic');
|
What is the total number of species in the Atlantic ocean?
|
SELECT COUNT(*) FROM species WHERE location = 'Atlantic'
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE posts (id INT, user_id INT, timestamp TIMESTAMP); INSERT INTO posts (id, user_id, timestamp) VALUES (1, 1, '2022-01-01 10:00:00'), (2, 1, '2022-01-02 12:00:00'), (3, 1, '2022-01-03 14:00:00'), (4, 2, '2022-01-01 10:00:00'), (5, 2, '2022-01-02 12:00:00');
|
What is the average number of posts per day for a given user?
|
SELECT user_id, AVG(1.0 * COUNT(DISTINCT DATE(timestamp))) AS avg_posts_per_day FROM posts GROUP BY user_id;
|
gretelai_synthetic_text_to_sql
|
CREATE SCHEMA energy_storage; CREATE TABLE storage_projects (id INT, technology VARCHAR(50), status VARCHAR(50)); INSERT INTO storage_projects (id, technology, status) VALUES (1, 'Lithium-ion', 'Operational'), (2, 'Flow', 'Operational'), (3, 'Lead-acid', 'Operational'), (4, 'Lithium-ion', 'Under Construction'), (5, 'Flow', 'Under Construction'), (6, 'Lead-acid', 'Under Construction'), (7, 'Sodium-ion', 'Operational'), (8, 'Sodium-ion', 'Under Construction');
|
How many energy storage projects are there in the 'energy_storage' schema, grouped by technology type and ordered by the count in descending order?
|
SELECT technology, COUNT(*) as count FROM energy_storage.storage_projects GROUP BY technology ORDER BY count DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE BudgetAllocations (Year INT, Service TEXT, Amount INT); INSERT INTO BudgetAllocations (Year, Service, Amount) VALUES (2020, 'PublicSafety', 10000000), (2021, 'PublicSafety', 11000000);
|
What was the total budget allocated for public safety in 2020 and 2021, and which year had a higher allocation?
|
SELECT Year, SUM(Amount) FROM BudgetAllocations WHERE Service = 'PublicSafety' GROUP BY Year HAVING Year IN (2020, 2021) ORDER BY SUM(Amount) DESC LIMIT 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE cultural_competency_training (worker_id INT, state VARCHAR(2), received_training BOOLEAN); INSERT INTO cultural_competency_training (worker_id, state, received_training) VALUES (1, 'CA', TRUE), (2, 'NY', FALSE), (3, 'TX', TRUE);
|
What is the percentage of community health workers who have received cultural competency training in each state?
|
SELECT c.state, (COUNT(*) FILTER (WHERE c.received_training = TRUE)) * 100.0 / COUNT(*) as pct_trained FROM cultural_competency_training c GROUP BY c.state;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE physicians (name VARCHAR(255), specialty VARCHAR(255), region VARCHAR(255)); INSERT INTO physicians (name, specialty, region) VALUES ('Dr. A', 'Primary Care', 'South'), ('Dr. B', 'Specialist', 'South'), ('Dr. C', 'Primary Care', 'South'), ('Dr. D', 'Specialist', 'South'), ('Dr. E', 'Primary Care', 'North'), ('Dr. F', 'Specialist', 'North');
|
What is the total number of primary care physicians and specialists in the South region?
|
SELECT specialty, COUNT(*) FROM physicians WHERE region = 'South' GROUP BY specialty;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE donors (donor_id INT, donation_date DATE, amount DECIMAL(10,2)); INSERT INTO donors VALUES (1, '2022-01-01', 50.00), (2, '2022-01-15', 100.00), (3, '2022-03-01', 200.00);
|
What was the total donation amount from new donors in Q1 2022?
|
SELECT SUM(amount) FROM donors WHERE donation_date BETWEEN '2022-01-01' AND '2022-03-31' AND donor_id NOT IN (SELECT donor_id FROM donors WHERE donation_date < '2022-01-01');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE UserLocations (UserID INT, City VARCHAR(255)); INSERT INTO UserLocations (UserID, City) VALUES (1, 'New York'), (2, 'Los Angeles'), (3, 'Chicago'), (4, 'Houston'), (5, 'Phoenix');
|
Identify the top 5 cities with the highest number of registered users in the "MediaEthics" database.
|
SELECT City, COUNT(*) FROM UserLocations GROUP BY City ORDER BY COUNT(*) DESC LIMIT 5;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE green_buildings (id INT, project_name VARCHAR(50), state VARCHAR(50)); INSERT INTO green_buildings (id, project_name, state) VALUES (1, 'Greenville Project', 'Texas'); INSERT INTO green_buildings (id, project_name, state) VALUES (2, 'Austin Green Towers', 'Texas');
|
What is the total number of green building projects in Texas?
|
SELECT COUNT(*) FROM green_buildings WHERE state = 'Texas' AND project_name LIKE '%green%'
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Donors (DonorID INT, DonorName TEXT, Age INT, DonationCount INT, DonationYear INT); INSERT INTO Donors (DonorID, DonorName, Age, DonationCount, DonationYear) VALUES (1, 'John Doe', 35, 2, 2021), (2, 'Jane Smith', 40, 1, 2021), (3, 'Alice Johnson', 28, 3, 2021), (4, 'Bob Brown', 45, 1, 2021), (5, 'Charlie Davis', 32, 2, 2021);
|
Which age group made the most donations in 2021?
|
SELECT Age, SUM(DonationCount) FROM Donors WHERE DonationYear = 2021 GROUP BY Age ORDER BY SUM(DonationCount) DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE posts (id INT, user VARCHAR(255), content TEXT, likes INT, timestamp TIMESTAMP);
|
What is the average number of likes on posts containing the hashtag "#nature" in the past week?
|
SELECT AVG(likes) FROM posts WHERE hashtags LIKE '%#nature%' AND timestamp BETWEEN DATE_SUB(NOW(), INTERVAL 1 WEEK) AND NOW();
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE games_sales (id INT, game_id INT, sport VARCHAR(50), sales INT); INSERT INTO games_sales (id, game_id, sport, sales) VALUES (1, 1, 'Basketball', 500); INSERT INTO games_sales (id, game_id, sport, sales) VALUES (2, 2, 'Basketball', 700);
|
What is the maximum number of tickets sold for any single Basketball game?
|
SELECT MAX(sales) FROM games_sales WHERE sport = 'Basketball';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Students_With_Disabilities (id INT, student_id INT, disability_type VARCHAR(50), ethnicity VARCHAR(50), num_accommodations INT); INSERT INTO Students_With_Disabilities (id, student_id, disability_type, ethnicity, num_accommodations) VALUES (1, 4001, 'Learning Disability', 'Hispanic', 2), (2, 4002, 'Mobility Impairment', 'African American', 1), (3, 4003, 'Visual Impairment', 'Asian', 3), (4, 4004, 'Hearing Impairment', 'Native American', 2);
|
What is the average number of disability-related accommodations provided per student with a disability by ethnicity?
|
SELECT AVG(Students_With_Disabilities.num_accommodations) as average_accommodations, Students_With_Disabilities.ethnicity FROM Students_With_Disabilities GROUP BY Students_With_Disabilities.ethnicity;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Explainable_AI (model_name TEXT, technique TEXT, algorithm TEXT); INSERT INTO Explainable_AI VALUES ('ALEX','Decision Tree', 'Random Forest');
|
What are the names of all explainable AI models that use decision trees?
|
SELECT model_name FROM Explainable_AI WHERE technique = 'Decision Tree';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE division (division_id INT, division_name VARCHAR(255)); INSERT INTO division (division_id, division_name) VALUES (1, 'Patrol'), (2, 'Investigations'), (3, 'Special Operations'); CREATE TABLE police_officers (officer_id INT, division_id INT, officer_name VARCHAR(255), officer_rank VARCHAR(255));
|
What is the total number of police officers in each division and their respective ranks?
|
SELECT division_id, COUNT(*), officer_rank FROM police_officers GROUP BY division_id, officer_rank;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Volunteers (VolunteerID INT, VolunteerName VARCHAR(100), Program VARCHAR(50), SignUpDate DATE); CREATE TABLE Community (CommunityID INT, CommunityName VARCHAR(50), State VARCHAR(50));
|
How many volunteers signed up for programs in Texas in the third quarter of 2019?
|
SELECT COUNT(*) FROM Volunteers INNER JOIN Community ON Volunteers.Program = Community.CommunityName WHERE Community.State = 'Texas' AND QUARTER(SignUpDate) = 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE NavalVessels (ID INT, Name VARCHAR(50), NumWeapons INT);
|
What is the average number of weapons for each naval vessel?
|
SELECT AVG(NumWeapons) FROM NavalVessels;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE tourism_stats (destination VARCHAR(255), year INT, visitors INT); INSERT INTO tourism_stats (destination, year, visitors) VALUES ('City D', 2019, 600000), ('City D', 2020, 800000), ('City E', 2019, 750000), ('City E', 2020, 700000), ('City F', 2019, 850000), ('City F', 2020, 950000);
|
Find the destination in Africa with the highest increase in tourists from 2019 to 2020
|
SELECT destination, (visitors - (SELECT visitors FROM tourism_stats t2 WHERE t2.destination = t1.destination AND t2.year = 2019)) AS diff FROM tourism_stats t1 WHERE year = 2020 ORDER BY diff DESC LIMIT 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE OrganicCottonManufacturing (id INT, water_consumption DECIMAL); INSERT INTO OrganicCottonManufacturing (id, water_consumption) VALUES (1, 1800), (2, 1900), (3, 1850), (4, 1700), (5, 1950);
|
What is the average water consumption of manufacturing processes using organic cotton?
|
SELECT AVG(water_consumption) FROM OrganicCottonManufacturing;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE companies (id INT, name TEXT, industry TEXT, founding_year INT, founder_gender TEXT); INSERT INTO companies (id, name, industry, founding_year, founder_gender) VALUES (9, 'HealthCareSolutions', 'Healthcare', 2022, 'Female'); INSERT INTO companies (id, name, industry, founding_year, founder_gender) VALUES (10, 'GreenInno', 'GreenTech', 2020, 'Male');
|
How many startups founded by women in the healthcare sector have never received funding?
|
SELECT COUNT(*) FROM companies WHERE founder_gender = 'Female' AND industry = 'Healthcare' AND id NOT IN (SELECT company_id FROM funding_records);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE arctic_species (id INT, species VARCHAR(255)); INSERT INTO arctic_species VALUES (1, 'Polar Bear'); INSERT INTO arctic_species VALUES (2, 'Narwhal'); CREATE TABLE antarctic_species (id INT, species VARCHAR(255)); INSERT INTO antarctic_species VALUES (1, 'Penguin'); INSERT INTO antarctic_species VALUES (2, 'Polar Bear');
|
List the species that exist in both the Arctic and Antarctic oceans.
|
SELECT species FROM arctic_species WHERE species IN (SELECT species FROM antarctic_species);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Employees (EmployeeID INT, EmployeeName VARCHAR(20), Department VARCHAR(20), Salary INT); INSERT INTO Employees (EmployeeID, EmployeeName, Department, Salary) VALUES (1, 'Ava Jones', 'Sales', 50000), (2, 'Brian Kim', 'Marketing', 60000), (3, 'Carlos Lopez', 'Sales', 55000);
|
What is the average salary for employees in the Sales department who have completed diversity training?
|
SELECT AVG(Salary) FROM Employees e JOIN Training t ON e.EmployeeID = t.EmployeeID WHERE e.Department = 'Sales' AND t.TrainingType = 'Diversity';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE student_mental_health_year (student_id INT, date DATE, score INT);
|
What is the change in mental health score from the beginning to the end of the school year for each student?
|
SELECT student_id, LAG(score) OVER (PARTITION BY student_id ORDER BY date) as beginning_score, score as end_score, score - LAG(score) OVER (PARTITION BY student_id ORDER BY date) as change FROM student_mental_health_year WHERE EXTRACT(MONTH FROM date) IN (5, 6, 7) AND EXTRACT(YEAR FROM date) = 2022;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE tokyo_train (route_id INT, num_riders INT, route_name VARCHAR(255));
|
List all unique train routes in Tokyo with more than 1000 riders per day
|
SELECT DISTINCT route_id, route_name FROM tokyo_train WHERE num_riders > 1000;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE CountryCybersecurity (country TEXT, budget INTEGER); INSERT INTO CountryCybersecurity (country, budget) VALUES ('USA', 20000000), ('China', 15000000), ('Russia', 10000000), ('India', 5000000), ('Germany', 7000000);
|
Which countries have the highest cybersecurity budgets?
|
SELECT country, budget FROM CountryCybersecurity ORDER BY budget DESC LIMIT 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE health_centers (id INT, name TEXT, location TEXT); INSERT INTO health_centers (id, name, location) VALUES (1, 'Health Center A', 'Rural Alaska'); INSERT INTO health_centers (id, name, location) VALUES (2, 'Health Center B', 'Urban Alaska'); INSERT INTO health_centers (id, name, location) VALUES (3, 'Health Center C', 'Rural Hawaii');
|
What is the number of rural health centers in Alaska and Hawaii?
|
SELECT COUNT(*) FROM health_centers WHERE location IN ('Rural Alaska', 'Rural Hawaii');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE startups(id INT, name TEXT, industry TEXT, founder_gender TEXT, funding FLOAT); INSERT INTO startups(id, name, industry, founder_gender, funding) VALUES (1, 'WomenInFinance', 'Fintech', 'Female', 5000000);
|
What is the total funding raised by startups with at least one female founder in the fintech sector?
|
SELECT SUM(funding) FROM startups WHERE industry = 'Fintech' AND founder_gender = 'Female';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE farmers (id INT PRIMARY KEY, name VARCHAR(50), age INT, gender VARCHAR(10), location VARCHAR(50)); INSERT INTO farmers (id, name, age, gender, location) VALUES (1, 'John Doe', 35, 'Male', 'USA'); INSERT INTO farmers (id, name, age, gender, location) VALUES (2, 'Jane Smith', 40, 'Female', 'Canada');
|
Create a view named 'older_farmers' with farmers older than 45
|
CREATE VIEW older_farmers AS SELECT * FROM farmers WHERE age > 45;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE wells (id INT, state VARCHAR(10), well_type VARCHAR(10), num_drilled INT); INSERT INTO wells (id, state, well_type, num_drilled) VALUES (1, 'Texas', 'Oil', 250), (2, 'Oklahoma', 'Gas', 180);
|
Find the number of wells drilled in Texas and Oklahoma
|
SELECT SUM(num_drilled) FROM wells WHERE state IN ('Texas', 'Oklahoma');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE HealthPolicies (PolicyID int, Region varchar(10)); INSERT INTO HealthPolicies (PolicyID, Region) VALUES (1, 'North'); INSERT INTO HealthPolicies (PolicyID, Region) VALUES (2, 'South'); INSERT INTO HealthPolicies (PolicyID, Region) VALUES (3, 'North');
|
How many health insurance policies are there in the 'North' region?
|
SELECT COUNT(*) FROM HealthPolicies WHERE Region = 'North';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Bridges (bridge_id int, bridge_name varchar(255), year int, location varchar(255));
|
Find the average age of bridges in each state
|
SELECT state, AVG(YEAR(CURRENT_DATE) - year) AS avg_age FROM Bridges GROUP BY state;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Donations (DonationID INT, DonationDate DATE); CREATE TABLE DonationDetails (DonationID INT, Amount DECIMAL(10,2)); INSERT INTO Donations (DonationID, DonationDate) VALUES (1, '2021-01-01'), (2, '2021-01-15'), (3, '2021-02-03'), (4, '2021-02-28'), (5, '2021-03-12'), (6, '2021-03-25'); INSERT INTO DonationDetails (DonationID, Amount) VALUES (1, 500), (2, 1000), (3, 750), (4, 250), (5, 300), (6, 800);
|
What is the total number of donations and their average amount for each month?
|
SELECT EXTRACT(MONTH FROM dd.DonationDate) as Month, COUNT(dd.DonationID) as NumDonations, AVG(dd.Amount) as AvgDonation FROM Donations dd JOIN DonationDetails dd2 ON dd.DonationID = dd2.DonationID GROUP BY Month;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE marine_species (id INT, species_name VARCHAR(255), conservation_status VARCHAR(100)); INSERT INTO marine_species (id, species_name, conservation_status) VALUES (1, 'Vaquita', 'Critically Endangered'), (2, 'Yangtze Finless Porpoise', 'Endangered'), (3, 'Blue Whale', 'Vulnerable'), (4, 'Leatherback Sea Turtle', 'Vulnerable'), (5, 'Giant Pacific Octopus', 'Least Concern'), (6, 'Passenger Pigeon', 'Extinct');
|
What is the number of marine species with a conservation status of 'Critically Endangered' or 'Extinct'?
|
SELECT COUNT(*) FROM marine_species WHERE conservation_status IN ('Critically Endangered', 'Extinct');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Machines (id INT, name VARCHAR(255), mining_site_id INT); INSERT INTO Machines (id, name, mining_site_id) VALUES (1, 'Machine A', 1), (2, 'Machine B', 1), (3, 'Machine C', 2);
|
List all the unique machines used in the mining operations
|
SELECT DISTINCT name FROM Machines;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE labor_statistics (state VARCHAR(20), occupation VARCHAR(20), number_of_employees INT); INSERT INTO labor_statistics (state, occupation, number_of_employees) VALUES ('Texas', 'Construction laborer', 15000); INSERT INTO labor_statistics (state, occupation, number_of_employees) VALUES ('California', 'Construction laborer', 12000);
|
How many construction laborers are there in Texas?
|
SELECT SUM(number_of_employees) FROM labor_statistics WHERE state = 'Texas' AND occupation = 'Construction laborer';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE dishes (id INT, name TEXT, category TEXT, sustainable_sourcing INT); INSERT INTO dishes (id, name, category, sustainable_sourcing) VALUES (1, 'Falafel', 'vegan', 5), (2, 'Quinoa Salad', 'vegan', 8), (3, 'Pizza', 'non-vegan', 3), (4, 'Pasta', 'gluten-free', 2);
|
Identify dishes that need sustainable sourcing improvements in 'vegan' and 'gluten-free' categories.
|
SELECT name, category FROM dishes WHERE sustainable_sourcing < 5 AND category IN ('vegan', 'gluten-free');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ethical_manufacturing (manufacturer_id INT, certification_status TEXT); INSERT INTO ethical_manufacturing (manufacturer_id, certification_status) VALUES (1, 'Fair Trade Pending'), (2, 'Not Certified'), (3, 'Fair Trade Certified'), (4, 'ManufacturerD');
|
Update the records in the ethical_manufacturing table with the correct 'Fair Trade' certification status for 'ManufacturerD'.
|
UPDATE ethical_manufacturing SET certification_status = 'Fair Trade Certified' WHERE manufacturer_id = (SELECT manufacturer_id FROM manufacturers WHERE manufacturer_name = 'ManufacturerD');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE government_transparency_initiatives (initiative_id INT, launch_year INT, state VARCHAR(20)); INSERT INTO government_transparency_initiatives (initiative_id, launch_year, state) VALUES (1, 2017, 'California'), (2, 2016, 'Texas'), (3, 2015, 'California'), (4, 2018, 'California'), (5, 2017, 'New York'), (6, 2020, 'California'), (7, 2019, 'California'), (8, 2019, 'Texas'), (9, 2020, 'New York');
|
How many government transparency initiatives were launched in the state of California in the year 2019?
|
SELECT COUNT(*) FROM government_transparency_initiatives WHERE launch_year = 2019 AND state = 'California';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE companies (id INT, name TEXT, founder_continent TEXT);
|
How many startups have been founded by people from each continent?
|
SELECT founder_continent, COUNT(*) as num_startups FROM companies GROUP BY founder_continent;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Suppliers (id INT, supplier VARCHAR(255), category VARCHAR(255)); INSERT INTO Suppliers (id, supplier, category) VALUES (1, 'Supplier1', 'Clothing'), (2, 'Supplier2', 'Electronics'), (3, 'Supplier3', 'Food'), (4, 'Supplier4', 'Furniture'); CREATE TABLE EthicalProducts (id INT, supplier_id INT, product VARCHAR(255), ethical BOOLEAN); INSERT INTO EthicalProducts (id, supplier_id, product, ethical) VALUES (1, 1, 'T-Shirt', true), (2, 1, 'Jeans', true), (3, 2, 'Smartphone', true), (4, 2, 'Headphones', true), (5, 3, 'Apples', true), (6, 3, 'Bananas', true), (7, 4, 'Table', false), (8, 4, 'Chair', false);
|
How many products does each supplier provide for ethical labor practices, by category?
|
SELECT s.category, e.supplier, COUNT(e.product) AS product_count FROM EthicalProducts e JOIN Suppliers s ON e.supplier_id = s.id WHERE e.ethical = true GROUP BY s.category, e.supplier;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE medical_facilities (facility_id INT, facility_name VARCHAR(255), facility_type VARCHAR(255), location VARCHAR(255), capacity INT);
|
Create a table for storing information about medical facilities in the 'disaster_response' schema.
|
CREATE TABLE medical_facilities (facility_id INT, facility_name VARCHAR(255), facility_type VARCHAR(255), location VARCHAR(255), capacity INT);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE sales_data (sale_id INT, jean_size INT, sale_date DATE); INSERT INTO sales_data (sale_id, jean_size, sale_date) VALUES (1, 28, '2022-06-03'), (2, 30, '2022-06-15'), (3, 32, '2022-06-27'), (4, 26, '2022-07-08'), (5, 30, '2022-07-15');
|
How many size 30 jeans were sold in the last month?
|
SELECT COUNT(*) FROM sales_data WHERE jean_size = 30 AND sale_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE forest_plot (id INT PRIMARY KEY, size FLOAT, species_id INT, FOREIGN KEY (species_id) REFERENCES species(id));
|
Remove any duplicate records from the forest_plot table.
|
DELETE FROM forest_plot fp USING (SELECT MIN(id) as id, size, species_id FROM forest_plot GROUP BY size, species_id HAVING COUNT(*) > 1) dup WHERE fp.id = dup.id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE infrastructure_projects(id INT, province TEXT, project_name TEXT, completion_status TEXT); INSERT INTO infrastructure_projects (id, province, project_name, completion_status) VALUES (1, 'Gauteng', 'Water Purification Plant', 'completed'); INSERT INTO infrastructure_projects (id, province, project_name, completion_status) VALUES (2, 'KwaZulu-Natal', 'Road Construction', 'in progress');
|
Delete the rural infrastructure project with ID 2 from the 'infrastructure_projects' table.
|
DELETE FROM infrastructure_projects WHERE id = 2;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE agency_data (agency VARCHAR(255), reports INT, month INT, year INT); INSERT INTO agency_data VALUES ('Agency A', 10, 1, 2022), ('Agency A', 12, 2, 2022), ('Agency B', 15, 1, 2022), ('Agency B', 18, 2, 2022);
|
What is the total number of transparency reports published by each agency in the last 12 months?
|
SELECT agency, SUM(reports) FROM agency_data WHERE month BETWEEN (SELECT EXTRACT(MONTH FROM NOW()) - 12) AND EXTRACT(MONTH FROM NOW()) AND year = EXTRACT(YEAR FROM NOW()) GROUP BY agency;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE MilitaryBases (Country VARCHAR(50), NumberOfBases INT); INSERT INTO MilitaryBases (Country, NumberOfBases) VALUES ('Egypt', 30), ('Algeria', 25), ('South Africa', 20), ('Morocco', 15), ('Sudan', 10);
|
What is the average number of military bases in each African country?
|
SELECT AVG(NumberOfBases) FROM MilitaryBases WHERE Country IN ('Egypt', 'Algeria', 'South Africa', 'Morocco', 'Sudan');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE price (id INT, refinery_id INT, date DATE, price FLOAT); INSERT INTO price (id, refinery_id, date, price) VALUES (1, 1, '2021-01-01', 100.0), (2, 1, '2021-02-01', 120.0), (3, 2, '2021-01-01', 150.0), (4, 2, '2021-02-01', 180.0);
|
Compute the average rare earth element price by refinery and quarter.
|
SELECT refinery_id, QUARTER(date) AS quarter, AVG(price) AS avg_price FROM price GROUP BY refinery_id, quarter;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE smart_city (project_name TEXT, state TEXT, start_date DATE, company TEXT); INSERT INTO smart_city (project_name, state, start_date, company) VALUES ('Smart Grid Project', 'New York', '2020-01-01', 'TechCo');
|
List all smart city projects in the state of New York, including their start dates and the names of the companies responsible for their implementation.
|
SELECT project_name, state, start_date, company FROM smart_city WHERE state = 'New York';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Products (ProductID INT, ProductName VARCHAR(50), IsVegan BOOLEAN, IsCrueltyFree BOOLEAN); INSERT INTO Products (ProductID, ProductName, IsVegan, IsCrueltyFree) VALUES (1, 'Lip Balm', true, true), (2, 'Face Cream', false, true), (3, 'Moisturizer', false, true);
|
Insert new vegan cosmetic products into the Products table.
|
INSERT INTO Products (ProductID, ProductName, IsVegan, IsCrueltyFree) VALUES (4, 'Vegan Lipstick', true, true), (5, 'Vegan Mascara', true, true), (6, 'Vegan Eyeshadow', true, true);
|
gretelai_synthetic_text_to_sql
|
CREATE SCHEMA IF NOT EXISTS sustainable_buildings;CREATE TABLE IF NOT EXISTS sustainable_buildings.green_buildings (id INT, name VARCHAR(50), certification VARCHAR(20));INSERT INTO sustainable_buildings.green_buildings (id, name, certification) VALUES (1, 'Green Building A', 'Platinum'), (2, 'Green Building B', 'Gold'), (3, 'Green Building C', 'Silver');
|
List the Green Buildings in the 'sustainable_buildings' schema with a Gold LEED certification.
|
SELECT name FROM sustainable_buildings.green_buildings WHERE certification = 'Gold';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE hospitals (id INT, name VARCHAR(255), rural_designation VARCHAR(50), state_id INT); INSERT INTO hospitals (id, name, rural_designation, state_id) VALUES (1, 'Hospital A', 'Rural', 1); CREATE TABLE readmissions (id INT, hospital_id INT, diabetes BOOLEAN, readmission BOOLEAN); INSERT INTO readmissions (id, hospital_id, diabetes, readmission) VALUES (1, 1, true, true);
|
Which rural hospitals have the highest readmission rates for diabetes patients?
|
SELECT h.name, ROUND(COUNT(r.id) * 100.0 / (SELECT COUNT(*) FROM readmissions r WHERE r.hospital_id = h.id AND r.diabetes = true), 2) AS readmission_percentage FROM hospitals h JOIN readmissions r ON h.id = r.hospital_id WHERE h.rural_designation = 'Rural' AND r.diabetes = true GROUP BY h.name ORDER BY readmission_percentage DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE heritage_sites (id INT, name TEXT, country TEXT, type TEXT); INSERT INTO heritage_sites (id, name, country, type) VALUES (1, 'Acropolis of Athens', 'Greece', 'cultural'); INSERT INTO heritage_sites (id, name, country, type) VALUES (2, 'Parthenon', 'Greece', 'cultural');
|
Delete all records of cultural heritage sites in Greece.
|
DELETE FROM heritage_sites WHERE country = 'Greece' AND type = 'cultural';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE satellites (id INT, country VARCHAR(255), launch_date DATE);
|
What is the difference in the number of satellites launched by the US and the European Union?
|
SELECT US_launches - EU_launches AS difference FROM (SELECT COUNT(*) AS US_launches FROM satellites WHERE country = 'US') AS subquery1, (SELECT COUNT(*) AS EU_launches FROM satellites WHERE country = 'European Union') AS subquery2;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE programs_impact (program TEXT, impact_score DECIMAL); INSERT INTO programs_impact (program, impact_score) VALUES ('Program A', 4.2), ('Program B', 3.5), ('Program C', 5.0), ('Program D', 4.5);
|
List all the unique programs with a program impact score greater than 4?
|
SELECT program FROM programs_impact WHERE impact_score > 4;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE mental_health_parity (id INT, regulation VARCHAR(100), state VARCHAR(20), implementation_date DATE); INSERT INTO mental_health_parity (id, regulation, state, implementation_date) VALUES (1, 'Regulation 1', 'New York', '2011-01-01'), (2, 'Regulation 2', 'Florida', '2012-01-01');
|
List all mental health parity regulations that have been implemented in New York and Florida since 2010.
|
SELECT regulation, state, implementation_date FROM mental_health_parity WHERE state IN ('New York', 'Florida') AND implementation_date >= '2010-01-01';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE donors (id INT, last_name VARCHAR, first_name VARCHAR, city VARCHAR); INSERT INTO donors VALUES (1, 'Smith', 'John', 'NYC')
|
Identify the top 3 most common last names of donors
|
SELECT d.last_name, COUNT(*) AS count FROM donors d GROUP BY d.last_name ORDER BY count DESC LIMIT 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE country_harvest (id INT, country VARCHAR(255), facility_name VARCHAR(255), avg_vol_cubic_meters FLOAT);
|
Which countries have the highest average sustainable timber harvest volume, in cubic meters, per timber production facility?
|
SELECT country, AVG(avg_vol_cubic_meters) FROM country_harvest GROUP BY country ORDER BY AVG(avg_vol_cubic_meters) DESC LIMIT 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE disasters (disaster_id INT, disaster_name TEXT, disaster_type TEXT, response_time INT, year INT, region TEXT); INSERT INTO disasters (disaster_id, disaster_name, disaster_type, response_time, year, region) VALUES (1, 'Floods', 'natural disaster', 72, 2019, 'Asia');
|
What is the average response time for disaster relief in Asia in 2019?
|
SELECT AVG(response_time) as avg_response_time FROM disasters WHERE disaster_type = 'natural disaster' AND year = 2019 AND region = 'Asia';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ExhibitionStats (exhibition_id INT, min_visits INT, max_visits INT); INSERT INTO ExhibitionStats (exhibition_id, min_visits, max_visits) VALUES (1, 1000, 2000), (2, 1500, 2500), (3, 2000, 3000);
|
What is the minimum number of visits for any exhibition?
|
SELECT MIN(min_visits) FROM ExhibitionStats;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Factories (factory_id INT, factory_location VARCHAR(50), factory_working_hours INT);
|
What is the maximum number of working hours per week for factories in Bangladesh?
|
SELECT MAX(factory_working_hours) AS max_working_hours FROM Factories WHERE factory_location = 'Bangladesh';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE regions (region_id INT, region_name VARCHAR(50)); INSERT INTO regions (region_id, region_name) VALUES (1, 'Northeast'), (2, 'Southeast'), (3, 'Midwest'), (4, 'Southwest'), (5, 'West'); CREATE TABLE community_health_workers (worker_id INT, worker_name VARCHAR(50), region_id INT); CREATE TABLE training_sessions (session_id INT, session_name VARCHAR(50), completed_by_worker INT); INSERT INTO training_sessions (session_id, session_name, completed_by_worker) VALUES (1, 'Cultural Competency 101', 120), (2, 'Advanced Cultural Competency', 80);
|
What is the percentage of community health workers who have completed cultural competency training in each region?
|
SELECT r.region_name, 100.0 * COUNT(chw.worker_id) / (SELECT COUNT(*) FROM community_health_workers chw2 WHERE chw2.region_id = r.region_id) as completion_rate FROM regions r JOIN community_health_workers chw ON r.region_id = chw.region_id JOIN training_sessions ts ON chw.worker_id = ts.completed_by_worker AND ts.session_id = (SELECT MAX(session_id) FROM training_sessions) GROUP BY r.region_name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE players (id INT, platform VARCHAR(20));CREATE TABLE games (id INT, player_id INT, game_type VARCHAR(10));CREATE TABLE vr_games (id INT, player_id INT, last_played DATE);
|
What is the percentage of players who have played a game on each platform, and the percentage of players who have played VR games on each platform?
|
SELECT p.platform, 100.0 * COUNT(DISTINCT g.player_id) / COUNT(DISTINCT p.id) AS players_with_games_percentage, 100.0 * COUNT(DISTINCT v.player_id) / COUNT(DISTINCT p.id) AS vr_players_percentage FROM players p LEFT JOIN games g ON p.id = g.player_id LEFT JOIN vr_games v ON p.id = v.player_id GROUP BY p.platform;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE authors (author_id INT PRIMARY KEY, first_name VARCHAR(50), last_name VARCHAR(50));
|
Delete the record for the author 'John Doe' from the 'authors' table
|
DELETE FROM authors WHERE first_name = 'John' AND last_name = 'Doe';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE donations (id INT, program VARCHAR(255), amount DECIMAL(10, 2)); INSERT INTO donations (id, program, amount) VALUES (1, 'Animal Welfare', 500.00), (2, 'Education', 1000.00); CREATE TABLE volunteers (id INT, program VARCHAR(255), hours INT); INSERT INTO volunteers (id, program, hours) VALUES (1, 'Animal Welfare', 20), (2, 'Education', 30);
|
What is the total donation amount for the 'Education' program and total volunteer hours for the 'Animal Welfare' program?
|
SELECT SUM(d.amount) FROM donations d WHERE d.program = 'Education'; SELECT SUM(v.hours) FROM volunteers v WHERE v.program = 'Animal Welfare';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ai_projects_budget (project_name TEXT, budget INTEGER); INSERT INTO ai_projects_budget (project_name, budget) VALUES ('ProjectA', 1000000), ('ProjectB', 2000000), ('ProjectC', 3000000), ('ProjectD', 4000000);
|
What is the maximum budget spent on a single AI project?
|
SELECT MAX(budget) FROM ai_projects_budget;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE safety_incidents (incident_date DATE, incident_type VARCHAR(20), incident_count INT); INSERT INTO safety_incidents (incident_date, incident_type, incident_count) VALUES ('2022-01-01', 'autonomous_vehicle', 3), ('2022-01-05', 'AI_assistant', 1), ('2022-02-10', 'autonomous_vehicle', 2);
|
How many AI safety incidents were recorded for each month in the 'safety_incidents' table?
|
SELECT DATE_FORMAT(incident_date, '%Y-%m') as month, SUM(incident_count) as total_incidents FROM safety_incidents GROUP BY month;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE shared_cars (id INT, city VARCHAR(50), car_count INT, timestamp TIMESTAMP);
|
What is the number of shared electric cars in Singapore and Hong Kong?
|
SELECT city, SUM(car_count) FROM shared_cars WHERE city IN ('Singapore', 'Hong Kong') GROUP BY city;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE GamePerformance (GameID INT, GraphicsCard VARCHAR(100), FrameRate FLOAT); INSERT INTO GamePerformance (GameID, GraphicsCard, FrameRate) VALUES (1, 'GraphicsCardA', 60.5), (2, 'GraphicsCardB', 70.2), (3, 'GraphicsCardA', 65.1);
|
What is the average frame rate of each game on high-end graphics cards?
|
SELECT GameID, AVG(FrameRate) as AvgFrameRate FROM GamePerformance WHERE GraphicsCard IN ('GraphicsCardA', 'GraphicsCardB') GROUP BY GameID;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE project (id INT, name VARCHAR(255), start_date DATE, end_date DATE, is_green BOOLEAN); INSERT INTO project (id, name, start_date, end_date, is_green) VALUES (1, 'Sample Project 1', '2020-01-01', '2020-06-01', true), (2, 'Sample Project 2', '2019-08-15', '2020-02-28', false);
|
How many Green Building projects were completed in the last 12 months?
|
SELECT COUNT(*) as green_building_projects_completed FROM project WHERE is_green = true AND end_date >= DATE_SUB(CURDATE(), INTERVAL 12 MONTH);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Feedback (Area TEXT, Service TEXT, Score INTEGER); INSERT INTO Feedback (Area, Service, Score) VALUES ('Rural', 'Education', 80), ('Rural', 'Healthcare', 75), ('Urban', 'Education', 85), ('Urban', 'Healthcare', 82);
|
What is the average citizen feedback score for public services in rural areas?
|
SELECT AVG(Score) FROM Feedback WHERE Area = 'Rural';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Visitors (VisitorID INT, Age INT, Gender VARCHAR(20));CREATE TABLE Events (EventID INT, EventName VARCHAR(20), EventCategory VARCHAR(20));CREATE TABLE VisitorAttendance (VisitorID INT, EventID INT);
|
How many unique visitors who identify as 'Non-binary' have attended events in the 'Film' category, and what is their average age?
|
SELECT AVG(V.Age) AS Avg_Age, COUNT(DISTINCT VA.VisitorID) AS Num_Unique_Visitors FROM Visitors V INNER JOIN VisitorAttendance VA ON V.VisitorID = VA.VisitorID INNER JOIN Events E ON VA.EventID = E.EventID WHERE V.Gender = 'Non-binary' AND E.EventCategory = 'Film';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE VirtualTours (id INT, country VARCHAR(20), energy INT); INSERT INTO VirtualTours (id, country, energy) VALUES (1, 'Portugal', 50), (2, 'Spain', 60);
|
What is the average energy consumption per virtual tour in Portugal?
|
SELECT AVG(energy) FROM VirtualTours WHERE country = 'Portugal';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE solar_energy_projects (project_id INT, state VARCHAR(20), year INT, investment FLOAT);
|
What was the total investment (in USD) in solar energy projects in New York in 2021?
|
SELECT SUM(investment) FROM solar_energy_projects WHERE state = 'New York' AND year = 2021;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Advocacy(advocacy_id INT, region TEXT);CREATE TABLE Policy_Advocacy(policy_id INT, advocacy_id INT);
|
How many policy advocacy events were held in each region?
|
SELECT a.region, COUNT(pa.policy_id) FROM Advocacy a INNER JOIN Policy_Advocacy pa ON a.advocacy_id = pa.advocacy_id GROUP BY a.region;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE orgs (id INT, name TEXT, contact_name TEXT, contact_email TEXT, contact_phone TEXT, type TEXT); INSERT INTO orgs (id, name, contact_name, contact_email, contact_phone, type) VALUES (1, 'Seeds of Hope', 'John Doe', 'johndoe@seedsofhope.org', '555-555-5555', 'Food Justice'); INSERT INTO orgs (id, name, contact_name, contact_email, contact_phone, type) VALUES (2, 'Harvest Together', 'Jane Smith', 'janesmith@harvesttogether.org', '555-555-5556', 'Food Justice');
|
List all food justice organizations and their respective contact information.
|
SELECT name, contact_name, contact_email, contact_phone FROM orgs WHERE type = 'Food Justice';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE contract (id INT, company VARCHAR(255), value FLOAT, year INT, quarter INT); INSERT INTO contract (id, company, value, year, quarter) VALUES (1, 'General Dynamics', 20000000, 2020, 3);
|
What is the total value of defense contracts awarded to General Dynamics in Q3 2020?
|
SELECT SUM(value) FROM contract WHERE company = 'General Dynamics' AND year = 2020 AND quarter = 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Products (productID int, productName varchar(255), circularSupplyChain varchar(5)); INSERT INTO Products VALUES (1, 'ProductA', 'Y'); CREATE TABLE Sales (saleID int, productID int, quantity int, date datetime); INSERT INTO Sales VALUES (1, 1, 50, '2021-01-01');
|
Find the top 5 most sold products in the circular supply chain in 2021.
|
SELECT P.productName, SUM(S.quantity) as total_sold FROM Products P INNER JOIN Sales S ON P.productID = S.productID WHERE P.circularSupplyChain = 'Y' AND YEAR(S.date) = 2021 GROUP BY P.productID ORDER BY total_sold DESC LIMIT 5;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE socially_responsible_loans(client_id INT, country VARCHAR(25));INSERT INTO socially_responsible_loans(client_id, country) VALUES (1, 'Malaysia'), (2, 'UAE'), (3, 'Indonesia'), (4, 'Saudi Arabia'), (1, 'Malaysia'), (2, 'UAE'), (7, 'Indonesia'), (8, 'Saudi Arabia'), (1, 'Malaysia'), (2, 'UAE');
|
Find the clients who have taken out the most socially responsible loans.
|
SELECT client_id, COUNT(*) as num_loans FROM socially_responsible_loans GROUP BY client_id ORDER BY num_loans DESC;
|
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.