File size: 157,382 Bytes
5a234e0 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 | {"sql_prompt":"Insert new records for the rare earth elements gadolinium and terbium into the production table","sql_context":"CREATE TABLE production ( id INT PRIMARY KEY, element VARCHAR(10), quantity INT, production_date DATE);","sql":"INSERT INTO production (element, quantity, production_date) VALUES ('gadolinium', 150, '2015-03-17'), ('terbium', 200, '2016-06-23');","sql_explanation":"This SQL query inserts two new records into the production table for the rare earth elements gadolinium and terbium. It uses the INSERT INTO statement and specifies the production table and the columns to insert data into. The VALUES clause specifies the data for each column in each new record."}
{"sql_prompt":"What is the total number of electric vehicles sold in each city in Canada?","sql_context":"CREATE TABLE if not exists EVSales (Id int, Vehicle varchar(100), City varchar(100), Quantity int); INSERT INTO EVSales (Id, Vehicle, City, Quantity) VALUES (1, 'Tesla Model 3', 'Toronto', 1000), (2, 'Nissan Leaf', 'Vancouver', 800), (3, 'Chevrolet Bolt', 'Montreal', 1200), (4, 'Tesla Model X', 'Calgary', 600), (5, 'Tesla Model S', 'Ottawa', 900);","sql":"SELECT City, SUM(Quantity) FROM EVSales WHERE Country = 'Canada' GROUP BY City;","sql_explanation":"The query filters the EVSales table for records corresponding to Canada, groups the records by City, and calculates the total number of electric vehicles sold in each city using the SUM function."}
{"sql_prompt":"What is the change in co-ownership cost per property between consecutive rows, ordered by the 'co_ownership' table's ID?","sql_context":"CREATE TABLE co_ownership (id INT, city VARCHAR(255), co_ownership_cost INT, property_id INT); INSERT INTO co_ownership (id, city, co_ownership_cost, property_id) VALUES (1, 'Seattle', 550000, 101), (2, 'Seattle', 560000, 102), (3, 'Portland', 420000, 103), (4, 'Portland', 430000, 104), (5, 'Portland', 440000, 105);","sql":"SELECT id, city, co_ownership_cost, LAG(co_ownership_cost) OVER (PARTITION BY city ORDER BY id) AS previous_co_ownership_cost, co_ownership_cost - LAG(co_ownership_cost) OVER (PARTITION BY city ORDER BY id) AS cost_change FROM co_ownership ORDER BY id;","sql_explanation":"Calculates the change in co-ownership cost per property between consecutive rows, ordered by the ID of the 'co_ownership' table. Uses a window function to access the previous row's co-ownership cost."}
{"sql_prompt":"What is the number of repeat attendees for each event type in 2021?","sql_context":"CREATE TABLE Events (EventID INT, EventTypeID INT, EventDate DATE); CREATE TABLE EventAttendance (EventID INT, AudienceID INT); CREATE TABLE Audience (AudienceID INT, AudienceName VARCHAR(50)); INSERT INTO Events (EventID, EventTypeID, EventDate) VALUES (1, 1, '2021-01-01'), (2, 1, '2021-02-01'), (3, 2, '2021-03-01'); INSERT INTO EventAttendance (EventID, AudienceID) VALUES (1, 1), (1, 2), (2, 1), (2, 3), (3, 1), (3, 2); INSERT INTO Audience (AudienceID, AudienceName) VALUES (1, 'Alice'), (2, 'Bob'), (3, 'Charlie');","sql":"SELECT et.EventTypeName, COUNT(DISTINCT ea.AudienceID) as NumRepeatAttendees FROM EventAttendance ea INNER JOIN Events e ON ea.EventID = e.EventID INNER JOIN EventTypes et ON e.EventTypeID = et.EventTypeID INNER JOIN (SELECT AudienceID, COUNT(EventID) as NumEvents FROM EventAttendance GROUP BY AudienceID HAVING COUNT(EventID) > 1) repeat_attendees ON ea.AudienceID = repeat_attendees.AudienceID GROUP BY et.EventTypeName;","sql_explanation":"This query joins the EventAttendance, Events, and EventTypes tables and filters the Events table to only include events that occurred in 2021. It then joins the result with a subquery that identifies repeat attendees and calculates the number of repeat attendees for each event type."}
{"sql_prompt":"What is the average carbon offset amount for carbon offset programs in the 'Energy Production' sector?","sql_context":"CREATE TABLE Carbon_Offset_Programs (id INT, sector VARCHAR(20), year INT, carbon_offset_amount INT); INSERT INTO Carbon_Offset_Programs (id, sector, year, carbon_offset_amount) VALUES (1, 'Transportation', 2018, 50000), (2, 'Energy Production', 2019, 75000), (3, 'Transportation', 2020, 65000), (4, 'Manufacturing', 2021, 80000), (5, 'Energy Production', 2020, 80000), (6, 'Energy Production', 2018, 60000);","sql":"SELECT AVG(carbon_offset_amount) FROM Carbon_Offset_Programs WHERE sector = 'Energy Production';","sql_explanation":"This SQL query calculates the average carbon offset amount for carbon offset programs in the 'Energy Production' sector by using the AVG() function and filtering the results with the WHERE clause."}
{"sql_prompt":"How many unique one-time donors made donations in 'q4' of '2022'?","sql_context":"CREATE TABLE Donations (id INT, donor_type VARCHAR(10), donation_amount DECIMAL(10,2), donation_date DATE); INSERT INTO Donations (id, donor_type, donation_amount, donation_date) VALUES (1, 'one-time', 50.00, '2022-01-01'); INSERT INTO Donations (id, donor_type, donation_amount, donation_date) VALUES (2, 'recurring', 25.00, '2022-01-15'); INSERT INTO Donations (id, donor_type, donation_amount, donation_date) VALUES (3, 'one-time', 75.00, '2022-12-31');","sql":"SELECT COUNT(DISTINCT donor_id) FROM Donations WHERE donor_type = 'one-time' AND QUARTER(donation_date) = 4 AND YEAR(donation_date) = 2022;","sql_explanation":"This query counts the number of unique donor_ids for one-time donors in the fourth quarter of 2022 by filtering the Donations table for the appropriate donor_type, quarter, and year, and then applying the COUNT function to the distinct donor_ids."}
{"sql_prompt":"What is the total number of financial transactions made by volunteers?","sql_context":"CREATE TABLE Volunteers (VolunteerID int, VolunteerName varchar(50), VolunteerNationality varchar(50), VolunteerSignUpDate date); CREATE TABLE FinancialTransactions (TransactionID int, TransactionAmount numeric(10,2), TransactionDate date, VolunteerID int); INSERT INTO Volunteers (VolunteerID, VolunteerName, VolunteerNationality, VolunteerSignUpDate) VALUES (1, 'Sophia Garcia', 'Mexican', '2021-05-10'), (2, 'Hamza Ahmed', 'Pakistani', '2021-03-22'), (3, 'Lea Kim', 'South Korean', '2021-07-18'); INSERT INTO FinancialTransactions (TransactionID, TransactionAmount, TransactionDate, VolunteerID) VALUES (1, 25, '2021-06-01', 1), (2, 30, '2021-04-01', 2), (3, 40, '2021-08-01', 3);","sql":"SELECT COUNT(*) as TotalTransactions FROM FinancialTransactions INNER JOIN Volunteers ON FinancialTransactions.VolunteerID = Volunteers.VolunteerID;","sql_explanation":"This SQL query calculates the total number of financial transactions made by volunteers. It uses a JOIN to combine the Volunteers and FinancialTransactions tables and then calculates the total number of transactions using the COUNT function."}
{"sql_prompt":"Delete users who haven't posted in the last 6 months from the \"users\" table","sql_context":"CREATE TABLE users (id INT, username VARCHAR(255), last_post_date DATE);","sql":"DELETE FROM users WHERE last_post_date < DATE_SUB(CURDATE(), INTERVAL 6 MONTH);","sql_explanation":"This query deletes records from the \"users\" table where the \"last_post_date\" is older than 6 months from the current date."}
{"sql_prompt":"What's the total number of properties in each city with inclusive housing policies?","sql_context":"CREATE TABLE properties (property_id INT, price DECIMAL(10,2), size INT, city VARCHAR(50), inclusive_policy BOOLEAN); INSERT INTO properties (property_id, price, size, city, inclusive_policy) VALUES (1, 500000, 2000, 'Oakland', true), (2, 600000, 2500, 'San Francisco', false), (3, 450000, 1000, 'Oakland', true);","sql":"SELECT city, COUNT(*) FROM properties WHERE inclusive_policy = true GROUP BY city;","sql_explanation":"The SQL query returns the number of properties in each city that have an inclusive housing policy (represented by the inclusive_policy column). It does this by filtering for rows where inclusive_policy is true, and then grouping by the city column and counting the number of rows in each group."}
{"sql_prompt":"Identify the total nitrogen levels and farm size for farms using a center pivot irrigation system, located in the Europe region.","sql_context":"CREATE TABLE farm (id INT, name VARCHAR(50), size FLOAT, irrigation_system VARCHAR(20), region VARCHAR(50), PRIMARY KEY(id)); INSERT INTO farm (id, name, size, irrigation_system, region) VALUES (1, 'Farm X', 80.3, 'center pivot', 'Europe'); INSERT INTO farm (id, name, size, irrigation_system, region) VALUES (2, 'Farm Y', 55.8, 'drip', 'Asia'); INSERT INTO farm (id, name, size, irrigation_system, region) VALUES (3, 'Farm Z', 65.1, 'center pivot', 'Europe'); CREATE TABLE nitrogen (id INT, farm_id INT, nitrogen FLOAT, PRIMARY KEY(id)); INSERT INTO nitrogen (id, farm_id, nitrogen) VALUES (1, 1, 33.5); INSERT INTO nitrogen (id, farm_id, nitrogen) VALUES (2, 1, 34.2); INSERT INTO nitrogen (id, farm_id, nitrogen) VALUES (3, 3, 30.8);","sql":"SELECT f.irrigation_system, f.region, SUM(f.size) AS total_area, AVG(n.nitrogen) AS avg_nitrogen FROM farm f INNER JOIN nitrogen n ON f.id = n.farm_id WHERE f.irrigation_system = 'center pivot' AND f.region = 'Europe' GROUP BY f.irrigation_system, f.region;","sql_explanation":"This query joins the farm and nitrogen tables on their common column farm_id. It filters the results to only show farms using a center pivot irrigation system (f.irrigation_system = 'center pivot') and located in the Europe region (f.region = 'Europe'). Then, it groups the results by irrigation system and region (f.irrigation_system, f.region) and calculates the total area (SUM(f.size)) and average nitrogen levels (AVG(n.nitrogen)) for farms using this type of irrigation system and located in this region."}
{"sql_prompt":"Count the number of suppliers from the United States.","sql_context":"CREATE TABLE suppliers (id INT PRIMARY KEY, name VARCHAR(255), location VARCHAR(255), sustainable BOOLEAN); INSERT INTO suppliers (id, name, location, sustainable) VALUES (1, 'Eco Friendly', 'California', true);","sql":"SELECT COUNT(*) FROM suppliers WHERE location = 'California';","sql_explanation":"Count the number of suppliers from the United States (California in this case)."}
{"sql_prompt":"What is the latest end date of astronaut medical records in 2012?","sql_context":"CREATE TABLE MedicalRecords (id INT, astronaut_id INT, start_date DATE, end_date DATE); INSERT INTO MedicalRecords (id, astronaut_id, start_date, end_date) VALUES (1, 1, '2010-01-01', '2010-01-10'), (2, 2, '2012-05-01', '2012-12-31');","sql":"SELECT MAX(end_date) FROM MedicalRecords WHERE YEAR(end_date) = 2012;","sql_explanation":"This query retrieves the latest end date of astronaut medical records in 2012 by selecting the MAX function on the end_date column, filtering for rows with the year 2012."}
{"sql_prompt":"Update records in the agricultural_innovations table with rural_innovation_id 2 to have a year of 2024","sql_context":"CREATE TABLE agricultural_innovations (id INT PRIMARY KEY, rural_innovation_id INT, name VARCHAR(255), description TEXT, year INT);","sql":"WITH cte AS (UPDATE agricultural_innovations SET year = 2024 WHERE rural_innovation_id = 2) SELECT * FROM cte;","sql_explanation":"The CTE updates records with rural_innovation_id 2 in the agricultural_innovations table to have a year of 2024, and then the SELECT statement returns all records from the CTE."}
{"sql_prompt":"Find properties with size greater than 1500 sq ft in urban_properties table.","sql_context":"CREATE TABLE urban_properties (id INT, size FLOAT, location VARCHAR(255)); INSERT INTO urban_properties (id, size, location) VALUES (1, 1200.0, 'San Francisco'), (2, 1800.0, 'New York'), (3, 1300.0, 'Los Angeles');","sql":"SELECT * FROM urban_properties WHERE size > 1500;","sql_explanation":"This query selects all properties with a size greater than 1500 sq ft in the urban_properties table."}
{"sql_prompt":"Which onshore wells in the Permian Basin have the highest production rate?","sql_context":"CREATE TABLE wells (well_id INT, well_name VARCHAR(255), well_type VARCHAR(255), location VARCHAR(255)); INSERT INTO wells VALUES (1, 'Well A', 'Offshore', 'Gulf of Mexico'); INSERT INTO wells VALUES (2, 'Well B', 'Onshore', 'Permian Basin');","sql":"SELECT well_id, well_name, production_rate FROM (SELECT well_id, well_name, production_rate, row_number() OVER (PARTITION BY well_type ORDER BY production_rate DESC) as rn FROM well_production WHERE well_type = 'Onshore' AND location = 'Permian Basin') WHERE rn = 1;","sql_explanation":"This query retrieves the onshore wells in the Permian Basin with the highest production rate, using the row_number() function to partition and order the results by production rate."}
{"sql_prompt":"Calculate the average number of goals per game for the top 2 teams in the Indian Super League","sql_context":"CREATE TABLE teams (id INT PRIMARY KEY, name TEXT, league TEXT, goals_scored INT, goals_conceded INT, games_played INT); INSERT INTO teams (id, name, league, goals_scored, goals_conceded, games_played) VALUES (1, 'Mumbai City FC', 'Indian Super League', 22, 12, 16), (2, 'Hyderabad FC', 'Indian Super League', 20, 12, 16), (3, 'Goa FC', 'Indian Super League', 18, 12, 16), (4, 'Kerala Blasters FC', 'Indian Super League', 17, 13, 16), (5, 'Bengaluru FC', 'Indian Super League', 15, 12, 16);","sql":"SELECT AVG(goals_scored\/games_played) FROM (SELECT * FROM teams ORDER BY goals_scored DESC LIMIT 2) AS top_two_teams;","sql_explanation":"This query first selects the top 2 teams with the most goals scored and then calculates the average number of goals per game for those teams."}
{"sql_prompt":"Show the total budget allocated to healthcare programs in each department from the 'government_budget' database.","sql_context":"CREATE TABLE departments (id INT PRIMARY KEY, name VARCHAR(255));CREATE TABLE programs (id INT PRIMARY KEY, name VARCHAR(255), department_id INT, FOREIGN KEY (department_id) REFERENCES departments(id), budget INT); INSERT INTO departments (id, name) VALUES (1, 'Health and Human Services'); INSERT INTO departments (id, name) VALUES (2, 'Education');","sql":"SELECT departments.name, SUM(programs.budget) as total_budget FROM departments INNER JOIN programs ON departments.id = programs.department_id WHERE programs.name LIKE '%healthcare%' GROUP BY departments.name;","sql_explanation":"This SQL query performs an inner join between the 'departments' and 'programs' tables on the 'department_id' foreign key. It then filters the results to only include healthcare programs and calculates the total budget allocated to each department."}
{"sql_prompt":"How many climate mitigation initiatives were launched in Southeast Asia between 2015 and 2020 that involved women-led organizations?","sql_context":"CREATE TABLE climate_initiatives (initiative VARCHAR(50), region VARCHAR(50), start_year INT, end_year INT, gender_focus BOOLEAN); INSERT INTO climate_initiatives (initiative, region, start_year, end_year, gender_focus) VALUES ('Initiative A', 'Southeast Asia', 2015, 2020, TRUE); INSERT INTO climate_initiatives (initiative, region, start_year, end_year, gender_focus) VALUES ('Initiative B', 'Southeast Asia', 2016, 2021, FALSE); INSERT INTO climate_initiatives (initiative, region, start_year, end_year, gender_focus) VALUES ('Initiative C', 'Southeast Asia', 2017, 2022, TRUE); INSERT INTO climate_initiatives (initiative, region, start_year, end_year, gender_focus) VALUES ('Initiative D', 'Southeast Asia', 2018, 2023, FALSE);","sql":"SELECT COUNT(*) FROM climate_initiatives WHERE region = 'Southeast Asia' AND start_year BETWEEN 2015 AND 2020 AND gender_focus = TRUE;","sql_explanation":"This query retrieves the number of climate mitigation initiatives launched in Southeast Asia between 2015 and 2020 that involved women-led organizations. It counts the number of rows where the region is 'Southeast Asia', the start_year is between 2015 and 2020, and the gender_focus is TRUE."}
{"sql_prompt":"What is the average age of patients who have been diagnosed with diabetes in the rural health clinic located in Texas?","sql_context":"CREATE TABLE rural_clinic (clinic_id INT, location VARCHAR(20), capacity INT); INSERT INTO rural_clinic (clinic_id, location, capacity) VALUES (1, 'Texas', 50); CREATE TABLE patient (patient_id INT, clinic_id INT, age INT, diagnosis VARCHAR(20)); INSERT INTO patient (patient_id, clinic_id, age, diagnosis) VALUES (1, 1, 45, 'diabetes'), (2, 1, 60, 'asthma'), (3, 1, 30, 'diabetes');","sql":"SELECT AVG(age) FROM patient WHERE diagnosis = 'diabetes' AND clinic_id = 1;","sql_explanation":"This query calculates the average age of patients diagnosed with diabetes in the rural clinic located in Texas by using the AVG function on the age column, filtered by the diagnosis and clinic_id."}
{"sql_prompt":"List the top 3 donor names and their total donation amounts for the 'Education' sector in the 'Americas' region for the year 2019, ordered by the donation amount in descending order.","sql_context":"CREATE TABLE Donors (donor_id INT, donor_name VARCHAR(255), donation_amount INT, sector VARCHAR(255), region VARCHAR(255), donation_date DATE); INSERT INTO Donors (donor_id, donor_name, donation_amount, sector, region, donation_date) VALUES (1, 'DonorB', 125000, 'Education', 'Americas', '2019-01-01');","sql":"SELECT donor_name, SUM(donation_amount) AS total_donation FROM Donors WHERE sector = 'Education' AND region = 'Americas' AND donation_date >= '2019-01-01' AND donation_date < '2020-01-01' GROUP BY donor_name ORDER BY total_donation DESC LIMIT 3;","sql_explanation":"The SQL query filters the Donors table for rows where the sector is 'Education', the region is 'Americas', and the donation_date is in the year 2019. It then groups the filtered results by donor_name and calculates the total donation amount for each group. Finally, it orders the groups by total_donation in descending order and selects the top 3 donor_name and total_donation rows."}
{"sql_prompt":"What is the average CO2 emissions for the garment manufacturing process for each collection?","sql_context":"CREATE TABLE emissions (collection VARCHAR(20), co2_emissions INT); INSERT INTO emissions (collection, co2_emissions) VALUES ('Spring 2021', 10000), ('Fall 2021', 12000), ('Winter 2021', 15000), ('Spring 2022', 18000);","sql":"SELECT collection, AVG(co2_emissions) FROM emissions GROUP BY collection;","sql_explanation":"* This query calculates the average CO2 emissions for the garment manufacturing process for each collection from the emissions table."}
{"sql_prompt":"Insert a new record into the 'energy_storage' table for a flow battery with 5 MWh capacity, located in 'Quebec'","sql_context":"CREATE TABLE energy_storage (id INT PRIMARY KEY, technology VARCHAR(255), capacity FLOAT, location VARCHAR(255));","sql":"INSERT INTO energy_storage (technology, capacity, location) VALUES ('flow', 5, 'Quebec');","sql_explanation":"This query inserts a new record into the energy_storage table for a flow battery with 5 MWh capacity, located in 'Quebec'. It uses the INSERT INTO statement with the VALUES clause to insert the new record."}
{"sql_prompt":"What is the total amount donated on Giving Tuesday by donors in the Health industry?","sql_context":"CREATE TABLE donations(id INT, donor_name TEXT, donation_amount FLOAT, donation_date DATE, industry TEXT); INSERT INTO donations(id, donor_name, donation_amount, donation_date, industry) VALUES (1, 'James Lee', 50, '2022-11-29', 'Technology'), (2, 'Grace Kim', 100, '2022-12-01', 'Finance'), (3, 'Anthony Nguyen', 25, '2022-11-29', 'Health');","sql":"SELECT SUM(donation_amount) FROM donations WHERE donation_date = '2022-11-29' AND industry = 'Health';","sql_explanation":"This query first selects all donations made on Giving Tuesday (November 29th, 2022) by donors in the 'Health' industry. It then calculates the total donation amount in this filtered set."}
{"sql_prompt":"What is the maximum safety score for chemical products manufactured in the Asian region?","sql_context":"CREATE TABLE Manufacturers (ManufacturerID INT, ManufacturerName TEXT, Region TEXT); INSERT INTO Manufacturers (ManufacturerID, ManufacturerName, Region) VALUES (1, 'ABC Chemicals', 'Asia'), (2, 'XYZ Chemicals', 'North America'), (3, ' DEF Chemicals', 'Asia'); CREATE TABLE ChemicalProducts (ProductID INT, Chemical TEXT, ManufacturerID INT, SafetyScore DECIMAL(3,2)); INSERT INTO ChemicalProducts (ProductID, Chemical, ManufacturerID, SafetyScore) VALUES (1, 'Acetone', 1, 3.2), (2, 'Ethanol', 1, 4.5), (3, 'Methanol', 2, 5.0), (4, 'Propanol', 3, 4.8), (5, 'Butanol', 3, 5.0);","sql":"SELECT MAX(CP.SafetyScore) AS MaxScore FROM ChemicalProducts CP INNER JOIN Manufacturers M ON CP.ManufacturerID = M.ManufacturerID WHERE M.Region = 'Asia';","sql_explanation":"The SQL query performs an inner join between the ChemicalProducts and Manufacturers tables, based on the ManufacturerID, and filters for the Asian region. It then calculates the maximum safety score for chemical products manufactured in the Asian region."}
{"sql_prompt":"Identify cities with the highest citizen feedback ratings and the corresponding number of public services provided in each city.","sql_context":"CREATE TABLE cities (city_id INT, city_name VARCHAR(255), region VARCHAR(255)); CREATE TABLE public_services (service_id INT, service_name VARCHAR(255), city_id INT, rating INT);","sql":"SELECT c.city_name, MAX(ps.rating) as max_rating, COUNT(ps.service_id) as num_services FROM cities c JOIN public_services ps ON c.city_id = ps.city_id GROUP BY c.city_name HAVING MAX(ps.rating) >= ALL (SELECT MAX(ps2.rating) FROM public_services ps2 GROUP BY ps2.city_id);","sql_explanation":"Join the cities and public_services tables, group by city, and filter to show only cities with the highest citizen feedback ratings. Count the number of public services in each city."}
{"sql_prompt":"What are the ethical AI principles for the technology projects in India?","sql_context":"CREATE TABLE EthicalAI (principle_id INT, principle_name VARCHAR(50), project_location VARCHAR(20)); INSERT INTO EthicalAI (principle_id, principle_name, project_location) VALUES (1, 'Fairness', 'India'), (2, 'Accountability', 'India'), (3, 'Transparency', 'India'), (4, 'Data Minimization', 'India'), (5, 'Explainability', 'India'), (6, 'Human Oversight', 'India');","sql":"SELECT principle_name FROM EthicalAI WHERE project_location = 'India';","sql_explanation":"This query retrieves the ethical AI principles for the technology projects in India by selecting the principle_name values where the project_location is India."}
{"sql_prompt":"List all the unique ports and countries where oil spills have occurred in the last 5 years.","sql_context":"CREATE TABLE oil_spills (id INT, port VARCHAR(30), country VARCHAR(30), date DATE); INSERT INTO oil_spills (id, port, country, date) VALUES (1, 'Port of Los Angeles', 'USA', '2020-01-01'); INSERT INTO oil_spills (id, port, country, date) VALUES (2, 'Port of Rotterdam', 'Netherlands', '2019-08-15');","sql":"SELECT DISTINCT port, country FROM oil_spills WHERE date >= DATE_SUB(CURRENT_DATE, INTERVAL 5 YEAR);","sql_explanation":"The SQL query selects the unique combination of ports and countries from the oil_spills table where the date of the oil spill is within the last 5 years. The DISTINCT keyword is used to ensure that only unique combinations of port and country are returned in the result set."}
{"sql_prompt":"How many mental health parity complaints were filed in the last 12 months by state?","sql_context":"CREATE TABLE mental_health_parity_complaints (complaint_id INT, complaint_date DATE, state VARCHAR(20)); INSERT INTO mental_health_parity_complaints (complaint_id, complaint_date, state) VALUES (1, '2021-01-01', 'California'), (2, '2021-03-15', 'New York'), (3, '2020-12-31', 'Texas');","sql":"SELECT state, COUNT(*) as num_complaints FROM mental_health_parity_complaints WHERE complaint_date >= DATE_SUB(CURRENT_DATE, INTERVAL 12 MONTH) GROUP BY state;","sql_explanation":"This SQL query counts the number of mental health parity complaints filed in the last 12 months by state. It uses the COUNT function to count the number of complaints and the WHERE clause to filter the results to only include complaints filed in the last 12 months. The query then groups the results by state using the GROUP BY clause."}
{"sql_prompt":"What is the average mental health score for students in traditional courses?","sql_context":"CREATE TABLE students (student_id INT, course_id INT, mental_health_score INT); INSERT INTO students (student_id, course_id, mental_health_score) VALUES (6, 15, 80), (7, 16, 85), (8, 17, 70), (9, 18, 90), (10, 19, 65); CREATE TABLE courses (course_id INT, course_type VARCHAR(20)); INSERT INTO courses (course_id, course_type) VALUES (15, 'Traditional'), (16, 'Open Pedagogy'), (17, 'Traditional'), (18, 'Open Pedagogy'), (19, 'Open Pedagogy');","sql":"SELECT AVG(students.mental_health_score) FROM students JOIN courses ON students.course_id = courses.course_id WHERE courses.course_type = 'Traditional';","sql_explanation":"This query joins the students table with the courses table, filters for traditional courses, and then calculates the average mental health score for students in those courses."}
{"sql_prompt":"What is the average experience of electrical engineers for each dam project?","sql_context":"CREATE TABLE dams (id INT, name VARCHAR(255), location VARCHAR(255), budget FLOAT, project_manager VARCHAR(255), engineer_specialty VARCHAR(255), engineer_experience INT);","sql":"SELECT d.name, AVG(d.engineer_experience) as avg_experience FROM dams d WHERE d.engineer_specialty = 'Electrical' GROUP BY d.name;","sql_explanation":"This SQL query filters the 'dams' table for rows with 'Electrical' as the engineer_specialty, then calculates the average experience for each dam name, providing an average experience for electrical engineers in each dam project."}
{"sql_prompt":"What was the average funding for 'Climate Change' initiatives provided by the US in 2021?","sql_context":"CREATE TABLE USFunding (Funder VARCHAR(50), Sector VARCHAR(50), FundingAmount NUMERIC(15,2), Year INT); INSERT INTO USFunding (Funder, Sector, FundingAmount, Year) VALUES ('US', 'Climate Change', 450000, 2021), ('US', 'Climate Change', 500000, 2021), ('US', 'Climate Change', 350000, 2021);","sql":"SELECT AVG(FundingAmount) FROM USFunding WHERE Sector = 'Climate Change' AND Year = 2021 AND Funder = 'US';","sql_explanation":"Calculates the average (AVG) FundingAmount where Sector is 'Climate Change', Year is 2021, and Funder is 'US'."}
{"sql_prompt":"What is the maximum response time for emergency calls in the city of Los Angeles?","sql_context":"CREATE TABLE emergency_calls (id INT, city VARCHAR(20), response_time INT);","sql":"SELECT MAX(response_time) FROM emergency_calls WHERE city = 'Los Angeles';","sql_explanation":"This SQL query calculates the maximum response time for emergency calls in the city of Los Angeles by using the MAX function on the response_time column and filtering for rows where the city is Los Angeles."}
{"sql_prompt":"Find the total sales of vendors located in the Midwest region.","sql_context":"CREATE TABLE vendors (vendor_id INT, vendor_name TEXT, region TEXT); INSERT INTO vendors (vendor_id, vendor_name, region) VALUES (1, 'Green Vendors', 'Midwest'); CREATE TABLE sales (sale_id INT, sale_date DATE, vendor_id INT, amount DECIMAL(5,2)); INSERT INTO sales (sale_id, sale_date, vendor_id, amount) VALUES (1, '2022-01-01', 1, 12000);","sql":"SELECT SUM(amount) FROM sales JOIN vendors ON sales.vendor_id = vendors.vendor_id WHERE vendors.region = 'Midwest';","sql_explanation":"The SQL query joins the vendors and sales tables on vendor_id, filters for vendors located in the Midwest region, and then calculates the total sales using the SUM function."}
{"sql_prompt":"What is the average monthly data usage for mobile subscribers in the city of Dallas?","sql_context":"CREATE TABLE mobile_subscribers (subscriber_id INT, city VARCHAR(255), data_usage_gb DECIMAL(5,2)); INSERT INTO mobile_subscribers (subscriber_id, city, data_usage_gb) VALUES (1, 'Dallas', 12.3), (2, 'Dallas', 10.5), (3, 'Austin', 11.7);","sql":"SELECT AVG(data_usage_gb) FROM mobile_subscribers WHERE city = 'Dallas';","sql_explanation":"The SQL query calculates the average (AVG) of the data_usage_gb column for rows with a city value of 'Dallas'."}
{"sql_prompt":"Add a new treatment type 'art therapy' for patient 5 in Canada","sql_context":"CREATE SCHEMA mental_health; USE mental_health; CREATE TABLE patients (patient_id INT, diagnosis VARCHAR(50), age INT, country VARCHAR(50)); CREATE TABLE treatments (treatment_id INT, patient_id INT, treatment_type VARCHAR(50), treatment_date DATE, country VARCHAR(50)); INSERT INTO patients VALUES (5, 'depression', 45, 'Canada');","sql":"INSERT INTO treatments VALUES (9, 5, 'art therapy', '2022-03-20', 'Canada');","sql_explanation":"This query inserts a new record into the treatments table with a treatment_id of 9, a patient_id of 5, a treatment_type of 'art therapy', a treatment_date of '2022-03-20', and a country of 'Canada'."}
{"sql_prompt":"What is the average price of vegan cosmetics in the US?","sql_context":"CREATE TABLE cosmetics (product_id INT, product_name VARCHAR(50), is_vegan BOOLEAN, price FLOAT, country VARCHAR(50));","sql":"SELECT AVG(price) FROM cosmetics WHERE is_vegan = TRUE AND country = 'USA';","sql_explanation":"This query calculates the average price of vegan cosmetics sold in the US. It does this by averaging the 'price' column of all records in the 'cosmetics' table where the 'is_vegan' column is set to true and the 'country' column is set to 'USA'."}
{"sql_prompt":"What is the minimum budget allocated for the 'Education' department in the year 2022?","sql_context":"CREATE TABLE Budget(year INT, department VARCHAR(20), amount INT); INSERT INTO Budget VALUES (2021, 'Healthcare', 7000000), (2021, 'Education', 5000000), (2022, 'Healthcare', 7800000), (2022, 'Education', 5300000), (2022, 'Education', 4800000);","sql":"SELECT MIN(amount) FROM Budget WHERE department = 'Education' AND year = 2022;","sql_explanation":"This query calculates the minimum budget allocated for the 'Education' department in the year 2022 by finding the minimum 'amount' column value where 'year' is 2022 and 'department' is 'Education'."}
{"sql_prompt":"What is the total number of crime incidents reported in each sector, sorted by the number of incidents in descending order?","sql_context":"CREATE TABLE sector (id INT, name TEXT, location TEXT); INSERT INTO sector (id, name, location) VALUES (1, 'Sector A', 'Downtown'), (2, 'Sector B', 'Uptown'); CREATE TABLE incidents (id INT, sector_id INT, type TEXT, timestamp DATETIME); INSERT INTO incidents (id, sector_id, type, timestamp) VALUES (1, 1, 'Theft', '2022-01-01 10:00:00'), (2, 2, 'Vandalism', '2022-01-02 12:00:00');","sql":"SELECT sector.name, COUNT(incidents.id) AS incident_count FROM sector LEFT JOIN incidents ON sector.id = incidents.sector_id GROUP BY sector.name ORDER BY incident_count DESC;","sql_explanation":"The SQL query joins the 'sector' and 'incidents' tables on the 'sector_id' column and then groups the results by sector name. The COUNT function is used to count the number of incidents for each sector, and the results are sorted in descending order based on the number of incidents."}
{"sql_prompt":"Which vessels have been involved in accidents in the Pacific Ocean?","sql_context":"CREATE TABLE vessels (vessel_id INT, name VARCHAR(100)); CREATE TABLE maritime_accidents (accident_id INT, vessel_id INT, country VARCHAR(100), ocean VARCHAR(100)); INSERT INTO vessels (vessel_id, name) VALUES (1, 'Sea Serpent'); INSERT INTO maritime_accidents (accident_id, vessel_id, country, ocean) VALUES (1, 1, 'Canada', 'Pacific Ocean');","sql":"SELECT vessels.name FROM vessels INNER JOIN maritime_accidents ON vessels.vessel_id = maritime_accidents.vessel_id WHERE maritime_accidents.ocean = 'Pacific Ocean';","sql_explanation":"This query joins the vessels and maritime_accidents tables on the vessel_id column and filters the results based on the ocean column. It then selects the names of the vessels that have been involved in accidents in the Pacific Ocean."}
{"sql_prompt":"What is the total metal waste generation in Rio de Janeiro in 2021?","sql_context":"CREATE TABLE waste_generation (city VARCHAR(50), waste_type VARCHAR(50), generation_quantity INT, generation_date DATE); INSERT INTO waste_generation (city, waste_type, generation_quantity, generation_date) VALUES ('Rio de Janeiro', 'Metal', 900, '2021-01-01'), ('Rio de Janeiro', 'Organic', 1200, '2021-01-01'), ('Rio de Janeiro', 'Glass', 700, '2021-01-01');","sql":"SELECT SUM(generation_quantity) FROM waste_generation WHERE city = 'Rio de Janeiro' AND waste_type = 'Metal' AND generation_date >= '2021-01-01' AND generation_date <= '2021-12-31';","sql_explanation":"This SQL query calculates the total metal waste generation in Rio de Janeiro in 2021. It sums the generation_quantity for records where the city is 'Rio de Janeiro', waste_type is 'Metal', and the generation_date falls within the range of January 1, 2021 to December 31, 2021."}
{"sql_prompt":"What are the names of the vessels that have complied with maritime law in the Pacific Ocean in the last 3 years?","sql_context":"CREATE TABLE vessels (vessel_name TEXT, compliance_status TEXT, ocean TEXT, year INT); INSERT INTO vessels (vessel_name, compliance_status, ocean, year) VALUES ('VesselA', 'compliant', 'Pacific', 2020), ('VesselB', 'non-compliant', 'Pacific', 2020), ('VesselC', 'compliant', 'Pacific', 2020), ('VesselA', 'compliant', 'Pacific', 2021), ('VesselB', 'non-compliant', 'Pacific', 2021), ('VesselC', 'compliant', 'Pacific', 2021);","sql":"SELECT DISTINCT vessel_name FROM vessels WHERE compliance_status = 'compliant' AND ocean = 'Pacific' AND year BETWEEN 2019 AND 2021;","sql_explanation":"This query lists the names of the vessels that have complied with maritime law in the Pacific Ocean in the last 3 years by selecting the DISTINCT vessel_name column values where compliance_status is 'compliant', ocean is 'Pacific', and year is between 2019 and 2021."}
{"sql_prompt":"What is the total revenue for 'Italian' category in '2023'?","sql_context":"CREATE TABLE RestaurantRevenue (category VARCHAR(20), year INT, revenue FLOAT); INSERT INTO RestaurantRevenue (category, year, revenue) VALUES ('Italian', 2023, 25000.00),('Italian', 2023, 28000.00),('Italian', 2023, 30000.00);","sql":"SELECT SUM(revenue) FROM RestaurantRevenue WHERE category = 'Italian' AND year = 2023;","sql_explanation":"The SQL query calculates the total revenue for the 'Italian' category in '2023' by summing the revenue values where the category is 'Italian' and the year is 2023."}
{"sql_prompt":"What is the average carbon price in the 'carbon_prices' table, grouped by region?","sql_context":"CREATE TABLE carbon_prices (id INT, region VARCHAR(50), price FLOAT); INSERT INTO carbon_prices (id, region, price) VALUES (1, 'EU', 25), (2, 'US', 40), (3, 'EU', 22), (4, 'US', 38), (5, 'EU', 28);","sql":"SELECT c.region, AVG(c.price) as avg_price FROM carbon_prices c GROUP BY c.region;","sql_explanation":"This SQL query calculates the average carbon price in the 'carbon_prices' table by grouping the records based on the 'region' column and calculating the average of the 'price' column values for each group."}
{"sql_prompt":"Count the number of products in the 'grocery' category","sql_context":"CREATE TABLE products (product_id INT, category VARCHAR(20), quantity INT); INSERT INTO products (product_id, category, quantity) VALUES (1, 'grocery', 10), (2, 'grocery', 20), (3, 'grocery', 30);","sql":"SELECT COUNT(*) FROM products WHERE category = 'grocery';","sql_explanation":"This SQL query counts the number of products in the 'grocery' category by selecting all columns (indicated by the *) from the 'products' table where the category is 'grocery' and counting the number of rows returned."}
{"sql_prompt":"How many fair labor practice violations have been reported for each region in the ethical fashion industry?","sql_context":"CREATE TABLE labor_practices_violations (region VARCHAR(50), violations INT); INSERT INTO labor_practices_violations (region, violations) VALUES ('Africa', 250), ('Asia', 300), ('Latin America', 200);","sql":"SELECT region, violations FROM labor_practices_violations GROUP BY region;","sql_explanation":"This SQL query groups fair labor practice violations by region in the ethical fashion industry by selecting the 'region' and 'violations' columns in the 'labor_practices_violations' table and grouping the results by the 'region' column."}
{"sql_prompt":"What is the total budget allocated for housing and transportation services in 2021 across all regions, excluding the South?","sql_context":"CREATE TABLE Budget (Year INT, Service VARCHAR(20), Region VARCHAR(20), Amount DECIMAL(10,2)); INSERT INTO Budget (Year, Service, Region, Amount) VALUES (2021, 'Housing', 'Northeast', 75000.00), (2021, 'Transportation', 'South', 80000.00), (2021, 'Housing', 'West', 90000.00);","sql":"SELECT SUM(Amount) FROM Budget WHERE Year = 2021 AND (Service IN ('Housing', 'Transportation') AND Region != 'South');","sql_explanation":"This query calculates the total budget allocated for housing and transportation services in 2021 by summing the 'Amount' column where the 'Year' is 2021, the 'Service' is either 'Housing' or 'Transportation', and the 'Region' is not 'South'."}
{"sql_prompt":"What was the total revenue from cannabis-infused edibles sold by each dispensary in the city of San Francisco in the month of December 2021?","sql_context":"CREATE TABLE Dispensaries (id INT, name VARCHAR(255), city VARCHAR(255), state VARCHAR(255));CREATE TABLE Inventory (id INT, dispensary_id INT, revenue DECIMAL(10, 2), product_type VARCHAR(255), month INT, year INT);INSERT INTO Dispensaries (id, name, city, state) VALUES (1, 'Golden Gate Greens', 'San Francisco', 'CA');INSERT INTO Inventory (id, dispensary_id, revenue, product_type, month, year) VALUES (1, 1, 2000, 'edibles', 12, 2021);","sql":"SELECT d.name, SUM(i.revenue) as total_revenue FROM Dispensaries d JOIN Inventory i ON d.id = i.dispensary_id WHERE d.city = 'San Francisco' AND i.product_type = 'edibles' AND i.month = 12 AND i.year = 2021 GROUP BY d.name;","sql_explanation":"This query joins the Dispensaries and Inventory tables on the dispensary_id and dispensary.id foreign keys. It then filters for cannabis-infused edible sales in San Francisco in December 2021, and groups by dispensary name to calculate the total revenue from cannabis-infused edibles sold by each dispensary."}
{"sql_prompt":"What is the total amount of climate finance invested in renewable energy projects by public and private sectors in Africa?","sql_context":"CREATE TABLE renewable_energy_projects (project_id INT, sector TEXT, investor_type TEXT, region TEXT, amount FLOAT); INSERT INTO renewable_energy_projects (project_id, sector, investor_type, region, amount) VALUES (1, 'Renewable Energy', 'Public', 'Africa', 5000000); INSERT INTO renewable_energy_projects (project_id, sector, investor_type, region, amount) VALUES (2, 'Renewable Energy', 'Private', 'Africa', 7000000);","sql":"SELECT SUM(amount) FROM renewable_energy_projects WHERE sector = 'Renewable Energy' AND region = 'Africa';","sql_explanation":"This query calculates the total amount of climate finance invested in renewable energy projects in Africa by summing up the 'amount' column values for the rows with the sector 'Renewable Energy' and region 'Africa'."}
{"sql_prompt":"What is the total number of indigenous food systems in Australia?","sql_context":"CREATE TABLE indigenous_food_systems (system_id INT, name TEXT, location TEXT, type TEXT, community TEXT, country TEXT); INSERT INTO indigenous_food_systems (system_id, name, location, type, community, country) VALUES (1, 'Bush Tucker Project', ' rural area', 'gardening', 'Aboriginal community', 'Australia');","sql":"SELECT COUNT(*) FROM indigenous_food_systems WHERE country = 'Australia';","sql_explanation":"This SQL query calculates the total number of indigenous food systems in Australia by counting all rows in the 'indigenous_food_systems' table, filtering by country."}
{"sql_prompt":"List vegan skincare products with a price below 15 EUR, available in Spain","sql_context":"CREATE TABLE products (product_id INT, product_name TEXT, price DECIMAL(5,2), is_vegan BOOLEAN, country TEXT);","sql":"SELECT * FROM products WHERE is_vegan = TRUE AND price < 15 AND country = 'Spain';","sql_explanation":"1. Select all records from the 'products' table. 2. Filter records for vegan skincare products with a price below 15 EUR and available in Spain."}
{"sql_prompt":"Delete broadband subscribers who have not used their service in the last 6 months.","sql_context":"CREATE TABLE broadband_subscribers_usage (subscriber_id INT, usage_date DATE); INSERT INTO broadband_subscribers_usage (subscriber_id, usage_date) VALUES (17, '2022-01-02'); INSERT INTO broadband_subscribers_usage (subscriber_id, usage_date) VALUES (18, '2022-02-03');","sql":"DELETE FROM broadband_subscribers WHERE subscriber_id NOT IN (SELECT subscriber_id FROM broadband_subscribers_usage WHERE usage_date >= DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH));","sql_explanation":"The SQL query first selects all subscriber_ids from the broadband_subscribers_usage table that have usage_date within the last 6 months, then deletes all records from the broadband_subscribers table that are not in the selected list."}
{"sql_prompt":"What is the change in yield for each crop over time, for a specific farm?","sql_context":"CREATE TABLE farming (id INT, name TEXT, location TEXT, crop TEXT, yield INT, year INT); INSERT INTO farming VALUES (1, 'Smith Farm', 'Colorado', 'Corn', 120, 2020), (2, 'Brown Farm', 'Nebraska', 'Soybeans', 45, 2020), (3, 'Jones Farm', 'Iowa', 'Wheat', 80, 2020), (1, 'Smith Farm', 'Colorado', 'Corn', 130, 2021), (2, 'Brown Farm', 'Nebraska', 'Soybeans', 50, 2021), (3, 'Jones Farm', 'Iowa', 'Wheat', 85, 2021);","sql":"SELECT crop, (yield - LAG(yield) OVER (PARTITION BY crop, name ORDER BY year)) as yield_change FROM farming WHERE name = 'Smith Farm';","sql_explanation":"This query calculates the change in yield for each crop over time for a specific farm by partitioning the farming table by the 'crop' and 'name' columns and then ordering the rows by the 'year' column. The LAG() function is used to access the yield of the previous year for each crop on the specific farm. The yield change is calculated as the current yield minus the previous year's yield for each crop on the specific farm."}
{"sql_prompt":"What is the minimum ride duration for ride-hailing services in Singapore?","sql_context":"CREATE TABLE ride_hailing (ride_id INT, ride_duration INT); INSERT INTO ride_hailing (ride_id, ride_duration) VALUES (1, 10), (2, 15), (3, 20), (4, 25);","sql":"SELECT MIN(ride_duration) as min_duration FROM ride_hailing;","sql_explanation":"Find the minimum ride duration for ride-hailing services in Singapore by selecting the minimum value of ride_duration from the ride_hailing table."}
{"sql_prompt":"Which suppliers provide the most \"Free-Range Chicken\" and \"Grass-Fed Beef\"?","sql_context":"CREATE TABLE Suppliers(supplier VARCHAR(20), product VARCHAR(20), quantity INT); INSERT INTO Suppliers(supplier, product, quantity) VALUES('Supplier A', 'Free-Range Chicken', 100), ('Supplier B', 'Grass-Fed Beef', 150), ('Supplier A', 'Grass-Fed Beef', 75);","sql":"SELECT supplier, product, SUM(quantity) as total_quantity FROM Suppliers GROUP BY supplier, product ORDER BY SUM(quantity) DESC;","sql_explanation":"This SQL query groups the supplier data by supplier and product and calculates the total quantity of each product supplied. It then orders the results by the total quantity in descending order, to show which suppliers provide the most \"Free-Range Chicken\" and \"Grass-Fed Beef\"."}
{"sql_prompt":"What is the average budget for all projects in the infrastructure development database?","sql_context":"CREATE TABLE if not exists Projects (id INT, name VARCHAR(50), type VARCHAR(50), budget DECIMAL(10,2)); INSERT INTO Projects (id, name, type, budget) VALUES (1, 'Seawall', 'Resilience', 5000000.00), (2, 'Floodgate', 'Resilience', 3000000.00), (3, 'Bridge', 'Transportation', 8000000.00), (4, 'Highway', 'Transportation', 12000000.00);","sql":"SELECT AVG(budget) FROM Projects;","sql_explanation":"This query calculates the average budget for all projects in the infrastructure development database by averaging the budget column."}
{"sql_prompt":"How many drought-impacted regions are in Egypt and their average impact scores?","sql_context":"CREATE TABLE drought_impact_EG (region VARCHAR(50), country VARCHAR(20), impact_score INT); INSERT INTO drought_impact_EG (region, country, impact_score) VALUES ('Region1', 'Egypt', 60), ('Region2', 'Egypt', 70);","sql":"SELECT COUNT(*), AVG(impact_score) FROM drought_impact_EG WHERE country = 'Egypt';","sql_explanation":"The SQL query counts the number of drought-impacted regions and calculates their average impact scores in Egypt by using COUNT(*) and AVG functions for the 'impact_score' column values in the 'Egypt' country."}
{"sql_prompt":"How many biosensors were developed in 2021?","sql_context":"CREATE TABLE biosensor_development (name TEXT, year INT); INSERT INTO biosensor_development (name, year) VALUES ('BioSensor1', 2020); INSERT INTO biosensor_development (name, year) VALUES ('BioSensor2', 2021);","sql":"SELECT COUNT(*) FROM biosensor_development WHERE year = 2021;","sql_explanation":"The SQL query filters the biosensor_development table for entries in 2021 and then counts the number of records."}
{"sql_prompt":"What is the maximum daily water usage in MWh for the industrial sector in October 2021?","sql_context":"CREATE TABLE max_daily_water_usage (year INT, month INT, sector VARCHAR(20), day INT, usage FLOAT); INSERT INTO max_daily_water_usage (year, month, sector, day, usage) VALUES (2021, 10, 'industrial', 1, 8000); INSERT INTO max_daily_water_usage (year, month, sector, day, usage) VALUES (2021, 10, 'industrial', 2, 8500); INSERT INTO max_daily_water_usage (year, month, sector, day, usage) VALUES (2021, 10, 'industrial', 3, 9000);","sql":"SELECT MAX(usage) FROM max_daily_water_usage WHERE year = 2021 AND month = 10 AND sector = 'industrial';","sql_explanation":"This query calculates the maximum daily water usage (in MWh) for the industrial sector in October 2021 by selecting the maximum 'usage' value in the max_daily_water_usage table where the year is 2021, month is 10, and sector is 'industrial'."}
{"sql_prompt":"Find and delete duplicate records in the resource_depletion table","sql_context":"CREATE TABLE resource_depletion (id INT, resource VARCHAR(255), depletion_rate DECIMAL(10,2));","sql":"DELETE t1 FROM resource_depletion t1 INNER JOIN (SELECT id, resource, depletion_rate, COUNT(*) FROM resource_depletion GROUP BY resource, depletion_rate HAVING COUNT(*) > 1) t2 ON t1.resource = t2.resource AND t1.depletion_rate = t2.depletion_rate AND t1.id < t2.id;","sql_explanation":"This query finds and deletes duplicate records in the resource_depletion table based on the resource and depletion_rate columns. It uses a self-join to match records with the same resource and depletion_rate, and then deletes the record with the lower id."}
{"sql_prompt":"List all the Praseodymium production data from 2018 to 2020","sql_context":"CREATE TABLE production_praseodymium (year INT, quantity INT); INSERT INTO production_praseodymium (year, quantity) VALUES (2015, 800), (2016, 900), (2017, 1000), (2018, 1200), (2019, 1400), (2020, 1600), (2021, 1800);","sql":"SELECT * FROM production_praseodymium WHERE year BETWEEN 2018 AND 2020;","sql_explanation":"This query lists all the production data for Praseodymium from the years 2018 to 2020 by selecting all columns from the production_praseodymium table where the year is between 2018 and 2020."}
{"sql_prompt":"Delete all comments made by users under 18 years old.","sql_context":"CREATE TABLE comments (id INT, user_id INT, article_id INT, comment TEXT, created_at DATETIME); INSERT INTO comments (id, user_id, article_id, comment, created_at) VALUES (1, 123, 456, 'Great article!', '2021-12-20 15:22:00');","sql":"DELETE FROM comments WHERE DATEDIFF('day', created_at, NOW()) < 18 * 365","sql_explanation":"Delete all comments made by users under 18 years old. Find the difference between the created_at date and the current date (NOW()) for each comment and delete those where this difference is less than 18 years (365 days * 18)."}
{"sql_prompt":"What is the minimum distance traveled by autonomous vehicles in the 'autonomous_vehicles' table, grouped by their 'vehicle_type'?","sql_context":"CREATE TABLE autonomous_vehicles (id INT, vehicle_type VARCHAR(255), manufacturer VARCHAR(255), distance_traveled INT);","sql":"SELECT vehicle_type, MIN(distance_traveled) FROM autonomous_vehicles GROUP BY vehicle_type;","sql_explanation":"The SQL query calculates the minimum distance traveled by autonomous vehicles in the 'autonomous_vehicles' table, grouped by their 'vehicle_type'. It uses the MIN() function to find the minimum distance traveled for each vehicle type and the GROUP BY clause to group the results by vehicle type."}
{"sql_prompt":"What is the total number of projects in the 'climate_mitigation' table?","sql_context":"CREATE TABLE climate_mitigation (project_id INT, project_name VARCHAR(255), location VARCHAR(255), start_date DATE, end_date DATE);","sql":"SELECT COUNT(*) FROM climate_mitigation;","sql_explanation":"This SQL query counts all records in the 'climate_mitigation' table by using the COUNT(*) function."}
{"sql_prompt":"Find the average soil moisture reading for each crop type in the month of May for 2021.","sql_context":"CREATE TABLE crop_data (id INT, crop_type VARCHAR(255), soil_moisture INT, measurement_date DATE); INSERT INTO crop_data (id, crop_type, soil_moisture, measurement_date) VALUES (1, 'Corn', 60, '2021-05-01'); INSERT INTO crop_data (id, crop_type, soil_moisture, measurement_date) VALUES (2, 'Soybean', 55, '2021-05-03');","sql":"SELECT crop_type, AVG(soil_moisture) as avg_moisture FROM crop_data WHERE measurement_date BETWEEN '2021-05-01' AND '2021-05-31' GROUP BY crop_type;","sql_explanation":"This query calculates the average soil moisture reading for each crop type in May 2021. It filters the crop_data table for records with measurement dates in May 2021, groups the results by crop_type, and calculates the average soil moisture for each group."}
{"sql_prompt":"What is the name and production date of the machines in the 'circular_economy' category that have a production date after 2015?","sql_context":"CREATE TABLE machines (id INT, name VARCHAR(255), category VARCHAR(255), production_date DATE); INSERT INTO machines (id, name, category, production_date) VALUES (1, 'ABC Machine', 'circular_economy', '2016-01-01'), (2, 'XYZ Machine', 'circular_economy', '2014-01-01'), (3, 'DEF Machine', 'circular_economy', '2017-01-01');","sql":"SELECT name, production_date FROM machines WHERE category = 'circular_economy' AND production_date > '2015-01-01';","sql_explanation":"This SQL query finds the name and production date of the machines in the 'circular_economy' category that have a production date after 2015 by using the WHERE clause to filter the machines table to only show machines in the 'circular_economy' category that have a production date after 2015."}
{"sql_prompt":"What is the count of incidents for each type at each location, and what is the percentage of the total count for each location?","sql_context":"CREATE TABLE incidents(id INT, location VARCHAR(255), type VARCHAR(255), timestamp TIMESTAMP);","sql":"SELECT location, type, COUNT(*) as incident_count, incident_count * 100.0 \/ SUM(COUNT(*)) OVER (PARTITION BY location) as percentage FROM incidents GROUP BY location, type;","sql_explanation":"This query calculates the count of incidents for each type at each location and calculates the percentage of the total count for each location using a window function. The PARTITION BY clause is used to reset the percentage for each location."}
{"sql_prompt":"Find the difference in technology accessibility scores between the first and last quarters for each region.","sql_context":"CREATE TABLE accessibility (region VARCHAR(50), quarter INT, score INT); INSERT INTO accessibility (region, quarter, score) VALUES ('Americas', 1, 80), ('Americas', 2, 85), ('Americas', 3, 75), ('Americas', 4, 90), ('APAC', 1, 70), ('APAC', 2, 75), ('APAC', 3, 80), ('APAC', 4, 85);","sql":"SELECT region, LAG(score, 3) OVER (PARTITION BY region ORDER BY quarter) - score as diff FROM accessibility;","sql_explanation":"The SQL query uses the LAG() function with a window of 3 to get the technology accessibility score of the first quarter for each region. It then calculates the difference between the score of the first quarter and the score of the last quarter."}
{"sql_prompt":"What is the maximum cost of a defense contract in Japan?","sql_context":"CREATE TABLE defense_contracts (id INT, country VARCHAR(50), cost FLOAT); INSERT INTO defense_contracts (id, country, cost) VALUES (1, 'Japan', 1750000), (2, 'Japan', 700000), (3, 'Japan', 1100000);","sql":"SELECT MAX(cost) FROM defense_contracts WHERE country = 'Japan';","sql_explanation":"This query finds the maximum cost of a defense contract in Japan by selecting the MAX function on the cost column, filtering the data where the country is Japan."}
{"sql_prompt":"How many works were exhibited in the year 1950?","sql_context":"CREATE TABLE exhibitions (exhibition_id INT PRIMARY KEY, exhibition_name TEXT, year INT, location TEXT);CREATE TABLE exhibits (exhibit_id INT PRIMARY KEY, work_id INT, exhibition_id INT, FOREIGN KEY (work_id) REFERENCES works(work_id), FOREIGN KEY (exhibition_id) REFERENCES exhibitions(exhibition_id));INSERT INTO exhibitions (exhibition_id, exhibition_name, year, location) VALUES (1, 'Documenta', 1950, 'Kassel, Germany'); INSERT INTO exhibits (exhibit_id, work_id, exhibition_id) VALUES (1, 1, 1);","sql":"SELECT COUNT(*) FROM exhibits e JOIN exhibitions ex ON e.exhibition_id = ex.exhibition_id WHERE ex.year = 1950;","sql_explanation":"The SQL query joins the exhibits and exhibitions tables on the exhibition_id foreign key. It then filters for exhibitions in the year 1950 and counts the number of corresponding exhibit records."}
{"sql_prompt":"What is the average carbon sequestration per hectare for each region?","sql_context":"CREATE TABLE carbon_sequestration(region VARCHAR(255), sequestration FLOAT, area INT); INSERT INTO carbon_sequestration(region, sequestration, area) VALUES ('North', 5.6, 1000), ('South', 4.8, 1500), ('East', 6.2, 1200), ('West', 5.1, 1800);","sql":"SELECT region, AVG(sequestration) FROM carbon_sequestration;","sql_explanation":"The SQL query calculates the average carbon sequestration per hectare by dividing the total sequestration by the total area for each region using the AVG() function."}
{"sql_prompt":"What is the difference in the average duration of closed cases between attorneys in the \"criminal_defense\" department, ordered by the difference?","sql_context":"CREATE TABLE attorneys (attorney_id INT, name VARCHAR(50), department VARCHAR(50)); INSERT INTO attorneys (attorney_id, name, department) VALUES (1, 'John Doe', 'criminal_defense'); INSERT INTO attorneys (attorney_id, name, department) VALUES (2, 'Jane Smith', 'criminal_defense'); CREATE TABLE cases (case_id INT, attorney_id INT, status VARCHAR(50), duration INT); INSERT INTO cases (case_id, attorney_id, status, duration) VALUES (1, 1, 'closed', 25); INSERT INTO cases (case_id, attorney_id, status, duration) VALUES (2, 1, 'closed', 30); INSERT INTO cases (case_id, attorney_id, status, duration) VALUES (3, 2, 'closed', 40);","sql":"SELECT attorney_id, AVG(duration) - LAG(AVG(duration)) OVER (PARTITION BY attorney_id ORDER BY attorney_id) as difference FROM cases WHERE status = 'closed' GROUP BY attorney_id ORDER BY difference;","sql_explanation":"The SQL query calculates the difference in the average duration of closed cases between attorneys in the specified department and orders the results by the difference. The AVG function is used to calculate the average duration of closed cases for each attorney, and the LAG function with the OVER clause is used to get the previous attorney's average duration. The difference between the current and previous attorney's average duration is then calculated and the results are ordered by this difference."}
{"sql_prompt":"What is the earliest launch date for each space mission?","sql_context":"CREATE TABLE SpaceMission (ID INT, Name VARCHAR(50), LaunchDate DATE);","sql":"SELECT Name, MIN(LaunchDate) AS EarliestLaunchDate FROM SpaceMission GROUP BY Name;","sql_explanation":"This query finds the earliest launch date for each space mission. It uses the MIN function to get the minimum launch date for each mission, grouped by the Name column."}
{"sql_prompt":"What is the average water consumption in the agricultural sector in Australia for the year 2020?","sql_context":"CREATE TABLE water_consumption_kl (region VARCHAR(20), sector VARCHAR(20), year INT, value FLOAT); INSERT INTO water_consumption_kl (region, sector, year, value) VALUES ('Australia', 'Agricultural', 2020, 12000000);","sql":"SELECT AVG(value) FROM water_consumption_kl WHERE sector = 'Agricultural' AND region = 'Australia' AND year = 2020;","sql_explanation":"This query selects the average value from the water_consumption_kl table where the sector is 'Agricultural' and region is 'Australia' for the year 2020. The average value returned represents the average water consumption in the agricultural sector in Australia for the year 2020."}
{"sql_prompt":"What is the number of flu cases in each region?","sql_context":"CREATE TABLE flu_cases(id INT, patient_id INT, region TEXT, date DATE);","sql":"SELECT region, COUNT(*) FROM flu_cases GROUP BY region;","sql_explanation":"This query groups flu_cases by region using the GROUP BY clause and then counts the number of flu cases in each region using the COUNT(*) aggregate function."}
{"sql_prompt":"What is the distribution of trips by mode of transport?","sql_context":"CREATE TABLE trips (user_id INT, trip_date DATE, mode VARCHAR(50), trip_count INT);","sql":"SELECT mode, SUM(trip_count) as total_trips FROM trips GROUP BY mode;","sql_explanation":"The SQL query calculates the distribution of trips by mode of transport by summing the trip_count column and grouping by mode."}
{"sql_prompt":"Delete records from the safety_records table where the status is 'Failed' and the inspection_date is after '2022-06-01'","sql_context":"CREATE TABLE safety_records (id INT PRIMARY KEY, vessel_id INT, inspection_date DATE, status VARCHAR(255)); INSERT INTO safety_records (id, vessel_id, inspection_date, status) VALUES (1, 1, '2022-03-01', 'Passed'), (2, 2, '2022-06-03', 'Failed'), (3, 3, '2021-03-01', 'Passed');","sql":"DELETE FROM safety_records WHERE status = 'Failed' AND inspection_date > '2022-06-01';","sql_explanation":"* The DELETE statement is used to remove records from the safety_records table.* The WHERE clause filters the records based on the status and inspection_date columns.* The condition status = 'Failed' AND inspection_date > '2022-06-01' selects records with a status of 'Failed' and an inspection_date after 2022-06-01."}
{"sql_prompt":"Show the top 3 cities with the highest total ticket sales.","sql_context":"CREATE TABLE concerts (id INT, country VARCHAR(255), city VARCHAR(255), artist_name VARCHAR(255), tier VARCHAR(255), price DECIMAL(10,2), num_tickets INT); CREATE VIEW city_sales AS SELECT city, SUM(price * num_tickets) AS total_sales FROM concerts GROUP BY city;","sql":"SELECT city, total_sales FROM city_sales ORDER BY total_sales DESC LIMIT 3;","sql_explanation":"This query shows the top 3 cities with the highest total ticket sales by first creating a view of city and total sales, then selecting city and total sales and sorting by total sales in descending order, and limiting to the top 3 results."}
{"sql_prompt":"Insert records for a new team, 'Seattle Kraken'","sql_context":"CREATE TABLE players (player_id INT, name VARCHAR(100), position VARCHAR(50), team_id INT); CREATE TABLE teams (team_id INT, name VARCHAR(100), city VARCHAR(100)); INSERT INTO players (player_id, name, position, team_id) VALUES (1, 'John Doe', 'Forward', 1), (2, 'Jane Smith', 'Goalie', 2); INSERT INTO teams (team_id, name, city) VALUES (1, 'Boston Bruins', 'Boston'), (2, 'New York Rangers', 'New York');","sql":"INSERT INTO teams (team_id, name, city) VALUES (3, 'Seattle Kraken', 'Seattle');","sql_explanation":"This query inserts a new record into the teams table for the Seattle Kraken, assigning them a team_id of 3."}
{"sql_prompt":"List all autonomous taxis and their makes, grouped by city, in the 'taxis' table.","sql_context":"CREATE TABLE taxis (id INT, make VARCHAR(20), model VARCHAR(20), year INT, city VARCHAR(20), autonomous BOOLEAN);","sql":"SELECT city, make FROM taxis WHERE autonomous = TRUE GROUP BY city;","sql_explanation":"The SQL query selects the 'city' and 'make' columns from the 'taxis' table where the 'autonomous' column is true, and groups the results by the 'city' column."}
{"sql_prompt":"What is the total value of surrealist art pieces?","sql_context":"CREATE TABLE ArtPieces (id INT, title VARCHAR(50), galleryId INT, year INT, value INT, style VARCHAR(20)); INSERT INTO ArtPieces (id, title, galleryId, year, value, style) VALUES (1, 'Piece 1', 1, 2000, 10000, 'Impressionism'), (2, 'Piece 2', 1, 2010, 15000, 'Surrealism'), (3, 'Piece 3', 2, 2020, 20000, 'Cubism'), (4, 'Piece 4', 3, 1990, 5000, 'Surrealism'), (5, 'Piece 5', NULL, 1874, 25000, 'Impressionism');","sql":"SELECT SUM(value) FROM ArtPieces WHERE style = 'Surrealism';","sql_explanation":"This query filters art pieces by the 'style' column and selects the sum of the 'value' column where 'style' is 'Surrealism'. It calculates the total value of surrealist art pieces."}
{"sql_prompt":"What are the total quantities of items shipped to each continent?","sql_context":"CREATE TABLE Shipment (id INT, source_country VARCHAR(255), destination_continent VARCHAR(255), quantity INT); INSERT INTO Shipment (id, source_country, destination_continent, quantity) VALUES (1, 'China', 'Asia', 500), (2, 'United States', 'North America', 300), (3, 'Germany', 'Europe', 200), (4, 'Brazil', 'South America', 100);","sql":"SELECT destination_continent, SUM(quantity) FROM Shipment GROUP BY destination_continent","sql_explanation":"This query groups the 'Shipment' table by the 'destination_continent' column and calculates the sum of the 'quantity' column for each group, returning the total quantities shipped to each continent."}
{"sql_prompt":"What is the maximum speed recorded for vessels in the Baltic Sea, and which vessels achieved this speed?","sql_context":"CREATE TABLE vessel_speed (id INT, vessel_id INT, speed FLOAT, speed_date DATE, speed_location TEXT);","sql":"SELECT vessel_id, MAX(speed) FROM vessel_speed WHERE speed_location = 'Baltic Sea' GROUP BY vessel_id HAVING MAX(speed) = (SELECT MAX(speed) FROM vessel_speed WHERE speed_location = 'Baltic Sea');","sql_explanation":"This query calculates the maximum speed recorded for vessels in the Baltic Sea and the vessels that achieved this speed. It does this by filtering the vessel_speed table for rows where speed_location is 'Baltic Sea' and using the MAX function to find the maximum speed. It then uses the GROUP BY clause to group the rows by vessel_id and the HAVING clause to only include rows where the maximum speed for each vessel_id is equal to the overall maximum speed."}
{"sql_prompt":"Which female founders have received the most funding?","sql_context":"CREATE TABLE founders (founder_id INT, founder_name VARCHAR(50), gender CHAR(1), startup_id INT); CREATE TABLE startups (startup_id INT, funding_amount INT); INSERT INTO founders VALUES (1, 'Alice', 'F', 1), (2, 'Bob', 'M', 2), (3, 'Charlie', 'M', 3); INSERT INTO startups VALUES (1, 500000), (2, 750000), (3, 300000);","sql":"SELECT f.founder_name, SUM(s.funding_amount) as total_funding FROM founders f JOIN startups s ON f.startup_id = s.startup_id WHERE f.gender = 'F' GROUP BY f.founder_name ORDER BY total_funding DESC;","sql_explanation":"This query calculates the total funding received by female founders by joining the founders and startups tables based on the startup_id and summing up the funding_amount values. The result is ordered in descending order of total funding."}
{"sql_prompt":"What is the total amount spent on each program type in the year 2019, sorted by the total amount spent in descending order?","sql_context":"CREATE TABLE Programs (ProgramType TEXT, Budget DECIMAL(10,2)); CREATE TABLE Spending (SpendingID INT, ProgramType TEXT, SpendingDate DATE, Amount DECIMAL(10,2));","sql":"SELECT P.ProgramType, SUM(S.Amount) as TotalSpending FROM Spending S JOIN Programs P ON S.ProgramType = P.ProgramType WHERE YEAR(SpendingDate) = 2019 GROUP BY P.ProgramType ORDER BY TotalSpending DESC;","sql_explanation":"This query first joins the Spending and Programs tables on the ProgramType field. It then filters for spending in the year 2019. For each program type, it calculates the total amount spent by summing the Amount field. Finally, it sorts the results by the total amount spent in descending order."}
{"sql_prompt":"Which community health workers received more than two types of trainings?","sql_context":"CREATE TABLE CommunityHealthWorkerTrainings (WorkerID INT, Training VARCHAR(50)); INSERT INTO CommunityHealthWorkerTrainings (WorkerID, Training) VALUES (1, 'Cultural Competency'), (2, 'Mental Health First Aid'), (3, 'Crisis Prevention'), (4, 'Cultural Competency'), (5, 'Motivational Interviewing'), (1, 'Language Access'), (6, 'Cultural Competency'), (7, 'Mental Health First Aid'), (8, 'Crisis Prevention'), (9, 'Cultural Competency'), (10, 'Motivational Interviewing'), (11, 'Cultural Competency'), (12, 'Mental Health First Aid'), (13, 'Crisis Prevention'), (14, 'Cultural Competency'), (15, 'Motivational Interviewing');","sql":"SELECT WorkerID FROM (SELECT WorkerID, COUNT(DISTINCT Training) as NumTrainings FROM CommunityHealthWorkerTrainings GROUP BY WorkerID) as distinct_trainings WHERE NumTrainings > 2;","sql_explanation":"This query first groups the CommunityHealthWorkerTrainings table by WorkerID and counts the number of distinct trainings received by each worker. It then filters the results to only include workers who have received more than two types of trainings."}
{"sql_prompt":"Determine the average engagement time for virtual tours in each city.","sql_context":"CREATE TABLE virtual_tours (tour_id INT, city TEXT, engagement_time FLOAT); INSERT INTO virtual_tours (tour_id, city, engagement_time) VALUES (1, 'Tokyo', 15.5), (2, 'Tokyo', 12.3), (3, 'Osaka', 18.1);","sql":"SELECT city, AVG(engagement_time) FROM virtual_tours GROUP BY city;","sql_explanation":"This SQL query calculates the average engagement time for virtual tours in each city. It first groups the virtual_tours table by city, then calculates the average engagement_time for the matching rows for each group."}
{"sql_prompt":"What is the average donation amount for each age group?","sql_context":"CREATE TABLE DonorAges (Id INT, AgeGroup VARCHAR(20), DonationAmount DECIMAL(10, 2)); INSERT INTO DonorAges (Id, AgeGroup, DonationAmount) VALUES (1, '18-35', 100.00), (2, '36-50', 150.00), (3, '51-65', 75.00), (4, '18-35', 50.00);","sql":"SELECT AgeGroup, AVG(DonationAmount) FROM DonorAges GROUP BY AgeGroup;","sql_explanation":"This query calculates the average donation amount for each age group by grouping the DonationAmount column by the AgeGroup column and then calculating the average of DonationAmount for each group."}
{"sql_prompt":"Identify the artist with the most works in the 'Modern Art' gallery.","sql_context":"CREATE TABLE Art (artist TEXT, gallery TEXT, piece_name TEXT); INSERT INTO Art (artist, gallery, piece_name) VALUES ('Picasso', 'Modern Art', 'Guernica'); INSERT INTO Art (artist, gallery, piece_name) VALUES ('Van Gogh', 'Modern Art', 'Starry Night'); INSERT INTO Art (artist, gallery, piece_name) VALUES ('Matisse', 'Modern Art', 'The Dance'); INSERT INTO Art (artist, gallery, piece_name) VALUES ('Dali', 'Surrealism', 'Persistence of Memory');","sql":"SELECT artist, COUNT(piece_name) AS piece_count FROM Art WHERE gallery = 'Modern Art' GROUP BY artist ORDER BY piece_count DESC LIMIT 1;","sql_explanation":"This SQL query identifies the artist with the most works in the 'Modern Art' gallery by selecting the artist column and using the COUNT function to count the number of piece_name entries for each artist. It filters the Art table to only include rows where the gallery column is equal to 'Modern Art' and groups the results by artist. The query then orders the grouped results by piece_count in descending order and limits the results to 1 row, which is the artist with the most works."}
{"sql_prompt":"How many vendors offer gluten-free options in the downtown area?","sql_context":"CREATE TABLE VendorLocation (VendorID INT, Location VARCHAR(50)); INSERT INTO VendorLocation (VendorID, Location) VALUES (1, 'Downtown'), (2, 'Uptown'); CREATE TABLE MenuItems (MenuItemID INT, VendorID INT, MenuItemName VARCHAR(50), MenuItemType VARCHAR(50), GlutenFree VARCHAR(5)); INSERT INTO MenuItems (MenuItemID, VendorID, MenuItemName, MenuItemType, GlutenFree) VALUES (1, 1, 'Chicken Caesar Salad', 'Salad', 'Yes'), (2, 1, 'Ham Sandwich', 'Sandwich', 'No'), (3, 2, 'Beef Burrito', 'Mexican', 'No');","sql":"SELECT COUNT(*) FROM MenuItems WHERE VendorID IN (SELECT VendorID FROM VendorLocation WHERE Location = 'Downtown') AND GlutenFree = 'Yes';","sql_explanation":"This query calculates the number of vendors that offer gluten-free options in the downtown area by counting all records (COUNT*) in the MenuItems table where VendorID is in the VendorLocation table with Location 'Downtown' and GlutenFree is 'Yes'."}
{"sql_prompt":"Delete all records from the CoralReefs table that represent reefs with a health status of \"Degraded\".","sql_context":"CREATE TABLE CoralReefs (Name VARCHAR(255), Location VARCHAR(255), Health_Status VARCHAR(255)); INSERT INTO CoralReefs (Name, Location, Health_Status) VALUES ('Great Barrier Reef', 'Australia', 'Degraded'), ('Palau Reef', 'Palau', 'Healthy'), ('Belize Barrier Reef', 'Belize', 'Vulnerable');","sql":"DELETE FROM CoralReefs WHERE Health_Status = 'Degraded';","sql_explanation":"The SQL query deletes all records from the CoralReefs table that represent reefs with a health status of \"Degraded\". It uses the WHERE clause to specifically target reefs with a degraded health status."}
{"sql_prompt":"What is the average severity of vulnerabilities in the 'Malware' category?","sql_context":"CREATE TABLE vulnerabilities (id INT, name TEXT, category TEXT, severity TEXT, date_discovered DATE); INSERT INTO vulnerabilities (id, name, category, severity, date_discovered) VALUES (1, 'Remote Code Execution', 'Malware', 'Critical', '2022-01-01');","sql":"SELECT AVG(severity = 'Critical') + AVG(severity = 'High') * 0.75 + AVG(severity = 'Medium') * 0.5 + AVG(severity = 'Low') * 0.25 as average FROM vulnerabilities WHERE category = 'Malware';","sql_explanation":"This query calculates the average severity of vulnerabilities in the 'Malware' category. It uses the CASE statement to assign a weight to each severity level (Critical = 1, High = 0.75, Medium = 0.5, Low = 0.25). The query then calculates the average weight for all vulnerabilities in the 'Malware' category."}
{"sql_prompt":"What is the average carbon footprint of products manufactured in each region?","sql_context":"CREATE TABLE regions (id INT, name TEXT); CREATE TABLE manufacturers (id INT, name TEXT, region_id INT, carbon_footprint INT); INSERT INTO regions (id, name) VALUES (1, 'Region 1'), (2, 'Region 2'), (3, 'Region 3'); INSERT INTO manufacturers (id, name, region_id, carbon_footprint) VALUES (1, 'Manufacturer 1', 1, 50), (2, 'Manufacturer 2', 2, 70), (3, 'Manufacturer 3', 3, 30), (4, 'Manufacturer 4', 1, 60), (5, 'Manufacturer 5', 2, 40);","sql":"SELECT regions.name, AVG(manufacturers.carbon_footprint) FROM regions INNER JOIN manufacturers ON regions.id = manufacturers.region_id GROUP BY regions.name;","sql_explanation":"The SQL query calculates the average carbon footprint of products manufactured in each region by performing an inner join between the regions and manufacturers table on the region_id column and grouping the rows by the name column in the regions table. It then computes the average of the carbon_footprint column from the resulting rows."}
{"sql_prompt":"Which cities have donors but no active programs?","sql_context":"CREATE TABLE Donors (id INT, donor_name VARCHAR(50), email VARCHAR(50), city VARCHAR(50)); INSERT INTO Donors (id, donor_name, email, city) VALUES (3, 'Maria Garcia', 'mariagarcia@example.com', 'Miami'), (4, 'Hiroshi Tanaka', 'hiroshitanaka@example.com', 'San Francisco'); CREATE TABLE Programs (id INT, program_name VARCHAR(50), city VARCHAR(50)); INSERT INTO Programs (id, program_name, city) VALUES (3, 'Disaster Relief', 'New York'), (4, 'Refugee Support', 'Seattle');","sql":"SELECT city FROM Donors WHERE city NOT IN (SELECT city FROM Programs);","sql_explanation":"This query returns the cities of donors who live in cities without active programs by using the NOT IN operator to filter cities not present in the Programs table."}
{"sql_prompt":"What is the average recycling rate in the state of California for the year 2020?","sql_context":"CREATE TABLE recycling_rates (state VARCHAR(20), year INT, recycling_rate FLOAT); INSERT INTO recycling_rates (state, year, recycling_rate) VALUES ('California', 2020, 55.5);","sql":"SELECT recycling_rate FROM recycling_rates WHERE state = 'California' AND year = 2020;","sql_explanation":"This query filters the recycling_rates table to the state of California and the year 2020 and returns the recycling rate."}
{"sql_prompt":"What is the average delivery time for shipments to the Southeast region, grouped by shipment type?","sql_context":"CREATE SCHEMA IF NOT EXISTS logistics;CREATE TABLE IF NOT EXISTS shipments (shipment_id INT,region VARCHAR(20),shipment_type VARCHAR(20),delivery_time INT);INSERT INTO shipments (shipment_id, region, shipment_type, delivery_time) VALUES (1, 'Southeast', 'domestic', 3), (2, 'Northeast', 'international', 7), (3, 'Southeast', 'domestic', 2);","sql":"SELECT shipment_type, AVG(delivery_time) FROM logistics.shipments WHERE region = 'Southeast' GROUP BY shipment_type;","sql_explanation":"This query calculates the average delivery time for shipments to the Southeast region, grouped by shipment type. It does this by filtering the shipments table to only include rows where the region is 'Southeast'. It then calculates the average delivery time for each shipment type by grouping the results by shipment_type and calculating the average of the delivery_time column for each group."}
{"sql_prompt":"What are the items with low stock levels and their cost that are not supplied by 'XYZ Corporation'?","sql_context":"CREATE TABLE Suppliers (SupplierID INT, Name VARCHAR(50), Item VARCHAR(50), Quantity INT, Cost DECIMAL(5,2)); CREATE VIEW LowStock AS SELECT SupplierID, Item FROM Suppliers WHERE Quantity < 10;","sql":"SELECT Suppliers.Item, Suppliers.Cost FROM Suppliers JOIN LowStock ON Suppliers.SupplierID = LowStock.SupplierID WHERE Suppliers.Name != 'XYZ Corporation';","sql_explanation":"This query first creates a view called LowStock that includes only the SupplierID and Item fields for suppliers who have less than 10 units of a given item. Then, it joins the Suppliers table with the LowStock view on the SupplierID field and filters for rows where the Suppliers.Name field is not equal to 'XYZ Corporation'. The result is a list of items with low stock levels and their cost that are not supplied by 'XYZ Corporation'."}
{"sql_prompt":"What is the count of bridges in California with seismic retrofit needs, categorized by bridge type and construction year?","sql_context":"CREATE TABLE Bridges (id INT, state VARCHAR(2), bridge_type VARCHAR(10), construction_year INT, seismic_retrofit_need BOOLEAN); INSERT INTO Bridges (id, state, bridge_type, construction_year, seismic_retrofit_need) VALUES (1, 'CA', 'Beam', 1960, TRUE), (2, 'CA', 'Arch', 1990, FALSE), (3, 'CA', 'Suspension', 2010, TRUE);","sql":"SELECT bridge_type, construction_year, COUNT(*) as count FROM Bridges WHERE state = 'CA' AND seismic_retrofit_need = TRUE GROUP BY bridge_type, construction_year;","sql_explanation":"This query calculates the count of bridges in California with seismic retrofit needs, categorized by bridge type and construction year. It groups the data by bridge type and construction year, then calculates the count for each group."}
{"sql_prompt":"Find the total budget allocated for public services in each state.","sql_context":"CREATE SCHEMA gov_data;CREATE TABLE gov_data.budget_allocation (state VARCHAR(20), service VARCHAR(20), budget INT); INSERT INTO gov_data.budget_allocation (state, service, budget) VALUES ('California', 'Education', 3000000), ('California', 'Healthcare', 4000000), ('Texas', 'Education', 2000000), ('Texas', 'Healthcare', 2500000), ('New York', 'Education', 2500000), ('New York', 'Healthcare', 3000000);","sql":"SELECT state, SUM(budget) as total_budget FROM gov_data.budget_allocation GROUP BY state;","sql_explanation":"This query finds the total budget allocated for public services in each state by grouping the budget_allocation table by state and summing up the budget values for each state."}
{"sql_prompt":"What is the average budget allocated per department for the years 2021 and 2022?","sql_context":"CREATE TABLE Department (id INT, name VARCHAR(255), budget FLOAT, year INT); INSERT INTO Department (id, name, budget, year) VALUES (1, 'Education', 5000000, 2021), (2, 'Healthcare', 7000000, 2021), (3, 'Transportation', 8000000, 2021), (4, 'Education', 6000000, 2022), (5, 'Healthcare', 8000000, 2022), (6, 'Transportation', 9000000, 2022);","sql":"SELECT AVG(budget) FROM Department WHERE year IN (2021, 2022);","sql_explanation":"This query calculates the average budget allocated per department for the years 2021 and 2022 by averaging the budget values from the Department table where the year field is 2021 or 2022."}
{"sql_prompt":"Delete the 'Forest Friends' program record in the 'education_programs' table","sql_context":"CREATE TABLE education_programs (id INT PRIMARY KEY, name VARCHAR(50), location VARCHAR(50), attendance INT, target_audience VARCHAR(50));","sql":"DELETE FROM education_programs WHERE name = 'Forest Friends';","sql_explanation":"This query deletes the 'Forest Friends' program record in the 'education_programs' table."}
{"sql_prompt":"What is the average playtime, in hours, for players from Germany, for games in the 'Simulation' genre?","sql_context":"CREATE TABLE games (game_id INT, game_genre VARCHAR(255), player_id INT, playtime_mins INT); CREATE TABLE players (player_id INT, player_country VARCHAR(255));","sql":"SELECT AVG(playtime_mins \/ 60) FROM games JOIN players ON games.player_id = players.player_id WHERE players.player_country = 'Germany' AND game_genre = 'Simulation';","sql_explanation":"The query calculates the average playtime for players from Germany, for games in the 'Simulation' genre by joining the games and players tables on player_id and filtering the data based on game_genre and player_country. The playtime_mins is divided by 60 to get the hours."}
{"sql_prompt":"How many 'Veggie Burgers' were sold in each region?","sql_context":"CREATE TABLE Regional_Sales(Region VARCHAR(20), Menu_Item VARCHAR(30), Quantity INT); INSERT INTO Regional_Sales(Region, Menu_Item, Quantity) VALUES('Northeast', 'Veggie Burger', 50), ('Midwest', 'Veggie Burger', 75), ('South', 'Veggie Burger', 100);","sql":"SELECT Region, SUM(Quantity) as Total_Quantity FROM Regional_Sales WHERE Menu_Item = 'Veggie Burger' GROUP BY Region;","sql_explanation":"This query calculates the total quantity of 'Veggie Burgers' sold in each region. It filters the Regional_Sales table for 'Veggie Burger' and then groups the results by Region, summing the Quantity for each group."}
{"sql_prompt":"What is the average CO2 emission of ride-hailing vehicles in San Francisco?","sql_context":"CREATE TABLE SFRideHailing (id INT, company VARCHAR(20), co2_emission DECIMAL(5,2));","sql":"SELECT AVG(co2_emission) FROM SFRideHailing WHERE company = 'Uber';","sql_explanation":"This query calculates the average CO2 emission of Uber ride-hailing vehicles in San Francisco by using the AVG function on the co2_emission column for rows with 'Uber' in the company column."}
{"sql_prompt":"Display all suppliers from 'Green Earth' that provide vegetables.","sql_context":"CREATE TABLE Suppliers (name text, product text); INSERT INTO Suppliers (name, product) VALUES ('Green Earth', 'Broccoli'), ('Green Earth', 'Carrots'), ('Green Earth', 'Apples'), ('Natural Picks', 'Spinach');","sql":"SELECT DISTINCT name FROM Suppliers WHERE product LIKE '%vegetable%';","sql_explanation":"This query displays all suppliers from 'Green Earth' that provide vegetables by filtering the Suppliers table for products that contain the word 'vegetable' and selecting distinct supplier names."}
{"sql_prompt":"Identify the top 3 rural counties with the highest percentage of residents who have been vaccinated against influenza.","sql_context":"CREATE TABLE county (name VARCHAR(50), population INT, flu_vaccinations INT); INSERT INTO county (name, population, flu_vaccinations) VALUES ('Woodland', 5000, 3000); INSERT INTO county (name, population, flu_vaccinations) VALUES ('Prairie', 6000, 4500); INSERT INTO county (name, population, flu_vaccinations) VALUES ('Mountain', 7000, 5500); INSERT INTO county (name, population, flu_vaccinations) VALUES ('Seaside', 8000, 6500);","sql":"SELECT name, (flu_vaccinations * 100.0 \/ population) AS percentage FROM county ORDER BY percentage DESC LIMIT 3;","sql_explanation":"This query identifies the top 3 rural counties with the highest percentage of residents who have been vaccinated against influenza by calculating the percentage of the population that has been vaccinated and ordering the results in descending order, then limiting the results to the top 3."}
{"sql_prompt":"What is the total budget allocated for healthcare projects in each city in the state of Florida?","sql_context":"CREATE TABLE Cities (CityID INTEGER, CityName TEXT, State TEXT); CREATE TABLE HealthcareProjects (ProjectID INTEGER, ProjectCityID INTEGER, ProjectBudget INTEGER);","sql":"SELECT C.CityName, SUM(HP.ProjectBudget) FROM Cities C INNER JOIN HealthcareProjects HP ON C.CityID = HP.ProjectCityID WHERE C.State = 'Florida' GROUP BY C.CityName;","sql_explanation":"Join Cities and HealthcareProjects tables, filter for Florida cities, group results by city, and calculate the total budget allocated for healthcare projects."}
{"sql_prompt":"List the number of eco-friendly hotels in each country and their total revenue.","sql_context":"CREATE TABLE eco_hotels (hotel_id INT, name TEXT, country TEXT, revenue FLOAT); INSERT INTO eco_hotels VALUES (1, 'Green Hotel', 'France', 350000), (2, 'Eco Lodge', 'Spain', 400000), (3, 'Sustainable Resort', 'France', 550000);","sql":"SELECT country, COUNT(*), SUM(revenue) FROM eco_hotels GROUP BY country;","sql_explanation":"This query lists the number of eco-friendly hotels in each country and their total revenue by grouping the results by the country. The COUNT and SUM functions are used to count the number of records and calculate the total revenue for each group."}
{"sql_prompt":"List all cybersecurity strategies in the strategies table that were implemented in the year 2018.","sql_context":"CREATE TABLE strategies (name TEXT, description TEXT, year INT); INSERT INTO strategies (name, description, year) VALUES ('Intrusion Detection Systems', 'Monitor network traffic for suspicious activity.', 2018), ('Multi-Factor Authentication', 'Require users to provide multiple forms of authentication.', 2016), ('Penetration Testing', 'Test systems for vulnerabilities.', 2019);","sql":"SELECT name FROM strategies WHERE year = 2018;","sql_explanation":"This query selects the name column from the strategies table and filters the rows where the year is equal to 2018."}
{"sql_prompt":"What is the number of mobile and broadband subscribers in each country?","sql_context":"CREATE TABLE subscribers (id INT, name VARCHAR(255), plan_id INT, country VARCHAR(255)); CREATE TABLE mobile_plans (id INT, name VARCHAR(255), type VARCHAR(255), price DECIMAL(10,2)); CREATE TABLE broadband_plans (id INT, name VARCHAR(255), type VARCHAR(255), price DECIMAL(10,2)); CREATE TABLE countries (id INT, name VARCHAR(255));","sql":"SELECT countries.name AS country, COUNT(*) FROM subscribers JOIN mobile_plans ON subscribers.plan_id = mobile_plans.id JOIN broadband_plans ON subscribers.plan_id = broadband_plans.id JOIN countries ON subscribers.country = countries.id GROUP BY countries.name;","sql_explanation":"This query retrieves the number of mobile and broadband subscribers in each country by performing a join on the \"subscribers\" table, \"mobile_plans\" table, \"broadband_plans\" table, and \"countries\" table. It then groups the results by the \"country\" column."}
{"sql_prompt":"Identify materials with waste generation above the industry average","sql_context":"CREATE TABLE WasteData (manufacturer_id INT, material VARCHAR(50), waste_quantity INT); INSERT INTO WasteData (manufacturer_id, material, waste_quantity) VALUES (1, 'Material1', 120), (1, 'Material2', 150), (2, 'Material1', 80), (2, 'Material3', 100), (3, 'Material2', 50), (3, 'Material3', 130); CREATE TABLE IndustryAverages (material VARCHAR(50), avg_waste INT); INSERT INTO IndustryAverages (material, avg_waste) VALUES ('Material1', 100), ('Material2', 100), ('Material3', 110);","sql":"SELECT w.material, w.waste_quantity, i.avg_waste FROM WasteData w INNER JOIN IndustryAverages i ON w.material = i.material WHERE w.waste_quantity > i.avg_waste;","sql_explanation":"The SQL query identifies materials with waste generation above the industry average by performing an inner join between the WasteData and IndustryAverages tables on the material field and filtering the results to only include rows where the waste_quantity is greater than the avg_waste."}
{"sql_prompt":"What is the total donation amount per region in the 'Donations' table?","sql_context":"CREATE TABLE Regions (RegionID int, RegionName varchar(50)); CREATE TABLE Donations (DonationID int, DonorID int, Amount decimal(10,2), RegionID int); INSERT INTO Regions (RegionID, RegionName) VALUES (1, 'North America'), (2, 'South America'), (3, 'Europe'), (4, 'Asia'), (5, 'Africa'); INSERT INTO Donations (DonationID, DonorID, Amount, RegionID) VALUES (1, 1001, 200.00, 1), (2, 1002, 300.00, 1), (3, 1003, 500.00, 3), (4, 1004, 150.00, 2), (5, 1005, 800.00, 4);","sql":"SELECT r.RegionName, SUM(d.Amount) as TotalDonationPerRegion FROM Donations d JOIN Regions r ON d.RegionID = r.RegionID GROUP BY r.RegionName;","sql_explanation":"This query joins the Donations and Regions tables based on the RegionID, then groups the result by RegionName and calculates the sum of Amount for each group, providing the total donation amount per region."}
{"sql_prompt":"Update the name of the passenger with the id 3 to 'Emily Lee'.","sql_context":"CREATE TABLE PASSENGERS (id INT, name VARCHAR(50)); INSERT INTO PASSENGERS VALUES (3, 'James Brown');","sql":"UPDATE PASSENGERS SET name = 'Emily Lee' WHERE id = 3;","sql_explanation":"The SQL query updates the name of the passenger with id 3 to 'Emily Lee' in the PASSENGERS table."}
{"sql_prompt":"Which esports event has the most participants?","sql_context":"CREATE TABLE EventParticipants (ParticipantID INT, EventID INT, ParticipantName VARCHAR(50)); INSERT INTO EventParticipants (ParticipantID, EventID) VALUES (1, 1), (2, 1), (3, 2), (4, 3), (5, 3);","sql":"SELECT EventID, COUNT(*) as ParticipantCount FROM EventParticipants GROUP BY EventID ORDER BY ParticipantCount DESC LIMIT 1;","sql_explanation":"This query retrieves the esports event with the most participants. It does this by using the COUNT function on the ParticipantID column, grouping by EventID, and then ordering by the count in descending order. The query then returns the first row of the result set."}
{"sql_prompt":"What is the average CO2 emission reduction of green building projects in California?","sql_context":"CREATE TABLE green_building_projects (id INT, project_name VARCHAR(50), city VARCHAR(50), state VARCHAR(50), country VARCHAR(50), co2_reduction FLOAT); INSERT INTO green_building_projects (id, project_name, city, state, country, co2_reduction) VALUES (1, 'California Green Building', 'Los Angeles', 'CA', 'USA', 15.4);","sql":"SELECT AVG(co2_reduction) FROM green_building_projects WHERE state = 'CA';","sql_explanation":"This query calculates the average CO2 emission reduction of green building projects in California by finding the average of the co2_reduction values in the green_building_projects table where the state is 'CA'."}
{"sql_prompt":"Find sites in 'european_sites' with more than 15 artifacts","sql_context":"CREATE TABLE european_sites (id INT, site_name VARCHAR(50), artifact_name VARCHAR(50));","sql":"SELECT site_name FROM european_sites GROUP BY site_name HAVING COUNT(artifact_name) > 15;","sql_explanation":"This query groups the 'european_sites' table by 'site_name' and counts 'artifact_name' entries. The HAVING clause filters the results to only include sites with more than 15 artifacts."}
{"sql_prompt":"What is the total number of hours volunteered by each volunteer in the last month?","sql_context":"CREATE TABLE volunteer_hours (hour_id INT, volunteer_id INT, hours_volunteered DECIMAL(10,2), volunteer_date DATE);","sql":"SELECT volunteer_id, SUM(hours_volunteered) FROM volunteer_hours WHERE volunteer_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) GROUP BY volunteer_id;","sql_explanation":"The query calculates the sum of hours_volunteered from the volunteer_hours table where the volunteer_date is within the last one month and groups the results by volunteer_id."}
{"sql_prompt":"What is the average transaction value in the last week, split by product category and customer demographics?","sql_context":"CREATE TABLE transactions (transaction_id INT, customer_id INT, product_id INT, category_id INT, transaction_date DATE, amount DECIMAL(10,2)); CREATE TABLE customers (customer_id INT, age INT, gender VARCHAR(10), location VARCHAR(255)); CREATE TABLE products (product_id INT, name VARCHAR(255), category_id INT);","sql":"SELECT c.age, c.gender, p.category_id, AVG(t.amount) as avg_transaction_value FROM transactions t INNER JOIN customers c ON t.customer_id = c.customer_id INNER JOIN products p ON t.product_id = p.product_id WHERE t.transaction_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 WEEK) GROUP BY c.age, c.gender, p.category_id;","sql_explanation":"This query starts by selecting age, gender, category ID, and the average transaction amount. It then joins transactions, customers, and products tables. The WHERE clause filters transactions within the last week. The GROUP BY clause groups the result by customer age, gender, and product category."}
{"sql_prompt":"How many artworks in the 'ArtCollection' table were created during the 20th century?","sql_context":"CREATE TABLE ArtCollection (ArtworkID INT, ArtworkYear INT); INSERT INTO ArtCollection (ArtworkID, ArtworkYear) VALUES (1, 1905), (2, 1910), (3, 1915), (4, 1920), (5, 1925), (6, 1930), (7, 1935), (8, 1940), (9, 1945), (10, 1950);","sql":"SELECT COUNT(*) AS Artworks20thCentury FROM ArtCollection WHERE ArtworkYear BETWEEN 1901 AND 2000;","sql_explanation":"This SQL query counts the number of artworks created during the 20th century by using the COUNT function on the ArtworkID column, filtering the rows using the WHERE clause to only consider artworks with a year between 1901 and 2000 (inclusive)."}
{"sql_prompt":"Which cruelty-free certified products use ingredients sourced from Canada?","sql_context":"CREATE TABLE products (product_id INT, product_name TEXT, is_cruelty_free BOOLEAN); CREATE TABLE ingredient_sources (ingredient_id INT, product_id INT, source_country TEXT);","sql":"SELECT products.product_name FROM products INNER JOIN ingredient_sources ON products.product_id = ingredient_sources.product_id WHERE products.is_cruelty_free = TRUE AND ingredient_sources.source_country = 'Canada';","sql_explanation":"This query first joins the products table with the ingredient_sources table on the product_id field. It then filters for rows where the product is cruelty-free and the ingredient source country is Canada. The result is a list of product names that meet the specified criteria."}
{"sql_prompt":"What is the maximum flight distance for each aircraft model?","sql_context":"CREATE TABLE flights (id INT, model VARCHAR(50), flight_distance DECIMAL(10,2), flight_hours DECIMAL(5,2)); INSERT INTO flights (id, model, flight_distance, flight_hours) VALUES (1, 'Boeing 737', 1500, 4.5), (2, 'Airbus A320', 1200, 3.8), (3, 'Boeing 787', 2000, 5.5);","sql":"SELECT model, MAX(flight_distance) as max_flight_distance FROM flights GROUP BY model;","sql_explanation":"This SQL query groups the flights table by model and calculates the maximum flight distance for each aircraft model. It returns the result."}
{"sql_prompt":"List all unique medical conditions of astronauts from Russia.","sql_context":"CREATE TABLE AstronautMedical (id INT, astronaut_id INT, nationality VARCHAR(50), medical_condition VARCHAR(50)); INSERT INTO AstronautMedical (id, astronaut_id, nationality, medical_condition) VALUES (1, 101, 'Russia', 'Anemia'); INSERT INTO AstronautMedical (id, astronaut_id, nationality, medical_condition) VALUES (2, 102, 'Russia', 'Dehydration'); INSERT INTO AstronautMedical (id, astronaut_id, nationality, medical_condition) VALUES (3, 103, 'USA', 'Motion Sickness');","sql":"SELECT DISTINCT medical_condition FROM AstronautMedical WHERE nationality = 'Russia';","sql_explanation":"The SQL query lists all unique medical conditions of astronauts from Russia by selecting the 'medical_condition' column from the 'AstronautMedical' table where the 'nationality' is 'Russia' and then using the DISTINCT keyword to return unique values in the column."}
{"sql_prompt":"How many fans are from each state?","sql_context":"CREATE TABLE fans (fan_id INT, state VARCHAR(255)); INSERT INTO fans (fan_id, state) VALUES (1, 'Texas'), (2, 'California'), (3, 'Texas'), (4, 'New York'), (5, 'California'), (6, 'California'), (7, 'Texas'), (8, 'Texas'), (9, 'New York'), (10, 'New York');","sql":"SELECT state, COUNT(*) as fan_count FROM fans GROUP BY state;","sql_explanation":"This query groups the fans table by the state column and counts the number of fans in each state using the COUNT function."}
{"sql_prompt":"Which cultivators supply sativa strains to dispensaries in Oregon?","sql_context":"CREATE TABLE CultivatorData (CultivatorName VARCHAR(50), State VARCHAR(20), Strain VARCHAR(20)); INSERT INTO CultivatorData (CultivatorName, State, Strain) VALUES ('Highland Organics', 'Oregon', 'Sativa'), ('Emerald Creek Farms', 'California', 'Sativa'), ('Mountain High Sungrown', 'Oregon', 'Hybrid'), ('Green Earth Gardens', 'Washington', 'Indica'), ('Pure Green Farms', 'Colorado', 'Sativa');","sql":"SELECT CultivatorName FROM CultivatorData WHERE State = 'Oregon' AND Strain = 'Sativa';","sql_explanation":"The SQL query selects the CultivatorName column from the CultivatorData table, filters the results to only include rows where the State column is 'Oregon' and the Strain column is 'Sativa', and returns the cultivators that supply sativa strains to dispensaries in Oregon."}
{"sql_prompt":"Which defense contracts have the highest total value, and what are their respective values?","sql_context":"CREATE TABLE Defense_Contracts (Contract_ID INT, Contract_Name VARCHAR(255), Agency VARCHAR(255), Value DECIMAL(18,2)); INSERT INTO Defense_Contracts (Contract_ID, Contract_Name, Agency, Value) VALUES (1, 'Contract A', 'DOD', 5000000), (2, 'Contract B', 'DOJ', 6000000), (3, 'Contract C', 'DOD', 7000000), (4, 'Contract D', 'CIA', 8000000);","sql":"SELECT Contract_Name, Value FROM (SELECT Contract_Name, Value, ROW_NUMBER() OVER (ORDER BY Value DESC) as Rank FROM Defense_Contracts) as Ranked_Contracts WHERE Rank <= 3;","sql_explanation":"The SQL query first calculates row numbers for each record in the Defense_Contracts table, ordered by the Value column in descending order using the ROW_NUMBER window function. Then, it selects the Contract_Name and Value columns from the derived table, filtering only those records where the row number is less than or equal to 3. This results in a list of the top three defense contracts with the highest total values."}
{"sql_prompt":"Insert a new client named 'Alex Juarez' into the 'clients' table and assign them a unique client_id.","sql_context":"CREATE TABLE clients (client_id INT PRIMARY KEY AUTO_INCREMENT, client_name VARCHAR(255));","sql":"INSERT INTO clients (client_name) VALUES ('Alex Juarez');","sql_explanation":"1. The INSERT INTO statement is used to insert a new record into the clients table. 2. The VALUES clause specifies the value for the client_name column ('Alex Juarez'). 3. Since the client_id column has the AUTO_INCREMENT attribute, a unique client_id will be generated automatically."}
{"sql_prompt":"What is the total biomass of marine species in ascending order of depth?","sql_context":"CREATE TABLE biomass (id INT, species TEXT, type TEXT, biomass FLOAT); INSERT INTO biomass (id, species, type, biomass) VALUES (1, 'Anglerfish', 'Trench', 0.5), (2, 'Goblin shark', 'Abyssal', 1.2), (3, 'Hatchetfish', 'Trench', 0.3);","sql":"SELECT type, SUM(biomass) total_biomass FROM biomass GROUP BY type ORDER BY total_biomass ASC;","sql_explanation":"Calculate the total biomass of marine species, grouped by type, and order the result by ascending total biomass."}
{"sql_prompt":"What is the minimum and maximum average age of healthcare workers in 'rural_hospitals' table?","sql_context":"CREATE TABLE rural_hospitals (id INT, name TEXT, location TEXT, num_workers INT, avg_age FLOAT); INSERT INTO rural_hospitals (id, name, location, num_workers, avg_age) VALUES (1, 'Rural Hospital A', 'Rural Area 1', 50, 50.1), (2, 'Rural Hospital B', 'Rural Area 2', 75, 48.5);","sql":"SELECT MIN(avg_age), MAX(avg_age) FROM rural_hospitals;","sql_explanation":"This query uses the MIN() and MAX() functions to find the minimum and maximum average age of healthcare workers in the 'rural_hospitals' table."}
{"sql_prompt":"What is the minimum energy efficiency rating for commercial buildings in the city of Chicago?","sql_context":"CREATE TABLE commercial_buildings (id INT, building_id VARCHAR(255), city VARCHAR(255), energy_efficiency_rating INT);","sql":"SELECT MIN(energy_efficiency_rating) FROM commercial_buildings WHERE city = 'Chicago';","sql_explanation":"The SQL query calculates the minimum energy efficiency rating for commercial buildings in Chicago. It uses the MIN() function to find the lowest value in the energy_efficiency_rating column."}
{"sql_prompt":"What is the average rating of films directed by women?","sql_context":"CREATE TABLE movies (id INT, title TEXT, rating FLOAT, director TEXT); INSERT INTO movies (id, title, rating, director) VALUES (1, 'Movie1', 7.5, 'DirectorA'), (2, 'Movie2', 8.2, 'DirectorB'), (3, 'Movie3', 6.8, 'DirectorA');","sql":"SELECT AVG(rating) FROM movies WHERE director IN ('DirectorA', 'DirectorC');","sql_explanation":"This query calculates the average rating of films directed by women by selecting all records with director 'DirectorA' or 'DirectorC' and computing the average of their rating column."}
{"sql_prompt":"What is the average altitude of all geostationary satellites?","sql_context":"CREATE TABLE geostationary_satellites (id INT, name VARCHAR(50), type VARCHAR(50), altitude INT); INSERT INTO geostationary_satellites (id, name, type, altitude) VALUES (1, 'Sat1', 'Communication', 35786), (2, 'Sat2', 'Weather', 35800), (3, 'Sat3', 'Observation', 35790), (4, 'Sat4', 'Communication', 35780), (5, 'Sat5', 'Weather', 35810);","sql":"SELECT AVG(altitude) FROM geostationary_satellites;","sql_explanation":"Calculate the average of the altitude column in the geostationary_satellites table."}
{"sql_prompt":"Who are the top 3 suppliers of recycled polyester?","sql_context":"CREATE TABLE suppliers (id INT, name VARCHAR(255), material VARCHAR(255)); INSERT INTO suppliers (id, name, material) VALUES (1, 'Supplier A', 'Recycled Polyester'), (2, 'Supplier B', 'Organic Cotton'), (3, 'Supplier C', 'Recycled Polyester'), (4, 'Supplier D', 'Hemp'), (5, 'Supplier E', 'Recycled Polyester');","sql":"SELECT name FROM suppliers WHERE material = 'Recycled Polyester' GROUP BY name ORDER BY COUNT(*) DESC LIMIT 3;","sql_explanation":"This SQL query identifies the top 3 suppliers of recycled polyester by selecting the name column where the material is 'Recycled Polyester', grouping the results by the name column, counting the number of occurrences for each name, and then ordering the results in descending order based on the count. The query then limits the results to the top 3."}
{"sql_prompt":"What is the average income of residents in each city in the state of California, grouped by city and ordered by average income in descending order?","sql_context":"CREATE TABLE cities (id INT PRIMARY KEY, name TEXT, state TEXT); INSERT INTO cities (id, name, state) VALUES (1, 'Los Angeles', 'California'), (2, 'San Diego', 'California'), (3, 'San Jose', 'California'); CREATE TABLE incomes (id INT PRIMARY KEY, city_id INT, income INT); INSERT INTO incomes (id, city_id, income) VALUES (1, 1, 50000), (2, 1, 70000), (3, 2, 45000), (4, 2, 60000), (5, 3, 48000), (6, 3, 52000);","sql":"SELECT c.name, AVG(i.income) FROM cities c JOIN incomes i ON c.id = i.city_id WHERE c.state = 'California' GROUP BY c.name ORDER BY AVG(i.income) DESC;","sql_explanation":"Join the cities and incomes tables on the id and city_id columns, respectively. Filter for rows where the state column in the cities table is 'California'. Calculate the average income for each city and order the results by the average income in descending order."}
{"sql_prompt":"What is the average carbon footprint of products made in each country?","sql_context":"CREATE TABLE products (product_id INT, country VARCHAR(50), carbon_footprint DECIMAL(10, 2)); CREATE VIEW country_products AS SELECT country, carbon_footprint FROM products GROUP BY country;","sql":"SELECT country, AVG(carbon_footprint) FROM country_products GROUP BY country;","sql_explanation":"The query calculates the average carbon footprint of products made in each country by joining the products table on the country column and then calculating the average carbon footprint using the AVG function. The results are then grouped by country."}
{"sql_prompt":"What is the total budget spent on each program category in H1 2022?","sql_context":"CREATE TABLE Programs (ProgramID int, ProgramName varchar(50), ProgramCategory varchar(50), Budget decimal(10,2), Spent decimal(10,2));","sql":"SELECT ProgramCategory, SUM(Spent) as TotalSpent FROM Programs WHERE YEAR(ProgramStartDate) = 2022 AND QUARTER(ProgramStartDate) <= 2 GROUP BY ProgramCategory;","sql_explanation":"This query calculates the total budget spent on each program category in H1 of 2022. It does so by grouping programs by the ProgramCategory and summing the Spent for each group. The WHERE clause filters the records to only those with a ProgramStartDate in 2022 and Q1 or Q2."}
{"sql_prompt":"How many labor violations have been reported in the supply chain for vegan leather products?","sql_context":"CREATE TABLE VeganLeatherSupplyChain (id INT, labor_violation ENUM('yes','no'));","sql":"SELECT COUNT(*) FROM VeganLeatherSupplyChain WHERE labor_violation = 'yes';","sql_explanation":"The SQL query calculates the number of labor violations reported in the supply chain for vegan leather products by using the COUNT function with a WHERE clause to filter the rows where labor_violation is 'yes'."}
{"sql_prompt":"How many cases were handled by attorneys in the 'Los Angeles' office?","sql_context":"CREATE TABLE offices (office_id INT, office_name VARCHAR(20), city VARCHAR(20), state VARCHAR(20)); INSERT INTO offices (office_id, office_name, city, state) VALUES (1, 'Boston', 'Boston', 'MA'), (2, 'New York', 'New York', 'NY'), (3, 'Los Angeles', 'Los Angeles', 'CA'); CREATE TABLE attorneys (attorney_id INT, office_id INT); INSERT INTO attorneys (attorney_id, office_id) VALUES (1, 1), (2, 2), (3, 3); CREATE TABLE cases (case_id INT, attorney_id INT); INSERT INTO cases (case_id, attorney_id) VALUES (1, 1), (2, 2), (3, 3);","sql":"SELECT COUNT(*) FROM cases JOIN attorneys ON cases.attorney_id = attorneys.attorney_id JOIN offices ON attorneys.office_id = offices.office_id WHERE offices.city = 'Los Angeles';","sql_explanation":"This query joins the 'cases', 'attorneys', and 'offices' tables on their respective IDs and filters for cases in the 'Los Angeles' office. The COUNT(*) function returns the total number of cases."}
{"sql_prompt":"What is the average water consumption per household in Mumbai for the years 2018 and 2019?","sql_context":"CREATE TABLE Household_Water_Usage (Household_ID INT, City VARCHAR(20), Year INT, Water_Consumption FLOAT); INSERT INTO Household_Water_Usage (Household_ID, City, Year, Water_Consumption) VALUES (1, 'Mumbai', 2018, 150.5), (2, 'Mumbai', 2019, 130.2);","sql":"SELECT Year, AVG(Water_Consumption) FROM Household_Water_Usage WHERE City = 'Mumbai' AND Year IN (2018, 2019) GROUP BY Year;","sql_explanation":"This query calculates the average water consumption per household in Mumbai for the years 2018 and 2019 by filtering the Household_Water_Usage table to only include rows with the city 'Mumbai' and years 2018 and 2019, grouping them by year, and then calculating the average water consumption for each year."}
{"sql_prompt":"What is the minimum salary for employees who joined the company in the summer?","sql_context":"CREATE TABLE Employees (EmployeeID int, HireDate date, Salary decimal(10,2)); INSERT INTO Employees (EmployeeID, HireDate, Salary) VALUES (1, '2021-06-01', 70000.00), (2, '2021-07-15', 75000.00), (3, '2021-08-31', 65000.00);","sql":"SELECT MIN(Salary) FROM Employees WHERE MONTH(HireDate) IN (6, 7, 8);","sql_explanation":"The SQL query finds the minimum salary for employees who joined the company in the summer (June, July, or August) by using the MIN function on the Salary column and filtering the data by the MONTH function applied to the HireDate column, checking for values in the set (6, 7, 8)."}
{"sql_prompt":"What is the total number of OTA (Online Travel Agency) bookings for each hotel in the USA, sorted by the hotel name?","sql_context":"CREATE TABLE hotel_bookings (booking_id INT, hotel_name TEXT, country TEXT, ota_name TEXT, revenue FLOAT); INSERT INTO hotel_bookings (booking_id, hotel_name, country, ota_name, revenue) VALUES (1, 'Hotel X', 'USA', 'OTA 1', 500), (2, 'Hotel Y', 'USA', 'OTA 2', 700), (3, 'Hotel X', 'USA', 'OTA 3', 300), (4, 'Hotel Y', 'USA', 'OTA 1', 600), (5, 'Hotel X', 'USA', 'OTA 2', 400);","sql":"SELECT hotel_name, SUM(revenue) as total_bookings FROM hotel_bookings WHERE country = 'USA' GROUP BY hotel_name ORDER BY hotel_name;","sql_explanation":"This SQL query filters the hotel_bookings table based on the country and then calculates the total number of OTA bookings for each hotel in the USA, sorted by the hotel name."}
{"sql_prompt":"What is the average stock level and biomass for each species in the 'fish_stock' table?","sql_context":"CREATE TABLE fish_stock (id INT, species VARCHAR(255), stock_level INT, biomass DECIMAL(6,2)); INSERT INTO fish_stock (id, species, stock_level, biomass) VALUES (1, 'Tilapia', 250, 325.45), (2, 'Salmon', 180, 2134.67), (3, 'Tilapia', 300, 412.34), (4, 'Catfish', 150, 654.32), (5, 'Salmon', 200, 2500.00);","sql":"SELECT species, AVG(stock_level) as avg_stock_level, AVG(biomass) as avg_biomass FROM fish_stock GROUP BY species;","sql_explanation":"The SQL query calculates the average stock level and biomass for each species in the 'fish_stock' table by grouping records by 'species' and calculating the average 'stock_level' and 'biomass' for each group."}
{"sql_prompt":"Which artifacts were discovered before 2000 in the 'Pompeii' excavation site?","sql_context":"CREATE TABLE ExcavationSites (site_id INT, site_name VARCHAR(50)); CREATE TABLE Artifacts (artifact_id INT, site_id INT, discovered_year INT); INSERT INTO ExcavationSites (site_id, site_name) VALUES (1, 'Pompeii'); INSERT INTO Artifacts (artifact_id, site_id, discovered_year) VALUES (1, 1, 1998), (2, 1, 2005), (3, 1, 1999), (4, 1, 1987);","sql":"SELECT Artifacts.artifact_id, Artifacts.site_id, Artifacts.discovered_year FROM Artifacts INNER JOIN ExcavationSites ON Artifacts.site_id = ExcavationSites.site_id WHERE ExcavationSites.site_name = 'Pompeii' AND Artifacts.discovered_year < 2000;","sql_explanation":"This query performs an INNER JOIN on the ExcavationSites and Artifacts tables to find artifacts (artifact_id, site_id, discovered_year) discovered before 2000 (discovered_year < 2000) in the 'Pompeii' excavation site (site_name)."}
{"sql_prompt":"List all social good technology programs launched in the first half of the year 2022.","sql_context":"CREATE TABLE Social_Good_Tech (Month INT, Program VARCHAR(255)); INSERT INTO Social_Good_Tech (Month, Program) VALUES (1, 'EduTech'), (2, 'HealthTech'), (3, 'AgriTech'), (4, 'FinTech'), (5, 'EduTech'), (6, 'HealthTech');","sql":"SELECT DISTINCT Program FROM Social_Good_Tech WHERE Month BETWEEN 1 AND 6;","sql_explanation":"The SQL query lists all social good technology programs launched in the first half of the year 2022. It does this by selecting the DISTINCT (unique) value of the Program column where the Month column is between 1 and 6."}
{"sql_prompt":"What is the average fabric cost for t-shirts?","sql_context":"CREATE TABLE Fabrics (id INT, fabric_name VARCHAR(255), cost DECIMAL(5,2)); INSERT INTO Fabrics (id, fabric_name, cost) VALUES (1, 'Cotton', 2.50), (2, 'Polyester', 1.80), (3, 'Rayon', 3.20); CREATE TABLE Products (id INT, product_name VARCHAR(255), fabric_id INT); INSERT INTO Products (id, product_name, fabric_id) VALUES (1, 'T-Shirt', 1), (2, 'Pants', 2), (3, 'Dress', 3);","sql":"SELECT AVG(Fabrics.cost) FROM Fabrics INNER JOIN Products ON Fabrics.id = Products.fabric_id WHERE Products.product_name = 'T-Shirt';","sql_explanation":"This query calculates the average cost of fabrics used for t-shirts. It joins the Fabrics and Products tables based on their id and fabric_id respectively, filters for t-shirts and calculates the average cost of fabrics."}
{"sql_prompt":"What is the total amount donated by small donors in the 'animals' cause area?","sql_context":"CREATE TABLE donations (id INT, donor_size VARCHAR(10), cause_area VARCHAR(20), amount INT); INSERT INTO donations (id, donor_size, cause_area, amount) VALUES (1, 'small', 'animals', 500);","sql":"SELECT SUM(amount) FROM donations WHERE donor_size = 'small' AND cause_area = 'animals';","sql_explanation":"The SQL query adds up the amounts donated by small donors in the 'animals' cause area."}
{"sql_prompt":"Update the community_policing table and mark 'true' for the record where the community_policing_id is 3","sql_context":"CREATE TABLE community_policing (community_policing_id INT, is_active BOOLEAN);","sql":"UPDATE community_policing SET is_active = true WHERE community_policing_id = 3;","sql_explanation":"This query updates the 'community_policing' table, setting the 'is_active' field to 'true' for the record with a 'community_policing_id' of 3."}
{"sql_prompt":"What is the average monthly water usage for residential customers in the San Francisco region for the year 2020?","sql_context":"CREATE TABLE water_usage(customer_id INT, region VARCHAR(50), usage FLOAT, year INT, month INT); INSERT INTO water_usage(customer_id, region, usage, year, month) VALUES (1, 'San Francisco', 15.3, 2020, 1), (2, 'San Francisco', 14.8, 2020, 2);","sql":"SELECT AVG(usage) FROM water_usage WHERE region = 'San Francisco' AND year = 2020 GROUP BY month;","sql_explanation":"This query calculates the average monthly water usage for residential customers in the San Francisco region for the year 2020. It groups the data by month and calculates the average usage for each month."}
{"sql_prompt":"Find programs with no financial donations","sql_context":"CREATE TABLE programs (id INT, name VARCHAR); CREATE TABLE financial_donations (id INT, program_id INT, amount INT)","sql":"SELECT p.name FROM programs p LEFT JOIN financial_donations fd ON p.id = fd.program_id WHERE fd.program_id IS NULL;","sql_explanation":"This query performs a left join between programs (p) and financial_donations (fd) tables on their respective id and program_id columns. It then filters the results to only include programs with no financial donations (fd.program_id IS NULL)."}
{"sql_prompt":"What is the average carbon footprint of cosmetic products up to a given product_id?","sql_context":"CREATE TABLE sustainability_metrics (product_id INT, carbon_footprint FLOAT); INSERT INTO sustainability_metrics (product_id, carbon_footprint) VALUES (1, 5.0), (2, 7.5), (3, 3.0), (4, 6.0), (5, 4.5), (6, 8.0);","sql":"SELECT product_id, carbon_footprint, AVG(carbon_footprint) OVER (ORDER BY product_id ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) as running_avg_cf FROM sustainability_metrics;","sql_explanation":"The SQL query calculates the running average of the carbon footprint for each product up to the current product_id."}
{"sql_prompt":"What is the total precipitation in 'Field E' for the month of January 2022?","sql_context":"CREATE TABLE sensors (sensor_id INT, location VARCHAR(50)); INSERT INTO sensors (sensor_id, location) VALUES (005, 'Field E'); CREATE TABLE precipitation (sensor_id INT, precipitation FLOAT, timestamp TIMESTAMP); INSERT INTO precipitation (sensor_id, precipitation, timestamp) VALUES (005, 12.3, '2022-01-01 10:00:00'); INSERT INTO precipitation (sensor_id, precipitation, timestamp) VALUES (005, 15.6, '2022-01-02 11:00:00');","sql":"SELECT SUM(precipitation) FROM precipitation WHERE sensor_id = 005 AND timestamp BETWEEN '2022-01-01 00:00:00' AND '2022-01-31 23:59:59';","sql_explanation":"Sum the total precipitation (SUM) in the 'precipitation' table where sensor_id is 005 for the month of January 2022."}
{"sql_prompt":"Find the average revenue per sustainable hotel.","sql_context":"CREATE TABLE revenues(hotel_id INT, is_sustainable BOOLEAN, revenue FLOAT); INSERT INTO revenues(hotel_id, is_sustainable, revenue) VALUES (1, true, 12000.0), (2, false, 10000.0), (3, true, 15000.0);","sql":"SELECT AVG(revenue) FROM revenues WHERE is_sustainable = true;","sql_explanation":"This query calculates the average revenue per sustainable hotel by averaging the revenue of hotels that have is_sustainable set to true."}
{"sql_prompt":"What is the total quantity of products sold by each customer?","sql_context":"CREATE TABLE customers (customer_id INT, customer_name VARCHAR(255)); CREATE TABLE sales (sale_id INT, customer_id INT, product_quantity INT);","sql":"SELECT customers.customer_name, SUM(sales.product_quantity) as total_quantity FROM sales JOIN customers ON sales.customer_id = customers.customer_id GROUP BY customers.customer_name;","sql_explanation":"This SQL query joins the customers and sales tables on the customer_id, then groups the data by customer_name, and calculates the total quantity of products sold by each customer by summing the product_quantity column."}
{"sql_prompt":"Who are the top 2 sales representatives by total sales for 'DrugT' in the North America region in Q1 2021?","sql_context":"CREATE TABLE sales_data_2 (rep_name TEXT, drug_name TEXT, region TEXT, quarter INT, total_sales FLOAT); INSERT INTO sales_data_2 (rep_name, drug_name, region, quarter, total_sales) VALUES ('RepE', 'DrugT', 'North America', 1, 600000), ('RepF', 'DrugT', 'North America', 1, 700000), ('RepG', 'DrugT', 'North America', 1, 550000), ('RepH', 'DrugT', 'North America', 1, 450000);","sql":"SELECT rep_name, SUM(total_sales) AS total_sales FROM sales_data_2 WHERE drug_name = 'DrugT' AND region = 'North America' AND quarter = 1 GROUP BY rep_name ORDER BY total_sales DESC LIMIT 2;","sql_explanation":"This query groups the sales representatives by drug name, region, and quarter, and calculates the total sales for each sales representative for 'DrugT' in the North America region in Q1 2021. It then orders the results by total sales in descending order and limits the results to the top 2 sales representatives with the highest total sales."}
{"sql_prompt":"List the number of users who have completed a workout of a specific type (e.g. Running) and have a membership status of 'Active'.","sql_context":"CREATE TABLE workouts (id INT, user_id INT, workout_type VARCHAR(20)); CREATE TABLE members (id INT, name VARCHAR(50), membership_status VARCHAR(20), state VARCHAR(20)); INSERT INTO workouts (id, user_id, workout_type) VALUES (1, 1, 'Running'), (2, 1, 'Cycling'), (3, 2, 'Running'), (4, 3, 'Cycling'), (5, 3, 'Swimming'), (6, 4, 'Running'), (7, 4, 'Swimming'); INSERT INTO members (id, name, membership_status, state) VALUES (1, 'John Doe', 'Active', 'Texas'), (2, 'Jane Doe', 'Inactive', 'California'), (3, 'Bob Smith', 'Active', 'Texas'), (4, 'Alice Johnson', 'Active', 'California');","sql":"SELECT COUNT(*) FROM (SELECT user_id FROM workouts WHERE workout_type = 'Running' INTERSECT SELECT id FROM members WHERE membership_status = 'Active') AS user_set;","sql_explanation":"The SQL query uses the INTERSECT operator to find the users who have completed a running workout and have an active membership status. The COUNT function is then used to count the number of users in the resulting set."}
{"sql_prompt":"Identify the top 5 mining locations with the highest average Gadolinium production in 2020, using a cross join.","sql_context":"CREATE TABLE mines (id INT, location VARCHAR(50), Gadolinium_prod FLOAT, datetime DATETIME); INSERT INTO mines (id, location, Gadolinium_prod, datetime) VALUES (1, 'Mount Weld', 120.0, '2020-01-01 10:00:00'), (2, 'Bayan Obo', 350.0, '2020-02-15 14:30:00');","sql":"SELECT a.location, AVG(a.Gadolinium_prod) FROM mines a CROSS JOIN mines b GROUP BY a.location ORDER BY AVG(a.Gadolinium_prod) DESC LIMIT 5;","sql_explanation":"The SQL query performs a cross join on the 'mines' table and calculates the average Gadolinium production for each mining location. The result is then ordered in descending order, and the top 5 locations are returned."}
{"sql_prompt":"What is the average donation amount in 'Asia' region?","sql_context":"CREATE TABLE donations (id INT, donor_id INT, donation_amount DECIMAL(10,2), region VARCHAR(50)); INSERT INTO donations (id, donor_id, donation_amount, region) VALUES (1, 1, 100.00, 'Asia'); INSERT INTO donations (id, donor_id, donation_amount, region) VALUES (2, 2, 200.00, 'Africa'); INSERT INTO donations (id, donor_id, donation_amount, region) VALUES (3, 3, 300.00, 'Europe');","sql":"SELECT AVG(donation_amount) FROM donations WHERE region = 'Asia';","sql_explanation":"This query calculates the average donation amount in the 'Asia' region by filtering the donations table using the region column and calculating the average donation_amount."}
{"sql_prompt":"What was the maximum ticket sales for any event in Tokyo?","sql_context":"CREATE TABLE EventData (id INT, city VARCHAR(50), ticket_sales INT); INSERT INTO EventData (id, city, ticket_sales) VALUES (1, 'Tokyo', 1200), (2, 'Tokyo', 1500), (3, 'Seoul', 1800), (4, 'Seoul', 1000), (5, 'Osaka', 1300);","sql":"SELECT MAX(ticket_sales) FROM EventData WHERE city = 'Tokyo';","sql_explanation":"This query calculates the maximum ticket sales for any event in Tokyo by using the MAX function."}
{"sql_prompt":"How many clients have taken out socially responsible loans in each country, excluding loans from clients in Saudi Arabia and the UAE?","sql_context":"CREATE TABLE socially_responsible_loans(client_id INT, client_country VARCHAR(25));INSERT INTO socially_responsible_loans(client_id, client_country) VALUES (1, 'Bahrain'), (2, 'UAE'), (3, 'Indonesia'), (4, 'Saudi Arabia'), (5, 'Malaysia'), (6, 'UAE'), (7, 'Indonesia'), (8, 'Saudi Arabia'), (9, 'Malaysia'), (10, 'UAE');","sql":"SELECT client_country, COUNT(DISTINCT client_id) as num_clients FROM socially_responsible_loans WHERE client_country NOT IN ('Saudi Arabia', 'UAE') GROUP BY client_country;","sql_explanation":"This query filters the socially_responsible_loans table to exclude clients from Saudi Arabia and the UAE, then groups the table by client_country and calculates the number of unique clients who have taken out a socially responsible loan in each country using the COUNT(DISTINCT) function."}
{"sql_prompt":"What is the minimum production emission for items in the Production_Emissions view?","sql_context":"CREATE VIEW Production_Emissions AS SELECT product_id, product_name, production_emissions FROM Products; INSERT INTO Products (product_id, product_name, transportation_emissions, production_emissions, packaging_emissions) VALUES (601, 'Socks', 2, 4, 1); INSERT INTO Products (product_id, product_name, transportation_emissions, production_emissions, packaging_emissions) VALUES (602, 'Hat', 3, 5, 2); INSERT INTO Products (product_id, product_name, transportation_emissions, production_emissions, packaging_emissions) VALUES (603, 'Scarf', 4, 6, 3);","sql":"SELECT MIN(production_emissions) FROM Production_Emissions;","sql_explanation":"The SQL query calculates the minimum production emission for items in the Production_Emissions view by selecting all records from the view and computing the minimum of their production_emissions values."}
{"sql_prompt":"What is the monthly data usage for the top 5 subscribers in the 'west' region, ordered by usage in descending order?","sql_context":"CREATE TABLE subscribers (subscriber_id INT, data_usage FLOAT, region VARCHAR(10)); INSERT INTO subscribers (subscriber_id, data_usage, region) VALUES (4, 35, 'west'), (5, 28, 'west'), (6, 45, 'west');","sql":"SELECT subscriber_id, data_usage FROM (SELECT subscriber_id, data_usage, ROW_NUMBER() OVER (PARTITION BY region ORDER BY data_usage DESC) as rn FROM subscribers WHERE region = 'west') subquery WHERE rn <= 5 ORDER BY data_usage DESC;","sql_explanation":"Partition the data by region, order by data_usage in descending order, assign row numbers, then filter top 5 subscribers and order by data_usage in descending order again."}
{"sql_prompt":"What was the total amount of minerals extracted in the 'north' region for each month in 2020?","sql_context":"CREATE TABLE extraction(id INT, location TEXT, month INT, year INT, minerals_extracted FLOAT);INSERT INTO extraction(id, location, month, year, minerals_extracted) VALUES (1, 'north', 1, 2020, 1500), (2, 'north', 2, 2020, 1800), (3, 'south', 1, 2020, 1200);","sql":"SELECT month, SUM(minerals_extracted) FROM extraction WHERE location = 'north' AND year = 2020 GROUP BY month;","sql_explanation":"Sum the total amount of minerals extracted in the 'north' region for each month in 2020."}
{"sql_prompt":"What is the minimum age of patients who received therapy in Colorado?","sql_context":"CREATE TABLE patients (patient_id INT, age INT, gender TEXT, treatment TEXT, state TEXT); INSERT INTO patients (patient_id, age, gender, treatment, state) VALUES (1, 30, 'Female', 'CBT', 'Texas'); INSERT INTO patients (patient_id, age, gender, treatment, state) VALUES (2, 45, 'Male', 'DBT', 'California'); INSERT INTO patients (patient_id, age, gender, treatment, state) VALUES (3, 25, 'Non-binary', 'Therapy', 'Washington'); INSERT INTO patients (patient_id, age, gender, treatment, state) VALUES (4, 18, 'Male', 'Therapy', 'Colorado');","sql":"SELECT MIN(age) FROM patients WHERE treatment = 'Therapy' AND state = 'Colorado';","sql_explanation":"This SQL query calculates the minimum age of patients who received therapy in Colorado. It does this by filtering the patients table to only include rows where the treatment is therapy and the state is Colorado, and then calculating the minimum value of the age column for those rows."}
{"sql_prompt":"What is the total amount of research grants awarded to graduate students from underrepresented communities in the last 5 years, partitioned by their home departments?","sql_context":"CREATE TABLE grad_students (student_id INT, name VARCHAR(50), home_dept VARCHAR(50), underrepresented_community BOOLEAN); CREATE TABLE research_grants (grant_id INT, student_id INT, grant_amount DECIMAL(10, 2), grant_date DATE);","sql":"SELECT home_dept, SUM(grant_amount) FROM research_grants rg JOIN grad_students gs ON rg.student_id = gs.student_id WHERE gs.underrepresented_community = TRUE AND rg.grant_date >= DATEADD(year, -5, GETDATE()) GROUP BY home_dept;","sql_explanation":"This SQL query calculates the total research grant amount awarded to graduate students from underrepresented communities within the past 5 years, partitioned by their home departments. It first joins the research_grants and grad_students tables based on the student_id. The WHERE clause filters the results based on the underrepresented_community status and the grant date within the past 5 years. Finally, the GROUP BY clause groups the results by the home_dept."}
{"sql_prompt":"What is the total quantity of dairy products sold in each country?","sql_context":"CREATE TABLE Countries (CountryID INT, CountryName VARCHAR(50));CREATE TABLE Products (ProductID INT, ProductName VARCHAR(50), Dairy BOOLEAN, QuantitySold INT); INSERT INTO Countries VALUES (1, 'USA'), (2, 'Canada'); INSERT INTO Products VALUES (1, 'Cheese', true, 100), (2, 'Milk', true, 150), (3, 'Eggs', true, 200), (4, 'Tofu', false, 50);","sql":"SELECT c.CountryName, p.ProductName, SUM(p.QuantitySold) as TotalQuantitySold FROM Countries c JOIN Products p ON c.CountryID = 1 GROUP BY c.CountryName, p.ProductName HAVING p.Dairy = true;","sql_explanation":"This query joins the Countries and Products tables, filters for dairy products, and then groups the data by country name and product name. Finally, it calculates the total quantity sold for each country-product combination."}
{"sql_prompt":"What was the landfill capacity in cubic meters for the 'East' region in 2020?","sql_context":"CREATE TABLE landfill_capacity (region VARCHAR(20), year INT, capacity INT); INSERT INTO landfill_capacity (region, year, capacity) VALUES ('East', 2019, 400000), ('East', 2020, 425000), ('East', 2021, 450000);","sql":"SELECT capacity FROM landfill_capacity WHERE region = 'East' AND year = 2020;","sql_explanation":"This query retrieves the landfill capacity in cubic meters for the 'East' region in the year 2020."}
{"sql_prompt":"Insert a new rural infrastructure project 'Solar Power' in Vietnam with a budget of 600000.","sql_context":"CREATE TABLE RuralInfrastructure (id INT, project VARCHAR(255), country VARCHAR(255), budget FLOAT);","sql":"INSERT INTO RuralInfrastructure (project, country, budget) VALUES ('Solar Power', 'Vietnam', 600000);","sql_explanation":"This SQL query inserts a new rural infrastructure project 'Solar Power' in Vietnam with a budget of 600000 by inserting a new row into the 'RuralInfrastructure' table with the specified values."}
{"sql_prompt":"What is the total biomass for all species in the Arctic Ocean?","sql_context":"CREATE TABLE species_biomass (species VARCHAR(255), ocean VARCHAR(255), biomass FLOAT); INSERT INTO species_biomass (species, ocean, biomass) VALUES ('Polar Bear', 'Arctic Ocean', 500.0);","sql":"SELECT ocean, SUM(biomass) FROM species_biomass WHERE ocean = 'Arctic Ocean' GROUP BY ocean","sql_explanation":"The SQL query aggregates the total biomass for all species in the Arctic Ocean from the species_biomass table, grouping by the ocean column."}
{"sql_prompt":"What is the average number of workers per industry?","sql_context":"CREATE TABLE if not exists industry (industry_id INT, industry_name TEXT, total_workers INT); INSERT INTO industry (industry_id, industry_name, total_workers) VALUES (1, 'manufacturing', 5000), (2, 'technology', 7000), (3, 'healthcare', 6000), (4, 'finance', 4000), (5, 'retail', 3000);","sql":"SELECT AVG(total_workers) FROM industry;","sql_explanation":"This SQL query calculates the average number of workers per industry by taking the average of the 'total_workers' column in the 'industry' table."}
{"sql_prompt":"How many rural infrastructure projects were completed in India before 2017?","sql_context":"CREATE TABLE projects (id INT, location VARCHAR(50), completion_date DATE); INSERT INTO projects (id, location, completion_date) VALUES (1, 'India', '2016-05-01'), (2, 'Brazil', '2017-12-31'), (3, 'Ghana', '2016-08-15'), (4, 'India', '2018-09-05'), (5, 'Tanzania', '2014-11-23');","sql":"SELECT COUNT(*) FROM projects WHERE location = 'India' AND completion_date < '2017-01-01';","sql_explanation":"This query counts the number of rural infrastructure projects completed in India before 2017 by filtering the 'projects' table based on the 'location' and 'completion_date' columns."}
{"sql_prompt":"What is the total number of threat indicators for the energy sector with a confidence level higher than 75?","sql_context":"CREATE TABLE threat_indicators (id INT, sector TEXT, confidence INT); INSERT INTO threat_indicators (id, sector, confidence) VALUES (1, 'Energy', 80); INSERT INTO threat_indicators (id, sector, confidence) VALUES (2, 'Transportation', 70); INSERT INTO threat_indicators (id, sector, confidence) VALUES (3, 'Energy', 78);","sql":"SELECT SUM(confidence) FROM threat_indicators WHERE sector = 'Energy' AND confidence > 75;","sql_explanation":"The SQL query calculates the total confidence level for threat indicators in the energy sector with a confidence level higher than 75 by using the SUM() function and filtering the data based on the sector and confidence columns."}
{"sql_prompt":"What is the average number of smart contracts developed per developer in Africa?","sql_context":"CREATE TABLE developers (id INT, name VARCHAR(50), country VARCHAR(50)); INSERT INTO developers (id, name, country) VALUES (1, 'Eve', 'Nigeria'), (2, 'Frank', 'South Africa'), (3, 'Grace', 'Egypt'); CREATE TABLE smart_contracts (id INT, name VARCHAR(50), developer_id INT); INSERT INTO smart_contracts (id, name, developer_id) VALUES (1, 'SC1', 1), (2, 'SC2', 1), (3, 'SC3', 2), (4, 'SC4', 3);","sql":"SELECT AVG(sc_per_dev) FROM (SELECT COUNT(*) as sc_per_dev FROM smart_contracts sc INNER JOIN developers d ON sc.developer_id = d.id GROUP BY d.id) as subquery;","sql_explanation":"Join the smart_contracts and developers tables based on developer_id. Group the records by developer_id and count the number of smart contracts per developer. Calculate the average of smart contracts per developer using a subquery."}
{"sql_prompt":"How many shipments were handled by each warehouse in the first quarter of 2021?","sql_context":"CREATE TABLE Warehouse (id INT, country VARCHAR(255), city VARCHAR(255), opened_date DATE); INSERT INTO Warehouse (id, country, city, opened_date) VALUES (1, 'Germany', 'Frankfurt', '2019-01-01'), (2, 'France', 'Lyon', '2020-01-01'); CREATE TABLE Shipments (id INT, warehouse_id INT, shipped_date DATE);","sql":"SELECT w.country, w.city, COUNT(s.id) AS shipment_count FROM Warehouse w JOIN Shipments s ON w.id = s.warehouse_id WHERE s.shipped_date >= '2021-01-01' AND s.shipped_date < '2021-04-01' GROUP BY w.id;","sql_explanation":"This query lists the number of shipments handled by each warehouse in the first quarter of 2021. It does so by joining the Warehouse table with the Shipments table on the warehouse_id foreign key. Then it filters for shipments that occurred in the first quarter of 2021, groups by warehouse id, and counts the number of rows in each group."}
{"sql_prompt":"What is the total number of customer complaints regarding mobile and broadband services by region?","sql_context":"CREATE TABLE complaints (complaint_id INT, complaint_type VARCHAR(255), region VARCHAR(255)); INSERT INTO complaints (complaint_id, complaint_type, region) VALUES (1, 'Mobile', 'North'), (2, 'Broadband', 'South'), (3, 'Mobile', 'East'), (4, 'Broadband', 'West'), (5, 'Mobile', 'North'), (6, 'Broadband', 'South'), (7, 'Mobile', 'East'), (8, 'Broadband', 'West');","sql":"SELECT region, COUNT(*) AS total_complaints FROM complaints WHERE complaint_type IN ('Mobile', 'Broadband') GROUP BY region;","sql_explanation":"The SQL query calculates the total number of customer complaints regarding mobile and broadband services by region."}
{"sql_prompt":"How many bioprocess engineering projects are in Eastern Europe?","sql_context":"CREATE SCHEMA if not exists bioprocessing;CREATE TABLE if not exists bioprocessing.projects (id INT PRIMARY KEY, name VARCHAR(100), region VARCHAR(100)); INSERT INTO bioprocessing.projects (id, name, region) VALUES (1, 'ProjA', 'Warsaw'), (2, 'ProjB', 'Moscow'), (3, 'ProjC', 'Prague'), (4, 'ProjD', 'Bucharest'), (5, 'ProjE', 'Kiev');","sql":"SELECT COUNT(*) FROM bioprocessing.projects WHERE region = 'Eastern Europe';","sql_explanation":"The SQL query counts the number of bioprocess engineering projects in Eastern Europe by using the COUNT() function on all rows (*) and filtering the results to only include rows where the region is 'Eastern Europe'."}
{"sql_prompt":"Which operators have the highest average production quantity per well?","sql_context":"CREATE TABLE wells (well_id INT, well_name TEXT, production_qty FLOAT, operator_id INT); INSERT INTO wells (well_id, well_name, production_qty, operator_id) VALUES (1, 'Well A', 1000, 1), (2, 'Well B', 1500, 1), (3, 'Well C', 800, 2); CREATE TABLE operators (operator_id INT, operator_name TEXT); INSERT INTO operators (operator_id, operator_name) VALUES (1, 'ABC Inc.'), (2, 'DEF'), (3, 'GHI Inc.');","sql":"SELECT o.operator_name, AVG(w.production_qty) as avg_production FROM wells w JOIN operators o ON w.operator_id = o.operator_id GROUP BY o.operator_name ORDER BY avg_production DESC;","sql_explanation":"This query first creates and populates the wells and operators tables with relevant data. It then performs an inner join between the two tables on the operator_id column. The query then calculates the average production quantity per well for each operator using the AVG function and groups the results by operator_name. Finally, it orders the results by avg_production in descending order."}
{"sql_prompt":"find the number of records in the CommunityHealthStatistics table where the State is 'TX' and the County is 'Harris'","sql_context":"CREATE TABLE CommunityHealthStatistics (ID INT, State TEXT, County TEXT, Population INT, AverageIncome FLOAT); INSERT INTO CommunityHealthStatistics (ID, State, County, Population, AverageIncome) VALUES (1, 'TX', 'Harris', 4500000, 60000), (2, 'CA', 'LA', 2500000, 70000);","sql":"SELECT * FROM CommunityHealthStatistics WHERE State = 'TX' AND County = 'Harris';","sql_explanation":"The SQL query selects all records from the CommunityHealthStatistics table where the State is 'TX' and the County is 'Harris'."}
{"sql_prompt":"What is the total number of satellites launched by SpaceX and ROSCOSMOS?","sql_context":"CREATE TABLE spacex_satellites (satellite_id INT, name VARCHAR(255), launch_date DATE);CREATE TABLE roscosmos_satellites (satellite_id INT, name VARCHAR(255), launch_date DATE);","sql":"SELECT COUNT(*) FROM spacex_satellites WHERE name = 'SpaceX';SELECT COUNT(*) FROM roscosmos_satellites WHERE name = 'ROSCOSMOS';","sql_explanation":"The first SQL query counts the number of satellites launched by SpaceX, while the second one counts the number of satellites launched by ROSCOSMOS. The total number of satellites is obtained by adding the results of these two queries."}
{"sql_prompt":"What is the total quantity of unsold garments for each manufacturer based in 'Italy' or 'Spain'?","sql_context":"CREATE TABLE manufacturers (id INT PRIMARY KEY, name VARCHAR(255), country VARCHAR(255)); CREATE TABLE garments (id INT PRIMARY KEY, manufacturer_id INT, quantity_manufactured INT, quantity_sold INT);","sql":"SELECT m.name, SUM(g.quantity_manufactured - g.quantity_sold) as total_unsold_quantity FROM manufacturers m JOIN garments g ON m.id = g.manufacturer_id WHERE m.country IN ('Italy', 'Spain') GROUP BY m.name;","sql_explanation":"The SQL query first joins the 'garments' table with the 'manufacturers' table based on the manufacturer_id. It then calculates the total quantity of unsold garments for each manufacturer based in 'Italy' or 'Spain'. The SUM function is used to add up the quantities for each manufacturer. Finally, the results are grouped by manufacturer name."}
{"sql_prompt":"Which aircraft models were involved in the highest number of accidents in 2020?","sql_context":"CREATE TABLE Aircraft(id INT, model VARCHAR(50), manufacturer VARCHAR(50)); CREATE TABLE Accidents(id INT, aircraft_id INT, year INT); INSERT INTO Aircraft(id, model, manufacturer) VALUES (1, 'A320', 'Airbus'), (2, '737', 'Boeing'); INSERT INTO Accidents(id, aircraft_id, year) VALUES (1, 1, 2020), (2, 1, 2020), (3, 2, 2020), (4, 2, 2020), (5, 2, 2020);","sql":"SELECT Aircraft.model, COUNT(*) as num_accidents FROM Aircraft INNER JOIN Accidents ON Aircraft.id = Accidents.aircraft_id WHERE Accidents.year = 2020 GROUP BY Aircraft.model ORDER BY num_accidents DESC LIMIT 1;","sql_explanation":"This query identifies the aircraft model involved in the highest number of accidents in 2020. It performs an inner join on the Aircraft and Accidents tables based on the aircraft_id, filters for accidents that occurred in 2020, groups the results by aircraft model, and orders them in descending order based on the number of accidents. The query then returns the top result, which is the aircraft model involved in the highest number of accidents."}
{"sql_prompt":"What is the total revenue of restaurants serving Italian cuisine?","sql_context":"CREATE TABLE Restaurants (id INT, name VARCHAR(50), type VARCHAR(20)); CREATE TABLE Menu (id INT, restaurant_id INT, dish VARCHAR(50), category VARCHAR(20), price DECIMAL(5,2)); INSERT INTO Restaurants (id, name, type) VALUES (1, 'PastaPalace', 'Italian'); INSERT INTO Menu (id, restaurant_id, dish, category, price) VALUES (1, 1, 'Lasagna', 'Italian', 12.99);","sql":"SELECT SUM(price) FROM Menu JOIN Restaurants ON Menu.restaurant_id = Restaurants.id WHERE Restaurants.type = 'Italian';","sql_explanation":"This query calculates the total revenue of restaurants serving Italian cuisine by joining the 'Menu' table with the 'Restaurants' table, filtering the records with type as 'Italian', and then summing up the 'price' of all dishes."}
{"sql_prompt":"List all climate mitigation projects in Oceania and their respective end dates.","sql_context":"CREATE TABLE climate_mitigation (project_name VARCHAR(255), region VARCHAR(255), start_date DATE, end_date DATE); INSERT INTO climate_mitigation (project_name, region, start_date, end_date) VALUES ('Coral Reef Restoration', 'Oceania', '2020-01-01', '2022-12-31'); INSERT INTO climate_mitigation (project_name, region, start_date, end_date) VALUES ('Mangrove Planting', 'Oceania', '2019-06-15', '2021-05-31');","sql":"SELECT project_name, end_date FROM climate_mitigation WHERE region = 'Oceania';","sql_explanation":"This query lists all climate mitigation projects in Oceania and their respective end dates by selecting the 'project_name' and 'end_date' columns where 'region' is 'Oceania'."}
{"sql_prompt":"What is the number of vaccination centers providing COVID-19 vaccines and flu shots, differentiated by type, for each state, from the vaccination_centers and state_data tables?","sql_context":"CREATE TABLE vaccination_centers (center_id TEXT, state TEXT, vaccine_type TEXT); INSERT INTO vaccination_centers (center_id, state, vaccine_type) VALUES ('Center1', 'StateA', 'COVID-19'), ('Center2', 'StateA', 'Flu'), ('Center3', 'StateB', 'COVID-19'), ('Center4', 'StateB', 'Flu'); CREATE TABLE state_data (state TEXT, total_centers INT); INSERT INTO state_data (state, total_centers) VALUES ('StateA', 500), ('StateB', 600), ('StateC', 700), ('StateD', 800);","sql":"SELECT state, vaccine_type, COUNT(*) AS center_count FROM vaccination_centers WHERE vaccine_type IN ('COVID-19', 'Flu') GROUP BY state, vaccine_type;","sql_explanation":"This query returns the number of vaccination centers providing COVID-19 vaccines and flu shots, differentiated by type, for each state. It filters the vaccination_centers table based on vaccine type and then groups the results by state and vaccine type."}
{"sql_prompt":"Calculate the average number of construction labor hours worked per day for the month of February 2022","sql_context":"CREATE TABLE construction_labor (worker_id INT, hours_worked INT, work_date DATE);","sql":"SELECT AVG(hours_worked \/ 8) FROM construction_labor WHERE EXTRACT(MONTH FROM work_date) = 2","sql_explanation":"This SQL query calculates the average number of construction labor hours worked per day for the month of February 2022."}
{"sql_prompt":"What is the total revenue for a specific cuisine type in a given month?","sql_context":"CREATE TABLE revenue_by_cuisine (restaurant_id INT, cuisine VARCHAR(255), revenue FLOAT, revenue_date DATE); INSERT INTO revenue_by_cuisine (restaurant_id, cuisine, revenue, revenue_date) VALUES (1, 'Italian', 5000.00, '2022-01-01'), (2, 'Mexican', 6000.00, '2022-01-02'), (3, 'Italian', 4000.00, '2022-01-03'), (4, 'Chinese', 7000.00, '2022-01-04'), (5, 'Chinese', 8000.00, '2022-01-05'), (6, 'Italian', 9000.00, '2022-01-06');","sql":"SELECT cuisine, SUM(revenue) as total_revenue FROM revenue_by_cuisine WHERE cuisine = 'Italian' AND revenue_date BETWEEN '2022-01-01' AND '2022-01-31' GROUP BY cuisine;","sql_explanation":"This SQL query calculates the total revenue for a specific cuisine type in a given month. It uses the WHERE clause to filter the records based on the cuisine type and the revenue date. The BETWEEN operator is used to specify the range of revenue dates. The GROUP BY clause is used to group the records by cuisine type and the SUM function is used to calculate the total revenue for each group."}
{"sql_prompt":"What is the average property tax for single-family homes in each neighborhood?","sql_context":"CREATE TABLE Neighborhoods (NeighborhoodID INT, Name VARCHAR(50), AveragePropertyTax FLOAT);CREATE TABLE Properties (PropertyID INT, NeighborhoodID INT, PropertyType VARCHAR(50), PropertyTax FLOAT);","sql":"SELECT N.Name, AVG(P.PropertyTax) as AvgPropertyTax FROM Properties P JOIN Neighborhoods N ON P.NeighborhoodID = N.NeighborhoodID WHERE P.PropertyType = 'Single-Family' GROUP BY N.Name;","sql_explanation":"We first join the Properties and Neighborhoods tables on the NeighborhoodID. We then filter for only single-family properties using the WHERE clause. Lastly, we group by the Name of the neighborhood and calculate the average property tax for each group."}
{"sql_prompt":"What is the total cargo weight transported by each vessel in the past week?","sql_context":"CREATE TABLE Cargo_Tracking(Vessel_ID INT, Cargo_Type VARCHAR(50), Transport_Date DATE, Total_Weight INT); INSERT INTO Cargo_Tracking VALUES (5, 'Coal', '2022-03-20', 2000), (5, 'Iron Ore', '2022-03-21', 3000), (5, 'Grain', '2022-03-23', 1500), (6, 'Coal', '2022-03-20', 3000), (6, 'Grain', '2022-03-21', 1000);","sql":"SELECT Vessel_ID, SUM(Total_Weight) FROM Cargo_Tracking WHERE Transport_Date >= DATEADD(WEEK, -1, GETDATE()) GROUP BY Vessel_ID;","sql_explanation":"This SQL query lists the total cargo weight transported by each vessel in the past week. It does this by selecting the sum of the Total_Weight column from the Cargo_Tracking table where the Transport_Date is within the last week, grouping the results by the Vessel_ID column."}
{"sql_prompt":"What are the names and production dates of garments made from fabrics with a sustainability score over 70, produced after 2021-01-01?","sql_context":"CREATE TABLE fabrics (id INT, name VARCHAR(50), type VARCHAR(50), sustainability_score INT); INSERT INTO fabrics (id, name, type, sustainability_score) VALUES (1, 'Organic Linen', 'Natural', 80); INSERT INTO fabrics (id, name, type, sustainability_score) VALUES (2, 'Recycled Nylon', 'Synthetic', 72);","sql":"SELECT garments.name, garments.production_date FROM garments JOIN fabrics ON garments.fabric_id = fabrics.id WHERE fabrics.sustainability_score > 70 AND garments.production_date > '2021-01-01';","sql_explanation":"Join the garments and fabrics tables, selecting the names and production dates of garments made from fabrics with a sustainability score over 70 and produced after 2021-01-01."}
{"sql_prompt":"Which countries have the highest average donation amount?","sql_context":"CREATE TABLE donations (id INT, donor_name VARCHAR, country VARCHAR, amount DECIMAL); INSERT INTO donations (id, donor_name, country, amount) VALUES (1, 'John Doe', 'USA', 100.00), (2, 'Jane Smith', 'Canada', 150.00);","sql":"SELECT country, AVG(amount) as avg_donation FROM donations GROUP BY country ORDER BY avg_donation DESC;","sql_explanation":"This query calculates the average donation amount for each country and orders the results in descending order to find the countries with the highest average donation amount."}
{"sql_prompt":"What is the total quantity of corn sold by farmers in 'Summerfield'?","sql_context":"CREATE TABLE farmers (id INT, name VARCHAR(50), location VARCHAR(50), crops VARCHAR(50)); CREATE TABLE crops (id INT, name VARCHAR(50), yield INT); CREATE TABLE sales (id INT, farmer_id INT, crop_name VARCHAR(50), quantity INT, price DECIMAL(5,2)); INSERT INTO farmers VALUES (1, 'Jane Doe', 'Summerfield', 'Corn'); INSERT INTO crops VALUES (1, 'Corn', 100); INSERT INTO sales VALUES (1, 1, 'Corn', 50, 2.50);","sql":"SELECT SUM(quantity) FROM sales INNER JOIN farmers ON sales.farmer_id = farmers.id INNER JOIN crops ON sales.crop_name = crops.name WHERE farmers.location = 'Summerfield' AND crops.name = 'Corn';","sql_explanation":"This query performs an inner join on the farmers, crops, and sales tables, joining the rows where the farmer_id column in the sales table matches the id column in the farmers table, and where the crop_name column in the sales table matches the name column in the crops table. The query then filters the results to only include rows where the location column in the farmers table is 'Summerfield' and where the name column in the crops table is 'Corn'. Finally, the query calculates the total quantity of corn sold by summing the quantity column."}
{"sql_prompt":"What is the name and region of the rural health department with the lowest patient-to-physician ratio?","sql_context":"CREATE TABLE departments (name VARCHAR(255), patient_count INT, physician_count INT); INSERT INTO departments (name, patient_count, physician_count) VALUES (1, 100, 50), (2, 150, 75);","sql":"SELECT name, region, patient_count, physician_count, (patient_count \/ NULLIF(physician_count, 0)) AS patient_physician_ratio FROM departments ORDER BY patient_physician_ratio ASC LIMIT 1;","sql_explanation":"This query calculates the patient-to-physician ratio for each department and orders the results by that ratio in ascending order, returning the top row and displaying the name, region, patient count, physician count, and patient-to-physician ratio for the department with the lowest ratio."}
{"sql_prompt":"Identify REE mining companies that have operations in both the USA and Australia?","sql_context":"CREATE TABLE company_operations (company_name VARCHAR(255), location VARCHAR(255)); INSERT INTO company_operations (company_name, location) VALUES ('Company X', 'USA'), ('Company Y', 'Australia'), ('Company Z', 'Canada'), ('Company A', 'China'), ('Company B', 'Australia'), ('Company C', 'USA'), ('Company D', 'Russia'), ('Company E', 'Brazil');","sql":"SELECT company_name FROM company_operations WHERE location IN ('USA', 'Australia') GROUP BY company_name HAVING COUNT(DISTINCT location) = 2;","sql_explanation":"This SQL query identifies REE mining companies that have operations in both the USA and Australia by selecting the company name from the company_operations table, grouping the result by company name, and filtering the grouped data for companies that have operations in both the USA and Australia using the HAVING clause and the COUNT and DISTINCT functions. It does so by grouping the company_operations table by company name using the GROUP BY clause, then counting the number of distinct locations for each company using the COUNT and DISTINCT functions, and finally filtering the grouped data for companies that have operations in both the USA and Australia using the HAVING clause and the COUNT and DISTINCT functions."}
{"sql_prompt":"What is the maximum temperature recorded in the 'arctic_weather' table for each month in the year 2020, broken down by species ('species' column in the 'arctic_weather' table)?","sql_context":"CREATE TABLE arctic_weather (id INT, date DATE, temperature FLOAT, species VARCHAR(50));","sql":"SELECT MONTH(date) AS month, species, MAX(temperature) AS max_temp FROM arctic_weather WHERE YEAR(date) = 2020 GROUP BY month, species;","sql_explanation":"The SQL query groups the data by month and species using the MONTH() and GROUP BY functions, and calculates the maximum temperature for each month and species using the MAX() function."}
{"sql_prompt":"What is the total number of refugee families supported by each NGO in the last 6 months in Asia?","sql_context":"CREATE TABLE NGOs (NGOID int, NGOName varchar(50)); INSERT INTO NGOs (NGOID, NGOName) VALUES (1, 'Save the Children Asia'), (2, 'Plan International Asia'); CREATE TABLE RefugeeSupport (SupportID int, NGOID int, FamilyID int, SupportDate date); INSERT INTO RefugeeSupport (SupportID, NGOID, FamilyID, SupportDate) VALUES (1, 1, 1, '2022-02-01'), (2, 1, 2, '2022-03-01'), (3, 2, 1, '2022-04-01');","sql":"SELECT NGOName, COUNT(DISTINCT FamilyID) as SupportedFamilies FROM NGOs INNER JOIN RefugeeSupport ON NGOs.NGOID = RefugeeSupport.NGOID WHERE SupportDate >= DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH) AND Country = 'Asia' GROUP BY NGOName;","sql_explanation":"This SQL query performs an inner join between the NGOs table and the RefugeeSupport table, filtering for the last 6 months and the continent of Asia. It counts the distinct number of refugee families supported by each NGO and groups the results by NGO name."}
{"sql_prompt":"How many economic diversification efforts were successful in South Africa between 2015 and 2021?","sql_context":"CREATE TABLE economic_diversification_efforts (id INT, country VARCHAR(20), success BOOLEAN, start_year INT, end_year INT); INSERT INTO economic_diversification_efforts (id, country, success, start_year, end_year) VALUES (1, 'South Africa', true, 2015, 2021), (2, 'South Africa', false, 2014, 2016);","sql":"SELECT COUNT(*) FROM economic_diversification_efforts WHERE country = 'South Africa' AND start_year >= 2015 AND end_year <= 2021 AND success = true;","sql_explanation":"This query counts the number of successful economic diversification efforts in South Africa between 2015 and 2021 by counting all records with country equals to South Africa, start_year greater than or equal to 2015, end_year less than or equal to 2021, and success equals to true."}
{"sql_prompt":"Find the number of wells drilled in the year 2020 in Texas","sql_context":"CREATE TABLE wells (id INT, well_name VARCHAR(255), location VARCHAR(255), drill_year INT, company VARCHAR(255)); INSERT INTO wells (id, well_name, location, drill_year, company) VALUES (1, 'Well001', 'Texas', 2020, 'CompanyA'); INSERT INTO wells (id, well_name, location, drill_year, company) VALUES (2, 'Well002', 'Colorado', 2019, 'CompanyB');","sql":"SELECT COUNT(*) FROM wells WHERE drill_year = 2020 AND location = 'Texas';","sql_explanation":"This query counts the number of records in the 'wells' table where the 'drill_year' is 2020 and the 'location' is 'Texas'."}
{"sql_prompt":"What is the percentage of organic certified fish farms in the Mediterranean in 2021?","sql_context":"CREATE TABLE fish_farms (farm_id INT, region VARCHAR(50), certification_status VARCHAR(50), year INT);","sql":"SELECT (COUNT(*) * 100.0 \/ (SELECT COUNT(*) FROM fish_farms WHERE year = 2021)) as percentage FROM fish_farms WHERE region = 'Mediterranean' AND certification_status = 'organic' AND year = 2021;","sql_explanation":"Calculate the percentage of organic certified fish farms in the Mediterranean in 2021 by filtering the fish_farms table with the WHERE clause to only include rows with the region set to 'Mediterranean', a certification status of 'organic', and a year of 2021. The SELECT statement uses a subquery to find the total number of farms in the Mediterranean in 2021 and the COUNT statement calculates the number of organic certified farms. The result is then multiplied by 100.0 to convert it to a percentage."}
{"sql_prompt":"What is the difference between the average satisfaction score of models trained on dataset D and dataset C, for each continent?","sql_context":"CREATE TABLE models (id INT, dataset VARCHAR(20), satisfaction FLOAT, continent VARCHAR(20)); INSERT INTO models VALUES (1, 'datasetD', 4.3, 'Asia'), (2, 'datasetD', 4.5, 'Africa'), (3, 'datasetC', 3.9, 'Antarctica'), (4, 'datasetC', 4.1, 'Antarctica'), (5, 'datasetD', 4.2, 'Europe'), (6, 'datasetC', 3.7, 'Europe');","sql":"SELECT continent, AVG(m.satisfaction) - (SELECT AVG(satisfaction) FROM models m2 WHERE m.continent = m2.continent AND m2.dataset = 'datasetC') FROM models m WHERE m.dataset = 'datasetD' GROUP BY continent;","sql_explanation":"This query uses a subquery to find the average satisfaction score for models trained on dataset C, for each continent, and then subtracts that from the average satisfaction score for models trained on dataset D."}
{"sql_prompt":"Minimum excavation date in 'asian_archaeology'?","sql_context":"CREATE TABLE asian_archaeology (site_id INT, excavation_date DATE);","sql":"SELECT MIN(excavation_date) FROM asian_archaeology;","sql_explanation":"This query finds the minimum excavation date in the 'asian_archaeology' table. It does this by using the MIN function on the 'excavation_date' column."}
{"sql_prompt":"What is the total revenue generated by sales of eco-friendly materials?","sql_context":"CREATE TABLE Sales (id INT, item_name VARCHAR(50), material VARCHAR(50), revenue INT); INSERT INTO Sales (id, item_name, material, revenue) VALUES (1, 'Shirt', 'Organic Cotton', 25), (2, 'Pants', 'Hemp', 30), (3, 'Jacket', 'Recycled Polyester', 50), (4, 'Shirt', 'Tencel', 20), (5, 'Skirt', 'Bamboo', 35);","sql":"SELECT SUM(revenue) FROM Sales WHERE material IN ('Organic Cotton', 'Hemp', 'Recycled Polyester', 'Tencel', 'Bamboo');","sql_explanation":"The SQL query calculates the total revenue generated by sales of eco-friendly materials, including Organic Cotton, Hemp, Recycled Polyester, Tencel, and Bamboo."}
{"sql_prompt":"List all artists who have created more than 100 pieces of artwork in the 'Modern Art' category.","sql_context":"CREATE TABLE Artists (artist_id INT, artist_name VARCHAR(255), category VARCHAR(255), num_pieces INT); INSERT INTO Artists (artist_id, artist_name, category, num_pieces) VALUES (1, 'Pablo Picasso', 'Modern Art', 120), (2, 'Vincent van Gogh', 'Post-Impressionism', 90), (3, 'Jackson Pollock', 'Modern Art', 150);","sql":"SELECT artist_name, category, num_pieces FROM Artists WHERE category = 'Modern Art' AND num_pieces > 100;","sql_explanation":"The SQL query lists all artists who have created more than 100 pieces of artwork in the 'Modern Art' category by filtering the data for the specific category and number of pieces, then selecting the relevant columns."}
{"sql_prompt":"List the intelligence operations and their corresponding threat levels, and rank them based on their threat level and budget.","sql_context":"CREATE TABLE intel_ops_threat (id INT, operation VARCHAR, threat VARCHAR, budget INT); INSERT INTO intel_ops_threat (id, operation, threat, budget) VALUES (1, 'Operation Red Folder', 'High', 5000000), (2, 'Operation Black Vault', 'Medium', 7000000), (3, 'Operation Blue Sail', 'Low', 6000000);","sql":"SELECT operation, threat, budget, ROW_NUMBER() OVER (PARTITION BY threat ORDER BY budget DESC) as rank FROM intel_ops_threat;","sql_explanation":"The SQL query ranks the intelligence operations based on their threat level and budget by using the ROW_NUMBER() window function with the PARTITION BY clause."}
|