instruction
stringlengths
0
1.06k
input
stringlengths
11
5.3k
response
stringlengths
2
4.44k
What is the total number of artworks created by each artist in the 'Artworks' table, ordered by the total count in descending order?
CREATE TABLE Artworks (id INT,art_category VARCHAR(255),artist_name VARCHAR(255),year INT,art_medium VARCHAR(255),price DECIMAL(10,2));
SELECT artist_name, COUNT(*) as total FROM Artworks GROUP BY artist_name ORDER BY total DESC;
What is the maximum budget for a technology for social good project in South America?
CREATE TABLE tech_for_social_good_projects (project_id INT,continent VARCHAR(10),budget DECIMAL(10,2)); INSERT INTO tech_for_social_good_projects (project_id,continent,budget) VALUES (1,'North America',250000.00),(2,'South America',350000.00),(3,'Europe',450000.00);
SELECT MAX(budget) FROM tech_for_social_good_projects WHERE continent = 'South America';
What is the minimum population size of all marine species in the Indian Ocean, grouped by conservation status?"
CREATE TABLE marine_species_population (species_name VARCHAR(255),region VARCHAR(255),min_population_size FLOAT,conservation_status VARCHAR(255)); INSERT INTO marine_species_population (species_name,region,min_population_size,conservation_status) VALUES ('Whale Shark','Indian Ocean',1500,'Fully Protected'),('Dolphin','...
SELECT conservation_status, MIN(min_population_size) as min_population_size FROM marine_species_population WHERE region = 'Indian Ocean' GROUP BY conservation_status;
What is the earliest visit date for vessels that have visited 'Port E'?
CREATE TABLE ports (port_id INT,port_name TEXT,country TEXT); INSERT INTO ports (port_id,port_name,country) VALUES (1,'Port A','USA'),(2,'Port B','Canada'),(3,'Port C','USA'),(4,'Port D','Mexico'),(5,'Port E','Brazil'); CREATE TABLE visits (visit_id INT,vessel_id INT,port_id INT,visit_date DATE); INSERT INTO visits (vi...
SELECT MIN(visit_date) FROM visits WHERE port_id = (SELECT port_id FROM ports WHERE port_name = 'Port E');
What is the percentage of female faculty members in the university?
CREATE TABLE university_faculty (id INT,gender VARCHAR(10)); INSERT INTO university_faculty (id,gender) VALUES (1,'Female'),(2,'Male'),(3,'Male'),(4,'Female'),(5,'Female');
SELECT ROUND(100.0 * SUM(CASE WHEN gender = 'Female' THEN 1 ELSE 0 END) / COUNT(*), 1) as pct_female_faculty;
What is the market share of 'DrugC' in 'RegionY' in Q2 of 2019?
CREATE TABLE sales(drug_name TEXT,region TEXT,sales_quarter INT,revenue FLOAT); INSERT INTO sales (drug_name,region,sales_quarter,revenue) VALUES ('DrugA','RegionY',2,1200000),('DrugB','RegionX',2,1000000),('DrugC','RegionY',2,1400000);
SELECT (SUM(sales.revenue) / (SELECT SUM(revenue) FROM sales WHERE sales_quarter = 2 AND region = 'RegionY')) * 100.0 AS market_share FROM sales WHERE drug_name = 'DrugC' AND sales_quarter = 2 AND region = 'RegionY';
Calculate the average daily oil production for each platform in the second quarter of 2021
CREATE TABLE platform (id INT,name VARCHAR(50),location VARCHAR(50)); CREATE TABLE oil_production (platform_id INT,date DATE,oil_production FLOAT);
SELECT p.name, AVG(op.oil_production/DATEDIFF('2021-06-30', op.date)) FROM oil_production op JOIN platform p ON op.platform_id = p.id WHERE op.date BETWEEN '2021-04-01' AND '2021-06-30' GROUP BY op.platform_id;
Identify the total sales of cosmetic products that contain 'aloe vera' as an ingredient, sourced from the US.
CREATE TABLE ingredients (ingredient_id INT,product_id INT,ingredient_name VARCHAR(50)); INSERT INTO ingredients (ingredient_id,product_id,ingredient_name) VALUES (1,1,'aloe vera'),(2,2,'lavender'),(3,3,'tea tree'); CREATE TABLE sourcing (product_id INT,country_code CHAR(2)); INSERT INTO sourcing (product_id,country_co...
SELECT SUM(products.sales) FROM products JOIN ingredients ON products.product_id = ingredients.product_id JOIN sourcing ON products.product_id = sourcing.product_id WHERE ingredients.ingredient_name = 'aloe vera' AND sourcing.country_code = 'US';
What is the average labor productivity by mine type in California?
CREATE TABLE mine (id INT,name VARCHAR(255),type VARCHAR(255),location VARCHAR(255));INSERT INTO mine (id,name,type,location) VALUES (1,'Golden','Open-pit','California'); INSERT INTO mine (id,name,type,location) VALUES (2,'Silver','Underground','California');
SELECT type, AVG(labor_productivity) as avg_labor_productivity FROM labor_productivity JOIN mine ON labor_productivity.mine_id = mine.id WHERE mine.location = 'California' GROUP BY type;
What is the name and location of the rural clinic with the most medical professionals in the state of New York?
CREATE TABLE medical_professionals (id INT,name VARCHAR(50),clinic_id INT); CREATE TABLE clinics (id INT,name VARCHAR(50),location VARCHAR(50)); INSERT INTO medical_professionals (id,name,clinic_id) VALUES (1,'Dr. Smith',1),(2,'Dr. Johnson',1),(3,'Dr. Lee',2); INSERT INTO clinics (id,name,location) VALUES (1,'Clinic A'...
SELECT clinics.name, clinics.location FROM clinics JOIN (SELECT clinic_id, COUNT(*) as num_of_professionals FROM medical_professionals GROUP BY clinic_id ORDER BY num_of_professionals DESC LIMIT 1) AS subquery ON clinics.id = subquery.clinic_id;
List the top 3 destinations with the highest average number of packages shipped per day in June 2021
CREATE TABLE Shipments (id INT,destination VARCHAR(50),packages INT,timestamp DATE); INSERT INTO Shipments (id,destination,packages,timestamp) VALUES (1,'Sao Paulo',50,'2021-06-01'),(2,'Rio de Janeiro',30,'2021-06-02'),(3,'Belo Horizonte',40,'2021-06-03'),(4,'Salvador',55,'2021-06-04'),(5,'Fortaleza',60,'2021-06-05');
SELECT destination, AVG(packages) FROM Shipments WHERE timestamp BETWEEN '2021-06-01' AND '2021-06-30' GROUP BY destination ORDER BY AVG(packages) DESC LIMIT 3;
List all the timber production data for the last 5 years in the timber_production table?
CREATE TABLE timber_production (production_id INT,year INT,volume FLOAT);
SELECT * FROM timber_production WHERE year BETWEEN YEAR(CURRENT_DATE) - 5 AND YEAR(CURRENT_DATE);
What is the total quantity of products with transparent supply chains sold by vendors in Washington D.C.?
CREATE TABLE vendors (vendor_id INT,vendor_name VARCHAR(50),state VARCHAR(50)); INSERT INTO vendors VALUES (1,'VendorA','Washington D.C.'); INSERT INTO vendors VALUES (2,'VendorB','Texas'); CREATE TABLE products (product_id INT,product_name VARCHAR(50),vendor_id INT,quantity INT,transparent_supply BOOLEAN); INSERT INTO...
SELECT SUM(products.quantity) FROM products JOIN vendors ON products.vendor_id = vendors.vendor_id WHERE products.transparent_supply = true AND vendors.state = 'Washington D.C.';
List the restaurants with their total organic revenue.
CREATE TABLE restaurants (id INT,name VARCHAR(255),organic BOOLEAN); INSERT INTO restaurants (id,name,organic) VALUES (1,'Restaurant A',TRUE),(2,'Restaurant B',FALSE),(3,'Organic Garden',TRUE); CREATE TABLE dishes (id INT,name VARCHAR(255),type VARCHAR(255),revenue INT,restaurant_id INT,organic BOOLEAN); INSERT INTO di...
SELECT r.name, SUM(d.revenue) FROM dishes d JOIN restaurants r ON d.restaurant_id = r.id WHERE r.organic = TRUE GROUP BY r.id;
What is the total number of volunteer hours for the 'North' region?
CREATE TABLE CityVolunteers (city TEXT,region TEXT,hours FLOAT); INSERT INTO CityVolunteers (city,region,hours) VALUES ('NYC','North',150.0),('LA','South',100.5),('Chicago','North',200.1),('Houston','South',180.2);
SELECT SUM(hours) FROM CityVolunteers WHERE region = 'North';
What is the average age of astronauts at their first space mission, grouped by their nationality?
CREATE TABLE astronauts (id INT,name VARCHAR(50),age INT,first_mission INT,nationality VARCHAR(50)); INSERT INTO astronauts (id,name,age,first_mission,nationality) VALUES (1,'Anousheh Ansari',49,2006,'Iran'),(2,'Serena Auñón-Chancellor',45,2018,'USA');
SELECT nationality, AVG(age) FROM astronauts WHERE first_mission IS NOT NULL GROUP BY nationality;
List the top 5 green building certifications with the most certified buildings in the green_buildings table.
CREATE TABLE green_buildings (building_id INT,building_name VARCHAR(255),location VARCHAR(255),certification_id INT,certification_name VARCHAR(255));
SELECT certification_name, COUNT(*) AS num_buildings FROM green_buildings GROUP BY certification_id ORDER BY num_buildings DESC LIMIT 5;
List the textile sourcing countries with the lowest water consumption for linen.
CREATE TABLE water_consumption (id INT PRIMARY KEY,fabric_type VARCHAR(255),country VARCHAR(255),water_consumption FLOAT); INSERT INTO water_consumption (id,fabric_type,country,water_consumption) VALUES (1,'Linen','Belgium',10),(2,'Cotton','India',25),(3,'Hemp','France',15),(4,'Linen','Poland',12),(5,'Polyester','China...
SELECT country, water_consumption FROM water_consumption WHERE fabric_type = 'Linen' ORDER BY water_consumption ASC LIMIT 1;
What is the number of patients who accessed primary care services by age group and gender, in the last year?
CREATE TABLE primary_care (patient_id INT,patient_gender VARCHAR(10),age_group INT,service_date DATE); INSERT INTO primary_care (patient_id,patient_gender,age_group,service_date) VALUES (1,'Male',0,'2022-01-01'),(2,'Female',1,'2022-01-02'),(3,'Male',2,'2022-01-03'),(4,'Female',0,'2022-01-04');
SELECT age_group, patient_gender, COUNT(*) as patient_count FROM primary_care WHERE service_date BETWEEN DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR) AND CURRENT_DATE GROUP BY age_group, patient_gender;
List the top 3 AI algorithms with the highest explainability scores, ordered by scores in descending order.
CREATE TABLE ai_algorithms (algorithm_id INT,algorithm_name VARCHAR(50),explainability_score FLOAT); INSERT INTO ai_algorithms (algorithm_id,algorithm_name,explainability_score) VALUES (1,'Algo1',0.85),(2,'Algo2',0.92),(3,'Algo3',0.78),(4,'Algo4',0.90),(5,'Algo5',0.80);
SELECT * FROM ai_algorithms ORDER BY explainability_score DESC LIMIT 3;
Get the total number of investments in 'Africa' and 'LatinAmerica'.
CREATE TABLE InvestmentsRegion (id INT,investor VARCHAR(255),country VARCHAR(255),sector VARCHAR(255),amount DECIMAL(10,2));
SELECT SUM(amount) FROM InvestmentsRegion WHERE country IN ('Africa', 'LatinAmerica');
What is the average age of patients in the rural_clinic table?
CREATE TABLE rural_clinic (patient_id INT,age INT,gender VARCHAR(10));
SELECT AVG(age) FROM rural_clinic;
What are the names of the volunteers who have donated more than $500 in the Donations table and participated in the Environment program in the VolunteerPrograms table?
CREATE TABLE Donations (DonorID INT,DonorName TEXT,DonationAmount DECIMAL(10,2)); CREATE TABLE VolunteerPrograms (VolunteerID INT,ProgramID INT,VolunteerName TEXT);
SELECT DonorName FROM Donations INNER JOIN (SELECT VolunteerName FROM VolunteerPrograms WHERE ProgramID = 3) AS Volunteers ON 1=1 WHERE DonationAmount > 500;
What is the total cargo weight (in metric tons) unloaded in Argentina?
CREATE TABLE ports (port_id INT,port_name VARCHAR(50),country VARCHAR(50)); INSERT INTO ports VALUES (1,'Buenos Aires','Argentina'); CREATE TABLE cargo (cargo_id INT,port_id INT,weight_ton FLOAT,loading_unloading VARCHAR(50)); INSERT INTO cargo VALUES (1,1,5000,'unloading'); INSERT INTO cargo VALUES (2,1,7000,'unloadin...
SELECT SUM(weight_ton) FROM cargo JOIN ports ON cargo.port_id = ports.port_id WHERE ports.country = 'Argentina' AND cargo.loading_unloading = 'unloading';
What is the maximum response time for emergency calls in the city of Phoenix?
CREATE TABLE EmergencyCalls (ID INT,City VARCHAR(20),ResponseTime INT); INSERT INTO EmergencyCalls (ID,City,ResponseTime) VALUES (1,'Phoenix',11);
SELECT MAX(ResponseTime) FROM EmergencyCalls WHERE City = 'Phoenix';
What is the average severity of vulnerabilities for web applications?
CREATE TABLE web_app_vulnerabilities (id INT,app_name VARCHAR(255),severity INT); INSERT INTO web_app_vulnerabilities (id,app_name,severity) VALUES (1,'App1',5),(2,'App2',3),(3,'App3',7);
SELECT AVG(severity) FROM web_app_vulnerabilities;
Identify dispensaries that have never sold any indica strain cannabis products.
CREATE TABLE DispensaryProductData2 (DispensaryName VARCHAR(50),IndicaSold INT); INSERT INTO DispensaryProductData2 (DispensaryName,IndicaSold) VALUES ('Green Earth Dispensary',50),('Buds and Beyond',100),('The Healing Center',150),('Elevated Roots',0),('Emerald Fields',200);
SELECT DispensaryName FROM DispensaryProductData2 WHERE IndicaSold = 0;
What was the production trend for 'China' from 2019 to 2020?
CREATE TABLE production (country VARCHAR(255),year INT,amount INT); INSERT INTO production (country,year,amount) VALUES ('China',2019,120000),('China',2020,140000),('USA',2020,38000),('Australia',2020,20000),('India',2020,5000);
SELECT country, year, amount, LAG(amount, 1) OVER (PARTITION BY country ORDER BY year) AS previous_year_production FROM production WHERE country = 'China';
What is the total revenue for each line in the 'paris' schema?
CREATE TABLE paris.lines (id INT,line_name VARCHAR); CREATE TABLE paris.revenue (id INT,line_id INT,daily_revenue DECIMAL);
SELECT paris.lines.line_name, SUM(paris.revenue.daily_revenue) FROM paris.lines INNER JOIN paris.revenue ON paris.lines.id = paris.revenue.line_id GROUP BY paris.lines.line_name;
Identify the top 2 cities with the highest average visitor spending.
CREATE TABLE CitySpending (id INT,city VARCHAR(20),spending INT); INSERT INTO CitySpending (id,city,spending) VALUES (1,'Paris',3000),(2,'London',2500),(3,'Berlin',2000),(4,'New York',3500),(5,'Tokyo',2800);
SELECT city, AVG(spending) FROM CitySpending GROUP BY city ORDER BY AVG(spending) DESC LIMIT 2;
What is the total weight of all 'Certified Organic' products in 'NatureMarket'?
CREATE TABLE NatureMarket (product_id INT,product_name VARCHAR(50),weight FLOAT,eco_label VARCHAR(50)); INSERT INTO NatureMarket (product_id,product_name,weight,eco_label) VALUES (1,'Apples',2.5,'Certified Organic'),(2,'Bananas',3.0,'Fair Trade'),(3,'Carrots',1.5,'Certified Organic'),(4,'Dates',1.0,'Fair Trade');
SELECT SUM(weight) FROM NatureMarket WHERE eco_label = 'Certified Organic';
What is the total number of tickets sold by each team for all events?
CREATE TABLE teams (team_id INT,team_name VARCHAR(255)); INSERT INTO teams (team_id,team_name) VALUES (1,'Knights'),(2,'Lions'),(3,'Titans'); CREATE TABLE events (event_id INT,team_id INT,num_tickets_sold INT); INSERT INTO events (event_id,team_id,num_tickets_sold) VALUES (1,1,500),(2,1,700),(3,2,600),(4,3,800),(5,3,90...
SELECT e.team_id, SUM(e.num_tickets_sold) as total_tickets_sold FROM events e GROUP BY e.team_id;
How many auto shows took place in Mexico in 2019?
CREATE TABLE Auto_Shows (year INT,country VARCHAR(50),quantity INT); INSERT INTO Auto_Shows (year,country,quantity) VALUES (2019,'Mexico',5);
SELECT SUM(quantity) FROM Auto_Shows WHERE year = 2019 AND country = 'Mexico';
Show companies that have not raised any investment
CREATE TABLE investment (id INT,company_id INT,investment_round_size REAL,investment_round_date DATE); CREATE TABLE startup (id INT,name TEXT,founding_year INT,founder_gender TEXT);
SELECT startup.name FROM startup LEFT JOIN investment ON startup.id = investment.company_id WHERE investment.id IS NULL;
List the public health policies related to vaccination in Florida.
CREATE TABLE public_health_policies (id INT,policy_type TEXT,description TEXT,state TEXT); INSERT INTO public_health_policies (id,policy_type,description,state) VALUES (1,'Vaccination','Mandatory Vaccination for School Children','Florida'); INSERT INTO public_health_policies (id,policy_type,description,state) VALUES (2...
SELECT description FROM public_health_policies WHERE policy_type = 'Vaccination' AND state = 'Florida';
List the names of all government departments in the United Kingdom.
CREATE TABLE uk_departments (name TEXT); INSERT INTO uk_departments (name) VALUES ('Department for Education'),('Department for Environment,Food and Rural Affairs');
SELECT name FROM uk_departments;
How many fish were farmed in each country for the past 3 years?
CREATE TABLE Country (CountryID INT,CountryName TEXT); CREATE TABLE Farm (FarmID INT,FarmName TEXT,CountryID INT,EstablishedDate DATE); INSERT INTO Country VALUES (1,'Norway'); INSERT INTO Country VALUES (2,'Scotland'); INSERT INTO Farm VALUES (1,'Farm A',1,'2018-01-01'); INSERT INTO Farm VALUES (2,'Farm B',2,'2019-01-...
SELECT CountryName, EXTRACT(YEAR FROM DATE_ADD(EstablishedDate, INTERVAL (YEAR(CURRENT_DATE) - YEAR(EstablishedDate)) YEAR)) AS Year, COUNT(*) AS FishCount FROM Country INNER JOIN Farm ON Country.CountryID = Farm.CountryID GROUP BY CountryName, Year;
What is the maximum rental price for accessible units in the 'rental_properties' table?
CREATE TABLE rental_properties (property_id INT,rental_price DECIMAL,accessible BOOLEAN);
SELECT MAX(rental_price) FROM rental_properties WHERE accessible = TRUE;
What is the average food safety score for restaurants in a given city over time?
CREATE TABLE restaurants (restaurant_id INT,city VARCHAR(255),food_safety_score INT,inspection_date DATE); INSERT INTO restaurants (restaurant_id,city,food_safety_score,inspection_date) VALUES (1,'New York',90,'2022-01-01'),(2,'Los Angeles',85,'2022-01-02'),(3,'New York',95,'2022-01-03');
SELECT city, AVG(food_safety_score) FROM restaurants GROUP BY city, DATE_TRUNC('month', inspection_date);
How many marine protected areas are there in the Caribbean Sea?
CREATE TABLE marine_protected_areas (id INT,area_name VARCHAR(255),ocean VARCHAR(255)); INSERT INTO marine_protected_areas (id,area_name,ocean) VALUES (1,'Area 1','Caribbean'),(2,'Area 2','Caribbean'),(3,'Area 3','Mediterranean'),(4,'Area 4','Pacific');
SELECT COUNT(*) FROM marine_protected_areas WHERE ocean = 'Caribbean';
What is the maximum salary of employees in the sales department in the employees table?
CREATE TABLE employees (id INT PRIMARY KEY,name VARCHAR(50),department VARCHAR(20),salary DECIMAL(10,2)); INSERT INTO employees (id,name,department,salary) VALUES (1,'Alice','sales',80000.00),(2,'Bob','marketing',70000.00),(3,'Charlie','sales',85000.00);
SELECT MAX(salary) AS max_salary FROM employees WHERE department = 'sales';
What is the average salary for each position at each mine, excluding managers?
CREATE TABLE Employee (EmployeeID INT,MineID INT,Name VARCHAR(50),Position VARCHAR(50),Gender VARCHAR(10),Age INT,Salary INT); INSERT INTO Employee (EmployeeID,MineID,Name,Position,Gender,Age,Salary) VALUES (1,1,'James','Miner','Male',35,50000); INSERT INTO Employee (EmployeeID,MineID,Name,Position,Gender,Age,Salary) V...
SELECT MineID, Position, AVG(Salary) as AverageSalary FROM Employee WHERE Position != 'Manager' GROUP BY MineID, Position;
What is the average budget for defense diplomacy events in Europe?
CREATE TABLE defense_diplomacy (id INT PRIMARY KEY,event_name VARCHAR(100),budget DECIMAL(10,2),region VARCHAR(50)); INSERT INTO defense_diplomacy (id,event_name,budget,region) VALUES (1,'Event 1',50000,'Europe'),(2,'Event 2',75000,'Asia-Pacific'),(3,'Event 3',30000,'Europe');
SELECT AVG(budget) FROM defense_diplomacy WHERE region = 'Europe';
List the top 2 countries with the highest total product defects in 2018.
CREATE TABLE ProductDefects (ID INT,CountryID INT,DefectDate DATE,Quantity INT); INSERT INTO ProductDefects (ID,CountryID,DefectDate,Quantity) VALUES (1,400,'2018-04-01',300),(2,401,'2018-01-10',500),(3,400,'2018-12-25',400);
SELECT CountryID, SUM(Quantity) as TotalQuantity FROM ProductDefects WHERE DefectDate >= '2018-01-01' AND DefectDate < '2019-01-01' GROUP BY CountryID ORDER BY TotalQuantity DESC LIMIT 2;
What is the average temperature recorded for each chemical storage facility in the past month?
CREATE TABLE facility (id INT,name VARCHAR(255)); CREATE TABLE temperature_record (id INT,facility_id INT,record_date DATE,temperature INT); INSERT INTO facility (id,name) VALUES (1,'Facility A'),(2,'Facility B'); INSERT INTO temperature_record (id,facility_id,record_date,temperature) VALUES (1,1,'2022-01-01',20),(2,1,...
SELECT f.name, AVG(tr.temperature) FROM facility f INNER JOIN temperature_record tr ON f.id = tr.facility_id WHERE tr.record_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) GROUP BY f.name;
How many manual buses and trams are in the public_transportation table?
CREATE TABLE public_transportation (id INT,vehicle_type VARCHAR(20),quantity INT); INSERT INTO public_transportation (id,vehicle_type,quantity) VALUES (1,'autonomous_bus',200),(2,'manual_bus',800),(3,'tram',1000);
SELECT SUM(quantity) FROM public_transportation WHERE vehicle_type IN ('manual_bus', 'tram');
Which region hosted the most esports events in 2021?
CREATE TABLE events (id INT,year INT,region VARCHAR(20)); INSERT INTO events (id,year,region) VALUES (1,2022,'Europe'),(2,2021,'Asia'),(3,2022,'North America'),(4,2021,'Europe'),(5,2021,'Asia'),(6,2022,'North America');
SELECT region, COUNT(*) as count FROM events WHERE year = 2021 GROUP BY region ORDER BY count DESC LIMIT 1;
How many products in the 'clothing' category are sold in stores located in Canada?
CREATE TABLE products (product_id INT,product_name VARCHAR(50),category VARCHAR(50),store_location VARCHAR(50)); INSERT INTO products (product_id,product_name,category,store_location) VALUES (1,'T-Shirt','clothing','Canada'),(2,'Jeans','clothing','USA'),(3,'Sneakers','footwear','Canada'),(4,'Backpack','accessories','US...
SELECT COUNT(*) FROM products WHERE category = 'clothing' AND store_location = 'Canada';
Update the 'is_fair_trade_certified' field for product 4 to 'true'
CREATE TABLE Products(id INT,name TEXT,material TEXT,is_sustainable BOOLEAN,is_fair_trade_certified BOOLEAN); INSERT INTO Products(id,name,material,is_sustainable,is_fair_trade_certified) VALUES (1,'Shirt','Hemp',true,false),(2,'Pants','Tencel',true,true),(3,'Jacket','Recycled Polyester',true,true),(4,'Scarf','Organic ...
UPDATE Products SET is_fair_trade_certified = true WHERE id = 4;
What is the average disaster preparedness score in the year 2020?
CREATE TABLE public.disaster_preparedness (id serial PRIMARY KEY,year int,score int); INSERT INTO public.disaster_preparedness (year,score) VALUES (2020,70),(2020,75),(2020,80);
SELECT AVG(score) FROM public.disaster_preparedness WHERE year = 2020;
Delete all records from the 'articles' table where the 'title' contains 'Politics'
CREATE TABLE articles (id INT,title VARCHAR(100),published_date DATE); INSERT INTO articles (id,title,published_date) VALUES (1,'Politics in the Capital','2022-01-01'); INSERT INTO articles (id,title,published_date) VALUES (2,'The Future of AI','2022-01-02');
DELETE FROM articles WHERE title LIKE '%Politics%';
What is the policy type and effective date of policies with a risk score greater than 800?
CREATE TABLE Policy (PolicyID int,PolicyType varchar(50),EffectiveDate date,RiskScore int); INSERT INTO Policy (PolicyID,PolicyType,EffectiveDate,RiskScore) VALUES (1,'Auto','2020-01-01',700),(2,'Home','2019-05-05',900),(3,'Life','2021-08-01',850);
SELECT PolicyType, EffectiveDate FROM Policy WHERE RiskScore > 800;
How many artworks are there in each medium category?
CREATE TABLE artworks (id INT,artwork VARCHAR(50),medium VARCHAR(50)); INSERT INTO artworks (id,artwork,medium) VALUES (1,'Painting','Painting'),(2,'Sculpture','Sculpture'),(3,'Print','Print');
SELECT medium, COUNT(*) as num_artworks FROM artworks GROUP BY medium;
Find the number of unique artists who received funding from private donors or corporations?
CREATE TABLE artists (id INT,name VARCHAR(255)); INSERT INTO artists (id,name) VALUES (1,'Picasso'),(2,'Van Gogh'); CREATE TABLE funding (artist_id INT,source VARCHAR(255),amount FLOAT); INSERT INTO funding (artist_id,source,amount) VALUES (1,'Private Donor',10000),(1,'Corporation',20000),(2,'Government',15000);
SELECT DISTINCT artist_id FROM funding WHERE source IN ('Private Donor', 'Corporation');
Which military equipment types have the highest maintenance costs?
CREATE TABLE equipment_maintenance (equipment_type TEXT,cost FLOAT); INSERT INTO equipment_maintenance (equipment_type,cost) VALUES ('Tank',12000),('Fighter Jet',35000),('Helicopter',18000);
SELECT equipment_type, cost FROM equipment_maintenance ORDER BY cost DESC LIMIT 1;
List all policy types that have at least one claim in the last 60 days, ordered by policy type.
CREATE TABLE PolicyTypes (PolicyTypeID INT,PolicyType TEXT); INSERT INTO PolicyTypes (PolicyTypeID,PolicyType) VALUES (1,'Home'),(2,'Auto'),(3,'Life'); CREATE TABLE Policyholders (PolicyholderID INT,PolicyholderName TEXT,PolicyTypeID INT); INSERT INTO Policyholders (PolicyholderID,PolicyholderName,PolicyTypeID) VALUES ...
SELECT PolicyTypes.PolicyType FROM PolicyTypes INNER JOIN Policyholders ON PolicyTypes.PolicyTypeID = Policyholders.PolicyTypeID INNER JOIN Claims ON Policyholders.PolicyholderID = Claims.PolicyholderID WHERE Claims.ClaimDate >= DATEADD(day, -60, GETDATE()) GROUP BY PolicyTypes.PolicyType ORDER BY PolicyTypes.PolicyTyp...
How many food safety inspections were conducted in each quarter of the year?
CREATE TABLE inspections (id INT,date DATE); INSERT INTO inspections (id,date) VALUES (1,'2022-01-01'),(2,'2022-04-01'),(3,'2022-07-01');
SELECT DATE_FORMAT(date, '%Y-%m') as quarter, COUNT(*) as num_inspections FROM inspections GROUP BY quarter;
What is the average hotel rating for eco-friendly hotels in Costa Rica?
CREATE TABLE hotels (id INT,name TEXT,country TEXT,is_ecofriendly BOOLEAN,rating FLOAT); INSERT INTO hotels (id,name,country,is_ecofriendly,rating) VALUES (1,'Hotel A','Costa Rica',TRUE,4.5),(2,'Hotel B','Costa Rica',FALSE,4.2),(3,'Hotel C','Costa Rica',TRUE,4.8);
SELECT AVG(rating) FROM hotels WHERE is_ecofriendly = TRUE AND country = 'Costa Rica';
What is the distribution of countries in our movie database?
CREATE TABLE Movies (id INT,title VARCHAR(255),country VARCHAR(255));
SELECT country, COUNT(*) AS count FROM Movies GROUP BY country;
What is the average threat intelligence score for the Asia region?
CREATE TABLE threat_intelligence (region VARCHAR(255),score NUMERIC); INSERT INTO threat_intelligence (region,score) VALUES ('Asia',70),('Europe',60),('Asia',75);
SELECT AVG(score) FROM threat_intelligence WHERE region = 'Asia';
What is the maximum price of eco-friendly fabrics for each textile vendor?
CREATE TABLE VendorEcoFabrics (id INT,vendor VARCHAR(20),fabric VARCHAR(20),price DECIMAL(5,2)); INSERT INTO VendorEcoFabrics (id,vendor,fabric,price) VALUES (1,'Vendor C','organic cotton',7.50),(2,'Vendor D','recycled polyester',9.00);
SELECT vendor, MAX(price) FROM VendorEcoFabrics WHERE fabric LIKE '%eco%' GROUP BY vendor;
List all satellites launched by Roscosmos before 2010.
CREATE TABLE satellites (satellite_id INT,name VARCHAR(100),company VARCHAR(100),launch_date DATE); INSERT INTO satellites (satellite_id,name,company,launch_date) VALUES (1,'Sputnik 1','Roscosmos','1957-10-04'),(2,'Sputnik 2','Roscosmos','1957-11-03'),(3,'Sputnik 3','Roscosmos','1958-05-15');
SELECT name FROM satellites WHERE company = 'Roscosmos' AND launch_date < '2010-01-01';
Which countries have the highest and lowest usage of sustainable materials in garment production?
CREATE TABLE Garment_Production_Countries (id INT,country VARCHAR,sustainable_material_usage DECIMAL);
SELECT country, sustainable_material_usage FROM (SELECT country, sustainable_material_usage, ROW_NUMBER() OVER (ORDER BY sustainable_material_usage DESC) rn1, ROW_NUMBER() OVER (ORDER BY sustainable_material_usage ASC) rn2 FROM Garment_Production_Countries) t WHERE rn1 = 1 OR rn2 = 1;
Delete peacekeeping operation records with missing start dates
CREATE TABLE peacekeeping (id INT PRIMARY KEY,operation_name VARCHAR(100),start_date DATE,end_date DATE,status VARCHAR(50));
DELETE FROM peacekeeping WHERE start_date IS NULL;
What is the total biomass of fish in the Tilapia farm?
CREATE TABLE FishBiomass (fish_id INT,farm_id INT,weight DECIMAL(5,2)); INSERT INTO FishBiomass (fish_id,farm_id,weight) VALUES (101,1,0.7),(102,1,0.8);
SELECT SUM(weight) total_biomass FROM FishBiomass WHERE farm_id = 1;
Calculate the percentage of posts related to 'food' that contain 'vegan' in the 'food' category.
CREATE TABLE posts (id INT,content TEXT,category TEXT);
SELECT (COUNT(*) * 100.0 / (SELECT COUNT(*) FROM posts WHERE category = 'food')) as percentage FROM posts WHERE category = 'food' AND content LIKE '%vegan%';
What is the total number of renewable energy projects completed in the states of New South Wales and Victoria since 2015?
CREATE TABLE Renewable_Energy_Projects (id INT,project_name VARCHAR(30),state VARCHAR(20),completion_year INT); INSERT INTO Renewable_Energy_Projects (id,project_name,state,completion_year) VALUES (1,'Solar Farm 1','New South Wales',2016),(2,'Wind Farm 2','New South Wales',2017),(3,'Geothermal Plant 3','New South Wales...
SELECT COUNT(*) FROM Renewable_Energy_Projects WHERE state IN ('New South Wales', 'Victoria') AND completion_year >= 2015;
How many events have been held in each month across all countries?
CREATE TABLE events (id INT,month VARCHAR(10),country VARCHAR(20),price DECIMAL(5,2));
SELECT month, COUNT(*) AS num_events FROM events GROUP BY month;
What is the total number of defense projects initiated by Harris Corporation in the Asia-Pacific region in 2018 and 2019?
CREATE TABLE defense_projects (company VARCHAR(255),region VARCHAR(255),year INT,num_projects INT); INSERT INTO defense_projects (company,region,year,num_projects) VALUES ('Harris Corporation','Asia-Pacific',2018,25),('Harris Corporation','Asia-Pacific',2019,30);
SELECT SUM(num_projects) FROM defense_projects WHERE company = 'Harris Corporation' AND region = 'Asia-Pacific' AND year IN (2018, 2019);
Show the five most recent satellite launches
CREATE TABLE satellite_launches (id INT PRIMARY KEY,satellite_name VARCHAR(255),country VARCHAR(255),launch_date DATE,orbit VARCHAR(255));
SELECT * FROM satellite_launches ORDER BY launch_date DESC LIMIT 5;
List the names of all copper mines in Peru that produced more than 8000 tons last year.
CREATE TABLE mines (id INT,name TEXT,location TEXT,production_volume INT,year INT); INSERT INTO mines (id,name,location,production_volume,year) VALUES (1,'Peruvian Mine','Peru',9000,2020); INSERT INTO mines (id,name,location,production_volume,year) VALUES (2,'Copper Mountain','Canada',7000,2020);
SELECT name FROM mines WHERE location = 'Peru' AND production_volume > 8000 AND mineral = 'copper' AND year = 2020;
What is the average quantity of products sold by each vendor, partitioned by vendor location, ordered by vendor name?
CREATE TABLE Vendor (VendorID INT,VendorName VARCHAR(50),Location VARCHAR(50),QuantitySold INT); INSERT INTO Vendor VALUES (1,'VendorA','LocationA',50),(2,'VendorB','LocationB',75);
SELECT VendorName, AVG(QuantitySold) OVER (PARTITION BY Location ORDER BY VendorName) AS AvgQuantitySoldByVendor FROM Vendor;
Add a new record to the 'Organizations' table with the name 'Save the Children', country 'USA', and category 'Children's Rights'
CREATE TABLE Organizations (id INT PRIMARY KEY,organization_name VARCHAR(255),country VARCHAR(255),category VARCHAR(255));
INSERT INTO Organizations (organization_name, country, category) VALUES ('Save the Children', 'USA', 'Children''s Rights');
What is the total number of military bases in the US and Canada, and the number of bases for each country?
CREATE TABLE military_bases (id INT,name TEXT,country TEXT); INSERT INTO military_bases (id,name,country) VALUES (1,'Fort Bragg','USA'),(2,'CFB Petawawa','Canada');
SELECT m.country, COUNT(m.id) as total_bases FROM military_bases m GROUP BY m.country;
What is the maximum number of workouts in a week for members who have a smartwatch?
CREATE TABLE Members (MemberID INT,HasSmartwatch BOOLEAN); CREATE TABLE Workouts (WorkoutID INT,MemberID INT,WorkoutDate DATE);
SELECT MAX(WorkoutsPerWeek) FROM (SELECT MemberID, COUNT(*)/7 AS WorkoutsPerWeek FROM Workouts INNER JOIN Members ON Workouts.MemberID = Members.MemberID WHERE Members.HasSmartwatch = TRUE GROUP BY MemberID) AS Subquery;
Update the Dysprosium production to 420 tons for the Canadian mine in Q2 2021.
CREATE TABLE mine (id INT,name TEXT,location TEXT,datetime DATE,Dysprosium_production FLOAT); INSERT INTO mine (id,name,location,datetime,Dysprosium_production) VALUES (1,'Canadian Mine','Canada','2021-04-01',350.6),(2,'Mexican Mine','Mexico','2021-04-15',180.2);
UPDATE mine SET Dysprosium_production = 420 WHERE location = 'Canada' AND QUARTER(datetime) = 2 AND YEAR(datetime) = 2021 AND name = 'Canadian Mine';
What is the average depth of marine protected areas in the Arctic, grouped by country?
CREATE TABLE marine_protected_areas (id INT,name VARCHAR(255),depth FLOAT,region VARCHAR(255)); INSERT INTO marine_protected_areas (id,name,depth,region) VALUES (1,'Svalbard Nature Reserve',300,'Arctic'); INSERT INTO marine_protected_areas (id,name,depth,region) VALUES (2,'Franz Josef Land MPA',500,'Arctic');
SELECT region, SUBSTRING(name, 1, (INSTR(name, ' ') - 1)) as country, AVG(depth) as avg_depth FROM marine_protected_areas WHERE region = 'Arctic' GROUP BY region, country;
List all the unique investors who have invested in companies based in both the US and Canada.
CREATE TABLE investments (investor_id INT,company_id INT,investment_date DATE); INSERT INTO investments (investor_id,company_id,investment_date) VALUES (1,1,'2020-01-01'),(1,2,'2019-06-15'),(2,3,'2021-03-04'),(2,4,'2020-12-31'),(3,5,'2022-05-23'); CREATE TABLE companies (id INT,name TEXT,country TEXT); INSERT INTO comp...
SELECT DISTINCT investor_id FROM investments i JOIN companies c ON i.company_id = c.id WHERE c.country IN ('USA', 'Canada') GROUP BY investor_id HAVING COUNT(DISTINCT c.country) = 2;
What is the average time taken by Bolt in the 100m sprint?
CREATE TABLE bolt_records (event VARCHAR(10),time DECIMAL(5,2)); INSERT INTO bolt_records (event,time) VALUES ('100m sprint',9.58),('100m sprint',9.79),('100m sprint',9.63);
SELECT AVG(time) FROM bolt_records WHERE event = '100m sprint';
What is the minimum budget for an ethical AI project?
CREATE TABLE ethical_ai_projects (id INT,project_name VARCHAR(50),budget INT); INSERT INTO ethical_ai_projects (id,project_name,budget) VALUES (1,'Ethical AI Guidelines Development',50000),(2,'AI Ethics Training Program',25000),(3,'AI Auditing Framework Design',75000);
SELECT MIN(budget) FROM ethical_ai_projects;
What are the most common types of threats detected in the last month?
CREATE TABLE threats (id INT,threat_type VARCHAR(50),date DATE); INSERT INTO threats (id,threat_type,date) VALUES (1,'phishing','2021-03-01'),(2,'malware','2021-03-02'),(3,'phishing','2021-03-03');
SELECT threat_type, ROW_NUMBER() OVER (PARTITION BY threat_type ORDER BY date DESC) as rank FROM threats WHERE date >= DATEADD(month, -1, GETDATE()) GROUP BY threat_type HAVING rank = 1;
Find the chemical product with the lowest safety score and the average environmental impact score of its manufacturing site.
CREATE TABLE product_safety (product_id INT,product_name TEXT,safety_score FLOAT,site_id INT); CREATE TABLE site_environment (site_id INT,environmental_score FLOAT); INSERT INTO product_safety (product_id,product_name,safety_score,site_id) VALUES (1,'Product A',75.3,101),(2,'Product B',87.6,102),(3,'Product C',68.9,103...
SELECT p.product_name, p.safety_score, AVG(s.environmental_score) as avg_environmental_score FROM product_safety p JOIN site_environment s ON p.site_id = s.site_id WHERE p.safety_score = (SELECT MIN(safety_score) FROM product_safety);
How many structures of each type ('dam', 'bridge', 'tunnel') are there in the 'civil_engineering_structures' table?
CREATE TABLE civil_engineering_structures (id INT,name VARCHAR(255),type VARCHAR(255),location VARCHAR(255));
SELECT type, COUNT(type) as structure_count FROM civil_engineering_structures GROUP BY type;
What are the top 5 customers by total purchases in the last month?
CREATE TABLE monthly_customer_purchases (customer_id INT,purchases DECIMAL(10,2)); INSERT INTO monthly_customer_purchases (customer_id,purchases) VALUES (1,150.00),(2,250.00),(3,350.00),(4,450.00),(5,550.00);
SELECT customer_id, purchases FROM monthly_customer_purchases ORDER BY purchases DESC LIMIT 5;
Calculate the production percentage of each product category.
CREATE TABLE products (id INT,name VARCHAR(50),category VARCHAR(50),production_date DATE); INSERT INTO products (id,name,category,production_date) VALUES (1,'Eco-friendly Mug','Home & Kitchen','2021-02-01'); INSERT INTO products (id,name,category,production_date) VALUES (2,'Solar Charger','Electronics','2021-03-15');
SELECT category, (COUNT(*)*100.0 / (SELECT COUNT(*) FROM products)) as production_percentage FROM products GROUP BY category;
Insert a new content item with type 'News' and language 'German'
CREATE TABLE Content (ContentID int,ContentType varchar(50),LanguageID int); CREATE TABLE Languages (LanguageID int,LanguageName varchar(50)); INSERT INTO Languages (LanguageID,LanguageName) VALUES (1,'English'),(2,'Spanish'),(3,'French'),(4,'German');
INSERT INTO Content (ContentID, ContentType, LanguageID) VALUES (4, 'News', (SELECT LanguageID FROM Languages WHERE LanguageName = 'German'));
Get total capacity of all warehouses
CREATE TABLE warehouses(id INT,name VARCHAR(255),capacity INT); INSERT INTO warehouses VALUES(1,'A01',5000),(2,'A02',7000),(3,'A03',6000);
SELECT SUM(capacity) FROM warehouses;
List all transactions related to explainable AI projects.
CREATE TABLE transactions (id INT PRIMARY KEY,project_name VARCHAR(50),category VARCHAR(50),amount FLOAT); INSERT INTO transactions (id,project_name,category,amount) VALUES (1,'XAI-101','Explainable AI',50000.0),(2,'SHAP','Feature Attribution',35000.0),(3,'LIME','Model Interpretation',28000.0),(4,'Anchors','Local Model...
SELECT * FROM transactions WHERE category = 'Explainable AI';
Find the deepest marine trench in the Indian Ocean
CREATE TABLE marine_trenches (ocean TEXT,trench TEXT,max_depth INTEGER);INSERT INTO marine_trenches (ocean,trench,max_depth) VALUES ('Pacific','Mariana Trench',10994),('Indian','Java Trench',7725);
SELECT ocean, trench, max_depth FROM marine_trenches WHERE ocean = 'Indian' AND max_depth = (SELECT MAX(max_depth) FROM marine_trenches WHERE ocean = 'Indian');
Which sustainable materials are used by the most manufacturers?
CREATE TABLE ManufacturerMaterials (manufacturer_id INT,manufacturer_name VARCHAR(255),material_type VARCHAR(255)); INSERT INTO ManufacturerMaterials (manufacturer_id,manufacturer_name,material_type) VALUES (1,'EcoFriendly Goods','Organic Cotton'),(2,'GreenCraft','Recycled Polyester'),(3,'SustainableFurniture','Reclaim...
SELECT material_type, COUNT(*) as num_manufacturers FROM ManufacturerMaterials GROUP BY material_type ORDER BY num_manufacturers DESC;
What is the total number of volunteers and total hours they have contributed, by city, for the current year?
CREATE TABLE volunteers (volunteer_id INT,city VARCHAR(50),total_hours INT); INSERT INTO volunteers (volunteer_id,city,total_hours) VALUES (1,'San Francisco',500),(2,'New York',300),(3,'Miami',700),(4,'Los Angeles',200);
SELECT city, SUM(total_hours) as total_hours, COUNT(*) as total_volunteers FROM volunteers WHERE YEAR(donation_date) = YEAR(GETDATE()) GROUP BY city;
Find the number of policies issued in 'Illinois' having a claim amount less than $500 and issued after '2020-01-01'.
CREATE TABLE policyholders (id INT,name TEXT,state TEXT); CREATE TABLE policies (id INT,policyholder_id INT,issue_date DATE,claim_amount FLOAT); INSERT INTO policyholders (id,name,state) VALUES (1,'Mike Brown','IL'); INSERT INTO policies (id,policyholder_id,issue_date,claim_amount) VALUES (1,1,'2020-02-01',400.00);
SELECT COUNT(policies.id) FROM policies INNER JOIN policyholders ON policies.policyholder_id = policyholders.id WHERE policies.claim_amount < 500 AND policies.issue_date > '2020-01-01' AND policyholders.state = 'IL';
What is the earliest joined date for each union member state?
CREATE TABLE union_members (id INT,name VARCHAR(50),state VARCHAR(2),joined_date DATE); INSERT INTO union_members (id,name,state,joined_date) VALUES (1,'John Doe','NY','2020-01-01'); INSERT INTO union_members (id,name,state,joined_date) VALUES (2,'Jane Smith','CA','2019-06-15'); INSERT INTO union_members (id,name,state...
SELECT state, MIN(joined_date) FROM union_members GROUP BY state;
How many co-ownership properties are available in each price range?
CREATE TABLE co_ownership_prices (property_id INT,price FLOAT,co_ownership BOOLEAN); INSERT INTO co_ownership_prices (property_id,price,co_ownership) VALUES (101,500000.00,TRUE),(102,400000.00,FALSE),(103,300000.00,TRUE),(104,700000.00,TRUE),(105,600000.00,FALSE); CREATE TABLE price_ranges (range_start FLOAT,range_end ...
SELECT pr.range_start, pr.range_end, COUNT(*) as num_properties FROM co_ownership_prices cop JOIN price_ranges pr ON cop.price BETWEEN pr.range_start AND pr.range_end WHERE co_ownership = TRUE GROUP BY pr.range_start, pr.range_end;
What is the ratio of funding from grants to total funding for each type of event?
CREATE TABLE events (id INT,type VARCHAR(20)); INSERT INTO events (id,type) VALUES (1,'Theater'),(2,'Dance'),(3,'Workshop'); CREATE TABLE funding (id INT,event_id INT,source VARCHAR(25),amount INT); INSERT INTO funding (id,event_id,source,amount) VALUES (1,1,'Grant 1',5000),(2,1,'Grant 2',3000),(3,2,'Sponsorship',4000)...
SELECT e.type, AVG(CASE WHEN f.source IN ('Grant 1', 'Grant 2') THEN f.amount ELSE 0 END) / AVG(f.amount) AS grant_ratio FROM events e JOIN funding f ON e.id = f.event_id GROUP BY e.type;
What is the minimum impact measurement for companies based in Europe?
CREATE TABLE companies (company_id INT,region VARCHAR(50),impact_measurement FLOAT); INSERT INTO companies (company_id,region,impact_measurement) VALUES (1,'Asia',9.2),(2,'Europe',7.6),(3,'Asia',8.9);
SELECT MIN(impact_measurement) FROM companies WHERE region = 'Europe';
What is the total budget allocated for disability accommodations and support programs in '2020'?
CREATE TABLE DisabilityAccommodations (year INT,budget DECIMAL(5,2)); INSERT INTO DisabilityAccommodations (year,budget) VALUES (2019,500000.00),(2020,750000.00); CREATE TABLE DisabilitySupportPrograms (year INT,budget DECIMAL(5,2)); INSERT INTO DisabilitySupportPrograms (year,budget) VALUES (2019,550000.00),(2020,8000...
SELECT SUM(DisabilityAccommodations.budget) + SUM(DisabilitySupportPrograms.budget) FROM DisabilityAccommodations, DisabilitySupportPrograms WHERE DisabilityAccommodations.year = 2020 AND DisabilitySupportPrograms.year = 2020;
List all cybersecurity incidents affecting the Australian government from 2018 to 2020, including the incident name and year.
CREATE TABLE CybersecurityIncidents (ID INT,Country VARCHAR(20),Name VARCHAR(50),Year INT); INSERT INTO CybersecurityIncidents (ID,Country,Name,Year) VALUES (1,'Australia','Parliament Hack',2019);
SELECT Name, Year FROM CybersecurityIncidents WHERE Country = 'Australia' AND Year BETWEEN 2018 AND 2020;
What is the average mental health score of students who have not completed any lifelong learning courses?
CREATE TABLE lifelong_learning (student_id INT,course TEXT,completion_date DATE,mental_health_score FLOAT); INSERT INTO lifelong_learning (student_id,course,completion_date,mental_health_score) VALUES (1,'Data Science','2022-01-10',70.5),(2,'Programming','2021-06-15',85.2),(3,'Data Science','2022-03-25',68.1);
SELECT AVG(mental_health_score) FROM lifelong_learning WHERE student_id NOT IN (SELECT student_id FROM lifelong_learning WHERE course IS NOT NULL);
How many flu cases were reported in each province in Canada?
CREATE TABLE flu_canada (flu_cases INT,province TEXT); INSERT INTO flu_canada (flu_cases,province) VALUES (50,'Ontario'),(75,'Quebec'),(60,'British Columbia');
SELECT province, SUM(flu_cases) AS total_flu_cases FROM flu_canada GROUP BY province;