instruction
stringlengths 0
1.06k
| input
stringlengths 11
5.3k
| response
stringlengths 2
4.44k
|
---|---|---|
What is the total revenue for 'Spicy Tuna Roll' at 'Sushi House' on '2022-01-05'? | CREATE TABLE restaurants (restaurant_id INT,name VARCHAR(255)); INSERT INTO restaurants (restaurant_id,name) VALUES (21,'Sushi House'); CREATE TABLE menu_items (menu_item_id INT,name VARCHAR(255),price DECIMAL(5,2)); INSERT INTO menu_items (menu_item_id,name,price) VALUES (22,'Spicy Tuna Roll',7.99); CREATE TABLE orders (order_id INT,menu_item_id INT,quantity INT,order_date DATE,restaurant_id INT); INSERT INTO orders (order_id,menu_item_id,quantity,order_date,restaurant_id) VALUES (23,22,3,'2022-01-05',21); | SELECT SUM(price * quantity) FROM orders o JOIN menu_items mi ON o.menu_item_id = mi.menu_item_id WHERE mi.name = 'Spicy Tuna Roll' AND o.order_date = '2022-01-05' AND o.restaurant_id = 21; |
What is the average depth for marine species in the Pacific Ocean? | CREATE TABLE marine_species (species_id INT,species_name VARCHAR(50),min_depth FLOAT,max_depth FLOAT,ocean VARCHAR(50)); INSERT INTO marine_species (species_id,species_name,min_depth,max_depth,ocean) VALUES (1,'Spinner Dolphin',250,500,'Pacific'),(2,'Clownfish',10,30,'Pacific'),(3,'Shark',100,600,'Atlantic'); | SELECT AVG(avg_depth) FROM (SELECT (min_depth + max_depth) / 2 AS avg_depth FROM marine_species WHERE ocean = 'Pacific') AS subquery; |
What is the maximum temperature reading for all IoT sensors in "IN-MH" and "PK-PB"? | CREATE TABLE Temperature (id INT,sensor_id INT,temperature DECIMAL(5,2),location VARCHAR(255)); INSERT INTO Temperature (id,sensor_id,temperature,location) VALUES (1,1004,35.2,'IN-MH'); | SELECT MAX(temperature) FROM Temperature WHERE location IN ('IN-MH', 'PK-PB'); |
How many athletes are there in each team? | CREATE TABLE teams (team_id INT,team_name VARCHAR(50));CREATE TABLE athletes (athlete_id INT,athlete_name VARCHAR(50),team_id INT); INSERT INTO teams (team_id,team_name) VALUES (1,'Atlanta Hawks'),(2,'Boston Celtics'); INSERT INTO athletes (athlete_id,athlete_name,team_id) VALUES (1,'Player1',1),(2,'Player2',1),(3,'Player3',2),(4,'Player4',2),(5,'Player5',2); | SELECT t.team_name, COUNT(a.athlete_id) FROM teams t JOIN athletes a ON t.team_id = a.team_id GROUP BY t.team_id; |
List campaigns with budgets over $10,000 | CREATE TABLE campaigns (id INT,name VARCHAR(50),location VARCHAR(50),budget INT); | SELECT name FROM campaigns WHERE budget > 10000; |
Update 'renewable_energy_percentage' in 'smart_grid' for 'San Francisco' | CREATE TABLE smart_grid (id INT PRIMARY KEY,city VARCHAR(50),power_sources VARCHAR(50),renewable_energy_percentage INT); | UPDATE smart_grid SET renewable_energy_percentage = 75 WHERE city = 'San Francisco'; |
What is the total number of parts in the 'recyclable' material category? | CREATE TABLE parts (id INT,name VARCHAR(50),material VARCHAR(20)); INSERT INTO parts (id,name,material) VALUES (1,'Part 1','recyclable'),(2,'Part 2','non-recyclable'),(3,'Part 3','recyclable'); | SELECT COUNT(*) FROM parts WHERE material = 'recyclable'; |
What is the percentage of students who have completed a lifelong learning course in each school? | CREATE TABLE students_lifelong_learning (student_id INT,school_id INT,completed_course INT); INSERT INTO students_lifelong_learning VALUES (1,1,1); INSERT INTO students_lifelong_learning VALUES (2,1,0); INSERT INTO students_lifelong_learning VALUES (3,2,1); INSERT INTO students_lifelong_learning VALUES (4,2,1); CREATE TABLE school_roster (student_id INT,school_id INT); INSERT INTO school_roster VALUES (1,1); INSERT INTO school_roster VALUES (2,1); INSERT INTO school_roster VALUES (3,2); INSERT INTO school_roster VALUES (4,2); | SELECT s.school_name, 100.0 * SUM(CASE WHEN sl.completed_course = 1 THEN 1 ELSE 0 END) / COUNT(sr.student_id) AS completion_percentage FROM school_roster sr INNER JOIN students_lifelong_learning sl ON sr.student_id = sl.student_id INNER JOIN schools s ON sr.school_id = s.school_id GROUP BY s.school_name; |
What is the average response time for fire incidents in each precinct? | CREATE TABLE precincts (precinct_id INT,precinct_name TEXT,total_population INT); INSERT INTO precincts (precinct_id,precinct_name,total_population) VALUES (1,'1st Precinct',50000),(2,'2nd Precinct',60000),(3,'3rd Precinct',40000); CREATE TABLE fire_incidents (incident_id INT,precinct_id INT,response_time INT); INSERT INTO fire_incidents (incident_id,precinct_id,response_time) VALUES (1,1,8),(2,1,10),(3,2,6),(4,2,7),(5,3,12),(6,3,14); | SELECT precinct_name, AVG(response_time) FROM fire_incidents JOIN precincts ON fire_incidents.precinct_id = precincts.precinct_id GROUP BY precinct_name; |
How many customers have a top size larger than a specific value? | CREATE TABLE CustomerSizes (CustomerID INT,TopSize VARCHAR(10),BottomSize VARCHAR(10)); INSERT INTO CustomerSizes (CustomerID,TopSize,BottomSize) VALUES (1,'M','L'),(2,'S','M'),(3,'L','XL'),(4,'XL','L'),(5,'XXL','XL'); | SELECT COUNT(*) AS CustomerCount FROM CustomerSizes WHERE TopSize > 'L'; |
What are the total CO2 emissions for Australia, Japan, and South Korea? | CREATE TABLE co2_emissions (country VARCHAR(50),emissions INT); INSERT INTO co2_emissions (country,emissions) VALUES ('Australia',400),('Japan',1100),('South Korea',600); | SELECT country, emissions FROM co2_emissions WHERE country IN ('Australia', 'Japan', 'South Korea'); |
What is the total energy storage capacity in California, and the number of energy storage systems in California? | CREATE TABLE energy_storage (id INT,system_name VARCHAR(255),state VARCHAR(255),energy_capacity FLOAT); INSERT INTO energy_storage (id,system_name,state,energy_capacity) VALUES (1,'SystemA','California',1234.56),(2,'SystemB','California',678.90),(3,'SystemC','California',3456.78); | SELECT SUM(energy_capacity) as total_capacity, COUNT(*) as num_systems FROM energy_storage WHERE state = 'California'; |
Which countries have the least and most number of female producers in the producers table? | CREATE TABLE producers (id INT,name VARCHAR(50),gender VARCHAR(10),country VARCHAR(50)); | SELECT country, gender, COUNT(*) as count FROM producers GROUP BY country, gender ORDER BY country, count DESC; |
Add a new column 'last_updated_date' to the 'chemical_compounds' table | CREATE TABLE chemical_compounds (id INT PRIMARY KEY,name VARCHAR(255),safety_rating INT); | ALTER TABLE chemical_compounds ADD last_updated_date DATE; |
Show the number of podcasts in the media_content table by genre, ordered by the number of podcasts in descending order. | CREATE TABLE media_content (id INTEGER,title TEXT,type TEXT,genre TEXT,duration INTEGER,release_date DATE,popularity INTEGER); INSERT INTO media_content (id,title,type,genre,duration,release_date,popularity) VALUES (1,'Tech Talk','Podcast','Technology',30,'2021-02-01',5000),(2,'Arts and Culture','Podcast','Arts',60,'2021-01-10',3000); | SELECT genre, COUNT(*) AS podcasts_count FROM media_content WHERE type = 'Podcast' GROUP BY genre ORDER BY podcasts_count DESC; |
What is the total number of tickets sold for all games of the football team in Texas? | CREATE TABLE tickets (ticket_id INT,game_id INT,quantity INT,price DECIMAL(5,2)); INSERT INTO tickets VALUES (1,1,50,25.99); INSERT INTO tickets VALUES (2,2,30,19.99); CREATE TABLE games (game_id INT,team VARCHAR(20),location VARCHAR(20)); INSERT INTO games VALUES (1,'Cowboys','Dallas'); INSERT INTO games VALUES (2,'Texans','Houston'); | SELECT SUM(tickets.quantity) FROM tickets INNER JOIN games ON tickets.game_id = games.game_id WHERE games.location LIKE 'Texas'; |
Delete all records in the ProductIngredients table with organic ingredients. | CREATE TABLE ProductIngredients (productID INT,ingredient VARCHAR(50),organic BOOLEAN); INSERT INTO ProductIngredients (productID,ingredient,organic) VALUES (1,'Aloe Vera',true),(2,'Chamomile',true),(3,'Retinol',false),(4,'Hyaluronic Acid',false); | DELETE FROM ProductIngredients WHERE organic = true; |
What is the total revenue for the Asia-Pacific region in the last quarter? | CREATE TABLE sales(region VARCHAR(20),quarter INT,revenue FLOAT); INSERT INTO sales(region,quarter,revenue) VALUES('Asia-Pacific',1,5000),('Asia-Pacific',2,7000),('Asia-Pacific',3,8000),('Asia-Pacific',4,6000); | SELECT SUM(revenue) FROM sales WHERE region = 'Asia-Pacific' AND quarter IN (3, 4) |
What percentage of faculty members in each department are from underrepresented racial or ethnic groups? | CREATE TABLE faculty (id INT,department VARCHAR(255),race_ethnicity VARCHAR(255)); INSERT INTO faculty (id,department,race_ethnicity) VALUES (1,'Computer Science','Asian'),(2,'Mathematics','White'),(3,'Computer Science','Hispanic'),(4,'Physics','White'),(5,'Computer Science','Black'); | SELECT department, 100.0 * COUNT(CASE WHEN race_ethnicity IN ('Black', 'Hispanic') THEN 1 ELSE NULL END) / COUNT(*) as underrepresented_percentage FROM faculty GROUP BY department; |
Which program categories received donations in the last month, excluding categories that have never received donations before? | CREATE TABLE program_donations_time (program_category VARCHAR(20),donation_date DATE);INSERT INTO program_donations_time VALUES ('Arts','2022-09-01'),('Education','2022-10-01'),('Health','2022-11-01'),('Science',NULL); | SELECT program_category FROM program_donations_time WHERE donation_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) AND program_category IN (SELECT program_category FROM program_donations_time WHERE donation_date IS NOT NULL GROUP BY program_category); |
Remove the warehouse in Miami | CREATE TABLE warehouse (id INT,city VARCHAR(20),capacity INT); INSERT INTO warehouse (id,city,capacity) VALUES (1,'Chicago',1000),(2,'Houston',1500),(3,'Miami',800); | DELETE FROM warehouse WHERE city = 'Miami'; |
What is the total quantity of organic products sold by retail stores located in California? | CREATE TABLE RetailStores (StoreID INT,StoreName VARCHAR(50),State VARCHAR(50)); INSERT INTO RetailStores (StoreID,StoreName,State) VALUES (1,'RetailStoreA','California'),(2,'RetailStoreB','California'),(3,'RetailStoreC','New York'); CREATE TABLE Sales (SaleID INT,StoreID INT,ProductID INT,Quantity INT,Price DECIMAL(5,2)); INSERT INTO Sales (SaleID,StoreID,ProductID,Quantity,Price) VALUES (1,1,1,10,15.99),(2,1,2,5,12.49),(3,2,1,7,15.99); CREATE TABLE Products (ProductID INT,ProductName VARCHAR(50),IsOrganic BOOLEAN); INSERT INTO Products (ProductID,ProductName,IsOrganic) VALUES (1,'Product1',true),(2,'Product2',false); | SELECT SUM(Quantity) FROM Sales JOIN RetailStores ON Sales.StoreID = RetailStores.StoreID JOIN Products ON Sales.ProductID = Products.ProductID WHERE RetailStores.State = 'California' AND Products.IsOrganic = true; |
Which vessels in the 'fleet_management' table have a capacity greater than 10000? | CREATE TABLE fleet_management (id INT,name VARCHAR(50),type VARCHAR(50),capacity INT); | SELECT name FROM fleet_management WHERE capacity > 10000; |
How many solar power plants are there in California and Texas, and what are their names? | CREATE TABLE solar_plants (id INT,name VARCHAR(255),state VARCHAR(50)); INSERT INTO solar_plants (id,name,state) VALUES (1,'Solar Plant A','California'),(2,'Solar Plant B','Texas'),(3,'Solar Plant C','California'); | SELECT s.state, COUNT(*), s.name FROM solar_plants s WHERE s.state IN ('California', 'Texas') GROUP BY s.state, s.name; |
Update the 'amount' column in the 'climate_finance' table where the 'funding_source' is 'Bilateral' and 'country' is 'Bangladesh' | CREATE TABLE climate_finance (id INT,funding_source VARCHAR(255),country VARCHAR(255),amount FLOAT); | UPDATE climate_finance SET amount = amount * 1.1 WHERE funding_source = 'Bilateral' AND country = 'Bangladesh'; |
Add a new donor named 'AAPI Giving Circle' who identifies as Asian. | CREATE TABLE donors (id INT,gender VARCHAR(50),name VARCHAR(255)); INSERT INTO donors (id,gender,name) VALUES (1,'Female','Gender Equality Donor'); | INSERT INTO donors (id, gender, name) VALUES (2, 'Asian', 'AAPI Giving Circle'); |
List all Shariah-compliant financial instruments offered in Germany with their respective issuance dates. | CREATE TABLE shariah_compliant_instruments (instrument_id INT,name VARCHAR(255),country VARCHAR(255),issuance_date DATE); INSERT INTO shariah_compliant_instruments (instrument_id,name,country,issuance_date) VALUES (1,'Sukuk','Germany','2022-01-01'); INSERT INTO shariah_compliant_instruments (instrument_id,name,country,issuance_date) VALUES (2,'Murabaha','Germany','2021-12-15'); | SELECT * FROM shariah_compliant_instruments WHERE country = 'Germany'; |
What was the total budget for all rural infrastructure projects initiated in Kenya in 2020? | CREATE TABLE rural_infrastructure_projects (id INT,country VARCHAR(50),project_name VARCHAR(100),start_date DATE,end_date DATE,budget DECIMAL(10,2)); | SELECT SUM(budget) FROM rural_infrastructure_projects WHERE country = 'Kenya' AND YEAR(start_date) = 2020; |
What is the average threat level for the Middle East in the last 6 months? | CREATE TABLE threat_intelligence (threat_id INT,threat_level INT,region TEXT,threat_date DATE); | SELECT AVG(threat_level) FROM threat_intelligence WHERE region = 'Middle East' AND threat_date >= DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH); |
What is the minimum budget allocated for intelligence operations in the Asian region in 2021? | CREATE TABLE Intelligence_Budgets (budget_id INT,year INT,region_id INT,amount DECIMAL(10,2)); INSERT INTO Intelligence_Budgets (budget_id,year,region_id,amount) VALUES (1,2020,4,8000000.00),(2,2021,4,8500000.00); | SELECT MIN(amount) FROM Intelligence_Budgets WHERE year = 2021 AND region_id = (SELECT region_id FROM Regions WHERE region_name = 'Asian'); |
What is the total volume of organic waste generated in 2020, only considering data from Asia? | CREATE TABLE WasteGeneration (year INT,region VARCHAR(50),material VARCHAR(50),volume FLOAT); INSERT INTO WasteGeneration (year,region,material,volume) VALUES (2020,'North America','Organic',12000),(2020,'Europe','Organic',15000),(2020,'Asia','Organic',30000),(2020,'South America','Organic',10000),(2020,'Africa','Organic',8000); | SELECT SUM(volume) FROM WasteGeneration WHERE year = 2020 AND region = 'Asia' AND material = 'Organic'; |
What is the total amount donated by individual donors based in Canada, excluding donations made by organizations? | CREATE TABLE Donors (DonorID INT,DonorName TEXT,DonorType TEXT,Country TEXT); INSERT INTO Donors (DonorID,DonorName,DonorType,Country) VALUES (1,'John Doe','Individual','Canada'); INSERT INTO Donors (DonorID,DonorName,DonorType,Country) VALUES (2,'ABC Corp','Organization','Canada'); | SELECT SUM(DonationAmount) FROM Donations d JOIN Donors don ON d.DonorID = don.DonorID WHERE don.DonorType = 'Individual' AND don.Country = 'Canada'; |
Display the total number of satellites deployed by each country, such as 'USA', 'China', and 'India'. | CREATE TABLE satellites (id INT,name VARCHAR(255),manufacturer VARCHAR(255),country VARCHAR(255),launch_date DATE); INSERT INTO satellites (id,name,manufacturer,country,launch_date) VALUES (1,'FalconSat','SpaceX','USA','2020-01-01'),(2,'Cubesat','Blue Origin','USA','2019-01-01'),(3,'Electron','Rocket Lab','New Zealand','2021-01-01'),(4,'Telstar 18V','Telesat','China','2018-09-10'),(5,'GSAT-11','ISRO','India','2018-12-05'); | SELECT country, COUNT(*) FROM satellites GROUP BY country; |
What is the policy number, coverage amount, and effective date for policies with a policyholder address in 'São Paulo'? | CREATE TABLE policy (policy_number INT,coverage_amount INT,policyholder_address VARCHAR(50)); INSERT INTO policy VALUES (1,50000,'São Paulo'); INSERT INTO policy VALUES (2,75000,'Los Angeles'); | SELECT policy_number, coverage_amount, effective_date FROM policy INNER JOIN address ON policy.policyholder_address = address.address_line1 WHERE address.city = 'São Paulo'; |
What is the maximum cargo weight for vessels from Canada? | CREATE TABLE Vessels (Id INT,Name VARCHAR(50),Type VARCHAR(50),Flag VARCHAR(50),TotalWeight INT); INSERT INTO Vessels (Id,Name,Type,Flag,TotalWeight) VALUES (5,'VesselE','Tanker','Canada',20000),(6,'VesselF','Bulk Carrier','Canada',25000); | SELECT MAX(TotalWeight) FROM Vessels WHERE Flag = 'Canada'; |
What is the total water usage for each mine? | CREATE TABLE Mines (MineID INT,MineName VARCHAR(50),Location VARCHAR(50)); INSERT INTO Mines (MineID,MineName,Location) VALUES (1,'ABC Mine','Colorado'),(2,'DEF Mine','Alaska'),(3,'GHI Mine','Australia'); CREATE TABLE Operations (OperationID INT,MineID INT,OperationType VARCHAR(50),StartDate DATE,EndDate DATE); INSERT INTO Operations (OperationID,MineID,OperationType,StartDate,EndDate) VALUES (1,1,'Drilling','2020-01-01','2020-01-15'),(2,2,'Exploration','2020-02-01','2020-03-01'),(3,3,'Extraction','2020-04-01','2020-06-01'); CREATE TABLE EnvironmentalImpact (OperationID INT,WaterUsage INT); INSERT INTO EnvironmentalImpact (OperationID,WaterUsage) VALUES (1,5000),(2,7000),(3,6000); | SELECT Mines.MineName, SUM(EnvironmentalImpact.WaterUsage) FROM Mines INNER JOIN Operations ON Mines.MineID = Operations.MineID INNER JOIN EnvironmentalImpact ON Operations.OperationID = EnvironmentalImpact.OperationID GROUP BY Mines.MineName; |
What is the maximum number of items delivered per day for 'region_deliveries' table for 'Asia' in the year 2022? | CREATE TABLE region_deliveries (delivery_id INT,item_count INT,delivery_date DATE,region VARCHAR(50)); INSERT INTO region_deliveries (delivery_id,item_count,delivery_date,region) VALUES (1,10,'2022-01-01','Asia'),(2,20,'2022-01-02','Asia'); | SELECT MAX(item_count) FROM region_deliveries WHERE EXTRACT(YEAR FROM delivery_date) = 2022 AND region = 'Asia' GROUP BY delivery_date; |
Who are the astronauts that have participated in space missions longer than 250 days? | CREATE TABLE space_missions (id INT,mission_name VARCHAR(255),astronaut_name VARCHAR(255),duration INT); INSERT INTO space_missions (id,mission_name,astronaut_name,duration) VALUES (1,'Apollo 11','Neil Armstrong',195),(2,'Apollo 12','Jane Foster',244),(3,'Ares 3','Mark Watney',568),(4,'Apollo 18','Anna Mitchell',205); | SELECT astronaut_name FROM space_missions WHERE duration > 250; |
What is the minimum number of crew members required to operate the Space Shuttle? | CREATE TABLE CrewRequirements (CrewID INT,SpaceCraft VARCHAR(50),MinCrew INT); | SELECT MIN(MinCrew) FROM CrewRequirements WHERE SpaceCraft = 'Space Shuttle'; |
Insert a new record into the "SmartBuildings" table for a new "Wind" type building in "Tokyo" with a capacity of 800 | CREATE TABLE SmartBuildings (id INT,city VARCHAR(20),type VARCHAR(20),capacity INT); | INSERT INTO SmartBuildings (city, type, capacity) VALUES ('Tokyo', 'Wind', 800); |
What is the number of items produced in the 'Local' category in each year? | CREATE TABLE local_production (product_id INT,category VARCHAR(255),year INT); INSERT INTO local_production (product_id,category,year) VALUES (1,'Local',2021),(2,'Local',2022),(3,'Local',2021),(4,'Local',2022); | SELECT year, COUNT(*) as items_produced FROM local_production WHERE category = 'Local' GROUP BY year; |
What is the total cost of treatment for each unique treatment_approach in the 'treatment_costs' schema? | CREATE TABLE treatment_costs (cost_id INT,treatment_approach VARCHAR(255),cost DECIMAL(10,2)); INSERT INTO treatment_costs (cost_id,treatment_approach,cost) VALUES (1,'CBT',150.00),(2,'DBT',200.00),(3,'EMDR',250.00),(4,'Medication',50.00); | SELECT treatment_approach, SUM(cost) AS total_cost FROM treatment_costs GROUP BY treatment_approach; |
What is the total cost of concrete and steel materials in 'WaterSupply' table? | CREATE TABLE WaterSupply(location VARCHAR(255),material VARCHAR(255),cost FLOAT); INSERT INTO WaterSupply VALUES('SiteA','Concrete',120.5),('SiteA','Steel',350.0),('SiteA','Wood',200.0),('SiteB','Concrete',140.0),('SiteB','Steel',380.0),('SiteB','Wood',220.0); | SELECT SUM(cost) FROM WaterSupply WHERE material IN ('Concrete', 'Steel'); |
What is the most popular team among fans in the 'fans' table? | CREATE TABLE fans (id INT PRIMARY KEY,name VARCHAR(100),gender VARCHAR(10),age INT,favorite_team VARCHAR(50)); | SELECT favorite_team, COUNT(*) as fan_count FROM fans GROUP BY favorite_team ORDER BY fan_count DESC LIMIT 1; |
What safety measures are in place for Hydrochloric Acid? | CREATE TABLE SafetyProtocols (Id INT PRIMARY KEY,ChemicalName VARCHAR(100),SafetyMeasures TEXT); INSERT INTO SafetyProtocols (Id,ChemicalName,SafetyMeasures) VALUES (2,'Hydrochloric Acid','Always wear protective gloves and a lab coat when handling.'); | SELECT SafetyMeasures FROM SafetyProtocols WHERE ChemicalName = 'Hydrochloric Acid'; |
Which circular economy initiatives were launched in Mumbai and Paris between 2018 and 2020? | CREATE TABLE CircularEconomyInitiatives (CEIID INT,Location VARCHAR(50),Initiative VARCHAR(50),StartDate DATE,EndDate DATE); INSERT INTO CircularEconomyInitiatives (CEIID,Location,Initiative,StartDate,EndDate) VALUES (15,'Mumbai','Food Waste Reduction','2019-01-01','2023-12-31'); INSERT INTO CircularEconomyInitiatives (CEIID,Location,Initiative,StartDate,EndDate) VALUES (16,'Paris','Plastic Recycling','2018-06-01','2022-05-31'); | SELECT C.Location, C.Initiative FROM CircularEconomyInitiatives C WHERE C.Location IN ('Mumbai', 'Paris') AND C.StartDate BETWEEN '2018-01-01' AND '2020-12-31' GROUP BY C.Location, C.Initiative; |
How many graduate students have published in each of the top 3 academic journals in the past 5 years? | CREATE TABLE student_publications (id INT,student_id INT,journal_name VARCHAR(255),publication_year INT); INSERT INTO student_publications (id,student_id,journal_name,publication_year) VALUES (1,123,'Journal A',2018),(2,456,'Journal B',2019),(3,789,'Journal C',2020),(4,321,'Journal A',2017),(5,654,'Journal B',2021); | SELECT journal_name, COUNT(*) as publications, ROW_NUMBER() OVER (ORDER BY COUNT(*) DESC) as rank FROM student_publications WHERE publication_year BETWEEN 2016 AND 2021 GROUP BY journal_name HAVING rank <= 3; |
How many security incidents have been recorded per region in the 'incidents' table for the last 30 days? | CREATE TABLE incidents (incident_id INT,incident_time TIMESTAMP,region VARCHAR(50),severity VARCHAR(10)); INSERT INTO incidents (incident_id,incident_time,region,severity) VALUES (1,'2022-06-01 10:00:00','region_1','medium'),(2,'2022-06-02 14:30:00','region_2','high'),(3,'2022-06-03 08:15:00','region_3','high'),(4,'2022-06-05 16:20:00','region_1','low'),(5,'2022-06-10 09:35:00','region_3','medium'); | SELECT region, COUNT(*) as incident_count FROM incidents WHERE incident_time >= NOW() - INTERVAL '30 days' GROUP BY region; |
How many visitors identified as 'Non-binary' in Exhibit B? | CREATE TABLE exhibit_visitors (visitor_id INT,exhibit_id INT,age INT,gender VARCHAR(50)); INSERT INTO exhibit_visitors (visitor_id,exhibit_id,age,gender) VALUES (1,2,30,'Non-binary'),(2,2,35,'Female'),(3,2,45,'Male'); | SELECT exhibit_id, COUNT(*) FROM exhibit_visitors WHERE exhibit_id = 2 AND gender = 'Non-binary' GROUP BY exhibit_id; |
What is the average mental health score for students in each ethnic group? | CREATE TABLE student_demographics (student_id INT,ethnicity VARCHAR(50),mental_health_score INT); INSERT INTO student_demographics (student_id,ethnicity,mental_health_score) VALUES (1,'Hispanic',75),(2,'Asian',80),(3,'African American',60),(4,'Caucasian',65),(5,'Native American',85),(6,'Pacific Islander',90),(7,'Multiracial',70),(8,'Middle Eastern',75),(9,'Latin American',80); | SELECT ethnicity, AVG(mental_health_score) AS avg_score FROM student_demographics GROUP BY ethnicity; |
What is the total number of security incidents caused by outdated software in the first half of 2021? | CREATE TABLE SecurityIncidents (id INT,incident_name VARCHAR(255),cause VARCHAR(255),date DATE); INSERT INTO SecurityIncidents (id,incident_name,cause,date) VALUES (5,'Data Breach','Outdated Software','2021-03-12'); | SELECT SUM(incidents) FROM (SELECT COUNT(*) AS incidents FROM SecurityIncidents WHERE cause = 'Outdated Software' AND date >= '2021-01-01' AND date < '2021-07-01' GROUP BY cause) AS subquery; |
What is the distribution of games by genre and rating? | CREATE TABLE Games (GameID INT,Genre VARCHAR(10),Rating INT); INSERT INTO Games (GameID,Genre,Rating) VALUES (1,'Action',8); INSERT INTO Games (GameID,Genre,Rating) VALUES (2,'RPG',9); INSERT INTO Games (GameID,Genre,Rating) VALUES (3,'Strategy',7); INSERT INTO Games (GameID,Genre,Rating) VALUES (4,'Simulation',10); INSERT INTO Games (GameID,Genre,Rating) VALUES (5,'Action',6); | SELECT Games.Genre, AVG(Games.Rating) FROM Games GROUP BY Games.Genre; |
What is the average environmental impact score for each mining site in the past year? | CREATE TABLE mining_site_environmental_scores (site_id INT,score FLOAT,score_date DATE); INSERT INTO mining_site_environmental_scores (site_id,score,score_date) VALUES (1,80.0,'2022-01-01'),(1,85.0,'2022-02-01'),(2,90.0,'2022-01-01'),(2,95.0,'2022-02-01'),(3,70.0,'2022-01-01'),(3,75.0,'2022-02-01'); | SELECT site_id, AVG(score) FROM mining_site_environmental_scores WHERE score_date >= '2022-01-01' AND score_date < '2023-01-01' GROUP BY site_id; |
Find the number of hospital beds in each state | CREATE TABLE hospital_beds(id INT,hospital_name TEXT,state TEXT,num_beds INT); INSERT INTO hospital_beds(id,hospital_name,state,num_beds) VALUES (1,'UCLA Medical Center','California',500),(2,'Stanford Health Care','California',600),(3,'Rural Health Clinic','California',50),(4,'Texas Medical Center',1000),(5,'Methodist Hospital',550),(6,'Rural Health Care',30),(7,'Parkland Hospital',860),(8,'Alabama Medical Center',700),(9,'Alabama Community Hospital',400); | SELECT state, SUM(num_beds) FROM hospital_beds GROUP BY state; |
Which regions have a recycling rate above 60%? | CREATE TABLE regions (id INT,name VARCHAR(50),recycling_rate DECIMAL(5,2)); INSERT INTO regions (id,name,recycling_rate) VALUES (1,'North',0.62),(2,'South',0.58),(3,'East',0.45),(4,'West',0.70); | SELECT name FROM regions WHERE recycling_rate > 0.6; |
What was the total revenue for a K-pop artist's concert ticket sales in 2019? | CREATE TABLE Kpop_Concerts (year INT,artist VARCHAR(50),revenue FLOAT); INSERT INTO Kpop_Concerts (year,artist,revenue) VALUES (2018,'BTS',1000000),(2019,'BLACKPINK',1500000),(2020,'TWICE',800000),(2021,'SEVENTEEN',1200000),(2019,'BTS',1500000); | SELECT artist, SUM(revenue) FROM Kpop_Concerts WHERE year = 2019 AND artist = 'BTS' GROUP BY artist; |
Show the 'case_type' and 'case_status' for cases in the 'LegalAid' table where the 'case_type' is 'civil' | CREATE TABLE LegalAid (case_id INT,case_type VARCHAR(10),case_status VARCHAR(10)); INSERT INTO LegalAid (case_id,case_type,case_status) VALUES (1,'civil','open'),(2,'criminal','closed'),(3,'civil','closed'); | SELECT case_type, case_status FROM LegalAid WHERE case_type = 'civil'; |
What is the total number of green building projects in Canada? | CREATE TABLE Green_Buildings (Project_ID INT,Project_Name VARCHAR(255),Country VARCHAR(255),Square_Footage INT); INSERT INTO Green_Buildings (Project_ID,Project_Name,Country,Square_Footage) VALUES (1,'Wind Turbine Park','Canada',750000),(2,'Solar Farm','Canada',500000); | SELECT Country, COUNT(*) FROM Green_Buildings WHERE Country = 'Canada'; |
What is the total number of medical supplies available in Asian hospitals? | CREATE TABLE supplies (id INT,hospital_id INT,type VARCHAR(20),quantity INT); | SELECT SUM(quantity) FROM supplies JOIN hospitals ON supplies.hospital_id = hospitals.id WHERE hospitals.location LIKE '%Asia%'; |
Find the average price of organic skincare products in Australia. | CREATE TABLE products (product_id INT,name VARCHAR(100),is_organic BOOLEAN,category VARCHAR(50),country VARCHAR(50),price DECIMAL(5,2)); INSERT INTO products (product_id,name,is_organic,category,country,price) VALUES (1,'Cleanser',true,'Skincare','Australia',24.99); INSERT INTO products (product_id,name,is_organic,category,country,price) VALUES (2,'Toner',true,'Skincare','Australia',19.99); | SELECT AVG(price) FROM products WHERE is_organic = true AND category = 'Skincare' AND country = 'Australia'; |
Which donors donated more than $500 in a single donation? | CREATE TABLE Donations (DonationID int,DonorID int,DonationDate date,DonationAmount numeric(10,2)); INSERT INTO Donations (DonationID,DonorID,DonationDate,DonationAmount) VALUES (1,1,'2021-03-15',800),(2,2,'2021-06-28',350),(3,3,'2021-08-02',700); | SELECT DonorID, MAX(DonationAmount) as LargestDonation FROM Donations GROUP BY DonorID HAVING MAX(DonationAmount) > 500; |
What is the total number of policy impact reports for 'Education' in the 'East' region in 2021? | CREATE TABLE PolicyImpact(Date DATE,Region VARCHAR(20),Department VARCHAR(20),Quantity INT); INSERT INTO PolicyImpact(Date,Region,Department,Quantity) VALUES ('2021-01-01','East','Education',20),('2021-01-05','East','Education',15),('2021-02-10','East','Education',12); | SELECT SUM(Quantity) FROM PolicyImpact WHERE Region = 'East' AND Department = 'Education' AND Year(Date) = 2021; |
Which countries have the highest and lowest hotel star ratings? | CREATE TABLE hotels (hotel_id INT,hotel_name TEXT,country TEXT,stars FLOAT); INSERT INTO hotels (hotel_id,hotel_name,country,stars) VALUES (1,'Hotel Royal','USA',4.5),(2,'Hotel Paris','France',5.0),(3,'Hotel Tokyo','Japan',4.7),(4,'Hotel Rome','Italy',4.2),(5,'Hotel Beijing','China',4.8); | SELECT country, MAX(stars) as max_stars, MIN(stars) as min_stars FROM hotels GROUP BY country; |
What was the total number of construction permits issued in the state of Florida in 2020? | CREATE TABLE Construction_Permits (id INT,permit_number VARCHAR(20),issue_date DATE,state VARCHAR(20)); INSERT INTO Construction_Permits (id,permit_number,issue_date,state) VALUES (1,'CP12345','2020-01-01','Florida'); | SELECT COUNT(permit_number) FROM Construction_Permits WHERE issue_date >= '2020-01-01' AND issue_date < '2021-01-01' AND state = 'Florida'; |
Identify the number of precision farming equipment purchases by month in 2021 | CREATE TABLE purchase_data (purchase_date DATE,equipment_type VARCHAR(50)); INSERT INTO purchase_data (purchase_date,equipment_type) VALUES ('2021-01-05','Auto-steer system'),('2021-02-10','Variable rate technology'),('2021-03-15','Precision planting system'),('2021-04-20','Yield monitor'),('2021-05-25','Precision irrigation system'); | SELECT DATE_FORMAT(purchase_date, '%Y-%m') AS month, COUNT(*) FROM purchase_data WHERE YEAR(purchase_date) = 2021 AND equipment_type = 'precision farming equipment' GROUP BY month; |
What is the total revenue generated by virtual tours in New York? | CREATE TABLE virtual_tours(id INT,name TEXT,city TEXT,revenue FLOAT); INSERT INTO virtual_tours(id,name,city,revenue) VALUES (1,'NYC Virtual Landmarks Tour','New York',15000.0); | SELECT SUM(revenue) FROM virtual_tours WHERE city = 'New York'; |
What is the average temperature of the three hottest exoplanets? | CREATE TABLE Exoplanets (name TEXT,temperature REAL); INSERT INTO Exoplanets (name,temperature) VALUES ('Kepler-438b',40.3),('Kepler-90c',71.2),('55 Cancri e',2362.5); | SELECT AVG(temperature) FROM (SELECT temperature FROM Exoplanets ORDER BY temperature DESC LIMIT 3) AS subquery; |
What is the average game performance score for players from Europe? | CREATE TABLE Player (player_id INT,country VARCHAR(20)); CREATE TABLE GamePerformance (player_id INT,score INT); INSERT INTO Player (player_id,country) VALUES (1,'FR'),(2,'DE'),(3,'GB'),(4,'US'),(5,'CA'); INSERT INTO GamePerformance (player_id,score) VALUES (1,85),(2,90),(3,75),(4,95),(5,80); | SELECT AVG(GamePerformance.score) as avg_score FROM Player JOIN GamePerformance ON Player.player_id = GamePerformance.player_id WHERE Player.country LIKE 'EU%'; |
Calculate the percentage of donations that each organization has received in the current month, for organizations that have received at least one donation in the current month. | CREATE TABLE organization (org_id INT,org_name VARCHAR(255)); CREATE TABLE donation (don_id INT,donor_id INT,org_id INT,donation_amount INT,donation_date DATE); | SELECT org_id, ROUND(100.0 * SUM(donation_amount) / (SELECT SUM(donation_amount) FROM donation WHERE EXTRACT(MONTH FROM donation_date) = EXTRACT(MONTH FROM CURRENT_DATE) AND EXTRACT(YEAR FROM donation_date) = EXTRACT(YEAR FROM CURRENT_DATE))::DECIMAL, 2) AS pct_donations_current_month FROM donation WHERE EXTRACT(MONTH FROM donation_date) = EXTRACT(MONTH FROM CURRENT_DATE) AND EXTRACT(YEAR FROM donation_date) = EXTRACT(YEAR FROM CURRENT_DATE) GROUP BY org_id; |
What is the rank of explainable AI models by fairness score? | CREATE TABLE ExplainableAI (model_name TEXT,fairness_score FLOAT); INSERT INTO ExplainableAI (model_name,fairness_score) VALUES ('ModelA',0.85),('ModelB',0.90),('ModelC',0.80),('ModelD',0.88),('ModelE',0.92); | SELECT model_name, RANK() OVER (ORDER BY fairness_score DESC) rank FROM ExplainableAI; |
How many cultural heritage sites are in Rome and have more than 3 stars? | CREATE TABLE cultural_heritage_sites (site_id INT,site_name TEXT,city TEXT,rating INT); INSERT INTO cultural_heritage_sites (site_id,site_name,city,rating) VALUES (1,'Colosseum','Rome',5),(2,'Roman Forum','Rome',4),(3,'Pantheon','Rome',5); | SELECT COUNT(*) FROM cultural_heritage_sites WHERE city = 'Rome' AND rating > 3; |
What is the total number of trees in the forest_inventory table that have a diameter class that is present in the dangerous_diameter_classes table? | CREATE TABLE forest_inventory (tree_id INT,diameter_class VARCHAR(50)); CREATE TABLE dangerous_diameter_classes (diameter_class VARCHAR(50)); | SELECT COUNT(*) FROM forest_inventory WHERE diameter_class IN (SELECT diameter_class FROM dangerous_diameter_classes); |
What is the total biomass of fish in farm A? | CREATE TABLE aquaculture_farms (id INT,name VARCHAR(255)); INSERT INTO aquaculture_farms (id,name) VALUES (1,'Farm A'),(2,'Farm B'); CREATE TABLE fish_biomass (id INT,farm_id INT,species VARCHAR(255),biomass DECIMAL(5,2)); INSERT INTO fish_biomass (id,farm_id,species,biomass) VALUES (1,1,'Tilapia',120.5),(2,1,'Catfish',150.3),(3,2,'Tilapia',95.1),(4,2,'Salmon',200.0); | SELECT SUM(biomass) FROM fish_biomass WHERE farm_id = 1; |
What is the average account balance and transaction volume for customers in the Northeast region? | CREATE TABLE customer_data (id INT,customer_id INT,account_balance DECIMAL(10,2),transaction_volume INT,region VARCHAR(255)); INSERT INTO customer_data (id,customer_id,account_balance,transaction_volume,region) VALUES (1,1,10000,50,'Northeast'),(2,2,15000,100,'Southeast'),(3,3,8000,75,'Northeast'),(4,4,12000,25,'Midwest'),(5,5,9000,100,'Northeast'); | SELECT AVG(cd.account_balance) AS avg_account_balance, AVG(cd.transaction_volume) AS avg_transaction_volume FROM customer_data cd WHERE cd.region = 'Northeast'; |
How many unique members have a membership type of "premium"? | CREATE TABLE members (member_id INT,membership_type VARCHAR(10)); INSERT INTO members VALUES (1,'Premium'),(2,'Basic'),(3,'Premium'),(4,'Standard'); | SELECT COUNT(DISTINCT member_id) FROM members WHERE membership_type = 'Premium'; |
List all aircraft models with more than 500 units manufactured by Boeing and Airbus. | CREATE TABLE aircraft (model VARCHAR(255),manufacturer VARCHAR(255),units_manufactured INT); INSERT INTO aircraft (model,manufacturer,units_manufactured) VALUES ('737','Boeing',10000),('A320','Airbus',8000),('787','Boeing',700); | SELECT model, manufacturer FROM aircraft WHERE manufacturer IN ('Boeing', 'Airbus') GROUP BY model HAVING SUM(units_manufactured) > 500; |
Which countries have the most fair trade certified factories? | CREATE TABLE Countries (country_id INT,country VARCHAR(50),certification VARCHAR(50)); INSERT INTO Countries (country_id,country,certification) VALUES (1,'India','Fair Trade'),(2,'Bangladesh','Certified Organic'),(3,'China','Fair Trade'),(4,'India','Fair Trade'),(5,'Indonesia','Fair Trade'); | SELECT country, COUNT(*) as num_fair_trade_factories FROM Countries WHERE certification = 'Fair Trade' GROUP BY country ORDER BY num_fair_trade_factories DESC; |
Which social impact investments by Yellow Fund in Q2 2021 had the highest ROI? | CREATE TABLE Yellow_Fund (id INT,quarter VARCHAR(10),social_investment VARCHAR(30),roi FLOAT); INSERT INTO Yellow_Fund (id,quarter,social_investment,roi) VALUES (1,'Q2 2021','Education',0.15),(2,'Q2 2021','Healthcare',0.12); | SELECT social_investment, MAX(roi) FROM Yellow_Fund WHERE quarter = 'Q2 2021' GROUP BY social_investment; |
Which countries have the most investments in gender equality? | CREATE TABLE investments (id INT,country VARCHAR(50),sector VARCHAR(50),amount FLOAT); INSERT INTO investments (id,country,sector,amount) VALUES (1,'Canada','Gender Equality',500000),(2,'Mexico','Renewable Energy',750000),(3,'Canada','Gender Equality',600000); | SELECT country, COUNT(*) as num_investments FROM investments WHERE sector = 'Gender Equality' GROUP BY country ORDER BY num_investments DESC; |
What is the average playtime per day for each player? | CREATE TABLE player_daily_playtime (player_id INT,play_date DATE,playtime INT); INSERT INTO player_daily_playtime (player_id,play_date,playtime) VALUES (1,'2021-01-01',100),(1,'2021-01-02',200),(1,'2021-01-03',300),(2,'2021-01-01',400),(2,'2021-01-02',500),(2,'2021-01-03',600); | SELECT player_id, AVG(playtime) FROM player_daily_playtime GROUP BY player_id; |
What is the average age of the athletes in each team? | CREATE TABLE athletes (athlete_id INT,team_id INT,age INT); INSERT INTO athletes VALUES (1,1,25),(2,1,26),(3,2,27),(4,2,28),(5,3,29); | SELECT te.team_name, AVG(a.age) as avg_age FROM athletes a JOIN teams te ON a.team_id = te.team_id GROUP BY te.team_id; |
Find the average maintenance cost of military equipment for each type in the last 6 months. | CREATE TABLE military_equipment (equipment_id INT,equipment_type VARCHAR(50),maintenance_cost FLOAT,date DATE); | SELECT equipment_type, AVG(maintenance_cost) FROM military_equipment WHERE date >= DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH) GROUP BY equipment_type; |
What are the total mission durations for astronauts from JAXA who have been on multiple missions? | CREATE TABLE Astronauts (Astronaut_ID INT,Name VARCHAR(50),Gender VARCHAR(10),Age INT,Agency VARCHAR(50)); INSERT INTO Astronauts (Astronaut_ID,Name,Gender,Age,Agency) VALUES (3,'Soichi Noguchi','Male',54,'JAXA'),(4,'Akihiko Hoshide','Male',51,'JAXA'); CREATE TABLE Missions (Mission_ID INT,Mission_Name VARCHAR(50),Astronaut_Name VARCHAR(50),Agency VARCHAR(50),Start_Date DATETIME,End_Date DATETIME); INSERT INTO Missions (Mission_ID,Mission_Name,Astronaut_Name,Agency,Start_Date,End_Date) VALUES (4,'STS-114','Soichi Noguchi','JAXA','2005-07-26','2005-08-09'),(5,'STS-126','Soichi Noguchi','JAXA','2008-11-14','2008-11-30'),(6,'Expedition 32/33','Akihiko Hoshide','JAXA','2012-07-15','2012-11-18'); | SELECT a.Name, DATEDIFF(day, MIN(m.Start_Date), MAX(m.End_Date)) * 1.0 / 30 AS Total_Mission_Duration_Months FROM Astronauts a INNER JOIN Missions m ON a.Name = m.Astronaut_Name WHERE a.Agency = 'JAXA' GROUP BY a.Name HAVING COUNT(m.Mission_ID) > 1; |
What is the total budget for agricultural innovation projects in 'Oceania' in '2020'? | CREATE TABLE agri_innovation_projects(id INT,project TEXT,location TEXT,budget INT,year INT); INSERT INTO agri_innovation_projects (id,project,location,budget,year) VALUES (1,'Smart Farming Project','Oceania',3000000,2020); | SELECT SUM(budget) FROM agri_innovation_projects WHERE location = 'Oceania' AND year = 2020; |
What is the average daily water usage for a specific residential customer in a given month? | CREATE TABLE daily_usage (usage_id INT,customer_id INT,usage_date DATE,usage_amount FLOAT); INSERT INTO daily_usage (usage_id,customer_id,usage_date,usage_amount) VALUES (1,1,'2022-01-01',50),(2,1,'2022-01-02',55),(3,1,'2022-01-03',60); | SELECT AVG(usage_amount) FROM daily_usage WHERE customer_id = 1 AND usage_date BETWEEN '2022-01-01' AND '2022-01-31'; |
What is the median time to contain a vulnerability for the finance department? | CREATE TABLE vulnerabilities (id INT,incident_id INT,department VARCHAR(255),containment_time INT); INSERT INTO vulnerabilities (id,incident_id,department,containment_time) VALUES (1,444,'finance',120),(2,555,'finance',150),(3,666,'finance',180),(4,777,'finance',210); | SELECT AVG(containment_time) FROM (SELECT containment_time FROM vulnerabilities WHERE department = 'finance' ORDER BY containment_time LIMIT 2) AS subquery; |
Find the transaction with the highest amount and its customer's name? | CREATE TABLE Customers (CustomerID int,Name varchar(50),Age int); INSERT INTO Customers (CustomerID,Name,Age) VALUES (1,'John Smith',35),(2,'Jane Doe',42); CREATE TABLE Transactions (TransactionID int,CustomerID int,Amount decimal(10,2)); INSERT INTO Transactions (TransactionID,CustomerID,Amount) VALUES (1,1,500.00),(2,1,750.00),(3,2,250.00),(4,2,1000.00); | SELECT Contexts.Name as CustomerName, Transactions.Amount as HighestAmount FROM Contexts JOIN Transactions ON Contexts.CustomerID = Transactions.CustomerID WHERE Transactions.Amount = (SELECT MAX(Amount) FROM Transactions) ORDER BY HighestAmount DESC; |
What is the total area of sustainable forest management, in square kilometers, for each continent? | CREATE TABLE sustainable_forest_management (id INT,continent VARCHAR(255),country VARCHAR(255),region VARCHAR(255),area FLOAT); INSERT INTO sustainable_forest_management (id,continent,country,region,area) VALUES (1,'Africa','Kenya','East Africa',12345.12),(2,'Asia','India','South Asia',23456.12),(3,'Europe','France','Western Europe',34567.12); | SELECT continent, SUM(area) FROM sustainable_forest_management GROUP BY continent; |
What is the total volume of electronic waste generated in 2020, categorized by region for North America, Europe, and Africa? | CREATE TABLE WasteGeneration (year INT,region VARCHAR(50),material VARCHAR(50),volume FLOAT); INSERT INTO WasteGeneration (year,region,material,volume) VALUES (2020,'North America','Electronic',12000),(2020,'Europe','Electronic',15000),(2020,'Asia','Electronic',20000),(2020,'South America','Electronic',8000),(2020,'Africa','Electronic',6000); | SELECT region, SUM(volume) FROM WasteGeneration WHERE year = 2020 AND material = 'Electronic' GROUP BY region HAVING region IN ('North America', 'Europe', 'Africa'); |
What is the total number of pallets handled in the Los Angeles warehouse? | CREATE TABLE warehouse_stats (id INT,warehouse VARCHAR(20),total_pallets INT); INSERT INTO warehouse_stats (id,warehouse,total_pallets) VALUES (1,'Atlanta',2500),(2,'Los Angeles',3000),(3,'Houston',2000); | SELECT SUM(total_pallets) FROM warehouse_stats WHERE warehouse = 'Los Angeles'; |
What is the total number of military vehicles in Oceania? | CREATE TABLE MilitaryVehicles (Country VARCHAR(50),NumberOfVehicles INT); INSERT INTO MilitaryVehicles (Country,NumberOfVehicles) VALUES ('Australia',1000),('New Zealand',500),('Papua New Guinea',250),('Fiji',150),('Solomon Islands',100); | SELECT SUM(NumberOfVehicles) FROM MilitaryVehicles WHERE Country IN ('Australia', 'New Zealand', 'Papua New Guinea', 'Fiji', 'Solomon Islands'); |
List the organizations that have not allocated any budget for ethical AI. | CREATE TABLE allocations (id INT,organization VARCHAR(50),budget DECIMAL(10,2)); INSERT INTO allocations (id,organization,budget) VALUES (1,'EthicalAI',750000.00),(2,'NoBudget',NULL); | SELECT organization FROM allocations WHERE budget IS NULL; |
What is the 'total_cost' for all 'infrastructure_projects' in 'City B'? | CREATE TABLE infrastructure_projects (id INT,project_name VARCHAR(50),location VARCHAR(50),total_cost INT); INSERT INTO infrastructure_projects (id,project_name,location,total_cost) VALUES (1,'Road Widening','City A',500000),(2,'Coastal Protection','City B',700000),(3,'Wastewater Treatment','City A',800000),(4,'Airport Expansion','City B',900000); | SELECT SUM(total_cost) FROM infrastructure_projects WHERE location = 'City B'; |
Update landfill_capacity table, setting the capacity to 12000 where the country is 'Canada' | CREATE TABLE landfill_capacity (country VARCHAR(50),capacity INT); INSERT INTO landfill_capacity (country,capacity) VALUES ('Japan',10000),('Canada',15000),('Brazil',20000),('India',8000),('Australia',14000); | UPDATE landfill_capacity SET capacity = 12000 WHERE country = 'Canada'; |
What is the total number of workers in each mine? | CREATE TABLE Mines (MineID INT,Name TEXT,Location TEXT,TotalWorkers INT); INSERT INTO Mines (MineID,Name,Location,TotalWorkers) VALUES (1,'Golden Mine','California',250),(2,'Silver Ridge','Nevada',300); | SELECT Name, SUM(TotalWorkers) FROM Mines GROUP BY Name; |
Find the average donation per donor for donors who have donated more than $5000 | CREATE TABLE donors (id INT,name TEXT,total_donated DECIMAL); | SELECT AVG(total_donated) FROM donors WHERE total_donated > 5000; |
Retrieve the total population of marine species per country in the 'MarineLife' table | CREATE TABLE MarineLife (id INT PRIMARY KEY,species VARCHAR(255),population INT,country VARCHAR(255)); | SELECT country, SUM(population) FROM MarineLife GROUP BY country; |
How many children are there in each school in Afghanistan? | CREATE TABLE Schools (SchoolID INT,SchoolName TEXT,SchoolCountry TEXT); CREATE TABLE Classes (ClassID INT,SchoolID INT,ClassStudents INT); INSERT INTO Schools (SchoolID,SchoolName,SchoolCountry) VALUES (1,'Kabul School','Afghanistan'),(2,'Herat School','Afghanistan'); INSERT INTO Classes (ClassID,SchoolID,ClassStudents) VALUES (1,1,50),(2,1,60),(3,2,70),(4,2,80); | SELECT Schools.SchoolName, SUM(Classes.ClassStudents) FROM Schools INNER JOIN Classes ON Schools.SchoolID = Classes.SchoolID GROUP BY Schools.SchoolName; |
How many algorithmic fairness issues have been reported for each AI system, ordered by the number of issues in descending order? | CREATE TABLE ai_systems (system_id INT,system_name VARCHAR(50)); INSERT INTO ai_systems (system_id,system_name) VALUES (1,'AISystem1'),(2,'AISystem2'),(3,'AISystem3'),(4,'AISystem4'); CREATE TABLE fairness_reports (report_id INT,system_id INT,issue_count INT); INSERT INTO fairness_reports (report_id,system_id,issue_count) VALUES (1,1,5),(2,2,3),(3,3,7),(4,4,2); | SELECT a.system_name, SUM(fr.issue_count) as total_issues FROM ai_systems a JOIN fairness_reports fr ON a.system_id = fr.system_id GROUP BY a.system_name ORDER BY total_issues DESC; |
What is the minimum cost of a satellite launched by SpaceX? | CREATE TABLE Satellites (name TEXT,launch_date DATE,company TEXT,cost INTEGER); INSERT INTO Satellites (name,launch_date,company,cost) VALUES ('Starlink-1','2019-05-24','SpaceX',100000000); INSERT INTO Satellites (name,launch_date,company,cost) VALUES ('Starlink-2','2019-11-11','SpaceX',150000000); | SELECT MIN(cost) FROM Satellites WHERE company = 'SpaceX'; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.