instruction stringlengths 0 1.06k | input stringlengths 11 5.3k | response stringlengths 2 4.44k |
|---|---|---|
What is the total number of vulnerabilities in the 'vulnerabilities' table for the Asia-Pacific region? | CREATE TABLE schema1.vulnerabilities (id INT,name VARCHAR(255),severity VARCHAR(50),description TEXT,date_discovered DATE,last_observed DATE,region VARCHAR(100)); INSERT INTO schema1.vulnerabilities (id,name,severity,description,date_discovered,last_observed,region) VALUES (1,'SQL Injection','Critical','Allows unauthorized access','2021-01-01','2021-02-01','Asia-Pacific'); | SELECT COUNT(*) FROM schema1.vulnerabilities WHERE region = 'Asia-Pacific'; |
What is the average number of articles published per day by each author, only considering articles about education? | CREATE TABLE articles (article_id INT,title TEXT,author_id INT,topic TEXT,published_at DATETIME); INSERT INTO articles (article_id,title,author_id,topic,published_at) VALUES (1,'Education Reform in the US',1,'education','2022-01-01 10:30:00'),(2,'History of Education in America',1,'education','2022-01-02 15:45:00'),(3,'Politics in the Classroom',2,'politics','2022-01-03 09:30:00'); | SELECT author_id, AVG(1.0 * COUNT(DISTINCT DATE(published_at))) FROM articles WHERE topic = 'education' GROUP BY author_id; |
Showcase the military technology used by each country and the year it was first introduced, along with the latest version of the technology. | CREATE TABLE military_tech (country VARCHAR(255),tech_name VARCHAR(255),year_introduced INT,current_version INT); | SELECT country, tech_name, MAX(year_introduced) as first_introduced, MAX(current_version) as latest_version FROM military_tech GROUP BY country, tech_name; |
Find the maximum carbon emissions for a factory in Latin America. | CREATE TABLE factory_emissions (id INT,carbon_emissions DECIMAL,region VARCHAR(20)); INSERT INTO factory_emissions (id,carbon_emissions,region) VALUES (1,5000.00,'Latin America'),(2,5500.00,'Latin America'),(3,6000.00,'Latin America'); | SELECT MAX(carbon_emissions) FROM factory_emissions WHERE region = 'Latin America'; |
What is the maximum number of animals in a habitat? | CREATE TABLE habitat (type TEXT,animal_count INTEGER); INSERT INTO habitat (type,animal_count) VALUES ('Forest',30),('Grassland',25),('Wetland',45); | SELECT MAX(animal_count) FROM habitat; |
Which continent has the highest average donation amount? | CREATE TABLE Continents (ContinentID INT PRIMARY KEY,ContinentName TEXT,AverageDonation DECIMAL(10,2)); INSERT INTO Continents (ContinentID,ContinentName,AverageDonation) VALUES (1,'North America',1000.00); INSERT INTO Continents (ContinentID,ContinentName,AverageDonation) VALUES (2,'Europe',800.00); | SELECT ContinentName, AVG(AmountDonated) AS AverageDonation FROM Donors INNER JOIN (SELECT DonorID, CountryName, ContinentName FROM Donors_Countries JOIN Continents ON Continents.ContinentName = Countries.Continent) AS DonorContinent ON Donors.DonorID = DonorContinent.DonorID GROUP BY ContinentName ORDER BY AverageDonation DESC LIMIT 1; |
How many units of each product were sold in the last quarter, by region? | CREATE TABLE sales (sale_date DATE,product VARCHAR(255),quantity INT,region VARCHAR(255)); | SELECT region, product, SUM(quantity) AS qty_sold, DATE_TRUNC('quarter', sale_date) AS sale_quarter FROM sales WHERE sale_date >= DATE_TRUNC('quarter', CURRENT_DATE - INTERVAL '1 year') GROUP BY region, product, sale_quarter; |
How many clients received financial capability training in South Africa? | CREATE TABLE financial_capability (id INT,client_id INT,country VARCHAR(50),training_type VARCHAR(50)); INSERT INTO financial_capability (id,client_id,country,training_type) VALUES (1,301,'South Africa','Financial Capability'),(2,302,'South Africa','Budgeting Skills'); | SELECT country, COUNT(DISTINCT client_id) as num_clients FROM financial_capability WHERE country = 'South Africa' GROUP BY country; |
How many diplomatic missions were conducted in Southeast Asia since 2010? | CREATE TABLE Diplomatic_Missions (Mission_ID INT PRIMARY KEY,Mission_Name VARCHAR(255),Country VARCHAR(255),Start_Date DATE,End_Date DATE); INSERT INTO Diplomatic_Missions (Mission_ID,Mission_Name,Country,Start_Date,End_Date) VALUES (1,'Operation Unified Protector','Libya','2011-03-24','2011-10-31'); | SELECT COUNT(*) FROM Diplomatic_Missions WHERE Country IN (SELECT Name FROM Countries WHERE Continent = 'Asia' AND Region = 'Southeast Asia') AND Start_Date >= '2010-01-01'; |
What is the minimum bridge length in the 'bridge_info' table? | CREATE TABLE bridge_info (bridge_id INT,bridge_name VARCHAR(50),bridge_length INT); INSERT INTO bridge_info (bridge_id,bridge_name,bridge_length) VALUES (1,'Golden Gate Bridge',2737),(2,'Verrazano-Narrows Bridge',4260),(3,'George Washington Bridge',3500); | SELECT MIN(bridge_length) FROM bridge_info; |
Find the top 3 products with the highest revenue, and their corresponding revenues. | CREATE TABLE sales (sale_id INT,product_id INT,revenue DECIMAL(10,2)); INSERT INTO sales VALUES (1,1,100.00),(2,1,200.00),(3,2,300.00),(4,2,400.00),(5,3,500.00),(6,3,600.00); | SELECT product_id, SUM(revenue) as total_revenue FROM sales GROUP BY product_id ORDER BY total_revenue DESC LIMIT 3; |
What is the maximum delivery time for packages shipped from 'Seattle' warehouse? | CREATE TABLE Warehouse (id INT,name VARCHAR(20),city VARCHAR(20)); INSERT INTO Warehouse (id,name,city) VALUES (1,'Seattle Warehouse','Seattle'); CREATE TABLE Packages (id INT,warehouse_id INT,delivery_time INT,status VARCHAR(20)); INSERT INTO Packages (id,warehouse_id,delivery_time,status) VALUES (1,1,5,'shipped'),(2,1,7,'shipped'),(3,1,6,'processing'); | SELECT MAX(delivery_time) FROM Packages WHERE warehouse_id = (SELECT id FROM Warehouse WHERE city = 'Seattle') AND status = 'shipped'; |
What is the number of fish species with stocks declining over the past 3 years? | CREATE TABLE fish_stocks (id INT,species TEXT,country TEXT,year INT,stock_weight INT); INSERT INTO fish_stocks (id,species,country,year,stock_weight) VALUES (1,'Salmon','Norway',2020,130000),(2,'Salmon','Chile',2020,110000),(3,'Salmon','Norway',2019,140000),(4,'Tuna','Japan',2020,160000),(5,'Tuna','Philippines',2020,140000),(6,'Tuna','Japan',2019,170000); | SELECT species, COUNT(*) number_of_species FROM fish_stocks WHERE stock_weight < (SELECT stock_weight FROM fish_stocks fs2 WHERE fs2.species = fs.species AND year = (year - 1)) GROUP BY species HAVING COUNT(*) > 0; |
Insert a new 'coral_bleaching' record into the 'events' table for 'Great Barrier Reef' on '2025-06-01'. | CREATE TABLE events (event_id INT,event_name TEXT,location TEXT,date DATE); | INSERT INTO events (event_id, event_name, location, date) VALUES (1, 'coral_bleaching', 'Great Barrier Reef', '2025-06-01'); |
What is the total water usage for industrial purposes in California in the year 2022? | CREATE TABLE WaterUsageMetrics (UsageID INT PRIMARY KEY,Location VARCHAR(255),Usage INT,UsageType VARCHAR(255),Timestamp DATETIME); INSERT INTO WaterUsageMetrics (UsageID,Location,Usage,UsageType,Timestamp) VALUES (1,'California',800,'Industrial','2022-01-01 00:00:00'); | SELECT SUM(Usage) FROM WaterUsageMetrics WHERE UsageType = 'Industrial' AND YEAR(Timestamp) = 2022 AND Location = 'California'; |
What are the total number of schools and libraries in the education and library departments? | CREATE TABLE education_dept (dept_name TEXT,location TEXT,num_schools INTEGER,num_libraries INTEGER); INSERT INTO education_dept (dept_name,location,num_schools,num_libraries) VALUES ('Education Department','CityA',30,15),('Education Department','CityB',25,10),('Library Department','CityA',5,20),('Library Department','CityB',10,25); | SELECT SUM(num_schools) + SUM(num_libraries) FROM education_dept WHERE dept_name IN ('Education Department', 'Library Department'); |
Get the total claims processed in each month of the year | CREATE TABLE claims (id INT,policyholder_id INT,date DATE,amount FLOAT); INSERT INTO claims (id,policyholder_id,date,amount) VALUES (1,1,'2021-01-01',100),(2,1,'2021-02-01',200),(3,2,'2021-03-01',300); | SELECT EXTRACT(MONTH FROM date) as month, SUM(amount) as total_claims FROM claims GROUP BY month; |
What is the total production of 'Corn' and 'Soybean' in the Midwest region for the year 2020, grouped by state? | CREATE TABLE Midwest_States (state VARCHAR(20)); INSERT INTO Midwest_States (state) VALUES ('Illinois'),('Indiana'),('Iowa'),('Michigan'),('Minnesota'),('Missouri'),('Ohio'),('Wisconsin'); CREATE TABLE Crop_Production (state VARCHAR(20),crop VARCHAR(20),production INT,year INT); INSERT INTO Crop_Production (state,crop,production,year) VALUES ('Illinois','Corn',2000,2020),('Illinois','Soybean',1500,2020); | SELECT cs.state, SUM(cp.production) as total_production FROM Crop_Production cp JOIN Midwest_States ms ON cs.state = cp.state WHERE cp.crop IN ('Corn', 'Soybean') AND cp.year = 2020 GROUP BY cs.state; |
Find the titles and runtimes of all TV shows in the media table that have a runtime over 45 minutes and were produced in Africa or South America. | CREATE TABLE media (id INT,title VARCHAR(50),runtime INT,type VARCHAR(10),country VARCHAR(50)); | SELECT title, runtime FROM media WHERE type = 'tv_show' AND runtime > 45 AND country IN ('Africa', 'South America'); |
What's the viewership trend for movies with a budget over 50 million in the last 3 years? | CREATE TABLE Movies (movie_id INT,movie_name VARCHAR(255),production_budget INT,release_year INT,viewership INT); INSERT INTO Movies (movie_id,movie_name,production_budget,release_year,viewership) VALUES (1,'Movie A',60000000,2020,1200000),(2,'Movie B',55000000,2021,1500000),(3,'Movie C',45000000,2022,1800000),(4,'Movie D',70000000,2019,1000000); | SELECT release_year, AVG(viewership) FROM Movies WHERE production_budget > 50000000 GROUP BY release_year ORDER BY release_year DESC LIMIT 3; |
List the donors who made donations in both the years 2018 and 2019. | CREATE TABLE Donors (DonorID INT,DonorName TEXT); CREATE TABLE Donations (DonationID INT,DonorID INT,DonationDate DATE,DonationAmount DECIMAL); | SELECT D.DonorName FROM Donors D JOIN Donations DON18 ON D.DonorID = DON18.DonorID JOIN Donations DON19 ON D.DonorID = DON19.DonorID WHERE YEAR(DON18.DonationDate) = 2018 AND YEAR(DON19.DonationDate) = 2019 GROUP BY D.DonorName HAVING COUNT(DISTINCT YEAR(DonationDate)) = 2; |
How many high-risk accounts are present in the Southeast region? | CREATE TABLE accounts (id INT,region VARCHAR(20),risk_level VARCHAR(10)); INSERT INTO accounts (id,region,risk_level) VALUES (1,'Southeast','high'),(2,'Northwest','medium'),(3,'Southeast','low'); | SELECT COUNT(*) FROM accounts WHERE region = 'Southeast' AND risk_level = 'high'; |
What is the average number of algorithmic fairness citations for each author? | CREATE TABLE author (name VARCHAR(255),country VARCHAR(255),citations INTEGER); INSERT INTO author (name,country,citations) VALUES ('Alice','USA',50),('Bob','USA',40),('Charlie','UK',60),('David','UK',70),('Eve','France',45); | SELECT AVG(citations) as avg_citations FROM author; |
Identify the top 3 mining companies in South America with the highest labor productivity. | CREATE TABLE company (id INT,name VARCHAR(255),country VARCHAR(255),employees INT,revenue DECIMAL(10,2));CREATE VIEW mining_companies AS SELECT * FROM company WHERE industry = 'Mining'; | SELECT c.name, AVG(c.revenue / c.employees) as labor_productivity FROM mining_companies c WHERE c.country LIKE '%South America%' GROUP BY c.name ORDER BY labor_productivity DESC LIMIT 3; |
What is the average gas price for transactions with 'erc20' type in the 'transactions' table, grouped by the 'gas_price' column and ordered by the average gas price in descending order? | CREATE TABLE transactions (transaction_id INT,type VARCHAR(255),gas_price DECIMAL(10,2),time DATETIME); | SELECT gas_price, AVG(gas_price) OVER (PARTITION BY type ORDER BY gas_price DESC) as avg_gas_price FROM transactions WHERE type = 'erc20' GROUP BY gas_price, type ORDER BY avg_gas_price DESC; |
What is the average age of players who prefer strategy games? | CREATE TABLE PlayerGamePreferences (PlayerID INT,Age INT,GameGenre VARCHAR(30)); INSERT INTO PlayerGamePreferences (PlayerID,Age,GameGenre) VALUES (1,28,'Strategy'),(2,31,'Simulation'),(3,22,'Strategy'),(4,45,'Adventure'); | SELECT AVG(Age) FROM PlayerGamePreferences WHERE GameGenre = 'Strategy'; |
How many graduate students from underrepresented racial and ethnic backgrounds are enrolled in each department? | CREATE TABLE graduate_students (student_id INT,name TEXT,race_ethnicity TEXT,department TEXT); | SELECT gs.department, COUNT(gs.student_id) FROM graduate_students gs WHERE gs.race_ethnicity IN ('Black or African American', 'Hispanic or Latinx', 'Native American or Alaska Native', 'Native Hawaiian or Pacific Islander') GROUP BY gs.department; |
List all space missions led by astronauts from India | CREATE TABLE SpaceMissions (id INT,mission_name VARCHAR(30),leader_name VARCHAR(30),leader_nationality VARCHAR(20)); INSERT INTO SpaceMissions (id,mission_name,leader_name,leader_nationality) VALUES (1,'Mars Exploration','Rajesh Kumar','India'); INSERT INTO SpaceMissions (id,mission_name,leader_name,leader_nationality) VALUES (2,'Asteroid Survey','Meera Patel','USA'); | SELECT mission_name FROM SpaceMissions WHERE leader_nationality = 'India'; |
Determine the difference in energy production between the wind turbines with the minimum and maximum energy production. | CREATE TABLE wind_turbines (turbine_id INT,energy_production FLOAT); INSERT INTO wind_turbines (turbine_id,energy_production) VALUES (1,2.3),(2,2.5),(3,2.8),(4,1.9),(5,3.1); | SELECT MAX(energy_production) - MIN(energy_production) FROM wind_turbines |
How many mental health parity violations were reported by region? | CREATE TABLE mental_health_parity_reports (report_id INT,violation_date DATE,region TEXT); INSERT INTO mental_health_parity_reports (report_id,violation_date,region) VALUES (1,'2022-01-01','Northeast'),(2,'2022-02-15','West'),(3,'2022-03-05','Northeast'),(4,'2022-04-20','South'); | SELECT region, COUNT(*) FROM mental_health_parity_reports GROUP BY region; |
How many public schools are there in the city of Chicago, and what are their names? | CREATE TABLE PublicSchools (SchoolID INT,SchoolName VARCHAR(100),City VARCHAR(100)); INSERT INTO PublicSchools (SchoolID,SchoolName,City) VALUES (1,'Johnson Elementary School','Chicago'),(2,'Washington High School','Chicago'),(3,'Lincoln Middle School','Chicago'); | SELECT COUNT(*) as NumberOfSchools, SchoolName FROM PublicSchools WHERE City = 'Chicago' GROUP BY SchoolName; |
What is the name of the longest vessel in the fleet? | CREATE TABLE vessels (id INT PRIMARY KEY,name VARCHAR(50),type VARCHAR(50),length FLOAT,year_built INT); | SELECT name FROM vessels WHERE length = (SELECT MAX(length) FROM vessels); |
What is the total number of high severity vulnerabilities for each product family in the past year? | CREATE TABLE vulnerabilities (product_family VARCHAR(50),severity INT,vulnerability_date DATE); INSERT INTO vulnerabilities (product_family,severity,vulnerability_date) VALUES ('Product Family A',7,'2022-01-01'),('Product Family B',5,'2022-01-02'),('Product Family C',8,'2022-01-03'),('Product Family D',3,'2022-01-04'); | SELECT product_family, SUM(CASE WHEN severity >= 7 THEN 1 ELSE 0 END) as high_severity_count FROM vulnerabilities WHERE vulnerability_date >= DATEADD(year, -1, GETDATE()) GROUP BY product_family; |
What is the average launch delay for satellite deployments in the past 3 years? | CREATE TABLE satellite_deployments (satellite_name VARCHAR(255),launch_date DATE,launch_time TIME,launch_delay INT); INSERT INTO satellite_deployments (satellite_name,launch_date,launch_time,launch_delay) VALUES ('Sat1','2020-01-01','10:00:00',5),('Sat2','2019-06-15','15:30:00',10),('Sat3','2021-08-27','09:45:00',3),('Sat4','2018-03-04','13:15:00',7),('Sat5','2021-02-12','11:00:00',8); | SELECT AVG(launch_delay) FROM satellite_deployments WHERE launch_date >= DATEADD(year, -3, CURRENT_DATE); |
What is the maximum depth reached by any marine mammal? | CREATE TABLE marine_mammals (mammal_name TEXT,max_depth REAL); | SELECT MAX(max_depth) FROM marine_mammals; |
List all peacekeeping operations led by the African Union in the last decade. | CREATE SCHEMA if not exists peacekeeping;CREATE TABLE if not exists au_operations (id INT,operation_name VARCHAR(255),operation_start_date DATE,operation_end_date DATE); INSERT INTO au_operations (id,operation_name,operation_start_date,operation_end_date) VALUES (1,'African Union Mission in Somalia','2010-01-01','2022-01-01'); | SELECT * FROM au_operations WHERE operation_start_date BETWEEN DATE_SUB(CURRENT_DATE, INTERVAL 10 YEAR) AND CURRENT_DATE; |
List all the collisions in the South China Sea involving vessels over 10,000 DWT in the past year, along with the vessels' flag states and the incident location. | CREATE TABLE incidents (incident_id INT,incident_type VARCHAR(255),latitude DECIMAL(9,6),longitude DECIMAL(9,6)); INSERT INTO incidents VALUES (1,'Collision',12.345678,109.234567); CREATE TABLE vessel_info (vessel_id INT,vessel_name VARCHAR(255),flag_state VARCHAR(255),gross_tonnage INT); INSERT INTO vessel_info VALUES (101,'Test Vessel 1','Panama',15000); | SELECT i.incident_id, v.flag_state, CONCAT(i.latitude, ' ', i.longitude) AS incident_location FROM incidents i JOIN vessel_info v ON i.incident_id = v.vessel_id WHERE i.incident_type = 'Collision' AND i.latitude BETWEEN 1.000000 AND 20.000000 AND i.longitude BETWEEN 99.000000 AND 123.000000 AND v.gross_tonnage > 10000 AND i.incident_timestamp BETWEEN DATE_SUB(NOW(), INTERVAL 1 YEAR) AND NOW(); |
What is the total amount of minerals extracted in the European Union in 2020, and what was the labor productivity for each mining operation? | CREATE TABLE eu_minerals_extracted (id INT,country VARCHAR(255),year INT,amount INT,productivity FLOAT); | SELECT country, year, productivity FROM eu_minerals_extracted WHERE country IN ('Germany', 'France', 'Italy', 'Spain', 'Poland') AND year = 2020; |
Calculate the average temperature in Q2 2022 for locations with renewable energy production above 55000 | CREATE TABLE weather_data (date DATE,location VARCHAR(255),temperature FLOAT,renewable_energy_production FLOAT); INSERT INTO weather_data (date,location,temperature,renewable_energy_production) VALUES ('2022-01-01','New York',32,50000); | SELECT location, AVG(temperature) FROM weather_data WHERE EXTRACT(MONTH FROM date) BETWEEN 4 AND 6 AND renewable_energy_production > 55000 GROUP BY location; |
How many visitors have returned to the museum for a second time? | CREATE TABLE Visitors (Id INT,Name VARCHAR(50),FirstVisit DATE,ReturnVisit DATE); | SELECT COUNT(*) FROM Visitors WHERE ReturnVisit IS NOT NULL; |
Update records in the 'hospitals' table where the hospital_name is 'St. Mary's' and the region is 'North'. | CREATE SCHEMA rural; CREATE TABLE rural.hospitals (id INT,hospital_name TEXT,region TEXT); | UPDATE rural.hospitals SET region = 'Northeast' WHERE hospital_name = 'St. Mary''s' AND region = 'North'; |
What is the total number of assists made by players from the Bundesliga in soccer games, excluding players with less than 10 games played? | CREATE TABLE Bundesliga_Teams (Player VARCHAR(50),Assists INT); INSERT INTO Bundesliga_Teams (Player,Assists) VALUES ('Thomas Muller',12),('Marco Reus',10),('Jadon Sancho',8); | SELECT SUM(Assists) FROM Bundesliga_Teams WHERE Assists > (SELECT AVG(Assists) FROM Bundesliga_Teams) GROUP BY Assists HAVING COUNT(*) >= 10; |
What is the percentage of sustainable fabrics used by each fashion designer? | CREATE TABLE fabric_usage(designer VARCHAR(50),fabric_type VARCHAR(20),percentage FLOAT); INSERT INTO fabric_usage(designer,fabric_type,percentage) VALUES('DesignerA','sustainable',75.2),('DesignerB','non-sustainable',63.1),('DesignerC','sustainable',81.6); | SELECT designer, (SUM(CASE WHEN fabric_type = 'sustainable' THEN percentage ELSE 0 END) / SUM(percentage)) * 100 AS sustainable_percentage FROM fabric_usage GROUP BY designer; |
What is the total area (in hectares) of all urban farms located in 'New York'? | CREATE TABLE urban_farms (id INT,name TEXT,city TEXT,area_ha FLOAT); INSERT INTO urban_farms (id,name,city,area_ha) VALUES (3,'Farm 3','New York',3.1),(4,'Farm 4','New York',5.6); | SELECT SUM(area_ha) FROM urban_farms WHERE city = 'New York'; |
Which cities have the most volunteer opportunities? | CREATE TABLE volunteer_opportunities (id INT,city VARCHAR(50),opportunities INT); INSERT INTO volunteer_opportunities (id,city,opportunities) VALUES (1,'New York',200),(2,'Los Angeles',150),(3,'Chicago',250),(4,'Houston',225); | SELECT city, SUM(opportunities) as total_opportunities FROM volunteer_opportunities GROUP BY city; |
How many unique cities and continents are represented in the media_data table? | CREATE TABLE media_data (id INT,content TEXT,city TEXT,country TEXT,continent TEXT); INSERT INTO media_data (id,content,city,country,continent) VALUES (1,'Sample content 1','New York','United States','North America'); INSERT INTO media_data (id,content,city,country,continent) VALUES (2,'Sample content 2','Toronto','Canada','North America'); INSERT INTO media_data (id,content,city,country,continent) VALUES (3,'Sample content 3','Mexico City','Mexico','North America'); INSERT INTO media_data (id,content,city,country,continent) VALUES (4,'Sample content 4','São Paulo','Brazil','South America'); | SELECT COUNT(DISTINCT city) + COUNT(DISTINCT continent) FROM media_data; |
List all clients who have never lost a case. | CREATE TABLE clients (client_id INT,name TEXT); INSERT INTO clients (client_id,name) VALUES (1,'John Doe'); CREATE TABLE cases (case_id INT,client_id INT,won BOOLEAN); INSERT INTO cases (case_id,client_id,won) VALUES (1,1,TRUE); | SELECT clients.name FROM clients LEFT OUTER JOIN cases ON clients.client_id = cases.client_id WHERE cases.won IS NULL; |
Provide the average depth of the top 3 deepest oceanic trenches in the Pacific Ocean, excluding the Mariana Trench. | CREATE TABLE ocean_trenches (trench_name TEXT,depth FLOAT,location TEXT); INSERT INTO ocean_trenches (trench_name,depth,location) VALUES ('Mariana Trench','-36069.2','Pacific Ocean'),('Tonga Trench','-35701.9','Pacific Ocean'),('Kuril Trench','-35462.3','Pacific Ocean'); | SELECT AVG(depth) FROM (SELECT ROW_NUMBER() OVER (PARTITION BY location ORDER BY depth DESC) as rn, depth FROM ocean_trenches WHERE location = 'Pacific Ocean' AND trench_name != 'Mariana Trench') tmp WHERE rn <= 3; |
What is the minimum project timeline for construction projects in California with 'Apartment' in their names? | CREATE TABLE Project_Timeline (id INT,project_name TEXT,location TEXT,min_timeline INT); INSERT INTO Project_Timeline (id,project_name,location,min_timeline) VALUES (1,'Apartment Complex','California',24),(2,'Commercial Building','California',36); | SELECT MIN(min_timeline) FROM Project_Timeline WHERE location = 'California' AND project_name LIKE '%Apartment%'; |
What is the total amount of research grants awarded to graduate students from the United States, partitioned by academic year? | CREATE TABLE research_grants (student_id INT,student_country VARCHAR(255),amount DECIMAL(10,2),grant_year INT); INSERT INTO research_grants (student_id,student_country,amount,grant_year) VALUES (1,'USA',15000,2020),(2,'Canada',20000,2020),(3,'USA',22000,2021); | SELECT grant_year, SUM(amount) AS total_grant_amount FROM research_grants WHERE student_country = 'USA' GROUP BY grant_year; |
What is the number of hotels that have adopted AI in 'Mumbai'? | CREATE TABLE ai_adoption (hotel_id INT,city TEXT,ai_adopted INT); INSERT INTO ai_adoption (hotel_id,city,ai_adopted) VALUES (3,'Mumbai',1),(4,'Mumbai',0),(5,'Delhi',1); | SELECT COUNT(*) FROM ai_adoption WHERE city = 'Mumbai' AND ai_adopted = 1; |
Update the genre of the artist 'Selena Gomez' to 'Pop-Folk' | CREATE TABLE Artists (ArtistID INT PRIMARY KEY,ArtistName VARCHAR(100),Genre VARCHAR(50)); | UPDATE Artists SET Genre = 'Pop-Folk' WHERE ArtistName = 'Selena Gomez'; |
What is the earliest and latest adoption year, and the number of smart city technology adoptions for each technology in a specific city and country, ordered by the number of adoptions in descending order? | CREATE TABLE smart_city_technology_adoption (id INT,name VARCHAR(50),city VARCHAR(50),country VARCHAR(50),technology VARCHAR(50),adoption_year INT,PRIMARY KEY (id)); | SELECT city, country, technology, MIN(adoption_year) as first_adoption_year, MAX(adoption_year) as last_adoption_year, COUNT(*) as adoption_count, ROW_NUMBER() OVER (ORDER BY COUNT(*) DESC) as ranking FROM smart_city_technology_adoption WHERE city = 'CityName' AND country = 'CountryName' GROUP BY technology; |
What is the total capacity of vessels in the 'fleet_management' table that are cargo ships? | CREATE TABLE fleet_management (id INT,name VARCHAR(50),type VARCHAR(50),capacity INT); | SELECT SUM(capacity) FROM fleet_management WHERE type = 'cargo ship'; |
What is the sum of 'total_resources' for 'gold' in the 'resources' table? | CREATE TABLE resources(id INT,resource_type VARCHAR(255),total_resources INT); INSERT INTO resources(id,resource_type,total_resources) VALUES (1,'gold',1000000); | SELECT SUM(total_resources) FROM resources WHERE resource_type = 'gold'; |
Identify the number of virtual tours engaged by users from India in 2021, grouped by the month of engagement. | CREATE TABLE users(user_id INT,user_country TEXT); INSERT INTO users(user_id,user_country) VALUES (1,'India'); CREATE TABLE virtual_tours(tour_id INT,tour_date DATE); CREATE TABLE user_tour_interactions(user_id INT,tour_id INT); | SELECT MONTH(vt.tour_date) AS month, COUNT(uti.user_id) AS num_interactions FROM users u INNER JOIN user_tour_interactions uti ON u.user_id = uti.user_id INNER JOIN virtual_tours vt ON uti.tour_id = vt.tour_id WHERE u.user_country = 'India' AND YEAR(vt.tour_date) = 2021 GROUP BY month; |
Display the total sales revenue for each product category in descending order | CREATE TABLE sales (product_type VARCHAR(20),revenue DECIMAL(10,2)); INSERT INTO sales (product_type,revenue) VALUES ('skincare',12000),('makeup',9000),('hair care',7000),('body care',5000); | SELECT product_type, SUM(revenue) AS total_revenue FROM sales GROUP BY product_type ORDER BY total_revenue DESC; |
What is the average body fat percentage for members from Australia? | CREATE TABLE Members (MemberID INT,BodyFat FLOAT,Country VARCHAR(20)); INSERT INTO Members (MemberID,BodyFat,Country) VALUES (1,15.6,'Canada'),(2,22.3,'Australia'),(3,18.9,'Australia'),(4,12.5,'Canada'); | SELECT AVG(BodyFat) FROM Members WHERE Country = 'Australia'; |
What is the maximum installed capacity of hydroelectric power plants in Brazil and Canada? | CREATE TABLE hydroelectric_plants (id INT,name TEXT,country TEXT,capacity FLOAT); INSERT INTO hydroelectric_plants (id,name,country,capacity) VALUES (1,'Itaipu','Brazil',14000),(2,'Guri','Brazil',10200),(3,'Tucurui','Brazil',8370),(4,'Churchill Falls','Canada',5428),(5,'Barrage de la Manic-5','Canada',2010),(6,'Barrage de la Manic-3','Canada',1244); | SELECT MAX(capacity) FROM hydroelectric_plants WHERE country IN ('Brazil', 'Canada'); |
What is the average installed capacity (in MW) of wind farms in Germany that were completed after 2015? | CREATE TABLE wind_farms (name TEXT,country TEXT,capacity_mw REAL,completion_date DATE); INSERT INTO wind_farms (name,country,capacity_mw,completion_date) VALUES ('Windpark Nordsee One','Germany',332,'2017-04-01'),('Global Tech I Offshore Wind Farm','Germany',400,'2015-05-01'); | SELECT AVG(capacity_mw) FROM wind_farms WHERE country = 'Germany' AND completion_date > '2015-01-01'; |
What are the total donation amounts for each cause in 2020, excluding causes with less than 100 donors? | CREATE TABLE donations (id INT,year INT,cause TEXT,donation_amount DECIMAL(10,2)); INSERT INTO donations (id,year,cause,donation_amount) VALUES (1,2020,'Education',500.00),(2,2020,'Health',1500.00),(3,2020,'Environment',300.00),(4,2020,'Education',400.00),(5,2020,'Education',50.00); | SELECT cause, SUM(donation_amount) FROM donations WHERE year = 2020 GROUP BY cause HAVING COUNT(*) >= 100; |
What are the most common allergens in cosmetic products sold in the United States, and how many products contain each allergen? | CREATE TABLE cosmetics_ingredients (product_id INT,ingredient TEXT,is_allergen BOOLEAN,country TEXT); | SELECT ingredient, COUNT(*) as num_products_with_allergen FROM cosmetics_ingredients WHERE is_allergen = TRUE AND country = 'United States' GROUP BY ingredient ORDER BY num_products_with_allergen DESC; |
Update the 'chemical_name' column to 'Sodium Chloride' for records where 'id' is 1 in 'chemical_inventory' table | CREATE TABLE chemical_inventory (id INT,chemical_name VARCHAR(50),safety_stock INT); | UPDATE chemical_inventory SET chemical_name = 'Sodium Chloride' WHERE id = 1; |
What is the total amount of minerals extracted by each mining company in the states of Nevada and New Mexico, USA, for the year 2020? | CREATE TABLE mining_companies (company_id INT,company_name TEXT);CREATE TABLE mining_sites (site_id INT,site_name TEXT,state TEXT,country TEXT);CREATE TABLE mineral_extraction (extraction_id INT,site_id INT,extraction_year INT,tons_extracted INT); | SELECT c.company_name, SUM(me.tons_extracted) AS total_tons_extracted FROM mining_companies c INNER JOIN mining_sites s ON c.company_id = s.company_id INNER JOIN mineral_extraction me ON s.site_id = me.site_id WHERE s.state IN ('Nevada', 'New Mexico') AND me.extraction_year = 2020 GROUP BY c.company_id, c.company_name; |
Update the carbon sequestration values for the year 2019 where the species is 'Spruce' to 1250.0 | CREATE TABLE carbon_sequestration (id INT,species VARCHAR(255),year INT,sequestration FLOAT); INSERT INTO carbon_sequestration (id,species,year,sequestration) VALUES (1,'Pine',2018,1000.2),(2,'Oak',2019,1100.1),(3,'Spruce',2018,1300.0),(4,'Spruce',2019,NULL); | UPDATE carbon_sequestration SET sequestration = 1250.0 WHERE species = 'Spruce' AND year = 2019; |
What is the maximum water consumption in a single day for all wastewater treatment plants? | CREATE TABLE wastewater_treatment_plants (plant_id INT,daily_consumption FLOAT,consumption_date DATE); INSERT INTO wastewater_treatment_plants (plant_id,daily_consumption,consumption_date) VALUES (1,1000,'2022-03-01'),(2,1500,'2022-03-02'),(3,1200,'2022-03-03'); | SELECT MAX(daily_consumption) FROM wastewater_treatment_plants; |
What was the maximum ticket price for Latinx theater productions in the USA in Q1 2022? | CREATE TABLE TheaterTickets (id INT,country VARCHAR(20),quarter INT,year INT,community VARCHAR(20),price FLOAT); INSERT INTO TheaterTickets (id,country,quarter,year,community,price) VALUES (19,'USA',1,2022,'Latinx',100); INSERT INTO TheaterTickets (id,country,quarter,year,community,price) VALUES (20,'USA',1,2022,'Non-Latinx',120); | SELECT MAX(price) FROM TheaterTickets WHERE country = 'USA' AND quarter = 1 AND year = 2022 AND community = 'Latinx'; |
How much wastewater has been treated by each treatment facility in the first half of 2022? | CREATE TABLE wastewater_treatment_facilities (id INT,name VARCHAR(255),lat FLOAT,long FLOAT); INSERT INTO wastewater_treatment_facilities (id,name,lat,long) VALUES (1,'Facility A',34.0534,-118.2453),(2,'Facility B',40.7128,-74.0060); CREATE TABLE wastewater_treatment (facility_id INT,date DATE,volume INT); INSERT INTO wastewater_treatment (facility_id,date,volume) VALUES (1,'2022-01-01',1000),(1,'2022-02-01',1200),(2,'2022-01-01',1500),(2,'2022-02-01',1800); | SELECT ft.name, SUM(wt.volume) FROM wastewater_treatment_facilities ft JOIN wastewater_treatment wt ON ft.id = wt.facility_id WHERE wt.date BETWEEN '2022-01-01' AND '2022-06-30' GROUP BY ft.name; |
Calculate the average salary by job title and gender | CREATE TABLE salaries (id INT,job_title VARCHAR(255),gender VARCHAR(10),salary DECIMAL(10,2)); INSERT INTO salaries (id,job_title,gender,salary) VALUES (1,'Software Engineer','Male',90000.00),(2,'Marketing Manager','Female',80000.00),(3,'Sales Representative','Male',70000.00),(4,'HR Manager','Female',75000.00); | SELECT job_title, gender, AVG(salary) as avg_salary FROM salaries GROUP BY job_title, gender; |
Get records on workforce development programs in South Africa | CREATE TABLE programs (id INT PRIMARY KEY,name VARCHAR(255),domain VARCHAR(255),level VARCHAR(255)); INSERT INTO programs (id,name,domain,level) VALUES (3,'SkillUp Manufacturing','Manufacturing','Intermediate'),(10,'GreenCape Skills','Manufacturing','Beginner'),(11,'SustainableWorkforce','Manufacturing','Advanced'); | SELECT * FROM programs WHERE domain = 'Manufacturing' AND level IN ('Beginner', 'Intermediate', 'Advanced') AND id != 3; |
List all the mining sites and the number of different job titles at each site | CREATE TABLE MiningSites (SiteID INT,SiteName VARCHAR(50),Location VARCHAR(50)); INSERT INTO MiningSites (SiteID,SiteName,Location) VALUES (1,'Site A','New York'),(2,'Site B','Ohio'); CREATE TABLE Employees (EmployeeID INT,FirstName VARCHAR(50),LastName VARCHAR(50),JobTitle VARCHAR(50),SiteID INT); INSERT INTO Employees (EmployeeID,FirstName,LastName,JobTitle,SiteID) VALUES (1,'John','Doe','Manager',1),(2,'Jane','Doe','Engineer',1),(3,'Bob','Smith','Manager',2),(4,'Sarah','Jones','Engineer',2),(5,'Mike','Williams','Geologist',2); | SELECT s.SiteName, s.Location, COUNT(DISTINCT e.JobTitle) as NumberOfJobTitles FROM Employees e INNER JOIN MiningSites s ON e.SiteID = s.SiteID GROUP BY e.SiteID; |
What is the average production cost of garments in the 'EthicalFashion' schema, ordered by production_cost in descending order? | CREATE TABLE EthicalFashion.Garments (garment_id INT,production_cost DECIMAL(5,2)); INSERT INTO EthicalFashion.Garments (garment_id,production_cost) VALUES (1,15.99),(2,24.49),(3,12.50); | SELECT AVG(production_cost) AS avg_production_cost FROM EthicalFashion.Garments ORDER BY avg_production_cost DESC; |
What is the average population size of 'marine' animals in the years '2018' to '2021'? | CREATE TABLE animal_population(animal_id INT,animal_name VARCHAR(50),category VARCHAR(20),year INT,population_size INT);INSERT INTO animal_population VALUES (1,'Dolphin','Marine',2018,100),(2,'Whale','Marine',2019,200),(3,'Shark','Marine',2020,300),(4,'Seal','Marine',2021,400); | SELECT AVG(population_size) FROM animal_population WHERE category = 'Marine' AND year BETWEEN 2018 AND 2021; |
What is the average number of courses taken by students in each district, grouped by district and ordered by the average number in descending order? | CREATE TABLE school_districts (district_id INT,district_name TEXT); CREATE TABLE students (student_id INT,district_id INT,num_courses INT); | SELECT sd.district_name, AVG(s.num_courses) as avg_num_courses FROM students s JOIN school_districts sd ON s.district_id = sd.district_id GROUP BY sd.district_name ORDER BY avg_num_courses DESC; |
What is the total number of medical appointments in rural Australia in the past year? | CREATE TABLE Appointments (AppointmentID int,Date date,Location varchar(50),Type varchar(50)); INSERT INTO Appointments (AppointmentID,Date,Location,Type) VALUES (1,'2021-01-01','Rural Australia','Checkup'); | SELECT COUNT(*) FROM Appointments WHERE Location LIKE '%Rural Australia%' AND Date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR); |
Add a new eco-friendly hotel in Brazil to the accommodations table. | CREATE TABLE accommodations (id INT,name TEXT,type TEXT,country TEXT,eco_friendly BOOLEAN); | INSERT INTO accommodations (name, type, country, eco_friendly) VALUES ('Eco-Hotel Amazonas', 'Hotel', 'Brazil', 'true'); |
What is the name and number of polling stations in each city? | CREATE TABLE cities (id INT,name VARCHAR(255)); CREATE TABLE polling_stations (id INT,city_id INT,name VARCHAR(255),number INT); | SELECT c.name, ps.number FROM cities c JOIN polling_stations ps ON c.id = ps.city_id; |
List all unique game genres that have at least 5 virtual reality (VR) games, along with the number of VR games in each genre. | CREATE TABLE GameDesign (GameID INT,GameName VARCHAR(100),Genre VARCHAR(50),VR BIT); INSERT INTO GameDesign VALUES (1,'GameA','Action',1); INSERT INTO GameDesign VALUES (2,'GameB','Strategy',0); INSERT INTO GameDesign VALUES (3,'GameC','Simulation',1); | SELECT Genre, COUNT(GameID) as VRGameCount FROM GameDesign WHERE VR = 1 GROUP BY Genre HAVING COUNT(GameID) >= 5; |
Delete all records from the 'safety_records' table where 'record_date' is before '2019-01-01' | CREATE TABLE safety_records (record_id INT PRIMARY KEY,record_date DATE,safety_rating INT); | DELETE FROM safety_records WHERE record_date < '2019-01-01'; |
Identify the mental health parity policies that have been enacted in the last year and their respective enforcement agencies. | CREATE TABLE Mental_Health_Parity_Policies (Policy_ID INT,Policy_Name VARCHAR(255),Enactment_Date DATE,Enforcement_Agency VARCHAR(255)); INSERT INTO Mental_Health_Parity_Policies (Policy_ID,Policy_Name,Enactment_Date,Enforcement_Agency) VALUES (1,'Parity in Insurance Coverage','2022-01-01','Department of Health and Human Services'),(2,'Parity in Mental Health Services','2021-02-15','Centers for Medicare and Medicaid Services'); | SELECT Policy_Name, Enforcement_Agency FROM Mental_Health_Parity_Policies WHERE Enactment_Date >= DATEADD(year, -1, GETDATE()); |
What is the total area (in km2) of marine protected areas in the Indian Ocean? | CREATE TABLE marine_protected_areas (name TEXT,avg_depth REAL,ocean TEXT,area_km2 REAL); INSERT INTO marine_protected_areas (name,avg_depth,ocean,area_km2) VALUES ('Maldives Protected Areas',45.0,'Indian',90000),('Chagos Marine Protected Area',1000.0,'Indian',640000); | SELECT SUM(area_km2) FROM marine_protected_areas WHERE ocean = 'Indian'; |
Find the number of ticket sales for each team in each country | CREATE TABLE sports_teams (team_id INT,team_name VARCHAR(50)); INSERT INTO sports_teams (team_id,team_name) VALUES (1,'TeamA'),(2,'TeamB'); CREATE TABLE ticket_sales (ticket_id INT,team_id INT,country VARCHAR(50)); INSERT INTO ticket_sales (ticket_id,team_id,country) VALUES (1,1,'USA'),(2,1,'Canada'),(3,2,'USA'),(4,2,'Canada'); | SELECT s.team_name, t.country, COUNT(*) FROM sports_teams s INNER JOIN ticket_sales t ON s.team_id = t.team_id GROUP BY s.team_name, t.country; |
What is the number of different crops grown in each region according to the 'crops_by_region' table? | CREATE TABLE crops_by_region (region VARCHAR(50),crop VARCHAR(50)); INSERT INTO crops_by_region VALUES ('Asia','Rice'); INSERT INTO crops_by_region VALUES ('Asia','Wheat'); INSERT INTO crops_by_region VALUES ('Africa','Cassava'); INSERT INTO crops_by_region VALUES ('Africa','Millet'); INSERT INTO crops_by_region VALUES ('Europe','Barley'); | SELECT region, COUNT(DISTINCT crop) AS crops_grown FROM crops_by_region GROUP BY region; |
What is the total number of posts with the hashtag "#sustainability" in the past year, grouped by month? | CREATE TABLE posts (id INT,hashtags TEXT,created_at DATETIME); | SELECT MONTH(posts.created_at) AS month, COUNT(*) AS count FROM posts WHERE FIND_IN_SET('sustainability', posts.hashtags) > 0 AND posts.created_at >= DATE_SUB(NOW(), INTERVAL 1 YEAR) GROUP BY month; |
What is the total revenue generated by streams of classical music in France on weekdays? | CREATE TABLE streams (id INT,track_id INT,user_id INT,region VARCHAR(255),genre VARCHAR(255),revenue DECIMAL(10,2),timestamp TIMESTAMP); | SELECT SUM(revenue) FROM streams s JOIN (SELECT DAYNAME(timestamp) AS day FROM streams WHERE genre = 'classical' AND region = 'France') AS days ON s.timestamp = days.day WHERE day IN ('Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday'); |
What is the total number of donations and the total donation amount for each month in the year 2020? | CREATE TABLE DonationHistory (DonationID int,DonationDate date); INSERT INTO DonationHistory (DonationID,DonationDate) VALUES (1,'2020-01-01'),(2,'2020-02-01'),(3,'2020-03-01'); CREATE TABLE Donations (DonationID int,DonationAmount numeric); INSERT INTO Donations (DonationID,DonationAmount) VALUES (1,500),(2,1200),(3,250); | SELECT EXTRACT(MONTH FROM DonationDate) as Month, COUNT(*) as NumDonations, SUM(DonationAmount) as TotalDonationAmount FROM DonationHistory JOIN Donations ON DonationHistory.DonationID = Donations.DonationID WHERE EXTRACT(YEAR FROM DonationDate) = 2020 GROUP BY Month; |
What is the minimum recycling rate for American countries? | CREATE TABLE RecyclingRates (country VARCHAR(255),recycling_rate DECIMAL(4,2),continent VARCHAR(255)); INSERT INTO RecyclingRates (country,recycling_rate,continent) VALUES ('Canada',48.0,'America'),('Brazil',35.0,'America'),('USA',35.0,'America'),('Mexico',52.0,'America'); | SELECT MIN(recycling_rate) FROM RecyclingRates WHERE continent = 'America'; |
Delete the mining operation with the lowest water consumption | CREATE TABLE mining_operations (operation_id INT,operation_name VARCHAR(50),location VARCHAR(50)); CREATE TABLE water_consumption (operation_id INT,water_consumption_cubic_meters INT); INSERT INTO mining_operations (operation_id,operation_name,location) VALUES (1,'Operation A','USA'),(2,'Operation B','Canada'),(3,'Operation C','Mexico'); INSERT INTO water_consumption (operation_id,water_consumption_cubic_meters) VALUES (1,1000),(2,1500),(3,500); | DELETE FROM mining_operations WHERE operation_id = (SELECT operation_id FROM water_consumption ORDER BY water_consumption_cubic_meters ASC LIMIT 1); DELETE FROM water_consumption WHERE operation_id = (SELECT operation_id FROM water_consumption ORDER BY water_consumption_cubic_meters ASC LIMIT 1); |
How many clients have a transaction amount greater than $500 in California? | CREATE TABLE clients (id INT,name TEXT,age INT,state TEXT,transaction_amount DECIMAL(10,2)); INSERT INTO clients (id,name,age,state,transaction_amount) VALUES (1,'John Doe',35,'California',550.00); INSERT INTO clients (id,name,age,state,transaction_amount) VALUES (2,'Jane Smith',40,'California',450.50); | SELECT COUNT(*) FROM clients WHERE state = 'California' AND transaction_amount > 500; |
How many marine species are listed in the 'endangered' category? | CREATE TABLE marine_species (id INTEGER,species_name VARCHAR(255),conservation_status VARCHAR(255)); | SELECT COUNT(*) FROM marine_species WHERE conservation_status = 'endangered'; |
What is the maximum depth reached by a marine species in the Southern Ocean, along with its habitat and species name? | CREATE TABLE southern_ocean_depths (id INT,species_name VARCHAR(255),depth FLOAT,habitat VARCHAR(255)); INSERT INTO southern_ocean_depths (id,species_name,depth,habitat) VALUES (1,'Southern Right Whale',300,'Coastal'); | SELECT species_name, depth, habitat FROM (SELECT species_name, depth, habitat, MAX(depth) OVER (PARTITION BY ocean) AS max_depth FROM southern_ocean_depths WHERE ocean = 'Southern Ocean') t WHERE depth = max_depth; |
What is the average museum attendance for each cultural event type? | CREATE TABLE Museums (museum_id INT,museum_name VARCHAR(255)); CREATE TABLE Events (event_id INT,museum_id INT,event_type VARCHAR(255),attendance INT); INSERT INTO Museums (museum_id,museum_name) VALUES (1,'Met'),(2,'Louvre'); INSERT INTO Events (event_id,museum_id,event_type,attendance) VALUES (1,1,'Art Exhibit',500),(2,1,'Concert',700),(3,2,'Art Exhibit',800),(4,2,'Theater',600); | SELECT event_type, AVG(attendance) as Avg_Attendance FROM Events GROUP BY event_type; |
What is the average word count for articles related to social justice issues? | CREATE TABLE Topics (id INT PRIMARY KEY,topic VARCHAR(100)); INSERT INTO Topics (id,topic) VALUES (1,'Politics'),(2,'Social Justice'),(3,'Entertainment'); CREATE TABLE Articles (id INT PRIMARY KEY,title TEXT,topic_id INT,word_count INT,FOREIGN KEY (topic_id) REFERENCES Topics(id)); INSERT INTO Articles (id,title,topic_id,word_count) VALUES (1,'Article 1',2,500),(2,'Article 2',1,700),(3,'Article 3',2,800); | SELECT AVG(a.word_count) as avg_word_count FROM Articles a JOIN Topics t ON a.topic_id = t.id WHERE t.topic = 'Social Justice'; |
List all workers and their corresponding department name | CREATE TABLE departments (id INT,name VARCHAR(20)); CREATE TABLE workers (id INT,department INT,salary FLOAT); INSERT INTO departments (id,name) VALUES (1,'Engineering'),(2,'Marketing'),(3,'Human Resources'); INSERT INTO workers (id,department,salary) VALUES (1,1,70000),(2,1,80000),(3,2,60000),(4,2,65000),(5,3,75000); | SELECT w.id, w.name, d.name AS department_name FROM workers w JOIN departments d ON w.department = d.id; |
How many policy advocacy events were held in 2022? | CREATE TABLE Advocacy(advocacy_id INT,date DATE);CREATE TABLE Policy_Advocacy(policy_id INT,advocacy_id INT); | SELECT COUNT(*) FROM Policy_Advocacy pa INNER JOIN Advocacy a ON pa.advocacy_id = a.advocacy_id WHERE YEAR(a.date) = 2022; |
Find the bioprocess engineering projects that started after June 30th, 2020 and are not yet completed. | CREATE TABLE bioprocess_engineering (id INT PRIMARY KEY,project_name VARCHAR(255),lead_scientist VARCHAR(255),start_date DATE,end_date DATE); INSERT INTO bioprocess_engineering (id,project_name,lead_scientist,start_date,end_date) VALUES (1,'Protein Purification','John Doe','2020-01-01','2020-12-31'),(2,'Cell Culturing','Jane Smith','2019-01-01','2019-12-31'),(3,'Enzyme Production','Alice Johnson','2020-07-01',NULL); | SELECT project_name, lead_scientist FROM bioprocess_engineering WHERE start_date > '2020-06-30' AND end_date IS NULL; |
What is the maximum number of kills achieved by a player in a single game session of "Starship Showdown"? | CREATE TABLE Kills (SessionID INT,PlayerID INT,Game TEXT,Kills INT); INSERT INTO Kills (SessionID,PlayerID,Game,Kills) VALUES (1,1,'Starship Showdown',25),(2,2,'Starship Showdown',30),(3,3,'Starship Showdown',15); | SELECT MAX(Kills) FROM Kills WHERE Game = 'Starship Showdown'; |
Which organizations have received the most funding for climate change initiatives? | CREATE TABLE grants (grantee_name TEXT,grant_amount REAL,grant_purpose TEXT); INSERT INTO grants (grantee_name,grant_amount,grant_purpose) VALUES ('Acme Impact',100000,'Climate Change'),('GreenTech Initiatives',200000,'Climate Change'),('EcoVentures',150000,'Climate Change'),('Global Philanthropic',50000,'Education'); | SELECT grantee_name, SUM(grant_amount) as total_climate_grants FROM grants WHERE grant_purpose = 'Climate Change' GROUP BY grantee_name ORDER BY total_climate_grants DESC; |
Which countries have the highest and lowest ethical labor ratings among their factories? | CREATE TABLE countries (country_id INT,name VARCHAR(255),region VARCHAR(255)); INSERT INTO countries VALUES (1,'USA','North America'); INSERT INTO countries VALUES (2,'India','Asia'); CREATE TABLE factories (factory_id INT,name VARCHAR(255),location VARCHAR(255),country_id INT,labor_rating INT); INSERT INTO factories VALUES (1,'Eco-Friendly Factory A','New York,NY',1,90); INSERT INTO factories VALUES (2,'Fairtrade Factory B','Delhi,India',2,85); | SELECT country.name, MAX(factories.labor_rating) AS max_rating, MIN(factories.labor_rating) AS min_rating FROM country JOIN factories ON country.country_id = factories.country_id GROUP BY country.name; |
How many art pieces were created per year in the 'impressionist_art' table? | CREATE TABLE impressionist_art (id INT,title VARCHAR(255),year INT); INSERT INTO impressionist_art (id,title,year) VALUES (1,'Impression,Sunrise',1872),(2,'Ballet Rehearsal',1873),(3,'Luncheon of the Boating Party',1880),(4,'Dance in the Country',1883); | SELECT year, COUNT(*) FROM impressionist_art GROUP BY year; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.