instruction stringlengths 0 1.06k | input stringlengths 11 5.3k | response stringlengths 2 4.44k |
|---|---|---|
What is the average consumer awareness score for each country in the ethical fashion industry? | CREATE TABLE consumer_awareness_scores (country VARCHAR(50),score INT); INSERT INTO consumer_awareness_scores (country,score) VALUES ('Brazil',75),('Colombia',80),('Ecuador',85),('Peru',90),('Venezuela',70); | SELECT country, AVG(score) FROM consumer_awareness_scores GROUP BY country; |
What is the maximum number of electric vehicle charging stations in France? | CREATE TABLE Charging_Stations (country VARCHAR(50),quantity INT); INSERT INTO Charging_Stations (country,quantity) VALUES ('France',5000); | SELECT MAX(quantity) FROM Charging_Stations WHERE country = 'France'; |
How many unique donors have donated to any organization in the 'Environment' category? | CREATE TABLE donors (id INT,name VARCHAR(50)); CREATE TABLE donations (id INT,donor_id INT,organization_id INT,amount DECIMAL(10,2)); INSERT INTO donors (id,name) VALUES (1,'Donor1'),(2,'Donor2'),(3,'Donor3'),(4,'Donor4'),(5,'Donor5'); INSERT INTO donations (id,donor_id,organization_id,amount) VALUES (1,1,1,500),(2,2,1,700),(3,3,2,1000),(4,4,2,1200),(5,5,3,800); CREATE TABLE organizations (id INT,name VARCHAR(50),category VARCHAR(20)); INSERT INTO organizations (id,name,category) VALUES (1,'Org1','Environment'),(2,'Org2','Environment'),(3,'Org3','Education'); | SELECT COUNT(DISTINCT donor_id) FROM donations JOIN organizations ON donations.organization_id = organizations.id WHERE organizations.category = 'Environment'; |
Display the monthly water usage for the customer with ID 5 for the year 2020 | CREATE TABLE water_usage_2 (customer_id INT,usage_date DATE,amount FLOAT); INSERT INTO water_usage_2 (customer_id,usage_date,amount) VALUES (5,'2020-01-01',100),(5,'2020-02-01',120),(5,'2020-03-01',150),(5,'2020-04-01',180),(5,'2020-05-01',200),(5,'2020-06-01',220),(5,'2020-07-01',250),(5,'2020-08-01',280),(5,'2020-09-01',300),(5,'2020-10-01',330),(5,'2020-11-01',360),(5,'2020-12-01',390); | SELECT usage_date, amount FROM water_usage_2 WHERE customer_id = 5 AND usage_date BETWEEN '2020-01-01' AND '2020-12-31' ORDER BY usage_date ASC; |
What is the maximum number of research grants awarded to a single faculty member in the Engineering department? | CREATE TABLE grants (id INT,faculty_id INT,department VARCHAR(50),year INT,amount FLOAT); INSERT INTO grants (id,faculty_id,department,year,amount) VALUES (1,1,'Engineering',2020,10000.00),(2,1,'Engineering',2019,15000.00),(3,2,'Engineering',2020,20000.00),(4,3,'Engineering',2019,5000.00); | SELECT MAX(amount) FROM grants WHERE faculty_id IN (SELECT faculty_id FROM grants GROUP BY faculty_id HAVING COUNT(DISTINCT year) > 1 AND department = 'Engineering'); |
What is the total rainfall (in inches) for each region in Texas in the first half of 2022? | CREATE TABLE regions (id INT,name VARCHAR(255)); INSERT INTO regions (id,name) VALUES (1,'RegionA'),(2,'RegionB'),(3,'RegionC'); CREATE TABLE rainfall (region_id INT,rainfall DECIMAL(5,2),date DATE); INSERT INTO rainfall (region_id,rainfall,date) VALUES (1,2.5,'2022-01-01'),(1,3.0,'2022-01-02'),(2,1.5,'2022-01-01'),(2,2.0,'2022-01-02'),(3,3.5,'2022-01-01'),(3,4.0,'2022-01-02'); | SELECT region_id, SUM(rainfall) as total_rainfall FROM rainfall WHERE date BETWEEN '2022-01-01' AND '2022-06-30' GROUP BY region_id; |
Find the names of artists who had more than 15 million streams in any year. | CREATE TABLE Streams (artist_name VARCHAR(50),year INT,streams INT); INSERT INTO Streams (artist_name,year,streams) VALUES ('Taylor Swift',2018,12000000),('Drake',2018,18000000),('BTS',2018,20000000),('Billie Eilish',2018,10000000),('Taylor Swift',2019,15000000); | SELECT artist_name FROM Streams WHERE streams > 15000000; |
How many unique customers purchased an eighth of an ounce or more of any strain in Washington state? | CREATE TABLE Sales (sale_id INT,customer_id INT,strain_name TEXT,state TEXT,quantity DECIMAL(3,1)); INSERT INTO Sales (sale_id,customer_id,strain_name,state,quantity) VALUES (1,1001,'Bubba Kush','Washington',0.25),(2,1002,'Sour Diesel','Washington',0.5),(3,1003,'Blue Dream','Washington',0.125),(4,1004,'Purple Haze','Washington',0.75),(5,1005,'OG Kush','Washington',0.25); | SELECT COUNT(DISTINCT customer_id) as unique_customers FROM Sales WHERE state = 'Washington' AND quantity >= 0.125; |
How many ethical and non-ethical products have been sold in each region? | CREATE TABLE sales_summary (sale_id int,product_id int,production_location varchar,is_ethical boolean); | SELECT production_location, SUM(CASE WHEN is_ethical THEN 1 ELSE 0 END) AS ethical_sales, SUM(CASE WHEN NOT is_ethical THEN 1 ELSE 0 END) AS non_ethical_sales FROM sales_summary GROUP BY production_location; |
What is the total number of union members in each European country in 2020, grouped by country? | CREATE TABLE European_Union_Members (Country VARCHAR(255),Members_2020 INT); INSERT INTO European_Union_Members (Country,Members_2020) VALUES ('Germany',6000000),('France',5500000),('Italy',4500000); | SELECT Country, SUM(Members_2020) as Total_Members_2020 FROM European_Union_Members GROUP BY Country; |
Show the average cultural competency score for community health workers in each region | CREATE TABLE community_health_workers (id INT PRIMARY KEY,name VARCHAR(255),region VARCHAR(255),years_experience INT,cultural_competency_score INT); INSERT INTO community_health_workers (id,name,region,years_experience,cultural_competency_score) VALUES (1,'Ada Williams','Southeast',8,95),(2,'Brian Johnson','Midwest',5,80),(3,'Carla Garcia','West',12,90),(4,'Ella Jones','Northeast',6,85),(5,'Farhad Ahmed','South',10,93),(6,'Graciela Gutierrez','Central',11,94),(7,'Hee Jeong Lee','Northwest',7,87),(8,'Ibrahim Hussein','East',9,96),(9,'Jasmine Patel','Southwest',8,91); | SELECT region, AVG(cultural_competency_score) as avg_score FROM community_health_workers GROUP BY region; |
How many solar power projects are there in the 'Asia-Pacific' region with an installed capacity greater than 100 MW? | CREATE TABLE projects (id INT,name TEXT,region TEXT,capacity_mw FLOAT); INSERT INTO projects (id,name,region,capacity_mw) VALUES (1,'Solar Project A','Asia-Pacific',120.6); INSERT INTO projects (id,name,region,capacity_mw) VALUES (2,'Solar Project B','Europe',150.2); | SELECT COUNT(*) FROM projects WHERE region = 'Asia-Pacific' AND capacity_mw > 100; |
Which stations on the Blue Line have elevators? | CREATE TABLE Elevators (line VARCHAR(20),station VARCHAR(20),elevator BOOLEAN); INSERT INTO Elevators (line,station,elevator) VALUES ('Blue Line','State',true),('Blue Line','Government Center',false); | SELECT station FROM Elevators WHERE line = 'Blue Line' AND elevator = true; |
Add a new vessel to the 'vessels' table | CREATE TABLE vessels (id INT PRIMARY KEY,name VARCHAR(50),type VARCHAR(50),length FLOAT,year_built INT); | INSERT INTO vessels (id, name, type, length, year_built) VALUES (1, 'MV Ocean Wave', 'Container Ship', 300.0, 2010); |
What is the total cargo weight handled by each port in descending order? | CREATE TABLE ports (port_id INT,port_name VARCHAR(50),country VARCHAR(50)); INSERT INTO ports VALUES (1,'Port of Los Angeles','USA'); INSERT INTO ports VALUES (2,'Port of Rotterdam','Netherlands'); CREATE TABLE cargo (cargo_id INT,port_id INT,cargo_weight INT,handling_date DATE); INSERT INTO cargo VALUES (1,1,5000,'2022-01-01'); INSERT INTO cargo VALUES (2,2,7000,'2022-01-05'); | SELECT port_name, SUM(cargo_weight) as total_cargo_weight FROM cargo JOIN ports ON cargo.port_id = ports.port_id GROUP BY port_name ORDER BY total_cargo_weight DESC; |
What is the landfill capacity in Mexico City for 2018? | CREATE TABLE landfill_capacity (city VARCHAR(255),year INT,capacity_m3 INT); INSERT INTO landfill_capacity (city,year,capacity_m3) VALUES ('Mexico City',2018,2000000); | SELECT capacity_m3 FROM landfill_capacity WHERE city = 'Mexico City' AND year = 2018; |
What is the name, age, and country of donors who have donated more than $5000? | CREATE TABLE Donors (DonorID int,Name varchar(50),Age int,Country varchar(50),Donations int); INSERT INTO Donors (DonorID,Name,Age,Country,Donations) VALUES (1,'John Doe',30,'USA',5000),(2,'Jane Smith',45,'Canada',7000),(3,'Pedro Martinez',25,'Mexico',6000); | SELECT d.Name, d.Age, d.Country FROM Donors d WHERE d.Donations > 5000; |
Update the 'start_time' column to '2022-01-01 00:00:00' for the record with id 1001 in the 'trips' table | CREATE TABLE trips (id INT,start_time TIMESTAMP,end_time TIMESTAMP,route_id INT,vehicle_id INT); | UPDATE trips SET start_time = '2022-01-01 00:00:00' WHERE id = 1001; |
Find the financial wellbeing score for the customer with ID 98765? | CREATE TABLE financial_wellbeing (customer_id INT,score DECIMAL(3,2)); INSERT INTO financial_wellbeing (customer_id,score) VALUES (12345,75.2),(98765,82.6); | SELECT score FROM financial_wellbeing WHERE customer_id = 98765; |
Get the total number of startups founded by people with disabilities | CREATE TABLE startups(id INT,name TEXT,founding_year INT,founder_disability BOOLEAN); INSERT INTO startups (id,name,founding_year,founder_disability) VALUES (1,'Acme Inc',2010,true); INSERT INTO startups (id,name,founding_year,founder_disability) VALUES (2,'Beta Corp',2015,false); INSERT INTO startups (id,name,founding_year,founder_disability) VALUES (3,'Gamma LLC',2020,true); INSERT INTO startups (id,name,founding_year,founder_disability) VALUES (4,'Delta Inc',2018,false); | SELECT COUNT(*) FROM startups WHERE founder_disability = true; |
How many polar bear sightings occurred in the Arctic National Wildlife Refuge in 2021? | CREATE TABLE WildlifeSightings (species VARCHAR(255),location VARCHAR(255),year INT,sightings INT); INSERT INTO WildlifeSightings (species,location,year,sightings) VALUES ('Polar bear','Arctic National Wildlife Refuge',2021,150); INSERT INTO WildlifeSightings (species,location,year,sightings) VALUES ('Polar bear','Arctic National Wildlife Refuge',2021,120); | SELECT SUM(sightings) FROM WildlifeSightings WHERE species = 'Polar bear' AND location = 'Arctic National Wildlife Refuge' AND year = 2021; |
What is the percentage of female authors in academic publications in the past year? | CREATE TABLE authorships (id INT,author_gender VARCHAR(10),year INT,publication_id INT); INSERT INTO authorships (id,author_gender,year,publication_id) VALUES (1,'Female',2021,1); INSERT INTO authorships (id,author_gender,year,publication_id) VALUES (2,'Male',2019,2); CREATE TABLE publications (id INT,year INT,title VARCHAR(50)); INSERT INTO publications (id,year,title) VALUES (1,2021,'Artificial Intelligence'); INSERT INTO publications (id,year,title) VALUES (2,2020,'Machine Learning'); | SELECT (COUNT(a.id) / (SELECT COUNT(id) FROM authorships WHERE year = 2021)) * 100 AS percentage FROM authorships a WHERE a.author_gender = 'Female'; |
What is the population of the animal named Giraffe in the 'animals' table? | CREATE TABLE animals (id INT PRIMARY KEY,name VARCHAR(50),population INT); INSERT INTO animals (id,name,population) VALUES (1,'Tiger',2000),(2,'Elephant',3000),(3,'Giraffe',1000); | SELECT population FROM animals WHERE name = 'Giraffe'; |
What is the total budget for technology accessibility projects in Oceania in the last 5 years? | CREATE TABLE tech_accessibility_projects (project_id INT,region VARCHAR(20),budget DECIMAL(10,2),completion_year INT); INSERT INTO tech_accessibility_projects (project_id,region,budget,completion_year) VALUES (1,'Australia',100000.00,2016),(2,'New Zealand',150000.00,2015),(3,'Australia',120000.00,2018),(4,'New Zealand',180000.00,2019),(5,'Australia',110000.00,2017),(6,'New Zealand',130000.00,2020); | SELECT SUM(budget) FROM tech_accessibility_projects WHERE region IN ('Australia', 'New Zealand') AND completion_year BETWEEN 2015 AND 2020; |
List all aircraft models manufactured by AeroCo in the United States that have a manufacturing date on or after 2010-01-01. | CREATE TABLE Aircraft (aircraft_id INT,model VARCHAR(255),manufacturer VARCHAR(255),manufacturing_date DATE); | SELECT model FROM Aircraft WHERE manufacturer = 'AeroCo' AND manufacturing_date >= '2010-01-01' AND country = 'United States'; |
Which sustainable materials have the lowest sustainability score? | CREATE TABLE sustainable_fashion (id INT,product_id INT,material VARCHAR(255),sustainability_score INT); INSERT INTO sustainable_fashion (id,product_id,material,sustainability_score) VALUES (1,101,'Organic Cotton',90),(2,102,'Recycled Polyester',80),(3,103,'Tencel',85),(4,101,'Hemp',95),(5,102,'Bamboo',88); | SELECT material, sustainability_score FROM sustainable_fashion WHERE sustainability_score < 90; |
Find the number of female professors in the 'Humanities' department. | CREATE TABLE departments (dept_name VARCHAR(255),num_professors INT,num_female_professors INT); INSERT INTO departments (dept_name,num_professors,num_female_professors) VALUES ('Humanities',50,20),('Social_Sciences',60,25),('Sciences',70,30); | SELECT SUM(num_female_professors) FROM departments WHERE dept_name = 'Humanities'; |
Which ZIP codes have the highest number of confirmed COVID-19 cases? | CREATE TABLE zip_codes (id INT,zip VARCHAR(10),city VARCHAR(50),state VARCHAR(2)); CREATE TABLE covid_data (id INT,zip_code INT,confirmed_cases INT); INSERT INTO zip_codes (id,zip,city,state) VALUES (1,'12345','Albany','NY'),(2,'67890','Springfield','IL'); INSERT INTO covid_data (id,zip_code,confirmed_cases) VALUES (1,12345,250),(2,67890,300); | SELECT z.zip, z.city, z.state, c.confirmed_cases FROM zip_codes z JOIN covid_data c ON z.id = c.zip_code ORDER BY c.confirmed_cases DESC; |
Who are the top 3 clients with the highest account balance in Europe? | CREATE TABLE clients (client_id INT,name VARCHAR(50),region VARCHAR(50),account_balance DECIMAL(10,2)); INSERT INTO clients VALUES (1,'John Doe','Asia-Pacific',25000.00),(2,'Jane Smith','North America',35000.00),(3,'Alice Johnson','Asia-Pacific',18000.00),(4,'Bob Williams','Europe',45000.00),(5,'Charlie Brown','Europe',50000.00),(6,'David Kim','Europe',60000.00); | SELECT name, account_balance FROM clients WHERE region = 'Europe' ORDER BY account_balance DESC LIMIT 3; |
How many solar power projects were implemented in Australia, South Africa, and Egypt between 2016 and 2021? | CREATE TABLE solar_projects_2 (project_id INT,country VARCHAR(50),start_year INT,end_year INT); INSERT INTO solar_projects_2 (project_id,country,start_year,end_year) VALUES (1,'Australia',2017,2021),(2,'South Africa',2018,2020),(3,'Egypt',2016,2019),(4,'Australia',2019,2022),(5,'South Africa',2017,2021),(6,'Egypt',2018,2021),(7,'Australia',2016,2018); | SELECT COUNT(*) FROM solar_projects_2 WHERE country IN ('Australia', 'South Africa', 'Egypt') AND start_year BETWEEN 2016 AND 2021 AND end_year BETWEEN 2016 AND 2021; |
How many articles were published by 'The Denver Daily' in each month of the last year, including months without any articles? | CREATE TABLE the_denver_daily (publication_date DATE); | SELECT to_char(publication_date, 'Month') as month, COUNT(*) as articles FROM the_denver_daily WHERE publication_date > DATE('now','-1 year') GROUP BY month ORDER BY MIN(publication_date); |
What is the total revenue from sales of all garments, in the 'sales' table, that were sold in the last week? | CREATE TABLE sales (id INT,garment_id INT,garment_name VARCHAR(50),sale_price DECIMAL(10,2),sale_date DATE,quantity INT); | SELECT SUM(sale_price * quantity) AS total_revenue FROM sales WHERE sale_date >= DATE_SUB(CURDATE(), INTERVAL 1 WEEK); |
Find all suppliers from Africa who provide vegan options. | CREATE TABLE Suppliers (supplier_id INT,supplier_name VARCHAR(100),country VARCHAR(50),has_vegan_options BOOLEAN); INSERT INTO Suppliers (supplier_id,supplier_name,country,has_vegan_options) VALUES (1,'ABC Foods','USA',false),(2,'GreenVeggies','Canada',true),(3,'Farm Fresh','Kenya',true); | SELECT * FROM Suppliers WHERE country LIKE 'Africa%' AND has_vegan_options = true; |
What is the maximum fare for subway rides in London? | CREATE TABLE subway (id INT,city VARCHAR(50),fare DECIMAL(5,2)); INSERT INTO subway (id,city,fare) VALUES (1,'London',4.90),(2,'London',5.20),(3,'Berlin',3.10); | SELECT MAX(fare) FROM subway WHERE city = 'London'; |
What was the total investment in agricultural innovation projects in Nigeria between 2016 and 2018, and how many were implemented? | CREATE TABLE agri_innovation_projects (project VARCHAR(50),country VARCHAR(50),start_year INT,end_year INT,investment FLOAT); INSERT INTO agri_innovation_projects (project,country,start_year,end_year,investment) VALUES ('Precision Agriculture','Nigeria',2016,2018,1500000),('Climate-smart Farming','Nigeria',2016,2018,2000000); | SELECT SUM(investment), COUNT(*) FROM agri_innovation_projects WHERE country = 'Nigeria' AND start_year BETWEEN 2016 AND 2018 AND end_year BETWEEN 2016 AND 2018; |
How many students from underrepresented communities have enrolled since 2020 in lifelong learning programs? | CREATE TABLE students (student_id INT,enrollment_date DATE,underrepresented_community INT,program_id INT); INSERT INTO students (student_id,enrollment_date,underrepresented_community,program_id) VALUES (26,'2020-09-01',1,6),(27,'2021-01-15',0,7),(28,'2022-06-01',1,8),(29,'2023-02-28',0,9),(30,'2020-12-31',1,6); CREATE TABLE programs (program_id INT,program_type VARCHAR(20)); INSERT INTO programs (program_id,program_type) VALUES (6,'Lifelong Learning'),(7,'Short Course'),(8,'Workshop'),(9,'Certification'),(10,'Degree Program'); | SELECT COUNT(*) FROM students JOIN programs ON students.program_id = programs.program_id WHERE underrepresented_community = 1 AND enrollment_date >= '2020-01-01' AND programs.program_type = 'Lifelong Learning'; |
Find the animal species with the highest population in the 'animal_population' table | CREATE TABLE animal_population (id INT,animal_species VARCHAR(50),population INT); INSERT INTO animal_population (id,animal_species,population) VALUES (1,'Tiger',2000),(2,'Elephant',5000),(3,'Giraffe',8000),(4,'Tiger',3000),(5,'Panda',1500); | SELECT animal_species, MAX(population) FROM animal_population GROUP BY animal_species; |
What is the average amount of gold extracted per worker, for mines that extract more than 500 tons of gold per year? | CREATE TABLE mine (id INT,name VARCHAR(255),type VARCHAR(255),gold_tons INT,workers INT); INSERT INTO mine (id,name,type,gold_tons,workers) VALUES (1,'Alaskan Gold Mine','Open Pit',700,300),(2,'Colorado Gold Mine','Underground',400,200); | SELECT AVG(gold_tons/workers) as avg_gold_per_worker FROM mine WHERE gold_tons > 500; |
What is the total quantity of Lutetium extracted in Brazil and Argentina between 2015 and 2017? | CREATE TABLE Lutetium_Production (id INT,year INT,country VARCHAR(255),quantity FLOAT); | SELECT SUM(quantity) FROM Lutetium_Production WHERE year BETWEEN 2015 AND 2017 AND country IN ('Brazil', 'Argentina'); |
Identify countries with the fewest pollution control initiatives in the Arctic Ocean. | CREATE TABLE ArcticPollution (country TEXT,initiative_count INTEGER); INSERT INTO ArcticPollution (country,initiative_count) VALUES ('Russia',5),('Greenland',3),('Canada',7); CREATE TABLE Countries (country TEXT,region TEXT); INSERT INTO Countries (country,region) VALUES ('Russia','Europe'),('Greenland','North America'),('Canada','North America'); | SELECT Countries.country, ArcticPollution.initiative_count FROM Countries INNER JOIN ArcticPollution ON Countries.country = ArcticPollution.country ORDER BY initiative_count ASC; |
Display the average price of all fair trade and sustainable clothing items available in the 'EthicalFashion' database | CREATE TABLE item_details (item_id INT,item_name VARCHAR(255),is_fair_trade BOOLEAN,is_sustainable BOOLEAN,price DECIMAL(10,2)); | SELECT AVG(price) FROM item_details WHERE is_fair_trade = TRUE AND is_sustainable = TRUE; |
Update the "year" column to 2024 for records in the "trucks" table where the "make" is "Rivian" | CREATE TABLE trucks (id INT PRIMARY KEY,make VARCHAR(50),model VARCHAR(50),year INT); | UPDATE trucks SET year = 2024 WHERE make = 'Rivian'; |
What is the total cargo weight transported from Canada to the US West Coast ports in Q1 2022? | CREATE TABLE ports (id INT,name TEXT,country TEXT); INSERT INTO ports (id,name,country) VALUES (1,'Los Angeles','USA'),(2,'Seattle','USA'),(3,'Vancouver','Canada'); CREATE TABLE vessels (id INT,name TEXT,type TEXT,cargo_weight INT,port_id INT); INSERT INTO vessels (id,name,type,cargo_weight,port_id) VALUES (1,'CSCL Globe','Container',15000,1),(2,'OOCL Hong Kong','Container',19000,2),(3,'CMA CGM Marco Polo','Container',16000,3); | SELECT SUM(cargo_weight) FROM vessels WHERE port_id IN (SELECT id FROM ports WHERE country = 'Canada' AND name = 'Vancouver') AND EXTRACT(QUARTER FROM departure_date) = 1 AND EXTRACT(COUNTRY FROM IP_ADDRESS) = 'US'; |
What is the average age of psychologists who have conducted mental health awareness campaigns in Canada and the US, ordered by the campaign's reach? | CREATE TABLE psychologists (id INT,name TEXT,age INT,country TEXT,campaigns INT); INSERT INTO psychologists (id,name,age,country,campaigns) VALUES (1,'John Doe',45,'Canada',3),(2,'Jane Smith',35,'US',5),(3,'Alice Johnson',40,'Canada',2),(4,'Bob Brown',50,'US',4); | SELECT AVG(age) as avg_age FROM (SELECT age, ROW_NUMBER() OVER (PARTITION BY country ORDER BY campaigns DESC) as rn FROM psychologists WHERE country IN ('Canada', 'US')) t WHERE rn = 1; |
List all facilities along with their waste types | CREATE TABLE WasteTypes (waste_type_id INT PRIMARY KEY,name VARCHAR,description VARCHAR); CREATE TABLE Facilities (facility_id INT PRIMARY KEY,name VARCHAR,location VARCHAR,capacity INT,waste_type_id INT,FOREIGN KEY (waste_type_id) REFERENCES WasteTypes(waste_type_id)); INSERT INTO WasteTypes (waste_type_id,name,description) VALUES (1,'Recyclable Waste','Waste that can be recycled'); | SELECT Facilities.name AS facility_name, WasteTypes.name AS waste_type_name FROM Facilities INNER JOIN WasteTypes ON Facilities.waste_type_id = WasteTypes.waste_type_id; |
What is the average number of schools per region ('community_development')? | CREATE TABLE community_development.schools (id INT,name VARCHAR(50),capacity INT,region VARCHAR(50)); | SELECT region, AVG(capacity) FROM community_development.schools GROUP BY region; |
What are the total R&D expenditures and sales amounts for each drug, unpivoted and with a total row? | CREATE TABLE RnDExpenditures (drug_name VARCHAR(255),rnd_expenditure DECIMAL(10,2)); INSERT INTO RnDExpenditures (drug_name,rnd_expenditure) VALUES ('DrugD',60000.00),('DrugE',80000.00),('DrugF',40000.00); CREATE TABLE SalesData (drug_name VARCHAR(255),sales_quantity INT,sales_amount DECIMAL(10,2)); INSERT INTO SalesData (drug_name,sales_quantity,sales_amount) VALUES ('DrugD',120,18000.00),('DrugE',150,22500.00),('DrugF',75,10500.00); | SELECT drug_name, 'rnd_expenditure' as metric, SUM(rnd_expenditure) as value FROM RnDExpenditures GROUP BY drug_name UNION ALL SELECT drug_name, 'sales_amount' as metric, SUM(sales_amount) as value FROM SalesData GROUP BY drug_name UNION ALL SELECT 'Total', SUM(value) as value FROM (SELECT drug_name, 'rnd_expenditure' as metric, SUM(rnd_expenditure) as value FROM RnDExpenditures GROUP BY drug_name UNION ALL SELECT drug_name, 'sales_amount' as metric, SUM(sales_amount) as value FROM SalesData GROUP BY drug_name) sub; |
Update the description of an existing military technology in the "military_tech" table | CREATE TABLE military_tech (id INT,name VARCHAR(255),description TEXT,country VARCHAR(255)); INSERT INTO military_tech (id,name,description,country) VALUES (1,'Stealth Drone','Unmanned aerial vehicle with low observable radar profile','US'); | UPDATE military_tech SET description = 'Unmanned aerial vehicle with advanced stealth capabilities' WHERE name = 'Stealth Drone'; |
Which farmers are younger than 40 and own plots smaller than 0.5 acre? | CREATE TABLE Farmers (id INT PRIMARY KEY,name VARCHAR(100),age INT,location VARCHAR(100)); INSERT INTO Farmers (id,name,age,location) VALUES (1,'Olga Ivanova',35,'Russia'); INSERT INTO Farmers (id,name,age,location) VALUES (2,'Ahmed Hussein',42,'Egypt'); CREATE TABLE Plots (id INT PRIMARY KEY,farmer_id INT,size FLOAT,crop VARCHAR(50)); INSERT INTO Plots (id,farmer_id,size,crop) VALUES (1,1,0.4,'Potatoes'); INSERT INTO Plots (id,farmer_id,size,crop) VALUES (2,2,0.6,'Corn'); CREATE TABLE Currencies (id INT PRIMARY KEY,country VARCHAR(50),currency VARCHAR(50)); INSERT INTO Currencies (id,country,currency) VALUES (1,'Russia','Ruble'); INSERT INTO Currencies (id,country,currency) VALUES (2,'Egypt','Pound'); | SELECT f.name FROM Farmers f INNER JOIN Plots p ON f.id = p.farmer_id INNER JOIN Currencies c ON f.location = c.country WHERE f.age < 40 AND p.size < 0.5; |
List all healthcare centers and their capacities in 'Region4' | CREATE TABLE Regions (RegionName VARCHAR(20),HealthcareCenterName VARCHAR(20),HealthcareCenterCapacity INT); INSERT INTO Regions (RegionName,HealthcareCenterName,HealthcareCenterCapacity) VALUES ('Region4','CenterA',100),('Region4','CenterB',120); | SELECT HealthcareCenterName, HealthcareCenterCapacity FROM Regions WHERE RegionName = 'Region4'; |
List all cannabis strains sold in Arizona dispensaries in the second quarter of 2022, with sales greater than $10,000. | CREATE TABLE strain_sales (id INT,strain VARCHAR(20),sales DECIMAL(10,2),state VARCHAR(2),sale_date DATE); INSERT INTO strain_sales (id,strain,sales,state,sale_date) VALUES (1,'Purple Haze',12000,'AZ','2022-04-15'),(2,'Blue Dream',11000,'AZ','2022-05-20'),(3,'OG Kush',13000,'AZ','2022-06-05'); | SELECT strain FROM strain_sales WHERE state = 'AZ' AND sales > 10000 AND sale_date BETWEEN '2022-04-01' AND '2022-06-30'; |
How many permits were issued for commercial projects in Texas in 2022? | CREATE TABLE Permits (PermitID INT,ProjectID INT,PermitType CHAR(1),PermitDate DATE,State CHAR(2)); | SELECT COUNT(*) FROM Permits WHERE State='TX' AND PermitType='C' AND PermitDate BETWEEN '2022-01-01' AND '2022-12-31'; |
What was the total revenue for the 'Seafood' category in January 2021? | CREATE TABLE restaurant_revenue(restaurant_id INT,category VARCHAR(255),revenue DECIMAL(10,2),date DATE); | SELECT SUM(revenue) FROM restaurant_revenue WHERE category = 'Seafood' AND date BETWEEN '2021-01-01' AND '2021-01-31'; |
How many broadband customers have a connection speed of over 500 Mbps in the Southeast region? | CREATE TABLE subscribers (id INT,service VARCHAR(10),region VARCHAR(10)); INSERT INTO subscribers (id,service,region) VALUES (1,'broadband','Southeast'),(2,'mobile','Southeast'); CREATE TABLE speeds (subscriber_id INT,connection_speed INT); INSERT INTO speeds (subscriber_id,connection_speed) VALUES (1,600),(2,450); | SELECT COUNT(*) FROM speeds JOIN subscribers ON speeds.subscriber_id = subscribers.id WHERE subscribers.service = 'broadband' AND connection_speed > 500; |
Insert a new record in the 'resource_depletion' table for 'Gold' with a depletion_rate of 3% in the 'Australia' region | CREATE TABLE resource_depletion (resource VARCHAR(20),depletion_rate DECIMAL(5,2),region VARCHAR(20)); | INSERT INTO resource_depletion (resource, depletion_rate, region) VALUES ('Gold', 0.03, 'Australia'); |
Present the humanitarian assistance provided by the United Nations, sorted by year | CREATE TABLE humanitarian_assistance (id INT,provider_country VARCHAR(255),recipient_country VARCHAR(255),amount FLOAT,year INT); | SELECT recipient_country, amount FROM humanitarian_assistance WHERE provider_country = 'United Nations' ORDER BY year; |
What is the total quantity of recycled materials in stock? | CREATE TABLE materials (id INT,name TEXT,recycled BOOLEAN); CREATE TABLE inventory (id INT,material_id INT,quantity INT); INSERT INTO materials (id,name,recycled) VALUES (1,'Material A',true),(2,'Material B',false),(3,'Material C',true); INSERT INTO inventory (id,material_id,quantity) VALUES (1,1,50),(2,2,80),(3,3,100); | SELECT SUM(inventory.quantity) FROM inventory INNER JOIN materials ON inventory.material_id = materials.id WHERE materials.recycled = true; |
Who are the top 3 suppliers of sustainable materials by quantity? | CREATE TABLE suppliers (supplier_id INT,name VARCHAR(20),total_quantity INT); INSERT INTO suppliers (supplier_id,name,total_quantity) VALUES (1,'EcoFibers',5000),(2,'GreenMaterials',3000),(3,'SustainableSource',7000); CREATE TABLE supplies (supply_id INT,supplier_id INT,material_id INT,quantity INT); INSERT INTO supplies (supply_id,supplier_id,material_id,quantity) VALUES (1,1,1,1000),(2,2,2,2000),(3,3,3,3000); | SELECT suppliers.name, SUM(supplies.quantity) AS total_quantity FROM suppliers JOIN supplies ON suppliers.supplier_id = supplies.supplier_id GROUP BY suppliers.name ORDER BY total_quantity DESC LIMIT 3; |
Which tilapia farms in Kenya have experienced dissolved oxygen levels below 5 ppm in the last week? | CREATE TABLE tilapia_farms (id INT,name TEXT,country TEXT,latitude DECIMAL(9,6),longitude DECIMAL(9,6)); INSERT INTO tilapia_farms (id,name,country,latitude,longitude) VALUES (1,'Farm I','Kenya',-0.456789,36.987654); INSERT INTO tilapia_farms (id,name,country,latitude,longitude) VALUES (2,'Farm J','Kenya',-0.567890,37.890123); CREATE TABLE tilapia_water_data (id INT,farm_id INT,timestamp TIMESTAMP,dissolved_oxygen DECIMAL(4,2)); INSERT INTO tilapia_water_data (id,farm_id,timestamp,dissolved_oxygen) VALUES (1,1,'2022-06-01 00:00:00',4.8); INSERT INTO tilapia_water_data (id,farm_id,timestamp,dissolved_oxygen) VALUES (2,1,'2022-06-02 00:00:00',5.2); INSERT INTO tilapia_water_data (id,farm_id,timestamp,dissolved_oxygen) VALUES (3,2,'2022-06-01 00:00:00',4.9); INSERT INTO tilapia_water_data (id,farm_id,timestamp,dissolved_oxygen) VALUES (4,2,'2022-06-02 00:00:00',5.1); | SELECT twd.farm_id, tf.name FROM tilapia_water_data twd JOIN tilapia_farms tf ON twd.farm_id = tf.id WHERE tf.country = 'Kenya' AND twd.dissolved_oxygen < 5 AND twd.timestamp >= NOW() - INTERVAL 1 WEEK; |
What is the total number of hospitals and their types in the Pacific region? | CREATE TABLE hospitals (name VARCHAR(255),type VARCHAR(255),region VARCHAR(255)); INSERT INTO hospitals (name,type,region) VALUES ('Hospital A','Public','Pacific'),('Hospital B','Private','Pacific'),('Hospital C','Teaching','Pacific'),('Hospital D','Public','Atlantic'),('Hospital E','Private','Atlantic'); | SELECT type, COUNT(*) FROM hospitals WHERE region = 'Pacific' GROUP BY type; |
What is the average number of hospital beds per hospital in hospitals located in Texas? | CREATE TABLE hospitals (id INT PRIMARY KEY,name VARCHAR(255),beds INT,location VARCHAR(255)); INSERT INTO hospitals (id,name,beds,location) VALUES (1,'Johns Hopkins Hospital',1138,'Baltimore,MD'); INSERT INTO hospitals (id,name,beds,location) VALUES (2,'Massachusetts General Hospital',999,'Boston,MA'); INSERT INTO hospitals (id,name,beds,location) VALUES (3,'Texas Medical Center',1000,'Houston,TX'); | SELECT AVG(beds) FROM hospitals WHERE location LIKE '%Texas%'; |
Add a new row to the carbon_offset_programs table for a program with id 6, name 'Public Transportation', start_date 2024-01-01 and end_date 2026-12-31 | CREATE TABLE carbon_offset_programs (id INT,name TEXT,start_date DATE,end_date DATE); | INSERT INTO carbon_offset_programs (id, name, start_date, end_date) VALUES (6, 'Public Transportation', '2024-01-01', '2026-12-31'); |
Which warehouse in 'Toronto' has the highest total weight of shipments? | CREATE TABLE Warehouse (id INT,name VARCHAR(20),city VARCHAR(20)); INSERT INTO Warehouse (id,name,city) VALUES (1,'Toronto Warehouse 1','Toronto'),(2,'Montreal Warehouse','Montreal'); CREATE TABLE Shipment (id INT,weight INT,warehouse_id INT); INSERT INTO Shipment (id,weight,warehouse_id) VALUES (101,12000,1),(102,15000,1),(103,8000,2); | SELECT w.name, SUM(s.weight) as total_weight FROM Warehouse w JOIN Shipment s ON w.id = s.warehouse_id WHERE w.city = 'Toronto' GROUP BY w.id ORDER BY total_weight DESC LIMIT 1; |
What are the names and prices of the 3 most expensive hotels in Oceania? | CREATE TABLE Hotels_Oceania (id INT,name VARCHAR(50),price DECIMAL(5,2),continent VARCHAR(50)); INSERT INTO Hotels_Oceania (id,name,price,continent) VALUES (1,'Pacific Palace',450.00,'Oceania'),(2,'Coral Reef Resort',380.00,'Oceania'),(3,'Island Breeze Hotel',290.00,'Oceania'); | SELECT name, price FROM Hotels_Oceania ORDER BY price DESC LIMIT 3; |
What is the average number of calories burned in workouts per user in Germany? | CREATE TABLE workouts (id INT,user_id INT,workout_date DATE,calories INT,country VARCHAR(50)); INSERT INTO workouts (id,user_id,workout_date,calories,country) VALUES (1,123,'2022-01-01',300,'USA'); INSERT INTO workouts (id,user_id,workout_date,calories,country) VALUES (2,456,'2022-01-02',400,'Canada'); | SELECT AVG(calories) FROM workouts WHERE country = 'Germany' GROUP BY user_id; |
Which AI researchers have not published any papers? | CREATE TABLE ai_researcher(id INT PRIMARY KEY,name VARCHAR(50),country VARCHAR(50)); INSERT INTO ai_researcher (id,name,country) VALUES (1,'Alice','USA'),(2,'Bob','Canada'),(3,'Charlie','UK'),(4,'Dave','India'); CREATE TABLE ai_papers(id INT PRIMARY KEY,title VARCHAR(50),researcher_id INT); INSERT INTO ai_papers (id,title,researcher_id) VALUES (1,'Fair AI',1),(2,'AI Safety',3),(3,'AI Ethics',1),(4,'Explainable AI for AI Safety',3); | SELECT r.name FROM ai_researcher r LEFT JOIN ai_papers p ON r.id = p.researcher_id WHERE p.id IS NULL; |
What is the count of intelligence operations conducted in the 'Asia-Pacific' region in the last month? | CREATE TABLE intelligence_operations (id INT,operation TEXT,region TEXT,operation_date DATE); INSERT INTO intelligence_operations (id,operation,region,operation_date) VALUES (1,'Operation Red Falcon','Asia-Pacific','2021-07-08'),(2,'Operation Iron Fist','Asia-Pacific','2021-08-12'),(3,'Operation Black Swan','Asia-Pacific','2021-06-27'); | SELECT COUNT(*) FROM intelligence_operations WHERE region = 'Asia-Pacific' AND operation_date >= DATEADD(month, -1, GETDATE()); |
Calculate the average budget for completed rural infrastructure projects in Southeast Asia. | CREATE TABLE rural_infra_proj (id INT,name VARCHAR(255),region VARCHAR(255),budget FLOAT,status VARCHAR(255)); INSERT INTO rural_infra_proj (id,name,region,budget,status) VALUES (1,'Bridge Construction','Southeast Asia',120000.00,'completed'); | SELECT AVG(budget) FROM rural_infra_proj WHERE region = 'Southeast Asia' AND status = 'completed'; |
Identify the 10 ships with the highest average cargo weight per voyage in 2022. | CREATE TABLE voyage (voyage_id INT,ship_id INT,voyage_date DATE,total_cargo_weight INT); INSERT INTO voyage VALUES (1,1,'2022-02-10',6000); INSERT INTO voyage VALUES (2,2,'2022-03-25',8000); CREATE TABLE ship_capacity (ship_id INT,max_cargo_capacity INT); INSERT INTO ship_capacity VALUES (1,10000); INSERT INTO ship_capacity VALUES (2,12000); | SELECT s.ship_name, AVG(v.total_cargo_weight) as avg_cargo_weight FROM ship s JOIN ship_capacity sc ON s.ship_id = sc.ship_id JOIN voyage v ON s.ship_id = v.ship_id WHERE v.voyage_date >= '2022-01-01' AND v.voyage_date < '2023-01-01' GROUP BY s.ship_name ORDER BY avg_cargo_weight DESC LIMIT 10; |
What is the total area of fields with soil type 'loamy'? | CREATE TABLE fields (id INT,field_name VARCHAR(255),area FLOAT,soil_type VARCHAR(255)); INSERT INTO fields (id,field_name,area,soil_type) VALUES (1,'field1',10.5,'loamy'),(2,'field2',12.3,'sandy'),(3,'field3',8.9,'loamy'); | SELECT SUM(area) FROM fields WHERE soil_type = 'loamy'; |
Who are the top 3 suppliers of organic cotton in India? | CREATE TABLE Suppliers (id INT,name VARCHAR(255),material VARCHAR(255),quantity INT,country VARCHAR(255)); INSERT INTO Suppliers (id,name,material,quantity,country) VALUES (1,'Supplier A','Organic Cotton',5000,'India'); INSERT INTO Suppliers (id,name,material,quantity,country) VALUES (2,'Supplier B','Organic Cotton',4000,'India'); INSERT INTO Suppliers (id,name,material,quantity,country) VALUES (3,'Supplier C','Organic Cotton',3500,'India'); | SELECT name, SUM(quantity) FROM Suppliers WHERE country = 'India' AND material = 'Organic Cotton' GROUP BY name ORDER BY SUM(quantity) DESC LIMIT 3 |
Identify the total number of military vehicles manufactured in the last 5 years. | CREATE TABLE military_vehicles (id INT,manufacturer VARCHAR(50),year INT,quantity INT); INSERT INTO military_vehicles (id,manufacturer,year,quantity) VALUES (1,'ABC Corp',2015,500); INSERT INTO military_vehicles (id,manufacturer,year,quantity) VALUES (2,'XYZ Inc',2018,800); | SELECT SUM(quantity) FROM military_vehicles WHERE year >= (SELECT YEAR(CURRENT_DATE) - 5); |
What is the total number of properties in the city of Berkeley that are both green-certified and co-owned? | CREATE TABLE properties (id INT,city VARCHAR(20),green_certified BOOLEAN,co_owned BOOLEAN); INSERT INTO properties (id,city,green_certified,co_owned) VALUES (1,'Berkeley',true,true),(2,'Berkeley',false,false),(3,'Berkeley',true,false); | SELECT COUNT(*) FROM properties WHERE city = 'Berkeley' AND green_certified = true AND co_owned = true; |
What is the average age of male members from the FitnessMembers table? | CREATE TABLE FitnessMembers (member_id INT,name VARCHAR(50),age INT,gender VARCHAR(10)); INSERT INTO FitnessMembers (member_id,name,age,gender) VALUES (1,'John Doe',25,'Male'); INSERT INTO FitnessMembers (member_id,name,age,gender) VALUES (2,'Jane Smith',30,'Female'); INSERT INTO FitnessMembers (member_id,name,age,gender) VALUES (3,'Alice Johnson',35,'Female'); INSERT INTO FitnessMembers (member_id,name,age,gender) VALUES (4,'Bob Brown',40,'Male'); | SELECT AVG(age) FROM FitnessMembers WHERE gender = 'Male'; |
Delete the record of a customer from the North America region with size 12? | CREATE TABLE customers (customer_id INT PRIMARY KEY,region VARCHAR(50),size INT); INSERT INTO customers (customer_id,region,size) VALUES (1,'Asia-Pacific',14),(2,'North America',12),(3,'Europe',16); | DELETE FROM customers WHERE region = 'North America' AND size = 12; |
Insert new aircraft model data with specific flight hours | CREATE TABLE Aircraft (ID INT,Model VARCHAR(50),FlightHours INT); INSERT INTO Aircraft (ID,Model,FlightHours) VALUES (1,'B747',120000),(2,'A320',90000),(3,'A380',150000),(4,'B777',200000); | INSERT INTO Aircraft (ID, Model, FlightHours) VALUES (5, 'Dreamliner', 180000); |
Which wells have a production quantity greater than 5500? | CREATE TABLE well_production (well_name TEXT,production_quantity INT); INSERT INTO well_production (well_name,production_quantity) VALUES ('Well A',6000),('Well B',5000),('Well C',5500),('Well D',6500); | SELECT well_name FROM well_production WHERE production_quantity > 5500; |
Calculate the sum of labor costs for 'Electrical' workers in 'Toronto' for the year 2020. | CREATE TABLE labor_costs (worker_id INT,city VARCHAR(20),sector VARCHAR(20),hourly_wage DECIMAL(5,2),hours_worked INT,record_date DATE); INSERT INTO labor_costs (worker_id,city,sector,hourly_wage,hours_worked,record_date) VALUES (3,'Toronto','Electrical',35.5,180,'2020-01-01'); INSERT INTO labor_costs (worker_id,city,sector,hourly_wage,hours_worked,record_date) VALUES (4,'Toronto','Electrical',34.8,176,'2020-02-15'); | SELECT SUM(hourly_wage * hours_worked) FROM labor_costs WHERE city = 'Toronto' AND sector = 'Electrical' AND EXTRACT(YEAR FROM record_date) = 2020; |
What is the total capacity of vessels in the 'fleet_management' table by type? | CREATE TABLE fleet_management (id INT,name VARCHAR(50),type VARCHAR(50),capacity INT); | SELECT type, SUM(capacity) FROM fleet_management GROUP BY type; |
What is the total number of animals (in the 'animals' table) that have a population size greater than 500? | CREATE TABLE animals (id INT,name VARCHAR(50),species VARCHAR(50),population_size INT); INSERT INTO animals (id,name,species,population_size) VALUES (1,'Lion','Felidae',550); | SELECT COUNT(*) FROM animals WHERE population_size > 500; |
What is the total number of mental health parity violations for each type of violation? | CREATE TABLE mental_health_parity (violation_type VARCHAR(50),violations INT); | SELECT violation_type, SUM(violations) FROM mental_health_parity GROUP BY violation_type; |
Which marine protected areas in the Atlantic region have a higher average depth than 2000 meters? | CREATE TABLE marine_protected_areas (name VARCHAR(255),location VARCHAR(255),avg_depth FLOAT); CREATE TABLE atlantic_region (name VARCHAR(255),region_type VARCHAR(255)); INSERT INTO marine_protected_areas (name,location,avg_depth) VALUES ('MPA1','Pacific',1234.56),('MPA2','Atlantic',2500.67); INSERT INTO atlantic_region (name,area_type) VALUES ('MPA2','Marine Protected Area'); | SELECT mpa.name FROM marine_protected_areas mpa INNER JOIN atlantic_region ar ON mpa.name = ar.name WHERE mpa.avg_depth > 2000; |
What is the total number of space missions for each space agency? | CREATE SCHEMA space; USE space; CREATE TABLE agency (name VARCHAR(50),country VARCHAR(50),missions INT); INSERT INTO agency (name,country,missions) VALUES ('ESA','Europe',120),('NASA','USA',230),('ROSCOSMOS','Russia',150); | SELECT s.name, SUM(s.missions) FROM space.agency s GROUP BY s.name; |
How many genetic research projects were completed in Africa? | CREATE SCHEMA if not exists genetics; USE genetics; CREATE TABLE if not exists research_projects (id INT,name VARCHAR(255),country VARCHAR(255)); INSERT INTO research_projects (id,name,country) VALUES (1,'Project X','Africa'),(2,'Project Y','USA'),(3,'Project Z','Europe'); | SELECT COUNT(*) FROM genetics.research_projects WHERE country = 'Africa' AND id IN (SELECT project_id FROM genetics.research_status WHERE status = 'Completed'); |
How many unique volunteers have participated in events organized by nonprofits in the education sector in the US? | CREATE TABLE states (state_id INT,state_name TEXT); INSERT INTO states VALUES (1,'California'); | SELECT COUNT(DISTINCT v.volunteer_id) as total_volunteers FROM volunteers v JOIN nonprofit_events ne ON v.city = ne.city JOIN events e ON ne.event_id = e.event_id JOIN nonprofits n ON ne.nonprofit_id = n.nonprofit_id JOIN states s ON v.city = s.state_name WHERE n.sector = 'education' AND s.state_name = 'California'; |
Which students have shown improvement in mental health scores compared to the last measurement? | CREATE TABLE students_time (student_id INT,student_name VARCHAR(50),school_id INT,mental_health_score INT,measurement_date DATE); INSERT INTO students_time (student_id,student_name,school_id,mental_health_score,measurement_date) VALUES (1,'John Doe',1001,75,'2022-01-01'),(2,'Jane Smith',1001,82,'2022-01-02'),(3,'Mike Johnson',1002,68,'2022-01-03'),(1,'John Doe',1001,80,'2022-01-04'); | SELECT student_id, school_id, mental_health_score, LAG(mental_health_score) OVER (PARTITION BY student_id ORDER BY measurement_date) as previous_mental_health_score, (mental_health_score - LAG(mental_health_score) OVER (PARTITION BY student_id ORDER BY measurement_date)) as mental_health_improvement FROM students_time; |
Calculate the minimum explainability score of models in Africa after 2018 | CREATE TABLE Models (ModelId INT,Name TEXT,ExplainabilityScore FLOAT,Year INT,Country TEXT); INSERT INTO Models (ModelId,Name,ExplainabilityScore,Year,Country) VALUES (1,'ModelX',0.7,2018,'South Africa'),(2,'ModelY',0.8,2020,'Egypt'),(3,'ModelZ',0.9,2019,'Nigeria'); | SELECT MIN(ExplainabilityScore) FROM Models WHERE Country = 'Africa' AND Year > 2018; |
Insert a new crop 'Rice' with production of 500 metric tons in Indonesia. | CREATE TABLE crops (id INT PRIMARY KEY,name VARCHAR(255),production_metric_tons FLOAT,country VARCHAR(255)); INSERT INTO crops (id,name,production_metric_tons,country) VALUES (1,'Quinoa',85.2,'Bolivia'),(2,'Potatoes',400.5,'Bolivia'),(3,'Corn',200.0,'Bolivia'); | INSERT INTO crops (name, production_metric_tons, country) VALUES ('Rice', 500, 'Indonesia'); |
What's the total amount of donations received by each organization for the 'food security' sector in Kenya in 2020? | CREATE TABLE organizations (id INT,name TEXT,country TEXT); INSERT INTO organizations VALUES (1,'WFP','Kenya'); CREATE TABLE donations (id INT,organization_id INT,sector TEXT,amount INT,donation_date DATE); INSERT INTO donations VALUES (1,1,'food security',5000,'2020-01-01'); | SELECT o.name, SUM(d.amount) FROM organizations o INNER JOIN donations d ON o.id = d.organization_id WHERE o.country = 'Kenya' AND d.sector = 'food security' AND d.donation_date BETWEEN '2020-01-01' AND '2020-12-31' GROUP BY o.name; |
How many hospitals are there in Russia and Japan? | CREATE TABLE hospitals (country VARCHAR(20),num_hospitals INT); INSERT INTO hospitals (country,num_hospitals) VALUES ('Russia',3000),('Japan',2500); | SELECT SUM(num_hospitals) FROM hospitals WHERE country IN ('Russia', 'Japan'); |
Delete records in the 'wind_turbines' table where the 'manufacturer' is 'XYZ Windpower' and the 'installed_year' is before 2010 | CREATE TABLE wind_turbines (id INT PRIMARY KEY,manufacturer VARCHAR(50),installed_year INT,capacity FLOAT); | DELETE FROM wind_turbines WHERE manufacturer = 'XYZ Windpower' AND installed_year < 2010; |
Add a new record for a healthcare worker in the 'rural_healthcare_workers' table | CREATE TABLE rural_healthcare_workers (id INT,name VARCHAR(50),title VARCHAR(50),location VARCHAR(50)); | INSERT INTO rural_healthcare_workers (id, name, title, location) VALUES (1, 'Jane Doe', 'Physician Assistant', 'Eureka'); |
What is the count of community health workers by region in the public health database? | CREATE TABLE community_health_workers (id INT,name VARCHAR(50),region VARCHAR(50)); INSERT INTO community_health_workers (id,name,region) VALUES (1,'Community Health Worker A','Region A'); INSERT INTO community_health_workers (id,name,region) VALUES (2,'Community Health Worker B','Region B'); | SELECT region, COUNT(*) FROM community_health_workers GROUP BY region; |
Update the sales record of naval vessels to the US | CREATE TABLE sales (id INT,year INT,country VARCHAR(255),equipment_type VARCHAR(255),revenue FLOAT); | UPDATE sales SET revenue = 15000000 WHERE country = 'United States' AND equipment_type = 'Naval Vessels'; |
What is the average retail price of men's organic cotton t-shirts sold in the USA? | CREATE TABLE retail_sales (id INT,garment_type VARCHAR(50),garment_material VARCHAR(50),price DECIMAL(5,2),country VARCHAR(50)); INSERT INTO retail_sales (id,garment_type,garment_material,price,country) VALUES (1,'T-Shirt','Organic Cotton',25.99,'USA'); INSERT INTO retail_sales (id,garment_type,garment_material,price,country) VALUES (2,'T-Shirt','Conventional Cotton',19.99,'USA'); | SELECT AVG(price) FROM retail_sales WHERE garment_type = 'T-Shirt' AND garment_material = 'Organic Cotton' AND country = 'USA'; |
What is the maximum price of recycled polyester products? | CREATE TABLE products (id INT,name VARCHAR(255),material VARCHAR(255),price DECIMAL(5,2)); INSERT INTO products (id,name,material,price) VALUES (1,'T-Shirt','Recycled Polyester',25.00),(2,'Hoodie','Recycled Polyester',75.00); | SELECT MAX(price) FROM products WHERE material = 'Recycled Polyester'; |
Find the total revenue from ticket sales for each exhibition | CREATE TABLE Exhibition (id INT,name TEXT,ticket_price INT); CREATE TABLE Ticket_Sales (exhibition_id INT,visitor_count INT); INSERT INTO Exhibition (id,name,ticket_price) VALUES (1,'Exhibition1',10),(2,'Exhibition2',15); INSERT INTO Ticket_Sales (exhibition_id,visitor_count) VALUES (1,50),(2,75); | SELECT Exhibition.name, SUM(Exhibition.ticket_price * Ticket_Sales.visitor_count) FROM Exhibition JOIN Ticket_Sales ON Exhibition.id = Ticket_Sales.exhibition_id GROUP BY Exhibition.name; |
What is the maximum and minimum depth of all marine protected areas in the Indian Ocean? | CREATE TABLE marine_protected_areas_indian (area_name VARCHAR(255),depth FLOAT); INSERT INTO marine_protected_areas_indian (area_name,depth) VALUES ('Gulf of Kutch',50.0),('Andaman and Nicobar Islands',3000.0),('Lakshadweep Islands',200.0); | SELECT MIN(depth), MAX(depth) FROM marine_protected_areas_indian; |
How many defense contracts were signed in the UK in 2021? | CREATE TABLE defense_contracts (id INT,country VARCHAR(50),year INT,contract_count INT); INSERT INTO defense_contracts (id,country,year,contract_count) VALUES (1,'UK',2021,350); INSERT INTO defense_contracts (id,country,year,contract_count) VALUES (2,'UK',2021,400); INSERT INTO defense_contracts (id,country,year,contract_count) VALUES (3,'UK',2020,450); | SELECT SUM(contract_count) FROM defense_contracts WHERE country = 'UK' AND year = 2021; |
Find the average transaction value for the 'South Asia' region. | CREATE TABLE customers (customer_id INT,name VARCHAR(50),region VARCHAR(50)); INSERT INTO customers (customer_id,name,region) VALUES (1,'John Doe','South Asia'); INSERT INTO customers (customer_id,name,region) VALUES (2,'Jane Smith','North America'); CREATE TABLE transactions (transaction_id INT,customer_id INT,transaction_value DECIMAL(10,2)); INSERT INTO transactions (transaction_id,customer_id,transaction_value) VALUES (1,1,100.00); INSERT INTO transactions (transaction_id,customer_id,transaction_value) VALUES (2,2,200.00); | SELECT AVG(transaction_value) FROM transactions JOIN customers ON transactions.customer_id = customers.customer_id WHERE customers.region = 'South Asia'; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.