instruction stringlengths 0 1.06k | input stringlengths 11 5.3k | response stringlengths 2 4.44k |
|---|---|---|
Delete all records from the 'crops' table where the temperature is below 15 degrees. | CREATE TABLE crops (id INT,crop_type VARCHAR(255),temperature FLOAT); INSERT INTO crops (id,crop_type,temperature) VALUES (1,'corn',20.5),(2,'soybean',18.3),(3,'wheat',16.7),(4,'rice',14.2),(5,'barley',12.9); | DELETE FROM crops WHERE temperature < 15; |
Get the average price of organic foundation products | CREATE TABLE beauty_products(product_id INT,product_type VARCHAR(20),organic BOOLEAN,price DECIMAL(10,2)); INSERT INTO beauty_products(product_id,product_type,organic,price) VALUES(1,'Foundation',TRUE,30.00),(2,'Blush',FALSE,15.00); | SELECT AVG(price) FROM beauty_products WHERE product_type = 'Foundation' AND organic = TRUE; |
How many cannabis plants were harvested in California in Q3 2022? | CREATE TABLE plant_harvest (plant_count INT,state VARCHAR(20),quarter VARCHAR(10)); INSERT INTO plant_harvest (plant_count,state,quarter) VALUES (1000,'California','Q3'),(1200,'California','Q3'),(1500,'California','Q3'); | SELECT SUM(plant_count) as total_plants FROM plant_harvest WHERE state = 'California' AND quarter = 'Q3'; |
What is the average age of musicians from the African continent? | CREATE TABLE artists (id INT PRIMARY KEY,name VARCHAR(50),ethnicity VARCHAR(20),age INT,genre VARCHAR(30)); INSERT INTO artists (id,name,ethnicity,age,genre) VALUES (1,'Saraa','Mongolian',35,'Throat Singing'),(2,'Kasumu','Nigerian',40,'Afrobeat'); | SELECT AVG(age) FROM artists WHERE ethnicity LIKE 'African%'; |
Update the location of a heritage site in the 'heritage_sites' table | CREATE TABLE heritage_sites (id INT PRIMARY KEY,name VARCHAR(255),location VARCHAR(255),year INT); | UPDATE heritage_sites SET location = 'Scotland' WHERE id = 1; |
What is the distribution of fan demographics (age, gender) for soccer games in Europe, and how does it compare to games in other regions? | CREATE TABLE soccer_demographics (game_date DATE,team VARCHAR(50),fan_age INT,fan_gender VARCHAR(50)); INSERT INTO soccer_demographics (game_date,team,fan_age,fan_gender) VALUES ('2022-01-01','Manchester United',25,'Male'),('2022-01-02','Barcelona',35,'Female'),('2022-01-03','Bayern Munich',28,'Male'),('2022-01-04','Pa... | SELECT fan_gender, AVG(fan_age) AS avg_age FROM soccer_demographics WHERE team IN ('Manchester United', 'Barcelona', 'Bayern Munich', 'Paris Saint-Germain', 'Juventus') GROUP BY fan_gender; |
Which fields in the 'South Atlantic' region produced more than 10000 barrels of oil daily in 2021? | CREATE TABLE wells (well_id INT,field VARCHAR(50),region VARCHAR(50),production_oil FLOAT,production_gas FLOAT,production_date DATE); INSERT INTO wells (well_id,field,region,production_oil,production_gas,production_date) VALUES (1,'Johnson','South Atlantic',15000.0,5000.0,'2021-01-01'),(2,'Smith','South Atlantic',8000.... | SELECT field FROM wells WHERE region = 'South Atlantic' AND production_oil > 10000 AND YEAR(production_date) = 2021; |
Find the total number of policies issued by 'Department A'? | CREATE TABLE policies (id INT,policy_number TEXT,department TEXT); INSERT INTO policies (id,policy_number,department) VALUES (1,'P1234','Department A'); INSERT INTO policies (id,policy_number,department) VALUES (2,'P5678','Department B'); INSERT INTO policies (id,policy_number,department) VALUES (3,'P9012','Department ... | SELECT COUNT(*) FROM policies WHERE department = 'Department A'; |
What is the average ticket price for concerts with attendance over 10000 for artists who identify as non-binary and are from Africa in 2023? | CREATE TABLE concert_events (event_id INT,artist_id INT,event_date DATE,event_location VARCHAR(255),attendance INT,ticket_price DECIMAL(10,2)); INSERT INTO concert_events (event_id,artist_id,event_date,event_location,attendance,ticket_price) VALUES (1,1,'2023-01-01','NYC',15000,50.00); CREATE TABLE artist_demographics ... | SELECT AVG(ticket_price) FROM concert_events ce JOIN artist_demographics ad ON ce.artist_id = ad.artist_id WHERE ce.attendance > 10000 AND ad.gender = 'non-binary' AND ad.ethnicity = 'African' AND ce.event_date BETWEEN '2023-01-01' AND '2023-12-31'; |
What is the average distance to the nearest hospital for residents in the "Appalachian" region? | CREATE TABLE Hospitals (HospitalID INT,Name VARCHAR(50),Location POINT); INSERT INTO Hospitals (HospitalID,Name,Location) VALUES (1,'Appalachian Hospital A',POINT(34.0459,-84.3494)); INSERT INTO Hospitals (HospitalID,Name,Location) VALUES (2,'Appalachian Hospital B',POINT(34.2356,-83.8724)); CREATE TABLE Residents (Res... | SELECT AVG(ST_Distance(Residents.Location, Hospitals.Location)) FROM Residents, Hospitals WHERE ST_DWithin(Residents.Location, Hospitals.Location, 50000) AND Residents.Location <> Hospitals.Location; |
Who are the top 3 organizations focusing on social good in Europe? | CREATE TABLE social_good (name VARCHAR(50),focus VARCHAR(50),region VARCHAR(50)); INSERT INTO social_good (name,focus,region) VALUES ('Tech for Good Europe','Social Good','Europe'),('AI for Social Impact','Social Good','Europe'),('Coding for Change','Social Good','Europe'),('Data for Social Good','Social Good','Europe'... | SELECT name FROM social_good WHERE region = 'Europe' ORDER BY ROW_NUMBER() OVER (ORDER BY focus DESC) LIMIT 3; |
What is the total number of environmental permits issued in Florida in 2021, categorized by permit type and permit issuer? | CREATE TABLE Permits (id INT,state VARCHAR(2),year INT,permit_type VARCHAR(10),permit_issuer VARCHAR(10),count INT); INSERT INTO Permits (id,state,year,permit_type,permit_issuer,count) VALUES (1,'FL',2021,'Air','EPA',20),(2,'FL',2021,'Water','DEP',30),(3,'FL',2021,'Waste','EPA',10); | SELECT permit_type, permit_issuer, SUM(count) FROM Permits WHERE state = 'FL' AND year = 2021 GROUP BY permit_type, permit_issuer; |
Find the daily oil production for platform 3 in January 2020 | CREATE TABLE daily_oil_production (platform_id INT,production_date DATE,oil_production FLOAT); INSERT INTO daily_oil_production (platform_id,production_date,oil_production) VALUES (1,'2020-01-01',50),(1,'2020-01-02',60),(1,'2020-01-03',70),(2,'2020-01-01',80),(2,'2020-01-02',90),(2,'2020-01-03',100),(3,'2020-01-01',110... | SELECT oil_production FROM daily_oil_production WHERE platform_id = 3 AND production_date BETWEEN '2020-01-01' AND '2020-01-03'; |
What is the maximum installed capacity of a single solar project in the state of New York? | CREATE TABLE solar_projects (id INT,state VARCHAR(20),installed_capacity FLOAT); INSERT INTO solar_projects (id,state,installed_capacity) VALUES (1,'New York',50.0),(2,'New York',60.5),(3,'California',75.2),(4,'New York',80.0); | SELECT MAX(installed_capacity) FROM solar_projects WHERE state = 'New York'; |
Find the total number of transactions made by customers from the 'Europe' region in the last month. | CREATE TABLE customers (id INT,region VARCHAR(20)); CREATE TABLE transactions (id INT,customer_id INT,transaction_date DATE); INSERT INTO customers (id,region) VALUES (1,'Europe'); INSERT INTO transactions (id,customer_id,transaction_date) VALUES (1,1,'2022-02-15'); | SELECT COUNT(*) FROM transactions JOIN customers ON transactions.customer_id = customers.id WHERE customers.region = 'Europe' AND transaction_date >= DATE_SUB(CURDATE(), INTERVAL 1 MONTH); |
List all biosensor technology patents that were filed by companies from the US or Canada. | CREATE SCHEMA if not exists biosensors;USE biosensors;CREATE TABLE if not exists patents(id INT,name VARCHAR(255),company VARCHAR(255),country VARCHAR(255));INSERT INTO patents(id,name,company,country) VALUES (1,'PatentA','Company1','US'),(2,'PatentB','Company2','CA'),(3,'PatentC','Company3','MX'); | SELECT * FROM biosensors.patents WHERE country IN ('US', 'CA'); |
What is the total quantity of each entree sold? | CREATE TABLE entree_orders (order_id INT,entree VARCHAR(255),entree_quantity INT); INSERT INTO entree_orders VALUES (1,'Spaghetti',10),(2,'Pizza',15),(3,'Pizza',8); | SELECT entree, SUM(entree_quantity) FROM entree_orders GROUP BY entree; |
What is the average rating of appliances for each type and energy efficiency standard in the appliances and energy_efficiency_standards tables, where the year is between 2015 and 2020? | CREATE TABLE energy_efficiency_standards (id INT,standard VARCHAR(255),year INT,min_rating FLOAT); CREATE TABLE appliances (id INT,type VARCHAR(255),standard VARCHAR(255),rating FLOAT); INSERT INTO energy_efficiency_standards (id,standard,year,min_rating) VALUES (1,'Energy Star',2010,0.5),(2,'EU Energy Label',2015,0.3)... | SELECT a.type, e.standard, AVG(a.rating) as avg_rating FROM appliances a INNER JOIN energy_efficiency_standards e ON a.standard = e.standard WHERE e.year BETWEEN 2015 AND 2020 GROUP BY a.type, e.standard; |
What is the total number of artworks by female artists in the 'Impressionist' movement? | CREATE TABLE Artists (ArtistID INT,Name VARCHAR(50),Gender VARCHAR(10),Nationality VARCHAR(50),ArtMovement VARCHAR(50)); INSERT INTO Artists (ArtistID,Name,Gender,Nationality,ArtMovement) VALUES (1,'Claude Monet','Male','French','Impressionist'); INSERT INTO Artists (ArtistID,Name,Gender,Nationality,ArtMovement) VALUES... | SELECT COUNT(*) FROM Artists WHERE Gender = 'Female' AND ArtMovement = 'Impressionist'; |
Insert a new row into the 'hotel_reviews' table with hotel_id 123, review_date '2022-01-01', and rating 4 | CREATE TABLE hotel_reviews (hotel_id INT,review_date DATE,rating INT); | INSERT INTO hotel_reviews (hotel_id, review_date, rating) VALUES (123, '2022-01-01', 4); |
Update the sector to 'Cybersecurity' for veteran_id 4 in the 'veteran_employment' table | CREATE TABLE veteran_employment (veteran_id INT,sector VARCHAR(255),employment_date DATE); INSERT INTO veteran_employment (veteran_id,sector,employment_date) VALUES (1,'IT','2020-01-01'),(2,'Healthcare','2019-06-15'),(3,'Finance','2018-09-30'),(4,'Manufacturing','2021-04-01'),(5,'Education','2020-12-15'); | UPDATE veteran_employment SET sector = 'Cybersecurity' WHERE veteran_id = 4; |
What is the quantity of hazardous items in the Lagos warehouse? | CREATE TABLE Warehouse (id INT,location VARCHAR(50),type VARCHAR(50),quantity INT); INSERT INTO Warehouse (id,location,type,quantity) VALUES (1,'USA','non-hazardous',300),(2,'Canada','hazardous',250),(3,'France','non-hazardous',500),(4,'Germany','hazardous',400),(5,'UK','non-hazardous',300),(6,'Japan','hazardous',450),... | SELECT quantity FROM Warehouse WHERE location = 'Lagos' AND type = 'hazardous'; |
What is the total funding received by startups founded by the LGBTQ+ community in the energy sector? | CREATE TABLE startups(id INT,name TEXT,industry TEXT,founder_community TEXT,funding FLOAT); INSERT INTO startups (id,name,industry,founder_community,funding) VALUES (1,'EnergyPride','Energy','LGBTQ+',8000000); | SELECT SUM(funding) FROM startups WHERE industry = 'Energy' AND founder_community = 'LGBTQ+'; |
What is the average delivery delay for Airbus A320neo aircraft? | CREATE TABLE Aircraft (id INT,name VARCHAR(50),manufacturer VARCHAR(50),delivery_date DATE,delivery_delay INT); INSERT INTO Aircraft (id,name,manufacturer,delivery_date,delivery_delay) VALUES (1,'A320neo','Airbus','2020-01-01',5),(2,'A320neo','Airbus','2020-02-01',3),(3,'787','Boeing','2019-12-01',0); | SELECT AVG(delivery_delay) FROM Aircraft WHERE name = 'A320neo'; |
What is the distribution of funding sources for theater programs, and how many programs have been funded by each source? | CREATE TABLE TheaterPrograms (Id INT,ProgramName VARCHAR(50),FundingSource VARCHAR(50));CREATE TABLE FundingSources (Id INT,Name VARCHAR(50)); | SELECT FS.Name, COUNT(*) as FundedPrograms, SUM(CASE WHEN FS.Id = TheaterPrograms.FundingSource THEN 1 ELSE 0 END) as TotalFunding FROM FundingSources FS LEFT JOIN TheaterPrograms ON FS.Id = TheaterPrograms.FundingSource GROUP BY FS.Name; |
Calculate the average severity of vulnerabilities for each software application | CREATE TABLE vulnerabilities (id INT,software_app VARCHAR(50),severity INT); | SELECT software_app, AVG(severity) as avg_severity FROM vulnerabilities GROUP BY software_app; |
What is the average revenue of games with multiplayer mode? | CREATE TABLE GameDesignData (GameID INT,Multiplayer BOOLEAN,Revenue DECIMAL(10,2)); INSERT INTO GameDesignData (GameID,Multiplayer,Revenue) VALUES (1,TRUE,2000000),(2,FALSE,1000000),(3,TRUE,1500000); | SELECT AVG(Revenue) FROM GameDesignData WHERE Multiplayer = TRUE; |
Determine the average energy consumption of buildings constructed before 2010 in the 'SmartCities' schema. | CREATE TABLE SmartCities.Buildings (id INT,built_year INT,energy_consumption FLOAT); INSERT INTO SmartCities.Buildings (id,built_year,energy_consumption) VALUES (1,2005,1200.5),(2,2012,800.2),(3,2008,1000.7),(4,2000,1500.3),(5,2015,900.0); | SELECT AVG(energy_consumption) FROM SmartCities.Buildings WHERE built_year < 2010; |
What is the minimum temperature recorded during the mission 'Ares 3'? | CREATE TABLE TemperatureRecords (Id INT,Mission VARCHAR(50),Temperature INT); INSERT INTO TemperatureRecords (Id,Mission,Temperature) VALUES (1,'Ares 3',100),(2,'Ares 3',150),(3,'Apollo 11',200); | SELECT MIN(Temperature) FROM TemperatureRecords WHERE Mission = 'Ares 3' |
List the genres that have no albums released in 2022. | CREATE TABLE Genres (Genre VARCHAR(20)); CREATE TABLE Albums (AlbumID INT,Genre VARCHAR(20),ReleaseYear INT); INSERT INTO Genres VALUES ('Rock'),('Pop'),('Jazz'),('Blues'),('Folk'),('Country'); INSERT INTO Albums VALUES (1,'Rock',2022),(2,'Jazz',2020),(3,'Blues',2022),(4,'Folk',2022),(5,'Pop',2022),(6,'Rock',2022),(7,'... | SELECT Genre FROM Genres WHERE Genre NOT IN (SELECT Genre FROM Albums WHERE ReleaseYear = 2022); |
What is the revenue for each region, excluding the lowest performing restaurant in that region? | CREATE TABLE Sales_By_Restaurant (RestaurantID INT,RestaurantName VARCHAR(255),Region VARCHAR(255),Sales INT); INSERT INTO Sales_By_Restaurant VALUES (1,'Restaurant A','North',1500),(2,'Restaurant B','North',1450),(3,'Restaurant C','South',1200),(4,'Restaurant D','South',1300),(5,'Restaurant E','East',1800),(6,'Restaur... | SELECT Sales_By_Restaurant.Region, SUM(Sales_By_Restaurant.Sales) - (SELECT Sales_By_Restaurant.Sales FROM Sales_By_Restaurant WHERE Sales_By_Restaurant.Region = R.Region AND Sales_By_Restaurant.Sales = (SELECT MIN(Sales) FROM Sales_By_Restaurant AS T WHERE T.Region = Sales_By_Restaurant.Region)) AS Revenue FROM Sales_... |
Update the number of participants for a specific program in a new location. | CREATE TABLE Programs (program_id INT,program_name VARCHAR(255),location VARCHAR(255),num_participants INT,impact_assessment DECIMAL(3,2)); | UPDATE Programs SET num_participants = 50, location = 'Denver, CO' WHERE program_id = 2 AND program_name = 'Art Education Program'; |
What is the total revenue generated from concert ticket sales in California? | CREATE TABLE concerts (id INT,artist_id INT,location VARCHAR(255),revenue FLOAT); INSERT INTO concerts (id,artist_id,location,revenue) VALUES (1,101,'California',50000.00); INSERT INTO concerts (id,artist_id,location,revenue) VALUES (2,102,'New York',75000.00); | SELECT SUM(revenue) FROM concerts WHERE location = 'California'; |
What is the average salary of workers in the 'mining' and 'geology' departments? | CREATE TABLE departments (id INT,name TEXT,salary FLOAT); INSERT INTO departments (id,name,salary) VALUES (1,'engineering',70000.0),(2,'mining',75000.0),(3,'geology',80000.0); | SELECT AVG(salary) FROM departments WHERE name IN ('mining', 'geology'); |
Delete students who have not taken any courses in "SchoolB" database since 2019 | CREATE TABLE SchoolB (student_id INT,course_id INT,enrollment_date DATE); INSERT INTO SchoolB (student_id,course_id,enrollment_date) VALUES (1,201,'2021-01-05'),(1,202,'2022-02-12'),(2,201,NULL),(3,203,'2019-12-31'),(4,202,'2020-09-01'),(5,201,'2021-05-15'); | DELETE FROM SchoolB WHERE student_id IN (SELECT student_id FROM SchoolB WHERE course_id IS NULL AND enrollment_date < '2020-01-01'); |
What is the minimum response time for ambulances in the city of Tokyo and Seoul? | CREATE TABLE ambulance_responses (id INT,city VARCHAR(20),response_time INT); INSERT INTO ambulance_responses (id,city,response_time) VALUES (1,'Tokyo',120),(2,'Tokyo',130),(3,'Seoul',100),(4,'Seoul',110); | SELECT MIN(response_time) FROM ambulance_responses WHERE city IN ('Tokyo', 'Seoul'); |
Delete records with a 'date_completed' before '2021-01-01' from the 'teacher_training' table | CREATE TABLE teacher_training (teacher_id INT,training_title VARCHAR(100),date_completed DATE); | DELETE FROM teacher_training WHERE date_completed < '2021-01-01'; |
Get CO2 emissions savings (in metric tons) of renewable projects in CA | CREATE TABLE project (id INT,name TEXT,state TEXT,co2_savings INT); INSERT INTO project (id,name,state,co2_savings) VALUES (5,'Solar Star','CA',1234567),(6,'Desert Stateline','CA',654321); | SELECT SUM(co2_savings) FROM project WHERE state = 'CA'; |
What is the average extraction rate for mines located in the Andes? | CREATE TABLE mines (id INT PRIMARY KEY,name VARCHAR(255),location VARCHAR(255)); INSERT INTO mines (id,name,location) VALUES (1,'La Rinconada','Peru'); INSERT INTO mines (id,name,location) VALUES (2,'Cerro Rico','Bolivia'); CREATE TABLE commodities (id INT PRIMARY KEY,mine_id INT,commodity_type VARCHAR(255),extraction_... | SELECT m.location, AVG(c.extraction_rate) as avg_extraction_rate FROM mines m JOIN commodities c ON m.id = c.mine_id WHERE m.location = 'Andes' GROUP BY m.location; |
Insert a new Series B round for a startup founded by an LGBTQ+ entrepreneur from India in 2018 with a $5M investment | CREATE TABLE startups_lgbtq(id INT,name VARCHAR(50),founding_year INT,founder_lgbtq VARCHAR(5)); CREATE TABLE investment_rounds_lgbtq(startup_id INT,round_type VARCHAR(10),round_amount FLOAT); INSERT INTO startups_lgbtq VALUES (1,'StartupG',2018,'Yes'); INSERT INTO startups_lgbtq VALUES (2,'StartupH',2017,'No'); INSERT... | INSERT INTO investment_rounds_lgbtq (startup_id, round_type, round_amount) VALUES (1, 'Series B', 5000000); |
List concert ticket sales revenue for artists from Africa. | CREATE TABLE artists (id INT PRIMARY KEY,name VARCHAR(255),genre VARCHAR(255),country VARCHAR(255)); CREATE TABLE concerts (id INT PRIMARY KEY,artist_id INT,venue VARCHAR(255),city VARCHAR(255),country VARCHAR(255),tickets_sold INT,revenue DECIMAL(10,2)); CREATE TABLE users (id INT PRIMARY KEY,gender VARCHAR(50),age IN... | SELECT SUM(revenue) AS total_revenue FROM concerts WHERE country = 'Africa'; |
List the unique 'Workout' types offered at each studio, excluding 'Yoga' workouts. | CREATE TABLE Studios (studio VARCHAR(50)); INSERT INTO Studios (studio) VALUES ('Boston'),('Seattle'),('New York'); CREATE TABLE Workouts (studio VARCHAR(50),workout VARCHAR(50)); INSERT INTO Workouts (studio,workout) VALUES ('Boston','Pilates'),('Boston','Boxing'),('Seattle','Cycling'),('Seattle','Yoga'),('New York','... | SELECT DISTINCT studio, workout FROM Workouts WHERE workout != 'Yoga'; |
What was the average donation amount in each country in H2 2021? | CREATE TABLE Donations (DonationID int,DonorID int,Country varchar(50),AmountDonated numeric(10,2),DonationDate date); INSERT INTO Donations (DonationID,DonorID,Country,AmountDonated,DonationDate) VALUES (1,1,'USA',100.00,'2021-07-01'),(2,2,'Canada',150.00,'2021-12-31'); | SELECT Country, AVG(AmountDonated) as AvgDonation FROM Donations WHERE DonationDate BETWEEN '2021-07-01' AND '2021-12-31' GROUP BY Country; |
List all marine species that live at a depth greater than 30 meters. | CREATE TABLE marine_species (name TEXT,depth FLOAT); INSERT INTO marine_species (name,depth) VALUES ('Squid',35.2),('Shark',22.9),('Anglerfish',40.5); | SELECT name FROM marine_species WHERE depth > 30; |
Identify the unique age ranges of members who participated in 'yoga' or 'spinning' classes. | CREATE TABLE member_classes (member_id INT,class_type VARCHAR(50),age INT); INSERT INTO member_classes (member_id,class_type,age) VALUES (1,'yoga',30),(2,'spinning',35),(3,'yoga',40),(4,'spinning',25),(5,'yoga',30); | SELECT DISTINCT FLOOR(age / 10) * 10 AS age_range FROM member_classes WHERE class_type IN ('yoga', 'spinning'); |
Update innovation_trends table to reflect AI as a trend for company_id 101 | CREATE TABLE companies (id INT PRIMARY KEY,name VARCHAR(255)); CREATE TABLE innovation_trends (id INT PRIMARY KEY,company_id INT,trend VARCHAR(255)); | UPDATE innovation_trends SET trend = 'AI' WHERE company_id = 101; |
What is the total weight of items in the warehouse located in Lagos? | CREATE TABLE warehouses (id INT,location VARCHAR(255),weight INT); INSERT INTO warehouses (id,location,weight) VALUES (1,'Houston',1000),(2,'New York',2000),(3,'Lagos',5000); | SELECT SUM(weight) FROM warehouses WHERE location = 'Lagos'; |
What is the total number of vegetarian dishes offered by restaurants located in the Pacific Northwest? | CREATE TABLE restaurants (id INT,name TEXT,region TEXT); INSERT INTO restaurants (id,name,region) VALUES (1,'Restaurant A','Pacific Northwest'),(2,'Restaurant B','Southeast'); CREATE TABLE dishes (id INT,name TEXT,restaurant_id INT,is_vegetarian BOOLEAN); INSERT INTO dishes (id,name,restaurant_id,is_vegetarian) VALUES ... | SELECT COUNT(*) FROM dishes d JOIN restaurants r ON d.restaurant_id = r.id WHERE r.region = 'Pacific Northwest' AND d.is_vegetarian = true; |
Which circular economy initiatives have been implemented by companies in the textile industry? | CREATE TABLE initiatives (id INT,company_id INT,initiative_type TEXT,initiative_description TEXT); INSERT INTO initiatives (id,company_id,initiative_type,initiative_description) VALUES (1,1,'Waste Reduction','Implemented a recycling program for fabric scraps'),(2,1,'Energy Efficiency','Installed solar panels on factory... | SELECT company_name, initiative_type, initiative_description FROM companies c JOIN initiatives i ON c.id = i.company_id WHERE c.industry = 'Textile' AND initiative_type IN ('Waste Reduction', 'Energy Efficiency', 'Product Design'); |
What is the name of the manager for the 'metallurgy' department? | CREATE TABLE department (id INT,name VARCHAR(255),manager_id INT,manager_name VARCHAR(255),location VARCHAR(255)); INSERT INTO department (id,name,manager_id,manager_name,location) VALUES (1,'textiles',101,'Eva','New York'); INSERT INTO department (id,name,manager_id,manager_name,location) VALUES (2,'metallurgy',102,'F... | SELECT manager_name FROM department WHERE name = 'metallurgy'; |
How many vehicles of type 'bus' and 'tram' are there in total? | CREATE TABLE vehicle (vehicle_id INT,type TEXT,model_year INT,last_maintenance_date DATE); | SELECT type, COUNT(*) FROM vehicle WHERE type IN ('bus', 'tram') GROUP BY type; |
What is the recycling rate for metal in the state of California in 2020?' | CREATE TABLE recycling_rates (state VARCHAR(20),year INT,material_type VARCHAR(20),recycling_rate DECIMAL(5,2)); INSERT INTO recycling_rates VALUES ('California',2020,'Plastic',0.3),('California',2020,'Glass',0.5),('California',2020,'Paper',0.7),('California',2020,'Metal',0.6),('California',2020,'Organic',0.4); | SELECT recycling_rate FROM recycling_rates WHERE state = 'California' AND year = 2020 AND material_type = 'Metal'; |
What is the average budget allocated for public works in the cities of Dallas, Seattle, and New York for the years 2023 and 2024? | CREATE TABLE city_budgets (city varchar(50),year int,service varchar(50),budget int); INSERT INTO city_budgets (city,year,service,budget) VALUES ('Dallas',2023,'Public Works',10000000),('Dallas',2024,'Public Works',11000000),('Seattle',2023,'Public Works',12000000),('Seattle',2024,'Public Works',13000000),('New York',2... | SELECT AVG(budget) FROM city_budgets WHERE (city = 'Dallas' OR city = 'Seattle' OR city = 'New York') AND service = 'Public Works' AND (year = 2023 OR year = 2024); |
Find the number of players who are older than 30. | CREATE TABLE player_demographics (player_id INT,age INT,favorite_genre VARCHAR(20)); INSERT INTO player_demographics (player_id,age,favorite_genre) VALUES (1,25,'Action'),(2,30,'RPG'),(3,22,'Action'),(4,35,'Simulation'); | SELECT COUNT(*) FROM player_demographics WHERE age > 30; |
Compare mental health parity violations between urban and rural areas. | CREATE TABLE mental_health_parity (state VARCHAR(2),area VARCHAR(5),violations INT); INSERT INTO mental_health_parity (state,area,violations) VALUES ('CA','Urban',15),('CA','Rural',10),('NY','Urban',12),('NY','Rural',6),('TX','Urban',20),('TX','Rural',10); | SELECT area, SUM(violations) FROM mental_health_parity GROUP BY area; |
What is the average cargo weight (in metric tons) for Indonesian ports? | CREATE TABLE ports (port_id INT,port_name VARCHAR(50),country VARCHAR(50)); INSERT INTO ports VALUES (1,'Tanjung Priok','Indonesia'); INSERT INTO ports VALUES (2,'Belawan','Indonesia'); CREATE TABLE cargo (cargo_id INT,port_id INT,weight_ton FLOAT); INSERT INTO cargo VALUES (1,1,5000); INSERT INTO cargo VALUES (2,1,700... | SELECT AVG(weight_ton) FROM cargo JOIN ports ON cargo.port_id = ports.port_id WHERE ports.country = 'Indonesia'; |
What is the minimum daily production of Samarium in 'Europe' in 2018? | CREATE TABLE mining(day INT,year INT,region VARCHAR(10),element VARCHAR(10),quantity INT); INSERT INTO mining VALUES(1,2018,'Europe','Samarium',200),(2,2018,'Europe','Samarium',250),(3,2018,'Europe','Samarium',300); | SELECT MIN(quantity) FROM mining WHERE element = 'Samarium' AND region = 'Europe' AND year = 2018 GROUP BY day, year, element, region |
What is the total billing amount for cases with a positive outcome? | CREATE TABLE cases (id INT,outcome VARCHAR(10),billing_amount DECIMAL(10,2)); INSERT INTO cases (id,outcome,billing_amount) VALUES (1,'Positive',5000.00),(2,'Negative',3000.00); | SELECT SUM(billing_amount) FROM cases WHERE outcome = 'Positive'; |
What is the total revenue for OTA bookings from 'Europe'? | CREATE TABLE ota_bookings (booking_id INT,hotel_name TEXT,region TEXT,revenue FLOAT); INSERT INTO ota_bookings (booking_id,hotel_name,region,revenue) VALUES (4,'Hotel T','Europe',800),(5,'Hotel U','Europe',900),(6,'Hotel V','Europe',700); | SELECT SUM(revenue) FROM ota_bookings WHERE region = 'Europe'; |
What is the total number of concert tickets sold in each city for artists from the Rock genre? | CREATE TABLE Concerts (id INT,city VARCHAR(255),tickets_sold INT); CREATE TABLE Artists (id INT,genre VARCHAR(255)); | SELECT city, SUM(tickets_sold) as total_tickets_sold FROM Concerts INNER JOIN Artists ON Concerts.id = Artists.id WHERE genre = 'Rock' GROUP BY city; |
What is the average delivery time for packages shipped via air from each warehouse in Q3 2021? | CREATE TABLE deliveries (id INT,delivery_time FLOAT,warehouse VARCHAR(20),quarter INT,shipment_type VARCHAR(20)); INSERT INTO deliveries (id,delivery_time,warehouse,quarter,shipment_type) VALUES (1,1.5,'New York',3,'Air'),(2,5.0,'Seattle',1,'Ground'),(3,1.2,'New York',3,'Air'); CREATE TABLE warehouses (id INT,name VARC... | SELECT p.warehouse, AVG(d.delivery_time) FROM deliveries d JOIN warehouses w ON d.warehouse = w.name JOIN shipment_types st ON d.shipment_type = st.type WHERE st.type = 'Air' AND d.quarter = 3 GROUP BY p.warehouse; |
Update labor_practices_rating for factories in 'factory_labor_practices' table | CREATE TABLE factories (id INT,name TEXT);CREATE TABLE factory_labor_practices (factory_id INT,labor_practices_rating INT); | UPDATE factory_labor_practices SET labor_practices_rating = 4 WHERE factory_id IN (SELECT f.id FROM factories f JOIN supplier_factories sf ON f.id = sf.factory_id WHERE sf.supplier_id = 10); |
Calculate the moving average of revenue for each garment for the last 3 months. | CREATE TABLE GarmentSales (garment_id INT,date DATE,revenue DECIMAL(10,2)); INSERT INTO GarmentSales (garment_id,date,revenue) VALUES (1,'2020-01-01',1000.00),(1,'2020-02-01',2000.00),(1,'2020-03-01',3000.00),(2,'2020-01-01',4000.00),(2,'2020-02-01',5000.00); | SELECT garment_id, date, AVG(revenue) OVER (PARTITION BY garment_id ORDER BY date ROWS BETWEEN 2 PRECEDING AND CURRENT ROW) AS moving_average FROM GarmentSales; |
Delete all records related to wheelchair ramps from the accommodations table. | CREATE TABLE accommodations (id INT,type VARCHAR(255),description VARCHAR(255)); INSERT INTO accommodations (id,type,description) VALUES (1,'Wheelchair Ramp','Ramp with handrails and non-slip surface'); INSERT INTO accommodations (id,type,description) VALUES (2,'Elevator','Standard elevator for building access'); | DELETE FROM accommodations WHERE type = 'Wheelchair Ramp'; |
Update the accommodation description for accommodation ID 789 to 'FM system' | CREATE TABLE Accommodations (AccommodationID INT PRIMARY KEY,Description VARCHAR(50),StudentID INT,Disability VARCHAR(20),FOREIGN KEY (StudentID) REFERENCES Students(StudentID)); | UPDATE Accommodations SET Description = 'FM system' WHERE AccommodationID = 789; |
List all the projects in the 'projects' table that received donations from donors in the 'donors' table and display the project names and the total donation amounts. | CREATE TABLE projects (project_id INT,project_name VARCHAR(255)); CREATE TABLE donors (donor_id INT,project_id INT,donation_amount FLOAT); INSERT INTO projects (project_id,project_name) VALUES (1,'Project A'),(2,'Project B'),(3,'Project C'); INSERT INTO donors (donor_id,project_id,donation_amount) VALUES (1,1,5000),(2,... | SELECT p.project_name, SUM(d.donation_amount) as total_donation FROM projects p JOIN donors d ON p.project_id = d.project_id GROUP BY p.project_name; |
What is the average production volume of neodymium in 2020, for mines located in Canada? | CREATE TABLE mines (id INT,name TEXT,location TEXT,production_volume INT); INSERT INTO mines (id,name,location,production_volume) VALUES (1,'Mine A','Canada',500),(2,'Mine B','USA',600); | SELECT AVG(production_volume) FROM mines WHERE location = 'Canada' AND extract(year from date) = 2020 AND element = 'neodymium'; |
What is the maximum arrival age of visitors from the United States? | CREATE TABLE tourism_data (visitor_id INT,country VARCHAR(50),arrival_age INT); INSERT INTO tourism_data (visitor_id,country,arrival_age) VALUES (1,'USA',35),(2,'USA',42),(3,'Japan',28),(4,'Australia',31),(5,'UK',29),(6,'UK',34),(7,'Canada',22),(8,'Canada',25); CREATE VIEW us_visitors AS SELECT * FROM tourism_data WHER... | SELECT MAX(arrival_age) FROM us_visitors WHERE country = 'USA'; |
How many cases were handled by attorneys who identify as male? | CREATE TABLE Attorneys (AttorneyID INT PRIMARY KEY,Gender VARCHAR(6),Name VARCHAR(255)); INSERT INTO Attorneys (AttorneyID,Gender,Name) VALUES (1,'Female','Sarah Johnson'),(2,'Male','Daniel Lee'),(3,'Non-binary','Jamie Taylor'); | SELECT COUNT(*) FROM Attorneys WHERE Gender = 'Male'; |
Which volunteers have contributed the most hours to a specific program, and what is the total number of hours they have contributed? | CREATE TABLE VolunteerHours (VolunteerID INT,VolunteerName TEXT,Program TEXT,Hours DECIMAL(5,2)); INSERT INTO VolunteerHours (VolunteerID,VolunteerName,Program,Hours) VALUES (1,'Alice','ProgramA',25.00),(2,'Bob','ProgramB',30.00),(3,'Charlie','ProgramA',40.00); | SELECT VolunteerName, Program, SUM(Hours) AS TotalHours FROM VolunteerHours GROUP BY VolunteerName, Program ORDER BY TotalHours DESC; |
What is the average donation amount per donor for the 'Refugee Support' program in '2022'? | CREATE TABLE refugee_donors_2022 (id INT,donor_name TEXT,program TEXT,donation_amount DECIMAL); INSERT INTO refugee_donors_2022 (id,donor_name,program,donation_amount) VALUES (1,'Karen','Refugee Support',75.00); INSERT INTO refugee_donors_2022 (id,donor_name,program,donation_amount) VALUES (2,'Liam','Refugee Support',1... | SELECT AVG(donation_amount) FROM refugee_donors_2022 WHERE program = 'Refugee Support' AND YEAR(donation_date) = 2022; |
What is the sum of 'total_emissions' for 'gas' in the 'emissions' table? | CREATE TABLE emissions(id INT,resource_type VARCHAR(255),total_emissions INT); INSERT INTO emissions(id,resource_type,total_emissions) VALUES ('1','gas',200000); | SELECT SUM(total_emissions) FROM emissions WHERE resource_type = 'gas'; |
What is the average calorie count for all entrées in the menu table? | CREATE TABLE menu (id INT,name TEXT,category TEXT,calories INT); INSERT INTO menu (id,name,category,calories) VALUES (1,'Chicken Alfredo','Entrée',1200); INSERT INTO menu (id,name,category,calories) VALUES (2,'Veggie Lasagna','Entrée',800); | SELECT AVG(calories) FROM menu WHERE category = 'Entrée'; |
Update a record with community health statistic for a specific community type | CREATE TABLE community_health_statistics_v2 (id INT,community_type VARCHAR(20),statistic_value INT); | UPDATE community_health_statistics_v2 SET statistic_value = 110 WHERE community_type = 'Urban'; |
How many art pieces were created by artists from underrepresented communities in the last decade? | CREATE TABLE art_pieces_identity (id INT,year INT,artist_name VARCHAR(50),art_type VARCHAR(50),underrepresented_community VARCHAR(50)); | SELECT COUNT(*) as total_art_pieces FROM art_pieces_identity WHERE year >= 2012 AND underrepresented_community IS NOT NULL; |
What are the total sales and average sales per transaction for organic skincare products in the United States? | CREATE TABLE skincare_sales (product_type VARCHAR(20),sale_date DATE,sales_quantity INT,unit_price DECIMAL(5,2)); INSERT INTO skincare_sales (product_type,sale_date,sales_quantity,unit_price) VALUES ('Organic','2022-01-01',50,25.99),('Conventional','2022-01-01',75,18.99); | SELECT SUM(sales_quantity * unit_price) AS total_sales, AVG(sales_quantity) AS avg_sales_per_transaction FROM skincare_sales WHERE product_type = 'Organic' AND sale_date BETWEEN '2022-01-01' AND '2022-12-31'; |
What's the average number of retweets on posts by users from Japan in the food category? | CREATE TABLE users (id INT,country VARCHAR(255),category VARCHAR(255)); INSERT INTO users (id,country,category) VALUES (1,'Japan','food'); CREATE TABLE posts (id INT,user_id INT,retweets INT); | SELECT AVG(posts.retweets) FROM posts INNER JOIN users ON posts.user_id = users.id WHERE users.country = 'Japan' AND users.category = 'food'; |
What is the number of employees by gender in each mining operation in the 'mining_operations' and 'employee_demographics' tables? | CREATE TABLE mining_operations (operation_id INT,name VARCHAR(50)); INSERT INTO mining_operations (operation_id,name) VALUES (1,'Operation A'); INSERT INTO mining_operations (operation_id,name) VALUES (2,'Operation B'); CREATE TABLE employee_demographics (employee_id INT,operation_id INT,gender VARCHAR(10)); INSERT INT... | SELECT mining_operations.name, employee_demographics.gender, COUNT(*) FROM mining_operations INNER JOIN employee_demographics ON mining_operations.operation_id = employee_demographics.operation_id GROUP BY mining_operations.name, employee_demographics.gender; |
What is the average lead time for orders placed in the UK and shipped from Italy? | CREATE TABLE Orders (order_id INT,order_date DATE,order_lead_time INT,order_country VARCHAR(50),order_shipped_from VARCHAR(50)); | SELECT AVG(order_lead_time) AS avg_lead_time FROM Orders WHERE order_country = 'UK' AND order_shipped_from = 'Italy'; |
Which defense projects had delays of more than 30 days in the last 12 months? | CREATE TABLE defense_projects (id INT,project_name VARCHAR(50),start_date DATE,end_date DATE,status VARCHAR(20)); | SELECT project_name, DATEDIFF(end_date, start_date) as delay_days FROM defense_projects WHERE end_date > DATEADD(day, 30, start_date) AND start_date >= DATEADD(year, -1, GETDATE()); |
What is the average quantity of recyclable products sold by vendors from South America? | CREATE TABLE vendors(vendor_id INT,vendor_name TEXT,country TEXT); INSERT INTO vendors(vendor_id,vendor_name,country) VALUES (1,'VendorA','Brazil'),(2,'VendorB','Argentina'),(3,'VendorC','Colombia'); CREATE TABLE products(product_id INT,product_name TEXT,recyclable BOOLEAN,quantity_sold INT); INSERT INTO products(produ... | SELECT AVG(products.quantity_sold) FROM products JOIN vendors ON products.vendor_id = vendors.vendor_id WHERE vendors.country = 'South America' AND products.recyclable = TRUE; |
Delete transactions with amounts greater than 500 for clients living in 'Tokyo'. | CREATE TABLE clients (id INT,name TEXT,city TEXT); CREATE TABLE transactions (client_id INT,amount DECIMAL(10,2),transaction_time TIMESTAMP); INSERT INTO clients (id,name,city) VALUES (1,'Gina','Tokyo'),(2,'Hal','Tokyo'); INSERT INTO transactions (client_id,amount,transaction_time) VALUES (1,600.00,'2022-01-05 11:00:00... | DELETE FROM transactions WHERE (client_id, amount) IN (SELECT transactions.client_id, transactions.amount FROM clients JOIN transactions ON clients.id = transactions.client_id WHERE clients.city = 'Tokyo' AND transactions.amount > 500); |
Which humanitarian aid operations were conducted in Yemen? | CREATE TABLE Humanitarian_Aid (Aid_ID INT PRIMARY KEY,Aid_Name VARCHAR(255),Recipient VARCHAR(255),Amount DECIMAL(10,2),Date_Provided DATE,Location VARCHAR(255)); INSERT INTO Humanitarian_Aid (Aid_ID,Aid_Name,Recipient,Amount,Date_Provided,Location) VALUES (1,'Operation Allies Welcome','Afghanistan',780000000,'2021-08-... | SELECT Aid_Name FROM Humanitarian_Aid WHERE Location = 'Yemen'; |
Update the first_name of policyholder with policy_holder_id 333 in the 'policy_holder' table to 'Jane'. | CREATE TABLE policy_holder (policy_holder_id INT,first_name VARCHAR(20),last_name VARCHAR(20),address VARCHAR(50)); | UPDATE policy_holder SET first_name = 'Jane' WHERE policy_holder_id = 333; |
How many organic cotton garments were sold in the EU region in the summer season? | CREATE TABLE garments (id INT,material VARCHAR(20),region VARCHAR(20)); INSERT INTO garments (id,material,region) VALUES (1,'organic cotton','EU'); -- additional rows removed for brevity; | SELECT COUNT(*) FROM garments WHERE material = 'organic cotton' AND region = 'EU' AND season = 'summer'; |
What is the maximum number of passengers for a single autonomous shuttle ride? | CREATE TABLE autonomous_shuttles (shuttle_id INT,ride_id INT,start_time TIMESTAMP,end_time TIMESTAMP,passengers INT); | SELECT MAX(passengers) FROM autonomous_shuttles; |
What is the total donation amount in the 'Donations' table for each day in June 2022? | CREATE TABLE Donations (DonationID INT,DonorID INT,DonationAmount DECIMAL(10,2),DonationDate DATE); | SELECT DATE_FORMAT(DonationDate, '%Y-%m-%d') AS DonationDay, SUM(DonationAmount) FROM Donations WHERE YEAR(DonationDate) = 2022 AND MONTH(DonationDate) = 6 GROUP BY DonationDay; |
What is the total budget for criminal justice reform programs in each state? | CREATE TABLE criminal_justice_reform_programs (program_id INT,state TEXT,budget INT); INSERT INTO criminal_justice_reform_programs VALUES (1,'California',5000000),(2,'Texas',4000000),(3,'New York',6000000); | SELECT state, SUM(budget) FROM criminal_justice_reform_programs GROUP BY state; |
Compute the average score-price for each regulator in the Midwest and their associated producers' prices, using a full outer join. | CREATE TABLE regulators (id INT PRIMARY KEY,name TEXT,region TEXT,compliance_score INT); INSERT INTO regulators (id,name,region,compliance_score) VALUES (1,'Midwest Marijuana Enforcement','Midwest',90); CREATE TABLE producers (id INT PRIMARY KEY,name TEXT,region TEXT,product TEXT,quantity INT,price FLOAT); INSERT INTO ... | SELECT producers.name, regulators.name, AVG(producers.price * regulators.compliance_score) as avg_score_price FROM producers FULL OUTER JOIN regulators ON producers.region = regulators.region GROUP BY producers.name, regulators.name; |
What is the average labor productivity by mine site? | CREATE TABLE mine_site (site_id INT,location VARCHAR(255),labor_force INT,productivity FLOAT); INSERT INTO mine_site (site_id,location,labor_force,productivity) VALUES (1,'Site A',50,12.5),(2,'Site B',75,15.0),(3,'Site C',60,13.3); | SELECT AVG(productivity) FROM mine_site; |
How many vegetarian menu items have been added to the menu in the last month? | CREATE TABLE Menu (menu_id INT PRIMARY KEY,menu_item VARCHAR(50),menu_item_category VARCHAR(50),menu_add_date DATE); CREATE TABLE Menu_Categories (menu_category VARCHAR(50) PRIMARY KEY); INSERT INTO Menu_Categories (menu_category) VALUES ('vegetarian'); | SELECT COUNT(menu_id) FROM Menu WHERE menu_item_category = 'vegetarian' AND menu_add_date >= DATEADD(month, -1, GETDATE()); |
Find the top 3 mobile subscribers with the highest monthly data usage in each city. | CREATE TABLE subscribers(id INT,city VARCHAR(20),monthly_data_usage DECIMAL(5,2)); INSERT INTO subscribers(id,city,monthly_data_usage) VALUES (1,'New York',3.5),(2,'New York',4.2),(3,'New York',5.0),(4,'Los Angeles',3.0),(5,'Los Angeles',3.5),(6,'Los Angeles',4.0); | SELECT city, id, monthly_data_usage FROM (SELECT city, id, monthly_data_usage, RANK() OVER(PARTITION BY city ORDER BY monthly_data_usage DESC) AS rank FROM subscribers) t WHERE rank <= 3; |
What is the maximum engagement time for virtual tours of hotels in Asia? | CREATE TABLE virtual_tours (tour_id INT,hotel_id INT,country TEXT,engagement_time INT); INSERT INTO virtual_tours (tour_id,hotel_id,country,engagement_time) VALUES (1,1,'China',30),(2,2,'Japan',60),(3,3,'India',90); | SELECT MAX(engagement_time) FROM virtual_tours WHERE country = 'Asia'; |
What is the maximum cost of resilience projects in the infrastructure database? | CREATE TABLE Infrastructure_Projects (Project_ID INT,Project_Name VARCHAR(50),Project_Type VARCHAR(50),Cost FLOAT); INSERT INTO Infrastructure_Projects (Project_ID,Project_Name,Project_Type,Cost) VALUES (1,'Seawall','Resilience',7000000.00),(2,'Floodgate','Resilience',3500000.00),(3,'Bridge_Replacement','Transportation... | SELECT MAX(Cost) FROM Infrastructure_Projects WHERE Project_Type = 'Resilience'; |
How many volunteers have joined each year? | CREATE TABLE volunteer_history (id INT,volunteer_id INT,year INT,num_hours INT); INSERT INTO volunteer_history (id,volunteer_id,year,num_hours) VALUES (1,1,2019,100),(2,1,2020,150),(3,2,2019,75),(4,2,2020,200),(5,3,2019,125),(6,3,2020,175); | SELECT year, COUNT(DISTINCT volunteer_id) as num_volunteers FROM volunteer_history GROUP BY year; |
What is the average price of vegetarian meals across all restaurants? | CREATE TABLE meals (id INT,name TEXT,vegetarian BOOLEAN,price INT); INSERT INTO meals (id,name,vegetarian,price) VALUES (1,'Filet Mignon',false,35),(2,'Chicken Caesar',false,15),(3,'Tofu Stir Fry',true,25); | SELECT AVG(meals.price) FROM meals WHERE meals.vegetarian = true; |
What is the total number of climate change adaptation projects in Africa funded by international organizations? | CREATE TABLE AdaptationProjects (Id INT,Name VARCHAR(50),Funded BOOLEAN,FundingOrganization VARCHAR(50),FundingDate DATE,Location VARCHAR(20)); | SELECT COUNT(*) FROM AdaptationProjects WHERE Funded = TRUE AND FundingOrganization NOT LIKE 'Africa%' AND Location = 'Africa'; |
What is the total number of successful and unsuccessful missions in each region? | CREATE TABLE missions (mission_id INT,region VARCHAR(50),mission_status VARCHAR(10)); INSERT INTO missions (mission_id,region,mission_status) VALUES (1,'Region A','successful'),(2,'Region A','unsuccessful'),(3,'Region B','successful'),(4,'Region C','unsuccessful'),(5,'Region A','successful'),(6,'Region B','unsuccessful... | SELECT r.name, SUM(CASE WHEN m.mission_status = 'successful' THEN 1 ELSE 0 END) AS num_successful, SUM(CASE WHEN m.mission_status = 'unsuccessful' THEN 1 ELSE 0 END) AS num_unsuccessful FROM missions m JOIN regions r ON m.region = r.name GROUP BY r.name |
Which cities have volunteers who have contributed more than 150 hours? | CREATE TABLE Volunteers (VolunteerID INT PRIMARY KEY,VolunteerName VARCHAR(50),VolunteerHours INT,VolunteerCity VARCHAR(30)); INSERT INTO Volunteers (VolunteerID,VolunteerName,VolunteerHours,VolunteerCity) VALUES (13,'Sophia Lee',200,'Seoul'),(14,'David Kim',180,'Seoul'),(15,'Emily Park',120,'Tokyo'),(16,'Daniel Lee',2... | SELECT VolunteerCity, SUM(VolunteerHours) FROM Volunteers GROUP BY VolunteerCity HAVING SUM(VolunteerHours) > 150; |
Find the average ticket price for each division in the ticket_sales table. | CREATE TABLE ticket_sales (ticket_id INT,game_id INT,home_team VARCHAR(20),away_team VARCHAR(20),price DECIMAL(5,2),quantity INT,division VARCHAR(20)); | SELECT division, AVG(price) as avg_ticket_price FROM ticket_sales GROUP BY division; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.