instruction
stringlengths
0
1.06k
input
stringlengths
11
5.3k
response
stringlengths
2
4.44k
What is the average annual rainfall and temperature for each region in the "regions" and "weather" tables?
CREATE TABLE regions (id INT,name VARCHAR(50)); CREATE TABLE weather (id INT,region_id INT,year INT,rainfall FLOAT,temperature FLOAT);
SELECT regions.name AS region, AVG(weather.rainfall) AS avg_rainfall, AVG(weather.temperature) AS avg_temperature FROM regions INNER JOIN weather ON regions.id = weather.region_id GROUP BY regions.name;
Show the recycling rate per quarter for the city of London in 2020, with the highest rate at the top.
CREATE TABLE recycling_rates (id INT,city VARCHAR(50),rate FLOAT,quarter INT,year INT); INSERT INTO recycling_rates (id,city,rate,quarter,year) VALUES (1,'London',25.6,1,2020),(2,'London',26.2,2,2020),(3,'London',27.1,3,2020);
SELECT city, AVG(rate) as avg_rate FROM recycling_rates WHERE city = 'London' AND year = 2020 GROUP BY city, quarter ORDER BY avg_rate DESC;
Top 3 music genres with highest revenue in the US?
CREATE TABLE Music_Sales (title VARCHAR(255),genre VARCHAR(50),release_date DATE,revenue INT);
SELECT genre, SUM(revenue) as total_revenue FROM Music_Sales WHERE release_date BETWEEN '2010-01-01' AND '2020-12-31' GROUP BY genre ORDER BY total_revenue DESC LIMIT 3;
What is the maximum budget allocated for a single policy in the year 2019?
CREATE TABLE Policies (Year INT,Policy VARCHAR(255),Amount INT); INSERT INTO Policies (Year,Policy,Amount) VALUES (2019,'PolicyA',8000000),(2019,'PolicyB',6000000),(2019,'PolicyC',9000000),(2020,'PolicyA',8500000),(2020,'PolicyB',6500000),(2020,'PolicyC',9500000);
SELECT MAX(Amount) FROM Policies WHERE Year = 2019;
What is the total number of individuals impacted by criminal justice reform initiatives in Texas in the past 3 years?
CREATE TABLE criminal_justice_reform_initiatives (initiative_id INT,year INT,individuals_impacted INT); INSERT INTO criminal_justice_reform_initiatives (initiative_id,year,individuals_impacted) VALUES (1,2020,5000),(2,2019,7000),(3,2018,8000),(4,2017,6000),(5,2016,9000);
SELECT SUM(individuals_impacted) FROM criminal_justice_reform_initiatives WHERE year >= 2018;
What is the maximum fish biomass (in kg) in fish farms located in South America, with a water salinity of less than 30 ppt?
CREATE TABLE fish_farms (id INT,name VARCHAR(255),region VARCHAR(255),water_salinity FLOAT,biomass FLOAT); INSERT INTO fish_farms (id,name,region,water_salinity,biomass) VALUES (1,'Farm X','South America',28.9,1800),(2,'Farm Y','South America',29.7,2100),(3,'Farm Z','South America',25.2,1500);
SELECT MAX(biomass) FROM fish_farms WHERE region = 'South America' AND water_salinity < 30;
What is the average CO2 emission for each garment manufacturing process?
CREATE TABLE emissions (emission_id INT,garment_type VARCHAR(50),manufacturing_process VARCHAR(50),co2_emission DECIMAL(10,2));
SELECT garment_type, AVG(co2_emission) FROM emissions GROUP BY garment_type;
How many products were sold by each vendor in the United States?
CREATE TABLE sales (sale_id int,product_id int,vendor_id int,quantity int,sale_date date); CREATE TABLE vendors (vendor_id int,vendor_name varchar(255),country varchar(50)); INSERT INTO sales (sale_id,product_id,vendor_id,quantity,sale_date) VALUES (1,1,101,10,'2022-01-01'); INSERT INTO vendors (vendor_id,vendor_name,country) VALUES (101,'Eco Vendors','United States');
SELECT vendor_id, SUM(quantity) AS total_sold FROM sales JOIN vendors ON sales.vendor_id = vendors.vendor_id WHERE country = 'United States' GROUP BY vendor_id;
How many employees of each gender work in the mining industry per country?
CREATE TABLE employees (employee_id INT,name TEXT,gender TEXT,job_title TEXT,mining_company_id INT); INSERT INTO employees (employee_id,name,gender,job_title,mining_company_id) VALUES (1,'John Doe','Male','Miner',1001),(2,'Jane Doe','Female','Engineer',1001),(3,'Alice Smith','Female','Miner',1002),(4,'Bob Johnson','Male','Manager',1002),(5,'Jessica Brown','Female','Engineer',1003); CREATE TABLE mining_companies (mining_company_id INT,company_name TEXT,country TEXT); INSERT INTO mining_companies (mining_company_id,company_name,country) VALUES (1001,'Acme Gold','Australia'),(1002,'Global Mining','Canada'),(1003,'Mining Inc','USA');
SELECT country, gender, COUNT(*) as employee_count FROM employees JOIN mining_companies ON employees.mining_company_id = mining_companies.mining_company_id GROUP BY country, gender;
What is the total budget for disability support programs in 'New York' for 2022?
CREATE TABLE budget (budget_id INT,program_name VARCHAR(50),state VARCHAR(50),year INT,amount INT); INSERT INTO budget (budget_id,program_name,state,year,amount) VALUES (1,'Accessible Transportation','New York',2022,50000),(2,'Sign Language Interpretation','New York',2022,30000),(3,'Adaptive Equipment','New York',2021,40000);
SELECT SUM(amount) FROM budget WHERE state = 'New York' AND year = 2022;
How many employees work in the 'finance' sector?
CREATE TABLE if not exists employment (id INT,industry VARCHAR,number_of_employees INT); INSERT INTO employment (id,industry,number_of_employees) VALUES (1,'manufacturing',5000),(2,'technology',8000),(3,'healthcare',7000),(4,'retail',6000),(5,'education',9000),(6,'finance',10000);
SELECT SUM(number_of_employees) FROM employment WHERE industry = 'finance';
Show the count of startups founded by individuals from historically underrepresented groups that have raised Series B or later funding.
CREATE TABLE startup (id INT,name TEXT,founder_identity TEXT,funding TEXT); INSERT INTO startup (id,name,founder_identity,funding) VALUES (1,'TechCo','Black Female','Seed'),(2,'InnovateIT','Black Male','Series A'),(3,'GreenSolutions','White Male','Seed'),(4,'DataDriven','Asian Female','Series B'),(5,'EcoTech','Latinx Female','Series C'),(6,'AI4Good','AAPI Male','Series D');
SELECT COUNT(*) FROM startup WHERE founder_identity NOT LIKE 'White%' AND funding IN ('Series B', 'Series C', 'Series D', 'Series E');
How many green buildings are there in the 'green_buildings' schema, for each certification level?
CREATE TABLE green_buildings.certification (certification_level VARCHAR(255),building_count INT); INSERT INTO green_buildings.certification (certification_level,building_count) VALUES ('Gold',200),('Silver',150),('Bronze',100),('Platinum',50);
SELECT certification_level, SUM(building_count) FROM green_buildings.certification GROUP BY certification_level;
What is the average operating hours for mining equipment in the 'equipment_stats' table that has more than 1000 operating hours?
CREATE TABLE equipment_stats (id INT,equipment_name VARCHAR(50),operating_hours INT,last_maintenance_date DATE);
SELECT AVG(operating_hours) FROM equipment_stats WHERE operating_hours > 1000;
Determine the number of climate finance policies in Asia since 2010, and their distribution by policy type.
CREATE TABLE climate_finance_policies_as (country VARCHAR(50),policy_year INT,policy_type VARCHAR(50)); INSERT INTO climate_finance_policies_as (country,policy_year,policy_type) VALUES ('China',2012,'Climate Finance'),('India',2015,'Carbon Pricing'),('Japan',2018,'Climate Finance'),('Vietnam',2011,'Renewable Energy'),('Indonesia',2013,'Adaptation');
SELECT policy_type, COUNT(*) FROM climate_finance_policies_as WHERE policy_year >= 2010 GROUP BY policy_type;
How many financial wellbeing programs have been added or updated in the last month?
CREATE TABLE programs (program_id INT,program_name TEXT,date_added DATE,date_updated DATE); INSERT INTO programs VALUES (1,'Financial Literacy 101','2021-01-01','2021-03-15'); INSERT INTO programs VALUES (2,'Budgeting Basics','2021-02-01','2021-02-28'); INSERT INTO programs VALUES (3,'Retirement Planning','2021-04-01','2021-04-15');
SELECT COUNT(*) FROM programs WHERE date_added >= DATEADD(month, -1, GETDATE()) OR date_updated >= DATEADD(month, -1, GETDATE());
What is the total revenue from broadband services for each region?
CREATE TABLE broadband_services (service_id INT,region VARCHAR(255),revenue DECIMAL(10,2)); INSERT INTO broadband_services (service_id,region,revenue) VALUES (1,'North',5000),(2,'South',7000);
SELECT region, SUM(revenue) FROM broadband_services GROUP BY region;
List the decentralized applications that have the lowest and highest number of transactions, in ascending order.
CREATE TABLE Transactions (TransactionID int,DAppName varchar(50),Transactions int); INSERT INTO Transactions (TransactionID,DAppName,Transactions) VALUES (1,'DApp1',100),(2,'DApp2',200),(3,'DApp3',300);
SELECT DAppName, MIN(Transactions) as MinTransactions, MAX(Transactions) as MaxTransactions FROM Transactions GROUP BY DAppName ORDER BY MinTransactions, MaxTransactions;
List all makeup products with recyclable packaging sold in Canada.
CREATE TABLE MakeupPackaging (product_id INT,product_name VARCHAR(100),packaging_material VARCHAR(50),recyclable BOOLEAN,country VARCHAR(50)); INSERT INTO MakeupPackaging VALUES (501,'Lipstick','Plastic',FALSE,'Canada'),(502,'Eyeshadow Palette','Cardboard',TRUE,'Canada'),(503,'Mascara','Glass',TRUE,'USA'),(504,'Blush','Plastic',FALSE,'Canada'),(505,'Foundation','Glass',TRUE,'Canada');
SELECT product_id, product_name FROM MakeupPackaging WHERE country = 'Canada' AND recyclable = TRUE;
Count the number of unique users from the "users" table who have posted content related to "plant-based diets" in the "social_media" schema.
CREATE TABLE users (id INT,username TEXT,email TEXT,created_at DATETIME); CREATE TABLE posts (id INT,user_id INT,content TEXT,likes INT,shares INT,created_at DATETIME); INSERT INTO users (id,username,email,created_at) VALUES (1,'jane123','[jane@gmail.com](mailto:jane@gmail.com)','2021-01-01 10:00:00'),(2,'bob_the_builder','[bob@yahoo.com](mailto:bob@yahoo.com)','2021-02-01 11:00:00'); INSERT INTO posts (id,user_id,content,likes,shares,created_at) VALUES (1,1,'I love plant-based diets!',500,200,'2022-01-01 10:00:00'),(2,1,'Trying out a new plant-based recipe...',800,300,'2022-01-02 11:00:00');
SELECT COUNT(DISTINCT users.id) FROM users JOIN posts ON users.id = posts.user_id WHERE posts.content LIKE '%plant-based%' AND schema='social_media';
What is the distribution of media content genres?
CREATE TABLE genres (content_id INTEGER,genre VARCHAR(100)); INSERT INTO genres (content_id,genre) VALUES (1,'Action'),(1,'Adventure'),(2,'Drama'),(2,'Comedy'),(3,'Documentary'),(3,'History'),(4,'Sci-Fi'),(4,'Fantasy');
SELECT genre, COUNT(*) FROM genres GROUP BY genre;
What is the maximum daily water consumption for the top 10 water-consuming households in the 'Industrial' district?
CREATE TABLE Industrial (id INT,household_id INT,daily_consumption DECIMAL(5,2)); INSERT INTO Industrial (id,household_id,daily_consumption) VALUES (1,201,250.50),(2,202,300.20),(3,203,220.85),(4,204,180.33),(5,205,290.11),(6,206,195.44),(7,207,350.76),(8,208,270.99),(9,209,215.60),(10,210,400.00),(11,211,150.23);
SELECT MAX(daily_consumption) FROM (SELECT daily_consumption FROM Industrial WHERE district = 'Industrial' ORDER BY daily_consumption DESC LIMIT 10) AS top_10_households;
Create a table named 'routes' with columns 'route_id', 'name', 'type'
CREATE TABLE routes (route_id INT,name VARCHAR(255),type VARCHAR(255));
CREATE TABLE routes (route_id INT, name VARCHAR(255), type VARCHAR(255));
What was the total time spent by visitors from a specific city?
CREATE TABLE time_spent (visitor_id INT,city VARCHAR(10),time_minutes INT); INSERT INTO time_spent (visitor_id,city,time_minutes) VALUES (1,'CityA',60),(2,'CityB',90);
SELECT city, SUM(time_minutes) AS total_time_minutes FROM time_spent GROUP BY city;
What is the total number of assistive technology items provided to students with hearing impairments?
CREATE TABLE Assistive_Technology (Student_ID INT,Student_Name TEXT,Disability_Type TEXT,Assistive_Tech_Item TEXT); INSERT INTO Assistive_Technology (Student_ID,Student_Name,Disability_Type,Assistive_Tech_Item) VALUES (1,'John Doe','Visual Impairment','Screen Reader'),(2,'Jane Smith','Hearing Impairment','Hearing Aid'),(3,'Michael Brown','ADHD','None');
SELECT SUM(CASE WHEN Disability_Type = 'Hearing Impairment' THEN 1 ELSE 0 END) FROM Assistive_Technology WHERE Assistive_Tech_Item IS NOT NULL;
Update the name of the community engagement event in 'Russia' with id 3
CREATE TABLE community_engagement (id INT PRIMARY KEY,name TEXT,location TEXT,date DATE);
UPDATE community_engagement SET name = 'Maslenitsa' WHERE id = 3 AND location = 'Russia';
What is the number of shelters and their types for each sector in 'disaster_response' schema?
CREATE TABLE shelters (shelter_id INT,shelter_name VARCHAR(255),location VARCHAR(255),sector VARCHAR(255)); INSERT INTO shelters (shelter_id,shelter_name,location,sector) VALUES (1,'Shelter A','City A','Education');
SELECT sector, COUNT(shelter_id) as total_shelters, sector as shelter_type FROM shelters GROUP BY sector;
Determine the number of financial capability programs in Africa that were launched in the last 5 years.
CREATE TABLE financial_capability_programs (id INT,program_name VARCHAR(255),country VARCHAR(255),launch_date DATE); INSERT INTO financial_capability_programs (id,program_name,country,launch_date) VALUES (1,'Financial Literacy 101','Nigeria','2018-01-01'),(2,'Money Management for Youth','South Africa','2017-06-15'),(3,'Budgeting Basics','Kenya','2019-03-20');
SELECT COUNT(*) FROM financial_capability_programs WHERE country = 'Africa' AND launch_date >= DATEADD(year, -5, CURRENT_DATE);
What is the total cargo weight handled by container ships built before 2010, grouped by ship builder?
CREATE TABLE container_ships (ship_id INT,ship_name VARCHAR(255),ship_builder VARCHAR(255),year INT,cargo_weight INT);INSERT INTO container_ships (ship_id,ship_name,ship_builder,year,cargo_weight) VALUES (1,'Ever Given','Baosteel',2010,210000),(2,'CMA CGM Marco Polo','Daewoo Shipbuilding & Marine Engineering',2008,165000);
SELECT ship_builder, SUM(cargo_weight) FROM container_ships WHERE year < 2010 GROUP BY ship_builder;
Calculate the total price of all properties in an inclusive housing scheme in Chicago.
CREATE TABLE property_prices (property_id INT,city VARCHAR(50),price INT); CREATE TABLE inclusive_housing (property_id INT,inclusive_scheme BOOLEAN); INSERT INTO property_prices (property_id,city,price) VALUES (1,'Chicago',600000),(2,'Portland',400000),(3,'Chicago',700000),(4,'Seattle',800000); INSERT INTO inclusive_housing (property_id) VALUES (1),(3);
SELECT SUM(price) FROM property_prices p JOIN inclusive_housing i ON p.property_id = i.property_id WHERE p.city = 'Chicago';
What is the total number of co-owned properties in the state of New York with an average size of over 1500 square feet?
CREATE TABLE property (id INT,size INT,state VARCHAR(20),co_owned BOOLEAN);
SELECT COUNT(*) FROM property WHERE state = 'New York' AND co_owned = TRUE GROUP BY co_owned HAVING AVG(size) > 1500;
What is the total number of clients for each investment strategy?
CREATE TABLE investment_strategies (strategy_id INT,strategy_name VARCHAR(50),client_id INT); INSERT INTO investment_strategies (strategy_id,strategy_name,client_id) VALUES (1,'Equity',1),(2,'Fixed Income',2),(3,'Real Estate',3),(4,'Equity',1),(5,'Fixed Income',2);
SELECT strategy_name, COUNT(DISTINCT client_id) AS total_clients FROM investment_strategies GROUP BY strategy_name;
What is the maximum preparedness score for each city?
CREATE TABLE DisasterPreparedness (id INT,city VARCHAR(255),preparedness_score INT);
SELECT city, MAX(preparedness_score) FROM DisasterPreparedness GROUP BY city;
Which products contain a specific ingredient?
CREATE TABLE if not exists ingredient (id INT PRIMARY KEY,name TEXT,natural BOOLEAN); INSERT INTO ingredient (id,name,natural) VALUES (2,'Glycerin',true); CREATE TABLE if not exists product_ingredient (product_id INT,ingredient_id INT); INSERT INTO product_ingredient (product_id,ingredient_id) VALUES (2,2); CREATE TABLE if not exists product (id INT PRIMARY KEY,name TEXT,brand_id INT,price DECIMAL(5,2)); INSERT INTO product (id,name,brand_id,price) VALUES (2,'Lip and Cheek Stain',1,18.99);
SELECT product.name FROM product JOIN product_ingredient ON product.id = product_ingredient.product_id JOIN ingredient ON product_ingredient.ingredient_id = ingredient.id WHERE ingredient.name = 'Glycerin';
What is the average donation amount by donors from the Middle East?
CREATE TABLE donations (id INT,donor_id INT,amount DECIMAL); INSERT INTO donations (id,donor_id,amount) VALUES (1,1,150.00),(2,2,75.00),(3,1,250.00),(4,3,120.00); CREATE TABLE donors (id INT,name TEXT,region TEXT); INSERT INTO donors (id,name,region) VALUES (1,'Hanin','Middle East'),(2,'Oliver','Europe'),(3,'Xiaoli','Asia');
SELECT AVG(donations.amount) FROM donations INNER JOIN donors ON donations.donor_id = donors.id WHERE donors.region = 'Middle East';
Insert new record into 'customer' table for 'Cindy' with 'loyalty_score' of 85
CREATE TABLE customer (id INT PRIMARY KEY,name VARCHAR(50),loyalty_score INT); INSERT INTO customer (id,name,loyalty_score) VALUES (1,'Bob',75),(2,'Alice',90);
INSERT INTO customer (name, loyalty_score) VALUES ('Cindy', 85);
What is the total number of public schools and universities in Texas?
CREATE TABLE texas_schools (name TEXT,type TEXT); INSERT INTO texas_schools (name,type) VALUES ('Houston ISD','Public School'),('University of Texas at Austin','University');
SELECT COUNT(*) FROM (SELECT name FROM texas_schools WHERE type = 'Public School' UNION SELECT name FROM texas_schools WHERE type = 'University') AS schools;
What is the average budget for AI projects in Africa?
CREATE TABLE ai_projects (id INT,project_name VARCHAR(50),location VARCHAR(50),budget INT); INSERT INTO ai_projects (id,project_name,location,budget) VALUES (1,'AI for Agriculture','Kenya',100000),(2,'AI for Healthcare','Nigeria',200000),(3,'AI for Education','South Africa',150000);
SELECT AVG(budget) FROM ai_projects WHERE location = 'Africa';
What is the maximum rainfall recorded for each region in the past year?
CREATE TABLE region_rainfall (region TEXT,date DATE,rainfall INTEGER);
SELECT region, MAX(rainfall) as max_rainfall FROM region_rainfall WHERE date >= DATEADD(year, -1, GETDATE()) GROUP BY region;
List of countries with the highest number of satellites and their respective debris count?
CREATE TABLE debris(debris_id INT,name VARCHAR(50),country VARCHAR(50),launch_date DATE,origin BOOLEAN); INSERT INTO debris VALUES (1,'Debris1','USA','2000-01-01',true); INSERT INTO debris VALUES (2,'Debris2','USA','2001-01-01',false); INSERT INTO debris VALUES (3,'Debris3','China','2002-01-01',true);
SELECT s.country, COUNT(s.satellite_id) as satellite_count, COUNT(d.debris_id) as debris_count FROM satellites s FULL OUTER JOIN debris d ON s.country = d.country GROUP BY s.country ORDER BY satellite_count DESC, debris_count DESC LIMIT 2;
Identify the number of creative AI applications submitted from Asia in the last year.
CREATE TABLE creative_ai_apps (id INT,app_name VARCHAR(255),submission_date DATE,location VARCHAR(255));
SELECT location, COUNT(*) FROM creative_ai_apps WHERE submission_date >= DATEADD(year, -1, GETDATE()) AND location = 'Asia' GROUP BY location;
Insert a new energy storage system with id 4, name 'GHI Battery', capacity 4000 and region 'East'.
CREATE TABLE energy_storage (id INT,name TEXT,capacity FLOAT,region TEXT);
INSERT INTO energy_storage (id, name, capacity, region) VALUES (4, 'GHI Battery', 4000, 'East');
What is the total market share for each drug, ranked by the highest market share first, for the year 2020?
CREATE TABLE market_share (market_share_id INT,drug_name VARCHAR(255),year INT,market_share DECIMAL(10,2)); INSERT INTO market_share (market_share_id,drug_name,year,market_share) VALUES (1,'DrugA',2020,0.35),(2,'DrugB',2020,0.28),(3,'DrugC',2020,0.30),(4,'DrugA',2020,0.33),(5,'DrugB',2020,0.31),(6,'DrugC',2020,0.29);
SELECT drug_name, SUM(market_share) as total_market_share FROM market_share WHERE year = 2020 GROUP BY drug_name ORDER BY total_market_share DESC;
What is the total revenue by region for mobile and broadband?
CREATE TABLE mobile_revenue (region VARCHAR(50),revenue FLOAT);
SELECT region, SUM(revenue) FROM (SELECT * FROM mobile_revenue UNION ALL SELECT * FROM broadband_revenue) GROUP BY region;
What is the average daily revenue generated by advertising on video content for the month of June 2022?
CREATE TABLE ad_revenue (id INT,content_type VARCHAR(50),revenue DECIMAL(10,2),date DATE);
SELECT AVG(revenue) as avg_daily_revenue FROM ad_revenue WHERE content_type = 'Video' AND date >= '2022-06-01' AND date <= '2022-06-30' GROUP BY EXTRACT(DAY FROM date);
Show soil nutrient levels in field 4
CREATE TABLE soil_nutrients (sensor_id TEXT,field_id TEXT,nitrogen FLOAT,phosphorus FLOAT,potassium FLOAT); INSERT INTO soil_nutrients (sensor_id,field_id,nitrogen,phosphorus,potassium) VALUES ('Sensor 401','Field 4',50.2,30.1,60.5),('Sensor 402','Field 4',51.0,31.0,61.0);
SELECT nitrogen, phosphorus, potassium FROM soil_nutrients WHERE field_id = 'Field 4';
What is the minimum age of players who play games in the 'Strategy' category?
CREATE TABLE Players (PlayerID INT,Age INT,Country VARCHAR(50)); INSERT INTO Players (PlayerID,Age,Country) VALUES (1,22,'Brazil'),(2,30,'Canada'),(3,25,'China'),(4,19,'India'); CREATE TABLE GameLibrary (GameID INT,GameName VARCHAR(50),GameType VARCHAR(50),Category VARCHAR(50)); INSERT INTO GameLibrary (GameID,GameName,GameType,Category) VALUES (1,'GameA','Non-VR','Strategy'),(2,'GameB','Non-VR','Adventure'),(3,'GameC','VR','Action'),(4,'GameD','Non-VR','Strategy'); CREATE TABLE PlayerGameLibrary (PlayerID INT,GameID INT); INSERT INTO PlayerGameLibrary (PlayerID,GameID) VALUES (1,1),(2,2),(3,1),(4,3),(4,4);
SELECT MIN(Players.Age) FROM Players JOIN PlayerGameLibrary ON Players.PlayerID = PlayerGameLibrary.PlayerID JOIN GameLibrary ON PlayerGameLibrary.GameID = GameLibrary.GameID WHERE GameLibrary.Category = 'Strategy';
What is the total biomass of fish in the Barents Sea?
CREATE TABLE fish_biomass (species TEXT,population REAL,biomass REAL); INSERT INTO fish_biomass (species,population,biomass) VALUES ('Cod',10000,200000),('Herring',20000,300000);
SELECT SUM(biomass) FROM fish_biomass WHERE species IN ('Cod', 'Herring', 'Capelin');
Find the number of platforms in each region
CREATE TABLE platforms (platform_id INT,region VARCHAR(50)); INSERT INTO platforms (platform_id,region) VALUES (1,'Gulf of Mexico'),(2,'North Sea'),(3,'South China Sea'),(4,'Gulf of Mexico');
SELECT region, COUNT(platform_id) as num_platforms FROM platforms GROUP BY region;
What is the number of veteran job applicants and hires for each job category in the state of California?
CREATE TABLE JobApplicants (ApplicantID int,JobCategory varchar(50),JobLocation varchar(50),ApplicantType varchar(50)); INSERT INTO JobApplicants (ApplicantID,JobCategory,JobLocation,ApplicantType) VALUES (1,'Software Engineer','California','Veteran'),(2,'Project Manager','California','Non-Veteran'),(3,'Data Analyst','California','Veteran'),(4,'Software Engineer','California','Non-Veteran'),(5,'Project Manager','California','Veteran');
SELECT JobCategory, COUNT(*) FILTER (WHERE ApplicantType = 'Veteran') as VeteranApplicants, COUNT(*) FILTER (WHERE ApplicantType = 'Non-Veteran') as NonVeteranApplicants, COUNT(*) as TotalApplicants FROM JobApplicants WHERE JobLocation = 'California' GROUP BY JobCategory;
List the top 5 clothing brands by the quantity of items produced using recycled materials.
CREATE TABLE clothing_brands (id INT PRIMARY KEY,brand VARCHAR(50),items_produced INT,recycled_materials_percentage FLOAT); INSERT INTO clothing_brands (id,brand,items_produced,recycled_materials_percentage) VALUES (1,'Brand A',100000,50.00),(2,'Brand B',150000,30.00),(3,'Brand C',80000,70.00),(4,'Brand D',120000,25.00),(5,'Brand E',200000,40.00);
SELECT brand, items_produced FROM clothing_brands WHERE recycled_materials_percentage >= 50 ORDER BY items_produced DESC LIMIT 5;
Delete the smart contract record with the ID 3 and update the timestamp of the record with ID 4 to the current time.
CREATE TABLE smart_contracts (id INT,name VARCHAR,timestamp TIMESTAMP); INSERT INTO smart_contracts (id,name,timestamp) VALUES (1,'SC1','2022-01-01 10:00:00'),(2,'SC2','2022-01-02 11:00:00'),(3,'SC3','2022-01-03 12:00:00'),(4,'SC4','2022-01-04 13:00:00');
DELETE FROM smart_contracts WHERE id = 3; UPDATE smart_contracts SET timestamp = CURRENT_TIMESTAMP WHERE id = 4;
What is the average experience of farmers per country?
CREATE TABLE farmers (id INT,name VARCHAR(50),country VARCHAR(50),experience INT); INSERT INTO farmers (id,name,country,experience) VALUES (1,'John Doe','US',10),(2,'Jane Smith','US',15),(3,'Pierre Dupont','France',5),(4,'Ana Sousa','Portugal',8),(5,'Hiroshi Tanaka','Japan',12);
SELECT country, AVG(experience) as avg_experience FROM farmers GROUP BY country;
What is the percentage of flights operated by 'UniversalAirlines' that had safety issues?
CREATE TABLE flights (id INT,airline VARCHAR(255),safety_issue BOOLEAN); INSERT INTO flights (id,airline,safety_issue) VALUES (1,'UniversalAirlines',true),(2,'UniversalAirlines',false),(3,'Intergalactic',true),(4,'UniversalAirlines',false),(5,'Intergalactic',false);
SELECT 100.0 * COUNT(*) FILTER (WHERE safety_issue = true) / COUNT(*) as percentage FROM flights WHERE airline = 'UniversalAirlines';
How many restaurants in New York offer gluten-free options on their menu?
CREATE TABLE restaurants (id INT,name TEXT,location TEXT,gluten_free BOOLEAN); INSERT INTO restaurants (id,name,location,gluten_free) VALUES (1,'Restaurant A','New York',true); INSERT INTO restaurants (id,name,location,gluten_free) VALUES (2,'Restaurant B','California',false); INSERT INTO restaurants (id,name,location,gluten_free) VALUES (3,'Restaurant C','New York',false); INSERT INTO restaurants (id,name,location,gluten_free) VALUES (4,'Restaurant D','Texas',true);
SELECT COUNT(*) FROM restaurants WHERE location = 'New York' AND gluten_free = true;
What is the average salary of workers in the textile industry by gender?
CREATE TABLE textile_workers (id INT,name VARCHAR(50),gender VARCHAR(10),salary FLOAT); INSERT INTO textile_workers (id,name,gender,salary) VALUES (1,'John Doe','Male',45000.0),(2,'Jane Doe','Female',42000.0);
SELECT gender, AVG(salary) FROM textile_workers GROUP BY gender;
What is the safety rating trend over time for vehicles manufactured in South Korea?
CREATE TABLE Vehicle_History (id INT,make VARCHAR(50),model VARCHAR(50),safety_rating FLOAT,manufacturing_country VARCHAR(50),year INT); INSERT INTO Vehicle_History (id,make,model,safety_rating,manufacturing_country,year) VALUES (1,'Hyundai','Sonata',5.1,'South Korea',2018); INSERT INTO Vehicle_History (id,make,model,safety_rating,manufacturing_country,year) VALUES (2,'Kia','Optima',4.9,'South Korea',2019);
SELECT manufacturing_country, year, safety_rating FROM Vehicle_History WHERE manufacturing_country = 'South Korea' ORDER BY year;
How many students with visual impairments received accommodations in 2020?
CREATE TABLE Students (Id INT,Name VARCHAR(100),DisabilityType VARCHAR(50)); CREATE TABLE Accommodations (Id INT,StudentId INT,AccommodationType VARCHAR(50),DateProvided DATETIME); INSERT INTO Students (Id,Name,DisabilityType) VALUES (1,'John Doe','Visual Impairment'); INSERT INTO Accommodations (Id,StudentId,AccommodationType,DateProvided) VALUES (1,1,'Screen Reader','2020-01-02');
SELECT COUNT(*) FROM Students JOIN Accommodations ON Students.Id = Accommodations.StudentId WHERE Students.DisabilityType = 'Visual Impairment' AND YEAR(Accommodations.DateProvided) = 2020;
What is the minimum and maximum altitude (in km) of all geostationary satellites?
CREATE TABLE geostationary_satellites (id INT,name VARCHAR(50),type VARCHAR(50),altitude FLOAT);
SELECT MIN(altitude), MAX(altitude) FROM geostationary_satellites WHERE type = 'Geostationary';
Update the price of all vegan nail polishes to $12.99
CREATE TABLE nail_polish_sales(product_id INT,sale_price FLOAT); INSERT INTO nail_polish_sales(product_id,sale_price) VALUES (1,9.99); INSERT INTO nail_polish_sales(product_id,sale_price) VALUES (2,10.99); CREATE TABLE product_info(product_id INT,is_vegan BOOLEAN); INSERT INTO product_info(product_id,is_vegan) VALUES (1,TRUE); INSERT INTO product_info(product_id,is_vegan) VALUES (2,FALSE); CREATE TABLE product_categories(product_id INT,category_name VARCHAR(50)); INSERT INTO product_categories(product_id,category_name) VALUES (1,'Nail Polish'); INSERT INTO product_categories(product_id,category_name) VALUES (2,'Makeup');
UPDATE nail_polish_sales SET sale_price = 12.99 FROM nail_polish_sales INNER JOIN product_info ON nail_polish_sales.product_id = product_info.product_id INNER JOIN product_categories ON nail_polish_sales.product_id = product_categories.product_id WHERE product_info.is_vegan = TRUE AND product_categories.category_name = 'Nail Polish';
Insert data into 'Game_Design' for game with ID 1001
CREATE TABLE Game_Design (id INT PRIMARY KEY,game_id INT,genre VARCHAR(255),release_year INT,developer VARCHAR(255));
INSERT INTO Game_Design (id, game_id, genre, release_year, developer) VALUES (1, 1001, 'RPG', 2018, 'CompanyA');
Which countries have the highest and lowest average song duration in the 'Reggaeton' genre?
CREATE TABLE songs (song_id INT,song VARCHAR(50),genre VARCHAR(10),duration FLOAT,country VARCHAR(50)); INSERT INTO songs VALUES (1,'Despacito','Reggaeton',320.5,'Puerto Rico'),(2,'Gasolina','Reggaeton',285.6,'Dominican Republic'),(3,'Bailando','Reggaeton',302.3,'Cuba');
SELECT s.country, AVG(s.duration) as avg_duration FROM songs s WHERE s.genre = 'Reggaeton' GROUP BY s.country ORDER BY avg_duration DESC, s.country;
How many satellites have been launched by China by the end of 2025?
CREATE TABLE satellites(id INT,name VARCHAR(255),launch_date DATE,launch_site VARCHAR(255),country VARCHAR(255)); INSERT INTO satellites VALUES (1,'Beidou-1A','1990-10-31','Xichang','China'); INSERT INTO satellites VALUES (2,'Beidou-1B','1990-11-15','Xichang','China'); INSERT INTO satellites VALUES (3,'Beidou-2A','2000-10-30','Xichang','China');
SELECT COUNT(*) FROM satellites WHERE country = 'China' AND launch_date <= '2025-12-31';
What is the most common age range of patients diagnosed with heart disease in rural areas of Florida?
CREATE TABLE patient (patient_id INT,age INT,diagnosis VARCHAR(50),location VARCHAR(20)); INSERT INTO patient (patient_id,age,diagnosis,location) VALUES (1,45,'Heart Disease','Rural Florida'); INSERT INTO patient (patient_id,age,diagnosis,location) VALUES (2,55,'Heart Disease','Rural Florida'); INSERT INTO patient (patient_id,age,diagnosis,location) VALUES (3,65,'Heart Disease','Urban Florida');
SELECT CASE WHEN age BETWEEN 20 AND 40 THEN '20-40' WHEN age BETWEEN 41 AND 60 THEN '41-60' WHEN age > 60 THEN '>60' END AS age_range, COUNT(*) FROM patient WHERE diagnosis = 'Heart Disease' AND location = 'Rural Florida' GROUP BY age_range;
What percentage of total hospital beds are ICU beds?
CREATE TABLE hospital_beds (id INT,hospital_name TEXT,location TEXT,total_beds INT,icu_beds INT,isolation_beds INT); INSERT INTO hospital_beds (id,hospital_name,location,total_beds,icu_beds,isolation_beds) VALUES (1,'NY Presbyterian','NYC',1000,200,150); INSERT INTO hospital_beds (id,hospital_name,location,total_beds,icu_beds,isolation_beds) VALUES (2,'Stanford Hospital','Palo Alto',1200,300,200);
SELECT location, (SUM(icu_beds) * 100.0 / SUM(total_beds)) as icu_percentage FROM hospital_beds GROUP BY location;
What are the names and research interests of faculty members who have not received any grants?
CREATE TABLE Faculty (FacultyID int,Name varchar(50),ResearchInterest varchar(50)); INSERT INTO Faculty (FacultyID,Name,ResearchInterest) VALUES (1,'John Smith','Machine Learning'); INSERT INTO Faculty (FacultyID,Name,ResearchInterest) VALUES (2,'Jane Doe','Data Science'); CREATE TABLE Grants (GrantID int,FacultyID int); INSERT INTO Grants (GrantID,FacultyID) VALUES (1,1);
SELECT Faculty.Name, Faculty.ResearchInterest FROM Faculty LEFT JOIN Grants ON Faculty.FacultyID = Grants.FacultyID WHERE Grants.FacultyID IS NULL;
What is the total carbon sequestration potential for each forest type in the 'forest_type_sequestration' table?
CREATE TABLE forest_type_sequestration (id INT,forest_type VARCHAR(255),total_sequestration FLOAT); INSERT INTO forest_type_sequestration (id,forest_type,total_sequestration) VALUES (1,'Deciduous',9000.0),(2,'Coniferous',11000.0),(3,'Mixed',8000.0);
SELECT forest_type, SUM(total_sequestration) FROM forest_type_sequestration GROUP BY forest_type;
List the case numbers and defendants' names of all cases that were settled out of court in the past 2 years, for each state.
CREATE TABLE CourtCases (Id INT,State VARCHAR(50),CaseNumber INT,Disposition VARCHAR(50),SettlementDate DATE); INSERT INTO CourtCases (Id,State,CaseNumber,Disposition,SettlementDate) VALUES (1,'California',12345,'Settled','2021-02-15'),(2,'Texas',67890,'Proceeding','2020-12-21'),(3,'New York',23456,'Settled','2020-08-01');
SELECT State, CaseNumber, DefendantName FROM CourtCases WHERE Disposition = 'Settled' AND SettlementDate >= DATEADD(year, -2, GETDATE());
What was the total oil production for each quarter in 2020?
CREATE TABLE production_2020 (production_id INT,quarter INT,oil_production FLOAT); INSERT INTO production_2020 (production_id,quarter,oil_production) VALUES (1,1,500.2),(2,1,550.4),(3,2,600.1),(4,2,650.3),(5,3,700.5),(6,3,750.6),(7,4,800.7),(8,4,850.8);
SELECT quarter, SUM(oil_production) as total_oil_production FROM production_2020 GROUP BY quarter ORDER BY quarter;
What is the total organic carbon content in each fish species' stock, partitioned by farming location and year?
CREATE TABLE FishStock (StockID INT,Location VARCHAR(50),Year INT,Species VARCHAR(50),OrganicCarbon FLOAT);
SELECT Location, Species, Year, SUM(OrganicCarbon) OVER (PARTITION BY Location, Species, Year) AS TotalOrganicCarbon FROM FishStock ORDER BY Location, Species, Year;
Display the unique customer preferences for 'vegetarian' dishes at 'Sprout' and 'GreenLeaf'.
CREATE TABLE Sprout (customer_id INT,dish_type VARCHAR(15)); INSERT INTO Sprout (customer_id,dish_type) VALUES (7,'vegetarian'),(8,'vegan'),(9,'vegetarian'); CREATE TABLE GreenLeaf (customer_id INT,dish_type VARCHAR(15)); INSERT INTO GreenLeaf (customer_id,dish_type) VALUES (10,'vegan'),(11,'vegetarian'),(12,'omnivore');
SELECT customer_id FROM Sprout WHERE dish_type = 'vegetarian' UNION SELECT customer_id FROM GreenLeaf WHERE dish_type = 'vegetarian';
How many public services are available in each state?
CREATE TABLE StateServices (State TEXT,Service TEXT); INSERT INTO StateServices (State,Service) VALUES ('State A','Education'),('State A','Healthcare'),('State B','Education'),('State B','Healthcare'),('State B','Transportation'),('State C','Education');
SELECT State, COUNT(DISTINCT Service) FROM StateServices GROUP BY State;
Which organic suppliers are used for lipstick products?
CREATE TABLE products (product_id INT,name VARCHAR(50),organic BOOLEAN); INSERT INTO products (product_id,name,organic) VALUES (1,'Lipstick A',true),(2,'Lipstick B',false),(3,'Eyeshadow C',false); CREATE TABLE ingredient_suppliers (ingredient_id INT,supplier_country VARCHAR(50),product_id INT,organic_source BOOLEAN); INSERT INTO ingredient_suppliers (ingredient_id,supplier_country,product_id,organic_source) VALUES (1,'US',1,true),(2,'CA',1,false),(3,'US',2,false),(4,'MX',3,false);
SELECT DISTINCT supplier_country FROM ingredient_suppliers WHERE organic_source = true AND ingredient_suppliers.product_id IN (SELECT product_id FROM products WHERE products.name = 'Lipstick A');
What are the names of the cosmetic products that are certified cruelty-free and source ingredients from country Z?
CREATE TABLE cosmetics (product_name TEXT,cruelty_free BOOLEAN,ingredient_source TEXT); INSERT INTO cosmetics (product_name,cruelty_free,ingredient_source) VALUES ('ProductA',true,'CountryX'),('ProductB',false,'CountryY'),('ProductC',true,'CountryZ'),('ProductD',true,'CountryZ'),('ProductE',false,'CountryY'),('ProductF',true,'CountryZ');
SELECT product_name FROM cosmetics WHERE cruelty_free = true AND ingredient_source = 'CountryZ';
How many offshore platforms have been installed in the Asia-Pacific region in total?
CREATE TABLE offshore_platforms (id INT,name VARCHAR(50),location VARCHAR(50),installation_year INT); INSERT INTO offshore_platforms VALUES (1,'Platform A','Asia-Pacific',2010); INSERT INTO offshore_platforms VALUES (2,'Platform B','Asia-Pacific',2012); INSERT INTO offshore_platforms VALUES (3,'Platform C','Asia-Pacific',2015); INSERT INTO offshore_platforms VALUES (4,'Platform D','Europe',2018);
SELECT COUNT(*) FROM offshore_platforms WHERE location = 'Asia-Pacific';
How many vulnerabilities were found in the 'Network Devices' category in the last quarter?
CREATE TABLE vulnerabilities (id INT,timestamp TIMESTAMP,category VARCHAR(255),severity VARCHAR(255)); INSERT INTO vulnerabilities (id,timestamp,category,severity) VALUES (1,'2022-01-01 10:00:00','Network Devices','High');
SELECT category, COUNT(*) as vulnerability_count FROM vulnerabilities WHERE timestamp >= DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 3 MONTH) AND category = 'Network Devices' GROUP BY category;
How many sightings of each marine species were recorded?
CREATE TABLE Sightings (Species VARCHAR(25),Sightings INT); INSERT INTO Sightings (Species,Sightings) VALUES ('Dolphin',200),('Turtle',300),('Shark',150),('Whale',400),('Dolphin',250);
SELECT Species, COUNT(*) FROM Sightings GROUP BY Species;
What is the average number of volunteer hours per volunteer for each program in 2021?
CREATE TABLE programs (id INT,name VARCHAR(255)); INSERT INTO programs (id,name) VALUES (1,'Mentoring'),(2,'After-School Tutoring'),(3,'Community Garden'); CREATE TABLE volunteer_hours (id INT,program_id INT,volunteer_id INT,hours INT); INSERT INTO volunteer_hours (id,program_id,volunteer_id,hours) VALUES (1,1,1,25),(2,2,2,30),(3,1,3,20),(4,3,4,40),(5,2,5,35),(6,1,6,22),(7,3,7,45),(8,2,8,33),(9,1,9,27),(10,3,10,50),(11,1,1,20),(12,2,2,25),(13,1,3,30),(14,3,4,35),(15,2,5,30),(16,1,6,25),(17,3,7,40),(18,2,8,35),(19,1,9,30),(20,3,10,45);
SELECT program_id, AVG(hours) as avg_volunteer_hours FROM volunteer_hours GROUP BY program_id;
How many games did a player play in the last season?
CREATE TABLE players (player_id INT,player_name TEXT); CREATE TABLE games (game_id INT,player_id INT,season TEXT);
SELECT p.player_name, (SELECT COUNT(*) FROM games g WHERE g.player_id = p.player_id AND g.season = 'last_season') as games_played FROM players p;
Delete all records in the 'military_equipment' table where the 'equipment_type' is 'Aircraft' AND the 'country_of_origin' is 'USA'
CREATE TABLE military_equipment (id INT,equipment_type VARCHAR(20),country_of_origin VARCHAR(20)); INSERT INTO military_equipment (id,equipment_type,country_of_origin) VALUES (1,'Aircraft','USA'),(2,'Ground Vehicle','Russia'),(3,'Naval Vessel','China');
DELETE FROM military_equipment WHERE equipment_type = 'Aircraft' AND country_of_origin = 'USA';
How many trees are present in each forest type in the 'forest_inventory' table?
CREATE TABLE forest_inventory (id INT,forest_type VARCHAR(255),tree_count INT); INSERT INTO forest_inventory (id,forest_type,tree_count) VALUES (1,'Temperate',1000),(2,'Tropical',2000),(3,'Boreal',1500);
SELECT forest_type, SUM(tree_count) FROM forest_inventory GROUP BY forest_type;
What is the earliest transaction date for account number 999999999?
CREATE TABLE transactions (transaction_id INT,account_number INT,amount DECIMAL(10,2),transaction_date DATE); INSERT INTO transactions (transaction_id,account_number,amount,transaction_date) VALUES (1,999999999,50.00,'2022-05-01'),(2,999999999,50.00,'2022-05-02');
SELECT MIN(transaction_date) FROM transactions WHERE account_number = 999999999;
What is the total number of volunteers from rural areas who have volunteered in the last year?
CREATE TABLE volunteers (id INT,name VARCHAR(50),reg_date DATE,location VARCHAR(30)); INSERT INTO volunteers (id,name,reg_date,location) VALUES (1,'Alex','2023-02-01','urban'),(2,'Bella','2023-01-15','rural'),(3,'Charlie','2023-03-05','suburban'),(4,'Diana','2022-07-20','rural'),(5,'Eli','2022-10-05','rural');
SELECT COUNT(*) FROM volunteers WHERE location = 'rural' AND reg_date >= DATEADD(year, -1, GETDATE());
What is the average gas price for transactions in the last 30 days, segmented by day?
CREATE TABLE transactions (id INT,transaction_hash VARCHAR(255),gas_price INT,timestamp TIMESTAMP); INSERT INTO transactions (id,transaction_hash,gas_price,timestamp) VALUES (1,'0x123...',10,'2022-02-01 00:00:00'),(2,'0x456...',12,'2022-02-02 12:34:56'),(3,'0x789...',8,'2022-02-09 14:23:01');
SELECT DATE(timestamp) as transaction_date, AVG(gas_price) as avg_gas_price FROM transactions WHERE timestamp >= DATE_SUB(NOW(), INTERVAL 30 DAY) GROUP BY transaction_date;
List all transactions for account number '123456789' in January 2022.
CREATE TABLE transactions (transaction_id INT,account_number INT,amount DECIMAL(10,2),transaction_date DATE); INSERT INTO transactions (transaction_id,account_number,amount,transaction_date) VALUES (1,123456789,100.00,'2022-01-05'),(2,123456789,200.00,'2022-01-10'),(3,987654321,50.00,'2022-02-15');
SELECT * FROM transactions WHERE account_number = 123456789 AND transaction_date BETWEEN '2022-01-01' AND '2022-01-31';
How many whale sightings were recorded in the Atlantic ocean in the last year?
CREATE TABLE whale_sightings (sighting_date DATE,location VARCHAR(255)); INSERT INTO whale_sightings (sighting_date,location) VALUES ('2021-06-15','Atlantic Ocean'),('2022-03-02','Atlantic Ocean');
SELECT COUNT(*) FROM whale_sightings WHERE location = 'Atlantic Ocean' AND sighting_date >= DATEADD(year, -1, GETDATE());
List the total production quantity of Terbium for each year it was produced.
CREATE TABLE Terbium_Production (Year INT,Quantity INT); INSERT INTO Terbium_Production (Year,Quantity) VALUES (2016,700),(2017,750),(2018,800),(2019,850);
SELECT Year, SUM(Quantity) FROM Terbium_Production GROUP BY Year;
What is the minimum value of military equipment sales in a single transaction to the Middle East?
CREATE TABLE MilitaryEquipmentSales (id INT PRIMARY KEY,year INT,country VARCHAR(50),equipment VARCHAR(50),value FLOAT); INSERT INTO MilitaryEquipmentSales (id,year,country,equipment,value) VALUES (1,2022,'Saudi Arabia','Missiles',1000000);
SELECT MIN(value) FROM MilitaryEquipmentSales WHERE country LIKE 'Middle East%';
What is the number of unique donors who made a donation in Q2 2022 and also volunteered in Q3 2022?
CREATE TABLE donations (donor_id INT,organization_id INT,amount DECIMAL(10,2),donation_date DATE); INSERT INTO donations (donor_id,organization_id,amount,donation_date) VALUES (1,101,500.00,'2022-04-01'),(2,102,350.00,'2022-04-15'),(3,101,200.00,'2022-04-30'),(1,101,50.00,'2022-07-05'),(2,102,100.00,'2022-07-20'),(3,101,75.00,'2022-07-10');
SELECT COUNT(DISTINCT donor_id) as unique_donors FROM donations d1 WHERE EXTRACT(QUARTER FROM donation_date) = 2 AND donor_id IN (SELECT donor_id FROM donations d2 WHERE EXTRACT(QUARTER FROM donation_date) = 3);
Find the least popular size among customers
CREATE TABLE customer_size (id INT,name VARCHAR(50),size VARCHAR(20)); INSERT INTO customer_size (id,name,size) VALUES (1,'David','L'); INSERT INTO customer_size (id,name,size) VALUES (2,'Eva','M'); INSERT INTO customer_size (id,name,size) VALUES (3,'Frank','S'); INSERT INTO customer_size (id,name,size) VALUES (4,'Grace','XL');
SELECT size, COUNT(*) FROM customer_size GROUP BY size ORDER BY COUNT(*) ASC LIMIT 1;
What is the energy efficiency rating of vehicles in South Korea?
CREATE TABLE vehicle_efficiency (vehicle TEXT,rating FLOAT); INSERT INTO vehicle_efficiency (vehicle,rating) VALUES ('Car A',8.0),('Bus B',6.5),('Truck C',4.0),('Motorcycle D',3.0);
SELECT vehicle, rating FROM vehicle_efficiency WHERE vehicle IN ('Car A', 'Bus B', 'Truck C', 'Motorcycle D');
What is the average recycling rate for residential areas in California over the last 3 months?
CREATE TABLE recycling_rates(location VARCHAR(50),date DATE,recycling_rate DECIMAL(5,2)); INSERT INTO recycling_rates(location,date,recycling_rate) VALUES ('California','2022-01-01',0.65),('California','2022-01-02',0.67),('California','2022-01-03',0.68),('California','2022-04-01',0.70),('California','2022-04-02',0.72),('California','2022-04-03',0.71);
SELECT AVG(recycling_rate) FROM recycling_rates WHERE location = 'California' AND date BETWEEN '2022-01-01' AND '2022-03-31';
Insert new record of military equipment sale to 'South America' in 2021
CREATE TABLE military_sales_3 (id INT,region VARCHAR,year INT,value FLOAT);
INSERT INTO military_sales_3 (id, region, year, value) VALUES (1, 'South America', 2021, 500000);
Which artists have the most artwork entries in the database, grouped by continent?
CREATE TABLE Artist (ArtistID INT,ArtistName TEXT,Continent TEXT); INSERT INTO Artist (ArtistID,ArtistName,Continent) VALUES (1,'Vincent Van Gogh','Europe');
SELECT Continent, ArtistName, COUNT(*) as ArtworkCount FROM Artist GROUP BY Continent, ArtistName ORDER BY Continent, COUNT(*) DESC;
List all the unique locations where 'Habitat Restoration' programs are being conducted from the 'education_programs' table?
CREATE TABLE education_programs (id INT,program_name VARCHAR(50),location VARCHAR(50),participants INT); INSERT INTO education_programs (id,program_name,location,participants) VALUES (1,'Wildlife Conservation','New York',100),(2,'Habitat Restoration','Los Angeles',150),(3,'Bird Watching','Chicago',75),(4,'Habitat Restoration','San Francisco',120);
SELECT DISTINCT location FROM education_programs WHERE program_name = 'Habitat Restoration'
Determine the number of public events held in the city of Los Angeles in each month of the year 2021
CREATE TABLE public_events (event_id INT,city VARCHAR(20),year INT,month INT,events_held INT); INSERT INTO public_events (event_id,city,year,month,events_held) VALUES (1,'Los Angeles',2021,1,10);
SELECT month, SUM(events_held) FROM public_events WHERE city = 'Los Angeles' AND year = 2021 GROUP BY month;
What is the average budget for cybersecurity operations in the 'Budget' table?
CREATE TABLE Budget (year INT,cybersecurity_budget INT,other_budget INT); INSERT INTO Budget (year,cybersecurity_budget,other_budget) VALUES (2018,5000000,15000000); INSERT INTO Budget (year,cybersecurity_budget,other_budget) VALUES (2019,5500000,16000000);
SELECT AVG(cybersecurity_budget) FROM Budget;
What was the total budget allocated for the 'Healthcare' department in the year 2021?
CREATE TABLE Budget(year INT,department VARCHAR(20),amount INT); INSERT INTO Budget VALUES (2021,'Healthcare',7000000),(2021,'Education',5000000),(2022,'Healthcare',7800000),(2022,'Education',5500000);
SELECT SUM(amount) FROM Budget WHERE department = 'Healthcare' AND year = 2021;
What is the number of hotels in 'Rio de Janeiro' with virtual tours?
CREATE TABLE hotels (hotel_id INT,name TEXT,city TEXT,virtual_tour BOOLEAN);
SELECT city, COUNT(*) as num_hotels FROM hotels WHERE city = 'Rio de Janeiro' AND virtual_tour = TRUE GROUP BY city;
Update records in the 'explainability_scores' table where the 'algorithm_name' is 'DL Algo 2' and the 'explanation_score' is less than 60
CREATE TABLE explainability_scores (id INT PRIMARY KEY,algorithm_name VARCHAR(50),explanation_score INT,evaluation_date DATE);
UPDATE explainability_scores SET explanation_score = explanation_score + 15 WHERE algorithm_name = 'DL Algo 2' AND explanation_score < 60;