instruction stringlengths 0 1.06k | input stringlengths 11 5.3k | response stringlengths 2 4.44k |
|---|---|---|
What is the average score difference between the home team and the away team in the NBA? | CREATE TABLE nba_games (game_id INT,home_team VARCHAR(50),away_team VARCHAR(50),home_score INT,away_score INT); INSERT INTO nba_games (game_id,home_team,away_team,home_score,away_score) VALUES (1,'Golden State Warriors','Los Angeles Lakers',115,105); | SELECT AVG(home_score - away_score) AS avg_score_difference FROM nba_games; |
How many patients received the Moderna vaccine in each state? | CREATE TABLE vaccine_records (patient_id INT,vaccine_name VARCHAR(20),age INT,state VARCHAR(20)); INSERT INTO vaccine_records VALUES (1,'Moderna',35,'Texas'),(2,'Moderna',42,'Texas'),(3,'Moderna',50,'Florida'); INSERT INTO vaccine_records VALUES (4,'Moderna',25,'New York'),(5,'Moderna',30,'New York'),(6,'Moderna',40,'New York'); | SELECT state, COUNT(*) FROM vaccine_records WHERE vaccine_name = 'Moderna' GROUP BY state; |
How many renewable energy farms (wind and solar) are there in total? | CREATE TABLE wind_farms (id INT,name VARCHAR(50),region VARCHAR(50),capacity FLOAT,efficiency FLOAT); INSERT INTO wind_farms (id,name,region,capacity,efficiency) VALUES (1,'Windfarm A','North',130.6,0.29); CREATE TABLE solar_farms (id INT,name VARCHAR(50),region VARCHAR(50),capacity FLOAT,efficiency FLOAT); INSERT INTO solar_farms (id,name,region,capacity,efficiency) VALUES (1,'Solarfarm A','South',170.4,0.33); | SELECT COUNT(*) AS total_farms FROM wind_farms UNION SELECT COUNT(*) AS total_farms FROM solar_farms; |
Count the number of exhibitions held in Germany since 2010. | CREATE TABLE Exhibitions (id INT,name VARCHAR(100),location VARCHAR(50),start_date DATE); INSERT INTO Exhibitions (id,name,location,start_date) VALUES (1,'Exhibition 1','Germany','2010-01-01'),(2,'Exhibition 2','France','2009-01-01'),(3,'Exhibition 3','Germany','2011-01-01'); | SELECT COUNT(*) FROM Exhibitions WHERE location = 'Germany' AND start_date >= '2010-01-01'; |
What is the total cargo weight transported by vessels from Japan to Port B? | CREATE TABLE cargo_data(id INT,vessel_name VARCHAR(50),destination VARCHAR(50),cargo_weight DECIMAL(5,2)); CREATE TABLE vessels(id INT,name VARCHAR(50),country VARCHAR(50),average_speed DECIMAL(5,2)); INSERT INTO vessels(id,name,country,average_speed) VALUES (1,'Vessel C','Japan',18.2),(2,'Vessel D','Japan',19.8); INSERT INTO cargo_data(id,vessel_name,destination,cargo_weight) VALUES (1,'Vessel C','Port B',220.0),(2,'Vessel D','Port A',275.0); | SELECT SUM(cargo_weight) FROM cargo_data JOIN vessels ON cargo_data.vessel_name = vessels.name WHERE vessels.country = 'Japan' AND destination = 'Port B'; |
What are the names of the military technologies with the highest and lowest code values in the 'military_tech' table? | CREATE TABLE military_tech (code INT,name VARCHAR(50),type VARCHAR(50),manufacturer VARCHAR(50),last_updated TIMESTAMP); | SELECT name, code FROM military_tech WHERE code = (SELECT MAX(code) FROM military_tech) OR code = (SELECT MIN(code) FROM military_tech); |
Insert a new record into the "employees" table with the following details: first name "Alex", last name "Smith", job_title "Engineer", and salary 50000 | CREATE TABLE employees (id INT PRIMARY KEY,first_name VARCHAR(50),last_name VARCHAR(50),job_title VARCHAR(50),salary INT); | INSERT INTO employees (first_name, last_name, job_title, salary) VALUES ('Alex', 'Smith', 'Engineer', 50000); |
Find the total quantity of non-GMO ingredients in our inventory. | CREATE TABLE NonGMOIngredients (id INT,name VARCHAR(50),quantity INT); INSERT INTO NonGMOIngredients (id,name,quantity) VALUES (1,'Spinach',500),(2,'Carrots',700),(3,'Garlic',300); | SELECT SUM(quantity) FROM NonGMOIngredients; |
What is the average recycling rate in Seoul for the last 6 months? | CREATE TABLE recycling_rates_seoul (city VARCHAR(50),recycling_rate DECIMAL(5,2),date DATE); INSERT INTO recycling_rates_seoul (city,recycling_rate,date) VALUES ('Seoul',0.70,'2022-01-01'),('Seoul',0.71,'2022-02-01'),('Seoul',0.72,'2022-03-01'),('Seoul',0.73,'2022-04-01'),('Seoul',0.74,'2022-05-01'),('Seoul',0.75,'2022-06-01'); | SELECT AVG(recycling_rate) FROM recycling_rates_seoul WHERE city = 'Seoul' AND date >= DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH); |
Calculate the average score of user 6 for all games played | CREATE TABLE game_scores (user_id INT,game_name VARCHAR(10),score INT); INSERT INTO game_scores (user_id,game_name,score) VALUES (1,'A',50),(2,'B',100),(3,'D',150),(4,'C',200),(4,'C',250),(6,'D',300),(6,'A',350); | SELECT AVG(score) FROM game_scores WHERE user_id = 6; |
What are the total items shipped between Canada and India, excluding items shipped in January 2021? | CREATE TABLE Shipment (id INT,source_country VARCHAR(255),destination_country VARCHAR(255),items_quantity INT,shipment_date DATE); INSERT INTO Shipment (id,source_country,destination_country,items_quantity,shipment_date) VALUES (1,'Canada','India',100,'2021-01-01'),(2,'Canada','India',200,'2021-02-01'); | SELECT SUM(items_quantity) FROM Shipment WHERE (source_country = 'Canada' AND destination_country = 'India') OR (source_country = 'India' AND destination_country = 'Canada') AND shipment_date NOT BETWEEN '2021-01-01' AND '2021-01-31'; |
Delete military equipment maintenance records older than 5 years | CREATE TABLE military_equipment_maintenance (id INT PRIMARY KEY,equipment_name VARCHAR(50),last_maintenance_date DATE,next_maintenance_date DATE,maintenance_type VARCHAR(50),maintenance_status VARCHAR(50)); | DELETE FROM military_equipment_maintenance WHERE last_maintenance_date < (CURRENT_DATE - INTERVAL '5 years'); |
What is the minimum and maximum property price for inclusive housing projects in the city of "Boston"? | CREATE TABLE inclusive_housing (project_id INT,property_id INT,price FLOAT,city_id INT,PRIMARY KEY (project_id)); INSERT INTO inclusive_housing (project_id,property_id,price,city_id) VALUES (1,1,500000.0,1),(2,2,600000.0,1),(3,3,400000.0,1); CREATE TABLE cities (city_id INT,city_name TEXT,PRIMARY KEY (city_id)); INSERT INTO cities (city_id,city_name) VALUES (1,'Boston'),(2,'Chicago'),(3,'Oakland'); | SELECT MIN(price), MAX(price) FROM inclusive_housing JOIN cities ON inclusive_housing.city_id = cities.city_id WHERE cities.city_name = 'Boston'; |
Count the number of customers from the 'Asia-Pacific' region who have made a transaction in the last month. | CREATE TABLE customers (id INT,region VARCHAR(20)); CREATE TABLE transactions (id INT,customer_id INT,transaction_date DATE); INSERT INTO customers (id,region) VALUES (1,'Asia-Pacific'); INSERT INTO transactions (id,customer_id,transaction_date) VALUES (1,1,'2022-05-10'); | SELECT COUNT(DISTINCT customers.id) FROM customers JOIN transactions ON customers.id = transactions.customer_id WHERE customers.region = 'Asia-Pacific' AND transactions.transaction_date >= DATE_SUB(CURDATE(), INTERVAL 1 MONTH); |
What is the total number of vessels in the maritime safety database? | CREATE TABLE maritime_safety (vessel_id INT,name VARCHAR(255),type VARCHAR(255)); INSERT INTO maritime_safety (vessel_id,name,type) VALUES (1,'Queen Mary 2','Passenger'),(2,'Seabed Worker','Research'),(3,'Tanker','Cargo'); | SELECT COUNT(*) FROM maritime_safety; |
What is the production of wells in the North Sea with a well_id greater than 1? | CREATE TABLE wells (well_id INT,name VARCHAR(50),location VARCHAR(50),production FLOAT); INSERT INTO wells (well_id,name,location,production) VALUES (1,'A1','North Sea',10000),(2,'A2','North Sea',11000),(3,'A3','North Sea',12000); | SELECT production FROM wells WHERE location = 'North Sea' AND well_id > 1; |
What is the average age of players who have played Virtual Reality games? | CREATE TABLE players (id INT,age INT,country VARCHAR(50),vrgames BOOLEAN); INSERT INTO players (id,age,country,vrgames) VALUES (1,25,'Canada',true),(2,30,'USA',false); | SELECT AVG(age) FROM players WHERE vrgames = true; |
Find the number of unique users who have accessed the network from each country in the 'user_activity' table. | CREATE TABLE user_activity (id INT,user_id INT,country VARCHAR(255),activity_date DATE); | SELECT country, COUNT(DISTINCT user_id) as unique_users FROM user_activity GROUP BY country; |
What is the total number of units in green-certified buildings? | CREATE TABLE green_buildings (building_id INT,num_units INT,is_green_certified BOOLEAN); INSERT INTO green_buildings (building_id,num_units,is_green_certified) VALUES (1,20,true),(2,30,false),(3,40,true),(4,50,true),(5,60,false); | SELECT SUM(num_units) FROM green_buildings WHERE is_green_certified = true; |
Determine the difference in days between the launch dates of the first and last missions for each spacecraft. | CREATE TABLE Spacecraft_Mission_Timeline (id INT,spacecraft_id INT,mission_name VARCHAR(100),mission_date DATE,launch_order INT); INSERT INTO Spacecraft_Mission_Timeline (id,spacecraft_id,mission_name,mission_date,launch_order) VALUES (1,1,'Apollo 11','1969-07-16',1); | SELECT spacecraft_id, DATEDIFF(MAX(mission_date), MIN(mission_date)) as mission_duration_days FROM Spacecraft_Mission_Timeline GROUP BY spacecraft_id |
Compare the market trends of Neodymium and Terbium | CREATE TABLE market_trends (year INT,element VARCHAR(10),price FLOAT); INSERT INTO market_trends VALUES (2015,'Neodymium',50),(2016,'Neodymium',55),(2015,'Terbium',200),(2016,'Terbium',250); | SELECT element, price FROM market_trends WHERE year = 2015 UNION SELECT element, price FROM market_trends WHERE year = 2016 ORDER BY element, price; |
What is the average price of ethical products in each country? | CREATE TABLE inventory (product_id INT,store_id INT,in_stock INT,ethical_product BOOLEAN,product_price DECIMAL); INSERT INTO inventory (product_id,store_id,in_stock,ethical_product,product_price) VALUES (1,1,50,true,15.99),(2,1,75,false,25.49),(3,2,30,true,12.99),(4,2,80,false,18.99),(5,3,100,true,9.99); | SELECT i.country, AVG(i.product_price) as avg_price FROM (SELECT store_id, country, product_price FROM inventory i JOIN stores s ON i.store_id = s.store_id WHERE ethical_product = true) i GROUP BY i.country; |
What is the average water usage for all customers in the top 3 regions with the highest water usage? | CREATE TABLE customers (customer_id INT,region VARCHAR(20),water_usage FLOAT); INSERT INTO customers (customer_id,region,water_usage) VALUES (1,'Sacramento',5000),(2,'San_Diego',4000),(3,'Sacramento',7000),(4,'Los_Angeles',6000),(5,'San_Francisco',3000),(6,'Los_Angeles',8000),(7,'Sacramento',9000),(8,'San_Diego',5000),(9,'Los_Angeles',7000),(10,'San_Francisco',4000); CREATE TABLE regions (region VARCHAR(20),PRIMARY KEY (region)); INSERT INTO regions (region) VALUES ('Sacramento'),('San_Diego'),('Los_Angeles'),('San_Francisco'); | SELECT AVG(customers.water_usage) FROM customers JOIN (SELECT region FROM regions JOIN customers ON regions.region = customers.region GROUP BY region ORDER BY SUM(customers.water_usage) DESC LIMIT 3) AS top_regions ON customers.region = top_regions.region; |
Delete records in the 'employee' table where the 'position' is 'field worker' | CREATE TABLE employee (employee_id INT,name VARCHAR(50),position VARCHAR(20)); | DELETE FROM employee WHERE position = 'field worker'; |
List the top 3 producers of Dysprosium by total production quantity for the year 2020. | CREATE TABLE production (id INT,mine_id INT,year INT,element TEXT,production_quantity INT); INSERT INTO production (id,mine_id,year,element,production_quantity) VALUES (1,1,2020,'Dysprosium',250),(2,2,2020,'Dysprosium',300),(3,3,2020,'Dysprosium',350),(4,1,2020,'Terbium',150),(5,2,2020,'Terbium',200),(6,3,2020,'Terbium',250); | SELECT mine_id, SUM(production_quantity) FROM production WHERE year = 2020 AND element = 'Dysprosium' GROUP BY mine_id ORDER BY SUM(production_quantity) DESC LIMIT 3; |
What is the maximum heart rate recorded for users in the afternoon? | CREATE TABLE heart_rate_times (user_id INT,heart_rate INT,measurement_time TIME); INSERT INTO heart_rate_times (user_id,heart_rate,measurement_time) VALUES (1,80,'13:00:00'),(2,85,'14:00:00'),(3,90,'15:00:00'),(4,95,'16:00:00'); | SELECT MAX(heart_rate) FROM heart_rate_times WHERE EXTRACT(HOUR FROM measurement_time) BETWEEN 12 AND 17; |
What is the maximum salary for employees in the largest department? | CREATE TABLE Employees (EmployeeID int,Department varchar(20),Salary decimal(10,2)); INSERT INTO Employees (EmployeeID,Department,Salary) VALUES (1,'IT',75000.00),(2,'IT',80000.00),(3,'Marketing',90000.00),(4,'Sales',85000.00),(5,'Sales',95000.00); | SELECT MAX(Salary) FROM Employees WHERE Department = (SELECT Department FROM Employees GROUP BY Department ORDER BY COUNT(*) DESC LIMIT 1); |
How many users from the USA and Japan liked or commented on posts about vegan food in the past month? | CREATE TABLE posts (post_id INT,post_country VARCHAR(255),post_topic VARCHAR(255),post_date DATE); CREATE TABLE user_interactions (interaction_id INT,user_id INT,post_id INT,interaction_type VARCHAR(10)); INSERT INTO posts (post_id,post_country,post_topic,post_date) VALUES (1,'USA','vegan food','2022-07-01'),(2,'Japan','vegan food','2022-07-05'); INSERT INTO user_interactions (interaction_id,user_id,post_id,interaction_type) VALUES (1,1,1,'like'),(2,2,1,'comment'),(3,3,2,'like'); | SELECT SUM(interaction_type = 'like') + SUM(interaction_type = 'comment') AS total_interactions FROM user_interactions WHERE post_id IN (SELECT post_id FROM posts WHERE post_date BETWEEN DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) AND CURRENT_DATE AND post_country IN ('USA', 'Japan') AND post_topic = 'vegan food'); |
What is the average ESG score of companies in the energy sector? | CREATE TABLE companies (id INT,sector VARCHAR(255),ESG_score FLOAT); INSERT INTO companies (id,sector,ESG_score) VALUES (1,'energy',55.3); | SELECT AVG(ESG_score) FROM companies WHERE sector = 'energy'; |
Show the total cost of all resilience projects in the 'California' region | CREATE TABLE projects (id INT,name VARCHAR(255),type VARCHAR(255),cost INT); INSERT INTO projects (id,name,type,cost) VALUES (789,'Seawall123','Resilience',2000000),(101,'RoadRepair456','Infrastructure',1000000); CREATE TABLE regions (id INT,name VARCHAR(255),country VARCHAR(255)); INSERT INTO regions (id,name,country) VALUES (1,'California','USA'),(2,'Ontario','Canada'); | SELECT SUM(projects.cost) FROM projects INNER JOIN regions ON TRUE WHERE projects.type = 'Resilience' AND regions.name = 'California'; |
Calculate the average number of employees for companies founded by non-binary individuals in the renewable energy sector with at least one funding round. | CREATE TABLE company (id INT,name TEXT,industry TEXT,founding_year INT,founder_gender TEXT,num_employees INT,num_funding_rounds INT); | SELECT AVG(num_employees) FROM company WHERE industry = 'Renewable Energy' AND founder_gender = 'Non-binary' AND num_funding_rounds >= 1 |
Update the "peacekeeping_operations" table, setting the "operation_name" to 'Operation Blue Helmet' for records where the "operation_year" is 2020 | CREATE TABLE peacekeeping_operations (operation_id INT PRIMARY KEY,operation_name VARCHAR(50),country VARCHAR(50),operation_year INT); INSERT INTO peacekeeping_operations (operation_id,operation_name,country,operation_year) VALUES (1,'Operation Peaceful Sky','Cyprus',2019),(2,'Operation Ocean Shield','Somalia',2011),(3,'Operation Peacekeeper','Bosnia',2020); | UPDATE peacekeeping_operations SET operation_name = 'Operation Blue Helmet' WHERE operation_year = 2020; |
Add a new team 'Los Angeles Lakers' with id 3 | CREATE TABLE teams (id INT,name VARCHAR(255)); | INSERT INTO teams (id, name) VALUES (3, 'Los Angeles Lakers'); |
Update the name of the communication campaign in the 'climate_communication' table to 'Green Horizons' if its name is 'Green Tomorrow'. | CREATE TABLE climate_communication (campaign_name TEXT,start_date DATE,end_date DATE); INSERT INTO climate_communication (campaign_name,start_date,end_date) VALUES ('Climate Action','2021-01-01','2021-12-31'),('Green Tomorrow','2022-01-01','2022-12-31'); | UPDATE climate_communication SET campaign_name = 'Green Horizons' WHERE campaign_name = 'Green Tomorrow'; |
What is the total square footage of green-certified buildings in each zip code? | CREATE TABLE ZipCodes (ZipCodeID INT,Zip VARCHAR(10));CREATE TABLE Buildings (BuildingID INT,ZipCodeID INT,GreenCertified BOOLEAN,SquareFootage INT); | SELECT Z.Zip, SUM(B.SquareFootage) as TotalSqFt FROM Buildings B JOIN ZipCodes Z ON B.ZipCodeID = Z.ZipCodeID WHERE B.GreenCertified = TRUE GROUP BY Z.Zip; |
How many traditional music pieces were created in each country and their average duration? | CREATE TABLE TraditionalMusicCountry (id INT,piece VARCHAR(255),country VARCHAR(255),duration INT); INSERT INTO TraditionalMusicCountry (id,piece,country,duration) VALUES (1,'Inuit Throat Singing','Canada',120),(2,'Kecak','Indonesia',180),(3,'Danzas Folklóricas','Mexico',150); | SELECT country, piece, COUNT(*) as total_pieces, AVG(duration) as avg_duration FROM TraditionalMusicCountry GROUP BY country, piece; |
What is the total carbon offset achieved by all carbon offset programs in the state of Oregon since 2015? | CREATE TABLE carbon_offset_programs (id INT,name VARCHAR(50),state VARCHAR(50),offset_quantity INT,start_year INT); | SELECT SUM(offset_quantity) FROM carbon_offset_programs WHERE state = 'Oregon' AND start_year >= 2015; |
What is the regulatory status of decentralized applications in Germany? | CREATE TABLE dapps (id INT,name VARCHAR(50),country VARCHAR(50),regulatory_status VARCHAR(50)); INSERT INTO dapps VALUES (1,'App1','Germany','Regulated'); INSERT INTO dapps VALUES (2,'App2','Germany','Unregulated'); INSERT INTO dapps VALUES (3,'App3','Germany','Under Review'); | SELECT country, regulatory_status FROM dapps WHERE country = 'Germany'; |
Update the production amount for Malaysia in 2021 to 7500 tons. | CREATE TABLE production (country VARCHAR(255),amount INT,year INT); INSERT INTO production (country,amount,year) VALUES ('Malaysia',7000,2021); | UPDATE production SET amount = 7500 WHERE country = 'Malaysia' AND year = 2021; |
Report the number of threat intelligence metrics collected by each agency for the category 'Cyber Attacks'. | CREATE TABLE threat_intelligence_cyber (metric_id INT,agency VARCHAR(255),category VARCHAR(255));INSERT INTO threat_intelligence_cyber (metric_id,agency,category) VALUES (1,'NSA','Cyber Attacks'),(2,'CIA','Foreign Spy Activity'),(3,'NSA','Cyber Attacks'),(4,'FBI','Domestic Terrorism'); | SELECT agency, COUNT(*) as cyber_attack_metrics FROM threat_intelligence_cyber WHERE category = 'Cyber Attacks' GROUP BY agency; |
What is the average life expectancy for each country in Europe, along with the number of countries? | CREATE TABLE countries (id INT,name TEXT,continent TEXT,life_expectancy FLOAT); INSERT INTO countries (id,name,continent,life_expectancy) VALUES (1,'Country A','Europe',80.5),(2,'Country B','Asia',72.3),(3,'Country C','Europe',78.7),(4,'Country D','Africa',65.1); | SELECT continent, AVG(life_expectancy) as avg_life_expectancy, COUNT(name) as num_countries FROM countries WHERE continent = 'Europe' GROUP BY continent; |
Add new virtual tours with their respective starting dates and updated timestamps. | CREATE TABLE virtual_tours (tour_id INT,tour_name TEXT,location TEXT,start_date DATETIME,updated_at DATETIME); INSERT INTO virtual_tours (tour_id,tour_name,location,start_date,updated_at) VALUES (1,'Louvre VR Experience','Paris','2023-06-01 10:00:00',NOW()),(2,'Gondola Tour in Venice','Venice','2023-07-01 11:00:00',NOW()),(3,'Great Wall of China Virtual Walk','China','2023-08-01 12:00:00',NOW()); | INSERT INTO virtual_tours (tour_id, tour_name, location, start_date, updated_at) VALUES (4, 'Machu Picchu Virtual Tour', 'Peru', '2023-09-01 13:00:00', NOW()), (5, 'Petra Virtual Experience', 'Jordan', '2023-10-01 14:00:00', NOW()); |
What is the average product price for items produced using ethical labor practices? | CREATE TABLE products (product_id INT,price DECIMAL,labor_practices VARCHAR(20)); INSERT INTO products (product_id,price,labor_practices) VALUES (1,15.99,'ethical'),(2,25.49,'unethical'),(3,12.99,'ethical'); | SELECT AVG(price) FROM products WHERE labor_practices = 'ethical'; |
Delete all records of pollution data in the Mariana Trench. | CREATE TABLE pollution_data (location TEXT,pollution_level INTEGER); INSERT INTO pollution_data (location,pollution_level) VALUES ('Mariana Trench',3); INSERT INTO pollution_data (location,pollution_level) VALUES ('Atlantic Ocean',2); | DELETE FROM pollution_data WHERE location = 'Mariana Trench'; |
What is the average price of vegan menu items in the breakfast category? | CREATE TABLE menus (menu_id INT,menu_name VARCHAR(255),category VARCHAR(255),price DECIMAL(10,2),is_vegan BOOLEAN); INSERT INTO menus (menu_id,menu_name,category,price,is_vegan) VALUES (1,'Quinoa Salad','Lunch',12.99,FALSE),(2,'Vegan Scramble','Breakfast',7.99,TRUE); | SELECT AVG(price) FROM menus WHERE category = 'Breakfast' AND is_vegan = TRUE; |
What is the total number of building permits issued for residential buildings in the state of New York in 2022? | CREATE TABLE building_permits (permit_id INT,building_type VARCHAR(50),state VARCHAR(50),issue_date DATE); INSERT INTO building_permits (permit_id,building_type,state,issue_date) VALUES (1,'Commercial','New York','2022-01-01'); INSERT INTO building_permits (permit_id,building_type,state,issue_date) VALUES (2,'Residential','New York','2022-02-01'); | SELECT COUNT(*) FROM building_permits WHERE building_type = 'Residential' AND state = 'New York' AND issue_date BETWEEN '2022-01-01' AND '2022-12-31'; |
What is the average bed count for rural hospitals and clinics in each country, and the total number of rural healthcare facilities in each? | CREATE TABLE hospitals (id INT,name TEXT,location TEXT,num_beds INT,country TEXT); INSERT INTO hospitals (id,name,location,num_beds,country) VALUES (1,'Hospital A','Rural Mexico',50,'Mexico'),(2,'Hospital B','Rural Guatemala',75,'Guatemala'); CREATE TABLE clinics (id INT,name TEXT,location TEXT,num_beds INT,country TEXT); INSERT INTO clinics (id,name,location,num_beds,country) VALUES (1,'Clinic A','Rural Mexico',25,'Mexico'),(2,'Clinic B','Rural Guatemala',35,'Guatemala'); | SELECT c.country, AVG(h.num_beds) AS avg_bed_count, AVG(c.num_beds) AS avg_clinic_bed_count, COUNT(h.id) + COUNT(c.id) AS total_facilities FROM hospitals h INNER JOIN clinics c ON h.country = c.country GROUP BY c.country; |
List all suppliers that have a fair labor certification. | CREATE TABLE suppliers (id INT,name VARCHAR(255),certification VARCHAR(255)); | SELECT name FROM suppliers WHERE certification = 'Fair Labor'; |
What is the average price of recycled materials used in production per region? | CREATE TABLE recycled_materials (id INT,region VARCHAR(255),material VARCHAR(255),price DECIMAL(10,2)); INSERT INTO recycled_materials VALUES (1,'North America','Recycled Plastic',1.50),(2,'North America','Recycled Paper',2.00),(3,'Europe','Recycled Textiles',3.00),(4,'Europe','Recycled Plastic',1.80); | SELECT region, AVG(price) FROM recycled_materials GROUP BY region; |
What is the maximum depth recorded for underwater canyons in the Pacific Ocean? | CREATE TABLE OceanFloor (feature_name VARCHAR(50),feature_type VARCHAR(50),depth_m INT,PRIMARY KEY(feature_name)); INSERT INTO OceanFloor (feature_name,feature_type,depth_m) VALUES ('Pacific Canyon 1','Underwater Canyon',7500),('Atlantic Ridge','Mid-Ocean Ridge',4000); | SELECT MAX(OceanFloor.depth_m) FROM OceanFloor WHERE OceanFloor.feature_type = 'Underwater Canyon' AND OceanFloor.region = 'Pacific Ocean'; |
Insert a new sustainable menu item "Impossible Burger" in the "Sustainable" category with a MenuID of 2003. | CREATE TABLE Menu (MenuID int,ItemName varchar(50),Category varchar(50)); | INSERT INTO Menu (MenuID, ItemName, Category) VALUES (2003, 'Impossible Burger', 'Sustainable'); |
Which education resources were distributed in South Sudan in Q4 2021? | CREATE TABLE education_resources (id INT,resource TEXT,quantity INT,country TEXT,quarter INT,year INT); INSERT INTO education_resources (id,resource,quantity,country,quarter,year) VALUES (1,'Textbooks',500,'South Sudan',4,2021),(2,'School Supplies',300,'South Sudan',4,2021),(3,'Laptops',200,'South Sudan',4,2021); | SELECT DISTINCT resource FROM education_resources WHERE country = 'South Sudan' AND quarter = 4 AND year = 2021; |
Delete the production data for Gadolinium from the Australian mine in 2019. | CREATE TABLE mine (id INT,name TEXT,location TEXT,Gadolinium_monthly_production FLOAT,timestamp TIMESTAMP); INSERT INTO mine (id,name,location,Gadolinium_monthly_production,timestamp) VALUES (1,'Australian Mine','Australia',120.5,'2019-03-01'),(2,'Californian Mine','USA',150.3,'2019-03-01'),(3,'Brazilian Mine','Brazil',80.0,'2019-03-01'); | DELETE FROM mine WHERE name = 'Australian Mine' AND EXTRACT(YEAR FROM timestamp) = 2019 AND EXISTS (SELECT * FROM mine WHERE name = 'Australian Mine' AND Gadolinium_monthly_production IS NOT NULL AND EXTRACT(YEAR FROM timestamp) = 2019); |
List all unique sports in 'team_performances_table' | CREATE TABLE team_performances_table (team_id INT,team_name VARCHAR(50),sport VARCHAR(20),wins INT,losses INT); INSERT INTO team_performances_table (team_id,team_name,sport,wins,losses) VALUES (1,'Blue Lions','Basketball',25,15); INSERT INTO team_performances_table (team_id,team_name,sport,wins,losses) VALUES (2,'Green Devils','Soccer',12,8); | SELECT DISTINCT sport FROM team_performances_table; |
What is the maximum number of work hours, grouped by the employee's role, who were working simultaneously in the 'Environmental Compliance' department in the past 2 months? | CREATE TABLE EmployeeWorkHours(id INT,employee_id INT,work_date DATE,role VARCHAR(50),department VARCHAR(50),work_hours INT); | SELECT role, MAX(COUNT(*)) as max_employees FROM EmployeeWorkHours WHERE department = 'Environmental Compliance' AND work_date >= DATE(NOW()) - INTERVAL 2 MONTH GROUP BY role; |
How many suppliers in Europe have a certification for Yttrium? | CREATE TABLE yttrium_suppliers (country VARCHAR(255),has_certification BOOLEAN); INSERT INTO yttrium_suppliers (country,has_certification) VALUES ('Germany',true),('France',false),('UK',true); | SELECT COUNT(*) FROM yttrium_suppliers WHERE country IN ('Germany', 'UK') AND has_certification = true; |
What is the maximum severity of vulnerabilities for each system type? | CREATE TABLE system_types (id INT,system_type TEXT,severity TEXT); INSERT INTO system_types (id,system_type,severity) VALUES (1,'Type1','High'),(2,'Type2','Medium'),(3,'Type3','Low'); CREATE TABLE system_vulnerabilities (system_id INT,system_type TEXT,vulnerability_id INT,severity TEXT); INSERT INTO system_vulnerabilities (system_id,system_type,vulnerability_id,severity) VALUES (1,'Type1',1,'High'),(2,'Type2',2,'Low'),(3,'Type1',3,'Medium'); | SELECT system_type, MAX(severity) as max_severity FROM system_vulnerabilities JOIN system_types ON system_types.system_type = system_vulnerabilities.system_type GROUP BY system_type; |
What is the total number of digital divide initiatives in South America? | CREATE TABLE divide_init (name VARCHAR(50),location VARCHAR(50),initiatives INT); INSERT INTO divide_init (name,location,initiatives) VALUES ('Connect South','South America',10),('Digital Inclusion','South America',15); | SELECT SUM(initiatives) FROM divide_init WHERE location = 'South America'; |
What is the minimum score of players from Oceania? | CREATE TABLE Player (PlayerID INT,Name VARCHAR(50),Country VARCHAR(50),Score INT); | SELECT MIN(Score) FROM Player WHERE Country IN ('Australia', 'New Zealand'); |
Identify patients who had a decrease in medical visits in the last 6 months compared to the previous 6 months in rural Montana. | CREATE TABLE medical_visits (id INT,patient_id INT,visit_date DATE,rural_mt BOOLEAN); INSERT INTO medical_visits (id,patient_id,visit_date,rural_mt) VALUES (1,1,'2019-06-01',true),(2,1,'2019-07-01',true); | SELECT patient_id, COUNT(*) as last_6_months, LAG(COUNT(*)) OVER (PARTITION BY patient_id ORDER BY visit_date) as previous_6_months FROM medical_visits WHERE rural_mt = true GROUP BY patient_id, visit_date HAVING last_6_months < previous_6_months; |
Delete green building records with a certification level lower than 'gold' from the 'green_buildings' table. | CREATE TABLE green_buildings (id INT,building_name VARCHAR(50),city VARCHAR(50),certification VARCHAR(50)); INSERT INTO green_buildings (id,building_name,city,certification) VALUES (1,'Empire State Building','New York','Gold'),(2,'Sears Tower','Chicago','Silver'); | DELETE FROM green_buildings WHERE certification NOT IN ('Gold', 'Platinum'); |
Find the average climate finance investment in mitigation projects in Europe. | CREATE TABLE climate_finance_mitigation_projects (project_id INT,sector TEXT,region TEXT,amount FLOAT); INSERT INTO climate_finance_mitigation_projects (project_id,sector,region,amount) VALUES (1,'Climate Mitigation','Europe',2000000); INSERT INTO climate_finance_mitigation_projects (project_id,sector,region,amount) VALUES (2,'Climate Mitigation','Europe',3000000); | SELECT AVG(amount) FROM climate_finance_mitigation_projects WHERE sector = 'Climate Mitigation' AND region = 'Europe'; |
Which TV shows have the highest viewership by season? | CREATE TABLE tv_viewership (id INT,title VARCHAR(255),season INT,viewership INT); INSERT INTO tv_viewership (id,title,season,viewership) VALUES (1,'Show1',1,1000000),(2,'Show2',1,1200000),(3,'Show1',2,1100000); | SELECT title, season, MAX(viewership) as max_viewership FROM tv_viewership GROUP BY title; |
Calculate the maximum temperature for each year in the 'temperature_data' table | CREATE TABLE temperature_data (id INT PRIMARY KEY,year INT,month INT,temperature DECIMAL(5,2)); INSERT INTO temperature_data (id,year,month,temperature) VALUES (1,2015,1,-20.5),(2,2015,2,-25.3),(3,2015,3,-18.7),(4,2015,4,-12.2),(5,2015,5,0.1),(6,2015,6,5.6),(7,2015,7,10.2),(8,2015,8,12.9),(9,2015,9,7.8),(10,2015,10,0.4),(11,2015,11,-5.2),(12,2015,12,-12.1),(13,2016,1,-21.5),(14,2016,2,-26.3),(15,2016,3,-19.7),(16,2016,4,-13.2),(17,2016,5,1.1),(18,2016,6,6.6),(19,2016,7,11.2),(20,2016,8,14.9),(21,2016,9,8.7),(22,2016,10,2.4),(23,2016,11,-4.2),(24,2016,12,-11.9); | SELECT year, MAX(temperature) FROM temperature_data GROUP BY year; |
What is the minimum number of visitors for jazz events in 2021? | CREATE TABLE IF NOT EXISTS events (id INT,name VARCHAR(255),type VARCHAR(255),year INT,visitors INT); INSERT INTO events (id,name,type,year,visitors) VALUES (1,'EventA','Jazz',2021,300),(2,'EventB','Jazz',2021,450),(3,'EventC','Jazz',2021,500); | SELECT MIN(visitors) FROM events WHERE type = 'Jazz' AND year = 2021; |
How many farmers in Haiti adopted sustainable agricultural practices in 2020? | CREATE TABLE Farmers (Farmer_ID INT,Farmer_Name TEXT,Location TEXT,Sustainable_Practices_Adopted INT,Year INT); INSERT INTO Farmers (Farmer_ID,Farmer_Name,Location,Sustainable_Practices_Adopted,Year) VALUES (1,'Jean-Claude','Haiti',1,2020); | SELECT SUM(Sustainable_Practices_Adopted) FROM Farmers WHERE Year = 2020 AND Location = 'Haiti'; |
What is the average budget allocated per school district in California, while only considering districts with more than 10 schools? | CREATE TABLE school_districts (district_id INT,district_name TEXT,state TEXT,number_of_schools INT,budget INT); INSERT INTO school_districts (district_id,district_name,state,number_of_schools,budget) VALUES (1,'Los Angeles Unified','California',15,2500000); INSERT INTO school_districts (district_id,district_name,state,number_of_schools,budget) VALUES (2,'San Francisco Unified','California',12,2000000); INSERT INTO school_districts (district_id,district_name,state,number_of_schools,budget) VALUES (3,'San Diego Unified','California',18,3000000); | SELECT AVG(budget) FROM school_districts WHERE state = 'California' AND number_of_schools > 10; |
What is the average number of community engagement events per year in each country? | CREATE TABLE CommunityEngagement (Event VARCHAR(255),Year INT,Country VARCHAR(255)); INSERT INTO CommunityEngagement (Event,Year,Country) VALUES ('Aboriginal Art Festival',2020,'Australia'),('Aboriginal Art Festival',2019,'Australia'),('Aboriginal Art Festival',2018,'Australia'),('Indigenous Film Festival',2020,'Australia'),('Indigenous Film Festival',2019,'Australia'),('Indigenous Film Festival',2018,'Australia'),('Maori Language Week',2020,'New Zealand'),('Maori Language Week',2019,'New Zealand'),('Maori Language Week',2018,'New Zealand'); | SELECT Country, AVG(Num_Events) as Avg_Num_Events FROM (SELECT Country, Year, COUNT(Event) as Num_Events FROM CommunityEngagement GROUP BY Country, Year) as subquery GROUP BY Country; |
Identify support programs with a higher than average cost for disability accommodations in California? | CREATE TABLE Support_Programs (State VARCHAR(2),Program VARCHAR(50),Cost DECIMAL(5,2)); INSERT INTO Support_Programs VALUES ('CA','Mobility Training',2000.00),('CA','Assistive Technology',2500.00),('CA','Hearing Loop',1800.00); | SELECT * FROM Support_Programs WHERE Cost > (SELECT AVG(Cost) FROM Support_Programs WHERE State = 'CA'); |
What is the percentage of games won by each team in the 2021-2022 NBA season? | CREATE TABLE nba_games (team TEXT,won INT,lost INT); INSERT INTO nba_games (team,won,lost) VALUES ('Lakers',33,49),('Clippers',42,40),('Suns',64,18); | SELECT team, (SUM(won) * 100.0 / (SUM(won) + SUM(lost))) as win_percentage FROM nba_games GROUP BY team; |
Which country has the highest number of startups founded by women? | CREATE TABLE startups(id INT,name TEXT,country TEXT,founder_gender TEXT); INSERT INTO startups VALUES (1,'EcoInnovate','Canada','Female'); INSERT INTO startups VALUES (2,'GreenTech','USA','Male'); INSERT INTO startups VALUES (3,'TechVenture','UK','Male'); INSERT INTO startups VALUES (4,'InnoVida','Brazil','Female'); | SELECT country, COUNT(*) AS count FROM startups WHERE founder_gender = 'Female' GROUP BY country ORDER BY count DESC LIMIT 1; |
How many accessible vehicles are there for each maintenance type? | CREATE TABLE Vehicles (VehicleID int,VehicleType varchar(50),Accessibility bit); INSERT INTO Vehicles VALUES (1,'Bus',1),(2,'Train',0),(3,'Tram',1); CREATE TABLE MaintenanceTypes (MaintenanceTypeID int,MaintenanceType varchar(50)); INSERT INTO MaintenanceTypes VALUES (1,'Oil Change'),(2,'Tire Rotation'); CREATE TABLE VehicleMaintenance (VehicleID int,MaintenanceTypeID int); INSERT INTO VehicleMaintenance VALUES (1,1),(1,2),(3,1); | SELECT V.VehicleType, M.MaintenanceType, COUNT(VM.VehicleID) as AccessibleVehicleCount FROM Vehicles V INNER JOIN VehicleMaintenance VM ON V.VehicleID = VM.VehicleID INNER JOIN MaintenanceTypes M ON VM.MaintenanceTypeID = M.MaintenanceTypeID WHERE V.Accessibility = 1 GROUP BY V.VehicleType, M.MaintenanceType; |
What are the details of heritage sites in the 'heritage' schema from the Caribbean region? | CREATE TABLE heritage_sites (id INT,name VARCHAR(255),region VARCHAR(255),description TEXT); INSERT INTO heritage_sites (id,name,region,description) VALUES (1,'Brimstone Hill Fortress','Caribbean','A fortress located in St. Kitts and Nevis'),(2,'Port Royal','Caribbean','A historic city located in Jamaica'); | SELECT * FROM heritage.heritage_sites WHERE region = 'Caribbean'; |
What is the average number of likes per post for influencers in the fashion genre? | CREATE TABLE influencer_posts (post_id INT,post_date DATE,influencer_name VARCHAR(50),genre VARCHAR(50),likes INT); INSERT INTO influencer_posts VALUES (501,'2022-01-01','Influencer R','Fashion',100),(502,'2022-01-03','Influencer S','Fashion',150),(503,'2022-01-05','Influencer T','Fashion',200),(504,'2022-01-07','Influencer R','Fashion',120); | SELECT genre, AVG(likes) as avg_likes_per_post FROM (SELECT genre, influencer_name, AVG(likes) as likes FROM influencer_posts GROUP BY genre, influencer_name) AS subquery WHERE genre = 'Fashion'; |
What is the average income of households with 4 members in the state of New York? | CREATE TABLE Households (HouseholdID INTEGER,HouseholdMembers INTEGER,HouseholdIncome INTEGER,HouseholdState TEXT); | SELECT AVG(HouseholdIncome) FROM Households H WHERE H.HouseholdMembers = 4 AND H.HouseholdState = 'New York'; |
What is the total biomass of fish species in the 'Arctic Ocean' per year? | CREATE TABLE fish_biomass (year INT,region VARCHAR(255),species VARCHAR(255),biomass FLOAT); INSERT INTO fish_biomass (year,region,species,biomass) VALUES (2020,'Arctic Ocean','Cod',1200),(2020,'Arctic Ocean','Haddock',800),(2021,'Arctic Ocean','Cod',1300); | SELECT year, SUM(biomass) AS total_biomass FROM fish_biomass WHERE region = 'Arctic Ocean' GROUP BY year; |
What is the maximum number of labor hours spent on a single permit in New York? | CREATE TABLE Permits (PermitID INT,State CHAR(2)); INSERT INTO Permits (PermitID,State) VALUES (1,'NY'),(2,'NY'),(3,'CA'); CREATE TABLE LaborHours (LaborHourID INT,PermitID INT,Hours DECIMAL(10,2)); INSERT INTO LaborHours (LaborHourID,PermitID,Hours) VALUES (1,1,250.00),(2,1,300.00),(3,2,150.00),(4,3,400.00),(5,1,500.00); | SELECT MAX(LaborHours.Hours) FROM LaborHours INNER JOIN Permits ON LaborHours.PermitID = Permits.PermitID WHERE Permits.State = 'NY'; |
What is the average property price in the "GreenCommunity" and "SolarVillage" neighborhoods, grouped by property type? | CREATE TABLE Property (id INT,neighborhood VARCHAR(20),price FLOAT,property_type VARCHAR(20)); INSERT INTO Property (id,neighborhood,price,property_type) VALUES (1,'GreenCommunity',500000,'Apartment'),(2,'SolarVillage',700000,'House'); | SELECT Property.property_type, AVG(Property.price) FROM Property WHERE Property.neighborhood IN ('GreenCommunity', 'SolarVillage') GROUP BY Property.property_type; |
Which country has the highest average word count in news articles? | CREATE TABLE Countries (country VARCHAR(255),num_articles INT,total_words INT); INSERT INTO Countries (country,num_articles,total_words) VALUES ('USA',1200,400000),('India',850,250000),('China',1025,350000); | SELECT country, AVG(total_words/num_articles) as avg_word_count FROM Countries GROUP BY country ORDER BY avg_word_count DESC LIMIT 1; |
Find the number of unique cities where articles about climate change were published in 2021. | CREATE TABLE articles (id INT,title TEXT,category TEXT,publish_date DATE,location TEXT); INSERT INTO articles (id,title,category,publish_date,location) VALUES (1,'Climate Crisis Explained','climate_change','2021-01-01','New York'),(2,'Fintech Trends in Asia','technology','2022-06-05','Singapore'); | SELECT COUNT(DISTINCT location) FROM articles WHERE category = 'climate_change' AND YEAR(publish_date) = 2021; |
Which country has the highest average sales in the jazz genre, across all platforms? | CREATE TABLE sales (sale_id INT,country VARCHAR(10),genre VARCHAR(10),platform VARCHAR(10),sales FLOAT); | SELECT country, AVG(sales) FROM sales WHERE genre = 'jazz' GROUP BY country ORDER BY AVG(sales) DESC LIMIT 1; |
What is the number of humanitarian assistance events in South America in the last decade, by country and year? | CREATE TABLE HumanitarianAssistance (ID INT,EventName TEXT,EventDate DATE,Country TEXT,Year INT); INSERT INTO HumanitarianAssistance VALUES (1,'Event 1','2013-01-01','Brazil',2013); CREATE VIEW SouthAmerica AS SELECT Country FROM HumanitarianAssistance WHERE Country IN ('Brazil','Argentina','Colombia','Peru','Chile'); | SELECT h.Country, h.Year, COUNT(*) as TotalEvents FROM HumanitarianAssistance h JOIN SouthAmerica sa ON h.Country = sa.Country WHERE h.Year BETWEEN DATEADD(year, -10, GETDATE()) AND GETDATE() GROUP BY h.Country, h.Year; |
Find the daily sales for the most expensive menu item in each restaurant | CREATE TABLE restaurant (id INT,name VARCHAR(255)); INSERT INTO restaurant (id,name) VALUES (1,'Bistro'),(2,'Grill'),(3,'Cafe'); CREATE TABLE menu (id INT,item VARCHAR(255),price DECIMAL(5,2),daily_sales INT,restaurant_id INT); | SELECT r.name, m.item, m.daily_sales FROM menu m JOIN (SELECT restaurant_id, MAX(price) as max_price FROM menu GROUP BY restaurant_id) mm ON m.restaurant_id = mm.restaurant_id AND m.price = mm.max_price JOIN restaurant r ON m.restaurant_id = r.id; |
List all investments made by investors from the 'Asia' region. | CREATE TABLE investment (id INT PRIMARY KEY,company_id INT,investor_id INT,investment_amount INT,investment_date DATE); INSERT INTO investment (id,company_id,investor_id,investment_amount,investment_date) VALUES (1,1,4,50000,'2020-01-01'); INSERT INTO investment (id,company_id,investor_id,investment_amount,investment_date) VALUES (2,2,5,75000,'2019-12-15'); INSERT INTO investment (id,company_id,investor_id,investment_amount,investment_date) VALUES (3,3,6,30000,'2021-02-03'); INSERT INTO investor (id,name,organization,location) VALUES (4,'James Lee','Asia Investment Group','Hong Kong'); INSERT INTO investor (id,name,organization,location) VALUES (5,'Yumi Kim','Japan Impact Fund','Japan'); INSERT INTO investor (id,name,organization,location) VALUES (6,'Raj Patel','India Impact Investment','India'); | SELECT i.investment_date, i.investment_amount, j.name, j.location FROM investment AS i JOIN investor AS j ON i.investor_id = j.id WHERE j.location LIKE 'Asia%'; |
How many community health workers are there in each city? | CREATE TABLE community_health_workers (worker_id INT,name VARCHAR(50),city VARCHAR(25)); INSERT INTO community_health_workers (worker_id,name,city) VALUES (1,'John Doe','Los Angeles'); INSERT INTO community_health_workers (worker_id,name,city) VALUES (2,'Jane Smith','New York City'); INSERT INTO community_health_workers (worker_id,name,city) VALUES (3,'Maria Garcia','Houston'); | SELECT city, COUNT(*) FROM community_health_workers GROUP BY city; |
What's the most common age group for TV show viewers? | CREATE TABLE tv_show_viewers(viewer_id INT,age_group VARCHAR(10),show_id INT); INSERT INTO tv_show_viewers(viewer_id,age_group,show_id) VALUES (1,'18-24',1),(2,'18-24',2),(3,'25-34',2),(4,'35-44',3),(5,'25-34',1),(6,'45-54',3),(7,'55-64',1),(8,'18-24',3); | SELECT age_group, COUNT(*) AS viewer_count FROM tv_show_viewers GROUP BY age_group ORDER BY viewer_count DESC LIMIT 1; |
Rank national security budgets for the last 3 years, partitioned by the region, in descending order of budget amount. | CREATE TABLE budgets (budget_id INT,year INT,region_id INT,amount INT); INSERT INTO budgets (budget_id,year,region_id,amount) VALUES (1,2019,1,500),(2,2020,1,600),(3,2021,1,700),(4,2019,2,400),(5,2020,2,450),(6,2021,2,500); | SELECT year, region_id, amount, RANK() OVER (PARTITION BY year, region_id ORDER BY amount DESC) as ranking FROM budgets ORDER BY year, region_id, ranking; |
What's the viewership trend for TV shows in the US over the last 5 years? | CREATE TABLE tv_shows (id INT,title VARCHAR(255),release_year INT,country VARCHAR(100),viewership INT); | SELECT release_year, AVG(viewership) as avg_viewership FROM tv_shows WHERE country = 'US' GROUP BY release_year ORDER BY release_year DESC LIMIT 5; |
What is the maximum property tax for buildings in low-income neighborhoods in New York City? | CREATE TABLE buildings (id INT,city VARCHAR,low_income BOOLEAN,property_tax DECIMAL); | SELECT MAX(property_tax) FROM buildings WHERE city = 'New York City' AND low_income = TRUE; |
What is the percentage of fish in the fish_stock table that are from sustainable sources? | CREATE TABLE fish_stock (species VARCHAR(50),is_sustainable BOOLEAN); | SELECT (COUNT(*) * 100.0 / (SELECT COUNT(*) FROM fish_stock)) as sustainability_percentage FROM fish_stock WHERE is_sustainable = TRUE; |
How many games have been designed by each game design studio? | CREATE TABLE GameDesign (GameID INT,Studio VARCHAR(50)); INSERT INTO GameDesign (GameID,Studio) VALUES (1,'Studio A'),(2,'Studio B'),(3,'Studio A'),(4,'Studio C'),(5,'Studio B'); | SELECT Studio, COUNT(*) as GameCount FROM GameDesign GROUP BY Studio; |
What is the total duration of all songs by 'Artist B'? | CREATE TABLE songs (id INT,title VARCHAR(255),duration INT,artist VARCHAR(255)); INSERT INTO songs (id,title,duration,artist) VALUES (1,'Song 1',180,'Artist B'); | SELECT SUM(duration) FROM songs WHERE artist = 'Artist B'; |
What is the most popular game genre among players under 30? | CREATE TABLE players (id INT,age INT,game_genre VARCHAR(20)); INSERT INTO players (id,age,game_genre) VALUES (1,25,'racing'),(2,30,'rpg'),(3,22,'racing'),(4,35,'strategy'); | SELECT game_genre, COUNT(*) as count FROM players WHERE age < 30 GROUP BY game_genre ORDER BY count DESC LIMIT 1; |
Delete the record for the student "Sofia Garcia" from the "students" table | CREATE TABLE students (id INT PRIMARY KEY,name VARCHAR(50),country VARCHAR(50),registration_date DATE); | DELETE FROM students WHERE name = 'Sofia Garcia'; |
Identify the number of digital assets with a 'stablecoin' classification in the 'Solana' network. | CREATE TABLE solana_network (digital_asset_name TEXT,digital_asset_classification TEXT); | SELECT digital_asset_classification, COUNT(*) as count FROM solana_network WHERE digital_asset_classification = 'stablecoin' GROUP BY digital_asset_classification; |
What is the total number of virtual tours booked in France and Germany? | CREATE TABLE virtual_tours (tour_id INT,country TEXT,bookings INT); INSERT INTO virtual_tours (tour_id,country,bookings) VALUES (1,'France',5000),(2,'Germany',7000); | SELECT SUM(bookings) FROM virtual_tours WHERE country IN ('France', 'Germany'); |
What is the total budget for disability accommodations in departments with more than 500 students with disabilities? | CREATE TABLE Departments (DepartmentID INT PRIMARY KEY,DepartmentName VARCHAR(50)); CREATE TABLE UniversityDepartments (UniversityDepartmentID INT PRIMARY KEY,DepartmentID INT,BudgetForDisabilityAccommodations DECIMAL(10,2),NumberOfStudentsWithDisabilities INT,FOREIGN KEY (DepartmentID) REFERENCES Departments(DepartmentID)); | SELECT SUM(BudgetForDisabilityAccommodations) as TotalBudget FROM UniversityDepartments WHERE NumberOfStudentsWithDisabilities > 500; |
What is the maximum production quantity for wells located in the 'Gulf of Mexico' and owned by 'Other Oil'? | CREATE TABLE wells (id INT,name VARCHAR(255),location VARCHAR(255),owner VARCHAR(255),production_quantity INT); INSERT INTO wells (id,name,location,owner,production_quantity) VALUES (1,'Well A','North Sea','Acme Oil',1000),(2,'Well B','Gulf of Mexico','Big Oil',2000),(3,'Well C','North Sea','Acme Oil',1500),(4,'Well D','Gulf of Mexico','Other Oil',2500),(5,'Well E','Gulf of Mexico','Other Oil',3000); | SELECT MAX(production_quantity) FROM wells WHERE location = 'Gulf of Mexico' AND owner = 'Other Oil'; |
What is the total number of fishing vessels in the Indian, Pacific, and Southern Oceans? | CREATE TABLE fishing_vessels (id INT,name VARCHAR(255),location VARCHAR(255),length FLOAT); INSERT INTO fishing_vessels (id,name,location,length) VALUES (1,'Indian Ocean Tuna Fleet','Indian Ocean',500); INSERT INTO fishing_vessels (id,name,location,length) VALUES (2,'South Pacific Squid Fleet','Pacific Ocean',450); INSERT INTO fishing_vessels (id,name,location,length) VALUES (3,'Southern Ocean Krill Fleet','Southern Ocean',600); | SELECT SUM(length) FROM fishing_vessels WHERE location IN ('Indian Ocean', 'Pacific Ocean', 'Southern Ocean'); |
How many mobile customers have a data usage over 5GB in the state of New York? | CREATE TABLE mobile_customers (customer_id INT,data_usage FLOAT,state VARCHAR(20)); INSERT INTO mobile_customers (customer_id,data_usage,state) VALUES (1,3.5,'New York'),(2,6.2,'New York'),(3,4.8,'Texas'); | SELECT COUNT(*) FROM mobile_customers WHERE data_usage > 5 AND state = 'New York'; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.