instruction stringlengths 0 1.06k | input stringlengths 11 5.3k | response stringlengths 2 4.44k |
|---|---|---|
How many graduate students in the Business department have not published any papers in the year 2019? | CREATE TABLE GraduateStudents (StudentID INT,Name VARCHAR(50),Department VARCHAR(50),Publications INT,PublicationYear INT); | SELECT COUNT(StudentID) FROM GraduateStudents WHERE Department = 'Business' AND Publications = 0 AND PublicationYear = 2019; |
Which conservation initiatives were implemented in regions with increasing contaminant levels in 2020? | CREATE TABLE water_quality (region VARCHAR(255),year INT,contaminant_level INT); INSERT INTO water_quality (region,year,contaminant_level) VALUES ('North',2018,10),('North',2019,12),('North',2020,15),('South',2018,15),('South',2019,18),('South',2020,20); CREATE TABLE conservation_initiatives (region VARCHAR(255),year I... | SELECT c.initiative FROM conservation_initiatives c JOIN water_quality w ON c.region = w.region WHERE c.year = w.year AND w.contaminant_level > (SELECT contaminant_level FROM water_quality WHERE region = w.region AND year = w.year - 1); |
Update records in the vessel_performance table where the vessel_id is 1001 and speed is less than 15, set the speed to 15 | CREATE TABLE vessel_performance (id INT,vessel_id INT,timestamp DATETIME,speed FLOAT); | UPDATE vessel_performance SET speed = 15 WHERE vessel_id = 1001 AND speed < 15; |
What is the total revenue for the skincare category in Canada? | CREATE TABLE cosmetics.sales_data (sale_id INT,category VARCHAR(50),country VARCHAR(50),revenue DECIMAL(10,2)); INSERT INTO cosmetics.sales_data (sale_id,category,country,revenue) VALUES (1,'Skincare','Canada',50.00),(2,'Makeup','Canada',75.00),(3,'Haircare','Canada',40.00),(4,'Skincare','US',100.00),(5,'Makeup','US',1... | SELECT SUM(revenue) as total_revenue FROM cosmetics.sales_data WHERE category = 'Skincare' AND country = 'Canada'; |
Which spacecraft had the highest temperature on its coldest mission? | CREATE TABLE spacecraft_temperatures (spacecraft_name TEXT,temperature FLOAT,mission_date DATE); | SELECT spacecraft_name, MIN(temperature) as lowest_temp, MAX(temperature) as highest_temp FROM spacecraft_temperatures GROUP BY spacecraft_name HAVING MAX(temperature) = (SELECT MAX(highest_temp) FROM (SELECT spacecraft_name, MAX(temperature) as highest_temp FROM spacecraft_temperatures GROUP BY spacecraft_name) subque... |
What is the maximum property value for townhouses in each borough? | CREATE TABLE Boroughs (BoroughID INT,BoroughName VARCHAR(255)); CREATE TABLE Properties (PropertyID INT,PropertyValue FLOAT,BoroughID INT); INSERT INTO Boroughs VALUES (1,'Brooklyn'); INSERT INTO Properties VALUES (1,2000000,1); | SELECT BoroughName, MAX(PropertyValue) FROM Properties p JOIN Boroughs b ON p.BoroughID = b.BoroughID WHERE p.PropertyType = 'Townhouse' GROUP BY BoroughName; |
Identify the number of whale sightings in the last 30 days | CREATE TABLE whale_sightings (id INT,sighting_date DATE); | SELECT COUNT(*) FROM whale_sightings WHERE sighting_date >= DATEADD(day, -30, GETDATE()); |
Which manufacturers in 'Tokyo' have more than 300 employees and their corresponding supplier names? | CREATE TABLE manufacturers (id INT,name VARCHAR(255),location VARCHAR(255),employee_count INT); INSERT INTO manufacturers (id,name,location,employee_count) VALUES (1,'Manufacturer X','Tokyo',400); CREATE TABLE suppliers (id INT,name VARCHAR(255),location VARCHAR(255),sustainability_rating INT); INSERT INTO suppliers (i... | SELECT m.name, s.name AS supplier_name FROM manufacturers m INNER JOIN suppliers s ON m.location = s.location WHERE m.employee_count > 300; |
find the total transaction volume for each smart contract in the 'SmartContractsTransactions' view, limited to the 'Ethereum' blockchain. | CREATE VIEW SmartContractsTransactions AS SELECT SmartContracts.name,Transactions.volume FROM SmartContracts JOIN Transactions ON SmartContracts.hash = Transactions.smart_contract_hash; CREATE TABLE Blockchain (id INT,name VARCHAR(20),type VARCHAR(20)); INSERT INTO Blockchain (id,name,type) VALUES (1,'Ethereum','Blockc... | SELECT SmartContracts.name, SUM(Transactions.volume) FROM SmartContractsTransactions JOIN SmartContracts ON SmartContractsTransactions.name = SmartContracts.name JOIN Transactions ON SmartContractsTransactions.hash = Transactions.smart_contract_hash JOIN Blockchain ON Transactions.blockchain_id = Blockchain.id WHERE Bl... |
Update the sales figure for DrugB in Q2 2023 to 16000. | CREATE TABLE sales_data (drug VARCHAR(255),quarter INT,year INT,sales FLOAT); INSERT INTO sales_data (drug,quarter,year,sales) VALUES ('DrugA',1,2023,12000),('DrugA',2,2023,15000),('DrugB',1,2023,8000),('DrugB',2,2023,18000),('DrugC',1,2023,10000); | UPDATE sales_data SET sales = 16000 WHERE drug = 'DrugB' AND quarter = 2 AND year = 2023; |
What is the total number of public transportation trips taken in the city of New York, including all routes, for the month of February 2023? | CREATE TABLE public_transportation (route VARCHAR(20),trip_count INT,trip_date DATE); INSERT INTO public_transportation (route,trip_count,trip_date) VALUES ('Route A',1200,'2023-02-01'); | SELECT SUM(trip_count) FROM public_transportation WHERE trip_date BETWEEN '2023-02-01' AND '2023-02-28'; |
What is the number of fish farms in each country in the Mediterranean? | CREATE TABLE fish_farms (id INT,name TEXT,country TEXT,ocean TEXT); INSERT INTO fish_farms (id,name,country,ocean) VALUES (1,'Farm A','Country A','Mediterranean'),(2,'Farm B','Country B','Mediterranean'),(3,'Farm C','Country A','Mediterranean'),(4,'Farm D','Country C','Mediterranean'); | SELECT country, COUNT(DISTINCT id) FROM fish_farms WHERE ocean = 'Mediterranean' GROUP BY country; |
What is the minimum age of a mental health professional in Illinois? | CREATE TABLE MentalHealthProfessional (ProfessionalID INT,Age INT,Specialty VARCHAR(50),State VARCHAR(20)); INSERT INTO MentalHealthProfessional (ProfessionalID,Age,Specialty,State) VALUES (1,50,'Psychologist','Illinois'); INSERT INTO MentalHealthProfessional (ProfessionalID,Age,Specialty,State) VALUES (2,45,'Social Wo... | SELECT MIN(Age) FROM MentalHealthProfessional WHERE State = 'Illinois'; |
Delete any smart contract that is not compliant with the regulatory framework and is older than 90 days. | CREATE TABLE smart_contracts (contract_id INT PRIMARY KEY,name VARCHAR(255),compliance_status VARCHAR(10),last_update_date DATETIME); INSERT INTO smart_contracts (contract_id,name,compliance_status,last_update_date) VALUES (1,'Contract1','Compliant','2022-01-10 15:00:00'),(2,'Contract2','Non-compliant','2022-02-05 16:0... | DELETE FROM smart_contracts WHERE compliance_status = 'Non-compliant' AND last_update_date < DATE_SUB(CURRENT_DATE, INTERVAL 90 DAY); |
Alter the "vessels" table by adding a new column named "flag_state" of type VARCHAR(3) to record the vessel's flag state. | CREATE TABLE vessels (vessel_id INT,name VARCHAR(50),type VARCHAR(50),year_built INT); | ALTER TABLE vessels ADD COLUMN flag_state VARCHAR(3); |
Find the total inventory cost for 'vegan' dishes across all restaurants and cafes. | CREATE TABLE VeganEats (location VARCHAR(20),item_type VARCHAR(15),cost DECIMAL(5,2)); INSERT INTO VeganEats (location,item_type,cost) VALUES ('GreenLeaf','vegan',5.50),('GreenLeaf','vegan',4.75),('Sprout','vegan',6.25),('EcoEats','vegan',6.50); | SELECT SUM(cost) FROM VeganEats WHERE item_type = 'vegan'; |
What are the details of vessels that arrived at the port of Los Angeles in January 2020? | CREATE TABLE port (port_name VARCHAR(255),arrival_date DATE); INSERT INTO port VALUES ('Los Angeles','2020-01-03'); CREATE TABLE vessel (vessel_name VARCHAR(255),vessel_type VARCHAR(255)); | SELECT v.vessel_name, v.vessel_type, p.port_name, p.arrival_date FROM vessel v INNER JOIN port p ON v.port_id = p.id WHERE p.arrival_date BETWEEN '2020-01-01' AND '2020-01-31'; |
Show total defense contracts value awarded per quarter | CREATE TABLE DefenseContracts (id INT,contract_date DATE,company_name VARCHAR(50),contract_value FLOAT); INSERT INTO DefenseContracts (id,contract_date,company_name,contract_value) VALUES (1,'2021-01-01','Northrop Grumman',15000000); INSERT INTO DefenseContracts (id,contract_date,company_name,contract_value) VALUES (2,... | SELECT DATE_FORMAT(contract_date, '%Y-%m'), SUM(contract_value) FROM DefenseContracts GROUP BY DATE_FORMAT(contract_date, '%Y-%m') ORDER BY DATE_FORMAT(contract_date, '%Y-%m'); |
Create a table named 'athlete_wellbeing' to store athlete wellbeing programs data | CREATE TABLE athlete_wellbeing (athlete_id INT,program_name VARCHAR(100),start_date DATE,end_date DATE,category VARCHAR(50)); | CREATE TABLE athlete_wellbeing (athlete_id INT, program_name VARCHAR(100), start_date DATE, end_date DATE, category VARCHAR(50)); |
What is the address, city, and state of properties without green certifications in 'EcoCity' priced above 700000? | CREATE TABLE properties (id INT,address VARCHAR(255),city VARCHAR(255),state VARCHAR(255),price INT,certification_type VARCHAR(255)); INSERT INTO properties (id,address,city,state,price,certification_type) VALUES (6,'654 Eco St','EcoCity','CO',725000,NULL); | SELECT DISTINCT properties.address, properties.city, properties.state FROM properties WHERE properties.city = 'EcoCity' AND properties.price > 700000 AND properties.certification_type IS NULL; |
Show the top 5 artists by total streams, including their genre and origin country. | CREATE TABLE artists (artist_id INT,artist_name VARCHAR(100),artist_genre VARCHAR(50),artist_country VARCHAR(50)); INSERT INTO artists (artist_id,artist_name,artist_genre,artist_country) VALUES (1,'Taylor Swift','Pop','United States'),(2,'Drake','Hip-Hop','Canada'),(3,'BTS','K-Pop','South Korea'); CREATE TABLE artist_s... | SELECT a.artist_name, a.artist_genre, a.artist_country, SUM(s.song_id) AS total_streams FROM artists a INNER JOIN artist_streams s ON a.artist_id = s.artist_id GROUP BY a.artist_id ORDER BY total_streams DESC LIMIT 5; |
Insert a new record into the 'multimodal_mobility' table with the following values: 'Seoul', 'Transit App' | CREATE TABLE multimodal_mobility (city VARCHAR(50),mode VARCHAR(50),PRIMARY KEY (city,mode)); | INSERT INTO multimodal_mobility (city, mode) VALUES ('Seoul', 'Transit App'); |
Find the most common actions taken by a specific actor. | CREATE TABLE incidents (id INT,date DATE,source TEXT,destination TEXT,action TEXT,actor TEXT);INSERT INTO incidents (id,date,source,destination,action,actor) VALUES (1,'2021-01-01','10.0.0.1','8.8.8.8','sent','user'); | SELECT actor, action, COUNT(*) as count, RANK() OVER (PARTITION BY actor ORDER BY count DESC) as rank FROM incidents GROUP BY actor, action ORDER BY actor, rank; |
What is the average number of citations for algorithmic fairness papers published in 2018 and 2019? | CREATE TABLE algorithmic_fairness_papers (year INT,paper_title VARCHAR(255),author_name VARCHAR(255),num_citations INT); INSERT INTO algorithmic_fairness_papers (year,paper_title,author_name,num_citations) VALUES ('2018','Algorithmic Fairness: A Review','Alice Johnson','50'); | SELECT AVG(num_citations) as avg_citations FROM algorithmic_fairness_papers WHERE year IN (2018, 2019); |
How many warehouse operations were performed in Q1 2022 for each warehouse? | CREATE TABLE warehouse_management (id INT,operation_date DATE,warehouse_id INT,operation_type VARCHAR(50),units INT); INSERT INTO warehouse_management (id,operation_date,warehouse_id,operation_type,units) VALUES [(1,'2022-01-01',1,'receiving',200),(2,'2022-01-02',1,'putaway',150),(3,'2022-01-03',2,'receiving',300),(4,'... | SELECT DATE_FORMAT(operation_date, '%Y-%m') AS quarter, warehouse_id, SUM(units) AS total_units FROM warehouse_management WHERE operation_date BETWEEN '2022-01-01' AND '2022-03-31' GROUP BY quarter, warehouse_id; |
How many circular economy initiatives were launched by country from 2015 to 2020? | CREATE TABLE circular_economy_initiatives (country VARCHAR(255),year INT,initiative_id INT); INSERT INTO circular_economy_initiatives (country,year,initiative_id) VALUES ('Germany',2015,1),('Germany',2016,2),('Germany',2017,3),('France',2016,1),('France',2017,2),('France',2018,3),('Italy',2017,1),('Italy',2018,2),('Ita... | SELECT country, COUNT(DISTINCT initiative_id) FROM circular_economy_initiatives WHERE year BETWEEN 2015 AND 2020 GROUP BY country; |
What is the maximum gas production per well in the Arctic in 2018? | CREATE TABLE gas_production (id INT,location VARCHAR(20),production_date DATE,gas_production INT); | SELECT MAX(gas_production) FROM gas_production WHERE location LIKE 'Arctic%' AND production_date = '2018-01-01'; |
What is the total number of tickets sold by month for each team? | CREATE TABLE monthly_ticket_sales (id INT,team VARCHAR(50),sale_month DATE,quantity INT); INSERT INTO monthly_ticket_sales (id,team,sale_month,quantity) VALUES (1,'TeamA','2022-01-01',1000),(2,'TeamB','2022-01-01',1500),(3,'TeamA','2022-02-01',1200),(4,'TeamB','2022-02-01',1800); | SELECT EXTRACT(MONTH FROM sale_month) as month, team, SUM(quantity) as total_sold FROM monthly_ticket_sales GROUP BY month, team; |
List the monthly immunization rates for children under 5 in rural health clinic Z in 2021? | CREATE TABLE clinics (clinic_id INT,clinic_name VARCHAR(50)); CREATE TABLE immunizations (immunization_id INT,patient_id INT,immunization_date DATE,clinic_id INT); | SELECT MONTH(immunization_date) as month, COUNT(DISTINCT patient_id) * 100.0 / (SELECT COUNT(DISTINCT patient_id) FROM patients WHERE age < 5) as immunization_rate FROM immunizations INNER JOIN clinics ON immunizations.clinic_id = clinics.clinic_id WHERE clinics.clinic_name = 'rural health clinic Z' AND YEAR(immunizati... |
Which traditional art form is the most popular in each country? | CREATE TABLE Countries (CountryID INT,CountryName VARCHAR(50)); CREATE TABLE ArtTypes (ArtTypeID INT,ArtType VARCHAR(50)); CREATE TABLE ArtCountry (ArtID INT,ArtTypeID INT,CountryID INT,Popularity INT); INSERT INTO Countries VALUES (1,'CountryA'),(2,'CountryB'),(3,'CountryC'); INSERT INTO ArtTypes VALUES (1,'Painting')... | SELECT C.CountryName, A.ArtType, MAX(AC.Popularity) AS MaxPopularity FROM Countries C JOIN ArtCountry AC ON C.CountryID = AC.CountryID JOIN ArtTypes A ON AC.ArtTypeID = A.ArtTypeID GROUP BY C.CountryName, A.ArtType; |
Insert a new cultural heritage site in Kyoto, Japan named "Kiyomizu-dera" with an ID of 3 | CREATE TABLE cultural_sites (site_id INT,name TEXT,location TEXT); INSERT INTO cultural_sites (site_id,name,location) VALUES (1,'Meiji Shrine','Tokyo'); INSERT INTO cultural_sites (site_id,name,location) VALUES (2,'Todai-ji Temple','Nara'); | INSERT INTO cultural_sites (site_id, name, location) VALUES (3, 'Kiyomizu-dera', 'Kyoto'); |
What is the energy efficiency score for each state, ranked from highest to lowest? | CREATE TABLE energy_efficiency (state VARCHAR(50),score FLOAT); INSERT INTO energy_efficiency (state,score) VALUES ('State A',80),('State B',85),('State C',90),('State D',75); | SELECT state, score, ROW_NUMBER() OVER (ORDER BY score DESC) as rank FROM energy_efficiency; |
Add a new marine protected area to the database. | CREATE TABLE marine_protected_areas (area_name TEXT,avg_depth REAL); INSERT INTO marine_protected_areas (area_name,avg_depth) VALUES ('Galapagos Islands',2000.0),('Great Barrier Reef',1500.0); | INSERT INTO marine_protected_areas (area_name, avg_depth) VALUES ('Palau', 2500.0); |
What is the maximum number of passengers carried by commercial airlines in India in 2019? | CREATE TABLE airline_passengers (airline VARCHAR(50),country VARCHAR(50),passengers INT,year INT); INSERT INTO airline_passengers (airline,country,passengers,year) VALUES ('IndiGo','India',120000,2019),('SpiceJet','India',150000,2019); | SELECT MAX(passengers) FROM airline_passengers WHERE country = 'India' AND year = 2019; |
Which country owns the spacecraft with the most medical incidents? | CREATE TABLE spacecraft (id INT,name VARCHAR(50),country VARCHAR(50),launch_date DATE); CREATE TABLE medical (id INT,spacecraft_id INT,medical_condition VARCHAR(50),medical_date DATE); INSERT INTO spacecraft (id,name,country,launch_date) VALUES (1,'Vostok 1','Russia','1961-04-12'); INSERT INTO spacecraft (id,name,count... | SELECT country, COUNT(*) as medical_counts FROM medical JOIN spacecraft ON medical.spacecraft_id = spacecraft.id GROUP BY country ORDER BY medical_counts DESC LIMIT 1; |
What is the total number of articles and videos produced by creators from underrepresented communities? | CREATE TABLE creators (id INT,name VARCHAR(100),community VARCHAR(50)); INSERT INTO creators (id,name,community) VALUES (1,'Alice','Female'),(2,'David','LGBTQ+'); CREATE TABLE content (id INT,creator_id INT,type VARCHAR(50),title VARCHAR(100)); INSERT INTO content (id,creator_id,type,title) VALUES (1,1,'article','Women... | SELECT SUM(num_articles + num_videos) FROM (SELECT c.community, COUNT(CASE WHEN con.type = 'article' THEN 1 END) AS num_articles, COUNT(CASE WHEN con.type = 'video' THEN 1 END) AS num_videos FROM creators c JOIN content con ON c.id = con.creator_id WHERE c.community IN ('underrepresented_group_1', 'underrepresented_gro... |
What is the minimum number of employees for startups founded by immigrants in the e-commerce sector? | CREATE TABLE startups (id INT,name TEXT,industry TEXT,founding_date DATE,founders TEXT,employees INT); INSERT INTO startups (id,name,industry,founding_date,founders,employees) VALUES (1,'EcomPioneers','E-commerce','2021-01-01','Immigrants',10); | SELECT MIN(employees) FROM startups WHERE founders = 'Immigrants' AND industry = 'E-commerce'; |
Update the response time for medical emergencies in the city of Boston to 7 minutes. | CREATE TABLE boston_medical_emergencies (id INT,response_time INT); INSERT INTO boston_medical_emergencies (id,response_time) VALUES (1,8); | UPDATE boston_medical_emergencies SET response_time = 7 WHERE id = 1; |
What is the average age of male and female patients for each condition? | CREATE TABLE PatientConditions (PatientID int,ConditionID int,Gender varchar(10),Age int); INSERT INTO PatientConditions (PatientID,ConditionID,Gender,Age) VALUES (1,1,'Male',30),(2,2,'Female',35); | SELECT Conditions.Condition, Gender, AVG(PatientConditions.Age) FROM PatientConditions JOIN Conditions ON PatientConditions.ConditionID = Conditions.ConditionID GROUP BY Conditions.Condition, Gender; |
Calculate the average price of 'Tilapia' in the 'sales' table. | CREATE TABLE sales (id INT PRIMARY KEY,vendor VARCHAR(50),quantity INT,species VARCHAR(50),price DECIMAL(5,2)); INSERT INTO sales (id,vendor,quantity,species,price) VALUES (1,'Seafood Haven',20,'Salmon',12.99),(2,'Sea Bounty',30,'Tilapia',9.49),(3,'Sea Bounty',15,'Cod',14.50); | SELECT AVG(price) FROM sales WHERE species = 'Tilapia'; |
What is the total R&D expenditure for each drug in the rd_expenditures table, grouped by drug name? | CREATE TABLE rd_expenditures (expenditure_id INT,drug_id INT,expenditure_type TEXT,expenditure_amount DECIMAL(10,2),year INT); INSERT INTO rd_expenditures (expenditure_id,drug_id,expenditure_type,expenditure_amount,year) VALUES (1,1,'Research',12000.00,2019),(2,1,'Development',15000.00,2020),(3,2,'Research',9000.00,201... | SELECT drug_id, SUM(expenditure_amount) AS total_rd_expenditure FROM rd_expenditures GROUP BY drug_id; |
What is the maximum caloric content of any food item sold by local grocery stores? | CREATE TABLE GroceryStores (id INT,name VARCHAR(50)); CREATE TABLE FoodItems (id INT,name VARCHAR(50),caloricContent FLOAT); | SELECT MAX(caloricContent) FROM FoodItems INNER JOIN GroceryStores ON FoodItems.name = GroceryStores.name; |
Find the number of approvals received for each drug, ranked from the most approvals to the least, by the FDA for infectious diseases? | CREATE TABLE fda_approvals_infectious_diseases (approval_id INT,drug_name VARCHAR(255),approval_date DATE,therapeutic_area VARCHAR(255)); INSERT INTO fda_approvals_infectious_diseases (approval_id,drug_name,approval_date,therapeutic_area) VALUES (1,'DrugS','2022-01-01','Infectious Diseases'),(2,'DrugT','2022-01-02','In... | SELECT drug_name, COUNT(*) as num_of_approvals FROM fda_approvals_infectious_diseases WHERE therapeutic_area = 'Infectious Diseases' GROUP BY drug_name ORDER BY num_of_approvals DESC; |
What is the most popular song (by number of streams) for each artist? | CREATE TABLE artist_songs (song_id INT,artist VARCHAR(50),streams INT); INSERT INTO artist_songs (song_id,artist,streams) VALUES (1,'ArtistA',20000),(1,'ArtistB',15000),(2,'ArtistA',30000),(3,'ArtistC',10000),(3,'ArtistA',25000),(4,'ArtistB',12000); | SELECT song_id, artist, MAX(streams) as max_streams FROM artist_songs GROUP BY artist; |
List the number of public events held in each city and state? | CREATE TABLE PublicEvents (EventID INT,EventName TEXT,EventCity TEXT,EventState TEXT); INSERT INTO PublicEvents (EventID,EventName,EventCity,EventState) VALUES (1,'Town Hall','New York','NY'),(2,'Community Meeting','Los Angeles','CA'); | SELECT EventState, EventCity, COUNT(*) FROM PublicEvents GROUP BY EventState, EventCity; |
Which esports event had the most international participants in 2022? | CREATE TABLE Events (EventID INT,Name VARCHAR(50),Country VARCHAR(50),StartDate DATE,EndDate DATE,Participants INT); INSERT INTO Events (EventID,Name,Country,StartDate,EndDate,Participants) VALUES (1,'Evo','USA','2022-08-06','2022-08-07',1000); INSERT INTO Events (EventID,Name,Country,StartDate,EndDate,Participants) VA... | SELECT Name, Participants FROM Events WHERE YEAR(StartDate) = 2022 GROUP BY Name ORDER BY Participants DESC LIMIT 1; |
How many games were won by players from Asia in the last week? | CREATE TABLE games (game_id INT,game_name TEXT,game_date DATE,winner_id INT,winner_name TEXT,winner_country TEXT); INSERT INTO games (game_id,game_name,game_date,winner_id,winner_name,winner_country) VALUES (1,'Game1','2022-01-01',4,'Han','South Korea'); INSERT INTO games (game_id,game_name,game_date,winner_id,winner_n... | SELECT COUNT(*) FROM games WHERE winner_country IN ('South Korea', 'China', 'Japan') AND game_date >= DATEADD(day, -7, GETDATE()); |
What is the total number of hours volunteered by volunteers from Latin America in 2020? | CREATE TABLE VolunteerHours (VolunteerID INT,Hours DECIMAL(5,2),Country TEXT,Year INT); INSERT INTO VolunteerHours (VolunteerID,Hours,Country,Year) VALUES (1,25.50,'Mexico',2020),(2,30.00,'USA',2019); | SELECT SUM(Hours) FROM VolunteerHours WHERE Country LIKE 'Lat%' AND Year = 2020; |
What are the top 5 cities with the most users who clicked on a sports ad in the past month? | CREATE TABLE cities (city_id INT,city_name VARCHAR(50));CREATE TABLE users (user_id INT,city_id INT,user_join_date DATE);CREATE TABLE clicks (click_id INT,user_id INT,ad_type VARCHAR(50),click_date DATE);INSERT INTO cities (city_id,city_name) VALUES (1,'New York'),(2,'Los Angeles'),(3,'Chicago'),(4,'Houston'),(5,'Phoen... | SELECT c.city_name, COUNT(DISTINCT u.user_id) as total_users FROM cities c JOIN users u ON c.city_id = u.city_id JOIN clicks cl ON u.user_id = cl.user_id WHERE cl.ad_type = 'sports' AND cl.click_date >= DATEADD(month, -1, GETDATE()) GROUP BY c.city_name ORDER BY total_users DESC LIMIT 5; |
What is the earliest incident date in the IncidentResponse table? | CREATE TABLE IncidentResponse (region VARCHAR(50),incidentDate DATE); INSERT INTO IncidentResponse (region,incidentDate) VALUES ('EMEA','2022-01-05'),('APAC','2022-01-12'),('AMER','2022-01-20'); | SELECT MIN(incidentDate) FROM IncidentResponse; |
Update the status of FOIA request with ID '98765' to 'Completed'. | CREATE TABLE foia_requests (request_id INT,requester_name VARCHAR(100),request_date DATE,request_type VARCHAR(50),status VARCHAR(50)); | UPDATE foia_requests SET status = 'Completed' WHERE request_id = 98765; |
Find the animals that are present in both the Asian and African regions. | CREATE TABLE if NOT EXISTS animal_region (animal_id INT,animal_name VARCHAR(50),region VARCHAR(10)); INSERT INTO animal_region (animal_id,animal_name,region) VALUES (1,'Tiger','Asia'); INSERT INTO animal_region (animal_id,animal_name,region) VALUES (2,'Lion','Africa'); INSERT INTO animal_region (animal_id,animal_name,r... | SELECT animal_name FROM animal_region WHERE region = 'Asia' INTERSECT SELECT animal_name FROM animal_region WHERE region = 'Africa'; |
Find the top 2 sites with the highest number of artifacts analyzed in the last 6 months. | CREATE TABLE SiteAnalysis (SiteName VARCHAR(50),AnalysisDate DATE); INSERT INTO SiteAnalysis (SiteName,AnalysisDate) VALUES ('Site1','2022-01-01'),('Site2','2022-02-01'),('Site3','2021-12-01'); | SELECT SiteName FROM (SELECT SiteName, COUNT(*) AS AnalysisCount, RANK() OVER (ORDER BY COUNT(*) DESC) AS SiteRank FROM SiteAnalysis WHERE AnalysisDate >= DATEADD(month, -6, GETDATE()) GROUP BY SiteName) AS Subquery WHERE SiteRank <= 2; |
Which departments have a policy impact above 4000? | CREATE TABLE dept_policy_impact (dept VARCHAR(50),impact INT); INSERT INTO dept_policy_impact (dept,impact) VALUES ('Infrastructure',5000),('Education',3000),('Health',4500); | SELECT dept FROM dept_policy_impact WHERE impact > 4000; |
How many matches were won by home teams in the last season? | CREATE TABLE matches (match_id INT,home_team_id INT,away_team_id INT,match_date DATE,home_team_won BOOLEAN); | SELECT COUNT(*) as num_wins FROM matches WHERE home_team_won = TRUE AND match_date >= DATEADD(year, -1, GETDATE()); |
Which carbon offset programs have a budget greater than $10 million in the carbon_offset schema? | CREATE TABLE carbon_offset_programs (id INT,name VARCHAR(50),budget FLOAT,start_date DATE,end_date DATE); INSERT INTO carbon_offset_programs (id,name,budget,start_date,end_date) VALUES (1,'Program 1',12000000,'2020-01-01','2025-12-31'); INSERT INTO carbon_offset_programs (id,name,budget,start_date,end_date) VALUES (2,'... | SELECT name FROM carbon_offset.carbon_offset_programs WHERE budget > 10000000; |
What is the average daily ridership for public transportation in rural areas? | CREATE TABLE public_transportation_rural (mode VARCHAR(20),daily_ridership INT); INSERT INTO public_transportation_rural (mode,daily_ridership) VALUES ('bus',500),('train',800),('light_rail',200); | SELECT AVG(daily_ridership) FROM public_transportation_rural WHERE mode IN ('bus', 'train', 'light_rail'); |
Find the average number of virtual tour bookings per user in 'Europe'? | CREATE TABLE user_bookings (user_id INT,country TEXT,num_virtual_tours INT); INSERT INTO user_bookings (user_id,country,num_virtual_tours) VALUES (1,'France',2),(2,'Germany',3),(3,'Spain',1),(4,'Italy',4),(5,'France',3); CREATE TABLE countries (country TEXT,continent TEXT); INSERT INTO countries (country,continent) VAL... | SELECT AVG(num_virtual_tours) FROM user_bookings WHERE country IN (SELECT country FROM countries WHERE continent = 'Europe'); |
What is the most common mental health condition among patients aged 18-35? | CREATE TABLE patient (patient_id INT,name VARCHAR(50),age INT,gender VARCHAR(10),condition VARCHAR(50)); INSERT INTO patient (patient_id,name,age,gender,condition) VALUES (1,'John Doe',27,'Male','Anxiety'),(2,'Jane Smith',32,'Female','Depression'),(3,'Alice Johnson',19,'Female','Anxiety'); CREATE TABLE condition_mappin... | SELECT condition, COUNT(patient_id) AS num_patients FROM patient JOIN condition_mapping ON patient.condition = condition_mapping.condition WHERE age BETWEEN 18 AND 35 GROUP BY condition ORDER BY num_patients DESC LIMIT 1; |
List all cases and their outcomes, along with the name of the attorney who handled the case, for cases with clients from underrepresented communities. | CREATE TABLE Cases (CaseID int,ClientID int,Outcome varchar(50)); CREATE TABLE Clients (ClientID int,Community varchar(50)); CREATE TABLE Attorneys (AttorneyID int,AttorneyName varchar(50)); INSERT INTO Cases VALUES (1,1,'Won'),(2,2,'Lost'),(3,3,'Settled'); INSERT INTO Clients VALUES (1,'Minority'),(2,'LGBTQ+'),(3,'Vet... | SELECT Cases.CaseID, Cases.Outcome, Attorneys.AttorneyName FROM Cases JOIN Clients ON Cases.ClientID = Clients.ClientID JOIN Attorneys ON Cases.AttorneyID = Attorneys.AttorneyID WHERE Clients.Community IN ('Minority', 'LGBTQ+', 'Veteran'); |
List all organic farming practices in descending order of their associated costs (in dollars) in the 'food_justice' schema? | CREATE SCHEMA food_justice;CREATE TABLE organic_practices (id INT,practice VARCHAR(50),cost FLOAT);INSERT INTO food_justice.organic_practices (id,practice,cost) VALUES (1,'Practice A',150.5),(2,'Practice B',200.3),(3,'Practice C',250.0); | SELECT practice, cost FROM food_justice.organic_practices ORDER BY cost DESC; |
What is the total amount of Shariah-compliant loans issued by each bank, ordered by total issued amount? | CREATE TABLE SHARIAH_COMPLIANT_LOANS (BANK_NAME VARCHAR(50),LOAN_TYPE VARCHAR(50),AMOUNT NUMBER(12,2)); INSERT INTO SHARIAH_COMPLIANT_LOANS VALUES ('Bank A','Shariah-compliant',120000); INSERT INTO SHARIAH_COMPLIANT_LOANS VALUES ('Bank B','Shariah-compliant',180000); INSERT INTO SHARIAH_COMPLIANT_LOANS VALUES ('Bank A'... | SELECT BANK_NAME, SUM(AMOUNT) TOTAL_LOANS FROM SHARIAH_COMPLIANT_LOANS WHERE LOAN_TYPE = 'Shariah-compliant' GROUP BY BANK_NAME ORDER BY TOTAL_LOANS DESC; |
Delete records of autonomous vehicles with manufacturing defects. | CREATE TABLE autonomous_vehicle (id INT PRIMARY KEY,name VARCHAR(255),make VARCHAR(255),model_year INT,defect_status VARCHAR(255)); INSERT INTO autonomous_vehicle (id,name,make,model_year,defect_status) VALUES (1,'Wayve Pod','Wayve',2021,'Yes'),(2,'Nuro R2','Nuro',2022,'No'),(3,'Zoox','Amazon',2021,'Yes'); | DELETE FROM autonomous_vehicle WHERE defect_status = 'Yes'; |
List all events with an attendance of over 500 people from the 'ArtExhibitions' and 'CulturalFestivals' tables. | CREATE TABLE ArtExhibitions (id INT,event_name VARCHAR(50),attendance INT); CREATE TABLE CulturalFestivals (id INT,event_name VARCHAR(50),attendance INT); | SELECT event_name FROM ArtExhibitions WHERE attendance > 500 UNION SELECT event_name FROM CulturalFestivals WHERE attendance > 500; |
Identify cultivators who have been compliant with regulations in the past year, ordered by the number of compliant months in descending order. | CREATE TABLE Cultivators (CultivatorID INT,CultivatorName VARCHAR(255)); CREATE TABLE Compliance (ComplianceID INT,CultivatorID INT,ComplianceMonth DATE); INSERT INTO Cultivators (CultivatorID,CultivatorName) VALUES (1,'Happy Hemp Farms'); INSERT INTO Cultivators (CultivatorID,CultivatorName) VALUES (2,'Kushy Kannabis'... | SELECT CultivatorName, COUNT(DISTINCT YEAR(ComplianceMonth) * 100 + MONTH(ComplianceMonth)) AS CompliantMonths FROM Cultivators JOIN Compliance ON Cultivators.CultivatorID = Compliance.CultivatorID WHERE ComplianceMonth >= DATEADD(MONTH, -12, GETDATE()) GROUP BY CultivatorName ORDER BY CompliantMonths DESC; |
What is the average number of employees in each department in the 'Health' agency? | CREATE SCHEMA Government;CREATE TABLE Government.Agency (name VARCHAR(255),budget INT);CREATE TABLE Government.Department (name VARCHAR(255),agency VARCHAR(255),employees INT,budget INT); | SELECT agency, AVG(employees) FROM Government.Department WHERE agency IN (SELECT name FROM Government.Agency WHERE budget > 3000000) GROUP BY agency; |
What are the top 5 most frequently used bus stops? | CREATE TABLE bus_stops (stop_id INT,stop_name VARCHAR(255)); CREATE TABLE bus_stop_visits (visit_id INT,stop_id INT,visit_date DATE); | SELECT bs.stop_name, COUNT(bsv.visit_id) as num_visits FROM bus_stops bs INNER JOIN bus_stop_visits bsv ON bs.stop_id = bsv.stop_id GROUP BY bs.stop_name ORDER BY num_visits DESC LIMIT 5; |
What is the maximum population of any marine species in the 'MarineLife' table, and what is the name of the species? | CREATE TABLE MarineLife (id INT,name VARCHAR(50),species VARCHAR(50),population INT); INSERT INTO MarineLife (id,name,species,population) VALUES (1,'Sea Dragon',1500),(2,'Blue Whale',2000),(3,'Clownfish',500),(4,'Giant Pacific Octopus',3000); | SELECT species, population FROM MarineLife WHERE population = (SELECT MAX(population) FROM MarineLife); |
What is the total quantity of locally sourced items sold? | CREATE TABLE supplier_data (supplier_id INT,location_id INT,item_id INT,quantity_sold INT,is_local BOOLEAN); INSERT INTO supplier_data (supplier_id,location_id,item_id,quantity_sold,is_local) VALUES (1,1,1,30,TRUE),(2,2,2,70,FALSE); | SELECT SUM(quantity_sold) FROM supplier_data WHERE is_local = TRUE; |
How many space missions have been cancelled before launch? | CREATE TABLE space_missions (id INT,name VARCHAR(255),status VARCHAR(255),launch_date DATE); | SELECT COUNT(*) FROM space_missions WHERE status = 'cancelled'; |
Delete the record with ID 1 from the prison table. | CREATE TABLE prison (id INT,name TEXT,security_level TEXT,age INT); INSERT INTO prison (id,name,security_level,age) VALUES (1,'John Doe','low_security',45); | DELETE FROM prison WHERE id = 1; |
Find the average value of digital assets with smart contracts having the word 'agreement' in their name? | CREATE TABLE digital_assets (asset_id INT,asset_name VARCHAR(50),value DECIMAL(10,2)); INSERT INTO digital_assets (asset_id,asset_name,value) VALUES (1,'Asset1',50.5),(2,'Asset2',100.2),(3,'Asset3',75.0); CREATE TABLE smart_contracts (contract_id INT,asset_id INT,contract_name VARCHAR(50)); INSERT INTO smart_contracts ... | SELECT AVG(digital_assets.value) FROM digital_assets INNER JOIN smart_contracts ON digital_assets.asset_id = smart_contracts.asset_id WHERE smart_contracts.contract_name LIKE '%agreement%'; |
Insert a new 'education' record into the 'education_programs' table | CREATE TABLE education_programs (id INT,name VARCHAR(50),description TEXT,target_audience VARCHAR(50),duration INT); | INSERT INTO education_programs (id, name, description, target_audience, duration) VALUES (1, 'Wildlife Warriors', 'A program to educate children about wildlife conservation.', 'Children (Ages 8-12)', 12); |
What is the total healthcare expenditure for each racial group? | CREATE TABLE HealthcareExpenditures (ExpenditureID INT,Race VARCHAR(25),Expenditure DECIMAL(10,2)); INSERT INTO HealthcareExpenditures (ExpenditureID,Race,Expenditure) VALUES (1,'Hispanic',5000),(2,'African American',6000),(3,'Asian',7000),(4,'Caucasian',8000); | SELECT Race, SUM(Expenditure) as TotalExpenditure FROM HealthcareExpenditures GROUP BY Race; |
What is the minimum energy efficiency score for commercial buildings in 'Rural' areas? | CREATE TABLE buildings_rural (id INT,building_type VARCHAR(255),area VARCHAR(255),energy_efficiency_score FLOAT); INSERT INTO buildings_rural (id,building_type,area,energy_efficiency_score) VALUES (1,'Residential','Rural',75.0),(2,'Commercial','Rural',55.0); | SELECT MIN(energy_efficiency_score) FROM buildings_rural WHERE building_type = 'Commercial' AND area = 'Rural'; |
Which countries have the most news channels in the 'news_channels' table? | CREATE TABLE news_channels (channel_name VARCHAR(50),country VARCHAR(50)); INSERT INTO news_channels (channel_name,country) VALUES ('CNN','USA'); INSERT INTO news_channels (channel_name,country) VALUES ('BBC','UK'); | SELECT country, COUNT(*) as channel_count FROM news_channels GROUP BY country ORDER BY channel_count DESC; |
Which Indian cricketers in the 'ipl_players' table were born before 1990? | CREATE TABLE ipl_players (player_id INT,player_name VARCHAR(50),country VARCHAR(50),birth_year INT); | SELECT player_name FROM ipl_players WHERE country = 'India' AND birth_year < 1990; |
What is the total quantity of products in the 'circular_supply_chain' table that are sourced from fair trade suppliers in the 'ethical_suppliers' table? | CREATE TABLE circular_supply_chain (product_id INT,source VARCHAR(255),quantity INT);CREATE TABLE ethical_suppliers (supplier_id INT,name VARCHAR(255),country VARCHAR(255),fair_trade BOOLEAN); | SELECT SUM(quantity) FROM circular_supply_chain c JOIN ethical_suppliers e ON c.source = e.name WHERE e.fair_trade = TRUE; |
What is the maximum number of public comments received for a proposed regulation? | CREATE TABLE regulations (id INT,proposal TEXT,comments INT); INSERT INTO regulations (id,proposal,comments) VALUES (1,'Regulation A',50); INSERT INTO regulations (id,proposal,comments) VALUES (2,'Regulation B',100); | SELECT MAX(comments) FROM regulations; |
What is the total number of male and female members in unions located in California? | CREATE TABLE union_membership (id INT,union_name TEXT,state TEXT,gender TEXT); INSERT INTO union_membership (id,union_name,state,gender) VALUES (1,'Union A','California','Male'),(2,'Union B','California','Female'),(3,'Union C','California','Male'); | SELECT SUM(gender = 'Male') AS total_male, SUM(gender = 'Female') AS total_female FROM union_membership WHERE state = 'California'; |
Find the total biomass of fish farmed in each country using organic methods. | CREATE TABLE FarmC (species VARCHAR(20),country VARCHAR(20),biomass FLOAT,farming_method VARCHAR(20)); INSERT INTO FarmC (species,country,biomass,farming_method) VALUES ('Salmon','Norway',30000,'Organic'); INSERT INTO FarmC (species,country,biomass,farming_method) VALUES ('Trout','Norway',15000,'Conventional'); INSERT ... | SELECT country, SUM(biomass) FROM FarmC WHERE farming_method = 'Organic' GROUP BY country; |
Identify public transportation systems that have a decrease in ridership by more than 20% since 2020 | CREATE TABLE public_transportation_2 (system_id INT,system_name VARCHAR(255),ridership INT,year INT); | SELECT system_name, ridership, year FROM public_transportation_2 WHERE year > 2020 AND ridership < 0.8 * (SELECT ridership FROM public_transportation_2 WHERE system_id = system_id AND year = 2020); |
Find the number of healthcare providers, by specialty and location. | CREATE TABLE providers (id INT,name VARCHAR,specialty VARCHAR,location VARCHAR); | SELECT p.specialty, p.location, COUNT(p.id) AS num_providers FROM providers p GROUP BY p.specialty, p.location; |
Display the number of volunteers who have donated to each program category, and the total donation amount. | CREATE TABLE DonorPrograms (DonorID INT,ProgramID INT); INSERT INTO DonorPrograms (DonorID,ProgramID) VALUES (1,101),(1,102),(2,102),(3,103),(3,104); CREATE TABLE ProgramCategories (CategoryID INT,Category TEXT); INSERT INTO ProgramCategories (CategoryID,Category) VALUES (1,'Education'),(2,'Health'),(3,'Environment'),(... | SELECT PC.Category, COUNT(DP.DonorID) AS NumVolunteers, SUM(D.Amount) AS TotalDonated FROM DonorPrograms DP INNER JOIN Donations D ON DP.DonorID = D.DonorID INNER JOIN Programs P ON DP.ProgramID = P.ProgramID INNER JOIN ProgramCategories PC ON P.CategoryID = PC.CategoryID GROUP BY PC.Category; |
What are the average construction wages by state for the year 2020? | CREATE TABLE construction_labor (state VARCHAR(2),year INT,wage DECIMAL(5,2)); INSERT INTO construction_labor VALUES ('NY',2020,35.50),('CA',2020,32.65),('TX',2020,28.34); | SELECT state, AVG(wage) FROM construction_labor WHERE year = 2020 GROUP BY state; |
Which community development initiatives were completed in 2020 and had a budget over $100,000? | CREATE TABLE initiatives (id INT,name VARCHAR(50),year INT,budget INT); INSERT INTO initiatives (id,name,year,budget) VALUES (1,'Clean Water',2020,120000),(2,'Green Spaces',2019,80000); | SELECT name FROM initiatives WHERE year = 2020 AND budget > 100000; |
Find the mining sites that have used a specific type of equipment more than any other site. | CREATE TABLE mining_sites (id INT,name VARCHAR(50)); CREATE TABLE equipment_usage (site_id INT,equipment_type VARCHAR(20),usage_count INT); INSERT INTO mining_sites (id,name) VALUES (1,'Site A'),(2,'Site B'),(3,'Site C'),(4,'Site D'); INSERT INTO equipment_usage (site_id,equipment_type,usage_count) VALUES (1,'Drill',10... | SELECT ms.name, eu.equipment_type, eu.usage_count FROM mining_sites ms INNER JOIN equipment_usage eu ON ms.id = eu.site_id WHERE eu.usage_count = (SELECT MAX(usage_count) FROM equipment_usage); |
What is the total funding spent by organizations based in France? | CREATE TABLE organizations (id INT,name VARCHAR(255),type VARCHAR(255),country VARCHAR(255),budget DECIMAL(10,2)); INSERT INTO organizations (id,name,type,country,budget) VALUES (1,'Eco-France','NGO','France',2000000.00); | SELECT SUM(budget) as total_funding FROM organizations WHERE country = 'France'; |
List the number of unique clients represented by each attorney in the 'Chicago' office. | CREATE TABLE attorneys (attorney_id INT,attorney_name VARCHAR(20),office_id INT); INSERT INTO attorneys (attorney_id,attorney_name,office_id) VALUES (101,'Smith',1),(102,'Johnson',1),(103,'Williams',2); CREATE TABLE cases (case_id INT,client_id INT,attorney_id INT,office_id INT); INSERT INTO cases (case_id,client_id,at... | SELECT a.attorney_name, COUNT(DISTINCT c.client_id) FROM attorneys a JOIN cases c ON a.attorney_id = c.attorney_id JOIN offices o ON a.office_id = o.office_id WHERE o.office_name = 'Chicago' GROUP BY a.attorney_name; |
What is the distribution of VR hardware products by price range, considering price ranges as: 0-500, 500-1000, and >1000, and their respective counts, ranked by count? | CREATE TABLE VRHardware (HardwareID INT,HardwareName VARCHAR(50),Manufacturer VARCHAR(20),ReleaseDate DATE,Price NUMERIC(10,2)); INSERT INTO VRHardware (HardwareID,HardwareName,Manufacturer,ReleaseDate,Price) VALUES (1,'Oculus Rift','Oculus','2016-03-28',599); INSERT INTO VRHardware (HardwareID,HardwareName,Manufacture... | SELECT CASE WHEN Price <= 500 THEN '0-500' WHEN Price <= 1000 THEN '500-1000' ELSE '>1000' END as PriceRange, COUNT(*) as ProductsInRange, ROW_NUMBER() OVER (ORDER BY COUNT(*) DESC) as Rank FROM VRHardware GROUP BY PriceRange; |
Insert a new community policing event in the city of Seattle, category 'Youth Outreach' on May 15th, 2023. | CREATE TABLE seattle_community_policing (id INT,event_name VARCHAR(255),event_date TIMESTAMP,event_category VARCHAR(255)); | INSERT INTO seattle_community_policing (id, event_name, event_date, event_category) VALUES (1, 'Youth Outreach Event', '2023-05-15 10:00:00', 'Youth Outreach'); |
Which rare earth elements were produced in higher volumes in 2022 compared to 2021? | CREATE TABLE production (year INT,element TEXT,volume INT); INSERT INTO production (year,element,volume) VALUES (2021,'neodymium',15000),(2022,'neodymium',18000),(2021,'dysprosium',8000),(2022,'dysprosium',10000); CREATE TABLE elements (element TEXT); INSERT INTO elements (element) VALUES ('neodymium'),('dysprosium'); | SELECT e.element, p2.volume - p1.volume AS volume_difference FROM elements e JOIN production p1 ON e.element = p1.element AND p1.year = 2021 JOIN production p2 ON e.element = p2.element AND p2.year = 2022 WHERE p2.volume > p1.volume; |
Find the smart city technology adoption project with the highest adoption rate | CREATE TABLE smart_city_projects (id INT,name VARCHAR(50),location VARCHAR(50),adoption_rate FLOAT); | SELECT * FROM smart_city_projects WHERE adoption_rate = (SELECT MAX(adoption_rate) FROM smart_city_projects); |
What is the ZIP code of the community health worker who conducted the least mental health parity consultations in Ohio? | CREATE TABLE community_health_workers (id INT,name TEXT,zip TEXT,consultations INT); INSERT INTO community_health_workers (id,name,zip,consultations) VALUES (1,'John Doe','43001',25),(2,'Jane Smith','44101',15); CREATE VIEW oh_workers AS SELECT * FROM community_health_workers WHERE zip BETWEEN '43001' AND '45999'; | SELECT zip FROM oh_workers WHERE consultations = (SELECT MIN(consultations) FROM oh_workers); |
How many autonomous buses were sold in the 'Asia-Pacific' region in the sales_data table for the year 2022? | CREATE TABLE sales_data (id INT,region TEXT,sales_channel TEXT,vehicle_type TEXT,fuel_type TEXT,year INT,quantity_sold INT); INSERT INTO sales_data (id,region,sales_channel,vehicle_type,fuel_type,year,quantity_sold) VALUES (1,'Asia-Pacific','Online','Bus','Autonomous',2022,150),(2,'Europe','Dealership','SUV','Gasoline'... | SELECT region, fuel_type, SUM(quantity_sold) as total_autonomous_buses_sold FROM sales_data WHERE region = 'Asia-Pacific' AND vehicle_type = 'Bus' AND fuel_type = 'Autonomous' AND year = 2022 GROUP BY region, fuel_type; |
Show the moving average of streams for the last 6 months for each artist. | CREATE TABLE songs (id INT,title TEXT,release_date DATE,genre TEXT,artist_id INT,streams INT); INSERT INTO songs (id,title,release_date,genre,artist_id,streams) VALUES (1,'Song1','2022-01-01','Hip-Hop',1,100000); INSERT INTO songs (id,title,release_date,genre,artist_id,streams) VALUES (2,'Song2','2022-01-02','Jazz',2,1... | SELECT artist_id, AVG(streams) OVER (PARTITION BY artist_id ORDER BY release_date ROWS BETWEEN 5 PRECEDING AND CURRENT ROW) AS moving_avg FROM songs WHERE release_date >= DATEADD(MONTH, -6, CURRENT_DATE); |
What is the distribution of patients by ethnicity and mental health condition? | CREATE TABLE Patients (PatientID INT,Age INT,Gender VARCHAR(10),Ethnicity VARCHAR(50),ConditionID INT); CREATE TABLE MentalHealthConditions (ConditionID INT,Condition VARCHAR(50)); | SELECT MentalHealthConditions.Condition, Patients.Ethnicity, COUNT(Patients.PatientID) FROM Patients INNER JOIN MentalHealthConditions ON Patients.ConditionID = MentalHealthConditions.ConditionID GROUP BY MentalHealthConditions.Condition, Patients.Ethnicity; |
Which customers have not placed an order in the last 6 months? | CREATE TABLE customers (customer_id INT,customer_name VARCHAR(255)); CREATE TABLE orders (order_id INT,customer_id INT,order_date DATE); INSERT INTO customers (customer_id,customer_name) VALUES (1,'John Doe'),(2,'Jane Smith'); INSERT INTO orders (order_id,customer_id,order_date) VALUES (1,1,'2022-01-01'),(2,1,'2022-02-... | SELECT c.customer_name FROM customers c LEFT JOIN orders o ON c.customer_id = o.customer_id WHERE o.order_date < DATE_SUB(CURDATE(), INTERVAL 6 MONTH) IS NULL; |
What is the median income of offenders in the justice system in California in 2021? | CREATE TABLE offenders (id INT,state TEXT,annual_income FLOAT,year INT); INSERT INTO offenders (id,state,annual_income,year) VALUES (1,'California',30000,2021),(2,'California',45000,2021),(3,'Texas',25000,2021),(4,'California',60000,2021); | SELECT AVG(annual_income) as median_income FROM (SELECT annual_income FROM offenders WHERE state = 'California' AND year = 2021 ORDER BY annual_income LIMIT 2 OFFSET 1) as subquery; |
What is the total number of health equity metric violations by type and region? | CREATE TABLE HealthEquityMetrics (ViolationID INT,ViolationType VARCHAR(255),Region VARCHAR(255),ViolationDate DATE); INSERT INTO HealthEquityMetrics (ViolationID,ViolationType,Region,ViolationDate) VALUES (1,'Language Access','Northeast','2021-02-14'),(2,'Racial Disparities','Southeast','2021-05-03'),(3,'Gender Identi... | SELECT ViolationType, Region, COUNT(*) as ViolationCount FROM HealthEquityMetrics GROUP BY ViolationType, Region; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.