instruction stringlengths 0 1.06k | input stringlengths 11 5.3k | response stringlengths 2 4.44k |
|---|---|---|
What is the total quantity of locally sourced ingredients used in our Asian operations? | CREATE TABLE ingredients (id INT,name VARCHAR(255),origin VARCHAR(255),quantity INT); INSERT INTO ingredients (id,name,origin,quantity) VALUES (1,'Rice','Thailand',1000),(2,'Soy Sauce','China',500); | SELECT SUM(quantity) FROM ingredients WHERE origin LIKE 'Asia%'; |
Delete the 'FitnessTests' table and all its records. | CREATE TABLE FitnessTests (TestID INT,PlayerID INT,TestDate DATE,TestScore INT); | DROP TABLE FitnessTests; |
Insert new records for electric cars produced in 2022 in the cars table. | cars (id,make,model,year,fuel_type) | INSERT INTO cars (make, model, year, fuel_type) VALUES ('Tesla', 'Model S', 2022, 'electric'), ('Nissan', 'Leaf', 2022, 'electric'), ('Chevrolet', 'Bolt', 2022, 'electric'); |
Update the donation amount to $100 for the user 'Jane' in the Donations table. | CREATE TABLE Donations (id INT,user VARCHAR(255),amount DECIMAL(10,2)); INSERT INTO Donations (id,user,amount) VALUES (1,'John',50.00),(2,'Jane',75.00); | UPDATE Donations SET amount = 100.00 WHERE user = 'Jane'; |
Which organization received the most donations in Q3 2019? | CREATE TABLE Organizations (OrgID INT,OrgName TEXT,TotalDonation DECIMAL); INSERT INTO Organizations (OrgID,OrgName,TotalDonation) VALUES (1,'ABC Nonprofit',10000.00),(2,'XYZ Foundation',15000.00); | SELECT OrgName, MAX(TotalDonation) as MaxDonation FROM Organizations WHERE QUARTER(DonationDate) = 3 AND YEAR(DonationDate) = 2019 GROUP BY OrgName; |
What is the average impact of projects involving machine learning? | CREATE TABLE social_tech (id INT,project VARCHAR(50),technology VARCHAR(50),description TEXT,impact FLOAT,organization VARCHAR(50)); INSERT INTO social_tech (id,project,technology,description,impact,organization) VALUES (2,'ML for Climate Change','Machine Learning','A project using ML to predict climate change patterns.',0.75,'ClimateCare'); | SELECT technology, AVG(impact) as avg_impact FROM social_tech WHERE description LIKE '%Machine Learning%' GROUP BY technology; |
What are the top 3 states with the highest mobile data usage? | CREATE TABLE mobile_customers (customer_id INT,name VARCHAR(50),data_usage FLOAT,state VARCHAR(20)); INSERT INTO mobile_customers (customer_id,name,data_usage,state) VALUES (1,'John Doe',3.5,'New York'); | SELECT state, SUM(data_usage) as total_data_usage FROM mobile_customers GROUP BY state ORDER BY total_data_usage DESC LIMIT 3; |
Find the number of cruelty-free products for each brand | CREATE TABLE product (id INT,name TEXT,brand TEXT,cruelty_free BOOLEAN); | SELECT brand, COUNT(*) FROM product WHERE cruelty_free = TRUE GROUP BY brand; |
What is the total duration of all exhibitions in the 'Minimalism' genre, in hours? | CREATE TABLE Exhibition (exhibition_id INT,exhibition_name VARCHAR(30),genre VARCHAR(20),duration INT); | SELECT SUM(Exhibition.duration / 60) FROM Exhibition WHERE Exhibition.genre = 'Minimalism'; |
Which sustainable materials are most commonly used by each producer in the 'producer_materials' table? | CREATE TABLE producer_materials (id INT,producer VARCHAR(20),material VARCHAR(20),usage INT); INSERT INTO producer_materials (id,producer,material,usage) VALUES (1,'EcoFabrics','cotton',7000),(2,'GreenYarn','wool',4000),(3,'EcoFabrics','polyester',6000),(4,'GreenYarn','cotton',3000),(5,'SustainaFiber','silk',5000); | SELECT producer, material, SUM(usage) AS total_usage FROM producer_materials GROUP BY producer, material ORDER BY total_usage DESC; |
How many visitors attended events in New York between 2018 and 2019? | CREATE TABLE Events (id INT,name VARCHAR(50),location VARCHAR(50),date DATE,attendance INT); INSERT INTO Events (id,name,location,date,attendance) VALUES (1,'Art Show','New York','2018-01-01',100); | SELECT SUM(attendance) FROM Events WHERE location = 'New York' AND date BETWEEN '2018-01-01' AND '2019-12-31'; |
What is the total funding amount received by biotech startups in 'Boston' from the 'startup_funding' database? | CREATE TABLE startup_funding (id INT,startup_name VARCHAR(50),city VARCHAR(50),funding_year INT,amount FLOAT); INSERT INTO startup_funding (id,startup_name,city,funding_year,amount) VALUES (1,'GreenGen','Seattle',2021,3000000),(2,'BioSolutions','Austin',2022,4000000),(3,'NeuroTech','Boston',2022,5000000); | SELECT SUM(amount) FROM startup_funding WHERE city = 'Boston'; |
How many marine research projects were conducted in the Atlantic Ocean by each organization? | CREATE TABLE AtlanticProjects (organization TEXT,project_name TEXT); INSERT INTO AtlanticProjects (organization,project_name) VALUES ('National Oceanic and Atmospheric Administration','Atlantic Currents'),('UNESCO','Marine Life Protection'),('Greenpeace','Atlantic Plastic Reduction'); CREATE TABLE Organizations (organization TEXT,research_count INTEGER); INSERT INTO Organizations (organization,research_count) VALUES ('National Oceanic and Atmospheric Administration',12),('UNESCO',17),('Greenpeace',15); | SELECT Organizations.organization, Organizations.research_count FROM Organizations INNER JOIN AtlanticProjects ON Organizations.organization = AtlanticProjects.organization WHERE AtlanticProjects.project_name LIKE '%Atlantic%'; |
What is the maximum price of dysprosium produced in any country for the year 2017? | CREATE TABLE DysprosiumProduction (country VARCHAR(20),year INT,price DECIMAL(5,2)); INSERT INTO DysprosiumProduction (country,year,price) VALUES ('CountryA',2017,110.00),('CountryB',2017,120.00); | SELECT MAX(price) FROM DysprosiumProduction WHERE year = 2017; |
Calculate the average playtime and total revenue for each genre of music | CREATE TABLE Genre (id INT,genre VARCHAR(255)); CREATE TABLE Song (id INT,genre_id INT,title VARCHAR(255),playtime INT); CREATE TABLE Sales (id INT,genre_id INT,year INT,revenue INT); | SELECT G.genre, AVG(S.playtime) as avg_playtime, SUM(S.revenue) as total_revenue FROM Genre G INNER JOIN Song S ON G.id = S.genre_id INNER JOIN Sales SL ON G.id = SL.genre_id GROUP BY G.genre; |
Show the total expenses for the last financial quarter | CREATE TABLE financial_quarters (id INT,quarter INT,year INT); INSERT INTO financial_quarters (id,quarter,year) VALUES (1,1,2021),(2,2,2021),(3,3,2021),(4,4,2021); CREATE TABLE expenses (id INT,financial_quarter_id INT,amount DECIMAL(10,2)); | SELECT SUM(e.amount) as total_expenses FROM expenses e JOIN financial_quarters fq ON e.financial_quarter_id = fq.id WHERE fq.quarter = (SELECT MAX(quarter) FROM financial_quarters WHERE year = (SELECT MAX(year) FROM financial_quarters)) GROUP BY fq.quarter; |
List all the makeup products with potentially harmful ingredients sold in Canada. | CREATE TABLE MakeupProducts (productID INT,productName VARCHAR(50),category VARCHAR(50),country VARCHAR(50),harmfulIngredient BOOLEAN); INSERT INTO MakeupProducts (productID,productName,category,country,harmfulIngredient) VALUES (1,'Liquid Lipstick','Makeup','Canada',TRUE); | SELECT * FROM MakeupProducts WHERE country = 'Canada' AND harmfulIngredient = TRUE; |
Delete all records from the 'sustainable_sourcing' table where the 'supplier_country' is 'USA' | CREATE TABLE sustainable_sourcing (supplier_name TEXT,supplier_country TEXT,sustainable_practices BOOLEAN); | DELETE FROM sustainable_sourcing WHERE supplier_country = 'USA'; |
What is the minimum dissolved oxygen level for fish farms in the 'Indian Ocean' region? | CREATE TABLE fish_farms (id INT,name TEXT,region TEXT); INSERT INTO fish_farms (id,name,region) VALUES (1,'Farm A','Indian Ocean'),(2,'Farm B','Atlantic Ocean'); CREATE TABLE readings (id INT,farm_id INT,dissolved_oxygen FLOAT); INSERT INTO readings (id,farm_id,dissolved_oxygen) VALUES (1,1,6.1),(2,1,6.3),(3,2,5.8); | SELECT MIN(readings.dissolved_oxygen) FROM readings INNER JOIN fish_farms ON readings.farm_id = fish_farms.id WHERE fish_farms.region = 'Indian Ocean'; |
List the Solar Power Plants in Spain with their installed capacity | CREATE TABLE solar_plants (id INT,name VARCHAR(100),country VARCHAR(50),capacity_mw FLOAT); INSERT INTO solar_plants (id,name,country,capacity_mw) VALUES (1,'Solar Plant 1','Spain',30.0),(2,'Solar Plant 2','Spain',45.0); | SELECT name, capacity_mw FROM solar_plants WHERE country = 'Spain'; |
What is the maximum number of accessible technology initiatives in a region? | CREATE TABLE accessible_technology_initiatives (id INT,initiative_name VARCHAR(50),region VARCHAR(50)); INSERT INTO accessible_technology_initiatives (id,initiative_name,region) VALUES (1,'Accessible Software Distribution','Asia'),(2,'Hardware Adaptation for Persons with Disabilities','Europe'),(3,'Inclusive Technology Education','Africa'),(4,'Assistive Technology Research','North America'); | SELECT region, COUNT(*) as initiative_count FROM accessible_technology_initiatives GROUP BY region ORDER BY initiative_count DESC LIMIT 1; |
List all countries with deep-sea exploration projects and their respective funding amounts. | CREATE TABLE deep_sea_exploration (project_id INT,country VARCHAR(50),funding_amount FLOAT); INSERT INTO deep_sea_exploration (project_id,country,funding_amount) VALUES (1,'Canada',15000000.0),(2,'Japan',20000000.0),(3,'USA',30000000.0); | SELECT country, funding_amount FROM deep_sea_exploration; |
Which suppliers have not been updated in the last 6 months and supply components for workforce development programs? | CREATE TABLE suppliers (name TEXT,last_update DATE,component_type TEXT); INSERT INTO suppliers (name,last_update,component_type) VALUES ('Smith Components','2021-01-01','Safety Equipment'),('Jones Parts','2022-03-15','Training Materials'); | SELECT name FROM suppliers WHERE last_update < DATE('now', '-6 month') AND component_type = 'Workforce Development'; |
What is the total number of ethical AI research papers published in Australia, India, and Argentina, in the year 2021? | CREATE TABLE ea_research_australia(paper_id INT,country VARCHAR(10),publish_year INT); INSERT INTO ea_research_australia VALUES (1,'Australia',2021),(2,'Australia',2020); CREATE TABLE ea_research_india(paper_id INT,country VARCHAR(10),publish_year INT); INSERT INTO ea_research_india VALUES (1,'India',2021),(2,'India',2020); CREATE TABLE ea_research_argentina(paper_id INT,country VARCHAR(10),publish_year INT); INSERT INTO ea_research_argentina VALUES (1,'Argentina',2021),(2,'Argentina',2020); | SELECT SUM(publish_year = 2021) FROM ea_research_australia WHERE country = 'Australia' UNION ALL SELECT SUM(publish_year = 2021) FROM ea_research_india WHERE country = 'India' UNION ALL SELECT SUM(publish_year = 2021) FROM ea_research_argentina WHERE country = 'Argentina'; |
Insert a new record into the "investment_rounds" table with the following data: "Series A", 2021, 5000000, "Venture Capital" | CREATE TABLE investment_rounds (round_name VARCHAR(50),investment_year INT,investment_amount INT,investment_type VARCHAR(50)); | INSERT INTO investment_rounds (round_name, investment_year, investment_amount, investment_type) VALUES ('Series A', 2021, 5000000, 'Venture Capital'); |
Insert new records into the "humanitarian_aid" table for the following disaster_id, country_name, aid_amount, and aid_date values: (301, 'Bangladesh', 50000, '2021-12-25'), (302, 'Pakistan', 75000, '2021-12-27'), and (303, 'Nepal', 60000, '2021-12-30') | CREATE TABLE humanitarian_aid (disaster_id INT,country_name VARCHAR(50),aid_amount INT,aid_date DATE); | INSERT INTO humanitarian_aid (disaster_id, country_name, aid_amount, aid_date) VALUES (301, 'Bangladesh', 50000, '2021-12-25'), (302, 'Pakistan', 75000, '2021-12-27'), (303, 'Nepal', 60000, '2021-12-30'); |
Count the number of patents filed by companies in the 'Healthcare' domain | CREATE TABLE patents (id INT,company_name VARCHAR(30),patent_count INT,company_domain VARCHAR(20)); INSERT INTO patents (id,company_name,patent_count,company_domain) VALUES (1,'CompanyE',2,'Healthcare'); INSERT INTO patents (id,company_name,patent_count,company_domain) VALUES (2,'CompanyF',0,'Finance'); | SELECT SUM(patent_count) FROM patents WHERE company_domain = 'Healthcare'; |
What is the difference in average temperature between field_1 and field_3? | CREATE TABLE field_1 (date DATE,temperature FLOAT); INSERT INTO field_1 (date,temperature) VALUES ('2022-01-01',15.0),('2022-01-02',14.5); CREATE TABLE field_3 (date DATE,temperature FLOAT); INSERT INTO field_3 (date,temperature) VALUES ('2022-01-01',14.0),('2022-01-02',13.5); | SELECT AVG(field_1.temperature) - AVG(field_3.temperature) FROM field_1, field_3 WHERE field_1.date = field_3.date AND field_1.date IN ('2022-01-01', '2022-01-02'); |
Show the number of food safety inspections for each restaurant in 'Eastside'? | CREATE TABLE inspections (inspection_id INT,restaurant_id INT,violation_score INT,inspection_date DATE); INSERT INTO inspections (inspection_id,restaurant_id,violation_score,inspection_date) VALUES (1,1,85,'2022-01-01'),(2,1,90,'2022-02-01'),(3,2,70,'2022-01-01'),(4,3,80,'2022-02-01'); CREATE TABLE restaurants (restaurant_id INT,name VARCHAR(255),area VARCHAR(255)); INSERT INTO restaurants (restaurant_id,name,area) VALUES (1,'Gourmet Delight','Eastside'),(2,'Spicy Express','Eastside'),(3,'Pho King','Westside'); | SELECT r.name, COUNT(i.inspection_id) AS number_of_inspections FROM inspections i JOIN restaurants r ON i.restaurant_id = r.restaurant_id WHERE r.area = 'Eastside' GROUP BY r.name; |
Which suppliers are located in Canada and have a sustainability rating of 4 or higher? | CREATE TABLE Suppliers (id INT PRIMARY KEY,supplier_name VARCHAR(255),country VARCHAR(100),sustainability_rating INT); INSERT INTO Suppliers (id,supplier_name,country,sustainability_rating) VALUES (1,'Green Farms','Canada',4),(2,'Tropical Fruits','Brazil',3),(3,'Ocean Harvest','Norway',5); | SELECT supplier_name FROM Suppliers WHERE country = 'Canada' AND sustainability_rating >= 4; |
Delete the record of DonorB from the Donors table | CREATE TABLE Donors (DonorID INT,DonorName TEXT,Country TEXT,Amount DECIMAL(10,2)); INSERT INTO Donors (DonorID,DonorName,Country,Amount) VALUES (1,'DonorA','USA',1500.00),(2,'DonorB','Canada',2000.00); | DELETE FROM Donors WHERE DonorName = 'DonorB'; |
Who is the faculty advisor for the graduate student with student_id 20? | CREATE TABLE students (student_id INT,first_name TEXT,last_name TEXT); INSERT INTO students (student_id,first_name,last_name) VALUES (10,'John','Doe'),(20,'Jane','Smith'),(30,'Mary','Johnson'),(40,'David','Williams'); CREATE TABLE faculty_advisors (advisor_id INT,faculty_name TEXT,student_id INT); INSERT INTO faculty_advisors (advisor_id,faculty_name,student_id) VALUES (1,'John Doe',10),(2,'Jane Smith',20),(3,'Mary Johnson',30),(4,'David Williams',40); | SELECT faculty_advisors.faculty_name FROM faculty_advisors WHERE faculty_advisors.student_id = 20; |
What is the percentage of cultural competency training completed by community health workers? | CREATE TABLE training (worker_id INT,training_type VARCHAR(50),completion_percentage INT); INSERT INTO training (worker_id,training_type,completion_percentage) VALUES (1,'Cultural Competency',85),(2,'Cultural Competency',90),(3,'Cultural Competency',95); | SELECT worker_id, training_type, completion_percentage, completion_percentage * 100.0 / SUM(completion_percentage) OVER (PARTITION BY training_type) as percentage FROM training WHERE training_type = 'Cultural Competency'; |
How many military technology patents were filed in 2020 by country? | CREATE TABLE MilitaryPatents (Id INT,Country VARCHAR(50),Patent VARCHAR(50),Year INT); INSERT INTO MilitaryPatents (Id,Country,Patent,Year) VALUES (1,'USA','Laser Communication',2020); INSERT INTO MilitaryPatents (Id,Country,Patent,Year) VALUES (2,'China','Drone Swarm',2020); | SELECT COUNT(*), Country FROM MilitaryPatents WHERE Year = 2020 GROUP BY Country; |
Update the "geological_survey" table to set the "survey_date" to '2022-04-15' for all records where the "mine_name" is 'Sapphire Summit' | CREATE TABLE geological_survey (survey_id INT PRIMARY KEY,mine_name VARCHAR(20),mineral_type VARCHAR(20),survey_date DATE); INSERT INTO geological_survey (survey_id,mine_name,mineral_type,survey_date) VALUES (1,'Sapphire Summit','Sapphire','2022-03-15'),(2,'Emerald Exploration','Emerald','2022-03-20'),(3,'Sapphire Summit','Sapphire','2022-03-27'); | UPDATE geological_survey SET survey_date = '2022-04-15' WHERE mine_name = 'Sapphire Summit'; |
Which brands offer the most sustainable products? | CREATE TABLE products (product_id INT,product_name TEXT,brand_id INT,sustainable_product BOOLEAN); INSERT INTO products (product_id,product_name,brand_id,sustainable_product) VALUES (1,'Organic Cotton Shirt',1,TRUE),(2,'Polyester Jacket',1,FALSE),(3,'Hemp T-Shirt',2,TRUE),(4,'Viscose Dress',2,FALSE); | SELECT brands.brand_name, COUNT(*) as sustainable_product_count FROM products JOIN brands ON products.brand_id = brands.brand_id WHERE products.sustainable_product = TRUE GROUP BY brands.brand_name ORDER BY sustainable_product_count DESC; |
List the artworks created in the Baroque period with a value greater than $100k. | CREATE TABLE ArtWorks (ArtworkID int,Title varchar(100),Value int,Period varchar(100)); | SELECT Title, Value FROM ArtWorks |
What is the total amount donated by each donor in H2 2022? | CREATE TABLE donations (donor_id INT,organization_id INT,amount DECIMAL(10,2),donation_date DATE); INSERT INTO donations (donor_id,organization_id,amount,donation_date) VALUES (1,101,500.00,'2022-10-01'),(2,102,350.00,'2022-11-05'),(3,101,200.00,'2022-12-25'),(1,103,400.00,'2022-11-12'); | SELECT donor_id, SUM(amount) as total_donation FROM donations WHERE donation_date BETWEEN '2022-10-01' AND '2022-12-31' GROUP BY donor_id; |
Provide the average labor productivity for mining operations in the Western region. | CREATE TABLE labor_productivity_by_region (region VARCHAR(20),productivity FLOAT); INSERT INTO labor_productivity_by_region (region,productivity) VALUES ('West',3.2),('East',3.5),('North',3.0),('South',3.6); | SELECT AVG(productivity) FROM labor_productivity_by_region WHERE region = 'West'; |
Update the price of the 'Tofu Stir Fry' on the 'Vegan' menu to 16.50 | CREATE TABLE Menu (menu_name VARCHAR(20),item_name VARCHAR(30),price DECIMAL(5,2)); INSERT INTO Menu (menu_name,item_name,price) VALUES ('Vegan','Tofu Stir Fry',15.50); | UPDATE Menu SET price = 16.50 WHERE menu_name = 'Vegan' AND item_name = 'Tofu Stir Fry'; |
List of players who have played games on both PlayStation and Xbox platforms? | CREATE TABLE players (id INT,name VARCHAR(20)); INSERT INTO players (id,name) VALUES (1,'Alice'),(2,'Bob'),(3,'Charlie'); CREATE TABLE console_games (id INT,player_id INT,console VARCHAR(10),title VARCHAR(20)); INSERT INTO console_games (id,player_id,console,title) VALUES (1,1,'PlayStation','God of War'),(2,2,'Xbox','Halo'),(3,3,'PlayStation','Spider-Man'),(4,2,'PlayStation','The Last of Us'),(5,1,'Xbox','Gears of War'); | SELECT players.name FROM players INNER JOIN console_games AS ps_games ON players.id = ps_games.player_id INNER JOIN console_games AS xbox_games ON players.id = xbox_games.player_id WHERE ps_games.console = 'PlayStation' AND xbox_games.console = 'Xbox'; |
Delete health equity metrics for New Mexico in 2018 | CREATE TABLE health_equity_metrics (state VARCHAR(2),year INT,accessibility FLOAT,affordability FLOAT); | DELETE FROM health_equity_metrics WHERE state = 'NM' AND year = 2018; |
How many restaurants are there in each category? | CREATE TABLE restaurants (id INT,name TEXT,category TEXT); INSERT INTO restaurants (id,name,category) VALUES (1,'Restaurant A','organic'),(2,'Restaurant B','conventional'),(3,'Restaurant C','organic'),(4,'Restaurant D','conventional'),(5,'Restaurant E','organic'); | SELECT category, COUNT(category) FROM restaurants GROUP BY category; |
List all biosensor technology patents that were filed by companies from the UK or Germany. | 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','UK'),(2,'PatentB','Company2','DE'),(3,'PatentC','Company3','MX'); | SELECT * FROM biosensors.patents WHERE country IN ('UK', 'DE'); |
What is the average delivery time for reverse logistics shipments from the United Kingdom in Q4 2022? | CREATE TABLE ReverseLogistics (id INT,customer VARCHAR(255),delivery_time FLOAT,country VARCHAR(255),quarter INT,year INT); | SELECT AVG(delivery_time) FROM ReverseLogistics WHERE country = 'United Kingdom' AND quarter = 4 AND year = 2022; |
What is the number of HIV cases in South Africa? | CREATE TABLE HIV (Country TEXT,Cases INT); INSERT INTO HIV (Country,Cases) VALUES ('South Africa',10000),('South Africa',12000); | SELECT SUM(Cases) FROM HIV WHERE Country = 'South Africa'; |
What is the average contract amount for plumbing projects managed by contractors from California? | CREATE TABLE Contractors (Id INT,Name VARCHAR(50),LicenseNumber VARCHAR(50),City VARCHAR(50),State VARCHAR(2),Specialty VARCHAR(50)); CREATE TABLE ContractorProjects (ContractorId INT,ProjectId INT,ContractStartDate DATE,ContractEndDate DATE,ContractAmount DECIMAL(10,2)); CREATE TABLE Projects (Id INT,Name VARCHAR(50),City VARCHAR(50),StartDate DATE,EndDate DATE,Sustainable BOOLEAN); | SELECT AVG(cp.ContractAmount) FROM ContractorProjects cp JOIN Contractors c ON cp.ContractorId = c.Id JOIN Projects p ON cp.ProjectId = p.Id WHERE c.State = 'CA' AND c.LicenseNumber IS NOT NULL AND p.Specialty = 'Plumbing'; |
Number of complaints related to allergies for cosmetic products launched since 2020? | CREATE TABLE complaints_details (complaint_id INTEGER,product_name TEXT,complaint_type TEXT,launch_year INTEGER); INSERT INTO complaints_details (complaint_id,product_name,complaint_type,launch_year) VALUES (1,'ProductA','Allergy',2021),(2,'ProductB','Packaging',2020),(3,'ProductC','Allergy',2019); | SELECT COUNT(*) FROM complaints_details WHERE complaint_type = 'Allergy' AND launch_year >= 2020; |
What are the average calorie counts for meals served in each country? | CREATE TABLE Meals (MealID INT,MealName VARCHAR(50),Country VARCHAR(50),Calories INT); INSERT INTO Meals (MealID,MealName,Country,Calories) VALUES (1,'Spaghetti Bolognese','Italy',650),(2,'Chicken Tikka Masala','UK',850); | SELECT Country, AVG(Calories) as AvgCalories FROM Meals GROUP BY Country; |
Sum the total cargo weight handled by all vessels in Oceania over the past 3 months | CREATE TABLE VesselCargo (CargoID INT,VesselID INT,CargoWeight INT,LastHandled DATE,Region VARCHAR(50)); INSERT INTO VesselCargo (CargoID,VesselID,CargoWeight,LastHandled,Region) VALUES (1,1,50000,'2022-03-15','Oceania'),(2,2,70000,'2022-02-20','Oceania'),(3,3,60000,'2022-01-05','Oceania'); | SELECT SUM(CargoWeight) FROM VesselCargo WHERE Region = 'Oceania' AND LastHandled >= DATE_SUB(CURDATE(), INTERVAL 3 MONTH); |
What is the average market price of Neodymium produced in the US in 2020? | CREATE TABLE Neodymium_Production (id INT,year INT,country VARCHAR(255),quantity FLOAT,market_price FLOAT); | SELECT AVG(market_price) FROM Neodymium_Production WHERE year = 2020 AND country = 'USA'; |
What is the maximum carbon price (in USD/tonne) in California in 2020? | CREATE TABLE CarbonPrices (id INT,state VARCHAR(50),year INT,price FLOAT); INSERT INTO CarbonPrices (id,state,year,price) VALUES (1,'California',2020,17.45),(2,'California',2019,15.63),(3,'NewYork',2020,12.27); | SELECT MAX(price) FROM CarbonPrices WHERE state = 'California' AND year = 2020; |
How many biosensor technology development projects were completed in Asia in 2020? | CREATE TABLE biosensor_projects (id INT,project_name VARCHAR(50),completion_year INT,region VARCHAR(50)); INSERT INTO biosensor_projects (id,project_name,completion_year,region) VALUES (1,'Glucose Monitor',2018,'Europe'); INSERT INTO biosensor_projects (id,project_name,completion_year,region) VALUES (2,'Heart Rate Sensor',2019,'Africa'); INSERT INTO biosensor_projects (id,project_name,completion_year,region) VALUES (3,'Temperature Sensor',2020,'Asia'); | SELECT COUNT(*) FROM biosensor_projects WHERE completion_year = 2020 AND region = 'Asia'; |
Who are the attorneys who have never lost a case in the 'Civil' category? | CREATE TABLE Attorneys (AttorneyID INT,Name VARCHAR(50),Wins INT,Losses INT); INSERT INTO Attorneys (AttorneyID,Name,Wins,Losses) VALUES (1,'John Doe',10,0),(2,'Jane Smith',15,5); CREATE TABLE Cases (CaseID INT,AttorneyID INT,Category VARCHAR(50),Won INT); INSERT INTO Cases (CaseID,AttorneyID,Category,Won) VALUES (1,1,'Civil',1),(2,2,'Civil',0); | SELECT Name FROM Attorneys WHERE AttorneyID NOT IN (SELECT AttorneyID FROM Cases WHERE Category = 'Civil' AND Won = 0); |
Obtain the total defense contracts awarded to 'Global Defence Inc.' in 2020. | CREATE TABLE defense_contracts (id INT,contractor TEXT,award_date DATE,contract_value INT); INSERT INTO defense_contracts (id,contractor,award_date,contract_value) VALUES (1,'Global Defence Inc.','2020-01-01',1000000),(2,'Global Defence Inc.','2019-12-01',800000); | SELECT SUM(contract_value) FROM defense_contracts WHERE contractor = 'Global Defence Inc.' AND award_date >= '2020-01-01' AND award_date < '2021-01-01'; |
Delete community health worker records that have not been updated in the last 2 years. | CREATE TABLE community_health_workers (id INT,name TEXT,last_update DATE); INSERT INTO community_health_workers (id,name,last_update) VALUES (1,'Sophia Lee','2019-01-01'),(2,'Daniel Park','2020-01-01'); | DELETE FROM community_health_workers WHERE last_update < DATE_SUB(CURDATE(), INTERVAL 2 YEAR); |
Show the top 3 sustainable menu items by sales? | CREATE TABLE sales (sale_id INT,menu_item VARCHAR(255),revenue INT); INSERT INTO sales (sale_id,menu_item,revenue) VALUES (1,'Impossible Burger',500),(2,'Beyond Sausage',700),(3,'Local Greens Salad',600),(4,'Tofu Stir Fry',800),(5,'Chicken Caesar Salad',900); CREATE TABLE menu (menu_item VARCHAR(255),sourcing VARCHAR(255)); INSERT INTO menu (menu_item,sourcing) VALUES ('Impossible Burger','Sustainable'),('Beyond Sausage','Sustainable'),('Local Greens Salad','Sustainable'),('Tofu Stir Fry','Sustainable'),('Chicken Caesar Salad','Unsustainable'); | SELECT m.menu_item, SUM(s.revenue) AS total_sales FROM sales s JOIN menu m ON s.menu_item = m.menu_item WHERE m.sourcing = 'Sustainable' GROUP BY s.menu_item ORDER BY total_sales DESC LIMIT 3; |
What was the total value of military equipment sales by Contractor X in Q3 of 2021? | CREATE TABLE EquipmentSales (SaleID INT,Contractor VARCHAR(255),EquipmentType VARCHAR(255),Quantity INT,SalePrice DECIMAL(5,2)); INSERT INTO EquipmentSales (SaleID,Contractor,EquipmentType,Quantity,SalePrice) VALUES (1,'Contractor X','Tank',7,8000000); | SELECT Contractor, SUM(Quantity * SalePrice) FROM EquipmentSales WHERE Contractor = 'Contractor X' AND Quarter = 'Q3' AND Year = 2021 GROUP BY Contractor; |
List the countries with the highest contract negotiation duration, limited to the top 3? | CREATE TABLE ContractNegotiations (contract_id INT,country VARCHAR(255),negotiation_start_date DATE,negotiation_end_date DATE); INSERT INTO ContractNegotiations (contract_id,country,negotiation_start_date,negotiation_end_date) VALUES (1,'USA','2018-04-01','2018-06-15'),(2,'Canada','2019-02-10','2019-05-20'),(3,'UK','2018-08-25','2018-11-10'),(4,'Germany','2019-06-01','2019-07-15'),(5,'France','2018-12-01','2019-01-10'); | SELECT country, TIMESTAMPDIFF(DAY, negotiation_start_date, negotiation_end_date) AS NegotiationDuration FROM ContractNegotiations ORDER BY NegotiationDuration DESC LIMIT 3; |
What is the minimum humanitarian assistance provided by the European Union? | CREATE TABLE humanitarian_assistance (country VARCHAR(50),amount NUMERIC(10,2)); INSERT INTO humanitarian_assistance (country,amount) VALUES ('EU',80000000),('USA',50000000),('Germany',15000000),('UK',20000000),('France',22000000); | SELECT MIN(amount) FROM humanitarian_assistance WHERE country = 'EU'; |
What is the average age and ticket revenue for fans of each team? | CREATE TABLE fans (fan_id INT,team_id INT,age INT); INSERT INTO fans (fan_id,team_id,age) VALUES (1,1,35),(2,1,45),(3,2,25),(4,2,30); | SELECT t.team_name, AVG(f.age) as avg_age, SUM(ts.revenue) as avg_revenue FROM teams t JOIN fans f ON t.team_id = f.team_id JOIN ticket_sales ts ON t.team_id = ts.team_id GROUP BY t.team_name; |
What is the average transaction amount for customers from the United States? | CREATE TABLE customers (customer_id INT,name TEXT,country TEXT,transaction_amount DECIMAL); INSERT INTO customers (customer_id,name,country,transaction_amount) VALUES (1,'John Doe','USA',150.00),(2,'Jane Smith','Canada',200.00); | SELECT AVG(transaction_amount) FROM customers WHERE country = 'USA'; |
Which autonomous vehicle has the highest average speed in city driving? | CREATE TABLE avs (id INT,model VARCHAR(50),avg_speed_city FLOAT,avg_speed_highway FLOAT); INSERT INTO avs (id,model,avg_speed_city,avg_speed_highway) VALUES (1,'Wayve',32.5,55.0),(2,'NVIDIA Drive',35.0,58.0),(3,'Baidu Apollo',30.0,52.0); | SELECT model, MAX(avg_speed_city) FROM avs; |
What is the percentage of students passing the exam in each subject? | CREATE TABLE exam_results (student_id INT,subject VARCHAR(10),passed BOOLEAN); INSERT INTO exam_results (student_id,subject,passed) VALUES (1,'Math',TRUE),(1,'English',FALSE),(2,'Math',TRUE),(2,'English',TRUE),(3,'Math',FALSE),(3,'English',TRUE); | SELECT subject, COUNT(*) * 100.0 / (SELECT COUNT(*) FROM exam_results) as pass_percentage FROM exam_results WHERE passed = TRUE GROUP BY subject; |
How many patients in 'clinic_CA' have a primary diagnosis of 'Depression' or 'Anxiety'? | CREATE TABLE clinic_CA (patient_id INT,name VARCHAR(50),primary_diagnosis VARCHAR(50)); INSERT INTO clinic_CA (patient_id,name,primary_diagnosis) VALUES (1,'John Doe','Depression'),(2,'Jane Smith','Anxiety'),(3,'Alice Johnson','Bipolar Disorder'); | SELECT COUNT(*) FROM clinic_CA WHERE primary_diagnosis IN ('Depression', 'Anxiety'); |
What is the average transaction value (in USD) for the 'Binance' platform, and what is the standard deviation? | CREATE TABLE transactions (platform VARCHAR(255),tx_value DECIMAL(10,2),tx_date DATE); INSERT INTO transactions (platform,tx_value,tx_date) VALUES ('Binance',50.00,'2021-12-01'),('Binance',75.00,'2021-12-02'),('Ethereum',100.00,'2021-12-01'),('Solana',20.00,'2021-12-03'),('Binance',80.00,'2021-12-04'); | SELECT AVG(tx_value), STDDEV(tx_value) FROM transactions WHERE platform = 'Binance'; |
What is the average yield of crops grown in 'climate_zone_1'? | CREATE TABLE climate_zone_1 (crop_name TEXT,yield INTEGER); INSERT INTO climate_zone_1 (crop_name,yield) VALUES ('corn',120),('soybean',50),('wheat',80); | SELECT AVG(yield) FROM climate_zone_1; |
What is the average rating of hip-hop songs released in 2015? | CREATE TABLE Hip_Hop_Songs (title TEXT,year INTEGER,rating FLOAT); INSERT INTO Hip_Hop_Songs (title,year,rating) VALUES ('Song1',2013,7.5),('Song2',2014,8.0),('Song3',2015,8.5),('Song4',2016,9.0),('Song5',2017,9.2),('Song6',2018,9.5); | SELECT AVG(rating) FROM Hip_Hop_Songs WHERE year = 2015; |
Show the number of safety incidents for each vessel in the last 6 months | VESSEL(vessel_id,safety_record_id,last_inspection_date); SAFETY_INCIDENT(safety_record_id,incident_date) | SELECT v.vessel_id, COUNT(si.safety_record_id) AS num_of_incidents FROM VESSEL v JOIN SAFETY_INCIDENT si ON v.safety_record_id = si.safety_record_id WHERE si.incident_date BETWEEN DATEADD(month, -6, v.last_inspection_date) AND v.last_inspection_date GROUP BY v.vessel_id; |
What is the total number of aircraft manufactured by each company, and the most recent year of manufacturing? | CREATE TABLE AircraftManufacturers (Company VARCHAR(50),Model VARCHAR(50),Year INT); INSERT INTO AircraftManufacturers (Company,Model,Year) VALUES ('Boeing','747',1969),('Boeing','787 Dreamliner',2004),('Airbus','A320',1988),('Airbus','A380',2005); | SELECT Company, COUNT(*) as Total, MAX(Year) as LatestYear FROM AircraftManufacturers GROUP BY Company; |
Find the average claim amount for policies in the 'auto' category | CREATE TABLE policies (policy_id INT,category VARCHAR(10)); INSERT INTO policies (policy_id,category) VALUES (1,'auto'),(2,'home'),(3,'auto'); CREATE TABLE claims (claim_id INT,policy_id INT,amount DECIMAL(10,2)); INSERT INTO claims (claim_id,policy_id,amount) VALUES (1,1,500),(2,1,700),(3,2,300),(4,3,800),(5,3,900); | SELECT AVG(claims.amount) FROM claims INNER JOIN policies ON claims.policy_id = policies.policy_id WHERE policies.category = 'auto'; |
What is the total revenue from sustainable menu items last month? | CREATE TABLE menus (menu_id INT,menu_name VARCHAR(50),category VARCHAR(50),price DECIMAL(5,2),is_sustainable BOOLEAN); INSERT INTO menus (menu_id,menu_name,category,price,is_sustainable) VALUES (1,'Quinoa Salad','Vegetarian',9.99,true),(2,'Margherita Pizza','Non-Vegetarian',12.99,false),(3,'Chickpea Curry','Vegetarian',10.99,true),(4,'Tofu Stir Fry','Vegan',11.99,true),(5,'Steak','Non-Vegetarian',25.99,false); CREATE TABLE orders (order_id INT,order_date DATE,menu_id INT); INSERT INTO orders (order_id,order_date,menu_id) VALUES (1,'2022-05-01',1),(2,'2022-05-02',2),(3,'2022-05-03',3),(4,'2022-05-04',4),(5,'2022-05-05',5); | SELECT SUM(price) FROM menus JOIN orders ON menus.menu_id = orders.menu_id WHERE is_sustainable = true AND orders.order_date BETWEEN '2022-04-01' AND '2022-04-30'; |
What is the total revenue of games with a single-player mode? | CREATE TABLE GameDesignData (GameID INT,SinglePlayer BOOLEAN,Revenue DECIMAL(10,2)); INSERT INTO GameDesignData (GameID,SinglePlayer,Revenue) VALUES (1,TRUE,1000000),(2,FALSE,2000000),(3,TRUE,500000); | SELECT SUM(Revenue) FROM GameDesignData WHERE SinglePlayer = TRUE; |
What is the average production time for each chemical category, for chemical manufacturing in the Africa region? | CREATE TABLE chemicals (id INT,name VARCHAR(255),category VARCHAR(255),production_time FLOAT,region VARCHAR(255)); | SELECT category, AVG(production_time) as avg_time FROM chemicals WHERE region = 'Africa' GROUP BY category; |
What is the average CO2 emission per sustainable tour package offered by vendors from Asia? | CREATE TABLE Vendors (VendorID INT,VendorName VARCHAR(50),Country VARCHAR(50)); INSERT INTO Vendors (VendorID,VendorName,Country) VALUES (1,'GreenVacations','Nepal'),(2,'EcoTours','India'),(3,'SustainableJourneys','Bhutan'),(4,'BluePlanetTours','USA'); CREATE TABLE Packages (PackageID INT,VendorID INT,PackageType VARCHAR(20),CO2Emission DECIMAL(10,2)); INSERT INTO Packages (PackageID,VendorID,PackageType,CO2Emission) VALUES (1,1,'Sustainable',0.5),(2,1,'Virtual',0),(3,2,'Sustainable',0.7),(4,2,'Virtual',0),(5,3,'Sustainable',0.4),(6,3,'Virtual',0),(7,4,'Sustainable',0.6),(8,4,'Virtual',0); | SELECT V.Country, AVG(P.CO2Emission) as AvgCO2Emission FROM Vendors V INNER JOIN Packages P ON V.VendorID = P.VendorID WHERE V.Country LIKE 'Asia%' AND P.PackageType = 'Sustainable' GROUP BY V.Country; |
What's the viewership trend for TV shows in Australia over the last 3 years? | CREATE TABLE tv_shows (id INT,title VARCHAR(255),release_year INT,country VARCHAR(100),viewership INT); | SELECT release_year, AVG(viewership) as avg_viewership FROM tv_shows WHERE country = 'Australia' GROUP BY release_year ORDER BY release_year DESC LIMIT 3; |
What is the maximum property price for buildings in each city with a sustainable urbanism certification? | CREATE TABLE cities (id INT,name VARCHAR(30)); CREATE TABLE properties (id INT,city VARCHAR(20),price INT,sustainable_urbanism BOOLEAN); INSERT INTO cities (id,name) VALUES (1,'Vancouver'),(2,'Seattle'),(3,'Portland'); INSERT INTO properties (id,city,price,sustainable_urbanism) VALUES (101,'Vancouver',600000,true),(102,'Vancouver',700000,false),(103,'Seattle',800000,true),(104,'Seattle',900000,false),(105,'Portland',500000,true),(106,'Portland',400000,false); | SELECT cities.name, MAX(properties.price) FROM cities INNER JOIN properties ON cities.name = properties.city WHERE properties.sustainable_urbanism = true GROUP BY cities.name; |
What was the total amount donated by individual donors from the United States in Q2 2022? | CREATE TABLE donors (id INT,name TEXT,country TEXT,donation_amount DECIMAL(10,2),donation_date DATE); INSERT INTO donors (id,name,country,donation_amount,donation_date) VALUES (1,'John Doe','USA',500.00,'2022-04-01'),(2,'Jane Smith','Canada',300.00,'2022-04-15'); | SELECT SUM(donation_amount) FROM donors WHERE country = 'USA' AND donation_date >= '2022-04-01' AND donation_date <= '2022-06-30'; |
What is the maximum number of mental health scores recorded for students in each school? | CREATE TABLE schools (id INT PRIMARY KEY,name VARCHAR(255)); CREATE TABLE students (id INT PRIMARY KEY,school_id INT,mental_health_score INT); | SELECT s.name, MAX(COUNT(st.mental_health_score)) FROM students st JOIN schools s ON st.school_id = s.id GROUP BY s.id; |
Which departments have the highest percentage of female faculty members? | CREATE TABLE departments (id INT,name TEXT); CREATE TABLE faculty (id INT,name TEXT,gender TEXT,department_id INT); INSERT INTO departments (id,name) VALUES (1,'Mathematics'),(2,'Computer Science'); INSERT INTO faculty (id,name,gender,department_id) VALUES (1,'Jane','Female',1),(2,'John','Male',2),(3,'Joan','Female',1),(4,'Jack','Male',1),(5,'Janet','Female',2); | SELECT d.name, 100.0 * COUNT(f.id) / ( SELECT COUNT(*) FROM faculty f WHERE f.department_id = d.id ) as percentage FROM departments d JOIN faculty f ON d.id = f.department_id WHERE f.gender = 'Female' GROUP BY d.name ORDER BY percentage DESC; |
Find the top 3 brands with the highest sales revenue and their total sales revenue? | CREATE TABLE sales(sale_id INT,brand VARCHAR(255),revenue DECIMAL(5,2));INSERT INTO sales (sale_id,brand,revenue) VALUES (1,'Brand A',5000),(2,'Brand B',7500),(3,'Brand A',6000),(4,'Brand C',4000),(5,'Brand B',8000); | SELECT brand, SUM(revenue) FROM sales GROUP BY brand ORDER BY SUM(revenue) DESC LIMIT 3; |
What is the average number of tickets sold for each game? | CREATE TABLE game_ticket_sales (id INT,game_id INT,team VARCHAR(50),revenue INT); INSERT INTO game_ticket_sales (id,game_id,team,revenue) VALUES (1,1,'TeamA',5000),(2,1,'TeamA',5000),(3,2,'TeamB',6000),(4,2,'TeamB',6000); | SELECT game_id, AVG(revenue/50) as avg_tickets_sold FROM game_ticket_sales GROUP BY game_id; |
Update the country of healthcare center with id 2 to 'Canada'. | CREATE TABLE healthcare_centers (id INT,name TEXT,country TEXT,created_at TIMESTAMP); | UPDATE healthcare_centers SET country = 'Canada' WHERE id = 2; |
Delete all records from the vessel_fuel_consumption table where the fuel_type is 'diesel' | vessel_fuel_consumption(consumption_id,voyage_id,fuel_type,fuel_consumption) | DELETE FROM vessel_fuel_consumption WHERE fuel_type = 'diesel'; |
Find the total revenue for concerts in the APAC region in 2022. | CREATE TABLE Concerts (concert_id INT,concert_name VARCHAR(255),location VARCHAR(255),year INT,revenue INT); INSERT INTO Concerts (concert_id,concert_name,location,year,revenue) VALUES (1,'Concert A','Tokyo',2022,1000000),(2,'Concert B','Seoul',2022,1200000),(3,'Concert C','Sydney',2021,800000); | SELECT SUM(revenue) FROM Concerts WHERE year = 2022 AND location LIKE 'APAC%'; |
Delete all records in the healthcare sector from the database. | CREATE TABLE investments (investment_id INT,investor_id INT,org_id INT,investment_amount INT); INSERT INTO investments (investment_id,investor_id,org_id,investment_amount) VALUES (1,1,10,30000),(2,2,11,40000),(3,1,12,50000),(4,3,11,45000),(5,2,12,60000); CREATE TABLE investors (investor_id INT,investor_name TEXT); INSERT INTO investors (investor_id,investor_name) VALUES (1,'Investor J'),(2,'Investor K'),(3,'Investor L'); CREATE TABLE organizations (org_id INT,org_name TEXT,focus_topic TEXT); INSERT INTO organizations (org_id,org_name,focus_topic) VALUES (10,'Org 10','Healthcare'),(11,'Org 11','Healthcare'),(12,'Org 12','Education'); | DELETE FROM investments WHERE investments.org_id IN (SELECT organizations.org_id FROM organizations WHERE organizations.focus_topic = 'Healthcare'); DELETE FROM organizations WHERE organizations.focus_topic = 'Healthcare'; |
Calculate the average monthly expenses and income for the past year from 'expenses' and 'income' tables | CREATE TABLE expenses (expense_id INT,expense_amount DECIMAL,expense_date DATE); CREATE TABLE income (income_id INT,income_amount DECIMAL,income_date DATE); | SELECT DATE_FORMAT(expenses.expense_date, '%Y-%m') as month, AVG(expenses.expense_amount) as avg_monthly_expenses, AVG(income.income_amount) as avg_monthly_income FROM expenses INNER JOIN income ON DATE_FORMAT(expenses.expense_date, '%Y-%m') = DATE_FORMAT(income.income_date, '%Y-%m') WHERE expenses.expense_date >= DATE_SUB(NOW(), INTERVAL 1 YEAR) GROUP BY month; |
Which ocean has the highest average sea surface temperature? | CREATE TABLE sea_surface_temperature (id INT,ocean VARCHAR(255),avg_temperature FLOAT); INSERT INTO sea_surface_temperature (id,ocean,avg_temperature) VALUES (1,'Pacific',28); | SELECT ocean, MAX(avg_temperature) FROM sea_surface_temperature GROUP BY ocean ORDER BY MAX(avg_temperature) DESC LIMIT 1 |
Find the average environmental impact score for each chemical produced at the Frankfurt and Munich plants. | CREATE TABLE plants (plant VARCHAR(20),chemical VARCHAR(20),score INT); INSERT INTO plants (plant,chemical,score) VALUES ('Frankfurt','Ethanol',80),('Frankfurt','Propanol',75),('Munich','Methanol',70),('Munich','Butanol',78); | SELECT chemical, AVG(score) FROM plants WHERE plant IN ('Frankfurt', 'Munich') GROUP BY chemical; |
What is the average orbital velocity of the International Space Station? | CREATE TABLE space_objects (name TEXT,orbital_velocity_km_s INTEGER); INSERT INTO space_objects (name,orbital_velocity_km_s) VALUES ('ISS',27600),('Hubble Space Telescope',28600),('Moon',1680); | SELECT AVG(orbital_velocity_km_s) FROM space_objects WHERE name = 'ISS'; |
How many games were won by each team in the eastern conference? | CREATE TABLE games (game_id INT,team_id INT,won BOOLEAN); INSERT INTO games VALUES (1,1,true),(2,1,true),(3,2,false),(4,2,false),(5,3,true); | SELECT te.team_name, SUM(g.won::INT) as num_wins FROM games g JOIN teams te ON g.team_id = te.team_id WHERE te.conference = 'Eastern' GROUP BY te.team_name; |
List the number of players who prefer Action games from each country. | CREATE TABLE Players (PlayerID INT,Age INT,Gender VARCHAR(10),Country VARCHAR(20),TotalHoursPlayed INT,FavoriteGame VARCHAR(10)); INSERT INTO Players (PlayerID,Age,Gender,Country,TotalHoursPlayed,FavoriteGame) VALUES (1,22,'Female','India',10,'Action'); INSERT INTO Players (PlayerID,Age,Gender,Country,TotalHoursPlayed,FavoriteGame) VALUES (2,28,'Male','Australia',15,'Action'); INSERT INTO Players (PlayerID,Age,Gender,Country,TotalHoursPlayed,FavoriteGame) VALUES (3,35,'Female','Brazil',20,'Action'); | SELECT Country, COUNT(PlayerID) as NumberOfPlayers FROM Players WHERE FavoriteGame = 'Action' GROUP BY Country; |
What is the total number of volunteer hours contributed by each volunteer for the 'Environment' program? | CREATE TABLE Volunteers (VolunteerID INT,VolunteerName TEXT,TotalHours DECIMAL(5,2));CREATE TABLE VolunteerHours (VolunteerHoursID INT,VolunteerID INT,Program TEXT,Hours DECIMAL(5,2),Partial BOOLEAN); | SELECT V.VolunteerName, SUM(VH.Hours) as TotalHours FROM VolunteerHours VH JOIN Volunteers V ON VH.VolunteerID = V.VolunteerID WHERE VH.Program = 'Environment' GROUP BY VH.VolunteerID; |
Which container ships have had their capacity updated in the last month? | CREATE TABLE ship_updates (update_id INT,ship_name VARCHAR(50),capacity INT,update_date DATE); INSERT INTO ship_updates VALUES (1,'MSC Maya',19224,'2022-03-15'); INSERT INTO ship_updates VALUES (2,'OOCL Hong Kong',21413,'2022-02-20'); INSERT INTO ship_updates VALUES (3,'Ever Given',20000,'2022-03-08'); | SELECT ship_name, update_date FROM ship_updates WHERE update_date > DATEADD(MONTH, -1, GETDATE()); |
Which province in China has the highest installed solar capacity? | CREATE TABLE solar_capacity (province VARCHAR(30),capacity FLOAT); INSERT INTO solar_capacity (province,capacity) VALUES ('Jiangsu',12000),('Jiangsu',14000),('Zhejiang',9000),('Zhejiang',11000),('Anhui',15000),('Anhui',17000); | SELECT province, MAX(capacity) FROM solar_capacity GROUP BY province; |
How many military vehicles were maintained in Texas in the last 6 months? | CREATE TABLE military_equipment (equipment_id INT,equipment_type TEXT,last_maintenance_date DATE,state TEXT); INSERT INTO military_equipment (equipment_id,equipment_type,last_maintenance_date,state) VALUES (1,'Tank','2022-01-01','Texas'); | SELECT COUNT(*) FROM military_equipment WHERE last_maintenance_date >= DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH) AND state = 'Texas' AND equipment_type = 'Tank'; |
What are the average and maximum altitudes of satellites in geostationary orbit? | CREATE TABLE satellites (id INT,name VARCHAR(50),country VARCHAR(50),launch_date DATE,altitude FLOAT,orbit VARCHAR(50)); | SELECT AVG(satellites.altitude) as average_altitude, MAX(satellites.altitude) as max_altitude FROM satellites WHERE satellites.orbit = 'geostationary'; |
What is the average age of attendees at 'Music Education' programs? | CREATE TABLE Attendees_Programs (program_name VARCHAR(255),attendee_age INT); INSERT INTO Attendees_Programs (program_name,attendee_age) VALUES ('Art Education',30,35,40,45),('Music Education',20,22,25),('Theater Education',50,55,60); | SELECT AVG(attendee_age) FROM Attendees_Programs WHERE program_name = 'Music Education'; |
What is the minimum funding received by a company founded by a Pacific Islander? | CREATE TABLE founders (id INT,name VARCHAR(50),ethnicity VARCHAR(20),company_id INT,founding_year INT); CREATE TABLE funding (id INT,company_id INT,amount INT); | SELECT MIN(funding.amount) FROM funding JOIN founders ON funding.company_id = founders.company_id WHERE founders.ethnicity = 'Pacific Islander'; |
How many satellites were deployed by each organization in the last 3 years? | CREATE TABLE Satellite_Deployments (satellite_deployment_id INT,satellite_model VARCHAR(50),deploying_org VARCHAR(50),deployment_date DATE); INSERT INTO Satellite_Deployments (satellite_deployment_id,satellite_model,deploying_org,deployment_date) VALUES (1,'Sat-A','NASA','2020-05-30'),(2,'Sat-B','CNSA','2021-03-09'),(3,'Sat-C','ESA','2019-07-25'),(4,'Sat-D','ISRO','2020-11-07'),(5,'Sat-A','NASA','2019-12-28'); | SELECT deploying_org, COUNT(*) as total_deployments FROM Satellite_Deployments WHERE deployment_date >= DATEADD(year, -3, GETDATE()) GROUP BY deploying_org; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.