context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
CREATE TABLE courses (course_id INT, teacher_id INT, completion_date DATE); INSERT INTO courses (course_id, teacher_id, completion_date) VALUES (1, 1, '2022-01-01'), (2, 1, '2022-12-31'), (3, 2, '2021-06-15'), (4, 3, '2022-05-05'), (5, 4, '2021-11-22');
What is the maximum number of courses a teacher has completed in a single year?
SELECT MAX(subquery.yearly_courses) FROM (SELECT COUNT(course_id) AS yearly_courses, teacher_id FROM courses WHERE completion_date > DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR) GROUP BY teacher_id) AS subquery;
gretelai_synthetic_text_to_sql
CREATE TABLE missions (mission_id INT, name VARCHAR(100), agency VARCHAR(100), launch_date DATE); INSERT INTO missions (mission_id, name, agency, launch_date) VALUES (1, 'SLV-3', 'ISRO', '1981-05-10'), (2, 'PSLV-C2', 'ISRO', '1994-10-15');
Show all missions conducted by ISRO.
SELECT name FROM missions WHERE agency = 'ISRO';
gretelai_synthetic_text_to_sql
CREATE TABLE Digital_Divide (contributor VARCHAR(50), year INT, impact INT); INSERT INTO Digital_Divide (contributor, year, impact) VALUES ('Income Inequality', 2019, 7), ('Education Disparity', 2019, 6), ('Rural Internet Access', 2019, 5), ('Language Barrier', 2019, 4);
Who are the top 3 contributors to the digital divide in 2019?
SELECT contributor FROM Digital_Divide WHERE year = 2019 ORDER BY impact DESC LIMIT 3;
gretelai_synthetic_text_to_sql
CREATE TABLE sea_surface_temperatures (ocean TEXT, temperature REAL, month TEXT);
What is the maximum sea surface temperature in the Southern Ocean in January?
SELECT MAX(temperature) FROM sea_surface_temperatures WHERE ocean = 'Southern Ocean' AND month = 'January';
gretelai_synthetic_text_to_sql
CREATE TABLE production (country VARCHAR(255), year INT, amount INT); INSERT INTO production (country, year, amount) VALUES ('China', 2020, 140000), ('USA', 2020, 38000), ('Australia', 2020, 20000), ('India', 2020, 5000);
What was the total rare earth element production for each country in 2020?
SELECT country, SUM(amount) AS total_production FROM production GROUP BY country;
gretelai_synthetic_text_to_sql
CREATE TABLE warehouses (warehouse_id varchar(5), warehouse_name varchar(10), location varchar(10)); INSERT INTO warehouses (warehouse_id, warehouse_name, location) VALUES ('NYC', 'New York City', 'NY'); CREATE TABLE inventory (item_code varchar(5), warehouse_id varchar(5), quantity int); INSERT INTO inventory (item_co...
What is the total quantity of item 'A01' in warehouse 'NYC'?
SELECT SUM(quantity) FROM inventory WHERE item_code = 'A01' AND warehouse_id = 'NYC';
gretelai_synthetic_text_to_sql
CREATE TABLE VRHeadsetsSales (SaleID INT, HeadsetModel VARCHAR(50), QuantitySold INT, SaleYear INT); INSERT INTO VRHeadsetsSales (SaleID, HeadsetModel, QuantitySold, SaleYear) VALUES (1, 'Oculus Rift S', 500, 2020); INSERT INTO VRHeadsetsSales (SaleID, HeadsetModel, QuantitySold, SaleYear) VALUES (2, 'HTC Vive Pro', 70...
How many virtual reality headsets were sold in the United States between 2020 and 2021?
SELECT SUM(QuantitySold) FROM VRHeadsetsSales WHERE SaleYear BETWEEN 2020 AND 2021 AND HeadsetModel = 'United States';
gretelai_synthetic_text_to_sql
CREATE TABLE Concerts (id INT, location VARCHAR(255), revenue INT, type VARCHAR(255)); INSERT INTO Concerts (id, location, revenue, type) VALUES (1, 'North America', 1000000, 'Music'), (2, 'Europe', 800000, 'Music'), (3, 'North America', 1200000, 'Sports');
What is the total revenue for music concerts in North America?
SELECT SUM(revenue) FROM Concerts WHERE location = 'North America' AND type = 'Music';
gretelai_synthetic_text_to_sql
CREATE TABLE LocalLibrary (id INT, name VARCHAR(255), visitor_id INT, event_date DATE); INSERT INTO LocalLibrary (id, name, visitor_id, event_date) VALUES (1, 'Local Library', 1, '2023-01-10'), (2, 'Local Library', 2, '2023-01-10'), (3, 'Local Library', 3, '2023-03-15');
How many unique visitors attended events at Local Library in 2023?
SELECT COUNT(DISTINCT visitor_id) FROM LocalLibrary WHERE YEAR(event_date) = 2023;
gretelai_synthetic_text_to_sql
CREATE TABLE clients (id INT, name TEXT, city TEXT); CREATE TABLE transactions (client_id INT, amount DECIMAL(10,2), transaction_time TIMESTAMP); INSERT INTO clients (id, name, city) VALUES (1, 'Eva', 'Berlin'), (2, 'Frank', 'Berlin'); INSERT INTO transactions (client_id, amount, transaction_time) VALUES (1, 400.00, '2...
What is the maximum transaction amount for clients living in 'Berlin' during the month of 'January'?
SELECT MAX(transaction_amount) FROM (SELECT transactions.amount AS transaction_amount FROM clients JOIN transactions ON clients.id = transactions.client_id WHERE clients.city = 'Berlin' AND DATE_TRUNC('month', transactions.transaction_time) = '2022-01-01');
gretelai_synthetic_text_to_sql
CREATE TABLE attorneys (attorney_id INT, age INT, state VARCHAR(2)); INSERT INTO attorneys (attorney_id, age, state) VALUES (1, 35, 'WA'); INSERT INTO attorneys (attorney_id, age, state) VALUES (2, 42, 'WA'); INSERT INTO attorneys (attorney_id, age, state) VALUES (3, 28, 'WA');
What is the minimum age of legal aid attorneys in the state of Washington?
SELECT MIN(age) FROM attorneys WHERE state = 'WA';
gretelai_synthetic_text_to_sql
CREATE TABLE sales (id INT, garment_id INT, size VARCHAR(10), sale_date DATE); INSERT INTO sales (id, garment_id, size, sale_date) VALUES (1, 1002, 'XL', '2021-05-15');
Count the number of size XL garments sold in the last month.
SELECT COUNT(*) FROM sales WHERE size = 'XL' AND sale_date >= DATEADD(month, -1, GETDATE());
gretelai_synthetic_text_to_sql
CREATE TABLE marine_protected_areas_pacific (area_name VARCHAR(255), depth FLOAT); INSERT INTO marine_protected_areas_pacific (area_name, depth) VALUES ('Great Barrier Reef', 10.0), ('Channel Islands National Park', 200.0), ('Monterey Bay National Marine Sanctuary', 400.0);
Display the names of marine protected areas and their corresponding depths in the Pacific Ocean.
SELECT area_name, depth FROM marine_protected_areas_pacific;
gretelai_synthetic_text_to_sql
CREATE TABLE recycling_centers (state VARCHAR(20), num_centers INT); INSERT INTO recycling_centers VALUES ('California', 350);
How many recycling centers are there in the state of California?
SELECT num_centers FROM recycling_centers WHERE state = 'California';
gretelai_synthetic_text_to_sql
CREATE TABLE students (student_id INT, course_id INT, course_completion_date DATE); INSERT INTO students (student_id, course_id, course_completion_date) VALUES (1, 101, '2022-01-01'), (1, 102, '2022-02-01'), (2, 101, '2022-01-15'), (3, 103, '2022-03-01'), (4, 101, '2022-01-05');
What is the lifelong learning progress for each student?
SELECT s.student_id, COUNT(s.course_id) as num_courses_completed, DATEDIFF(MAX(s.course_completion_date), MIN(s.course_completion_date)) as days_since_first_course FROM students s GROUP BY s.student_id;
gretelai_synthetic_text_to_sql
CREATE TABLE CoOwnershipProperties (Id INT, City VARCHAR(50), Value FLOAT); INSERT INTO CoOwnershipProperties (Id, City, Value) VALUES (1, 'Austin', 900000), (2, 'Seattle', 800000), (3, 'Austin', 1000000), (4, 'Portland', 700000);
What is the maximum value of a co-ownership property in Austin, TX?
SELECT MAX(Value) FROM CoOwnershipProperties WHERE City = 'Austin';
gretelai_synthetic_text_to_sql
CREATE TABLE humanitarian_assistance (country VARCHAR(50), resource_type VARCHAR(50), quantity INT); INSERT INTO humanitarian_assistance (country, resource_type, quantity) VALUES (), (), ();
Add a new record to the "humanitarian_assistance" table with the following information: ('Syria', 'food', 15000)
INSERT INTO humanitarian_assistance (country, resource_type, quantity) VALUES ('Syria', 'food', 15000);
gretelai_synthetic_text_to_sql
CREATE TABLE site_safety (site_id INT, site_name TEXT, incident_date DATE, incident_type TEXT, num_injuries INT);
What is the number of workplace injuries reported at each mining site in 2018?
SELECT site_name, SUM(num_injuries) AS total_injuries FROM site_safety WHERE incident_date LIKE '2018-%' AND incident_type = 'Workplace Injury' GROUP BY site_name;
gretelai_synthetic_text_to_sql
CREATE TABLE arctic_points (id INT, point TEXT, lat FLOAT, lon FLOAT); INSERT INTO arctic_points (id, point, lat, lon) VALUES (1, 'North Pole', 90.0, 0.0), (2, 'Cape Morris Jesup', 83.3, -39.7);
What are the coordinates of the Southernmost point in the Arctic Ocean?
SELECT lat, lon FROM arctic_points WHERE point = 'Cape Morris Jesup';
gretelai_synthetic_text_to_sql
CREATE TABLE dmo (id INT, name TEXT, region TEXT); INSERT INTO dmo (id, name, region) VALUES (1, 'Tourism Australia', 'Australia'), (2, 'Japan National Tourism Organization', 'Japan'), (3, 'New Zealand Tourism Board', 'New Zealand');
Which destination marketing organizations are in the Asia-Pacific region?
SELECT name FROM dmo WHERE region = 'Asia-Pacific';
gretelai_synthetic_text_to_sql
CREATE TABLE Donors (DonorID INT, Gender VARCHAR(10), DonationAmount DECIMAL(10,2)); INSERT INTO Donors (DonorID, Gender, DonationAmount) VALUES (1, 'Male', 50.00), (2, 'Female', 75.00), (3, 'Non-binary', 25.00);
What is the total amount of donations by gender?
SELECT Gender, SUM(DonationAmount) as TotalDonation FROM Donors GROUP BY Gender;
gretelai_synthetic_text_to_sql
CREATE TABLE AstronautMedicalData (astronaut_name VARCHAR(30), country VARCHAR(20), age INT, mission_name VARCHAR(30)); INSERT INTO AstronautMedicalData (astronaut_name, country, age, mission_name) VALUES ('James Smith', 'UK', 40, 'Moon Landing'), ('Michael Johnson', 'Canada', 38, 'Moon Landing');
What is the minimum age of astronauts who have traveled to the Moon?
SELECT MIN(age) FROM AstronautMedicalData WHERE mission_name = 'Moon Landing';
gretelai_synthetic_text_to_sql
CREATE TABLE food_resources (id INT, quantity INT, country TEXT, quarter INT, year INT); INSERT INTO food_resources (id, quantity, country, quarter, year) VALUES (1, 500, 'Pakistan', 1, 2022), (2, 600, 'Pakistan', 2, 2022), (3, 700, 'Pakistan', 3, 2022), (4, 800, 'Pakistan', 4, 2022);
How many food resources were distributed in Pakistan in Q1 and Q2 2022?
SELECT SUM(quantity) FROM food_resources WHERE country = 'Pakistan' AND (quarter = 1 OR quarter = 2) AND year = 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE ArticleWordCount (id INT, word_count INT, category VARCHAR(20), newspaper VARCHAR(20)); INSERT INTO ArticleWordCount (id, word_count, category, newspaper) VALUES (1, 500, 'politics', 'WashingtonPost'), (2, 700, 'politics', 'WashingtonPost'), (3, 600, 'technology', 'WashingtonPost');
What is the average word count of articles about politics in the "WashingtonPost"?
SELECT AVG(word_count) FROM ArticleWordCount WHERE category = 'politics' AND newspaper = 'WashingtonPost';
gretelai_synthetic_text_to_sql
CREATE TABLE machines (id INT, model VARCHAR(50), year INT, status VARCHAR(50), maintenance_start_date DATE, maintenance_end_date DATE); INSERT INTO machines (id, model, year, status, maintenance_start_date, maintenance_end_date) VALUES (1, 'CNC Mill', 2015, 'Operational', '2021-02-01', '2021-02-03'); INSERT INTO machi...
Calculate the average maintenance duration for each machine model.
SELECT model, AVG(DATEDIFF(day, maintenance_start_date, maintenance_end_date)) as avg_maintenance_duration FROM machines GROUP BY model;
gretelai_synthetic_text_to_sql
CREATE TABLE Mining_Operations (Mine_ID INT, Material VARCHAR(10), Quantity INT, Date DATE); INSERT INTO Mining_Operations (Mine_ID, Material, Quantity, Date) VALUES (1, 'Gold', 120, '2020-01-01'), (2, 'Silver', 180, '2020-01-02');
What is the total quantity of gold and silver mined in each mine?
SELECT Mine_ID, SUM(CASE WHEN Material IN ('Gold', 'Silver') THEN Quantity ELSE 0 END) FROM Mining_Operations GROUP BY Mine_ID;
gretelai_synthetic_text_to_sql
CREATE TABLE otas (id INT, name TEXT, region TEXT, revenue FLOAT); INSERT INTO otas (id, name, region, revenue) VALUES (1, 'Expedia', 'North America', 5000000), (2, 'Booking.com', 'Europe', 7000000);
What is the total revenue of online travel agencies in 'North America' for the current month?
SELECT SUM(revenue) FROM otas WHERE region = 'North America' AND MONTH(start_date) = MONTH(CURRENT_DATE);
gretelai_synthetic_text_to_sql
CREATE TABLE GamePlayTimes (player_id INT, game_id INT, playtime_hours DECIMAL(5,2), region VARCHAR(255)); INSERT INTO GamePlayTimes (player_id, game_id, playtime_hours, region) VALUES (7, 4, 25.5, 'Africa'), (8, 4, 22.3, 'Africa'), (9, 5, 30.1, 'Africa'), (10, 5, 28.7, 'Africa');
What are the total playtime hours for each game by players in Africa?
SELECT G.game_name, GP.region, SUM(GP.playtime_hours) as total_playtime_hours FROM GamePlayTimes GP JOIN Games G ON GP.game_id = G.game_id GROUP BY G.game_name, GP.region;
gretelai_synthetic_text_to_sql
CREATE TABLE hotels(id INT, name TEXT, city TEXT, rating FLOAT, spa BOOLEAN);CREATE TABLE virtual_tours(hotel_id INT, views INT);
What is the average rating of hotels in 'Paris' that offer 'spa' services, and how many virtual tours have been taken for these hotels?
SELECT AVG(hotels.rating), SUM(virtual_tours.views) FROM hotels INNER JOIN virtual_tours ON hotels.id = virtual_tours.hotel_id WHERE hotels.city = 'Paris' AND hotels.spa = TRUE;
gretelai_synthetic_text_to_sql
CREATE TABLE defense_diplomacy (id INT PRIMARY KEY, participant_1 VARCHAR(50), participant_2 VARCHAR(50), year INT, agreement VARCHAR(50));
Delete all records from the 'defense_diplomacy' table where 'participant_2' is 'Mexico'
WITH cte AS (DELETE FROM defense_diplomacy WHERE participant_2 = 'Mexico' RETURNING *) INSERT INTO defense_diplomacy SELECT * FROM cte;
gretelai_synthetic_text_to_sql
CREATE TABLE bike_sharing_systems (bike_id INT, trip_id INT, trip_start_time TIMESTAMP, trip_end_time TIMESTAMP, start_location TEXT, end_location TEXT, city TEXT, daily_usage INT);
What is the daily usage of bike-sharing systems in Seoul, South Korea?
SELECT SUM(daily_usage) FROM bike_sharing_systems WHERE city = 'Seoul';
gretelai_synthetic_text_to_sql
CREATE TABLE infrastructure_projects (id INT, project_name VARCHAR(50), location VARCHAR(50), budget DECIMAL(10,2), year INT); INSERT INTO infrastructure_projects (id, project_name, location, budget, year) VALUES (1, 'Highway 101 Expansion', 'California', 5000000, 2022), (2, 'Bridge Replacement', 'New York', 3000000, 2...
What is the total budget for infrastructure projects in 2023?
SELECT SUM(budget) as total_budget FROM infrastructure_projects WHERE year = 2023;
gretelai_synthetic_text_to_sql
CREATE TABLE Autonomous_Driving_Tests (id INT, vehicle_model VARCHAR(50), test_location VARCHAR(50), year INT);
List the number of autonomous driving research tests conducted in each country.
SELECT test_location, COUNT(*) FROM Autonomous_Driving_Tests GROUP BY test_location;
gretelai_synthetic_text_to_sql
CREATE TABLE schools_3 (name VARCHAR(255), state VARCHAR(255), population DECIMAL(10,2), schools DECIMAL(5,2)); INSERT INTO schools_3 (name, state, population, schools) VALUES ('School4', 'California', 39512223, 31540), ('School5', 'Texas', 29528404, 22120), ('School6', 'Florida', 21644287, 18350);
Show the top 2 states with the most public schools per capita.
SELECT state, (schools / population) AS schools_per_capita FROM schools_3 ORDER BY schools_per_capita DESC LIMIT 2;
gretelai_synthetic_text_to_sql
CREATE TABLE Warehouses (id INT PRIMARY KEY, name VARCHAR(255), location VARCHAR(255)); CREATE TABLE Freights (id INT PRIMARY KEY, warehouse_id INT, status VARCHAR(255), quantity INT, pickup_date DATETIME); CREATE VIEW PendingFreights AS SELECT * FROM Freights WHERE status = 'pending';
What is the total quantity of pending freights in 'TX' warehouses?
SELECT SUM(quantity) as total_quantity FROM PendingFreights p INNER JOIN Warehouses w ON p.warehouse_id = w.id WHERE w.location = 'TX';
gretelai_synthetic_text_to_sql
CREATE TABLE ethical_ai_projects (id INT, project_name TEXT, completion_year INT); INSERT INTO ethical_ai_projects (id, project_name, completion_year) VALUES (1, 'AI Ethics Framework', 2021), (2, 'Fair AI Algorithms', 2020), (3, 'AI Ethics Guidelines', 2021), (4, 'Transparent AI Systems', 2022);
How many ethical AI projects were completed in 2021?
SELECT COUNT(*) FROM ethical_ai_projects WHERE completion_year = 2021;
gretelai_synthetic_text_to_sql
CREATE TABLE carbon_price (date DATE, region VARCHAR(20), price FLOAT); INSERT INTO carbon_price (date, region, price) VALUES ('2022-01-01', 'European Union', 25.0), ('2022-02-01', 'European Union', 26.5);
What is the average carbon price in the European Union for the past year?
SELECT AVG(price) FROM carbon_price WHERE region = 'European Union' AND date BETWEEN DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR) AND CURRENT_DATE;
gretelai_synthetic_text_to_sql
CREATE TABLE skorea_cultural_heritage (id INT, year INT, num_sites INT); INSERT INTO skorea_cultural_heritage (id, year, num_sites) VALUES (1, 2021, 30), (2, 2022, 40);
How many cultural heritage sites were preserved in South Korea in the year 2021 and 2022?
SELECT SUM(num_sites) FROM skorea_cultural_heritage WHERE year IN (2021, 2022);
gretelai_synthetic_text_to_sql
CREATE TABLE SecurityIncidents (IncidentID INT, Region VARCHAR(255), Year INT, IncidentCount INT); INSERT INTO SecurityIncidents (IncidentID, Region, Year, IncidentCount) VALUES (3, 'APAC', 2022, 55); INSERT INTO SecurityIncidents (IncidentID, Region, Year, IncidentCount) VALUES (4, 'EMEA', 2022, 65);
How many security incidents were reported in the EMEA region in 2022?
SELECT SUM(IncidentCount) FROM SecurityIncidents WHERE Region = 'EMEA' AND Year = 2022;
gretelai_synthetic_text_to_sql
CREATE TABLE AircraftManufacturing(id INT, manufacturer VARCHAR(255), model VARCHAR(255), delivery_date DATE); INSERT INTO AircraftManufacturing(id, manufacturer, model, delivery_date) VALUES (1, 'Boeing', '737', '2020-03-15'), (2, 'Airbus', 'A320', '2019-12-28'), (3, 'Boeing', '787', '2020-08-12'), (4, 'Boeing', '777'...
What is the total number of aircrafts manufactured by Boeing with delivery date in 2020?
SELECT COUNT(*) FROM AircraftManufacturing WHERE manufacturer = 'Boeing' AND YEAR(delivery_date) = 2020;
gretelai_synthetic_text_to_sql
CREATE TABLE JobOpenings (OpeningID INT, Position VARCHAR(50), Department VARCHAR(50), TotalApplicants INT); INSERT INTO JobOpenings (OpeningID, Position, Department, TotalApplicants) VALUES (1, 'Developer', 'IT', 75), (2, 'Manager', 'HR', 30), (3, 'Designer', 'Marketing', 60), (4, 'Analyst', 'Finance', 45);
How many applicants were there for each job opening, and which openings had more than 50 applicants?
SELECT OpeningID, Position, Department, TotalApplicants FROM JobOpenings WHERE TotalApplicants > 50;
gretelai_synthetic_text_to_sql
CREATE TABLE sales (id INT PRIMARY KEY, garment_id INT, size VARCHAR(10), quantity INT, date DATE); INSERT INTO sales (id, garment_id, size, quantity, date) VALUES (1, 1, 'S', 10, '2021-01-01'); INSERT INTO sales (id, garment_id, size, quantity, date) VALUES (2, 1, 'M', 15, '2021-01-01'); INSERT INTO sales (id, garment...
What is the average quantity of size XL garments sold?
SELECT size, AVG(quantity) FROM sales WHERE size = 'XL';
gretelai_synthetic_text_to_sql
CREATE TABLE research_funding (id INT, year INT, area VARCHAR(50), amount FLOAT);INSERT INTO research_funding (id, year, area, amount) VALUES (1, 2020, 'Astrobiology', 150000000.0);
What was the combined funding for astrobiology research in 2020?
SELECT SUM(amount) FROM research_funding WHERE year = 2020 AND area = 'Astrobiology';
gretelai_synthetic_text_to_sql
CREATE TABLE tools_usage (id INT, tool_name VARCHAR(255), usage_date DATE); INSERT INTO tools_usage (id, tool_name, usage_date) VALUES (1, 'Tableau', '2022-01-01'), (2, 'PowerBI', '2022-01-05'), (3, 'Jupyter Notebook', '2022-01-07'), (4, 'Tableau', '2022-01-10'), (5, 'Jupyter Notebook', '2022-01-15'), (6, 'Google Colab...
Count the number of unique exploratory data analysis tools used in the past month
SELECT COUNT(DISTINCT tool_name) FROM tools_usage WHERE usage_date >= NOW() - INTERVAL 1 MONTH;
gretelai_synthetic_text_to_sql
CREATE TABLE cases (case_id INT, attorney_id INT, billing_date DATE, billing_amount DECIMAL(10, 2)); INSERT INTO cases (case_id, attorney_id, billing_date, billing_amount) VALUES (1, 6, '2021-01-01', 5000.00), (2, 6, '2021-02-01', 7000.00), (3, 7, '2021-03-01', 3000.00); CREATE TABLE attorneys (attorney_id INT, name VA...
What is the total billing amount for cases handled by attorney Olivia Lee?
SELECT SUM(billing_amount) FROM cases JOIN attorneys ON cases.attorney_id = attorneys.attorney_id WHERE attorneys.name = 'Olivia Lee';
gretelai_synthetic_text_to_sql
CREATE TABLE vehicle_models (model_id INT, make VARCHAR(20), model VARCHAR(30), release_year INT); INSERT INTO vehicle_models (model_id, make, model, release_year) VALUES (1, 'Tesla', 'Model S', 2012), (2, 'Tesla', 'Model X', 2015), (3, 'Rivian', 'R1T', 2019), (4, 'Rivian', 'R1S', 2020);
Find the number of electric vehicle models released each year, in the 'vehicle_models' table.
SELECT EXTRACT(YEAR FROM release_year) release_year, COUNT(*) models_per_year FROM vehicle_models GROUP BY release_year ORDER BY release_year;
gretelai_synthetic_text_to_sql
CREATE TABLE Algorithms (AlgorithmId INT, Name TEXT, FairnessScore FLOAT, Year INT, Country TEXT); INSERT INTO Algorithms (AlgorithmId, Name, FairnessScore, Year, Country) VALUES (1, 'AlgorithmA', 0.9, 2017, 'Germany'), (2, 'AlgorithmB', 0.8, 2019, 'France'), (3, 'AlgorithmC', 0.95, 2015, 'UK');
What is the maximum fairness score of all algorithms created in Europe before 2018?
SELECT MAX(FairnessScore) FROM Algorithms WHERE Country = 'Europe' AND Year < 2018;
gretelai_synthetic_text_to_sql
CREATE TABLE Menu (id INT, item_name VARCHAR(20), item_type VARCHAR(10), price DECIMAL(10,2), region VARCHAR(10)); INSERT INTO Menu (id, item_name, item_type, price, region) VALUES (1, 'Vegan Burger', 'entrée', 12.99, 'New York'), (2, 'Chicken Salad', 'entrée', 15.99, 'Los Angeles');
What is the average price of vegan entrées in the New York region?
SELECT AVG(price) FROM Menu WHERE item_type = 'entrée' AND region = 'New York' AND item_name LIKE '%vegan%';
gretelai_synthetic_text_to_sql
CREATE TABLE healthcare_providers (id INT, name TEXT, type TEXT, services TEXT);
Find the number of rural healthcare providers that offer mental health services, grouped by provider type.
SELECT type, COUNT(*) FROM healthcare_providers WHERE services LIKE '%Mental Health%' GROUP BY type;
gretelai_synthetic_text_to_sql
CREATE TABLE Arts_Preservation (Art_ID INT PRIMARY KEY, Art_Name VARCHAR(100), Type VARCHAR(50), Origin_Country VARCHAR(50), Preservation_Status VARCHAR(50)); INSERT INTO Arts_Preservation (Art_ID, Art_Name, Type, Origin_Country, Preservation_Status) VALUES (4, 'Kapa Haka', 'Performing Arts', 'New Zealand', 'Stable');
What are the names and types of arts from New Zealand?
SELECT Art_Name, Type FROM Arts_Preservation WHERE Origin_Country = 'New Zealand';
gretelai_synthetic_text_to_sql
CREATE TABLE community_education (id INT PRIMARY KEY, program_name VARCHAR(255), description TEXT, target_audience VARCHAR(255));
Delete the Save the Manatee program from the 'community_education' table
DELETE FROM community_education WHERE program_name = 'Save the Manatee';
gretelai_synthetic_text_to_sql
CREATE TABLE teachers_pd (teacher_id INT, subject_area TEXT, last_pd_program_date DATE); INSERT INTO teachers_pd (teacher_id, subject_area, last_pd_program_date) VALUES (1, 'Math', '2020-01-01'), (2, 'Science', '2019-06-15'), (3, 'English', '2021-02-20');
How many teachers have not participated in any professional development programs in the last 2 years, grouped by subject area?
SELECT subject_area, COUNT(*) FROM teachers_pd WHERE last_pd_program_date < DATE_SUB(CURRENT_DATE, INTERVAL 2 YEAR) GROUP BY subject_area HAVING COUNT(*) = (SELECT COUNT(*) FROM teachers_pd WHERE teachers_pd.teacher_id = teacher_id);
gretelai_synthetic_text_to_sql
CREATE TABLE mining_sites (site_id INT, site_name TEXT, location TEXT); CREATE TABLE environmental_impact (site_id INT, site_name TEXT, ei_score FLOAT); INSERT INTO mining_sites (site_id, site_name, location) VALUES (1, 'Site A', 'Country X'), (2, 'Site B', 'Country Y'); INSERT INTO environmental_impact (site_id, site_...
Insert new records for mining sites in Country Z, with Site E and Site F having environmental impact scores of 65 and 90 respectively.
INSERT INTO mining_sites (site_id, site_name, location) VALUES (5, 'Site E', 'Country Z'), (6, 'Site F', 'Country Z'); INSERT INTO environmental_impact (site_id, site_name, ei_score) VALUES (5, 'Site E', 65), (6, 'Site F', 90);
gretelai_synthetic_text_to_sql
CREATE TABLE user_registrations (registration_id INT, user_id INT, registration_date DATE);
Display the number of users who registered for each day of the week
SELECT DATEPART(dw, registration_date) AS day_of_week, COUNT(DISTINCT user_id) AS num_users FROM user_registrations GROUP BY day_of_week;
gretelai_synthetic_text_to_sql
CREATE TABLE countries (country_id INT, country VARCHAR(255)); CREATE TABLE users (user_id INT, user_country VARCHAR(255)); CREATE TABLE songs (song_id INT, title VARCHAR(255), genre_id INT, release_date DATE); CREATE TABLE streams (stream_id INT, song_id INT, user_id INT, stream_date DATE);
Find the number of unique users who have streamed a song from each country.
SELECT cu.country, COUNT(DISTINCT st.user_id) as unique_users FROM countries cu JOIN users u ON cu.country = u.user_country JOIN streams st ON u.user_id = st.user_id GROUP BY cu.country;
gretelai_synthetic_text_to_sql
CREATE TABLE Artists (id INT, name VARCHAR(100)); CREATE TABLE Songs (id INT, artist_id INT, title VARCHAR(100), release_year INT, genre VARCHAR(50), streams INT);
How many songs were released by each artist in the 'Hip Hop' genre?
SELECT Artists.name, COUNT(*) FROM Artists JOIN Songs ON Artists.id = Songs.artist_id WHERE genre = 'Hip Hop' GROUP BY Artists.name;
gretelai_synthetic_text_to_sql
CREATE TABLE crops (id INT PRIMARY KEY, name VARCHAR(50), yield INT, country VARCHAR(50)); INSERT INTO crops (id, name, yield, country) VALUES (1, 'Rice', 7500, 'China'), (2, 'Cotton', 1000, 'Turkey'), (3, 'Wheat', 2600, 'India');
Update 'Yield' of 'Cotton' in 'Turkey' to 1200?
UPDATE crops SET yield = 1200 WHERE name = 'Cotton' AND country = 'Turkey';
gretelai_synthetic_text_to_sql
CREATE TABLE restaurants (restaurant_id INT, name TEXT, region TEXT); INSERT INTO restaurants (restaurant_id, name, region) VALUES (1, 'Big Burger', 'East'), (2, 'Veggies R Us', 'Midwest'), (3, 'Tasty Bites', 'West'); CREATE TABLE orders (order_id INT, dish TEXT, customer_id INT, restaurant_id INT); INSERT INTO orders ...
List the total quantity of vegan and vegetarian dishes sold in each region.
SELECT r.region, SUM(CASE WHEN m.is_vegan = true THEN 1 ELSE 0 END) as vegan_quantity, SUM(CASE WHEN m.is_vegetarian = true THEN 1 ELSE 0 END) as vegetarian_quantity FROM orders o JOIN restaurants r ON o.restaurant_id = r.restaurant_id JOIN menu_items m ON o.dish = m.name GROUP BY r.region;
gretelai_synthetic_text_to_sql
CREATE TABLE HeritageSites (id INT, name VARCHAR(50), country VARCHAR(50), is_unesco BOOLEAN); CREATE TABLE ArtPieces (id INT, site_id INT, art VARCHAR(50));
What is the total number of traditional art pieces in each country, excluding those from UNESCO-designated sites?
SELECT H.country, COUNT(AP.id) as total_art_pieces FROM HeritageSites H INNER JOIN ArtPieces AP ON H.id = AP.site_id WHERE NOT H.is_unesco GROUP BY H.country;
gretelai_synthetic_text_to_sql
CREATE TABLE attendee_demographics (attendee_id INT, attendee_name VARCHAR(50), attendee_age INT); INSERT INTO attendee_demographics (attendee_id, attendee_name, attendee_age) VALUES (1, 'Jane Smith', 25), (2, 'Michael Johnson', 17), (3, 'Sophia Rodriguez', 16); CREATE TABLE event_attendance (attendee_id INT, event_nam...
How many attendees under the age of 18 attended 'Art' events?
SELECT COUNT(*) FROM attendee_demographics ad JOIN event_attendance ea ON ad.attendee_id = ea.attendee_id WHERE attendee_age < 18 AND (event_name = 'Art Exhibit' OR event_name = 'Art Workshop');
gretelai_synthetic_text_to_sql
CREATE TABLE Performances (id INT, name VARCHAR(50), date DATE, duration INT); INSERT INTO Performances (id, name, date, duration) VALUES (1, 'Play', '2020-01-01', 30);
What is the number of performances in the 'Performances' table with a duration of exactly 30 minutes?
SELECT COUNT(*) FROM Performances WHERE duration = 30;
gretelai_synthetic_text_to_sql
CREATE TABLE regions (id INT, name TEXT); INSERT INTO regions (id, name) VALUES (1, 'North America'), (2, 'South America'), (3, 'Europe'), (4, 'Asia'), (5, 'Africa'); CREATE TABLE products (id INT, name TEXT, is_organic BOOLEAN, price DECIMAL(5, 2)); INSERT INTO products (id, name, is_organic, price) VALUES (1, 'Produc...
What is the average price of organic products in North America?
SELECT AVG(products.price) FROM products INNER JOIN sales ON products.name = sales.product INNER JOIN regions ON sales.region = regions.name WHERE products.is_organic = true AND regions.name = 'North America';
gretelai_synthetic_text_to_sql
CREATE TABLE Teams (TeamID INT, TeamName VARCHAR(50)); INSERT INTO Teams VALUES (1, 'Red Sox'), (2, 'Yankees'); CREATE TABLE Games (GameID INT, TeamID INT, HomeAway VARCHAR(5), Attendance INT); INSERT INTO Games VALUES (1, 1, 'Home', 20000), (2, 1, 'Away', 15000), (3, 2, 'Home', 35000), (4, 2, 'Away', 30000), (5, 1, 'H...
What is the average attendance for home games?
SELECT TeamID, AVG(Attendance) AS AvgHomeAttendance FROM Games WHERE HomeAway = 'Home' GROUP BY TeamID;
gretelai_synthetic_text_to_sql
CREATE TABLE investments (id INT, client_name VARCHAR(50), country VARCHAR(50), type VARCHAR(50), value DECIMAL(10,2), date DATE); INSERT INTO investments (id, client_name, country, type, value, date) VALUES (1, 'Ali', 'Egypt', 'stocks', 12000, '2022-01-01'); CREATE TABLE donations (id INT, client_name VARCHAR(50), cou...
What is the total number of clients that have made investments or donations in Egypt?
SELECT client_name FROM investments WHERE country = 'Egypt' UNION SELECT client_name FROM donations WHERE country = 'Egypt';
gretelai_synthetic_text_to_sql
CREATE TABLE cuisine (id INT, type VARCHAR(50), calories INT); INSERT INTO cuisine (id, type, calories) VALUES (1, 'Italian', 500), (2, 'Mexican', 600), (3, 'Japanese', 400);
Find the top 2 cuisine types with the highest calorie content?
SELECT type, calories, ROW_NUMBER() OVER (ORDER BY calories DESC) as rank FROM cuisine WHERE rank <= 2;
gretelai_synthetic_text_to_sql
CREATE TABLE Artworks (id INT, title VARCHAR(50), artist_nationality VARCHAR(50), collection VARCHAR(50)); CREATE TABLE Collections (id INT, name VARCHAR(50), continent VARCHAR(50));
What is the total number of artworks in our collection from each continent?
SELECT Collections.continent, COUNT(Artworks.id) as artwork_count FROM Artworks INNER JOIN Collections ON Artworks.collection = Collections.name GROUP BY Collections.continent;
gretelai_synthetic_text_to_sql
CREATE TABLE cyber_incidents (id INT, incident_date DATE, description VARCHAR(255)); INSERT INTO cyber_incidents (id, incident_date, description) VALUES (1, '2022-01-01', 'Phishing attack'), (2, '2022-03-15', 'Ransomware attack'), (3, '2022-04-20', 'Data breach'), (4, '2022-06-05', 'Malware attack');
What are the cybersecurity incidents reported in the last 6 months?
SELECT description, incident_date FROM cyber_incidents WHERE incident_date >= DATE(NOW()) - INTERVAL 6 MONTH;
gretelai_synthetic_text_to_sql
CREATE TABLE suppliers (supplier_id INT, supplier_name TEXT, quantity_sold INT);CREATE TABLE inventory (product_id INT, product_name TEXT, category TEXT, is_organic BOOLEAN);INSERT INTO suppliers VALUES (1, 'Supplier A', 2000), (2, 'Supplier B', 1500), (3, 'Supplier C', 1200), (4, 'Supplier D', 800);INSERT INTO invento...
Identify the non-organic products that are not supplied by any of the top 3 suppliers in terms of quantity sold.
SELECT product_name FROM inventory WHERE NOT EXISTS (SELECT 1 FROM (SELECT supplier_id, SUM(quantity_sold) AS total_quantity FROM suppliers GROUP BY supplier_id LIMIT 3) AS top_suppliers INNER JOIN inventory ON TRUE WHERE is_organic = FALSE AND NOT (supplier_id = ANY(top_suppliers.supplier_id))) AND is_organic = FALSE;
gretelai_synthetic_text_to_sql
CREATE TABLE military_equipment (id INT PRIMARY KEY, name VARCHAR(255), type VARCHAR(255), manufacturer VARCHAR(255), year INT, country VARCHAR(255)); INSERT INTO military_equipment (id, name, type, manufacturer, year, country) VALUES (1, 'M1 Abrams', 'Tank', 'General Dynamics', 1980, 'USA'), (2, 'F-15 Eagle', 'Fighter...
Select all fighter aircraft from 'military_equipment' table
SELECT * FROM military_equipment WHERE type = 'Fighter';
gretelai_synthetic_text_to_sql
CREATE TABLE TV_Shows (id INT, title VARCHAR(100), country VARCHAR(50), views INT);
Top 5 most viewed TV shows in Canada?
SELECT title, views FROM TV_Shows WHERE country = 'Canada' ORDER BY views DESC LIMIT 5;
gretelai_synthetic_text_to_sql
CREATE TABLE mental_health_parity (id INT, violation_date DATE, location TEXT); INSERT INTO mental_health_parity (id, violation_date, location) VALUES (1, '2021-01-01', 'Texas'); INSERT INTO mental_health_parity (id, violation_date, location) VALUES (2, '2021-02-01', 'California');
How many mental health parity violations were reported in Texas in 2021?
SELECT COUNT(*) FROM mental_health_parity WHERE violation_date >= '2021-01-01' AND violation_date < '2022-01-01' AND location = 'Texas';
gretelai_synthetic_text_to_sql
CREATE TABLE hotels (hotel_id INT, name TEXT, city TEXT, country TEXT, rating FLOAT); INSERT INTO hotels (hotel_id, name, city, country, rating) VALUES (1, 'Hotel Ritz', 'Paris', 'France', 4.6), (2, 'Hotel de Crillon', 'Paris', 'France', 4.8);
What is the average rating of hotels in 'Paris', France?
SELECT AVG(rating) FROM hotels WHERE city = 'Paris' AND country = 'France';
gretelai_synthetic_text_to_sql
CREATE TABLE trawlers (id INT, name VARCHAR(50)); CREATE TABLE catch (trawler_id INT, date DATE, species VARCHAR(50), quantity INT, price FLOAT); INSERT INTO trawlers VALUES (1, 'North Sea Trawler 1'), (2, 'North Sea Trawler 2'), (3, 'North Sea Trawler 3'); INSERT INTO catch VALUES (1, '2021-01-01', 'Cod', 1000, 4), (1...
List the number of fish caught and total revenue for each trawler in the North Sea during 2021.
SELECT t.name, COUNT(c.trawler_id) as catches, SUM(c.quantity * c.price) as revenue FROM trawlers t INNER JOIN catch c ON t.id = c.trawler_id WHERE YEAR(c.date) = 2021 GROUP BY t.id;
gretelai_synthetic_text_to_sql
CREATE TABLE marine_conservation_laws (id INT PRIMARY KEY, law_name VARCHAR(255), region VARCHAR(255)); INSERT INTO marine_conservation_laws (id, law_name, region) VALUES (1, 'Mediterranean Marine Conservation Act', 'Mediterranean Sea');
Update the marine conservation law in the Mediterranean Sea
UPDATE marine_conservation_laws SET law_name = 'Updated Mediterranean Marine Conservation Act' WHERE region = 'Mediterranean Sea';
gretelai_synthetic_text_to_sql
CREATE TABLE green_buildings_canada (id INT, city VARCHAR(255), energy_consumption FLOAT); INSERT INTO green_buildings_canada (id, city, energy_consumption) VALUES (1, 'Toronto', 3000), (2, 'Toronto', 3500), (3, 'Vancouver', 4000);
Calculate the total energy consumption of green buildings in each city in Canada.
SELECT city, SUM(energy_consumption) FROM green_buildings_canada GROUP BY city;
gretelai_synthetic_text_to_sql
CREATE TABLE Projects (project_id INT, project_name VARCHAR(100), state VARCHAR(100), completion_date DATE);
Which renewable energy projects have been completed in the state of Colorado since January 1, 2020?
SELECT project_name FROM Projects WHERE state = 'Colorado' AND completion_date >= '2020-01-01';
gretelai_synthetic_text_to_sql
CREATE TABLE hotel_revenue (hotel_name VARCHAR(20), revenue DECIMAL(10,2), revenue_date DATE); INSERT INTO hotel_revenue (hotel_name, revenue, revenue_date) VALUES ('Hotel A', 15000, '2022-01-01'), ('Hotel A', 16000, '2022-02-01'), ('Hotel A', 18000, '2022-03-01');
What is the monthly revenue trend for a specific hotel in 2022?
SELECT revenue_date, SUM(revenue) as monthly_revenue FROM hotel_revenue WHERE hotel_name = 'Hotel A' AND revenue_date BETWEEN '2022-01-01' AND '2022-12-31' GROUP BY EXTRACT(MONTH FROM revenue_date);
gretelai_synthetic_text_to_sql
CREATE TABLE donations (id INT, nonprofit_id INT, amount FLOAT, donation_date DATE); INSERT INTO donations (id, nonprofit_id, amount, donation_date) VALUES (1, 1, 500, '2022-03-15'), (2, 2, 1000, '2022-03-20'), (3, 1, 750, '2022-03-25'); CREATE TABLE nonprofit_ratings (id INT, nonprofit_id INT, rating INT); INSERT INTO...
What is the average rating for nonprofits that have received donations in the last month?
SELECT nonprofit_id, AVG(rating) FROM nonprofit_ratings JOIN (SELECT nonprofit_id FROM donations WHERE donation_date BETWEEN DATEADD(day, -30, GETDATE()) AND GETDATE() GROUP BY nonprofit_id) AS last_month_donors ON nonprofit_ratings.nonprofit_id = last_month_donors.nonprofit_id GROUP BY nonprofit_id;
gretelai_synthetic_text_to_sql
CREATE TABLE pollution_history (id INT, region TEXT, incident_date DATE); INSERT INTO pollution_history (id, region, incident_date) VALUES (1, 'Atlantic', '2021-01-10'), (2, 'Pacific', '2021-02-15'), (3, 'Indian', '2021-03-05');
What is the earliest pollution incident in each ocean region?
SELECT region, MIN(incident_date) earliest_date FROM pollution_history GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE donors (id INT, name TEXT, country TEXT, amount_donated DECIMAL(10,2)); INSERT INTO donors (id, name, country, amount_donated) VALUES (1, 'Alice', 'United States', 5000.00), (2, 'Bob', 'Canada', 6000.00);
Delete the record for the donor from Canada.
DELETE FROM donors WHERE country = 'Canada';
gretelai_synthetic_text_to_sql
CREATE TABLE artists (artist_id INT, last_release_date DATE); INSERT INTO artists (artist_id, last_release_date) VALUES (1, '2018-03-15'), (2, '2016-07-27'), (3, '2014-09-01'), (4, '2020-11-29'), (5, '2010-05-05');
Delete all records of artists who have not released any music in the last 5 years.
DELETE FROM artists WHERE last_release_date < DATE_SUB(CURRENT_DATE, INTERVAL 5 YEAR);
gretelai_synthetic_text_to_sql
CREATE TABLE donors (id INT, name TEXT, total_donated_amount FLOAT); CREATE TABLE donations (id INT, donor_id INT, organization_id INT, donation_amount FLOAT); CREATE TABLE organizations (id INT, name TEXT, cause_area TEXT);
What's the percentage of total donations made by the top 5 donors, categorized by cause area?
SELECT o.cause_area, SUM(donations.donation_amount) as total_donations, (SUM(donations.donation_amount) / (SELECT SUM(donations.donation_amount) FROM donations)) * 100 as percentage_of_total_donations FROM donations INNER JOIN organizations o ON donations.organization_id = o.id INNER JOIN (SELECT id, total_donated_amou...
gretelai_synthetic_text_to_sql
CREATE TABLE bookings (id INT, hotel_id INT, date DATE); CREATE TABLE hotels (id INT, name TEXT, city TEXT); INSERT INTO hotels (id, name, city) VALUES (1, 'Hotel Ritz', 'London'), (2, 'Hotel George V', 'London'), (3, 'Hotel Plaza', 'London'); INSERT INTO bookings (id, hotel_id, date) VALUES (1, 1, '2022-01-01'), (2, 1...
What is the most popular hotel in 'London'?
SELECT hotels.name, COUNT(bookings.id) AS num_bookings FROM hotels INNER JOIN bookings ON hotels.id = bookings.hotel_id WHERE hotels.city = 'London' GROUP BY hotels.name ORDER BY num_bookings DESC LIMIT 1;
gretelai_synthetic_text_to_sql
CREATE TABLE mental_health_parity_officers (officer_id INT, name VARCHAR(50), department VARCHAR(50)); INSERT INTO mental_health_parity_officers (officer_id, name, department) VALUES (1, 'Alice Johnson', 'Compliance'); INSERT INTO mental_health_parity_officers (officer_id, name, department) VALUES (2, 'Bob Brown', 'Leg...
List the departments of mental health parity officers and the number of officers in each department in the mental_health schema.
SELECT department, COUNT(*) FROM mental_health.mental_health_parity_officers GROUP BY department;
gretelai_synthetic_text_to_sql
CREATE TABLE EquipmentTypes (id INT, equipment VARCHAR(50));CREATE TABLE ProjectTimelines (id INT, equipment VARCHAR(50), start_year INT, end_year INT);CREATE TABLE ProjectCountries (id INT, project_id INT, country VARCHAR(50));
Which military equipment types are part of defense projects with timelines extending into 2025, and for which countries are these projects?
SELECT EquipmentTypes.equipment, ProjectCountries.country FROM EquipmentTypes INNER JOIN ProjectTimelines ON EquipmentTypes.equipment = ProjectTimelines.equipment INNER JOIN ProjectCountries ON ProjectTimelines.id = ProjectCountries.project_id WHERE ProjectTimelines.end_year >= 2025;
gretelai_synthetic_text_to_sql
CREATE TABLE Players (PlayerID int, Name varchar(50), Age int, Gender varchar(10)); INSERT INTO Players (PlayerID, Name, Age, Gender) VALUES (1, 'John Doe', 25, 'Male'), (2, 'Jane Smith', 30, 'Female'), (3, 'Alex Johnson', 22, 'Non-binary');
Delete records of players who have not played any games
DELETE FROM Players WHERE PlayerID NOT IN (SELECT DISTINCT PlayerID FROM Games);
gretelai_synthetic_text_to_sql
CREATE TABLE countries (id INT, name VARCHAR(50), num_orgs INT); INSERT INTO countries (id, name, num_orgs) VALUES (1, 'Germany', 7), (2, 'France', 8), (3, 'Spain', 9);
List the countries with the highest number of organizations involved in ethical AI.
SELECT name FROM countries WHERE num_orgs = (SELECT MAX(num_orgs) FROM countries WHERE name LIKE '%ethical AI%');
gretelai_synthetic_text_to_sql
CREATE TABLE Healthcare_Providers (ID INT, Name TEXT, Gender TEXT, Specialty TEXT); INSERT INTO Healthcare_Providers (ID, Name, Gender, Specialty) VALUES (1, 'Dr. A', 'Male', 'Surgeon'); INSERT INTO Healthcare_Providers (ID, Name, Gender, Specialty) VALUES (2, 'Dr. B', 'Female', 'Anesthesiologist');
What is the distribution of healthcare providers by gender, excluding surgeons and anesthesiologists?
SELECT Gender, COUNT(*) FROM Healthcare_Providers WHERE Specialty NOT IN ('Surgeon', 'Anesthesiologist') GROUP BY Gender;
gretelai_synthetic_text_to_sql
CREATE TABLE accident_type (accident_type_id INT, accident_type_name VARCHAR(255)); INSERT INTO accident_type (accident_type_id, accident_type_name) VALUES (1, 'AccidentTypeA'), (2, 'AccidentTypeB'); CREATE TABLE accidents (accident_type_id INT, number INT); INSERT INTO accidents (accident_type_id, number) VALUES (1, 5...
What is the total number of accidents for each type?
SELECT accident_type_id, SUM(number) as total_accidents FROM accidents GROUP BY accident_type_id
gretelai_synthetic_text_to_sql
CREATE TABLE funding_allocation (project_name VARCHAR(255), funding_year INT, funding_quarter INT, amount INT); INSERT INTO funding_allocation (project_name, funding_year, funding_quarter, amount) VALUES ('Precision Agriculture', 2020, 3, 500000), ('Smart Irrigation', 2019, 4, 400000);
How many agricultural innovation projects were funded in each quarter in the 'funding_allocation' table?
SELECT funding_year, funding_quarter, COUNT(*) FROM funding_allocation GROUP BY funding_year, funding_quarter;
gretelai_synthetic_text_to_sql
CREATE TABLE PolicyStateCount (State TEXT, PolicyCount INT); INSERT INTO PolicyStateCount (State, PolicyCount) VALUES ('California', 400); INSERT INTO PolicyStateCount (State, PolicyCount) VALUES ('Texas', 350); INSERT INTO PolicyStateCount (State, PolicyCount) VALUES ('Florida', 300); INSERT INTO PolicyStateCount (Sta...
What are the top 3 states with the most policies?
SELECT State, PolicyCount FROM (SELECT State, PolicyCount, ROW_NUMBER() OVER (ORDER BY PolicyCount DESC) as row FROM PolicyStateCount) as t WHERE row <= 3;
gretelai_synthetic_text_to_sql
CREATE TABLE ExplorationData (WellID int, ExplorationDate date, DrillingCosts decimal(10, 2)); INSERT INTO ExplorationData (WellID, ExplorationDate, DrillingCosts) VALUES (301, '2021-11-01', 450000), (301, '2021-11-02', 475000), (302, '2021-11-03', 500000);
What are the total drilling costs for Well ID 301 in the ExplorationData table?
SELECT SUM(DrillingCosts) FROM ExplorationData WHERE WellID = 301;
gretelai_synthetic_text_to_sql
CREATE TABLE donations (id INT, donation_date DATE, amount DECIMAL(10,2));
What is the average donation amount per month in the 'donations' table?
SELECT AVG(amount) AS avg_monthly_donation FROM donations WHERE donation_date BETWEEN '2022-01-01' AND '2022-12-31' GROUP BY EXTRACT(MONTH FROM donation_date);
gretelai_synthetic_text_to_sql
CREATE TABLE soil_moisture_data (id INT, farm_id INT, moisture_level INT, time_stamp DATETIME); INSERT INTO soil_moisture_data (id, farm_id, moisture_level, time_stamp) VALUES (1, 1, 55, '2022-03-14 12:00:00'), (2, 2, 60, '2022-03-14 13:00:00'), (3, 3, 50, '2022-03-14 14:00:00');
Delete all records in the soil_moisture_data table for farms in 'Nebraska'.
DELETE FROM soil_moisture_data WHERE farm_id IN (SELECT id FROM farm_locations WHERE state = 'Nebraska');
gretelai_synthetic_text_to_sql
CREATE TABLE vessels (id INT, name TEXT, last_port TEXT, last_port_date DATE); INSERT INTO vessels (id, name, last_port, last_port_date) VALUES (1, 'VesselC', 'Singapore', '2021-12-15'); INSERT INTO vessels (id, name, last_port, last_port_date) VALUES (2, 'VesselD', 'Hong Kong', '2021-11-30');
List the names of vessels that have been to the port of Singapore in the last 6 months.
SELECT DISTINCT name FROM vessels WHERE last_port = 'Singapore' AND last_port_date >= DATE_SUB(CURDATE(), INTERVAL 6 MONTH);
gretelai_synthetic_text_to_sql
CREATE TABLE india_factories (factory_id INT, factory_name VARCHAR(50), textile_material VARCHAR(50), co2_emission INT); INSERT INTO india_factories VALUES (1, 'Factory X', 'Cotton', 1200); INSERT INTO india_factories VALUES (2, 'Factory Y', 'Silk', 1500); INSERT INTO india_factories VALUES (3, 'Factory Z', 'Wool', 180...
What is the total CO2 emission of factories in India, grouped by textile material and sorted in descending order?
SELECT textile_material, SUM(co2_emission) as total_emission FROM india_factories GROUP BY textile_material ORDER BY total_emission DESC;
gretelai_synthetic_text_to_sql
CREATE TABLE strains (strain_id INT, name VARCHAR(255), type VARCHAR(255)); INSERT INTO strains (strain_id, name, type) VALUES (8, 'Purple Kush', 'Indica'); CREATE TABLE dispensaries (dispensary_id INT, name VARCHAR(255)); INSERT INTO dispensaries (dispensary_id, name) VALUES (8, 'Buds & Beyond'); CREATE TABLE inventor...
Delete 'Indica' strains from 'Buds & Beyond' dispensary before 2021.
DELETE FROM inventory WHERE strain_id = (SELECT strain_id FROM strains WHERE name = 'Purple Kush' AND type = 'Indica') AND dispensary_id = (SELECT dispensary_id FROM dispensaries WHERE name = 'Buds & Beyond') AND inventory_id IN (SELECT inventory_id FROM sales WHERE sale_date < '2021-01-01');
gretelai_synthetic_text_to_sql
CREATE TABLE broadband_customers (customer_id INT, devices INT); INSERT INTO broadband_customers (customer_id, devices) VALUES (1, 3), (2, 5), (3, 2);
What is the maximum number of devices registered by a broadband customer?
SELECT customer_id, MAX(devices) FROM broadband_customers GROUP BY customer_id;
gretelai_synthetic_text_to_sql
CREATE TABLE cultural_competency_training (id INT, region VARCHAR(50), year INT, sessions INT); INSERT INTO cultural_competency_training (id, region, year, sessions) VALUES (1, 'Northeast', 2020, 120), (2, 'Southeast', 2020, 150), (3, 'Midwest', 2020, 100), (4, 'West', 2020, 180), (5, 'Northeast', 2021, 140), (6, 'Sout...
List the average cultural competency training sessions per region in 2020 and 2021.
SELECT region, AVG(sessions) as avg_sessions FROM cultural_competency_training WHERE year IN (2020, 2021) GROUP BY region;
gretelai_synthetic_text_to_sql
CREATE TABLE movies (id INT, title VARCHAR(100), release_year INT, rating DECIMAL(3,2)); INSERT INTO movies (id, title, release_year, rating) VALUES (1, 'MovieA', 2015, 8.1); INSERT INTO movies (id, title, release_year, rating) VALUES (2, 'MovieB', 2017, 8.5);
What is the average rating for movies released between 2015 and 2020?
SELECT AVG(rating) FROM movies WHERE release_year BETWEEN 2015 AND 2020;
gretelai_synthetic_text_to_sql