instruction stringlengths 0 1.06k | input stringlengths 11 5.3k | response stringlengths 2 4.44k |
|---|---|---|
Who are the community health workers who have not completed any training? | CREATE TABLE CommunityHealthWorkers (CHW_ID INT,Name VARCHAR(50),Job_Title VARCHAR(50),Training_Completion_Date DATE); INSERT INTO CommunityHealthWorkers (CHW_ID,Name,Job_Title,Training_Completion_Date) VALUES (1,'Alex','Community Health Worker',NULL); INSERT INTO CommunityHealthWorkers (CHW_ID,Name,Job_Title,Training_... | SELECT Name, Job_Title FROM CommunityHealthWorkers WHERE Training_Completion_Date IS NULL; |
What is the distribution of grants by funding source category? | CREATE SCHEMA if not exists arts_culture;CREATE TABLE if not exists arts_culture.funding_sources (funding_source_id INT PRIMARY KEY,name VARCHAR(255),category VARCHAR(255));INSERT INTO arts_culture.funding_sources (funding_source_id,name,category) VALUES (1,'National Endowment for the Arts','Federal Agency'),(2,'Andy W... | SELECT category, COUNT(*) as grant_count FROM arts_culture.funding_sources GROUP BY category; |
Find the minimum temperature for all crops | CREATE TABLE crop (id INT,type VARCHAR(255),temperature FLOAT); INSERT INTO crop (id,type,temperature) VALUES (1,'corn',22.5),(2,'soybean',20.0),(3,'cotton',24.3),(4,'corn',18.5),(5,'soybean',19.5); | SELECT MIN(temperature) FROM crop; |
Get the number of employees hired in each month of the year from the 'hiring' table | CREATE TABLE hiring (id INT,employee_name VARCHAR(50),position VARCHAR(50),date_hired DATE); | SELECT MONTH(date_hired) AS month, COUNT(*) FROM hiring GROUP BY MONTH(date_hired); |
What is the total number of education programs conducted? | CREATE TABLE education_programs (region TEXT,program_count INTEGER); INSERT INTO education_programs (region,program_count) VALUES ('North',15),('South',20),('East',10),('West',25); | SELECT SUM(program_count) FROM education_programs; |
What is the average water requirement for crops grown in India? | CREATE TABLE irrigation (id INT,farm_id INT,irrigation_amount INT); INSERT INTO irrigation (id,farm_id,irrigation_amount) VALUES (1,1,1000),(2,2,1500); | SELECT AVG(crops.water_requirement) FROM crops JOIN (SELECT farm_id FROM farms WHERE country = 'India') as subquery ON crops.id = subquery.farm_id JOIN irrigation ON crops.id = irrigation.farm_id; |
How many public parks were built in the South region between Q1 and Q2 of 2019? | CREATE TABLE Parks (quarter INT,region VARCHAR(255),count INT); INSERT INTO Parks (quarter,region,count) VALUES (1,'South',50),(1,'South',55),(2,'South',60),(2,'South',65); | SELECT SUM(count) FROM Parks WHERE (quarter = 1 OR quarter = 2) AND region = 'South'; |
What is the total waste generated by factories in Asia? | CREATE TABLE factories (id INT,name VARCHAR(50),location VARCHAR(50),production_count INT); INSERT INTO factories (id,name,location,production_count) VALUES (1,'Factory A','Asia',1500),(2,'Factory B','Europe',1200),(3,'Factory C','Asia',1800); CREATE TABLE waste (factory_id INT,date DATE,waste_quantity INT); INSERT INT... | SELECT f.location, SUM(w.waste_quantity) FROM waste w JOIN factories f ON w.factory_id = f.id WHERE f.location = 'Asia' GROUP BY f.location; |
Who is the creator of 'The Starry Night'? | CREATE TABLE Artworks (artwork VARCHAR(50),artist VARCHAR(50)); INSERT INTO Artworks (artwork,artist) VALUES ('Guernica','Picasso'),('The Starry Night','Van Gogh'); | SELECT artist FROM Artworks WHERE artwork = 'The Starry Night'; |
What is the number of military personnel in each branch of the US Armed Forces? | CREATE TABLE military_personnel (id INT,name VARCHAR(255),branch VARCHAR(255),personnel_count INT); INSERT INTO military_personnel (id,name,branch,personnel_count) VALUES (1,'Fort Bragg','Army',53300),(2,'Naval Base San Diego','Navy',36000); | SELECT mp.branch, COUNT(*) as total_personnel FROM military_personnel AS mp GROUP BY mp.branch; |
What is the minimum pollution level in the Mediterranean Sea? | CREATE TABLE pollution_levels (id INT,location TEXT,pollution_level FLOAT); INSERT INTO pollution_levels (id,location,pollution_level) VALUES (1,'Mediterranean Sea',5.0),(2,'Baltic Sea',3.0); | SELECT MIN(pollution_level) FROM pollution_levels WHERE location = 'Mediterranean Sea'; |
What is the total production of well 'W001' in the year 2020? | CREATE TABLE wells (well_id varchar(10),production int); INSERT INTO wells (well_id,production) VALUES ('W001',1500),('W002',1200); | SELECT SUM(production) FROM wells WHERE well_id = 'W001' AND YEAR(datetime) = 2020; |
Determine the number of satellites launched per year and their status. | CREATE TABLE Satellites (SatelliteID INT,Name VARCHAR(50),Manufacturer VARCHAR(50),LaunchDate DATE,Orbit VARCHAR(50),Status VARCHAR(50)); INSERT INTO Satellites (SatelliteID,Name,Manufacturer,LaunchDate,Orbit,Status) VALUES (18,'GPS V','Lockheed Martin','2013-04-29','GEO','Active'),(19,'GPS VI','Raytheon','2017-06-16',... | SELECT YEAR(LaunchDate) AS LaunchYear, Status, COUNT(*) AS CountOfSatellites FROM Satellites GROUP BY YEAR(LaunchDate), Status; |
How many smart contracts were deployed in each country during the past year? | CREATE TABLE smart_contracts (contract_name TEXT,deployment_country TEXT,deployment_date DATE); | SELECT deployment_country, COUNT(contract_name) FROM smart_contracts WHERE deployment_date >= DATEADD(year, -1, GETDATE()) GROUP BY deployment_country; |
What is the number of hospitals in 'rural_healthcare' schema? | CREATE SCHEMA if not exists rural_healthcare; use rural_healthcare; CREATE TABLE hospitals (id int,name varchar(255),location varchar(255)); | SELECT COUNT(*) FROM hospitals; |
How many exhibitions were there in Paris between 1950 and 1970, including those that started before 1950 and ended after 1970? | CREATE TABLE Exhibitions (ExhibitionID INT,Name VARCHAR(100),City VARCHAR(100),StartDate DATE,EndDate DATE); INSERT INTO Exhibitions (ExhibitionID,Name,City,StartDate,EndDate) VALUES (1,'Paris Art Exhibition','Paris','1949-05-01','1950-09-30'),(2,'Modern Art in Paris','Paris','1968-03-01','1971-01-10'),(3,'Paris Art De... | SELECT COUNT(*) FROM Exhibitions WHERE City = 'Paris' AND StartDate <= '1970-12-31' AND EndDate >= '1950-01-01'; |
Identify mobile subscribers with consecutive data usage greater than 4GB for the last 3 months, in ascending order of subscription IDs. | CREATE TABLE mobile_usage (subscriber_id INT,usage FLOAT,month INT); INSERT INTO mobile_usage (subscriber_id,usage,month) VALUES (1,4.1,1),(1,4.5,2),(1,5.0,3),(2,3.0,1),(2,3.3,2),(2,3.6,3); | SELECT subscriber_id, usage, month FROM (SELECT subscriber_id, usage, month, LAG(usage, 1) OVER (PARTITION BY subscriber_id ORDER BY month) as prev_usage FROM mobile_usage) t WHERE t.usage > 4.0 AND (t.prev_usage IS NULL OR t.prev_usage <= 4.0) ORDER BY subscriber_id; |
What is the total number of crimes committed in each city in the last 12 months? | CREATE TABLE cities (id INT,name TEXT);CREATE TABLE crimes (id INT,city_id INT,date DATE); | SELECT c.name, COUNT(cr.id) FROM cities c JOIN crimes cr ON c.id = cr.city_id WHERE cr.date >= DATEADD(year, -1, GETDATE()) GROUP BY c.id; |
Find the number of wells drilled in Texas and Louisiana in 2020 | CREATE TABLE wells (id INT,state VARCHAR(20),date DATE); INSERT INTO wells (id,state,date) VALUES (1,'Texas','2020-01-01'); INSERT INTO wells (id,state,date) VALUES (2,'Texas','2020-02-01'); INSERT INTO wells (id,state,date) VALUES (3,'Louisiana','2020-03-01'); | SELECT COUNT(*) FROM wells WHERE state IN ('Texas', 'Louisiana') AND YEAR(date) = 2020; |
What is the maximum number of voyages of vessels with 'HMM' prefix that carried dangerous goods in the Southern Ocean in 2017? | CREATE TABLE Vessels (ID INT,Name TEXT,Voyages INT,Dangerous_Goods BOOLEAN,Prefix TEXT,Year INT);CREATE VIEW Southern_Ocean_Vessels AS SELECT * FROM Vessels WHERE Region = 'Southern Ocean'; | SELECT MAX(Voyages) FROM Southern_Ocean_Vessels WHERE Prefix = 'HMM' AND Dangerous_Goods = 1 AND Year = 2017; |
Which building materials were used in ProjectId 2 with a quantity greater than 350? | CREATE TABLE BuildingMaterials (Id INT,ProjectId INT,Material VARCHAR(50),Quantity INT,Cost DECIMAL(10,2)); INSERT INTO BuildingMaterials (Id,ProjectId,Material,Quantity,Cost) VALUES (1,1,'Concrete',500,4500.00); INSERT INTO BuildingMaterials (Id,ProjectId,Material,Quantity,Cost) VALUES (2,2,'Steel',300,7000.00); | SELECT * FROM BuildingMaterials WHERE ProjectId = 2 AND Quantity > 350; |
What is the minimum sleep duration for each user in the last week? | CREATE TABLE sleep (id INT,user_id INT,sleep_duration INT,sleep_date DATE); INSERT INTO sleep (id,user_id,sleep_duration,sleep_date) VALUES (1,1,7,'2022-02-01'),(2,2,6,'2022-02-05'); | SELECT user_id, MIN(sleep_duration) FROM sleep WHERE sleep_date BETWEEN DATE_SUB(CURRENT_DATE(), INTERVAL 1 WEEK) AND CURRENT_DATE() GROUP BY user_id; |
What is the maximum age of patients diagnosed with anxiety in the 'mental_health' schema? | CREATE TABLE patients (patient_id INT,diagnosis VARCHAR(255),age INT); INSERT INTO patients (patient_id,diagnosis,age) VALUES (1,'depression',35),(2,'anxiety',28),(3,'depression',42),(4,'anxiety',50),(5,'anxiety',38); | SELECT MAX(age) FROM mental_health.patients WHERE diagnosis = 'anxiety'; |
Which restaurants in the 'independent_restaurants' schema have a food safety violation? | CREATE TABLE independent_restaurants.inspections (restaurant_id INT,name TEXT,food_safety_violation BOOLEAN); INSERT INTO independent_restaurants.inspections (restaurant_id,name,food_safety_violation) VALUES (1,'Fancy Eats',true),(2,'Home Cooking',false); | SELECT * FROM independent_restaurants.inspections WHERE food_safety_violation = true; |
How many cases did each attorney win in California? | CREATE TABLE attorneys (id INT,name TEXT,state TEXT); INSERT INTO attorneys (id,name,state) VALUES (1,'Barry Zuckerkorn','California'); CREATE TABLE cases (id INT,attorney_id INT,result TEXT,state TEXT); INSERT INTO cases (id,attorney_id,result,state) VALUES (1,1,'won','California'); | SELECT attorneys.name, COUNT(cases.id) FROM attorneys INNER JOIN cases ON attorneys.id = cases.attorney_id WHERE attorneys.state = 'California' AND cases.result = 'won' GROUP BY attorneys.name; |
List the names and budgets of all rural infrastructure projects in the 'rural_infrastructure' table that are located in 'Asia'. | CREATE TABLE rural_infrastructure (id INT,project_name VARCHAR(255),budget INT,location VARCHAR(255)); | SELECT project_name, budget FROM rural_infrastructure WHERE location = 'Asia'; |
What is the average budget for Indian movies released after 2015, grouped by genre? | CREATE TABLE movie (id INT,title VARCHAR(100),release_year INT,country VARCHAR(50),genre VARCHAR(50),budget INT); INSERT INTO movie (id,title,release_year,country,genre,budget) VALUES (1,'Movie1',2016,'India','Action',10000000); INSERT INTO movie (id,title,release_year,country,genre,budget) VALUES (2,'Movie2',2018,'Ind... | SELECT genre, AVG(budget) FROM movie WHERE country = 'India' AND release_year > 2015 GROUP BY genre; |
What is the total value of military equipment sales to South Korea and Japan? | CREATE TABLE Military_Equipment_Sales(id INT,country VARCHAR(50),equipment_type VARCHAR(50),sale_value FLOAT); INSERT INTO Military_Equipment_Sales(id,country,equipment_type,sale_value) VALUES (1,'South Korea','Aircraft',30000000),(2,'Japan','Vehicles',20000000); | SELECT SUM(sale_value) FROM Military_Equipment_Sales WHERE country IN ('South Korea', 'Japan'); |
What is the approval status of a specific drug in clinical trials? | CREATE TABLE clinical_trials (drug_name TEXT,trial_status TEXT); INSERT INTO clinical_trials (drug_name,trial_status) VALUES ('DrugA','Approved'),('DrugB','Denied'),('DrugC','Pending'); | SELECT trial_status FROM clinical_trials WHERE drug_name = 'DrugA'; |
What is the average distance traveled per day by autonomous trains in Berlin? | CREATE TABLE autonomous_trains (train_id INT,trip_id INT,trip_start_time TIMESTAMP,trip_end_time TIMESTAMP,start_latitude DECIMAL(9,6),start_longitude DECIMAL(9,6),end_latitude DECIMAL(9,6),end_longitude DECIMAL(9,6),distance DECIMAL(10,2),trip_date DATE); | SELECT AVG(distance/100) FROM autonomous_trains WHERE start_longitude BETWEEN 13.1 AND 13.8 AND start_latitude BETWEEN 52.3 AND 52.7 GROUP BY DATE(trip_date); |
What is the total number of articles published per month? | CREATE TABLE articles (id INT,publication_date DATE,topic TEXT); INSERT INTO articles VALUES (1,'2022-01-01','Media Literacy'),(2,'2022-01-15','Content Diversity'),(3,'2022-02-01','Media Representation'),(4,'2022-02-15','Disinformation Detection'),(5,'2022-03-01','Media Literacy'),(6,'2022-03-15','Content Diversity'); | SELECT EXTRACT(MONTH FROM publication_date) as month, COUNT(*) as article_count FROM articles GROUP BY month; |
What is the minimum number of students enrolled in a course in each department? | CREATE TABLE departments (dept_id INT,dept_name TEXT); CREATE TABLE courses (course_id INT,course_name TEXT,dept_id INT,num_students INT); INSERT INTO departments (dept_id,dept_name) VALUES (1,'Computer Science'),(2,'Mathematics'),(3,'English'); INSERT INTO courses (course_id,course_name,dept_id,num_students) VALUES (1... | SELECT dept_name, MIN(num_students) as min_enrollment FROM departments JOIN courses ON departments.dept_id = courses.dept_id GROUP BY dept_name; |
What is the average transaction value, in EUR, for each customer in the "debit_card" table, grouped by their country, for transactions that occurred in the month of May 2023? | CREATE TABLE customer (customer_id INT,name VARCHAR(50),country VARCHAR(50)); CREATE TABLE debit_card (transaction_id INT,customer_id INT,value DECIMAL(10,2),timestamp TIMESTAMP,currency VARCHAR(3)); CREATE TABLE foreign_exchange (date DATE,currency VARCHAR(3),rate DECIMAL(10,4)); | SELECT c.country, AVG(dc.value * fx.rate) as avg_value FROM customer c JOIN debit_card dc ON c.customer_id = dc.customer_id LEFT JOIN foreign_exchange fx ON dc.currency = fx.currency AND DATE_FORMAT(dc.timestamp, '%Y-%m') = '2023-05' GROUP BY c.country; |
Identify unique fish farmers in the Mediterranean with sustainable practices | CREATE TABLE farmers (id INT,name VARCHAR(50),region VARCHAR(50),sustainability_rating INT); | SELECT DISTINCT name FROM farmers WHERE region = 'Mediterranean' AND sustainability_rating = 5; |
What is the minimum safety rating of vehicles in the Safety_Testing table? | CREATE TABLE Safety_Testing (Vehicle_ID INT,Manufacturer VARCHAR(30),Model VARCHAR(20),Safety_Rating FLOAT); | SELECT MIN(Safety_Rating) FROM Safety_Testing; |
How many species of marine life are present in the Arctic Ocean? | CREATE TABLE marine_life (species_name TEXT,location TEXT); INSERT INTO marine_life (species_name,location) VALUES ('Narwhal','Arctic Ocean'),('Beluga','Arctic Ocean'),('Walrus','Arctic Ocean'),('Bearded Seal','Arctic Ocean'),('Ringed Seal','Arctic Ocean'); | SELECT COUNT(DISTINCT species_name) FROM marine_life WHERE location = 'Arctic Ocean'; |
Insert the following suppliers into the suppliers table: (1, 'Acme Quinoa Inc.', 'Colorado, USA', 4.2), (2, 'Boulder Salt Co.', 'Utah, USA', 4.5), (3, 'Green Olive Oil Ltd.', 'Italy', 4.8) | CREATE TABLE suppliers (id INT PRIMARY KEY,name TEXT,location TEXT,sustainability_rating REAL); | INSERT INTO suppliers (id, name, location, sustainability_rating) VALUES (1, 'Acme Quinoa Inc.', 'Colorado, USA', 4.2), (2, 'Boulder Salt Co.', 'Utah, USA', 4.5), (3, 'Green Olive Oil Ltd.', 'Italy', 4.8); |
What is the minimum depth of wells drilled in the Gulf of Mexico? | CREATE TABLE wells (id INT,location VARCHAR(20),depth FLOAT); INSERT INTO wells (id,location,depth) VALUES (1,'Gulf of Mexico',2500.3); INSERT INTO wells (id,location,depth) VALUES (2,'Gulf of Mexico',1800.5); INSERT INTO wells (id,location,depth) VALUES (3,'Arctic',4000.0); | SELECT MIN(depth) FROM wells WHERE location = 'Gulf of Mexico'; |
List the total installed capacity for each country in the projects and project_capacity tables, excluding South America. | CREATE TABLE projects(id INT,project_name VARCHAR(50),project_type VARCHAR(50),country VARCHAR(50));CREATE TABLE project_capacity(project_id INT,capacity_mw FLOAT); | SELECT p.country, SUM(pc.capacity_mw) AS total_capacity FROM projects p INNER JOIN project_capacity pc ON p.id = pc.project_id WHERE p.country NOT LIKE 'SA%' GROUP BY p.country; |
Insert a new record into the "tourism_trends" table with the following information: trend_id = 201, trend_name = 'Virtual Reality Tours', popularity_score = 9.2 | CREATE TABLE tourism_trends (trend_id INT,trend_name VARCHAR(50),popularity_score DECIMAL(3,1),PRIMARY KEY (trend_id)); | INSERT INTO tourism_trends (trend_id, trend_name, popularity_score) VALUES (201, 'Virtual Reality Tours', 9.2); |
Count the number of excavation sites in each country, sorted by the count in descending order. | CREATE TABLE excavations (id INT,country VARCHAR(255)); INSERT INTO excavations (id,country) VALUES (1,'Mexico'),(2,'USA'),(3,'Canada'); | SELECT country, COUNT(*) AS excavation_count FROM excavations GROUP BY country ORDER BY excavation_count DESC; |
What is the minimum carbon offset amount for carbon offset programs in the 'Transportation' sector? | 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,40000),(2,'Energy Production',2019,75000),(3,'Transportation',2020,45000),(4,'Manufacturing',2021,80000),(5,'Transpo... | SELECT MIN(carbon_offset_amount) FROM Carbon_Offset_Programs WHERE sector = 'Transportation'; |
What is the total number of hours spent on open pedagogy projects by students in each city? | CREATE TABLE projects (id INT,city TEXT,hours INT,open_pedagogy BOOLEAN); | SELECT city, SUM(hours) FROM projects WHERE open_pedagogy = TRUE GROUP BY city; |
How many energy storage projects are there in Indonesia, Malaysia, and Thailand? | CREATE TABLE energy_storage (country VARCHAR(50),num_projects INT); INSERT INTO energy_storage (country,num_projects) VALUES ('Indonesia',10),('Malaysia',15),('Thailand',20); | SELECT country, num_projects FROM energy_storage WHERE country IN ('Indonesia', 'Malaysia', 'Thailand'); |
What is the total production volume of Samarium in Canada and the USA combined? | CREATE TABLE Samarium_Production (id INT,year INT,country VARCHAR(20),production_volume INT); | SELECT SUM(production_volume) FROM Samarium_Production WHERE country IN ('Canada', 'USA'); |
Insert a new patient 'Oliver' with age 40 and diagnosis 'hypertension' into 'RuralHealthFacility9' table. | CREATE TABLE RuralHealthFacility9 (patient_id INT,patient_name VARCHAR(50),age INT,diagnosis VARCHAR(20)); | INSERT INTO RuralHealthFacility9 (patient_id, patient_name, age, diagnosis) VALUES (21, 'Oliver', 40, 'hypertension'); |
Calculate the moving average of 'Recycled Polyester' production (in kg) over the past 3 months. | CREATE TABLE Production (fabric_type VARCHAR(20),date DATE,quantity INT); INSERT INTO Production (fabric_type,date,quantity) VALUES ('Recycled Polyester','2021-09-01',1200),('Recycled Polyester','2021-10-01',1300),('Recycled Polyester','2021-11-01',1400),('Recycled Polyester','2021-12-01',1500),('Recycled Polyester','2... | SELECT fabric_type, AVG(quantity) OVER (PARTITION BY fabric_type ORDER BY date ROWS BETWEEN 2 PRECEDING AND CURRENT ROW) as moving_avg, date FROM Production WHERE fabric_type = 'Recycled Polyester'; |
What is the average cost of drugs approved in 2020? | CREATE TABLE drug_approval (id INT,drug_name VARCHAR(255),approval_year INT,cost DECIMAL(10,2)); INSERT INTO drug_approval (id,drug_name,approval_year,cost) VALUES (1,'DrugA',2018,1200.00),(2,'DrugB',2019,1500.00),(3,'DrugC',2020,2000.00),(4,'DrugD',2021,2500.00); | SELECT AVG(cost) FROM drug_approval WHERE approval_year = 2020; |
What are the CO2 emissions for site 1 on January 3rd, 2021? | CREATE TABLE environmental_impact (site_id INT,date DATE,co2_emissions FLOAT,water_consumption FLOAT); INSERT INTO environmental_impact (site_id,date,co2_emissions,water_consumption) VALUES (1,'2021-01-01',150.5,20000),(1,'2021-01-02',160.3,21000),(1,'2021-01-03',158.7,20500); | SELECT date, co2_emissions FROM environmental_impact WHERE site_id = 1 AND date = '2021-01-03'; |
What is the minimum energy efficiency improvement in the Chinese industrial sector? | CREATE TABLE energy_efficiency_china (id INT,sector VARCHAR(50),year INT,improvement FLOAT); | SELECT MIN(improvement) FROM energy_efficiency_china WHERE sector = 'industrial'; |
Who are the astronauts that have not been on any mission for 'SpacePioneers'? | CREATE TABLE Astronauts (id INT,name VARCHAR(50),organization VARCHAR(50)); CREATE TABLE Missions (id INT,astronaut_id INT,company VARCHAR(50),mission_type VARCHAR(50)); INSERT INTO Astronauts (id,name,organization) VALUES (1,'Alice','SpacePioneers'),(2,'Bob','SpacePioneers'),(3,'Charlie','SpacePioneers'); INSERT INTO ... | SELECT a.name FROM Astronauts a LEFT JOIN Missions m ON a.id = m.astronaut_id AND a.organization = m.company WHERE m.id IS NULL AND a.organization = 'SpacePioneers'; |
What are the details of policies with premiums between 500 and 2000? | CREATE TABLE Policies (PolicyID TEXT,PolicyHolder TEXT,Premium INT); INSERT INTO Policies (PolicyID,PolicyHolder,Premium) VALUES ('P123','John Doe',1000); INSERT INTO Policies (PolicyID,PolicyHolder,Premium) VALUES ('Y456','Jane Smith',2000); | SELECT * FROM Policies WHERE Premium BETWEEN 500 AND 2000; |
Find underrepresented communities with cultural competency scores above 80 in NJ. | CREATE TABLE healthcare_providers (provider_id INT,name TEXT,state TEXT); INSERT INTO healthcare_providers (provider_id,name,state) VALUES (1,'Ms. Sofia Patel','NJ'); CREATE TABLE cultural_competency (provider_id INT,score INT,community TEXT); | SELECT c.community, AVG(c.score) AS avg_score FROM cultural_competency c INNER JOIN healthcare_providers h ON c.provider_id = h.provider_id WHERE h.state = 'NJ' AND c.community IN ('Underrepresented') GROUP BY c.community HAVING avg_score > 80; |
Which water treatment plants in California have a capacity over 100 million gallons per day? | CREATE TABLE Water_treatment_plants (Name VARCHAR(255),Capacity_gallons_per_day INT,State VARCHAR(255)); INSERT INTO Water_treatment_plants (Name,Capacity_gallons_per_day,State) VALUES ('Los Angeles Water Reclamation Plant',200,'California'); | SELECT Name FROM Water_treatment_plants WHERE Capacity_gallons_per_day > 100 AND State = 'California'; |
List all regions and the number of support staff working in each | CREATE TABLE Staff (StaffID INT,Region VARCHAR(50)); INSERT INTO Staff (StaffID,Region) VALUES (1,'Northeast'),(2,'Southeast'),(3,'Midwest'),(4,'West'),(5,'Northeast'),(6,'Southeast'),(7,'Midwest'),(8,'West'),(9,'Northeast'),(10,'Southeast'),(11,'Midwest'),(12,'West'); CREATE TABLE SupportStaff (StaffID INT,AccomID INT... | SELECT Region, COUNT(DISTINCT StaffID) as NumSupportStaff FROM Staff JOIN SupportStaff ON Staff.StaffID = SupportStaff.StaffID GROUP BY Region; |
List all chemical compounds and their corresponding environmental impact scores for production sites in Texas, USA. | CREATE TABLE chemical_compounds(id INT,compound_name TEXT,environmental_impact_score INT); CREATE TABLE production_sites(id INT,site_name TEXT,location TEXT); INSERT INTO chemical_compounds (id,compound_name,environmental_impact_score) VALUES (1,'Compound X',60),(2,'Compound Y',70); INSERT INTO production_sites (id,sit... | SELECT chemical_compounds.compound_name, chemical_compounds.environmental_impact_score FROM chemical_compounds INNER JOIN production_sites ON chemical_compounds.id = production_sites.id WHERE production_sites.location = 'Texas, USA'; |
Delete the row with ID 3 from the 'esports_events' table | CREATE TABLE esports_events (id INT,name VARCHAR(255),date DATE); | DELETE FROM esports_events WHERE id = 3; |
What is the total number of employees in the Department of Justice as of January 1, 2022? | CREATE TABLE employees(employee_id INT,department VARCHAR(255),employment_date DATE); INSERT INTO employees(employee_id,department,employment_date) VALUES (1,'Department of Justice','2022-01-01'); | SELECT COUNT(*) FROM employees WHERE department = 'Department of Justice' AND EXTRACT(YEAR FROM employment_date) = 2022 AND EXTRACT(MONTH FROM employment_date) = 1; |
What is the total number of artworks in the database? | CREATE TABLE Artworks(id INT,title VARCHAR(255)); INSERT INTO Artworks(id,title) VALUES (1,'Impression,Sunrise'); INSERT INTO Artworks(id,title) VALUES (2,'Ballet Rehearsal'); INSERT INTO Artworks(id,title) VALUES (3,'The Card Players'); INSERT INTO Artworks(id,title) VALUES (4,'Starry Night'); INSERT INTO Artworks(id,... | SELECT COUNT(*) FROM Artworks; |
What is the average commission percentage of OTA partners based in 'Europe'? | CREATE TABLE ota_partners (id INT,partner_name TEXT,region TEXT,commission_percentage FLOAT); INSERT INTO ota_partners (id,partner_name,region,commission_percentage) VALUES (1,'Expedia','Europe',0.15),(2,'Booking.com','Europe',0.18),(3,'Agoda','Asia',0.12); | SELECT AVG(commission_percentage) FROM ota_partners WHERE region = 'Europe'; |
What's the total cost of fertilizers sold in 2022 in the Southern region? | CREATE TABLE FertilizerSales (id INT PRIMARY KEY,year INT,region VARCHAR(20),cost FLOAT); | SELECT SUM(cost) FROM FertilizerSales WHERE year = 2022 AND region = 'Southern'; |
Create a table named 'trend_forecasts' for storing fashion trend forecasts | CREATE TABLE trend_forecasts (id INT PRIMARY KEY,trend VARCHAR(100),popularity_score INT); | CREATE TABLE trend_forecasts (id INT PRIMARY KEY, trend VARCHAR(100), popularity_score INT); |
What is the average energy generation from renewable sources in Texas? | CREATE TABLE texas_energy (id INT,source TEXT,generation FLOAT); INSERT INTO texas_energy (id,source,generation) VALUES (1,'wind',23456.7),(2,'solar',34567.7); | SELECT AVG(generation) FROM texas_energy WHERE source IN ('wind', 'solar'); |
What is the distribution of fairness scores for AI models 'Fairlearn' and 'AIF360' in the 'model_performance' table, grouped by prediction? | CREATE TABLE model_performance (model_name VARCHAR(20),prediction VARCHAR(20),fairness_score FLOAT); INSERT INTO model_performance (model_name,prediction,fairness_score) VALUES ('Fairlearn','fairness',0.85),('Fairlearn','bias',0.91),('AIF360','fairness',0.78),('AIF360','explainability',0.95); | SELECT model_name, prediction, COUNT(*) as count, AVG(fairness_score) as avg_score FROM model_performance WHERE model_name IN ('Fairlearn', 'AIF360') GROUP BY model_name, prediction; |
Identify the total number of articles published in 'articles' table, grouped by the author in 'authors' table. | CREATE TABLE articles (article_id INT,author_id INT,title VARCHAR(100),pub_date DATE); CREATE TABLE authors (author_id INT,author_name VARCHAR(50),country VARCHAR(50)); | SELECT authors.author_name, COUNT(articles.article_id) FROM articles INNER JOIN authors ON articles.author_id = authors.author_id GROUP BY authors.author_name; |
How many missions were conducted by SpaceCorp in 2025? | CREATE TABLE Missions (ID INT,Manufacturer VARCHAR(255),Year INT); INSERT INTO Missions (ID,Manufacturer,Year) VALUES (1,'SpaceCorp',2025),(2,'SpaceCorp',2025),(3,'SpaceCorp',2026); | SELECT COUNT(*) FROM Missions WHERE Manufacturer = 'SpaceCorp' AND Year = 2025; |
What is the percentage of veteran employment in the defense industry, by job category, for the past three months? | CREATE TABLE veteran_employment (employment_id INT,employment_date DATE,company TEXT,job_category TEXT,is_veteran BOOLEAN); INSERT INTO veteran_employment (employment_id,employment_date,company,job_category,is_veteran) VALUES (1,'2022-04-01','ACME Inc','Engineering',true),(2,'2022-05-15','Beta Corp','Management',false)... | SELECT job_category, ROUND(100.0 * SUM(CASE WHEN is_veteran THEN 1 ELSE 0 END) / COUNT(*), 2) as pct_veteran_employment FROM veteran_employment WHERE employment_date BETWEEN DATE_SUB(CURRENT_DATE, INTERVAL 3 MONTH) AND CURRENT_DATE GROUP BY job_category; |
How many sustainable construction projects were completed in New York? | CREATE TABLE project_data (project_number INT,city VARCHAR(20),is_sustainable BOOLEAN); INSERT INTO project_data (project_number,city,is_sustainable) VALUES (1,'New York',TRUE); INSERT INTO project_data (project_number,city,is_sustainable) VALUES (2,'New York',FALSE); | SELECT COUNT(*) FROM project_data WHERE city = 'New York' AND is_sustainable = TRUE; |
How many traditional arts centers exist in the Asia-Pacific region, broken down by country? | CREATE TABLE Traditional_Arts_Centers (Center_Name VARCHAR(50),Country VARCHAR(50),Type VARCHAR(50)); INSERT INTO Traditional_Arts_Centers (Center_Name,Country,Type) VALUES ('Tanjungpura Palace','Indonesia','Dance'),('Sawang Boran','Thailand','Shadow Puppetry'),('The Australian Ballet','Australia','Ballet'); | SELECT Country, COUNT(*) FROM Traditional_Arts_Centers WHERE Country IN ('Indonesia', 'Thailand', 'Australia') GROUP BY Country; |
How many performances were there at the "Berlin Opera" in 2022? | CREATE TABLE OperaPerformances2 (TheatreName TEXT,PerformanceDate DATE); INSERT INTO OperaPerformances2 (TheatreName,PerformanceDate) VALUES ('Berlin Opera','2022-01-01'),('Berlin Opera','2022-02-15'),('Berlin Opera','2022-04-20'); | SELECT COUNT(*) FROM OperaPerformances2 WHERE TheatreName = 'Berlin Opera' AND YEAR(PerformanceDate) = 2022; |
How many socially responsible loans were issued in the Latin American region? | CREATE TABLE social_loans (lender VARCHAR(50),region VARCHAR(50),loan_count INT); INSERT INTO social_loans (lender,region,loan_count) VALUES ('ABC Bank','Latin America',500),('DEF Bank','Asia',700),('GHI Bank','Latin America',300); | SELECT SUM(loan_count) FROM social_loans WHERE region = 'Latin America'; |
How many employees work in each department in New York? | CREATE TABLE department (id INT,name VARCHAR(255),manager_id INT,location VARCHAR(255)); INSERT INTO department (id,name,manager_id,location) VALUES (1,'textiles',101,'New York'); INSERT INTO department (id,name,manager_id,location) VALUES (2,'metallurgy',102,'Chicago'); CREATE TABLE employee (id INT,name VARCHAR(255),... | SELECT department_id, COUNT(*) as employee_count FROM employee INNER JOIN department_location ON employee.department_id = department_location.department_id WHERE location = 'New York' GROUP BY department_id; |
Insert a new record into the 'labor_practices3' table for a brand with the name 'BrandU', a product_id of 6, and a quantity_sold of 750. | CREATE TABLE labor_practices3 (product_id INT,brand VARCHAR(255),quantity_sold INT); | INSERT INTO labor_practices3 (product_id, brand, quantity_sold) VALUES (6, 'BrandU', 750); |
Update the supplier information for products sourced from a high-risk country | CREATE TABLE products (product_id INT,supplier_id INT,sourcing_country VARCHAR(50)); CREATE TABLE suppliers (supplier_id INT,supplier_name VARCHAR(50),ethical_rating INT); INSERT INTO products (product_id,supplier_id,sourcing_country) VALUES (1,101,'USA'),(2,102,'Brazil'),(3,103,'Canada'); INSERT INTO suppliers (suppli... | UPDATE products p JOIN suppliers s ON p.supplier_id = s.supplier_id SET p.supplier_id = 999 WHERE p.sourcing_country = 'Brazil'; |
Which African countries have received climate finance from both public and private sources? | CREATE TABLE climate_finance(project_name TEXT,country TEXT,source TYPE,budget FLOAT); INSERT INTO climate_finance(project_name,country,source,budget) VALUES ('Project A','Kenya','Public',300000.00),('Project B','Nigeria','Private',400000.00),('Project C','Egypt','Public',500000.00),('Project D','South Africa','Private... | SELECT country FROM climate_finance WHERE source IN ('Public', 'Private') GROUP BY country HAVING COUNT(DISTINCT source) = 2; |
Which organizations provided the most assistance in 'disaster_response' table, and what types of assistance did they provide? | CREATE TABLE disaster_response (id INT,organization VARCHAR(50),location VARCHAR(50),assistance_type VARCHAR(50),quantity INT); INSERT INTO disaster_response (id,organization,location,assistance_type,quantity) VALUES (1,'WFP','Syria','Food',5000),(2,'UNWRA','Gaza','Food',3000),(3,'IFRC','Syria','Shelter',2000); | SELECT organization, assistance_type, SUM(quantity) as total_quantity FROM disaster_response GROUP BY organization, assistance_type ORDER BY total_quantity DESC; |
How many times did field 5 have precipitation over 5mm in the last 14 days? | CREATE TABLE field_precipitation (field_id INT,date DATE,precipitation FLOAT); INSERT INTO field_precipitation (field_id,date,precipitation) VALUES (5,'2021-06-15',12.5),(5,'2021-06-20',8.3),(5,'2021-07-01',15.2),(5,'2021-07-05',5.4); | SELECT field_id, COUNT(*) as precipitation_days FROM field_precipitation WHERE field_id = 5 AND precipitation > 5 GROUP BY field_id HAVING precipitation_days > 0; |
What is the total number of electric vehicles sold by make and model? | CREATE TABLE electric_vehicles (id INT,city_id INT,make VARCHAR(50),model VARCHAR(50),year INT,sales INT); INSERT INTO electric_vehicles (id,city_id,make,model,year,sales) VALUES (1,1,'Tesla','Model S',2020,5000); INSERT INTO electric_vehicles (id,city_id,make,model,year,sales) VALUES (2,1,'Tesla','Model 3',2020,8000);... | SELECT electric_vehicles.make, electric_vehicles.model, SUM(electric_vehicles.sales) as total_sales FROM electric_vehicles GROUP BY electric_vehicles.make, electric_vehicles.model; |
What is the total water usage for each drought category in the western region in 2019?' | CREATE TABLE drought_impact (region VARCHAR(255),drought_category VARCHAR(255),month DATE,usage INT); INSERT INTO drought_impact (region,drought_category,month,usage) VALUES ('Western','Severe','2019-01-01',12000); | SELECT region, drought_category, SUM(usage) FROM drought_impact WHERE region = 'Western' AND YEAR(month) = 2019 GROUP BY region, drought_category; |
Find military equipment sales to country 'UK' with sale dates in 2019, grouped by month. | CREATE TABLE military_sales(id INT,country VARCHAR(50),sale_value FLOAT,sale_date DATE); INSERT INTO military_sales(id,country,sale_value,sale_date) VALUES (1,'UK',5000000,'2019-01-01'); INSERT INTO military_sales(id,country,sale_value,sale_date) VALUES (2,'UK',3000000,'2019-02-01'); | SELECT sale_date, SUM(sale_value) FROM military_sales WHERE country = 'UK' AND YEAR(sale_date) = 2019 GROUP BY MONTH(sale_date); |
Insert new student records for 'Oregon' and 'Washington' who have completed their mental health counseling | CREATE TABLE NewStudents (StudentID INT,State VARCHAR(10),Counseling VARCHAR(10)); INSERT INTO NewStudents (StudentID,State,Counseling) VALUES (1,'OR','Completed'),(2,'WA','Completed'); | INSERT INTO NewStudents (StudentID, State, Counseling) VALUES (3, 'Oregon', 'Completed'), (4, 'Washington', 'Completed'); |
List all countries and their average drug approval time since 2000. | CREATE TABLE drug_approvals (country TEXT,approval_date DATE); CREATE TABLE drugs (drug_id INTEGER,approval_country TEXT); CREATE TABLE drug_approval_dates (drug_id INTEGER,approval_date DATE); | SELECT country, AVG(DATEDIFF('day', approval_date, lead(approval_date) OVER (PARTITION BY country ORDER BY approval_date))) AS avg_approval_time FROM drug_approvals JOIN drugs ON drug_approvals.country = drugs.approval_country JOIN drug_approval_dates ON drugs.drug_id = drug_approval_dates.drug_id WHERE approval_date >... |
What are the names and countries of AI safety researchers who have not published any papers? | CREATE TABLE if not exists safety_researchers (researcher_id INT PRIMARY KEY,name TEXT,paper_id INT); INSERT INTO safety_researchers (researcher_id,name,paper_id) VALUES (101,'Alice',NULL),(102,'Bob',201),(103,'Charlie',NULL),(104,'Dave',202); | SELECT name, country FROM safety_researchers WHERE paper_id IS NULL; |
What is the average carbon footprint per international visitor in North America? | CREATE TABLE if not exists countries (id INT,name VARCHAR(20)); INSERT INTO countries (id,name) VALUES (1,'Canada'),(2,'Mexico'),(3,'United States'); CREATE TABLE if not exists visitors (id INT,country_id INT,year INT,visitors INT,carbon_footprint INT); | SELECT c.name, AVG(v.carbon_footprint/v.visitors) FROM visitors v JOIN countries c ON v.country_id = c.id WHERE c.name IN ('Canada', 'Mexico', 'United States') GROUP BY c.name; |
What is the average speed of all autonomous vehicles? | CREATE TABLE Autonomous_Vehicles_Speed (id INT,name TEXT,max_speed FLOAT); INSERT INTO Autonomous_Vehicles_Speed (id,name,max_speed) VALUES (1,'AutoX',110.5); INSERT INTO Autonomous_Vehicles_Speed (id,name,max_speed) VALUES (2,'AutoY',120.0); | SELECT AVG(max_speed) FROM Autonomous_Vehicles_Speed; |
What is the total revenue generated from each region? | CREATE TABLE CompanyRevenue (CompanyID INT,Region VARCHAR(10),Revenue INT); INSERT INTO CompanyRevenue (CompanyID,Region,Revenue) VALUES (1,'North America',500000),(2,'Europe',700000),(3,'North America',600000),(4,'Asia',800000); | SELECT Region, SUM(Revenue) FROM CompanyRevenue GROUP BY Region; |
List all aircraft manufactured in the US. | CREATE TABLE AircraftManufacturing (aircraft_id INT,manufacturer VARCHAR(50),country VARCHAR(50)); | SELECT aircraft_id, manufacturer FROM AircraftManufacturing WHERE country = 'USA'; |
What is the average distance walked by members in each region, in ascending order? | CREATE TABLE workouts (workout_id INT,member_id INT,distance FLOAT,region VARCHAR(20)); INSERT INTO workouts (workout_id,member_id,distance,region) VALUES (1,1,2.5,'North'),(2,2,3.2,'South'),(3,3,1.8,'East'); | SELECT AVG(distance) as avg_distance, region FROM workouts GROUP BY region ORDER BY avg_distance ASC; |
Update the donation amounts for the 'Doctors Without Borders' non-profit that were made in the last month, increasing them by 10%. | CREATE TABLE non_profit (id INT,name TEXT); INSERT INTO non_profit (id,name) VALUES (1,'Habitat for Humanity'),(2,'American Red Cross'),(3,'Doctors Without Borders'); CREATE TABLE donations (id INT,non_profit_id INT,donation_amount INT,donation_date DATE); INSERT INTO donations (id,non_profit_id,donation_amount,donatio... | UPDATE donations d SET donation_amount = d.donation_amount * 1.10 WHERE d.non_profit_id = 3 AND d.donation_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH); |
Calculate the total revenue generated by a specific continent's tourism industry in the last 5 years. | CREATE TABLE revenue (year INT,continent TEXT,revenue INT); INSERT INTO revenue (year,continent,revenue) VALUES (2017,'North America',50000000),(2018,'North America',55000000),(2019,'North America',60000000),(2020,'North America',30000000),(2017,'South America',30000000),(2018,'South America',33000000),(2019,'South Ame... | SELECT continent, SUM(revenue) as total_revenue FROM revenue WHERE year >= (SELECT MAX(year) - 5 FROM revenue) GROUP BY continent; |
Find the total number of transactions for all digital assets. | CREATE TABLE digital_assets (asset_id varchar(10),asset_name varchar(10)); INSERT INTO digital_assets (asset_id,asset_name) VALUES ('ETH','Ethereum'),('BTC','Bitcoin'); CREATE TABLE transactions (transaction_id serial,asset_id varchar(10),transaction_amount numeric); INSERT INTO transactions (asset_id,transaction_amoun... | SELECT COUNT(*) FROM transactions; |
List all companies in the 'renewable_energy' sector | CREATE TABLE companies (id INT,sector VARCHAR(20)) | SELECT * FROM companies WHERE sector = 'renewable_energy' |
What is the difference in water usage between the residential and industrial sectors in Texas in 2021? | CREATE TABLE residential_water_usage (state VARCHAR(20),year INT,usage FLOAT); INSERT INTO residential_water_usage (state,year,usage) VALUES ('Texas',2021,12345.6); CREATE TABLE industrial_water_usage (state VARCHAR(20),year INT,sector VARCHAR(30),usage FLOAT); INSERT INTO industrial_water_usage (state,year,sector,usag... | SELECT SUM(residential_water_usage.usage) - SUM(industrial_water_usage.usage) FROM residential_water_usage, industrial_water_usage WHERE residential_water_usage.state = 'Texas' AND residential_water_usage.year = 2021 AND industrial_water_usage.state = 'Texas' AND industrial_water_usage.year = 2021; |
List all chemical compounds and their corresponding environmental impact scores for production sites in Brazil. | CREATE TABLE chemical_compounds(id INT,compound_name TEXT,environmental_impact_score INT); CREATE TABLE production_sites(id INT,site_name TEXT,location TEXT); INSERT INTO chemical_compounds (id,compound_name,environmental_impact_score) VALUES (1,'Compound X',60),(2,'Compound Y',70); INSERT INTO production_sites (id,sit... | SELECT chemical_compounds.compound_name, chemical_compounds.environmental_impact_score FROM chemical_compounds INNER JOIN production_sites ON chemical_compounds.id = production_sites.id WHERE production_sites.location = 'Brazil'; |
Delete all records from indigenous_communities table where region is 'Siberia' | CREATE TABLE indigenous_communities (id INT PRIMARY KEY,community VARCHAR(50),population INT,region VARCHAR(50)); INSERT INTO indigenous_communities (id,community,population,region) VALUES (1,'Yamal Nenets',5000,'Siberia'); INSERT INTO indigenous_communities (id,community,population,region) VALUES (2,'Evenki',3000,'Sib... | WITH cte AS (DELETE FROM indigenous_communities WHERE region = 'Siberia') SELECT * FROM indigenous_communities; |
Delete the researcher 'John Doe' from the researchers table. | CREATE TABLE researchers (id INT PRIMARY KEY,name VARCHAR(50),affiliation VARCHAR(50)); | DELETE FROM researchers WHERE name = 'John Doe'; |
Update Europium production records in Russia for 2018 by 10%. | CREATE TABLE production (country VARCHAR(255),year INT,element VARCHAR(10),quantity INT); INSERT INTO production (country,year,element,quantity) VALUES ('Russia',2018,'Eu',1500); | UPDATE production SET quantity = ROUND(quantity * 1.10) WHERE country = 'Russia' AND year = 2018 AND element = 'Eu'; |
What is the average response time for medical emergencies in each city in Texas? | CREATE TABLE emergency_responses (id INT,incident_id INT,response_time INT,city VARCHAR(255),state VARCHAR(255)); INSERT INTO emergency_responses (id,incident_id,response_time,city,state) VALUES (1,1,8,'Austin','Texas'); INSERT INTO emergency_responses (id,incident_id,response_time,city,state) VALUES (2,2,12,'Houston',... | SELECT city, AVG(response_time) FROM emergency_responses WHERE state = 'Texas' AND incident_type = 'Medical Emergency' GROUP BY city; |
What are the labor costs for green building projects in California, grouped by project name? | CREATE TABLE Green_Buildings (Project_ID INT,Project_Name VARCHAR(255),State VARCHAR(255),Labor_Cost DECIMAL(10,2)); INSERT INTO Green_Buildings (Project_ID,Project_Name,State,Labor_Cost) VALUES (1,'Solar Farm','California',150000.00),(2,'Wind Turbine Park','California',200000.00); | SELECT Project_Name, SUM(Labor_Cost) FROM Green_Buildings WHERE State = 'California' GROUP BY Project_Name; |
Update the total number of electric ferries for the new Vancouver-Victoria service | CREATE TABLE electric_ferries (id INT PRIMARY KEY,ferry_name VARCHAR(255),departure_city VARCHAR(255),destination_city VARCHAR(255),num_ferries INT,capacity INT); | UPDATE electric_ferries SET num_ferries = 15 WHERE ferry_name = 'Sea Spirit'; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.