instruction
stringlengths
0
1.06k
input
stringlengths
11
5.3k
response
stringlengths
2
4.44k
What is the average waste generated per garment for each manufacturer?
CREATE TABLE Manufacturers (ManufacturerID INT,ManufacturerName VARCHAR(100)); INSERT INTO Manufacturers (ManufacturerID,ManufacturerName) VALUES (1,'ABC Garments'),(2,'XYZ Textiles'); CREATE TABLE Waste (WasteID INT,ManufacturerID INT,WastePerGarment DECIMAL(5,2)); INSERT INTO Waste (WasteID,ManufacturerID,WastePerGar...
SELECT m.ManufacturerName, AVG(w.WastePerGarment) AS AvgWastePerGarment FROM Manufacturers m JOIN Waste w ON m.ManufacturerID = w.ManufacturerID GROUP BY m.ManufacturerName;
List the number of unique founders for companies in the edtech sector founded between 2010 and 2015.
CREATE TABLE companies (id INT,name TEXT,industry TEXT,founding_date DATE,founder_gender TEXT,founder_minority TEXT,founder_immigrant TEXT);
SELECT COUNT(DISTINCT founder_gender, founder_minority, founder_immigrant) FROM companies WHERE industry = 'Edtech' AND founding_date BETWEEN '2010-01-01' AND '2015-12-31';
What are the total sales for each region and product category, sorted by the highest sales?
CREATE TABLE sales_data (id INT PRIMARY KEY,product_name VARCHAR(100),region VARCHAR(100),sales_amount DECIMAL(10,2)); INSERT INTO sales_data (id,product_name,region,sales_amount) VALUES (1,'Shampoo','North America',1000.00); INSERT INTO sales_data (id,product_name,region,sales_amount) VALUES (2,'Conditioner','Europe',...
SELECT region, product_category, SUM(sales_amount) as total_sales FROM sales_data sd INNER JOIN (SELECT product_name, 'Hair Care' as product_category FROM sales_data WHERE product_name = 'Shampoo' OR product_name = 'Conditioner' GROUP BY product_name) pcat ON sd.product_name = pcat.product_name GROUP BY region, product...
Calculate the total number of childhood immunization doses administered, by type, in each region, for the year 2021.
CREATE TABLE immunizations (immunization_type VARCHAR(50),region VARCHAR(50),year INTEGER,doses_administered INTEGER); INSERT INTO immunizations (immunization_type,region,year,doses_administered) VALUES ('MMR','North',2021,12000),('Polio','North',2021,15000),('MMR','South',2021,10000),('Polio','South',2021,18000),('MMR...
SELECT region, immunization_type, SUM(doses_administered) as total_doses FROM immunizations WHERE year = 2021 GROUP BY region, immunization_type;
What are the top 3 most popular garment colors in terms of quantity sold?
CREATE TABLE sales (id INT,garment_type VARCHAR(20),color VARCHAR(20),price DECIMAL(10,2),quantity INT);
SELECT color, SUM(quantity) AS total_quantity_sold FROM sales GROUP BY color ORDER BY total_quantity_sold DESC LIMIT 3;
What are the top 2 non-cruelty-free cosmetic products by sales in the European region for 2022?
CREATE TABLE products (product_id INT,product_name VARCHAR(50),is_cruelty_free BOOLEAN,sales FLOAT); INSERT INTO products VALUES (1,'Lipstick',false,500.50),(2,'Mascara',false,300.00),(3,'Foundation',true,700.00); CREATE TABLE regions (region_id INT,region_name VARCHAR(50)); INSERT INTO regions VALUES (1,'Canada'),(2,'...
SELECT p.product_name, p.sales FROM products p INNER JOIN regions r ON p.product_id = r.region_id INNER JOIN time t ON p.product_id = t.time_id WHERE p.is_cruelty_free = false GROUP BY p.product_name, p.sales, r.region_name, t.year ORDER BY p.sales DESC LIMIT 2;
Identify customers who have an account balance greater than any of their previous balances for the same account type.
CREATE TABLE accounts (customer_id INT,account_type VARCHAR(20),balance DECIMAL(10,2),transaction_date DATE);
SELECT customer_id, account_type, balance FROM (SELECT customer_id, account_type, balance, LAG(balance) OVER (PARTITION BY customer_id, account_type ORDER BY transaction_date) AS prev_balance FROM accounts) AS lagged_accounts WHERE balance > prev_balance;
What is the total value of defense contracts signed by company 'MNO Corp' in Q1 2020?
CREATE TABLE defense_contracts (contract_id INT,company VARCHAR(255),value FLOAT,date DATE); INSERT INTO defense_contracts (contract_id,company,value,date) VALUES (3,'MNO Corp',300000,'2020-01-01'); INSERT INTO defense_contracts (contract_id,company,value,date) VALUES (4,'DEF Inc',450000,'2020-01-05');
SELECT SUM(value) FROM defense_contracts WHERE company = 'MNO Corp' AND date BETWEEN '2020-01-01' AND '2020-03-31';
What is the total number of community members who speak an endangered language in each region with more than 10 heritage sites?
CREATE TABLE regions (id INT,name TEXT,num_heritage_sites INT); INSERT INTO regions (id,name,num_heritage_sites) VALUES (1,'West Africa',12),(2,'Amazon Basin',3); CREATE TABLE countries (id INT,region_id INT,name TEXT,num_endangered_languages INT); INSERT INTO countries (id,region_id,name,num_endangered_languages) VALU...
SELECT r.id, r.name, SUM(c.num_members) FROM regions r JOIN countries c ON r.id = c.region_id JOIN communities com ON c.id = com.country_id WHERE r.num_heritage_sites > 10 AND com.endangered_language = true GROUP BY r.id;
Update the "price" to 200 for all records in the "tours" table where the "country" is "France"
CREATE TABLE tours (id INT,name VARCHAR(50),country VARCHAR(50),price INT);
UPDATE tours SET price = 200 WHERE country = 'France';
How many streams does 'Justin Bieber' have in total?
CREATE TABLE Streams (id INT,artist VARCHAR(255),count INT); INSERT INTO Streams (id,artist,count) VALUES (1,'Taylor Swift',10000000),(2,'Justin Bieber',8000000);
SELECT SUM(count) FROM Streams WHERE artist = 'Justin Bieber';
What is the total CO2 emissions for each menu category in the last year?
CREATE TABLE dish (dish_id INT,dish_name TEXT,category_id INT,waste_percentage DECIMAL(5,2),co2_emissions INT); INSERT INTO dish (dish_id,dish_name,category_id,waste_percentage,co2_emissions) VALUES (1,'Pizza Margherita',1,0.12,500),(2,'Veggie Burger',2,0.18,300); CREATE TABLE category (category_id INT,category_name TE...
SELECT c.category_name, SUM(d.co2_emissions) as total_co2_emissions FROM dish d JOIN category c ON d.category_id = c.category_id WHERE d.order_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR) GROUP BY c.category_name;
Which students with disabilities have not been assigned a mentor?
CREATE TABLE students (id INT,name VARCHAR(50),department VARCHAR(50),disability BOOLEAN); INSERT INTO students (id,name,department,disability) VALUES (1,'Alice Johnson','Engineering',TRUE),(2,'Bob Smith','Engineering',FALSE),(3,'Charlie Brown','Business',TRUE); CREATE TABLE mentors (id INT,student_id INT,mentor_name V...
SELECT students.name FROM students LEFT JOIN mentors ON students.id = mentors.student_id WHERE mentors.id IS NULL AND students.disability = TRUE;
Show the 'case_id' and 'case_type' for cases in the 'LegalAid' table where the 'case_type' is 'civil' or 'family'
CREATE TABLE LegalAid (case_id INT,case_type VARCHAR(10)); INSERT INTO LegalAid (case_id,case_type) VALUES (1,'civil'),(2,'criminal'),(3,'family'),(4,'criminal'),(5,'family');
SELECT case_id, case_type FROM LegalAid WHERE case_type IN ('civil', 'family');
How many mental health facilities exist in each state that have a cultural competency rating above 8?
CREATE TABLE MentalHealthFacilities (Id INT,State VARCHAR(255),CulturalCompetencyRating INT); INSERT INTO MentalHealthFacilities (Id,State,CulturalCompetencyRating) VALUES (1,'California',9); INSERT INTO MentalHealthFacilities (Id,State,CulturalCompetencyRating) VALUES (2,'Texas',7); INSERT INTO MentalHealthFacilities ...
SELECT State, COUNT(*) FROM MentalHealthFacilities WHERE CulturalCompetencyRating > 8 GROUP BY State;
What are the artifact names from 'SiteC'?
CREATE TABLE SiteC (id INT PRIMARY KEY,artifact_name VARCHAR(50));
SELECT artifact_name FROM SiteC;
Delete medical facilities in New Mexico with less than 5 beds.
CREATE TABLE medical_facilities (facility_id INT,facility_name TEXT,state TEXT,num_beds INT);
DELETE FROM medical_facilities WHERE facility_id IN (SELECT facility_id FROM medical_facilities WHERE state = 'New Mexico' AND num_beds < 5);
How many unique volunteers have participated in each program in 2019?
CREATE TABLE programs (program_id INT,program_name VARCHAR(50));CREATE TABLE volunteers (volunteer_id INT,volunteer_program_id INT); INSERT INTO programs (program_id,program_name) VALUES (1,'Education'),(2,'Environment'),(3,'Health'); INSERT INTO volunteers (volunteer_id,volunteer_program_id) VALUES (1,1),(2,1),(3,2),(...
SELECT p.program_name, COUNT(DISTINCT v.volunteer_id) as unique_volunteers FROM programs p JOIN volunteers v ON p.program_id = v.volunteer_program_id GROUP BY p.program_name;
What is the total biomass of fish species in the Pacific Ocean?
CREATE TABLE fish_species (species_name TEXT,biomass REAL,ocean TEXT); INSERT INTO fish_species (species_name,biomass,ocean) VALUES ('Tuna',5000.0,'Pacific'),('Salmon',2000.0,'Pacific'),('Shark',8000.0,'Pacific');
SELECT SUM(biomass) FROM fish_species WHERE ocean = 'Pacific';
What is the combined energy output of all renewable energy projects in the United Kingdom?
CREATE TABLE project_uk (project_name TEXT,type TEXT,capacity NUMERIC); INSERT INTO project_uk (project_name,type,capacity) VALUES ('Solar Park A','Solar',5000),('Solar Park B','Solar',6000),('Wind Farm C','Wind',8000),('Wind Farm D','Wind',9000),('Hydro Dam E','Hydro',10000);
SELECT SUM(capacity) FROM project_uk WHERE type IN ('Solar', 'Wind', 'Hydro');
What is the average square footage of green-certified buildings in the city of Seattle?
CREATE TABLE buildings (id INT,city VARCHAR,size INT,green_certified BOOLEAN);
SELECT AVG(size) FROM buildings WHERE city = 'Seattle' AND green_certified = TRUE;
Update age of 'Alice Johnson' to 25 in 'athletes' table
CREATE TABLE athletes (name VARCHAR(100),sport VARCHAR(50),country VARCHAR(50),age INT);
UPDATE athletes SET age = 25 WHERE name = 'Alice Johnson';
List the top 5 members who have burned the most calories from running workouts.
CREATE TABLE Members (MemberID INT,Age INT,Gender VARCHAR(10),MembershipType VARCHAR(20)); INSERT INTO Members (MemberID,Age,Gender,MembershipType) VALUES (1,35,'Female','Premium'),(2,45,'Male','Basic'),(3,30,'Female','Premium'); CREATE TABLE Workouts (WorkoutID INT,MemberID INT,Duration INT,WorkoutType VARCHAR(20),Cal...
SELECT m.MemberID, SUM(w.Calories) AS TotalCalories FROM Members m JOIN Workouts w ON m.MemberID = w.MemberID WHERE w.WorkoutType = 'Running' GROUP BY m.MemberID ORDER BY TotalCalories DESC LIMIT 5;
What is the average citizen satisfaction score for public services in each district of City X in 2022?
CREATE TABLE Satisfaction (Year INT,District VARCHAR(255),Score FLOAT); INSERT INTO Satisfaction (Year,District,Score) VALUES (2022,'District A',4.2); INSERT INTO Satisfaction (Year,District,Score) VALUES (2022,'District B',4.5); INSERT INTO Satisfaction (Year,District,Score) VALUES (2022,'District C',4.3);
SELECT District, AVG(Score) as AverageScore FROM Satisfaction WHERE Year = 2022 GROUP BY District;
What is the total number of electric vehicle trips in Berlin?
CREATE TABLE electric_vehicles (vehicle_id INT,trip_duration FLOAT,start_speed FLOAT,end_speed FLOAT,start_time TIMESTAMP,end_time TIMESTAMP,city VARCHAR(50)); INSERT INTO electric_vehicles (vehicle_id,trip_duration,start_speed,end_speed,start_time,end_time,city) VALUES (1,30.0,0.0,20.0,'2021-01-01 00:00:00','2021-01-0...
SELECT COUNT(*) FROM electric_vehicles WHERE city = 'Berlin';
What is the total duration of yoga classes offered in the entire month of March 2021?
CREATE TABLE Classes (ClassID int,ClassType varchar(10),ClassDuration int,ClassDate date); INSERT INTO Classes (ClassID,ClassType,ClassDuration,ClassDate) VALUES (1,'Yoga',60,'2021-03-01');
SELECT SUM(ClassDuration) FROM Classes WHERE ClassType = 'Yoga' AND MONTH(ClassDate) = 3 AND YEAR(ClassDate) = 2021;
What is the average number of delays for vessels in the Indian Ocean in the past year?
CREATE TABLE DelayRecords (Id INT,VesselName VARCHAR(50),Area VARCHAR(50),DelayDate DATETIME,Delay INT);
SELECT AVG(Delay) FROM DelayRecords WHERE Area = 'Indian Ocean' AND DelayDate >= DATEADD(YEAR, -1, GETDATE());
What is the average amount of socially responsible loans issued per month?
CREATE TABLE loans (loan_date DATE,loan_type VARCHAR(50),loan_amount DECIMAL(10,2));
SELECT EXTRACT(MONTH FROM loan_date) AS month, AVG(loan_amount) FROM loans WHERE loan_type = 'socially responsible' GROUP BY month;
Find the number of wells drilled in each country and the total production for each well
CREATE TABLE wells (well_id INT,well_name TEXT,country TEXT,production FLOAT); INSERT INTO wells (well_id,well_name,country,production) VALUES (1,'Well A','USA',1500000); INSERT INTO wells (well_id,well_name,country,production) VALUES (2,'Well B','Canada',1200000);
SELECT country, COUNT(well_id) AS num_wells, SUM(production) AS total_production FROM wells GROUP BY country;
What is the total installed capacity (in MW) of renewable energy sources in Germany?
CREATE TABLE energy_sources (id INT PRIMARY KEY,source VARCHAR(50),capacity_mw FLOAT,country VARCHAR(50)); INSERT INTO energy_sources (id,source,capacity_mw,country) VALUES (1,'Wind',60000.0,'Germany'),(2,'Solar',45000.0,'Germany'),(3,'Hydro',5000.0,'Germany');
SELECT SUM(capacity_mw) FROM energy_sources WHERE source IN ('Wind', 'Solar', 'Hydro') AND country = 'Germany';
What is the total revenue generated by hotels with sustainable tourism certifications in the last 3 months?
CREATE TABLE hotel_certifications (hotel_id INT,certification VARCHAR(50)); INSERT INTO hotel_certifications (hotel_id,certification) VALUES (1,'GreenLeaders'),(2,'EarthCheck'),(3,'GreenGlobe'),(4,'Sustainable Tourism'); CREATE TABLE hotel_revenue (hotel_id INT,revenue INT,date DATE); INSERT INTO hotel_revenue (hotel_i...
SELECT SUM(revenue) FROM hotel_revenue hr JOIN hotel_certifications hc ON hr.hotel_id = hc.hotel_id WHERE hc.certification IN ('GreenLeaders', 'EarthCheck', 'GreenGlobe', 'Sustainable Tourism') AND hr.date >= DATE_SUB(CURRENT_DATE, INTERVAL 3 MONTH);
Delete food 'Apple' from 'nutrition_facts' table
CREATE TABLE nutrition_facts (id INT PRIMARY KEY,food VARCHAR(255),calories INT,protein INT,carbs INT,fats INT); CREATE VIEW low_calorie_foods AS SELECT * FROM nutrition_facts WHERE calories < 100;
DELETE FROM nutrition_facts WHERE food = 'Apple';
Insert a new organization with ID 5 and name 'Greenpeace'
CREATE TABLE organizations (organization_id INT,name TEXT); INSERT INTO organizations (organization_id,name) VALUES (1,'World Wildlife Fund'),(2,'Doctors Without Borders'),(3,'American Red Cross'),(4,'UNICEF');
INSERT INTO organizations (organization_id, name) VALUES (5, 'Greenpeace');
What is the total number of laboratories in the state of New York?
CREATE TABLE laboratories (name TEXT,state TEXT,tests_performed INTEGER); INSERT INTO laboratories (name,state,tests_performed) VALUES ('Quest Diagnostics','New York',10000),('LabCorp','New York',9000),('BioReference Laboratories','New York',8000);
SELECT COUNT(*) FROM laboratories WHERE state = 'New York';
What is the contact information for all suppliers from India who provide textiles and have a sustainability rating above 3.5?
CREATE TABLE Suppliers (SupplierID INT,SupplierName VARCHAR(50),Country VARCHAR(50),Industry VARCHAR(50),SustainabilityRating DECIMAL(3,2),EthicalManufacturing BOOLEAN); INSERT INTO Suppliers (SupplierID,SupplierName,Country,Industry,SustainabilityRating,EthicalManufacturing) VALUES (1,'Green Supplies Inc.','USA','Gree...
SELECT SupplierName, Country, Industry FROM Suppliers WHERE Country = 'India' AND Industry = 'Textiles' AND SustainabilityRating > 3.5;
What is the total revenue generated from VR games?
CREATE TABLE game (game_id INT,game_title VARCHAR(50),game_genre VARCHAR(20),revenue INT); INSERT INTO game (game_id,game_title,game_genre,revenue) VALUES (1,'League of Legends','MOBA',1000000); INSERT INTO game (game_id,game_title,game_genre,revenue) VALUES (2,'Mario Kart','Racing',500000); INSERT INTO game (game_id,g...
SELECT SUM(revenue) FROM game WHERE game_genre = 'VR';
Identify the top 3 countries with the highest installed renewable energy capacity, ranked by capacity in descending order.
CREATE TABLE Country_Renewable_Energy (country VARCHAR(255),capacity INT); INSERT INTO Country_Renewable_Energy (country,capacity) VALUES ('Germany',100000),('Spain',55000),('Brazil',125000),('India',90000);
SELECT country, capacity FROM (SELECT country, capacity, RANK() OVER (ORDER BY capacity DESC) AS rank FROM Country_Renewable_Energy) AS ranked_countries WHERE rank <= 3;
List the top 3 countries with the highest number of eSports events in 2022.
CREATE TABLE Events (id INT,name VARCHAR(100),country VARCHAR(50),year INT);
SELECT country, COUNT(*) FROM Events WHERE year = 2022 GROUP BY country ORDER BY COUNT(*) DESC LIMIT 3;
What is the total cargo weight transported by each vessel type in the Indian Ocean, ordered by the total weight?
CREATE TABLE cargo (id INT,vessel_name VARCHAR(255),vessel_type VARCHAR(255),cargo_weight INT,port VARCHAR(255),unload_date DATE); INSERT INTO cargo (id,vessel_name,vessel_type,cargo_weight,port,unload_date) VALUES (1,'VesselA','Tanker',25000,'Colombo','2022-02-10');
SELECT vessel_type, SUM(cargo_weight) as total_weight FROM cargo WHERE port IN ('Mumbai', 'Colombo', 'Durban', 'Maputo', 'Mombasa') GROUP BY vessel_type ORDER BY total_weight DESC;
How many criminal cases were resolved through alternative justice measures in Texas and Florida?
CREATE TABLE alternative_justice_tx (case_id INT,state VARCHAR(20)); INSERT INTO alternative_justice_tx VALUES (1,'Texas'),(2,'Texas'),(3,'Texas'); CREATE TABLE alternative_justice_fl (case_id INT,state VARCHAR(20)); INSERT INTO alternative_justice_fl VALUES (4,'Florida'),(5,'Florida'),(6,'Florida');
SELECT COUNT(*) FROM alternative_justice_tx UNION ALL SELECT COUNT(*) FROM alternative_justice_fl;
List all garment types and their respective production quantities from the 'GarmentProduction' table, ordered by production quantity in descending order.
CREATE TABLE GarmentProduction (garment_type VARCHAR(50),quantity INT); INSERT INTO GarmentProduction (garment_type,quantity) VALUES ('T-Shirt',500),('Jeans',300),('Hoodie',200);
SELECT garment_type, quantity FROM GarmentProduction ORDER BY quantity DESC;
Delete the record for 'ManufacturerI' from the ethical_manufacturing table as they are not a valid manufacturer.
CREATE TABLE ethical_manufacturing (manufacturer_id INT,certification_status TEXT); INSERT INTO ethical_manufacturing (manufacturer_id,certification_status) VALUES (1,'Fair Trade Pending'),(2,'Not Certified'),(3,'Fair Trade Certified'),(4,'ManufacturerD'),(5,'ManufacturerE'),(6,'ManufacturerF'),(7,'ManufacturerG'),(8,'...
DELETE FROM ethical_manufacturing WHERE manufacturer_id = 9;
List all ports and the number of safety incidents that occurred there in the last month
CREATE TABLE Ports (PortID INT,PortName VARCHAR(50)); CREATE TABLE Incidents (IncidentID INT,IncidentType VARCHAR(50),PortID INT,IncidentDate DATE); INSERT INTO Ports (PortID,PortName) VALUES (1,'PortA'),(2,'PortB'); INSERT INTO Incidents (IncidentID,IncidentType,PortID,IncidentDate) VALUES (1,'Collision',1,'2022-01-05...
SELECT PortName, COUNT(*) FROM Incidents INNER JOIN Ports ON Incidents.PortID = Ports.PortID WHERE IncidentDate >= DATEADD(month, -1, GETDATE()) GROUP BY PortName;
List all vessels that have not complied with maritime law in the Mediterranean sea since 2020-01-01?
CREATE TABLE vessels (id INT,name TEXT,type TEXT,status TEXT,last_inspection_date DATE); INSERT INTO vessels (id,name,type,status,last_inspection_date) VALUES (1,'Vessel A','Cargo','Non-compliant','2021-03-15'); INSERT INTO vessels (id,name,type,status,last_inspection_date) VALUES (2,'Vessel B','Tanker','Compliant','20...
SELECT name FROM vessels WHERE status = 'Non-compliant' AND last_inspection_date < '2020-01-01' AND location = 'Mediterranean sea';
How many projects were completed in 'UrbanDevelopment' and 'RenewableEnergy' categories?
CREATE TABLE Infrastructure (id INT,category VARCHAR(20),completed DATE); INSERT INTO Infrastructure (id,category,completed) VALUES (1,'UrbanDevelopment','2020-01-01'),(2,'WaterSupply','2019-01-01'),(3,'UrbanDevelopment','2021-01-01'),(4,'RenewableEnergy','2020-05-01');
SELECT COUNT(*) FROM Infrastructure WHERE category IN ('UrbanDevelopment', 'RenewableEnergy');
What is the minimum ocean acidification level recorded in the Arctic region in the last 5 years?"
CREATE TABLE ocean_acidification_levels (location TEXT,acidification_level REAL,measurement_date DATE); CREATE TABLE arctic_region (region_name TEXT,region_description TEXT);
SELECT MIN(oal.acidification_level) FROM ocean_acidification_levels oal INNER JOIN arctic_region ar ON oal.location LIKE '%Arctic%' AND oal.measurement_date >= (CURRENT_DATE - INTERVAL '5 years');
Which cybersecurity strategies have been implemented in the 'North' region since 2016?
CREATE TABLE if not exists cybersecurity_strategies (region VARCHAR(50),strategy_name VARCHAR(50),year INT);
SELECT strategy_name FROM cybersecurity_strategies WHERE region = 'North' AND year >= 2016;
Update artifact quantities based on their type?
CREATE TABLE Artifacts (ArtifactID INT,ArtifactType VARCHAR(50),Quantity INT); INSERT INTO Artifacts (ArtifactID,ArtifactType,Quantity) VALUES (1,'Pottery',25),(2,'Tools',12),(3,'Pottery',30);
UPDATE Artifacts SET Quantity = CASE ArtifactType WHEN 'Pottery' THEN Quantity * 1.1 WHEN 'Tools' THEN Quantity * 1.2 END;
Delete all records with accommodation type "large_print_materials" from the "accommodations" table
CREATE TABLE accommodations (id INT,student_id INT,accommodation_type VARCHAR(255),cost FLOAT); INSERT INTO accommodations (id,student_id,accommodation_type,cost) VALUES (1,123,'visual_aids',250.0),(2,456,'audio_aids',100.0),(3,789,'large_print_materials',120.0),(4,890,'mobility_aids',300.0);
DELETE FROM accommodations WHERE accommodation_type = 'large_print_materials';
What is the average CO2 emission per international flight arriving in Australia?
CREATE TABLE flight_emissions (flight_number VARCHAR(255),origin VARCHAR(255),destination VARCHAR(255),year INT,co2_emission INT); INSERT INTO flight_emissions (flight_number,origin,destination,year,co2_emission) VALUES ('QF1','Los Angeles,USA','Sydney,Australia',2015,113000),('CX1','Hong Kong,China','Sydney,Australia'...
SELECT AVG(co2_emission) FROM flight_emissions WHERE destination = 'Sydney, Australia';
Select the policy_id, premium, sum_insured from policy_info where sum_insured > 50000
CREATE TABLE policy_info (policy_id INT,premium FLOAT,sum_insured INT); INSERT INTO policy_info (policy_id,premium,sum_insured) VALUES (1,1200.50,60000),(2,2500.00,70000),(3,1800.00,90000);
SELECT policy_id, premium, sum_insured FROM policy_info WHERE sum_insured > 50000;
What was the total carbon emissions reduction due to energy efficiency measures in Africa in 2020?
CREATE TABLE carbon_emissions (year INT,region VARCHAR(255),emissions_reduction FLOAT); INSERT INTO carbon_emissions (year,region,emissions_reduction) VALUES (2020,'Africa',200),(2020,'Europe',300),(2021,'Africa',250);
SELECT emissions_reduction FROM carbon_emissions WHERE year = 2020 AND region = 'Africa'
Find ingredients sourced from a specific country
Ingredients (ingredient_id,name,source,last_updated)
SELECT * FROM Ingredients WHERE source LIKE '%country%'
What are the top 3 cities with the most news articles published about them in the "news_articles" table, and their corresponding article counts?
CREATE TABLE news_articles (article_id INT,city VARCHAR(255));
SELECT city, COUNT(*) AS article_count FROM news_articles GROUP BY city ORDER BY article_count DESC LIMIT 3;
What are the most common types of ocean pollution in the Gulf of Mexico?
CREATE TABLE Gulf_of_Mexico_Pollution (pollutant TEXT,frequency INTEGER); INSERT INTO Gulf_of_Mexico_Pollution (pollutant,frequency) VALUES ('Oil Spills',32),('Plastic Waste',55);
SELECT pollutant, frequency FROM Gulf_of_Mexico_Pollution ORDER BY frequency DESC;
What is the maximum number of employees in a single mining operation?
CREATE TABLE mining_operations (id INT PRIMARY KEY,operation_name VARCHAR(50),location VARCHAR(50),num_employees INT);
SELECT MAX(num_employees) FROM mining_operations;
How many maritime safety incidents occurred in the Pacific Ocean in the last year?
CREATE TABLE incidents (location varchar(255),date date); INSERT INTO incidents (location,date) VALUES ('Pacific Ocean','2021-08-23'),('Atlantic Ocean','2022-02-12'),('Indian Ocean','2021-11-18');
SELECT COUNT(*) FROM incidents WHERE location = 'Pacific Ocean' AND date >= '2021-01-01' AND date < '2022-01-01';
What is the total number of mobile and broadband subscribers who have not made a complaint in the last 6 months?
CREATE TABLE mobile_subscribers(subscriber_id INT,last_complaint_date DATE); INSERT INTO mobile_subscribers(subscriber_id,last_complaint_date) VALUES (1,'2021-07-01'),(2,'2021-02-15'),(3,'2021-05-05'),(4,'2021-12-31'); CREATE TABLE broadband_subscribers(subscriber_id INT,last_complaint_date DATE); INSERT INTO broadband...
SELECT COUNT(*) FROM (SELECT subscriber_id FROM mobile_subscribers WHERE last_complaint_date < DATEADD(month, -6, GETDATE()) EXCEPT SELECT subscriber_id FROM broadband_subscribers WHERE last_complaint_date < DATEADD(month, -6, GETDATE()));
Update the energy efficiency rating of a green building in the green_buildings table
CREATE TABLE public.green_buildings (id SERIAL PRIMARY KEY,building_name VARCHAR(255),energy_efficiency_rating INTEGER); INSERT INTO public.green_buildings (building_name,energy_efficiency_rating) VALUES ('SolarTower',98),('WindScraper',97),('GeoDome',96);
WITH updated_rating AS (UPDATE public.green_buildings SET energy_efficiency_rating = 99 WHERE building_name = 'SolarTower' RETURNING *) INSERT INTO public.green_buildings (id, building_name, energy_efficiency_rating) SELECT id, building_name, 99 FROM updated_rating;
Which countries participated in space exploration missions to Venus?
CREATE TABLE Venus_Missions (Mission_ID INT,Mission_Name VARCHAR(50),Country VARCHAR(50),Launch_Year INT,PRIMARY KEY (Mission_ID)); INSERT INTO Venus_Missions (Mission_ID,Mission_Name,Country,Launch_Year) VALUES (1,'Venera 7','Soviet Union',1970),(2,'Magellan','United States',1989),(3,'Akatsuki','Japan',2010);
SELECT DISTINCT Country FROM Venus_Missions;
What is the average income in the "East" and "West" districts?
CREATE TABLE district (name VARCHAR(20),income FLOAT); INSERT INTO district (name,income) VALUES ('North',45000.0),('East',50000.0),('West',40000.0),('South',55000.0),('East',53000.0),('West',42000.0);
SELECT AVG(income) FROM district WHERE name IN ('East', 'West');
List policy numbers, claim amounts, and claim dates for claims that were processed between '2020-01-01' and '2020-12-31'
CREATE TABLE claims (claim_id INT,policy_number INT,claim_amount DECIMAL(10,2),claim_date DATE);
SELECT policy_number, claim_amount, claim_date FROM claims WHERE claim_date BETWEEN '2020-01-01' AND '2020-12-31';
What is the average temperature and precipitation in Brazil's Northeast region in June?
CREATE TABLE weather (country VARCHAR(255),region VARCHAR(255),month INT,temperature FLOAT,precipitation FLOAT); INSERT INTO weather (country,region,month,temperature,precipitation) VALUES ('Brazil','Northeast',6,25.3,120.5);
SELECT AVG(temperature), AVG(precipitation) FROM weather WHERE country = 'Brazil' AND region = 'Northeast' AND month = 6;
How many transactions were made by each employee in the Compliance department?
CREATE TABLE employees (id INT,name VARCHAR(50),department VARCHAR(50)); INSERT INTO employees (id,name,department) VALUES (1,'John Doe','Compliance'),(2,'Jane Smith','Risk Management'); CREATE TABLE transactions (employee_id INT,transaction_count INT); INSERT INTO transactions (employee_id,transaction_count) VALUES (1...
SELECT e.name, SUM(t.transaction_count) as total_transactions FROM employees e JOIN transactions t ON e.id = t.employee_id GROUP BY e.name;
List all mining sites with their respective environmental impact scores and the number of accidents that occurred at each site.
CREATE TABLE mining_sites (id INT,site_name VARCHAR(255),environmental_impact_score INT); INSERT INTO mining_sites (id,site_name,environmental_impact_score) VALUES (1,'Site A',80),(2,'Site B',60),(3,'Site C',90); CREATE TABLE accidents (id INT,mining_site_id INT,accident_count INT); INSERT INTO accidents (id,mining_sit...
SELECT s.site_name, s.environmental_impact_score, COALESCE(a.accident_count, 0) as total_accidents FROM mining_sites s LEFT JOIN accidents a ON s.id = a.mining_site_id;
What is the maximum number of players in a multiplayer game?
CREATE TABLE Games (GameID INT,MaxPlayers INT,Players INT); INSERT INTO Games (GameID,MaxPlayers,Players) VALUES (1,10,5);
SELECT MAX(MaxPlayers) FROM Games;
Find all the titles in the movies table that have a runtime over 180 minutes and were produced in the US or Canada.
CREATE TABLE movies (id INT,title VARCHAR(50),runtime INT,country VARCHAR(50));
SELECT title FROM movies WHERE runtime > 180 AND (country = 'US' OR country = 'Canada');
What is the average playtime per day for each player, in the past month?
CREATE TABLE PlayerDailyPlaytime (PlayerID INT,PlayDate DATE,Playtime INT); INSERT INTO PlayerDailyPlaytime (PlayerID,PlayDate,Playtime) VALUES (1,'2022-01-01',100); INSERT INTO PlayerDailyPlaytime (PlayerID,PlayDate,Playtime) VALUES (2,'2022-01-02',150);
SELECT PlayerID, AVG(Playtime) as AvgPlaytime FROM PlayerDailyPlaytime WHERE PlayDate >= '2022-01-01' AND PlayDate <= '2022-01-31' GROUP BY PlayerID
What is the total budget for defense diplomacy by each department, only for departments that have spent more than $5 million?
CREATE TABLE DefenseDiplomacy (id INT,department VARCHAR(50),budget INT);
SELECT department, SUM(budget) FROM DefenseDiplomacy GROUP BY department HAVING SUM(budget) > 5000000;
What is the total budget for programs focused on environmental sustainability?
CREATE TABLE Programs (ProgramID INT,ProgramName TEXT,Budget DECIMAL(10,2),FocusArea TEXT);
SELECT SUM(Budget) FROM Programs WHERE FocusArea = 'Environmental Sustainability';
Which artworks were visited the most by female visitors?
CREATE TABLE Artworks (ArtworkID INT,ArtworkName VARCHAR(100)); CREATE TABLE Visits (VisitID INT,VisitorID INT,ArtworkID INT,VisitDate DATE,Gender VARCHAR(10)); INSERT INTO Artworks (ArtworkID,ArtworkName) VALUES (1,'Mona Lisa'),(2,'Starry Night'),(3,'Sunflowers'),(4,'David'); INSERT INTO Visits (VisitID,VisitorID,Artw...
SELECT A.ArtworkName, COUNT(*) AS Visits FROM Artworks A JOIN Visits B ON A.ArtworkID = B.ArtworkID WHERE Gender = 'Female' GROUP BY A.ArtworkName ORDER BY Visits DESC;
What is the median adoption rate of electric vehicles in Europe?
CREATE TABLE AdoptionStatistics (Id INT,Country VARCHAR(100),Year INT,AdoptionRate FLOAT); INSERT INTO AdoptionStatistics (Id,Country,Year,AdoptionRate) VALUES (5,'Norway',2018,61.5),(6,'Sweden',2018,7.0),(7,'Norway',2019,65.7),(8,'Sweden',2019,9.0);
SELECT MEDIAN(AdoptionRate) FROM AdoptionStatistics WHERE Country IN ('Norway', 'Sweden') AND Year >= 2018;
What is the maximum landfill capacity in the state of New York in 2020?
CREATE TABLE landfill_capacity (state VARCHAR(255),year INT,capacity INT); INSERT INTO landfill_capacity (state,year,capacity) VALUES ('New York',2020,50000),('New York',2020,60000),('New York',2020,40000);
SELECT MAX(capacity) FROM landfill_capacity WHERE state = 'New York' AND year = 2020;
What is the maximum rating of songs in the 'hip-hop' genre?
CREATE TABLE songs_2 (id INT,title TEXT,rating FLOAT,genre TEXT); INSERT INTO songs_2 (id,title,rating,genre) VALUES (1,'Song1',4.8,'hip-hop'),(2,'Song2',4.5,'hip-hop');
SELECT MAX(rating) FROM songs_2 WHERE genre = 'hip-hop';
Which countries have the most community engagement?
CREATE TABLE community_engagement (ce_id INT,country_id INT,year INT,participants INT); INSERT INTO community_engagement VALUES (1,1,2015,5000),(2,1,2016,5500),(3,2,2015,7000),(4,2,2016,8000),(5,3,2015,6000),(6,3,2016,7000);
SELECT country_id, SUM(participants) FROM community_engagement GROUP BY country_id ORDER BY SUM(participants) DESC;
How many artworks were created by artists from France in the 19th century?
CREATE TABLE Artists (id INT,name TEXT,nationality TEXT,birth_year INT,death_year INT); INSERT INTO Artists (id,name,nationality,birth_year,death_year) VALUES (1,'Claude Monet','French',1840,1926),(2,'Paul Cezanne','French',1839,1906);
SELECT COUNT(*) FROM Artists WHERE nationality = 'French' AND birth_year <= 1900 AND death_year >= 1800;
What was the total budget allocated for social services in H1 2021?
CREATE TABLE Social_Budget (half INT,year INT,amount INT); INSERT INTO Social_Budget (half,year,amount) VALUES (1,2021,400000),(2,2021,500000),(1,2022,450000),(2,2022,550000);
SELECT SUM(amount) as Total_Budget FROM Social_Budget WHERE half = 1 AND year = 2021;
Update the compliance status to 'Non-Compliant' for vessels that have not been inspected in the last year.
CREATE TABLE Vessels (VesselID INT,VesselName VARCHAR(50),Manufacturer VARCHAR(50)); INSERT INTO Vessels (VesselID,VesselName,Manufacturer) VALUES (1,'Ocean Titan','ABC Shipyard'),(2,'Maritime Queen','Indian Ocean Shipbuilders'); CREATE TABLE SafetyInspections (InspectionID INT,VesselID INT,InspectionDate DATE); INSERT...
UPDATE Vessels v INNER JOIN SafetyInspections s ON v.VesselID = s.VesselID SET v.ComplianceStatus = 'Non-Compliant' WHERE s.InspectionDate < DATE_SUB(CURDATE(), INTERVAL 1 YEAR);
Find the number of wells drilled by CompanyD
CREATE TABLE wells (id INT,well_name VARCHAR(255),location VARCHAR(255),drill_year INT,company VARCHAR(255)); INSERT INTO wells (id,well_name,location,drill_year,company) VALUES (1,'Well001','Texas',2020,'CompanyA'); INSERT INTO wells (id,well_name,location,drill_year,company) VALUES (2,'Well002','Colorado',2019,'Compa...
SELECT COUNT(*) FROM wells WHERE company = 'CompanyD';
What is the three-month rolling average of workplace injury rates, partitioned by industry?
CREATE TABLE injuries (id INT,industry VARCHAR(255),injury_date DATE,rate DECIMAL(5,2)); INSERT INTO injuries (id,industry,injury_date,rate) VALUES (1,'Manufacturing','2022-01-01',4.5),(2,'Construction','2022-02-15',6.2),(3,'Manufacturing','2022-03-05',4.8),(4,'Construction','2022-04-10',5.9),(5,'Manufacturing','2022-0...
SELECT industry, AVG(rate) OVER (PARTITION BY industry ORDER BY injury_date ROWS BETWEEN 2 PRECEDING AND CURRENT ROW) as rolling_avg FROM injuries;
List all unique mine_names from 'coal_mines' table where 'yearly_production' is greater than 500000?
CREATE TABLE coal_mines (mine_name VARCHAR(50),yearly_production INT); INSERT INTO coal_mines (mine_name,yearly_production) VALUES ('ABC Coal Mine',550000),('DEF Coal Mine',400000),('GHI Coal Mine',600000);
SELECT mine_name FROM coal_mines WHERE yearly_production > 500000;
Update the cargo type of voyage V007 to 'containers'
vessel_voyage(voyage_id,cargo_type,cargo_weight)
UPDATE vessel_voyage SET cargo_type = 'containers' WHERE voyage_id = 'V007';
Who are the top 5 construction workers with the most working hours in California?
CREATE TABLE Workers (Id INT,Name VARCHAR(50),ProjectId INT,Hours FLOAT,State VARCHAR(50)); INSERT INTO Workers (Id,Name,ProjectId,Hours,State) VALUES (1,'John Doe',1,80,'California');
SELECT Name, SUM(Hours) AS TotalHours FROM Workers WHERE State = 'California' GROUP BY Name ORDER BY TotalHours DESC LIMIT 5;
Show the biosensor technology development data for the most recent date in the biosensor_development table
CREATE TABLE biosensor_development (id INT,sensor_type VARCHAR(50),data TEXT,date DATE); INSERT INTO biosensor_development (id,sensor_type,data,date) VALUES (1,'optical','Sensor data 1','2022-01-01'); INSERT INTO biosensor_development (id,sensor_type,data,date) VALUES (2,'electrochemical','Sensor data 2','2022-02-01');
SELECT * FROM biosensor_development WHERE date = (SELECT MAX(date) FROM biosensor_development);
What is the geopolitical risk assessment score for Russia on the latest military equipment sale date?
CREATE TABLE Military_Equipment_Sales (sale_date DATE,customer_country VARCHAR(50),sale_value INT); CREATE TABLE Geopolitical_Risk_Assessments (assessment_date DATE,customer_country VARCHAR(50),risk_score INT); INSERT INTO Military_Equipment_Sales (sale_date,customer_country,sale_value) VALUES ('2018-01-01','Russia',60...
SELECT R.customer_country, MAX(M.sale_date) AS latest_sale_date, R.risk_score AS risk_assessment_score FROM Military_Equipment_Sales M JOIN Geopolitical_Risk_Assessments R ON M.customer_country = R.customer_country WHERE M.sale_date = (SELECT MAX(sale_date) FROM Military_Equipment_Sales) GROUP BY R.customer_country, R....
Find the mining operations that have a high environmental impact score and also a low number of employees.
CREATE TABLE mining_operations (id INT,name VARCHAR(50),num_employees INT,environmental_impact_score INT);
SELECT name FROM mining_operations WHERE num_employees < (SELECT AVG(num_employees) FROM mining_operations) AND environmental_impact_score > (SELECT AVG(environmental_impact_score) FROM mining_operations);
What is the average delivery time for shipments from South Korea, partitioned by warehouse?
CREATE TABLE Warehouses (WarehouseID INT,WarehouseName VARCHAR(50),Country VARCHAR(50)); INSERT INTO Warehouses (WarehouseID,WarehouseName,Country) VALUES (1,'Seoul Warehouse','South Korea'); CREATE TABLE Shipments (ShipmentID INT,WarehouseID INT,DeliveryTime INT);
SELECT WarehouseID, AVG(DeliveryTime) OVER (PARTITION BY WarehouseID) AS AvgDeliveryTime FROM Shipments WHERE Country = 'South Korea';
What are the total budget allocations for healthcare and education services in the state of 'Sunshine'?
CREATE TABLE state_budget (state VARCHAR(20),service VARCHAR(20),allocation INT); INSERT INTO state_budget (state,service,allocation) VALUES ('Sunshine','Healthcare',1500000),('Sunshine','Education',2000000);
SELECT SUM(allocation) FROM state_budget WHERE state = 'Sunshine' AND service IN ('Healthcare', 'Education');
What is the total cost of military equipment for the Air Force?
CREATE TABLE Equipment (Id INT,Name VARCHAR(50),Type VARCHAR(50),Agency VARCHAR(50),Cost FLOAT); INSERT INTO Equipment (Id,Name,Type,Agency,Cost) VALUES (1,'M1 Abrams','Tank','Army',8000000); INSERT INTO Equipment (Id,Name,Type,Agency,Cost) VALUES (2,'F-35','Fighter Jet','Air Force',100000000); INSERT INTO Equipment (I...
SELECT SUM(Cost) FROM Equipment WHERE Agency = 'Air Force';
What is the average budget allocation for healthcare services in urban areas?
CREATE TABLE cities (id INT,name VARCHAR(20),type VARCHAR(10)); INSERT INTO cities VALUES (1,'CityA','Urban'),(2,'CityB','Rural'); CREATE TABLE budget_allocation (service VARCHAR(20),city_id INT,amount INT); INSERT INTO budget_allocation VALUES ('Healthcare',1,500000),('Healthcare',2,300000),('Education',1,700000),('Ed...
SELECT AVG(amount) FROM budget_allocation WHERE service = 'Healthcare' AND city_id IN (SELECT id FROM cities WHERE type = 'Urban');
How many songs were released by 'Female Artists' in the 'Pop' genre before 2010?
CREATE TABLE artists (artist_id INT,artist_name VARCHAR(100),gender VARCHAR(10)); INSERT INTO artists (artist_id,artist_name,gender) VALUES (1,'Taylor Swift','Female'),(2,'Ed Sheeran','Male'),(3,'Kendrick Lamar','Male'),(4,'Ariana Grande','Female'); CREATE TABLE songs (song_id INT,song_name VARCHAR(100),release_year IN...
SELECT COUNT(*) FROM songs s INNER JOIN artists a ON s.artist_id = a.artist_id WHERE a.gender = 'Female' AND s.genre = 'Pop' AND s.release_year < 2010;
List all fish species raised in sustainable farms in Norway.
CREATE TABLE fish_species (id INT,species TEXT,sustainable BOOLEAN); CREATE TABLE farm_species (farm_id INT,species_id INT); INSERT INTO fish_species (id,species,sustainable) VALUES (1,'Salmon',TRUE); INSERT INTO fish_species (id,species,sustainable) VALUES (2,'Cod',FALSE); INSERT INTO farm_species (farm_id,species_id)...
SELECT species FROM fish_species fs JOIN farm_species fss ON fs.id = fss.species_id WHERE fss.farm_id IN (SELECT id FROM farms WHERE country = 'Norway' AND sustainable = TRUE);
What is the number of distinct habitats in 'critical_habitats' table?
CREATE TABLE critical_habitats (id INT,habitat_name VARCHAR(50),animal_name VARCHAR(50)); INSERT INTO critical_habitats VALUES (1,'Rainforest','Jaguar'),(2,'Savannah','Lion');
SELECT COUNT(DISTINCT habitat_name) FROM critical_habitats;
What is the average salary of female employees in the education sector?
CREATE TABLE employees (id INT,gender TEXT,sector TEXT,salary FLOAT); INSERT INTO employees (id,gender,sector,salary) VALUES (1,'Female','Education',50000.00),(2,'Male','Healthcare',60000.00),(3,'Female','Education',55000.00),(4,'Male','Technology',70000.00);
SELECT AVG(salary) FROM employees WHERE gender = 'Female' AND sector = 'Education';
Calculate the total number of animals in each habitat, along with the total area, and display only habitats with more than 50 animals
CREATE TABLE habitats (id INT,name VARCHAR(255),area INT);CREATE TABLE animals (id INT,habitat_id INT,species VARCHAR(255)); INSERT INTO habitats (id,name,area) VALUES (1,'Rainforest',10000),(2,'Savannah',15000),(3,'Mountains',20000); INSERT INTO animals (id,habitat_id,species) VALUES (1,1,'Monkey'),(2,1,'Parrot'),(3,2...
SELECT h.name, SUM(h.area), COUNT(a.id) AS animal_count FROM habitats h INNER JOIN animals a ON h.id = a.habitat_id GROUP BY h.name HAVING COUNT(a.id) > 50;
What is the average price of organic skincare products?
CREATE TABLE products (product_id INT PRIMARY KEY,product_name TEXT,product_type TEXT,brand_id INT,is_organic BOOLEAN,price DECIMAL); INSERT INTO products (product_id,product_name,product_type,brand_id,is_organic,price) VALUES (1,'Cleanser','Skincare',1,true,19.99),(2,'Toner','Skincare',2,true,15.99),(3,'Moisturizer','...
SELECT AVG(price) FROM products WHERE product_type = 'Skincare' AND is_organic = true;
What is the average capacity of renewable energy plants in the United States?
CREATE TABLE renewable_energy_plants (id INT,name TEXT,country TEXT,capacity FLOAT); INSERT INTO renewable_energy_plants (id,name,country,capacity) VALUES (1,'Plant 1','USA',75.0),(2,'Plant 2','USA',120.0);
SELECT AVG(capacity) FROM renewable_energy_plants WHERE country = 'USA';
What is the average temperature difference between Field7 and Field8 for each day in the month of July?
CREATE TABLE Field7 (date DATE,temperature FLOAT); INSERT INTO Field7 VALUES ('2021-07-01',25),('2021-07-02',22); CREATE TABLE Field8 (date DATE,temperature FLOAT); INSERT INTO Field8 VALUES ('2021-07-01',27),('2021-07-02',23);
SELECT AVG(f7.temperature - f8.temperature) as avg_temperature_difference FROM Field7 f7 INNER JOIN Field8 f8 ON f7.date = f8.date WHERE EXTRACT(MONTH FROM f7.date) = 7;
What is the average age of military personnel in the 'Air Force'?
CREATE TABLE MilitaryPersonnel (id INT,name VARCHAR(100),rank VARCHAR(50),service VARCHAR(50),age INT); INSERT INTO MilitaryPersonnel (id,name,rank,service,age) VALUES (1,'John Doe','Colonel','Air Force',45); INSERT INTO MilitaryPersonnel (id,name,rank,service,age) VALUES (2,'Jane Smith','Captain','Navy',35);
SELECT AVG(age) FROM MilitaryPersonnel WHERE service = 'Air Force';
How many products have a rating of 4.8 or higher?
CREATE TABLE products (product_id INT,rating FLOAT); INSERT INTO products (product_id,rating) VALUES (1,4.5),(2,4.8),(3,3.2);
SELECT COUNT(*) FROM products WHERE rating >= 4.8;