context
stringlengths 11
9.12k
| question
stringlengths 0
1.06k
| SQL
stringlengths 2
4.44k
| source
stringclasses 28
values |
|---|---|---|---|
CREATE TABLE Product_Revenue (product_id INT, revenue INT); INSERT INTO Product_Revenue (product_id, revenue) VALUES (1, 100), (2, 150), (3, 200), (4, 50), (5, 300);
|
What is the total revenue of products sold in each state?
|
SELECT S.state_name, SUM(Revenue) FROM Sales S JOIN Product_Revenue PR ON S.product_id = PR.product_id GROUP BY S.state_name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE timber_production (id INT PRIMARY KEY, state TEXT, annual_production INT); INSERT INTO timber_production (id, state, annual_production) VALUES (1, 'Oregon', 900);
|
Update the timber_production table to set the annual_production to 1000 for 'Oregon'
|
UPDATE timber_production SET annual_production = 1000 WHERE state = 'Oregon';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Studios (studio_id INT, studio_name VARCHAR(255), country VARCHAR(255)); INSERT INTO Studios (studio_id, studio_name, country) VALUES (1, 'Studio A', 'USA'), (2, 'Studio B', 'USA'), (3, 'Studio C', 'Canada'); CREATE TABLE Movies (movie_id INT, movie_name VARCHAR(255), studio_id INT, rating DECIMAL(3,2)); INSERT INTO Movies (movie_id, movie_name, studio_id, rating) VALUES (1, 'Movie X', 1, 8.5), (2, 'Movie Y', 1, 8.2), (3, 'Movie Z', 2, 7.8), (4, 'Movie W', 3, 6.9);
|
What's the average rating of movies produced by studios located in the US?
|
SELECT AVG(m.rating) FROM Movies m JOIN Studios s ON m.studio_id = s.studio_id WHERE s.country = 'USA';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE subscribers (id INT, region VARCHAR(10), monthly_data_usage DECIMAL(5,2)); INSERT INTO subscribers (id, region, monthly_data_usage) VALUES (1, 'urban', 3.5), (2, 'rural', 2.2);
|
What is the average monthly mobile data usage for customers in the 'urban' region?
|
SELECT AVG(monthly_data_usage) FROM subscribers WHERE region = 'urban';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE skincare_products (product_id INT, name VARCHAR(255), launch_year INT, is_cruelty_free BOOLEAN, rating DECIMAL(2,1));
|
What is the average rating of cruelty-free skincare products launched in 2021?
|
SELECT AVG(rating) FROM skincare_products WHERE is_cruelty_free = TRUE AND launch_year = 2021;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE company (id INT, name TEXT, founder_id INT); INSERT INTO company (id, name, founder_id) VALUES (1, 'Acme Inc', 101), (2, 'Beta Corp', 102), (3, 'Gamma PLC', 103); CREATE TABLE investment (id INT, company_id INT); INSERT INTO investment (id, company_id) VALUES (1, 1), (2, 1), (3, 2);
|
Identify the number of unique founders who have founded companies that have had at least one investment round.
|
SELECT COUNT(DISTINCT founder_id) FROM company WHERE id IN (SELECT company_id FROM investment)
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE recycling_rates (region VARCHAR(50), year INT, recycling_rate FLOAT); INSERT INTO recycling_rates (region, year, recycling_rate) VALUES ('Cairo', 2020, 45.67);
|
What was the recycling rate in percentage for the region 'Cairo' in 2020?
|
SELECT recycling_rate FROM recycling_rates WHERE region = 'Cairo' AND year = 2020;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Events (event_id INT, event_date DATE, art_form VARCHAR(50)); INSERT INTO Events (event_id, event_date, art_form) VALUES (1, '2021-01-01', 'Dance'), (2, '2021-02-01', 'Theater'), (3, '2021-03-01', 'Music'), (4, '2021-04-01', 'Art'), (5, '2021-05-01', 'Dance'), (6, '2021-06-01', 'Theater'), (7, '2021-07-01', 'Music'), (8, '2021-08-01', 'Art');
|
How many events were held for each art form in 2021?
|
SELECT art_form, COUNT(*) AS event_count FROM Events WHERE event_date BETWEEN '2021-01-01' AND '2021-12-31' GROUP BY art_form;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE OutdoorWorkouts (UserID INT, Distance FLOAT, WorkoutLocation VARCHAR(20)); INSERT INTO OutdoorWorkouts (UserID, Distance, WorkoutLocation) VALUES (1, 4.2, 'Park'), (1, 3.5, 'Street'), (2, 5.1, 'Trail'), (3, 6.0, 'Beach');
|
Calculate the total distance covered in miles by users in outdoor workouts.
|
SELECT SUM(Distance) FROM OutdoorWorkouts WHERE WorkoutLocation IN ('Park', 'Street', 'Trail', 'Beach');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE student_mental_health (student_id INT, district_id INT, mental_health_score INT, date DATE); CREATE TABLE districts (district_id INT, district_name VARCHAR(100));
|
What is the most common mental health score in each district?
|
SELECT d.district_name, mental_health_score as most_common_score FROM districts d JOIN (SELECT district_id, mental_health_score, COUNT(*) as count FROM student_mental_health GROUP BY district_id, mental_health_score) smh ON d.district_id = smh.district_id WHERE smh.count = (SELECT MAX(count) FROM (SELECT district_id, mental_health_score, COUNT(*) as count FROM student_mental_health GROUP BY district_id, mental_health_score) smh2 WHERE smh2.district_id = smh.district_id);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Aircraft (aircraft_id INT, model VARCHAR(50), passengers INT); INSERT INTO Aircraft (aircraft_id, model, passengers) VALUES (1, 'B747', 416), (2, 'A380', 525), (3, 'B777', 396);
|
What is the maximum number of passengers an aircraft can carry?
|
SELECT MAX(passengers) FROM Aircraft;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE community_projects (id INT, name VARCHAR(100), budget INT, country VARCHAR(50)); INSERT INTO community_projects (id, name, budget, country) VALUES (1, 'Projeto X', 50000, 'Brazil');
|
Which community projects in Brazil have the highest budget?
|
SELECT name, budget FROM community_projects WHERE country = 'Brazil' AND budget = (SELECT MAX(budget) FROM community_projects WHERE country = 'Brazil')
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE division_info (team VARCHAR(255), division VARCHAR(255)); INSERT INTO division_info (team, division) VALUES ('TeamC', 'Northern Division'), ('TeamD', 'Southern Division');
|
Show the number of athletes from each team in the 'Northern Division'
|
SELECT a.team, COUNT(a.athlete_id) FROM athlete_stats a INNER JOIN division_info d ON a.team = d.team WHERE d.division = 'Northern Division' GROUP BY a.team;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Permits_NY (permit_id INT, permit_date DATE); INSERT INTO Permits_NY (permit_id, permit_date) VALUES (1, '2020-01-01'), (2, '2020-02-01'), (3, '2022-03-01');
|
How many building permits were issued per month in New York between 2020 and 2022?
|
SELECT permit_date, COUNT(*) OVER (PARTITION BY EXTRACT(YEAR FROM permit_date)) AS permits_per_year FROM Permits_NY WHERE permit_date >= '2020-01-01' AND permit_date < '2023-01-01' ORDER BY permit_date;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE soil_moisture (moisture DECIMAL(3,1), reading_date DATE, location TEXT); INSERT INTO soil_moisture (moisture, reading_date, location) VALUES (42.5, '2021-07-01', 'India'), (45.3, '2021-07-02', 'India'), (39.2, '2021-04-01', 'India');
|
What is the minimum soil moisture (%) in corn fields in India in the past month?
|
SELECT MIN(moisture) FROM soil_moisture WHERE location = 'India' AND reading_date > DATE_SUB(CURDATE(), INTERVAL 1 MONTH) AND location LIKE '%corn%';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Events (id INT, city VARCHAR(20), country VARCHAR(20), price DECIMAL(5,2)); INSERT INTO Events (id, city, country, price) VALUES (1, 'Paris', 'France', 25.50), (2, 'London', 'UK', 30.00);
|
What is the average ticket price for events in Paris, France?
|
SELECT AVG(price) FROM Events WHERE city = 'Paris' AND country = 'France';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE if not exists EVSales (Id int, Vehicle varchar(100), City varchar(100), Country varchar(50), Quantity int); INSERT INTO EVSales (Id, Vehicle, City, Country, Quantity) VALUES (1, 'Tesla Model 3', 'Tokyo', 'Japan', 1000), (2, 'Nissan Leaf', 'Yokohama', 'Japan', 800), (3, 'Mitsubishi i-MiEV', 'Osaka', 'Japan', 1200), (4, 'Toyota Prius', 'Nagoya', 'Japan', 600), (5, 'Honda Fit', 'Sapporo', 'Japan', 900), (6, 'Audi e-Tron', 'Berlin', 'Germany', 700), (7, 'Renault Zoe', 'Paris', 'France', 1100), (8, 'BYD e6', 'Beijing', 'China', 1500), (9, 'Ford Mustang Mach-E', 'New York', 'USA', 1300), (10, 'Volvo XC40 Recharge', 'Stockholm', 'Sweden', 800);
|
What is the total number of electric vehicles sold in the world?
|
SELECT SUM(Quantity) FROM EVSales WHERE Country != '';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE subscribers (subscriber_id INT, name VARCHAR(50)); INSERT INTO subscribers (subscriber_id, name) VALUES (1, 'John Doe'), (2, 'Jane Smith'), (3, 'Bob Johnson'), (5, 'Alice Davis'); CREATE TABLE international_calls (call_id INT, subscriber_id INT, call_duration INT, call_charge DECIMAL(10,2)); INSERT INTO international_calls (call_id, subscriber_id, call_duration, call_charge) VALUES (1, 5, 30, 1.25), (2, 5, 45, 1.85), (3, 2, 20, 1.10);
|
List all the international calls made by a subscriber with the subscriber_id of 5 and the call duration, along with the international call charges.
|
SELECT i.subscriber_id, i.call_duration, i.call_charge FROM subscribers s JOIN international_calls i ON s.subscriber_id = i.subscriber_id WHERE s.subscriber_id = 5;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Region (id INT, name VARCHAR(255)); INSERT INTO Region (id, name) VALUES (1, 'Amazonia'), (2, 'Central America'), (3, 'Andes'); CREATE TABLE Crop (id INT, name VARCHAR(255), region_id INT); INSERT INTO Crop (id, name, region_id) VALUES (1, 'Yuca', 1), (2, 'Corn', 2), (3, 'Potato', 3), (4, 'Quinoa', 3);
|
Which indigenous food systems have the highest crop diversity?
|
SELECT Region.name, COUNT(DISTINCT Crop.name) FROM Region INNER JOIN Crop ON Region.id = Crop.region_id GROUP BY Region.name ORDER BY COUNT(DISTINCT Crop.name) DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE well_production (well_id INT, company VARCHAR(255), basin VARCHAR(255), daily_production INT); INSERT INTO well_production (well_id, company, basin, daily_production) VALUES (1, 'Chevron', 'Marcellus Shale', 100); INSERT INTO well_production (well_id, company, basin, daily_production) VALUES (2, 'Chevron', 'Marcellus Shale', 120); INSERT INTO well_production (well_id, company, basin, daily_production) VALUES (3, 'Chevron', 'Bakken Formation', 150);
|
What is the average daily production of oil from wells owned by Chevron in the Marcellus Shale?
|
SELECT AVG(daily_production) FROM well_production WHERE company = 'Chevron' AND basin = 'Marcellus Shale';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE donations (id INT, donor VARCHAR(50), amount DECIMAL(10,2), donation_date DATE, year INT); INSERT INTO donations (id, donor, amount, donation_date, year) VALUES (1, 'Sophia Lee', 250, '2022-02-14', 2022); INSERT INTO donations (id, donor, amount, donation_date, year) VALUES (2, 'Ali Al-Khaleej', 400, '2022-07-03', 2022); INSERT INTO donations (id, donor, amount, donation_date, year) VALUES (3, 'Sophia Lee', 200, '2021-02-14', 2021); INSERT INTO donations (id, donor, amount, donation_date, year) VALUES (4, 'Ali Al-Khaleej', 300, '2021-07-03', 2021);
|
What is the number of donors who increased their donation amount from 2021 to 2022?
|
SELECT COUNT(DISTINCT donor) as increased_donor_count FROM donations d1 INNER JOIN donations d2 ON d1.donor = d2.donor WHERE d1.year = 2022 AND d2.year = 2021 AND d1.amount > d2.amount;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE urban_community_farms AS SELECT f.name AS farmer_name, c.crop_name, c.acres FROM farmers f JOIN crops c ON f.id = c.farmer_id JOIN farm_communities fr ON f.id = fr.farm_id WHERE fr.community = 'urban'; INSERT INTO urban_community_farms (farmer_name, crop_name, acres) VALUES ('Jane', 'maize', 50), ('Alice', 'carrot', 75), ('Bob', 'soybean', 100), ('Jane', 'carrot', 25);
|
Identify the top three crops by acreage in 'urban' farming communities.
|
SELECT crop_name, SUM(acres) AS total_acres FROM urban_community_farms GROUP BY crop_name ORDER BY total_acres DESC LIMIT 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE mines (id INT, name TEXT, location TEXT, total_employees INT); INSERT INTO mines (id, name, location, total_employees) VALUES (1, 'Golden Mine', 'Colorado, USA', 300), (2, 'Silver Ridge', 'Nevada, USA', 400), (3, 'Bronze Basin', 'Utah, USA', 500);
|
What is the total number of employees in each mine?
|
SELECT name, SUM(total_employees) FROM mines GROUP BY name
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE CircularEconomy(id INT, initiative VARCHAR(50), region VARCHAR(50)); INSERT INTO CircularEconomy(id, initiative, region) VALUES (1, 'Clothing Swap Events', 'France'), (2, 'Repair Cafes', 'Germany'), (3, 'E-Waste Recycling Programs', 'Spain');
|
Which circular economy initiatives have been implemented in Europe?
|
SELECT initiative, region FROM CircularEconomy WHERE region = 'Europe';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE mines (id INT, name TEXT, location TEXT, quarter INT, annual_production INT); INSERT INTO mines (id, name, location, quarter, annual_production) VALUES (1, 'Mine A', 'Country X', 1, 375), (2, 'Mine B', 'Country Y', 1, 500), (3, 'Mine C', 'Country Z', 1, 437), (1, 'Mine A', 'Country X', 2, 400), (2, 'Mine B', 'Country Y', 2, 500), (3, 'Mine C', 'Country Z', 2, 437), (1, 'Mine A', 'Country X', 3, 425), (2, 'Mine B', 'Country Y', 3, 500), (3, 'Mine C', 'Country Z', 3, 462), (1, 'Mine A', 'Country X', 4, 375), (2, 'Mine B', 'Country Y', 4, 500), (3, 'Mine C', 'Country Z', 4, 463);
|
What was the total REE production for each quarter in 2020?
|
SELECT YEAR(timestamp) as year, QUARTER(timestamp) as quarter, SUM(annual_production) as total_production FROM mines WHERE YEAR(timestamp) = 2020 GROUP BY year, quarter;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE products (product_id INT, name VARCHAR(255), category VARCHAR(255), price DECIMAL(5,2));
|
Insert a new product into the "products" table
|
INSERT INTO products (product_id, name, category, price) VALUES (1001, 'Organic Cotton Shirt', 'Clothing', 35.99);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE gas_wells (well_id INT, state VARCHAR(10), daily_production FLOAT); INSERT INTO gas_wells (well_id, state, daily_production) VALUES (1, 'North Dakota', 120.5), (2, 'North Dakota', 130.2), (3, 'Montana', 105.6);
|
Count the number of gas wells in North Dakota and Montana and their total daily production
|
SELECT state, COUNT(*), SUM(daily_production) FROM gas_wells WHERE state IN ('North Dakota', 'Montana') GROUP BY state;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE donors (donor_id INT, donation_date DATE, donation_amount DECIMAL(10, 2)); INSERT INTO donors VALUES (8, '2022-09-01', 100.00), (9, '2022-10-15', 200.00), (10, '2022-11-05', 300.00);
|
What was the average donation amount per donor in Q3 2022?
|
SELECT AVG(donation_amount) FROM donors WHERE donation_date BETWEEN '2022-07-01' AND '2022-09-30' GROUP BY donor_id HAVING COUNT(*) > 0;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE military_vehicles (id INT, model VARCHAR(50), maintenance_cost FLOAT); INSERT INTO military_vehicles (id, model, maintenance_cost) VALUES (1, 'HMMWV', 12000), (2, 'Stryker', 18000), (3, 'Tank', 25000);
|
What is the minimum maintenance cost for military vehicles?
|
SELECT MIN(maintenance_cost) FROM military_vehicles;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE companies (company_id INT, company_name TEXT, industry TEXT, founding_year INT, founder_race TEXT); INSERT INTO companies (company_id, company_name, industry, founding_year, founder_race) VALUES (1, 'SolarForce', 'Renewable Energy', 2015, 'Black'); CREATE TABLE funding_records (funding_id INT, company_id INT, amount INT); INSERT INTO funding_records (funding_id, company_id, amount) VALUES (1, 1, 1200000);
|
What is the total funding received by companies founded by Black entrepreneurs in the renewable energy sector?
|
SELECT SUM(fr.amount) FROM companies c JOIN funding_records fr ON c.company_id = fr.company_id WHERE c.industry = 'Renewable Energy' AND c.founder_race = 'Black';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE if not exists oceanographic_studies (id INT, name TEXT, location TEXT, year INT);
|
List all oceanographic studies in 'Atlantic Ocean' since 2010.
|
SELECT * FROM oceanographic_studies WHERE location = 'Atlantic Ocean' AND year >= 2010;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE cargo_tracking ( voyage_date DATE, departure_port VARCHAR(255), destination_port VARCHAR(255), cargo_weight INT, vessel_name VARCHAR(255), status VARCHAR(255));
|
Update the cargo_tracking table and set the status as 'Delivered' for records where the destination_port is 'Tokyo'
|
UPDATE cargo_tracking SET status = 'Delivered' WHERE destination_port = 'Tokyo';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE sustainable_buildings (city VARCHAR(255), total_sqft INTEGER, sustainable BOOLEAN); INSERT INTO sustainable_buildings (city, total_sqft, sustainable) VALUES ('New York City', 5000000, true), ('New York City', 3000000, false), ('Los Angeles', 4000000, true);
|
What is the total square footage of sustainable buildings in New York City?
|
SELECT SUM(total_sqft) FROM sustainable_buildings WHERE city = 'New York City' AND sustainable = true;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Users (UserID INT, Age INT, Category VARCHAR(50)); INSERT INTO Users (UserID, Age, Category) VALUES (1, 30, 'Dance'), (2, 25, 'Music'); CREATE TABLE Events (EventID INT, Category VARCHAR(50)); INSERT INTO Events (EventID, Category) VALUES (1, 'Dance'), (2, 'Music');
|
What is the average age of users who attended events in the "Dance" category?
|
SELECT AVG(Users.Age) AS AverageAge FROM Users INNER JOIN Events ON Users.Category = Events.Category WHERE Events.Category = 'Dance';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE factories (id INT, name VARCHAR(255), workers INT, living_wage_workers INT); INSERT INTO factories (id, name, workers, living_wage_workers) VALUES (1, 'EthicalFactory1', 500, 450), (2, 'EthicalFactory2', 300, 280), (3, 'EthicalFactory3', 400, 360), (4, 'EthicalFactory4', 600, 540), (5, 'EthicalFactory5', 700, 630);
|
How many workers in each factory are not paid a living wage?
|
SELECT name, (workers - living_wage_workers) AS non_living_wage_workers FROM factories;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Donations (donor_id INT, donation_amount DECIMAL(10,2), donation_date DATE);
|
Insert a new donation record for donor 5 with a donation amount of 800 on 2021-05-01.
|
INSERT INTO Donations (donor_id, donation_amount, donation_date) VALUES (5, 800, '2021-05-01');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE pollution_control_initiatives (id INT, initiative TEXT, region TEXT); INSERT INTO pollution_control_initiatives (id, initiative, region) VALUES (1, 'Initiative X', 'North Atlantic'), (2, 'Initiative Y', 'Arctic'), (3, 'Initiative Z', 'North Atlantic'), (4, 'Initiative W', 'Indian Ocean');
|
How many pollution control initiatives are there in each region?
|
SELECT region, COUNT(*) FROM pollution_control_initiatives GROUP BY region;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Dishes (id INT, cuisine VARCHAR(255), serving_size INT); INSERT INTO Dishes (id, cuisine, serving_size) VALUES (1, 'Vegan', 300), (2, 'Vegan', 450), (3, 'Vegan', 200), (4, 'Italian', 500);
|
What is the maximum and minimum serving size for dishes in the 'Vegan' cuisine category?
|
SELECT cuisine, MIN(serving_size) as min_serving_size, MAX(serving_size) as max_serving_size FROM Dishes WHERE cuisine = 'Vegan' GROUP BY cuisine;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE defense_diplomacy (country VARCHAR(50), event_date DATE);
|
Find the number of defense diplomacy events where 'country A' was involved in the last 3 years
|
SELECT COUNT(*) FROM defense_diplomacy WHERE country = 'country A' AND event_date >= DATE(CURRENT_DATE) - INTERVAL 3 YEAR;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE cases (case_id INT, billing_amount INT); INSERT INTO cases (case_id, billing_amount) VALUES (1, 5000), (2, 0), (3, 4000);
|
Delete all cases with a billing amount of $0.
|
DELETE FROM cases WHERE billing_amount = 0;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE departments (dept_id INT, dept_name TEXT); INSERT INTO departments (dept_id, dept_name) VALUES (1, 'HR'), (2, 'IT'), (3, 'Sales'); CREATE TABLE employees (employee_id INT, name TEXT, dept_id INT, diversity_inclusion_training BOOLEAN); INSERT INTO employees (employee_id, name, dept_id, diversity_inclusion_training) VALUES (1, 'Alice', 1, TRUE), (2, 'Bob', 2, FALSE), (3, 'Charlie', 1, TRUE), (4, 'Dave', 2, TRUE), (5, 'Eve', 1, FALSE);
|
What is the number of employees who have completed diversity and inclusion training, by department?
|
SELECT dept_name, SUM(CASE WHEN diversity_inclusion_training THEN 1 ELSE 0 END) AS num_trained FROM employees JOIN departments ON employees.dept_id = departments.dept_id GROUP BY dept_name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE media (id INT, title TEXT, type TEXT, runtime INT);
|
What is the total runtime (in minutes) of all the movies and TV shows in the media table?
|
SELECT SUM(runtime) FROM media WHERE type = 'movie' UNION SELECT SUM(runtime) FROM media WHERE type = 'tv_show';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Donors (DonorID INT, DonorName TEXT, DonorRegion TEXT, DonationAmount FLOAT, DonationDate DATE); INSERT INTO Donors (DonorID, DonorName, DonorRegion, DonationAmount, DonationDate) VALUES (1, 'John Doe', 'North', 500.00, '2021-01-01'), (2, 'Jane Smith', 'South', 350.00, '2021-02-14'), (3, 'Bob Johnson', 'East', 1000.00, '2021-12-31'), (4, 'Alice Williams', 'North', 200.00, '2021-03-15');
|
How many unique donors made donations in each region in 2021, and what was the total donation amount per region for the year?
|
SELECT DonorRegion, COUNT(DISTINCT DonorID) as UniqueDonors, SUM(DonationAmount) as TotalDonationPerYear FROM Donors WHERE YEAR(DonationDate) = 2021 GROUP BY DonorRegion;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE peacekeeping_operations (id INT, operation_name VARCHAR(255), lead_organization VARCHAR(255), start_date DATE); INSERT INTO peacekeeping_operations (id, operation_name, lead_organization, start_date) VALUES (1, 'AMISOM', 'African Union', '2007-01-19'), (2, 'MINUSMA', 'United Nations', '2013-07-25');
|
Identify the peacekeeping operations where the African Union is the lead organization
|
SELECT * FROM peacekeeping_operations WHERE lead_organization = 'African Union';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Employees (employee_id INT, name VARCHAR(50), gender VARCHAR(10), department VARCHAR(20), hire_date DATE); INSERT INTO Employees (employee_id, name, gender, department, hire_date) VALUES (1, 'John Doe', 'Male', 'Mining', '2020-01-01'), (2, 'Jane Smith', 'Female', 'Mining', '2019-06-15');
|
Insert new records for 5 employees who joined the mining department in January 2022.
|
INSERT INTO Employees (employee_id, name, gender, department, hire_date) VALUES (4, 'Bruce Wayne', 'Male', 'Mining', '2022-01-05'), (5, 'Clark Kent', 'Male', 'Mining', '2022-01-10'), (6, 'Diana Prince', 'Female', 'Mining', '2022-01-12'), (7, 'Peter Parker', 'Male', 'Mining', '2022-01-15'), (8, 'Natasha Romanoff', 'Female', 'Mining', '2022-01-20');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE green_vehicles (id INT PRIMARY KEY, make VARCHAR(50), model VARCHAR(50), year INT, type VARCHAR(50), range INT);
|
Calculate the average range of vehicles grouped by type in the 'green_vehicles' table
|
SELECT type, AVG(range) FROM green_vehicles GROUP BY type;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE arctic_ocean (id INT, well_name VARCHAR(255), drill_date DATE, daily_production_oil FLOAT);
|
What is the maximum daily production rate of oil wells in the Arctic Ocean that were drilled after 2016?
|
SELECT MAX(daily_production_oil) as max_daily_production_oil FROM arctic_ocean WHERE drill_date > '2016-12-31';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE environmental_impact ( id INT PRIMARY KEY, element VARCHAR(10), impact_score INT );
|
Insert new records for the rare earth elements promethium and samarium into the environmental_impact table
|
INSERT INTO environmental_impact (element, impact_score) VALUES ('promethium', 7), ('samarium', 6);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE models (id INT, dataset VARCHAR(20), performance FLOAT, region VARCHAR(20)); INSERT INTO models VALUES (1, 'datasetA', 4.3, 'Europe'), (2, 'datasetA', 4.5, 'Asia'), (3, 'datasetB', 3.9, 'Africa'), (4, 'datasetB', 4.1, 'Africa'), (5, 'datasetA', 4.2, 'North America');
|
What is the difference between the maximum performance score of models trained on dataset A and dataset B, for each region?
|
SELECT region, MAX(m.performance) - (SELECT MAX(performance) FROM models m2 WHERE m.region = m2.region AND m2.dataset = 'datasetB') FROM models m WHERE m.dataset = 'datasetA' GROUP BY region;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE city (id INT, name VARCHAR(255)); INSERT INTO city (id, name) VALUES (1, 'Austin'); CREATE TABLE water_meter_readings (id INT, city_id INT, consumption FLOAT, reading_date DATE); INSERT INTO water_meter_readings (id, city_id, consumption, reading_date) VALUES (1, 1, 100, '2022-01-01'); INSERT INTO water_meter_readings (id, city_id, consumption, reading_date) VALUES (2, 1, 120, '2022-02-01');
|
Calculate the average monthly water consumption per capita in the city of Austin
|
SELECT AVG(consumption / population) FROM (SELECT water_meter_readings.consumption, city.population, EXTRACT(MONTH FROM water_meter_readings.reading_date) as month FROM water_meter_readings JOIN city ON water_meter_readings.city_id = city.id WHERE city.name = 'Austin') as subquery GROUP BY month;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE well (well_id INT, well_name TEXT, gas_production_2020 FLOAT); INSERT INTO well (well_id, well_name, gas_production_2020) VALUES (1, 'Well A', 9000), (2, 'Well B', 11000), (3, 'Well C', 8000);
|
Delete wells that have gas production less than 5000 in 2020?
|
DELETE FROM well WHERE gas_production_2020 < 5000;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Space_Debris (object_name TEXT, weight FLOAT); INSERT INTO Space_Debris (object_name, weight) VALUES ('FENGYUN 1C', 1000), ('COSMOS 1402', 6000), ('Meteor 1-21', 2000), ('COSMOS 954', 1500), ('TIROS-M', 130);
|
What is the total weight of all space debris?
|
SELECT SUM(weight) as total_debris_weight FROM Space_Debris;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE faculty (id INT, faculty_name TEXT, faculty_gender TEXT, hire_date DATE); INSERT INTO faculty (id, faculty_name, faculty_gender, hire_date) VALUES (1, 'Eliot', 'M', '2018-02-15'); INSERT INTO faculty (id, faculty_name, faculty_gender, hire_date) VALUES (2, 'Fiona', 'F', '2021-03-20');
|
How many female and male faculty members were hired in the last 5 years?
|
SELECT faculty_gender, COUNT(*) FROM faculty WHERE hire_date BETWEEN DATE_SUB(CURRENT_DATE, INTERVAL 5 YEAR) AND CURRENT_DATE GROUP BY faculty_gender
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE crop_health (field_id INT, health_score INT, measurement_timestamp DATETIME);
|
Delete all records from crop_health table where field_id is not in (3, 5, 7)
|
DELETE FROM crop_health WHERE field_id NOT IN (3, 5, 7);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE songs (song_id INT, release_date DATE, song_length FLOAT, genre TEXT); INSERT INTO songs VALUES (1, '2005-07-12', 125.3, 'Rap'), (2, '2010-02-14', 200.2, 'R&B'), (3, '2008-05-23', 100.5, 'Rap'), (4, '2012-12-31', 180.1, 'Hip Hop'), (5, '2011-06-20', 150.0, 'Rap');
|
What is the release date of the shortest Rap song?
|
SELECT release_date FROM songs WHERE genre = 'Rap' AND song_length = (SELECT MIN(song_length) FROM songs WHERE genre = 'Rap');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE rome_bus (route_id INT, num_riders INT, ride_date DATE);
|
What is the average number of riders per day for each bus route in Rome?
|
SELECT route_id, AVG(num_riders) FROM rome_bus GROUP BY route_id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Sustainable_Material_Garments (id INT, production_date DATE, quantity INT);
|
What is the total quantity of garments produced using sustainable materials in the last 6 months?
|
SELECT SUM(quantity) FROM Sustainable_Material_Garments WHERE production_date >= DATEADD(month, -6, GETDATE());
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ElectricVehicles (id INT, company VARCHAR(20), vehicle_type VARCHAR(20), num_vehicles INT); INSERT INTO ElectricVehicles (id, company, vehicle_type, num_vehicles) VALUES (1, 'Tesla', 'EV', 1500000), (2, 'Nissan', 'Leaf', 500000), (3, 'Chevrolet', 'Bolt', 300000), (6, 'Rivian', 'EV', 2000), (7, 'Lucid', 'EV', 5000);
|
Find the company with the most electric vehicles in the ElectricVehicles table.
|
SELECT company FROM ElectricVehicles WHERE num_vehicles = (SELECT MAX(num_vehicles) FROM ElectricVehicles);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Donations (DonationID INT, DonorID INT, DonationAmount FLOAT, DonationDate DATE, OrganizationType TEXT); INSERT INTO Donations (DonationID, DonorID, DonationAmount, DonationDate, OrganizationType) VALUES (1, 1, 500.00, '2022-01-01', 'Non-profit'), (2, 2, 350.00, '2022-02-14', 'Corporation'), (3, 3, 1000.00, '2022-12-31', 'Individual');
|
What was the total amount donated by each organization type in 2022?
|
SELECT OrganizationType, SUM(DonationAmount) as TotalDonation FROM Donations WHERE YEAR(DonationDate) = 2022 GROUP BY OrganizationType;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE org_info (org_name VARCHAR(50), location VARCHAR(50)); INSERT INTO org_info (org_name, location) VALUES ('XYZ Foundation', 'New York');
|
List all the organizations in 'org_info' table located in 'New York'?
|
SELECT org_name FROM org_info WHERE location = 'New York';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE cybersecurity_incidents (id INT, incident_date DATE, incident_type VARCHAR(255)); INSERT INTO cybersecurity_incidents (id, incident_date, incident_type) VALUES (1, '2021-01-05', 'Data Breach'), (2, '2021-03-18', 'Phishing');
|
What is the total number of cybersecurity incidents reported in Q1 of 2021?
|
SELECT COUNT(*) FROM cybersecurity_incidents WHERE incident_date BETWEEN '2021-01-01' AND '2021-03-31';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE menu_items (item_id INT, item_name TEXT, category TEXT, price DECIMAL(5,2)); INSERT INTO menu_items (item_id, item_name, category, price) VALUES (1, 'Burger', 'entrees', 9.99), (2, 'Fries', 'side_dishes', 2.50), (3, 'Salad', 'appetizers', 4.50), (4, 'Fries', 'side_dishes', 3.50);
|
Get the total revenue of menu items in the 'side_dishes' category
|
SELECT SUM(price) FROM menu_items WHERE category = 'side_dishes';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE research_grants (id INT, student_id INT, year INT, amount DECIMAL(10, 2), country VARCHAR(50)); INSERT INTO research_grants VALUES (1, 1, 2021, 10000, 'USA'); INSERT INTO research_grants VALUES (2, 2, 2020, 12000, 'Canada'); INSERT INTO research_grants VALUES (3, 3, 2021, 15000, 'Mexico');
|
What is the total amount of research grants awarded by country?
|
SELECT r.country, SUM(r.amount) FROM research_grants r GROUP BY r.country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE animal_species (species_id INT, species_name VARCHAR(255)); INSERT INTO animal_species (species_id, species_name) VALUES (1, 'Tiger'), (2, 'Lion'), (3, 'Elephant');
|
Which animal species have never been admitted to the rehabilitation center?
|
SELECT species_name FROM animal_species WHERE species_id NOT IN (SELECT animal_id FROM rehabilitation_center);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE game_sales (id INT, year INT, platform VARCHAR(20), revenue INT); INSERT INTO game_sales (id, year, platform, revenue) VALUES (1, 2022, 'mobile', 5000000), (2, 2021, 'pc', 4000000), (3, 2022, 'console', 3000000), (4, 2021, 'mobile', 6000000), (5, 2022, 'pc', 7000000), (6, 2021, 'console', 2000000);
|
What is the total revenue generated by mobile games in 2022?
|
SELECT SUM(revenue) FROM game_sales WHERE year = 2022 AND platform = 'mobile';
|
gretelai_synthetic_text_to_sql
|
CREATE SCHEMA if not exists engineering; CREATE TABLE if not exists engineering.jobs( job_id INT PRIMARY KEY, title VARCHAR(100), location VARCHAR(50), salary DECIMAL(10,2)); INSERT INTO engineering.jobs (job_id, title, location, salary) VALUES (1, 'Bioprocess Engineer', 'Germany', 80000); INSERT INTO engineering.jobs (job_id, title, location, salary) VALUES (2, 'Mechanical Engineer', 'Germany', 70000);
|
How many bioprocess engineering jobs are available in Germany?
|
SELECT COUNT(*) FROM engineering.jobs WHERE title = 'Bioprocess Engineer' AND location = 'Germany';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE carbon_offsets ( id INT PRIMARY KEY, sector VARCHAR(255), amount_offset INT ); INSERT INTO carbon_offsets (id, sector, amount_offset) VALUES (1, 'Transportation', 350000); INSERT INTO carbon_offsets (id, sector, amount_offset) VALUES (2, 'Energy', 200000);
|
Show the total carbon offsets in each sector, excluding sectors with no carbon offsets
|
SELECT sector, SUM(amount_offset) FROM carbon_offsets WHERE amount_offset IS NOT NULL GROUP BY sector;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Events (id INT, name TEXT, location TEXT); CREATE TABLE Visitors_Events (visitor_id INT, event_id INT); INSERT INTO Events (id, name, location) VALUES (1, 'Dance Performance', 'New York'), (2, 'Film Festival', 'London'); INSERT INTO Visitors_Events (visitor_id, event_id) VALUES (1, 1), (1, 2), (3, 1);
|
Find the number of unique visitors who attended events in 'New York' and 'London'.
|
SELECT COUNT(DISTINCT Visitors_Events.visitor_id) FROM Visitors_Events INNER JOIN Events ON Visitors_Events.event_id = Events.id WHERE Events.location IN ('New York', 'London');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Museums (MuseumID INT, MuseumName VARCHAR(50), Country VARCHAR(50)); CREATE TABLE Attendance (AttendanceID INT, MuseumID INT, Year INT, Visitors INT); INSERT INTO Museums VALUES (1, 'Louvre', 'France'), (2, 'Met', 'USA'), (3, 'British Museum', 'UK'); INSERT INTO Attendance VALUES (1, 1, 2019, 1000000), (2, 1, 2020, 800000), (3, 1, 2021, 900000), (4, 2, 2019, 7000000), (5, 2, 2020, 4000000), (6, 2, 2021, 5000000), (7, 3, 2019, 6000000), (8, 3, 2020, 5000000), (9, 3, 2021, 6500000);
|
Which countries had the highest and lowest museum attendance in the last 3 years?
|
SELECT M.Country, MAX(A.Visitors) AS MaxAttendance, MIN(A.Visitors) AS MinAttendance FROM Museums M INNER JOIN Attendance A ON M.MuseumID = A.MuseumID WHERE A.Year BETWEEN 2019 AND 2021 GROUP BY M.Country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE clients (client_id INT, region VARCHAR(20)); INSERT INTO clients (client_id, region) VALUES (1, 'North America'), (2, 'Asia-Pacific'), (3, 'Europe'); CREATE TABLE assets (asset_id INT, client_id INT, value DECIMAL(10,2)); INSERT INTO assets (asset_id, client_id, value) VALUES (1, 1, 500000.00), (2, 1, 750000.00), (3, 2, 250000.00), (4, 3, 1000000.00);
|
What is the total assets under management (AUM) for clients in the Asia-Pacific region?
|
SELECT SUM(value) AS AUM FROM assets JOIN clients ON assets.client_id = clients.client_id WHERE clients.region = 'Asia-Pacific';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE programs (id INT, name VARCHAR(50), location VARCHAR(50), type VARCHAR(50), start_date DATE, end_date DATE);
|
Unpivot the data to show the total number of programs by type
|
SELECT type, SUM(value) AS Total_Programs FROM (SELECT location, type, 1 AS value FROM programs WHERE start_date <= CURDATE() AND end_date >= CURDATE()) AS subquery GROUP BY type;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE satellite_projects (id INT, country VARCHAR(255), manufacturer VARCHAR(255), project_start_date DATE, project_end_date DATE);
|
What is the trend of satellite deployment projects over the last decade?
|
SELECT YEAR(project_start_date) as year, COUNT(*) as num_projects FROM satellite_projects GROUP BY year ORDER BY year;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE HealthcareFacilities (Name VARCHAR(255), City VARCHAR(255), Specialized BOOLEAN); INSERT INTO HealthcareFacilities (Name, City, Specialized) VALUES ('Facility A', 'City X', TRUE), ('Facility B', 'City X', FALSE), ('Facility C', 'City Y', TRUE);
|
Insert new records for a new healthcare facility 'Facility D' in 'City Y' that offers mental health services.
|
INSERT INTO HealthcareFacilities (Name, City, Specialized) VALUES ('Facility D', 'City Y', TRUE);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE union_names (union_name TEXT); INSERT INTO union_names (union_name) VALUES ('Union A'), ('Union B'), ('Union C'), ('Union D'); CREATE TABLE membership_stats (union_name TEXT, members INTEGER); INSERT INTO membership_stats (union_name, members) VALUES ('Union A', 4000), ('Union B', 2000), ('Union C', 6000), ('Union D', 500); CREATE TABLE cb_agreements (union_name TEXT, expiration_year INTEGER); INSERT INTO cb_agreements (union_name, expiration_year) VALUES ('Union A', 2023), ('Union B', 2025), ('Union C', 2024), ('Union D', 2025), ('Union H', 2022);
|
List union names, their membership statistics, and collective bargaining agreements that will expire before 2023?
|
SELECT union_names.union_name, membership_stats.members, cb_agreements.expiration_year FROM union_names FULL OUTER JOIN membership_stats ON union_names.union_name = membership_stats.union_name FULL OUTER JOIN cb_agreements ON union_names.union_name = cb_agreements.union_name WHERE cb_agreements.expiration_year < 2023;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE builders (id INT, name VARCHAR(50), salary DECIMAL(10, 2), is_union_member BOOLEAN); INSERT INTO builders (id, name, salary, is_union_member) VALUES (1, 'Mia', 80000.00, true), (2, 'Max', 85000.00, true), (3, 'Mel', 90000.00, true);
|
What is the maximum salary for workers in the 'construction_database' database who are members of a union?
|
SELECT MAX(salary) FROM builders WHERE is_union_member = true;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Farm (id INT, farm_name TEXT, species TEXT, weight FLOAT, age INT); INSERT INTO Farm (id, farm_name, species, weight, age) VALUES (1, 'OceanPacific', 'Tilapia', 500.3, 2), (2, 'SeaBreeze', 'Salmon', 300.1, 1), (3, 'OceanPacific', 'Tilapia', 600.5, 3), (4, 'FarmX', 'Salmon', 700.2, 4), (5, 'OceanPacific', 'Salmon', 800.1, 5);
|
Find the average weight of fish, grouped by farm name and species.
|
SELECT farm_name, species, AVG(weight) as avg_weight FROM Farm GROUP BY farm_name, species;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE athletes (id INT, name VARCHAR(50), sport VARCHAR(50), event VARCHAR(50), personal_best FLOAT); INSERT INTO athletes (id, name, sport, event, personal_best) VALUES (1, 'John Doe', 'Athletics', '100m', 9.87), (2, 'Jane Smith', 'Athletics', '100m', 10.12);
|
What is the average distance run by the top 10 fastest sprinters in the 100m dash event?
|
SELECT AVG(personal_best) FROM (SELECT personal_best FROM athletes WHERE sport = 'Athletics' AND event = '100m' ORDER BY personal_best DESC FETCH NEXT 10 ROWS ONLY) AS subquery;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE chocolate_farms (id INT, farm_name TEXT, country TEXT, fair_trade BOOLEAN); INSERT INTO chocolate_farms (id, farm_name, country, fair_trade) VALUES (1, 'Cocoa Paradise', 'Ecuador', true), (2, 'Choco Haven', 'Ghana', true), (3, 'Sweet Earth', 'Peru', false);
|
Which are the top 3 countries with the most fair trade chocolate farms?
|
SELECT country, COUNT(*) FROM chocolate_farms WHERE fair_trade = true GROUP BY country ORDER BY COUNT(*) DESC LIMIT 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ocean_temperatures (id INT, ocean TEXT, min_temp FLOAT); INSERT INTO ocean_temperatures (id, ocean, min_temp) VALUES (1, 'Arctic Ocean', -50.0), (2, 'Atlantic Ocean', 0.0);
|
What is the minimum temperature ever recorded in the Arctic Ocean?
|
SELECT MIN(min_temp) FROM ocean_temperatures WHERE ocean = 'Arctic Ocean';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE sourcing (sourcing_id INT, textile_type VARCHAR(30), quantity INT, region VARCHAR(20)); INSERT INTO sourcing (sourcing_id, textile_type, quantity, region) VALUES (1, 'Organic Cotton', 5000, 'Africa'), (2, 'Tencel', 3000, 'Europe'), (3, 'Bamboo', 4000, 'Asia');
|
What is the total quantity of sustainable textiles sourced from Africa?
|
SELECT SUM(quantity) FROM sourcing WHERE textile_type = 'Organic Cotton' AND region = 'Africa';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE carbon_sequestration (year INT, tree_type VARCHAR(255), region VARCHAR(255), sequestration_rate FLOAT);
|
delete all records from the carbon_sequestration table where the tree_type is 'Spruce'
|
DELETE FROM carbon_sequestration WHERE tree_type = 'Spruce';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE patients (patient_id INT, age INT, gender TEXT, treatment TEXT, state TEXT, condition TEXT); INSERT INTO patients (patient_id, age, gender, treatment, state, condition) VALUES (1, 30, 'Female', 'CBT', 'Texas', 'Anxiety'); INSERT INTO patients (patient_id, age, gender, treatment, state, condition) VALUES (2, 45, 'Male', 'DBT', 'California', 'Depression'); INSERT INTO patients (patient_id, age, gender, treatment, state, condition) VALUES (3, 25, 'Non-binary', 'Therapy', 'Washington', 'Depression');
|
What is the most common treatment approach for patients with depression in Florida?
|
SELECT treatment, COUNT(*) AS count FROM patients WHERE condition = 'Depression' AND state = 'Florida' GROUP BY treatment ORDER BY count DESC LIMIT 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE SustainableFabric (Brand VARCHAR(255), Supplier VARCHAR(255), Quantity INT); INSERT INTO SustainableFabric (Brand, Supplier, Quantity) VALUES ('BrandG', 'SupplierD', 2000), ('BrandH', 'SupplierE', 2500), ('BrandI', 'SupplierF', 3000), ('BrandJ', 'SupplierD', 1500);
|
What is the total quantity of sustainable fabric sourced from Indian suppliers?
|
SELECT SUM(Quantity) FROM SustainableFabric WHERE Supplier IN ('SupplierD', 'SupplierE', 'SupplierF');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE manufacturers (id INT PRIMARY KEY, name VARCHAR(255), country VARCHAR(255), sustainability_score INT);
|
Find the top 5 countries with the highest average sustainability score for their manufacturers, along with the total number of manufacturers.
|
SELECT m.country, AVG(m.sustainability_score) as avg_score, COUNT(*) as total_manufacturers, RANK() OVER (ORDER BY avg_score DESC) as rank FROM manufacturers m GROUP BY m.country HAVING rank <= 5;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Waste (Plant VARCHAR(255), Waste_Amount INT, Waste_Date DATE); INSERT INTO Waste (Plant, Waste_Amount, Waste_Date) VALUES ('PlantA', 500, '2022-01-01'), ('PlantB', 300, '2022-01-02'), ('PlantC', 700, '2022-01-03');
|
Find the total waste produced by each manufacturing plant in the first quarter of 2022, ordered from greatest to least.
|
SELECT Plant, SUM(Waste_Amount) AS Total_Waste FROM Waste WHERE Waste_Date BETWEEN '2022-01-01' AND '2022-03-31' GROUP BY Plant ORDER BY Total_Waste DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Hotels (id INT, name TEXT, country TEXT, rating FLOAT, eco_friendly BOOLEAN); INSERT INTO Hotels (id, name, country, rating, eco_friendly) VALUES (1, 'Eco Hotel', 'United Kingdom', 3.8, true), (2, 'Green Lodge', 'United Kingdom', 4.2, true), (3, 'Classic Hotel', 'United Kingdom', 4.6, false);
|
What is the lowest-rated eco-friendly hotel in the United Kingdom?
|
SELECT name, rating FROM Hotels WHERE country = 'United Kingdom' AND eco_friendly = true ORDER BY rating ASC LIMIT 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE marine_species (id INT, name VARCHAR(255), phylum VARCHAR(255)); INSERT INTO marine_species (id, name, phylum) VALUES (1, 'Pacific salmon', 'Chordata'), (2, 'Hawaiian monk seal', 'Chordata'), (3, 'Sea anemone', 'Cnidaria');
|
Delete all marine species in the 'marine_species' table that belong to the 'Cnidaria' phylum.
|
DELETE FROM marine_species WHERE phylum = 'Cnidaria';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Policyholder_Info (ID INT, Age INT, State VARCHAR(20), Insurance_Type VARCHAR(20)); INSERT INTO Policyholder_Info (ID, Age, State, Insurance_Type) VALUES (1, 45, 'New York', 'Life'), (2, 35, 'California', 'Health'), (3, 60, 'New York', 'Life'), (4, 25, 'Texas', 'Auto'), (5, 50, 'New York', 'Life'), (6, 40, 'California', 'Life');
|
What is the average age of policyholders with life insurance in the state of New York?
|
SELECT AVG(Age) FROM Policyholder_Info WHERE State = 'New York' AND Insurance_Type = 'Life';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE if not exists Buses (id INT, type VARCHAR(20), city VARCHAR(20), speed FLOAT); INSERT INTO Buses (id, type, city, speed) VALUES (1, 'Electric', 'Austin', 35.6), (2, 'Diesel', 'Austin', 32.8), (3, 'Electric', 'Austin', 37.2);
|
What is the average speed of electric buses in the city of Austin?
|
SELECT AVG(speed) FROM Buses WHERE type = 'Electric' AND city = 'Austin';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE weather (id INT, city VARCHAR(50), temperature FLOAT, wind_speed FLOAT, timestamp TIMESTAMP); INSERT INTO weather (id, city, temperature, wind_speed, timestamp) VALUES (1, 'Sydney', 70.2, 12.5, '2022-02-01 10:00:00'); INSERT INTO weather (id, city, temperature, wind_speed, timestamp) VALUES (2, 'Sydney', 72.1, 14.3, '2022-02-02 10:00:00');
|
What is the average wind speed for Sydney in the month of February 2022?
|
SELECT AVG(wind_speed) as avg_wind_speed FROM weather WHERE city = 'Sydney' AND timestamp BETWEEN '2022-02-01 00:00:00' AND '2022-02-28 23:59:59';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE geologists (id INT, name VARCHAR(50), age INT, gender VARCHAR(10), years_of_experience INT);
|
What is the average years of experience for male geologists in the 'geologists' table?
|
SELECT AVG(years_of_experience) FROM geologists WHERE gender = 'male';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE customer_transactions (transaction_id INT, customer_id INT, transaction_date DATE, transaction_value DECIMAL(10, 2)); INSERT INTO customer_transactions (transaction_id, customer_id, transaction_date, transaction_value) VALUES (1, 1, '2022-01-01', 100.00), (2, 1, '2022-02-01', 200.00), (3, 2, '2022-03-01', 150.00), (4, 1, '2022-04-01', 300.00);
|
Determine the total value of all transactions for a specific customer in the last year.
|
SELECT SUM(transaction_value) FROM customer_transactions WHERE customer_id = 1 AND transaction_date >= DATE_SUB(NOW(), INTERVAL 1 YEAR);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE EnergyStorageSystems (id INT, country VARCHAR(20), system_capacity INT); INSERT INTO EnergyStorageSystems (id, country, system_capacity) VALUES (1, 'South Korea', 5000), (2, 'South Korea', 7000), (3, 'Japan', 6000);
|
What is the maximum capacity of a single energy storage system in South Korea?
|
SELECT MAX(system_capacity) FROM EnergyStorageSystems WHERE country = 'South Korea';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE customers (id INT, state VARCHAR(50), credit_score INT); INSERT INTO customers (id, state, credit_score) VALUES (1, 'California', 700), (2, 'New York', 750), (3, 'Texas', 650);
|
What is the average credit score for customers in each state?
|
SELECT state, AVG(credit_score) FROM customers GROUP BY state;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE production (id INT, material VARCHAR(255), water_consumption INT); INSERT INTO production (id, material, water_consumption) VALUES (1, 'Hemp', 300), (2, 'Cotton', 2500);
|
What is the average water consumption of hemp clothing production compared to cotton?
|
SELECT AVG(CASE WHEN material = 'Hemp' THEN water_consumption ELSE NULL END) as avg_hemp, AVG(CASE WHEN material = 'Cotton' THEN water_consumption ELSE NULL END) as avg_cotton FROM production;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE marine_species (name VARCHAR(255), region VARCHAR(255), population INT); INSERT INTO marine_species (name, region, population) VALUES ('Polar Bear', 'Arctic', 25000), ('Narwhal', 'Arctic', 10000);
|
How many marine species are found in the Arctic region?
|
SELECT SUM(population) FROM marine_species WHERE region = 'Arctic';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE customers (id INT, name VARCHAR(100), region VARCHAR(50), assets_value FLOAT);
|
Insert a new record for a customer 'Mohamed Ahmed' from 'Middle East' region with assets value $900,000.00.
|
INSERT INTO customers (name, region, assets_value) VALUES ('Mohamed Ahmed', 'Middle East', 900000.00);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE developers (developer_id INT, developer_name VARCHAR(100), developer_country VARCHAR(50), date_of_birth DATE); INSERT INTO developers VALUES (1, 'Alice', 'USA', '1990-05-01'); INSERT INTO developers VALUES (2, 'Bob', 'Canada', '1985-08-12');
|
Find the number of digital assets created by developers in each country in April 2022.
|
SELECT developer_country, COUNT(*) as num_assets FROM developers WHERE date_of_birth BETWEEN '1980-01-01' AND '2000-12-31' AND developer_country IN ('USA', 'Canada', 'Mexico', 'Brazil', 'UK') GROUP BY developer_country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE MarsRovers (RoverName TEXT, LaunchCountry TEXT);CREATE VIEW MarsLandings (RoverName) AS SELECT RoverName FROM MarsRovers WHERE MarsRovers.RoverName IN ('Spirit', 'Opportunity', 'Curiosity', 'Perseverance');
|
List all rovers that have landed on Mars and their launching countries.
|
SELECT MarsRovers.RoverName, MarsRovers.LaunchCountry FROM MarsRovers INNER JOIN MarsLandings ON MarsRovers.RoverName = MarsLandings.RoverName;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE canada_waste_generation (city VARCHAR(20), province VARCHAR(20), year INT, waste_type VARCHAR(20), quantity FLOAT); INSERT INTO canada_waste_generation (city, province, year, waste_type, quantity) VALUES ('Vancouver', 'British Columbia', 2021, 'Organic', 100000); INSERT INTO canada_waste_generation (city, province, year, waste_type, quantity) VALUES ('Vancouver', 'British Columbia', 2021, 'Recyclable', 150000);
|
Determine the total waste generation by city for the year 2021 in the province of British Columbia, Canada, separated by waste type.
|
SELECT city, waste_type, SUM(quantity) as total_quantity FROM canada_waste_generation WHERE province = 'British Columbia' AND year = 2021 GROUP BY city, waste_type;
|
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.