context
stringlengths 11
9.12k
| question
stringlengths 0
1.06k
| SQL
stringlengths 2
4.44k
| source
stringclasses 28
values |
|---|---|---|---|
CREATE TABLE labor_statistics (labor_category VARCHAR(50), average_wage NUMERIC(10,2)); INSERT INTO labor_statistics (labor_category, average_wage) VALUES ('Carpenters', '35.56'), ('Electricians', '38.42'), ('Plumbers', '42.15'); CREATE TABLE project_data (project_id SERIAL PRIMARY KEY, labor_category VARCHAR(50), square_footage INTEGER); INSERT INTO project_data (project_id, labor_category, square_footage) VALUES (1, 'Carpenters', 15000), (2, 'Electricians', 20000), (3, 'Plumbers', 25000);
|
What is the total square footage of building projects per labor category?
|
SELECT labor_category, SUM(square_footage) FROM project_data GROUP BY labor_category;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE facility_ratings (id INT, facility_name VARCHAR(255), region VARCHAR(255), ethical_rating INT); INSERT INTO facility_ratings (id, facility_name, region, ethical_rating) VALUES (1, 'Green Textiles', 'Americas', 9), (2, 'EcoMetal', 'Europe', 10), (3, 'SolarSteel', 'Asia', 8);
|
What is the average ethical rating of facilities in the 'Americas' region?
|
SELECT AVG(ethical_rating) FROM facility_ratings WHERE region = 'Americas';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE CountryConcerts (Country VARCHAR(50), ConcertID INT); INSERT INTO CountryConcerts (Country, ConcertID) VALUES ('USA', 1); INSERT INTO CountryConcerts (Country, ConcertID) VALUES ('Canada', 2); INSERT INTO CountryConcerts (Country, ConcertID) VALUES ('Mexico', 3);
|
Find the number of unique genres in each country with at least one concert.
|
SELECT Country, COUNT(DISTINCT Genre) AS UniqueGenres FROM CountryConcerts JOIN Concerts ON CountryConcerts.ConcertID = Concerts.ConcertID JOIN Songs ON Concerts.ConcertID = Songs.ConcertID GROUP BY Country HAVING COUNT(DISTINCT Concerts.ConcertID) > 0;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE CommunityHealthWorker (ID INT, Name TEXT); INSERT INTO CommunityHealthWorker (ID, Name) VALUES (1, 'Mabel Lee'); INSERT INTO CommunityHealthWorker (ID, Name) VALUES (2, 'Ali Hassan'); INSERT INTO CommunityHealthWorker (ID, Name) VALUES (3, 'Lauren Johnson'); CREATE TABLE PatientCommunityHealthWorker (PatientID INT, CommunityHealthWorkerID INT);
|
Identify the top three community health workers with the most unique patients served, along with the number of patients they have served.
|
SELECT CommunityHealthWorkerID, COUNT(DISTINCT PatientID) as PatientsServed FROM PatientCommunityHealthWorker GROUP BY CommunityHealthWorkerID ORDER BY PatientsServed DESC LIMIT 3;
|
gretelai_synthetic_text_to_sql
|
CREATE VIEW sales_data AS SELECT id, vehicle_type, avg_speed, sales FROM vehicle_sales WHERE sales > 20000;
|
How many autonomous vehicles were sold in 'sales_data' view?
|
SELECT COUNT(*) FROM sales_data WHERE vehicle_type LIKE '%autonomous%';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Brand_Preferences (brand_id INT, brand TEXT, total_products INT, avg_preference_rating DECIMAL); INSERT INTO Brand_Preferences (brand_id, brand, total_products, avg_preference_rating) VALUES (1, 'EcoPure', 15, 4.7), (2, 'Natural Beauty', 12, 4.3), (3, 'Green Visions', 10, 4.9), (4, 'Pure & Simple', 14, 4.1); CREATE TABLE Product_Sustainability (product_id INT, brand_id INT, carbon_footprint DECIMAL); INSERT INTO Product_Sustainability (product_id, brand_id, carbon_footprint) VALUES (1001, 1, 3.2), (1002, 2, 4.1), (1003, 3, 2.8), (1004, 4, 3.7), (1005, 1, 2.9); CREATE TABLE Product_Reviews (product_id INT, review_count INT); INSERT INTO Product_Reviews (product_id, review_count) VALUES (1001, 45), (1002, 32), (1003, 38), (1004, 29), (1005, 42);
|
Which products from brands with an average preference rating above 4 have been reviewed more than 30 times and have a carbon footprint below 3.5?
|
SELECT product_id FROM Product_Sustainability INNER JOIN Brand_Preferences ON Product_Sustainability.brand_id = Brand_Preferences.brand_id INNER JOIN Product_Reviews ON Product_Sustainability.product_id = Product_Reviews.product_id WHERE avg_preference_rating > 4 AND review_count > 30 AND carbon_footprint < 3.5;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE districts(id INT, name TEXT); INSERT INTO districts VALUES (1, 'District A'); INSERT INTO districts VALUES (2, 'District B'); INSERT INTO districts VALUES (3, 'District C'); CREATE TABLE museums(id INT, district_id INT, name TEXT, exhibits INT); INSERT INTO museums VALUES (1, 1, 'Museum A', 100); INSERT INTO museums VALUES (2, 1, 'Museum B', 120); INSERT INTO museums VALUES (3, 2, 'Museum C', 140); INSERT INTO museums VALUES (4, 3, 'Museum D', 160);
|
What is the number of public museums in each district in the city of Chicago, including their names and number of exhibits?
|
SELECT d.name as district_name, m.name as museum_name, COUNT(*) as museum_count, SUM(m.exhibits) as total_exhibits FROM districts d JOIN museums m ON d.id = m.district_id WHERE d.name = 'Chicago' GROUP BY d.name, m.name;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE green_buildings (id INT, project_name VARCHAR(50), state VARCHAR(50), value FLOAT); INSERT INTO green_buildings (id, project_name, state, value) VALUES (1, 'Seattle Green Tower', 'Washington', 15000000.00); INSERT INTO green_buildings (id, project_name, state, value) VALUES (2, 'Tacoma Green Project', 'Washington', 20000000.00);
|
What is the total value of green building projects in Washington state?
|
SELECT SUM(value) FROM green_buildings WHERE state = 'Washington' AND project_name LIKE '%green%'
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Donors (DonorID INT, FirstName VARCHAR(50), LastName VARCHAR(50), Country VARCHAR(100), DateOfBirth DATE); INSERT INTO Donors (DonorID, FirstName, LastName, Country, DateOfBirth) VALUES (1, 'John', 'Doe', 'USA', '1980-01-01'), (2, 'Jane', 'Doe', 'Canada', '1990-01-01');
|
List the first and last name of the youngest donor for each country?
|
SELECT FirstName, LastName, Country, MIN(DateOfBirth) as YoungestDonor FROM Donors GROUP BY Country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE GarmentProduction (manufacturer_id INT, garment_type VARCHAR(50), quantity INT); INSERT INTO GarmentProduction (manufacturer_id, garment_type, quantity) VALUES (1, 'T-Shirt', 500), (2, 'Jeans', 300), (1, 'T-Shirt', 500);
|
What is the total quantity of garments produced by each manufacturer in the 'GarmentProduction' table, excluding any duplicates based on the 'manufacturer_id'?
|
SELECT DISTINCT manufacturer_id, SUM(quantity) FROM GarmentProduction GROUP BY manufacturer_id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE dept_vulnerabilities (id INT, department VARCHAR(255), app_name VARCHAR(255), severity INT); INSERT INTO dept_vulnerabilities (id, department, app_name, severity) VALUES (1, 'Finance', 'App1', 5), (2, 'Finance', 'App2', 3), (3, 'IT', 'App3', 7);
|
What is the minimum severity of vulnerabilities for applications in the 'Finance' department?
|
SELECT department, MIN(severity) FROM dept_vulnerabilities WHERE department = 'Finance';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE oil_spills_atlantic (id INT, location VARCHAR(20), severity INT);
|
Delete all records of oil spills in the Atlantic Ocean with a severity level less than or equal to 3.
|
DELETE FROM oil_spills_atlantic WHERE location LIKE 'Atlantic Ocean%' AND severity <= 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE customers (id INT, name VARCHAR(50), region VARCHAR(50), revenue FLOAT); INSERT INTO customers (id, name, region, revenue) VALUES (1, 'John Smith', 'Southeast', 5000), (2, 'Jane Doe', 'Northeast', 7000), (3, 'Bob Johnson', 'Southeast', 6000);
|
What is the total revenue of customers in the Southeast region?
|
SELECT SUM(revenue) FROM customers WHERE region = 'Southeast';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE inspections (inspection_id INT, restaurant_id INT, inspection_date DATE, score INT); INSERT INTO inspections (inspection_id, restaurant_id, inspection_date, score) VALUES (1, 1, '2022-01-01', 95);
|
How many food safety inspections were conducted for each restaurant, and what is the average score of the inspections?
|
SELECT restaurant_id, COUNT(*), AVG(score) FROM inspections GROUP BY restaurant_id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE renewable_energy (id INT, type TEXT, country TEXT, capacity FLOAT); INSERT INTO renewable_energy (id, type, country, capacity) VALUES (1, 'Wind Turbine', 'Germany', 2.2), (2, 'Solar Panel', 'Spain', 3.2), (3, 'Wind Turbine', 'France', 2.5);
|
Determine the total installed capacity of wind turbines in Germany.
|
SELECT SUM(capacity) FROM renewable_energy WHERE type = 'Wind Turbine' AND country = 'Germany';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE neighborhoods (neighborhood_id INT, name VARCHAR(255), inclusive_housing BOOLEAN, max_property_price DECIMAL(10,2)); INSERT INTO neighborhoods (neighborhood_id, name, inclusive_housing, max_property_price) VALUES (1, 'Central Park', true, 1200000), (2, 'Soho', false, 1500000), (3, 'Greenwich Village', true, 1300000), (4, 'Harlem', true, 800000);
|
What is the maximum property price in neighborhoods with inclusive housing policies?
|
SELECT MAX(max_property_price) FROM neighborhoods WHERE inclusive_housing = true
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE recycling_rates (id INT PRIMARY KEY, location VARCHAR(255), recycling_type VARCHAR(255), rate DECIMAL(5,4), date DATE);
|
Update the rate of 'Paper' to 0.35 in recycling_rates table
|
UPDATE recycling_rates SET rate = 0.35 WHERE recycling_type = 'Paper';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE members(member_id INT, name VARCHAR(50), member_type VARCHAR(50)); INSERT INTO members (member_id, name, member_type) VALUES (1, 'John Doe', 'Individual'), (2, 'Jane Smith', 'Family'); CREATE TABLE artworks(artwork_id INT, title VARCHAR(50), is_checked_out INT); INSERT INTO artworks (artwork_id, title, is_checked_out) VALUES (1, 'Mona Lisa', 1), (2, 'Starry Night', 0);
|
What is the average number of artworks checked out by visitors who are members of the museum?
|
SELECT AVG(a.is_checked_out) FROM artworks a JOIN members m ON a.member_id = m.member_id WHERE m.member_type = 'Individual' OR m.member_type = 'Family';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Shipment (id INT PRIMARY KEY, customer_id INT, weight FLOAT, shipped_date DATE); INSERT INTO Shipment (id, customer_id, weight, shipped_date) VALUES (7, 1, 120.5, '2022-05-01'), (8, 2, 150.3, '2022-05-05'), (9, 3, 180.7, '2022-05-07'), (10, 1, 90.2, '2022-06-10'), (11, 2, 135.6, '2022-07-14'), (12, 4, 175.8, '2022-07-20'); CREATE TABLE Customer (id INT PRIMARY KEY, name VARCHAR(100), address VARCHAR(200), phone VARCHAR(15)); INSERT INTO Customer (id, name, address, phone) VALUES (1, 'John Doe', '123 Main St, Miami, FL', '305-555-1212'), (2, 'Jane Smith', '456 Oak St, San Francisco, CA', '415-555-3434'), (3, 'Mike Johnson', '789 Elm St, Dallas, TX', '214-555-5656'), (4, 'Emilia Clarke', '700 Spruce St, New York, NY', '646-555-7878');
|
Identify customers who have shipped the most in the last month.
|
SELECT customer_id, SUM(weight) AS total_weight FROM Shipment WHERE shipped_date >= DATEADD(month, -1, GETDATE()) GROUP BY customer_id ORDER BY total_weight DESC;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE news (id INT, name VARCHAR(50), gender VARCHAR(10), age INT); INSERT INTO news (id, name, gender, age) VALUES (1, 'John', 'Male', 35), (2, 'Alex', 'Male', 45);
|
What is the average age of male reporters in the 'news' table?
|
SELECT AVG(age) FROM news WHERE gender = 'Male';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE finance.cost_of_goods_sold (product_line VARCHAR(50), month INT, year INT, cost DECIMAL(10,2)); INSERT INTO finance.cost_of_goods_sold (product_line, month, year, cost) VALUES ('Product Line A', 1, 2022, 10000.00), ('Product Line A', 2, 2022, 20000.00), ('Product Line B', 1, 2022, 15000.00), ('Product Line B', 2, 2022, 25000.00);
|
What is the total cost of goods sold for each product line in the 'finance' schema?
|
SELECT product_line, SUM(cost) as total_cost_of_goods_sold FROM finance.cost_of_goods_sold GROUP BY product_line;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE climate_monitoring_stations (id INT, station_name VARCHAR(255), region VARCHAR(255)); INSERT INTO climate_monitoring_stations (id, station_name, region) VALUES (1, 'Station A', 'canada'), (2, 'Station B', 'greenland'), (3, 'Station C', 'canada'), (4, 'Station D', 'norway');
|
What is the total number of climate monitoring stations in the 'canada' and 'greenland' regions?
|
SELECT region FROM climate_monitoring_stations WHERE region IN ('canada', 'greenland') GROUP BY region;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Games (GameID INT, GameName VARCHAR(100), Genre VARCHAR(50), Rating DECIMAL(3, 1)); INSERT INTO Games (GameID, GameName, Genre, Rating) VALUES (1, 'Beat Saber', 'VR', 9.0), (2, 'Job Simulator', 'VR', 8.3), (3, 'Echo VR', 'VR', 8.7);
|
List all virtual reality (VR) games with a rating higher than 8.5, ordered alphabetically.
|
SELECT GameName FROM Games WHERE Genre = 'VR' AND Rating > 8.5 ORDER BY GameName;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Manufacturers (ID INT, Name VARCHAR(100), Country VARCHAR(50)); INSERT INTO Manufacturers (ID, Name, Country) VALUES (1, 'Audi', 'Germany'), (2, 'BMW', 'Germany'), (3, 'Porsche', 'Germany'); CREATE TABLE Vehicles (ID INT, Name VARCHAR(100), ManufacturerID INT, Horsepower INT, VehicleType VARCHAR(50)); INSERT INTO Vehicles (ID, Name, ManufacturerID, Horsepower, VehicleType) VALUES (1, 'e-Tron', 1, 402, 'Electric'), (2, 'i3', 2, 170, 'Electric'), (3, 'i8', 2, 369, 'Electric'), (4, 'Taycan', 3, 751, 'Electric');
|
What is the average horsepower of electric vehicles manufactured in Germany?
|
SELECT AVG(Horsepower) FROM Vehicles WHERE ManufacturerID IN (SELECT ID FROM Manufacturers WHERE Country = 'Germany') AND VehicleType = 'Electric';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE factories (id INT, sector VARCHAR(255), ethical_practices BOOLEAN);
|
What is the total number of factories in the 'Renewable Energy' sector that are compliant with ethical manufacturing practices?
|
SELECT COUNT(*) FROM factories WHERE sector = 'Renewable Energy' AND ethical_practices = TRUE;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE space_missions (mission_id INT, mission_year INT, mission_status VARCHAR(10), mission_company VARCHAR(100));
|
What is the failure rate for SpaceX missions?
|
SELECT mission_company, COUNT(*) * 100.0 / (SELECT COUNT(*) FROM space_missions WHERE mission_company = 'SpaceX') AS failure_rate FROM space_missions WHERE mission_status = 'failed' AND mission_company = 'SpaceX' GROUP BY mission_company;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE attorneys (attorney_id INT, name VARCHAR(50)); CREATE TABLE cases (case_id INT, attorney_id INT); INSERT INTO attorneys (attorney_id, name) VALUES (1, 'Smith'), (2, 'Johnson'), (3, 'Williams'), (4, 'Brown'); INSERT INTO cases (case_id, attorney_id) VALUES (1, 2), (2, 1), (3, 3), (4, 2);
|
List all attorneys who have not handled any cases?
|
SELECT attorneys.name FROM attorneys LEFT JOIN cases ON attorneys.attorney_id = cases.attorney_id WHERE cases.attorney_id IS NULL;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE song_releases (song_id INT, genre VARCHAR(20));
|
What are the top 3 genres with the most songs in the song_releases table?
|
SELECT genre, COUNT(*) FROM song_releases GROUP BY genre ORDER BY COUNT(*) DESC LIMIT 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ResourceDepletion (Operation VARCHAR(50), Resource VARCHAR(50), DepletionQuantity FLOAT); INSERT INTO ResourceDepletion(Operation, Resource, DepletionQuantity) VALUES ('Operation A', 'Coal', 12000), ('Operation A', 'Iron', 15000), ('Operation B', 'Coal', 10000), ('Operation B', 'Iron', 18000), ('Operation C', 'Coal', 16000), ('Operation C', 'Iron', 13000);
|
What is the total amount of resources depleted by each mining operation last quarter?
|
SELECT Operation, SUM(DepletionQuantity) FROM ResourceDepletion WHERE Resource IN ('Coal', 'Iron') AND DepletionQuantity >= 0 GROUP BY Operation;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE if not exists rnd_projects (id INT, project_name VARCHAR(100), category VARCHAR(50), cost INT, start_date DATE, end_date DATE); INSERT INTO rnd_projects (id, project_name, category, cost, start_date, end_date) VALUES (1, 'Stealth Fighter', 'Aircraft', 5000000, '2010-01-01', '2015-12-31'); INSERT INTO rnd_projects (id, project_name, category, cost, start_date, end_date) VALUES (2, 'AI-Powered Drone', 'UAV', 1000000, '2018-01-01', '2020-12-31');
|
What are the R&D projects in the 'Cybersecurity' category and their start dates?
|
SELECT project_name, category, start_date FROM rnd_projects WHERE category = 'Cybersecurity';
|
gretelai_synthetic_text_to_sql
|
CREATE SCHEMA maintenance; CREATE TABLE maintenance.vehicle_maintenance (id INT PRIMARY KEY, vehicle_id INT, year INT); INSERT INTO maintenance.vehicle_maintenance (id, vehicle_id, year) VALUES (1, 1, 2015), (2, 2, 2018), (3, 3, 2020), (4, 4, 2017), (5, 5, 2019);
|
What is the earliest year of a vehicle in the 'maintenance' schema?
|
SELECT MIN(year) FROM maintenance.vehicle_maintenance;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE mining_operations (employee_id INT, job_title VARCHAR(50), gender VARCHAR(10)); INSERT INTO mining_operations (employee_id, job_title, gender) VALUES (1, 'Engineer', 'Male'), (2, 'Operator', 'Female'), (3, 'Manager', 'Male');
|
Find the percentage of female and male employees in the 'mining_operations' table, grouped by their job title.
|
SELECT job_title, CONCAT(ROUND(100.0 * SUM(CASE WHEN gender = 'Female' THEN 1 ELSE 0 END) / COUNT(*) * 100.0, 2), '%') as female_percentage, CONCAT(ROUND(100.0 * SUM(CASE WHEN gender = 'Male' THEN 1 ELSE 0 END) / COUNT(*) * 100.0, 2), '%') as male_percentage FROM mining_operations GROUP BY job_title;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE sustainable_tourism_initiatives (initiative_id INT, initiative VARCHAR(50)); INSERT INTO sustainable_tourism_initiatives (initiative_id, initiative) VALUES (1, 'Eco-tours'), (2, 'Green hotels'), (3, 'Carbon offset programs');
|
How many sustainable tourism initiatives are there in total in 'sustainable_tourism_initiatives' table?
|
SELECT COUNT(*) FROM sustainable_tourism_initiatives;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE tour_de_france (id INT, cyclist VARCHAR(50), stage INT, speed DECIMAL(5,2));
|
What is the average speed of all cyclists in the tour_de_france table, grouped by stage?
|
SELECT stage, AVG(speed) AS avg_speed FROM tour_de_france GROUP BY stage;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE temperature_data (id INT, region VARCHAR(50), year INT, temperature DECIMAL); INSERT INTO temperature_data (id, region, year, temperature) VALUES (1, 'Arctic', 2020, -25.6); INSERT INTO temperature_data (id, region, year, temperature) VALUES (2, 'Antarctic', 2019, -35.7); INSERT INTO temperature_data (id, region, year, temperature) VALUES (3, 'Antarctic', 2020, -45.6);
|
What is the average temperature in the Antarctic region in 2020?
|
SELECT AVG(temperature) FROM temperature_data WHERE region = 'Antarctic' AND year = 2020;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Budget_Sum (id INT, project_name TEXT, state TEXT, start_date DATE, budget INT); INSERT INTO Budget_Sum (id, project_name, state, start_date, budget) VALUES (1, 'Highway Expansion', 'Arizona', '2018-02-14', 12000000), (2, 'School Addition', 'Arizona', '2017-12-31', 8000000);
|
What is the sum of budgets for construction projects in Arizona that started after 2017?
|
SELECT SUM(budget) FROM Budget_Sum WHERE state = 'Arizona' AND start_date > '2017-01-01';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE safety_incidents (id INT, incident_type VARCHAR(50), incident_date DATE); INSERT INTO safety_incidents (id, incident_type, incident_date) VALUES (1, 'Fall', '2021-03-15'), (2, 'Electrical Shock', '2021-03-17'), (3, 'Fall', '2021-03-20');
|
What is the total number of safety incidents, by type, in the 'safety_incidents' table?
|
SELECT incident_type, COUNT(*) as num_incidents FROM safety_incidents GROUP BY incident_type;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE athlete (athlete_id INT, name VARCHAR(50), sport VARCHAR(50)); CREATE TABLE wellbeing_programs (program_id INT, athlete_id INT, enrollment_date DATE); INSERT INTO athlete VALUES (1, 'Jane Smith', 'Basketball'); INSERT INTO wellbeing_programs VALUES (1, 1, '2022-06-15');
|
Show the number of athletes enrolled in wellbeing programs, by sport, for the past year.
|
SELECT a.sport, COUNT(DISTINCT a.athlete_id) AS athletes_enrolled FROM athlete a JOIN wellbeing_programs wp ON a.athlete_id = wp.athlete_id WHERE wp.enrollment_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR) GROUP BY a.sport;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE building_permits (permit_number VARCHAR(10), issue_date DATE); INSERT INTO building_permits (permit_number, issue_date) VALUES ('N-12345', '2021-03-01'), ('A-54321', '2021-06-15'), ('P-98765', '2021-09-30');
|
List all permits that were issued in the second quarter of the year
|
SELECT permit_number FROM building_permits WHERE EXTRACT(QUARTER FROM issue_date) = 2;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE indian_ocean (id INT, name VARCHAR(100), region VARCHAR(50)); CREATE TABLE marine_species (id INT, name VARCHAR(100), species_type VARCHAR(50), ocean_id INT); INSERT INTO indian_ocean (id, name, region) VALUES (1, 'Indian Ocean', 'Indian'); INSERT INTO marine_species (id, name, species_type, ocean_id) VALUES (1, 'Blue Whale', 'Mammal', 1), (2, 'Clownfish', 'Fish', 1);
|
How many marine species are recorded in the Indian Ocean, excluding fish?
|
SELECT COUNT(*) FROM marine_species ms WHERE ms.ocean_id = (SELECT id FROM indian_ocean WHERE name = 'Indian Ocean') AND species_type != 'Fish';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE wastewater_treatment_facilities (id INT, facility_name VARCHAR(255), location VARCHAR(255), length FLOAT, construction_year INT); INSERT INTO wastewater_treatment_facilities (id, facility_name, location, length, construction_year) VALUES (1, 'Central Valley Water Treatment', 'California', 12.5, 1995), (2, 'Southern California Water Reclamation', 'California', 15.2, 2000), (3, 'San Francisco Water Treatment', 'California', 10.8, 2005);
|
What is the maximum length of any wastewater treatment facility in California, and the name of the facility, along with its construction year?
|
SELECT facility_name, length, construction_year FROM wastewater_treatment_facilities WHERE location = 'California' AND length = (SELECT MAX(length) FROM wastewater_treatment_facilities WHERE location = 'California');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE broadband_subscribers (id INT, subscriber_name VARCHAR(50), country VARCHAR(50), speed DECIMAL(10,2));
|
What is the average broadband speed for subscribers in each country?
|
SELECT country, AVG(speed) FROM broadband_subscribers GROUP BY country;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE iot_sensors (id INT, installation_date DATE, sensor_type VARCHAR(255)); INSERT INTO iot_sensors (id, installation_date, sensor_type) VALUES (1, '2022-01-01', 'temperature'), (2, '2022-01-05', 'humidity'), (3, '2022-02-10', 'moisture'), (4, '2022-02-15', 'light');
|
Find the difference in the number of IoT sensors installed in January and February.
|
SELECT COUNT(*) - (SELECT COUNT(*) FROM iot_sensors WHERE MONTH(installation_date) = 2) AS jan_feb_sensor_count_diff FROM iot_sensors WHERE MONTH(installation_date) = 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE music_streams (stream_id INT, genre VARCHAR(10), year INT, streams INT); INSERT INTO music_streams (stream_id, genre, year, streams) VALUES (1, 'Classical', 2019, 1000000), (2, 'Jazz', 2020, 1500000), (3, 'Classical', 2020, 1200000), (4, 'Pop', 2019, 1800000), (5, 'Rock', 2021, 4500000), (6, 'R&B', 2021, 5000000); CREATE VIEW genre_streams AS SELECT genre, SUM(streams) as total_streams FROM music_streams GROUP BY genre;
|
How many streams were there for the R&B genre in 2021?
|
SELECT total_streams FROM genre_streams WHERE genre = 'R&B' AND year = 2021;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Policyholders (ID INT, Name VARCHAR(50), Age INT, Gender VARCHAR(10), City VARCHAR(50), State VARCHAR(20), ZipCode VARCHAR(10)); CREATE TABLE Claims (ID INT, PolicyholderID INT, ClaimAmount DECIMAL(10,2), ClaimDate DATE);
|
What is the total claim amount for policyholders who are male and over the age of 50?
|
SELECT SUM(Claims.ClaimAmount) FROM Claims JOIN Policyholders ON Claims.PolicyholderID = Policyholders.ID WHERE Policyholders.Gender = 'Male' AND Policyholders.Age > 50;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE public_meetings (meeting_id INT, meeting_name VARCHAR(255), state VARCHAR(255), region VARCHAR(255), meeting_date DATE); INSERT INTO public_meetings (meeting_id, meeting_name, state, region, meeting_date) VALUES (1, 'Meeting A', 'Illinois', 'Midwest', '2022-01-01'), (2, 'Meeting B', 'Indiana', 'Midwest', '2022-02-01');
|
What is the number of public meetings held in the Midwest in the past year?
|
SELECT COUNT(*) FROM public_meetings WHERE region = 'Midwest' AND meeting_date >= DATEADD(year, -1, GETDATE());
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE patients (id INT, region VARCHAR(255), treatment_received BOOLEAN); INSERT INTO patients (id, region, treatment_received) VALUES (1, 'Ontario', true), (2, 'Quebec', false), (3, 'Ontario', true);
|
How many patients were treated in each region in Canada?
|
SELECT region, COUNT(*) FROM patients WHERE treatment_received = true GROUP BY region;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE brands (brand_id INT, brand_name TEXT); INSERT INTO brands (brand_id, brand_name) VALUES (1, 'H&M'), (2, 'Patagonia'), (3, 'Everlane'); CREATE TABLE products (product_id INT, product_name TEXT, brand_id INT, fair_trade_certified BOOLEAN); INSERT INTO products (product_id, product_name, brand_id, fair_trade_certified) VALUES (1, 'Organic Cotton T-Shirt', 1, TRUE), (2, 'Organic Cotton T-Shirt', 2, FALSE), (3, 'Organic Cotton Hoodie', 2, TRUE), (4, 'Hemp T-Shirt', 3, TRUE);
|
How many fair trade certified products does each brand offer?
|
SELECT brands.brand_name, COUNT(*) as num_fair_trade FROM brands JOIN products ON brands.brand_id = products.brand_id WHERE products.fair_trade_certified = TRUE GROUP BY brands.brand_id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE vulnerabilities (id INT, timestamp TIMESTAMP, software VARCHAR(255), category VARCHAR(255), severity VARCHAR(255)); INSERT INTO vulnerabilities (id, timestamp, software, category, severity) VALUES (1, '2022-01-01 10:00:00', 'Firefox', 'browser', 'high'), (2, '2022-04-02 15:00:00', 'Windows', 'OS', 'medium');
|
What are the top 3 software categories with the highest severity level of vulnerabilities in the last 6 months?
|
SELECT category, MAX(severity) as max_severity, COUNT(*) as vulnerability_count FROM vulnerabilities WHERE timestamp >= DATE_SUB(CURRENT_TIMESTAMP(), INTERVAL 6 MONTH) GROUP BY category ORDER BY max_severity DESC, vulnerability_count DESC LIMIT 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE trip (id INT, year INT, gender VARCHAR(10), trips INT, community VARCHAR(255)); INSERT INTO trip (id, year, gender, trips, community) VALUES (1, 2018, 'Male', 50000, 'White'), (2, 2018, 'Female', 55000, 'African American'), (3, 2019, 'Male', 60000, 'Hispanic'), (4, 2019, 'Female', 65000, 'Asian'), (5, 2020, 'Male', 70000, 'Native American'), (6, 2020, 'Female', 75000, 'Pacific Islander'), (7, 2021, 'Male', 80000, 'White'), (8, 2021, 'Female', 85000, 'African American');
|
What is the total number of public transportation trips taken by people from historically underrepresented communities in each year?
|
SELECT year, SUM(trips) FROM trip WHERE community != 'White' GROUP BY year
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE terbium_prices (region VARCHAR(255), price DECIMAL(10,2)); INSERT INTO terbium_prices (region, price) VALUES ('China', 350.00), ('Japan', 330.00), ('India', 370.00);
|
What is the minimum price of Terbium in Asia?
|
SELECT MIN(price) FROM terbium_prices WHERE region = 'China' OR region = 'Japan' OR region = 'India';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE vendor_contracts (vendor_id INT, vendor_name VARCHAR(50), contract_id INT, contract_value DECIMAL(10,2));
|
Add a new vendor named 'XYZ Defense' to the vendor_contracts table with a vendor_id of 123
|
INSERT INTO vendor_contracts (vendor_id, vendor_name) VALUES (123, 'XYZ Defense');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Japanese_Streaming (user INT, artist VARCHAR(50), year INT); INSERT INTO Japanese_Streaming (user, artist, year) VALUES (1, 'Utada Hikaru', 2018), (1, 'Perfume', 2019), (2, 'Utada Hikaru', 2020), (2, 'Perfume', 2020), (3, 'Utada Hikaru', 2021), (3, 'Perfume', 2020);
|
What was the number of unique users who streamed a Japanese artist's songs in 2020?
|
SELECT artist, COUNT(DISTINCT user) FROM Japanese_Streaming WHERE year = 2020 GROUP BY artist;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Ports (id INT, name VARCHAR(50), country VARCHAR(50)); CREATE TABLE CargoTransports (id INT, vessel_id INT, weight INT, transport_time TIMESTAMP, source_port_id INT, destination_port_id INT);
|
What is the total cargo weight transported by vessels from Japan to the US in the last 6 months?
|
SELECT SUM(weight) FROM CargoTransports WHERE transport_time > NOW() - INTERVAL '6 months' AND source_port_id IN (SELECT id FROM Ports WHERE country = 'Japan') AND destination_port_id IN (SELECT id FROM Ports WHERE country = 'US');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ConstructionSalaries (WorkerID INT, Company VARCHAR(50), Region VARCHAR(50), Salary DECIMAL(10,2)); INSERT INTO ConstructionSalaries (WorkerID, Company, Region, Salary) VALUES (1, 'Company A', 'North America', 6000), (2, 'Company B', 'South America', 7000), (3, 'Company C', 'Europe', 8000);
|
What is the average salary of workers in the construction industry by region?
|
SELECT Region, AVG(Salary) as AvgSalary FROM ConstructionSalaries WHERE Industry = 'Construction' GROUP BY Region;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE student_mental_health (student_id INT, grade_level INT, mental_health_score INT); INSERT INTO student_mental_health (student_id, grade_level, mental_health_score) VALUES (1, 6, 75), (2, 7, 80), (3, 6, 85), (4, 7, 70), (5, 6, 70), (6, 7, 85), (7, 6, 90);
|
Which students have a mental health score below the average for their grade level?
|
SELECT smh.student_id, smh.grade_level, smh.mental_health_score FROM student_mental_health smh JOIN (SELECT grade_level, AVG(mental_health_score) as avg_mh FROM student_mental_health GROUP BY grade_level) sub ON smh.grade_level = sub.grade_level WHERE smh.mental_health_score < sub.avg_mh;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Animals (id INT, name VARCHAR(255), population INT, status VARCHAR(255));
|
Add a record for the 'Javan Rhino' to the Animals table.
|
INSERT INTO Animals (id, name, population, status) VALUES (4, 'Javan Rhino', 67, 'Critically Endangered');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE health_grants (grant_id INT, grant_amount DECIMAL(10,2), grant_recipient VARCHAR(50), recipient_identity VARCHAR(50)); INSERT INTO health_grants (grant_id, grant_amount, grant_recipient, recipient_identity) VALUES (1, 35000.00, 'Prof. Rivera', 'Hispanic'), (2, 45000.00, 'Prof. Thompson', 'African American'), (3, 55000.00, 'Prof. Wang', 'Asian'), (4, 65000.00, 'Prof. Lopez', 'Latino'), (5, 25000.00, 'Prof. Jackson', 'African American');
|
What is the total number of research grants awarded to faculty members in the College of Health Sciences who identify as African American or Black?
|
SELECT COUNT(*) FROM health_grants WHERE grant_recipient LIKE '%College of Health Sciences%' AND recipient_identity IN ('African American', 'Black');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE likes (id INT, post_id INT, user_id INT, like_count INT); INSERT INTO likes (id, post_id, user_id, like_count) VALUES (1, 1, 1, 50), (2, 2, 1, 100);
|
What is the average number of likes per post for users in 'CA' region?
|
SELECT AVG(likes.like_count) FROM posts JOIN likes ON posts.id = likes.post_id JOIN users ON posts.user_id = users.id WHERE users.region = 'CA' GROUP BY posts.id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE deep_sea_volcanoes (volcano_id INT, location VARCHAR(50), avg_depth FLOAT); INSERT INTO deep_sea_volcanoes (volcano_id, location, avg_depth) VALUES (1, 'Pacific Ocean', 2000.0), (2, 'Atlantic Ocean', 1500.0), (3, 'Indian Ocean', 1800.0);
|
What is the average depth of all deep-sea volcanoes in the Atlantic Ocean?
|
SELECT AVG(avg_depth) FROM deep_sea_volcanoes WHERE location = 'Atlantic Ocean';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Companies (company_id INT, company_name VARCHAR(255), company_country VARCHAR(255)); INSERT INTO Companies (company_id, company_name, company_country) VALUES (1, 'Ethereum Foundation', 'Switzerland'), (2, 'ConsenSys', 'US'), (3, 'Cardano Foundation', 'Switzerland'); CREATE TABLE DigitalAssets (asset_id INT, asset_name VARCHAR(255), company_id INT, is_smart_contract BOOLEAN); INSERT INTO DigitalAssets (asset_id, asset_name, company_id, is_smart_contract) VALUES (1, 'ETH', 2, false), (2, 'DAI', 2, true), (3, 'ADA', 3, false);
|
What is the total number of digital assets issued by companies based in the US, and how many of those are smart contracts?
|
SELECT SUM(CASE WHEN DigitalAssets.company_country = 'US' THEN 1 ELSE 0 END) AS total_us_assets, SUM(CASE WHEN DigitalAssets.company_country = 'US' AND DigitalAssets.is_smart_contract = true THEN 1 ELSE 0 END) AS us_smart_contracts FROM DigitalAssets INNER JOIN Companies ON DigitalAssets.company_id = Companies.company_id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE user_workout_durations (user_id INT, duration INT);
|
Identify the average duration of workouts for users who have checked in more than 30 times
|
SELECT AVG(duration) as avg_duration FROM user_workout_durations WHERE user_id IN (SELECT user_id FROM user_check_ins GROUP BY user_id HAVING COUNT(check_in_id) > 30);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Employees (EmployeeID INT, Department VARCHAR(20), Salary DECIMAL(10,2));CREATE VIEW DepartmentSalaries AS SELECT Department, SUM(Salary) as TotalSalary FROM Employees GROUP BY Department;
|
What are the departments with the highest total salary expenses?
|
SELECT Department FROM DepartmentSalaries WHERE ROW_NUMBER() OVER(ORDER BY TotalSalary DESC) <= 3;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE emergency_calls (id INT, region VARCHAR(10), response_time INT); INSERT INTO emergency_calls (id, region, response_time) VALUES (1, 'west', 120), (2, 'west', 150), (3, 'east', 90);
|
What is the minimum response time for emergency calls in each region?
|
SELECT region, MIN(response_time) FROM emergency_calls GROUP BY region;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE community_development (initiative_type VARCHAR(255), state VARCHAR(255), initiative_name VARCHAR(255), budget INT); INSERT INTO community_development (initiative_type, state, initiative_name, budget) VALUES ('Youth Center', 'California', 'Oakland Youth Hub', 200000), ('Library', 'Texas', 'Austin Public Library', 300000);
|
What is the total budget for community development initiatives per initiative type in the 'community_development' table?
|
SELECT initiative_type, SUM(budget) FROM community_development GROUP BY initiative_type;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE household_energy_consumption (household_id INT, city VARCHAR(50), consumption_kwh FLOAT); INSERT INTO household_energy_consumption (household_id, city, consumption_kwh) VALUES (1, 'Jakarta', 220.3), (2, 'Kuala Lumpur', 250.9), (3, 'Jakarta', 270.1), (4, 'Kuala Lumpur', 230.5), (5, 'Jakarta', 260.4), (6, 'Kuala Lumpur', 280.1);
|
What is the average energy consumption (in kWh) of households in Jakarta and Kuala Lumpur?
|
SELECT AVG(consumption_kwh) FROM household_energy_consumption WHERE city IN ('Jakarta', 'Kuala Lumpur');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE shark_sightings (id INT PRIMARY KEY, species VARCHAR(255), location VARCHAR(255), sighting_date DATE); INSERT INTO shark_sightings (id, species, location, sighting_date) VALUES (1, 'Hammerhead Shark', 'Pacific Ocean', '2023-03-11');
|
Update the location of the shark sighting in the Pacific Ocean
|
UPDATE shark_sightings SET location = 'North Pacific' WHERE sighting_date = '2023-03-11';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE peacekeeping_ops (id INT, leader VARCHAR(50), start_date DATE); INSERT INTO peacekeeping_ops (id, leader, start_date) VALUES (1, 'Major Anya', '2018-01-01'); INSERT INTO peacekeeping_ops (id, leader, start_date) VALUES (2, 'Colonel Nguyen', '2019-01-01'); INSERT INTO peacekeeping_ops (id, leader, start_date) VALUES (3, 'Lieutenant Rodriguez', '2020-01-01');
|
What is the total number of peacekeeping operations led by women in the last 5 years?
|
SELECT COUNT(*) as total_women_led_ops FROM peacekeeping_ops WHERE leader LIKE 'Captain%' OR leader LIKE 'Major%' OR leader LIKE 'Colonel%' OR leader LIKE 'General%' OR leader LIKE 'Lieutenant%' AND start_date >= DATEADD(year, -5, GETDATE());
|
gretelai_synthetic_text_to_sql
|
CREATE SCHEMA if not exists biotech;CREATE TABLE if not exists biotech.startups (id INT PRIMARY KEY, name VARCHAR(100), country VARCHAR(50), funding DECIMAL(10, 2)); INSERT INTO biotech.startups (id, name, country, funding) VALUES (1, 'StartupA', 'USA', 1500000.00), (2, 'StartupB', 'USA', 2000000.00), (3, 'StartupC', 'Canada', 1200000.00);
|
What is the minimum funding received by a biotech startup in the USA?
|
SELECT MIN(funding) FROM biotech.startups WHERE country = 'USA';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE grants (grant_id INT, name VARCHAR(50), budget DECIMAL(10,2), project_type VARCHAR(50)); INSERT INTO grants (grant_id, name, budget, project_type) VALUES (1, 'Ethical AI Research', 400000, 'ethical AI'); INSERT INTO grants (grant_id, name, budget, project_type) VALUES (2, 'Accessibility Tech Development', 600000, 'accessibility tech'); INSERT INTO grants (grant_id, name, budget, project_type) VALUES (3, 'Digital Divide Education', 500000, 'digital divide');
|
What is the total budget of ethical AI and accessibility tech projects?
|
SELECT SUM(budget) FROM grants WHERE project_type IN ('ethical AI', 'accessibility tech');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Projects (id INT, state VARCHAR(2), project_type VARCHAR(10), funding_source VARCHAR(10), budget INT); INSERT INTO Projects (id, state, project_type, funding_source, budget) VALUES (1, 'IL', 'Road', 'Federal', 1000000), (2, 'IL', 'Rail', 'State', 500000), (3, 'IL', 'Bridge', 'Local', 750000);
|
What is the total budget for transportation projects in Illinois, categorized by project type and funding source?
|
SELECT project_type, funding_source, SUM(budget) FROM Projects WHERE state = 'IL' GROUP BY project_type, funding_source;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE spacecraft (id INT, name VARCHAR(255), manufacturer VARCHAR(255), mass FLOAT); INSERT INTO spacecraft (id, name, manufacturer, mass) VALUES (1, 'Voyager 1', 'Galactic Pioneers Inc.', 770.), (2, 'Voyager 2', 'Galactic Pioneers Inc.', 780.), (3, 'New Horizons', 'Space Explorers Ltd.', 1010.), (4, 'ISS', 'Interstellar Inc.', 420.);
|
What is the average mass of spacecraft manufactured by 'Interstellar Inc.'?
|
SELECT AVG(mass) FROM spacecraft WHERE manufacturer = 'Interstellar Inc.';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Artists (ArtistID INT, Name VARCHAR(100), Nationality VARCHAR(50), BirthYear INT, DeathYear INT);
|
Update artist's nationality
|
UPDATE Artists SET Nationality = 'German' WHERE ArtistID = 1 AND Name = 'Leonardo da Vinci';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE products (product_id INT, name VARCHAR(255), price DECIMAL(5,2));
|
Update the name of the product with product_id 102 to 'Gelato' in the 'products' table
|
UPDATE products SET name = 'Gelato' WHERE product_id = 102;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE threat_intelligence (report_id INT, submission_date DATE);
|
Get the number of threat intelligence reports submitted in the last 6 months
|
SELECT COUNT(*) FROM threat_intelligence WHERE submission_date >= NOW() - INTERVAL '6 months';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE ArtistPortfolio (ArtistID INT, ArtID INT); INSERT INTO ArtistPortfolio (ArtistID, ArtID) VALUES (1, 1), (1, 2), (2, 3), (2, 4), (3, 5), (3, 6), (4, 7), (5, 8), (5, 9), (6, 10), (6, 11), (7, 12), (8, 13), (8, 14), (9, 15), (9, 16), (10, 17), (10, 18);
|
What is the average number of artworks in each artist's portfolio?
|
SELECT AVG(ArtworksPerArtist) FROM (SELECT ArtistID, COUNT(*) OVER (PARTITION BY ArtistID) as ArtworksPerArtist FROM ArtistPortfolio);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE multimodal_trips (trip_id INT, trip_start_time TIMESTAMP, trip_end_time TIMESTAMP, trip_modes VARCHAR(50)); CREATE VIEW seoul_trips AS SELECT * FROM multimodal_trips WHERE trip_modes LIKE '%public%' AND trip_modes LIKE '%e-scooter%';
|
List the number of multimodal trips in Seoul involving public transportation and shared e-scooters.
|
SELECT COUNT(*) FROM seoul_trips;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Accommodations(student_id INT, accommodation_id INT, cost DECIMAL(5,2), disability TEXT);
|
What is the maximum cost of accommodations for students with a hearing impairment?
|
SELECT MAX(cost) FROM Accommodations WHERE disability LIKE '%hearing%';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE donations (id INT, donor VARCHAR(255), project VARCHAR(255), region VARCHAR(255), amount DECIMAL(10, 2), donation_date DATE); INSERT INTO donations (id, donor, project, region, amount, donation_date) VALUES (1, 'Hope Foundation', 'Education', 'Africa', 5000, '2016-01-01');
|
What is the total amount of donations made by 'Hope Foundation' to 'Education' projects in 'Africa' after 2015?
|
SELECT SUM(amount) FROM donations WHERE donor = 'Hope Foundation' AND project = 'Education' AND region = 'Africa' AND donation_date > '2015-12-31';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE community_health_workers (worker_id INT, name TEXT, race TEXT); INSERT INTO community_health_workers (worker_id, name, race) VALUES (1, 'Alice', 'Hispanic'), (2, 'Bob', 'Asian'), (3, 'Charlie', 'African American'), (4, 'Diana', 'White');
|
What is the total number of community health workers by race/ethnicity?
|
SELECT race, COUNT(*) FROM community_health_workers GROUP BY race;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Claims (PolicyType VARCHAR(20), ClaimAmount DECIMAL(10, 2), Region VARCHAR(50)); INSERT INTO Claims VALUES ('Auto', 5000, 'New South Wales'); INSERT INTO Claims VALUES ('Home', 3000, 'New South Wales'); INSERT INTO Claims VALUES ('Auto', 4000, 'Queensland'); INSERT INTO Claims VALUES ('Home', 6000, 'Queensland');
|
Find the top 2 riskiest regions with the highest average claim amount in Australia, ordered by the total claim amount in descending order.
|
SELECT Region, AVG(ClaimAmount) AS AvgClaimAmount, SUM(ClaimAmount) AS TotalClaimAmount FROM Claims WHERE Country = 'Australia' GROUP BY Region ORDER BY TotalClaimAmount DESC, AvgClaimAmount DESC LIMIT 2;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE CHW_Demographics (CHW_ID INT, Age INT, Ethnicity VARCHAR(255));
|
Count the number of community health workers in the 'CHW_Demographics' table who identify as African American.
|
SELECT COUNT(*) as CountOfCHW FROM CHW_Demographics WHERE Ethnicity = 'African American';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE news_articles (id INT, title VARCHAR(100), category VARCHAR(30)); INSERT INTO news_articles (id, title, category) VALUES (1, 'Political Update', 'Politics'); INSERT INTO news_articles (id, title, category) VALUES (2, 'Sports News', 'Sports'); INSERT INTO news_articles (id, title, category) VALUES (3, 'Movie Review', 'Entertainment'); INSERT INTO news_articles (id, title, category) VALUES (4, 'Political Analysis', 'Politics');
|
What is the total number of articles written about 'Politics' in the 'news_articles' table?
|
SELECT COUNT(*) FROM news_articles WHERE category = 'Politics';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE animals (id INT PRIMARY KEY, name VARCHAR(50), species VARCHAR(50), population INT);
|
Update the population of the 'Koala' species in the 'animals' table
|
UPDATE animals SET population = 1200 WHERE species = 'Koala';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Arts (id INT, name TEXT, origin TEXT); INSERT INTO Arts (id, name, origin) VALUES (1, 'Ukara Paintings', 'Tanzania'); CREATE TABLE Communities (id INT, art_id INT, name TEXT); INSERT INTO Communities (id, art_id, name) VALUES (1, 1, 'Kurya Tribe');
|
List all the traditional art forms, their origins, and the communities that practice them.
|
SELECT A.name, A.origin, C.name FROM Arts A INNER JOIN Communities C ON A.id = C.art_id;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE water_usage (id INT PRIMARY KEY, year INT, location VARCHAR(50), usage FLOAT); INSERT INTO water_usage (id, year, location, usage) VALUES (1, 2018, 'Chicago', 1234.56), (2, 2019, 'Chicago', 1567.89), (3, 2020, 'Chicago', 1890.12), (4, 2018, 'Miami', 2234.56), (5, 2019, 'Miami', 2567.89), (6, 2020, 'Miami', 2890.12);
|
Determine the average water usage in cubic meters for the locations 'Chicago' and 'Miami' for the year 2019
|
SELECT AVG(usage) FROM water_usage WHERE year = 2019 AND location IN ('Chicago', 'Miami');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE fashion_trends (id INT PRIMARY KEY, size VARCHAR(10), country VARCHAR(20), popularity INT); INSERT INTO fashion_trends (id, size, country, popularity) VALUES (1, 'XS', 'US', 100), (2, 'S', 'US', 500), (3, 'M', 'US', 700);
|
Which size categories in the fashion_trends table are the most popular among customers in the US?
|
SELECT size, MAX(popularity) FROM fashion_trends WHERE country = 'US' GROUP BY size;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE startup (id INT, name TEXT, founder_gender TEXT); INSERT INTO startup (id, name, founder_gender) VALUES (1, 'Ecobnb', 'Male'), (2, 'Ecobnb', 'Female'), (3, 'Babbel', 'Male');
|
How many startups have a diverse founding team (at least two founders with different genders)?
|
SELECT COUNT(*) FROM startup JOIN (SELECT startup_id, COUNT(DISTINCT founder_gender) AS gender_count FROM startup GROUP BY startup_id) AS subquery ON startup.id = subquery.startup_id WHERE gender_count > 1;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Sustainable_Projects (project_id INT, project_name VARCHAR(50), location VARCHAR(50), cost FLOAT); INSERT INTO Sustainable_Projects VALUES (8888, 'Hydroelectric Dam', 'Texas', 12000000);
|
List all sustainable building projects in Texas with a cost greater than $5 million.
|
SELECT project_id, project_name, location, cost FROM Sustainable_Projects WHERE location = 'Texas' AND cost > 5000000;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE sports_teams (team_id INT, team_name VARCHAR(50), stadium VARCHAR(50)); INSERT INTO sports_teams (team_id, team_name, stadium) VALUES (1, 'TeamA', 'StadiumA'), (2, 'TeamB', 'StadiumB'), (3, 'TeamC', 'StadiumC'), (4, 'TeamD', NULL);
|
List the teams that have not hosted any home games
|
SELECT s.team_name FROM sports_teams s WHERE s.stadium IS NULL;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE donors_ext (id INT, name VARCHAR(50), donation_amount DECIMAL(10,2), donation_date DATE, program VARCHAR(50)); INSERT INTO donors_ext (id, name, donation_amount, donation_date, program) VALUES (1, 'Alice', 500.00, '2022-02-01', 'Refugee Support'), (2, 'Bob', 300.00, '2022-03-10', 'Disaster Response');
|
What is the total donation amount per program, ordered by the total donation amount in descending order?
|
SELECT program, SUM(donation_amount) AS total_donation, ROW_NUMBER() OVER (ORDER BY SUM(donation_amount) DESC) AS donation_rank FROM donors_ext GROUP BY program ORDER BY donation_rank;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Donations (donor_id INT, donation_amount DECIMAL(10,2), donation_date DATE, country VARCHAR(50)); INSERT INTO Donations (donor_id, donation_amount, donation_date, country) VALUES (1, 500.00, '2021-09-01', 'USA'), (2, 300.00, '2021-07-15', 'Canada'), (3, 700.00, '2021-10-20', 'Mexico'), (4, 250.00, '2021-06-05', 'USA'), (5, 600.00, '2021-08-30', 'Canada'), (6, 50.00, '2021-05-01', 'Brazil');
|
Delete records with donation amounts less than $100.00
|
DELETE FROM Donations WHERE donation_amount < 100.00;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE influenza_data (id INT, month TEXT, region TEXT, cases INT); INSERT INTO influenza_data (id, month, region, cases) VALUES (1, 'January', 'Region A', 50); INSERT INTO influenza_data (id, month, region, cases) VALUES (2, 'February', 'Region A', 75); INSERT INTO influenza_data (id, month, region, cases) VALUES (3, 'March', 'Region B', 100);
|
What is the number of reported cases of influenza, grouped by month and region?
|
SELECT month, region, SUM(cases) as total_cases FROM influenza_data GROUP BY month, region;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE aquafarms (id INT, name TEXT); INSERT INTO aquafarms (id, name) VALUES (1, 'Farm A'), (2, 'Farm B'), (3, 'Farm C'), (4, 'Farm D'); CREATE TABLE harvest_data (aquafarm_id INT, species TEXT, harvested_quantity INT, timestamp TIMESTAMP);
|
What is the total quantity of fish harvested per month for each species at Farm D?
|
SELECT species, EXTRACT(MONTH FROM timestamp) AS month, SUM(harvested_quantity) AS total_harvested FROM harvest_data JOIN aquafarms ON harvest_data.aquafarm_id = aquafarms.id WHERE aquafarm_id = 4 GROUP BY species, month;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE habitat_animals (animal_id INT, age INT); INSERT INTO habitat_animals (animal_id, age) VALUES (1, 5), (2, 3), (3, 7), (4, 4);
|
What is the average age of animals in the habitat preservation program?
|
SELECT AVG(age) FROM habitat_animals;
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE event_visitors (id INT, event_name VARCHAR(50), year INT, visitor_age INT, visitor_count INT);
|
How many visitors attended cultural events by age group in the last 5 years?
|
SELECT year, FLOOR(visitor_age / 10) * 10 as age_group, SUM(visitor_count) as total_visitors FROM event_visitors WHERE year >= 2017 GROUP BY year, FLOOR(visitor_age / 10);
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE student_mental_health (student_id INT PRIMARY KEY, mental_health_score INT, date_recorded DATE);
|
Insert a new record into the 'student_mental_health' table
|
INSERT INTO student_mental_health (student_id, mental_health_score, date_recorded) VALUES (105, 80, '2022-07-01');
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE species (id INT, name VARCHAR(255), habitat VARCHAR(255), depth FLOAT); INSERT INTO species (id, name, habitat, depth) VALUES (1, 'Clownfish', 'Coral Reef', 20.0); INSERT INTO species (id, name, habitat, depth) VALUES (2, 'Blue Whale', 'Open Ocean', 2000.0); INSERT INTO species (id, name, habitat, depth) VALUES (3, 'Sea Otter', 'Kelp Forest', 50.0); INSERT INTO species (id, name, habitat, depth) VALUES (4, 'Mud Crab', 'Mangrove', 2.0);
|
What is the average depth of mangrove habitats?
|
SELECT AVG(depth) FROM species WHERE habitat = 'Mangrove';
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE Regions (RegionID INT, Region VARCHAR(50)); INSERT INTO Regions (RegionID, Region) VALUES (1, 'Northeast'); INSERT INTO Regions (RegionID, Region) VALUES (2, 'West');
|
Which support programs were offered in a specific region in the past 6 months?
|
SELECT SupportPrograms.ProgramName FROM SupportPrograms INNER JOIN Regions ON SupportPrograms.RegionID = Regions.RegionID WHERE Regions.Region = 'Northeast' AND SupportPrograms.Date BETWEEN DATEADD(month, -6, GETDATE()) AND GETDATE();
|
gretelai_synthetic_text_to_sql
|
CREATE TABLE organization (org_id INT, org_name VARCHAR(255)); INSERT INTO organization VALUES (1, 'University of Washington'), (2, 'Stanford University');CREATE TABLE sub_field (sub_field_id INT, sub_field_name VARCHAR(255)); INSERT INTO sub_field VALUES (1, 'AI Safety'), (2, 'Explainable AI'), (3, 'AI Fairness');CREATE TABLE org_sub_field (org_id INT, sub_field_id INT); INSERT INTO org_sub_field VALUES (1, 1), (1, 2), (2, 1), (2, 3);
|
Identify the number of unique organizations involved in each AI safety sub-field.
|
SELECT s.sub_field_name, COUNT(DISTINCT o.org_id) as num_orgs FROM organization o INNER JOIN org_sub_field osf ON o.org_id = osf.org_id INNER JOIN sub_field s ON osf.sub_field_id = s.sub_field_id WHERE s.sub_field_name LIKE '%AI Safety%' GROUP BY s.sub_field_name;
|
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.