instruction stringlengths 0 1.06k | input stringlengths 11 5.3k | response stringlengths 2 4.44k |
|---|---|---|
What is the average time to complete threat intelligence reports, by region, for the top three contractors in the defense industry in the past year? | CREATE TABLE threat_intelligence_reports (report_id INT,report_date DATE,contractor TEXT,region TEXT,report_description TEXT,completion_date DATE); INSERT INTO threat_intelligence_reports (report_id,report_date,contractor,region,report_description,completion_date) VALUES (1,'2022-02-01','ACME Inc','Northeast','Cyber th... | SELECT region, AVG(DATEDIFF(completion_date, report_date)) as avg_time_to_complete FROM threat_intelligence_reports WHERE contractor IN (SELECT contractor FROM (SELECT contractor, COUNT(*) as num_reports FROM threat_intelligence_reports GROUP BY contractor ORDER BY num_reports DESC LIMIT 3) as top_three_contractors) GR... |
How many cases were handled by attorneys with more than 5 years of experience? | CREATE TABLE attorneys (attorney_id INT,years_of_experience INT); INSERT INTO attorneys (attorney_id,years_of_experience) VALUES (1,6),(2,3),(3,7); | SELECT COUNT(*) FROM attorneys WHERE years_of_experience > 5; |
What is the total number of hybrid and electric vehicles sold in the Sales_Data table in the fourth quarter of 2022? | CREATE TABLE Sales_Data (Sale_Date DATE,Vehicle_Type VARCHAR(20),Quantity_Sold INT); | SELECT SUM(Quantity_Sold) FROM Sales_Data WHERE Vehicle_Type IN ('Hybrid', 'Electric') AND Sale_Date BETWEEN '2022-10-01' AND '2022-12-31'; |
What is the total amount of research grants awarded to female faculty members in the past 5 years? | CREATE TABLE faculty (faculty_id INT,name TEXT,gender TEXT,department TEXT); CREATE TABLE research_grants (grant_id INT,faculty_id INT,amount DECIMAL(10,2),date DATE); | SELECT SUM(rg.amount) FROM research_grants rg INNER JOIN faculty f ON rg.faculty_id = f.faculty_id WHERE f.gender = 'female' AND rg.date >= DATE_SUB(CURRENT_DATE, INTERVAL 5 YEAR); |
Show the "name" and "region" of all researchers in the "researchers" table who have more than 5 years of experience in "Asia". | CREATE TABLE researchers (researcher_id INT PRIMARY KEY,name VARCHAR(255),region VARCHAR(255),experience INT); | SELECT name, region FROM researchers WHERE region = 'Asia' AND experience > 5; |
What are the top 3 threat actors with the highest number of attacks in the last 6 months? | CREATE TABLE threat_actors (actor_id INT,actor_name VARCHAR(255),attack_count INT); INSERT INTO threat_actors (actor_id,actor_name,attack_count) VALUES (1,'APT28',20),(2,'APT33',30),(3,'Lazarus Group',40); | SELECT actor_name, attack_count as total_attacks FROM (SELECT actor_name, attack_count, ROW_NUMBER() OVER (ORDER BY attack_count DESC) as rank FROM threat_actors WHERE attack_date >= DATEADD(month, -6, CURRENT_TIMESTAMP)) subquery WHERE rank <= 3; |
Update the visitor count for exhibition 'Asian Art' to 3500 for the date 2023-04-15. | CREATE TABLE Exhibition_Visitors (visitor_id INT,exhibition_id INT,visit_date DATE,visitor_count INT); INSERT INTO Exhibition_Visitors (visitor_id,exhibition_id,visit_date,visitor_count) VALUES (1,2,'2023-01-01',2000),(2,3,'2023-02-01',1500); CREATE TABLE Exhibitions (exhibition_id INT,exhibition_name VARCHAR(50),start... | UPDATE Exhibition_Visitors SET visitor_count = 3500 WHERE exhibition_id = (SELECT exhibition_id FROM Exhibitions WHERE exhibition_name = 'Asian Art') AND visit_date = '2023-04-15'; |
What is the most recent autonomous driving research study conducted in Japan? | CREATE TABLE Research_Studies (id INT,title VARCHAR(100),description TEXT,date_conducted DATE,location VARCHAR(50)); INSERT INTO Research_Studies (id,title,description,date_conducted,location) VALUES (1,'Autonomous Driving and Pedestrian Safety','Research on pedestrian safety in autonomous driving vehicles...','2022-03... | SELECT title FROM Research_Studies WHERE date_conducted = (SELECT MAX(date_conducted) FROM Research_Studies WHERE location = 'Japan'); |
How many companies were founded in Canada? | CREATE TABLE company (id INT,name VARCHAR(50),country VARCHAR(50)); INSERT INTO company (id,name,country) VALUES (1,'Maple Leaf Technologies','Canada'); INSERT INTO company (id,name,country) VALUES (2,'Acme Corp','USA'); INSERT INTO company (id,name,country) VALUES (3,'TechNord','Sweden'); | SELECT COUNT(*) AS num_companies FROM company WHERE country = 'Canada'; |
What is the average CO2 emission from the Canadian oil sands in the last 5 years? | CREATE TABLE Emissions (EmissionID INT,MineID INT,EmissionType VARCHAR(20),EmissionValue INT,Year INT); INSERT INTO Emissions (EmissionID,MineID,EmissionType,EmissionValue,Year) VALUES (1,1,'CO2',1000,2020); INSERT INTO Emissions (EmissionID,MineID,EmissionType,EmissionValue,Year) VALUES (2,2,'CO2',1500,2020); INSERT I... | SELECT AVG(EmissionValue) FROM Emissions WHERE EmissionType = 'CO2' AND MineID IN (SELECT MineID FROM Mines WHERE Country = 'Canada') AND Year >= (SELECT YEAR(CURDATE()) - 5); |
How many users have each mobile operating system? | CREATE TABLE mobile_users (user_id INT,username VARCHAR(50),os VARCHAR(20)); INSERT INTO mobile_users VALUES (1,'User 1','Android'); INSERT INTO mobile_users VALUES (2,'User 2','iOS'); INSERT INTO mobile_users VALUES (3,'User 3','Android'); INSERT INTO mobile_users VALUES (4,'User 4','Windows Phone'); | SELECT os, COUNT(*) as user_count FROM mobile_users GROUP BY os; |
Insert new item ABC into inventory | CREATE TABLE inventory(item VARCHAR(255),warehouse VARCHAR(255)); INSERT INTO inventory VALUES('XYZ','A01'),('DEF','A02'); | INSERT INTO inventory(item) VALUES('ABC'); |
What is the agricultural and environmental impact of drought in a specific location over time? | CREATE TABLE DroughtImpactAssessments (AssessmentID INT,Location VARCHAR(50),Date DATE,AgriculturalImpact INT,EnvironmentalImpact INT); INSERT INTO DroughtImpactAssessments (AssessmentID,Location,Date,AgriculturalImpact,EnvironmentalImpact) VALUES (4,'Los Angeles,CA','2022-04-01',250,125),(5,'Los Angeles,CA','2022-04-0... | SELECT Location, Date, SUM(AgriculturalImpact + EnvironmentalImpact) as TotalImpact FROM DroughtImpactAssessments GROUP BY Location, Date; |
What is the maximum number of works created by an artist in the 'sculpture' medium? | CREATE TABLE works (id INT,artist_id INT,medium TEXT,quantity INT); INSERT INTO works (id,artist_id,medium,quantity) VALUES (1,1,'sculpture',12),(2,2,'painting',25),(3,3,'sculpture',8); | SELECT MAX(quantity) FROM works WHERE medium = 'sculpture'; |
What is the average salary for employees who identify as BIPOC? | CREATE TABLE Employees (EmployeeID INT,Race VARCHAR(20),Salary DECIMAL(10,2)); INSERT INTO Employees (EmployeeID,Race,Salary) VALUES (1,'Asian',80000.00),(2,'Black',85000.00),(3,'Hispanic',90000.00),(4,'White',95000.00); | SELECT AVG(Salary) FROM Employees WHERE Race IN ('Asian', 'Black', 'Hispanic'); |
Show travel advisory updates for Caribbean countries in the last 6 months | CREATE TABLE travel_advisories (id INT,country VARCHAR(255),advisory_date DATE,advisory_update TEXT); INSERT INTO travel_advisories (id,country,advisory_date,advisory_update) VALUES (1,'Bahamas','2023-01-10','Protests in Nassau...'),(2,'Jamaica','2023-02-15','New entry requirements...'),(3,'Cuba','2022-08-20','Hurrican... | SELECT country, advisory_update FROM travel_advisories WHERE country IN ('Bahamas', 'Jamaica', 'Cuba', 'Haiti', 'Puerto Rico', 'Barbados', 'Dominican Republic', 'Trinidad and Tobago', 'Haiti', 'Grenada') AND advisory_date >= DATEADD(month, -6, CURRENT_DATE); |
What is the average amount of research grants awarded to each university in the last three years, rounded to the nearest dollar, with a rank based on the total amount of grants awarded? | CREATE TABLE Universities (UniversityID int,UniversityName varchar(255)); CREATE TABLE ResearchGrants (GrantID int,UniversityID int,Amount int,GrantDate date); | SELECT UniversityName, ROUND(AVG(Amount)) as AvgGrantAmount, RANK() OVER (PARTITION BY UniversityName ORDER BY AVG(Amount) DESC) as GrantRank FROM ResearchGrants WHERE GrantDate >= DATEADD(year, -3, GETDATE()) GROUP BY UniversityName; |
What is the minimum billing amount for cases in Florida? | CREATE TABLE cases (id INT,state VARCHAR(2),billing_amount DECIMAL(10,2)); INSERT INTO cases (id,state,billing_amount) VALUES (1,'FL',2000.00),(2,'NY',3000.00),(3,'FL',1000.00); | SELECT MIN(billing_amount) FROM cases WHERE state = 'FL'; |
What is the average safety rating of vehicles, partitioned by manufacturer, for vehicles with a safety rating of 4 or higher? | CREATE TABLE VehicleSafetyRatings (id INT,make VARCHAR(50),model VARCHAR(50),safety_rating INT); INSERT INTO VehicleSafetyRatings (id,make,model,safety_rating) VALUES (1,'Volvo','XC90',5),(2,'Volvo','XC60',4),(3,'Tesla','Model S',5),(4,'Tesla','Model 3',4),(5,'BMW','X5',4),(6,'BMW','X3',3),(7,'Mercedes','GLC',4),(8,'Me... | SELECT make, AVG(safety_rating) AS avg_safety_rating FROM VehicleSafetyRatings WHERE safety_rating >= 4 GROUP BY make; |
How many companies have been founded by individuals identifying as LGBTQ+? | CREATE TABLE company (id INT,name VARCHAR(50),founder_identity VARCHAR(50)); INSERT INTO company (id,name,founder_identity) VALUES (1,'GreenTech','LGBTQ+'); INSERT INTO company (id,name,founder_identity) VALUES (2,'CodeSolutions','Non-LGBTQ+'); INSERT INTO company (id,name,founder_identity) VALUES (3,'InnoVentures','LG... | SELECT COUNT(*) AS num_companies FROM company WHERE founder_identity = 'LGBTQ+'; |
What is the total number of military bases located in 'caribbean' schema | CREATE SCHEMA if not exists caribbean; USE caribbean; CREATE TABLE if not exists military_bases (id INT,name VARCHAR(255),type VARCHAR(255),location VARCHAR(255)); INSERT INTO military_bases (id,name,type,location) VALUES (1,'Guantanamo Bay Naval Base','Navy Base','Cuba'),(2,'Camp Santiago','Army Base','Puerto Rico'),(... | SELECT COUNT(*) FROM caribbean.military_bases; |
What is the total number of volunteers and the total amount donated for each program? | CREATE TABLE programs (id INT,name TEXT,volunteers_count INT,total_donation FLOAT); | SELECT p.name, SUM(d.total_donation) as total_donation, COUNT(v.id) as volunteers_count FROM programs p LEFT JOIN volunteers v ON p.id = v.program_id LEFT JOIN donors d ON v.id = d.volunteer_id GROUP BY p.name; |
How many games were won by the Raptors at home in the 2019-2020 season? | CREATE TABLE teams (team_name VARCHAR(255),season_start_year INT,season_end_year INT); INSERT INTO teams (team_name,season_start_year,season_end_year) VALUES ('Raptors',2019,2020); CREATE TABLE games (team_name VARCHAR(255),location VARCHAR(255),won BOOLEAN); | SELECT COUNT(*) FROM games WHERE team_name = 'Raptors' AND location = 'home' AND won = TRUE AND season_start_year = 2019 AND season_end_year = 2020; |
What is the total number of marine mammals in the Pacific Ocean? | CREATE TABLE marine_mammals (mammal TEXT,ocean TEXT); INSERT INTO marine_mammals (mammal,ocean) VALUES ('Dolphin','Atlantic Ocean'),('Whale','Pacific Ocean'),('Seal','Arctic Ocean'); | SELECT COUNT(*) FROM marine_mammals WHERE ocean = 'Pacific Ocean' AND mammal LIKE 'Whale%'; |
What is the life expectancy in Australia? | CREATE TABLE Life_Expectancy (ID INT,Country VARCHAR(50),Life_Expectancy FLOAT); INSERT INTO Life_Expectancy (ID,Country,Life_Expectancy) VALUES (1,'Australia',82.8); | SELECT Life_Expectancy FROM Life_Expectancy WHERE Country = 'Australia'; |
Which programs had the highest total donations in the first half of this year? | CREATE TABLE Donations (DonationID INT,DonorID INT,ProgramID INT,Amount DECIMAL(10,2),DonationDate DATE); | SELECT p.ProgramName, SUM(d.Amount) FROM Donations d INNER JOIN Programs p ON d.ProgramID = p.ProgramID WHERE d.DonationDate >= DATEADD(year, DATEDIFF(year, 0, GETDATE()) - 1, 0) AND d.DonationDate < DATEADD(year, DATEDIFF(year, 0, GETDATE()), 6) GROUP BY p.ProgramName ORDER BY SUM(d.Amount) DESC; |
Update the location of mine with ID 4 | mines(mine_id,mine_name,location,extraction_type) | UPDATE mines SET location = 'New Location' WHERE mine_id = 4; |
What is the average safety score for each AI algorithm, partitioned by algorithm type, ordered by score in descending order? | CREATE TABLE ai_algorithms (algorithm_id INT,algorithm_name VARCHAR(50),safety_score DECIMAL(5,2)); INSERT INTO ai_algorithms (algorithm_id,algorithm_name,safety_score) VALUES (1,'DeepQA',85.34),(2,'Random Forest',91.23),(3,'Support Vector Machine',89.11),(4,'Neural Network',87.54); | SELECT algorithm_name, AVG(safety_score) as avg_safety_score FROM ai_algorithms GROUP BY algorithm_name ORDER BY avg_safety_score DESC; |
Identify the top 5 wells with the highest daily oil production | CREATE TABLE wells (well_id INT,daily_oil_production FLOAT); INSERT INTO wells (well_id,daily_oil_production) VALUES (1,1000),(2,2000),(3,1500),(4,2500),(5,3000),(6,4000),(7,5000),(8,6000),(9,7000),(10,8000); | SELECT well_id, daily_oil_production FROM wells ORDER BY daily_oil_production DESC LIMIT 5; |
What is the total precipitation for each country in the past month? | CREATE TABLE country_precipitation_data (id INT,country VARCHAR(255),precipitation INT,timestamp TIMESTAMP); INSERT INTO country_precipitation_data (id,country,precipitation,timestamp) VALUES (1,'India',10,'2022-01-01 10:00:00'),(2,'Brazil',20,'2022-01-01 10:00:00'); | SELECT country, SUM(precipitation) FROM country_precipitation_data WHERE timestamp >= DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 1 MONTH) GROUP BY country; |
What is the total capacity of each landfill in GB serving 'SuburbanArea' as of 2022? | CREATE TABLE landfill_capacity(landfill VARCHAR(50),location VARCHAR(50),capacity FLOAT); INSERT INTO landfill_capacity(landfill,location,capacity) VALUES('Landfill7','SuburbanArea',60000),('Landfill7','SuburbanArea',60000),('Landfill8','SuburbanArea',65000),('Landfill8','SuburbanArea',65000),('Landfill9','SuburbanArea... | SELECT landfill, SUM(capacity) FROM landfill_capacity WHERE location = 'SuburbanArea' GROUP BY landfill; |
What is the maximum number of microtransactions made by players from South America in CS:GO? | CREATE TABLE MicroTransactions (TransactionID INT,PlayerID INT,Amount FLOAT,Game VARCHAR(50)); INSERT INTO MicroTransactions (TransactionID,PlayerID,Amount,Game) VALUES (1,1,20,'CS:GO'); INSERT INTO MicroTransactions (TransactionID,PlayerID,Amount,Game) VALUES (2,2,30,'CS:GO'); INSERT INTO MicroTransactions (Transactio... | SELECT Continent, MAX(Amount) as MaxMicroTransactions FROM MicroTransactions JOIN Players ON MicroTransactions.PlayerID = Players.PlayerID WHERE Game = 'CS:GO' AND Continent = 'South America'; |
What is the total capacity of renewable energy plants in Japan? | CREATE TABLE renewable_plants (id INT PRIMARY KEY,country VARCHAR(50),name VARCHAR(50),capacity FLOAT); INSERT INTO renewable_plants (id,country,name,capacity) VALUES (1,'Japan','Renewable Plant A',65.5),(2,'Japan','Renewable Plant B',75.6); | SELECT SUM(capacity) FROM renewable_plants WHERE country = 'Japan'; |
What is the number of esports events in each country and the total number of VR headset adoptions in those events? | CREATE TABLE EsportsEvents (EventID INT,Country VARCHAR(20),VRAdoption INT); INSERT INTO EsportsEvents (EventID,Country,VRAdoption) VALUES (1,'USA',50),(2,'Canada',30),(3,'Mexico',40),(4,'USA',60),(5,'Canada',70); | SELECT Country, COUNT(*) as NumEvents, SUM(VRAdoption) as TotalVRAdoption FROM EsportsEvents GROUP BY Country; |
What is the total number of language preservation programs in Africa, grouped by country? | CREATE TABLE LanguagePreservation (Country VARCHAR(255),Programs INT); INSERT INTO LanguagePreservation (Country,Programs) VALUES ('Nigeria',15),('South Africa',12),('Ethiopia',18),('Kenya',10),('Tanzania',14); | SELECT Country, SUM(Programs) FROM LanguagePreservation WHERE Country = 'Africa' GROUP BY Country; |
Insert records of new recruits who joined the navy in 2022 into the navy_recruits table | CREATE TABLE navy_recruits (recruit_id INT,name VARCHAR(50),rank VARCHAR(50),join_date DATE); | INSERT INTO navy_recruits (recruit_id, name, rank, join_date) VALUES (1, 'Nguyen Thi Ha', 'Seaman Recruit', '2022-03-04'), (2, 'Ibrahim Ahmed', 'Seaman Recruit', '2022-07-20'), (3, 'Maria Rodriguez', 'Seaman Recruit', '2022-11-12'); |
What is the total quantity of fish farmed in each country by species? | CREATE TABLE CountryFishSpecies (Country varchar(50),SpeciesID int,SpeciesName varchar(50),Quantity int); INSERT INTO CountryFishSpecies (Country,SpeciesID,SpeciesName,Quantity) VALUES ('Canada',1,'Salmon',5000),('Canada',2,'Tuna',6000),('USA',1,'Salmon',7000); | SELECT Country, SpeciesName, SUM(Quantity) as TotalQuantity FROM CountryFishSpecies GROUP BY Country, SpeciesName; |
What is the average duration of membership for unions that have a workplace safety rating above 80? * Assume a column named 'safety_rating' exists in the 'union_profiles' table with numeric values between 0 and 100. | CREATE TABLE union_profiles (union_name VARCHAR(30),safety_rating INT); INSERT INTO union_profiles (union_name,safety_rating) VALUES ('UnionA',85),('UnionB',70),('UnionC',90); | SELECT AVG(membership_duration) FROM union_profiles WHERE safety_rating > 80; |
What is the safety rating of vehicles by manufacturer and model? | CREATE TABLE VehicleSafetyTests (Manufacturer VARCHAR(50),Model VARCHAR(50),Year INT,SafetyRating DECIMAL(3,2)); INSERT INTO VehicleSafetyTests (Manufacturer,Model,Year,SafetyRating) VALUES ('Toyota','Corolla',2020,4.2),('Toyota','Camry',2020,4.8),('Honda','Civic',2020,4.6),('Honda','Accord',2020,4.9),('Ford','Fusion',... | SELECT Manufacturer, Model, SafetyRating FROM VehicleSafetyTests; |
How many wells were drilled in Brazil between 2015 and 2017? | CREATE TABLE drilling_data (well_id INT,drilling_date DATE,well_depth INT,state TEXT); INSERT INTO drilling_data (well_id,drilling_date,well_depth,state) VALUES (1,'2015-01-01',12000,'Brazil'); INSERT INTO drilling_data (well_id,drilling_date,well_depth,state) VALUES (2,'2016-05-15',15000,'Brazil'); INSERT INTO drillin... | SELECT COUNT(*) FROM drilling_data WHERE state = 'Brazil' AND drilling_date BETWEEN '2015-01-01' AND '2017-12-31'; |
Which IP addresses have been detected as threats in the last week and have also had security incidents in the last month? | CREATE TABLE threats (ip_address VARCHAR(255),timestamp TIMESTAMP); CREATE TABLE security_incidents (id INT,ip_address VARCHAR(255),timestamp TIMESTAMP); | SELECT t.ip_address FROM threats t JOIN security_incidents i ON t.ip_address = i.ip_address WHERE t.timestamp >= NOW() - INTERVAL 1 WEEK AND i.timestamp >= NOW() - INTERVAL 1 MONTH; |
Which regions had the highest and lowest donation amounts in 2022? | CREATE TABLE Donors (DonorID INT,DonorRegion VARCHAR(50),Amount DECIMAL(10,2)); INSERT INTO Donors (DonorID,DonorRegion,Amount) VALUES (1,'North America',1200),(2,'Europe',1100),(3,'Asia',900),(4,'North America',1500),(5,'Africa',800); | SELECT DonorRegion, MAX(Amount) as HighestDonation, MIN(Amount) as LowestDonation FROM Donors WHERE YEAR(DonationDate) = 2022 GROUP BY DonorRegion HAVING COUNT(DonorID) > 1; |
Which country sources the most natural ingredients for cosmetic products? | CREATE TABLE ingredient_sourcing (ingredient_name VARCHAR(100),source_country VARCHAR(100),is_natural BOOLEAN); INSERT INTO ingredient_sourcing (ingredient_name,source_country,is_natural) VALUES ('Coconut Oil','Sri Lanka',true),('Rosehip Oil','Chile',true),('Lavender Oil','France',true); | SELECT source_country, SUM(CASE WHEN is_natural THEN 1 ELSE 0 END) AS total_natural_ingredients FROM ingredient_sourcing GROUP BY source_country ORDER BY total_natural_ingredients DESC LIMIT 1; |
What is the average age of teachers who have completed at least one professional development course in the past year? | CREATE TABLE teachers (teacher_id INT,age INT,num_courses_completed INT); INSERT INTO teachers (teacher_id,age,num_courses_completed) VALUES (1,35,2),(2,45,0),(3,30,1),(4,50,3); | SELECT AVG(age) FROM teachers WHERE num_courses_completed >= (SELECT COUNT(course_id) FROM courses WHERE completion_date > DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR)); |
What is the most common medium used in sculptures from the Baroque period? | CREATE TABLE ArtMovements (MovementID int,Name varchar(50)); CREATE TABLE ArtPieces (ArtPieceID int,Title varchar(50),YearCreated int,MovementID int,Medium varchar(50)); | SELECT ArtMovements.Name, ArtPieces.Medium, COUNT(ArtPieces.ArtPieceID) AS ArtPiecesCount FROM ArtMovements INNER JOIN ArtPieces ON ArtMovements.MovementID = ArtPieces.MovementID WHERE ArtMovements.Name = 'Baroque' AND ArtPieces.Medium IS NOT NULL GROUP BY ArtMovements.Name, ArtPieces.Medium ORDER BY ArtPiecesCount DES... |
How many defense diplomacy events involved cybersecurity cooperation in the European region? | CREATE TABLE DefenseDiplomacy (Country VARCHAR(255),Region VARCHAR(255),EventType VARCHAR(255),InvolvesCybersecurity BOOLEAN); INSERT INTO DefenseDiplomacy (Country,Region,EventType,InvolvesCybersecurity) VALUES ('France','Europe','MilitaryExercise',TRUE),('Germany','Europe','MilitaryExercise',FALSE); | SELECT COUNT(*) FROM DefenseDiplomacy WHERE Region = 'Europe' AND InvolvesCybersecurity = TRUE; |
What is the maximum budget allocated for biosensor technology development in startups located in the United Kingdom? | CREATE TABLE startups (id INT,name VARCHAR(255),location VARCHAR(255),budget FLOAT); INSERT INTO startups (id,name,location,budget) VALUES (1,'StartupA','UK',6000000); INSERT INTO startups (id,name,location,budget) VALUES (2,'StartupB','UK',3000000); INSERT INTO startups (id,name,location,budget) VALUES (3,'StartupC','... | SELECT MAX(budget) FROM startups WHERE location = 'UK' AND category = 'biosensor technology'; |
List all suppliers that donate a portion of their profits to charity. | CREATE TABLE suppliers (supplier_id INT,name VARCHAR(255),charity_donation BOOLEAN); INSERT INTO suppliers (supplier_id,name,charity_donation) VALUES (1,'Kind Supplies',TRUE),(2,'Eco Goods',FALSE); | SELECT * FROM suppliers WHERE charity_donation = TRUE; |
What is the average donation amount per donor in the last year? | CREATE TABLE Donors (DonorID INT,DonationDate DATE,DonationAmount DECIMAL(10,2)); INSERT INTO Donors (DonorID,DonationDate,DonationAmount) VALUES (1,'2022-02-15',50.00),(2,'2022-03-20',100.00),(3,'2021-12-31',75.00); | SELECT DonorID, AVG(DonationAmount) as AvgDonationPerDonor FROM Donors WHERE DonationDate >= DATE_TRUNC('year', CURRENT_DATE - INTERVAL '1 year') AND DonationDate < DATE_TRUNC('year', CURRENT_DATE) GROUP BY DonorID; |
Delete records of Carp species from the fish_species table | CREATE TABLE fish_species (id INT PRIMARY KEY,species VARCHAR(255),scientific_name VARCHAR(255)); | DELETE FROM fish_species WHERE species = 'Carp'; |
What is the total energy consumption for commercial buildings in Texas, categorized by energy source, for the year 2020?' | CREATE TABLE commercial_buildings (id INT,state VARCHAR(2),energy_consumption FLOAT); INSERT INTO commercial_buildings (id,state,energy_consumption) VALUES (1,'TX',1200000),(2,'TX',1500000),(3,'TX',900000),(4,'TX',1700000); CREATE TABLE energy_source (id INT,source VARCHAR(20),commercial_buildings_id INT); INSERT INTO ... | SELECT e.source, SUM(cb.energy_consumption) as total_energy_consumption FROM commercial_buildings cb JOIN energy_source e ON cb.id = e.commercial_buildings_id WHERE cb.state = 'TX' AND YEAR(cb.timestamp) = 2020 GROUP BY e.source; |
What is the name and manufacturer of the earliest deployed satellite, considering 'Telstar 18V' by Telesat? | CREATE TABLE satellites (id INT,name VARCHAR(255),manufacturer VARCHAR(255),launch_date DATE); INSERT INTO satellites (id,name,manufacturer,launch_date) VALUES (1,'FalconSat','SpaceX','2020-01-01'),(2,'Cubesat','Blue Origin','2019-01-01'),(3,'Electron','Rocket Lab','2021-01-01'),(4,'Telstar 18V','Telesat','2018-09-10')... | SELECT name, manufacturer FROM satellites ORDER BY launch_date ASC LIMIT 1; |
For how many fish species has feed been provided in the Arctic region with a dissolved oxygen level greater than 8? | CREATE TABLE Feed (FeedID INT,StockID INT,FeedType VARCHAR(50),Quantity INT,FeedDate DATE,Location VARCHAR(50),DissolvedOxygen FLOAT); INSERT INTO Feed (FeedID,StockID,FeedType,Quantity,FeedDate,Location,DissolvedOxygen) VALUES (1,1,'Organic',120,'2021-01-01','Arctic',8.2); INSERT INTO Feed (FeedID,StockID,FeedType,Qua... | SELECT COUNT(DISTINCT Species) FROM FishStock fs JOIN Feed f ON fs.StockID = f.StockID WHERE f.Location = 'Arctic' AND f.DissolvedOxygen > 8; |
What is the total number of animals in the rehabilitation center and their respective species? | CREATE TABLE animal_species (species_id INT,species_name VARCHAR(255)); INSERT INTO animal_species (species_id,species_name) VALUES (1,'Tiger'),(2,'Lion'),(3,'Elephant'); CREATE TABLE rehabilitation_center (animal_id INT,species_id INT,admission_date DATE); INSERT INTO rehabilitation_center (animal_id,species_id,admiss... | SELECT r.animal_id, s.species_name FROM rehabilitation_center r JOIN animal_species s ON r.species_id = s.species_id; |
Retrieve the total number of policies and claims for each risk assessment model. | CREATE TABLE policies (policy_id INT,risk_assessment_model_id INT); CREATE TABLE claims (claim_id INT,policy_id INT); CREATE TABLE risk_assessment_models (risk_assessment_model_id INT,model_name VARCHAR(50)); | SELECT risk_assessment_models.model_name, COUNT(policies.policy_id) AS total_policies, COUNT(claims.claim_id) AS total_claims FROM risk_assessment_models LEFT JOIN policies ON risk_assessment_models.risk_assessment_model_id = policies.risk_assessment_model_id LEFT JOIN claims ON policies.policy_id = claims.policy_id GR... |
What is the total weight of shipments from Spain since 2021-01-01? | CREATE TABLE Shipments (id INT,weight FLOAT,origin VARCHAR(20),shipped_date DATE); INSERT INTO Shipments (id,weight,origin,shipped_date) VALUES (1,50,'Spain','2021-01-05'),(2,70,'USA','2021-02-10'),(3,30,'Spain','2021-03-20'); | SELECT SUM(weight) FROM Shipments WHERE origin = 'Spain' AND shipped_date >= '2021-01-01' |
Delete records in the vessel_fuel_consumption table where the fuel_consumption_liters is greater than 1000 and the voyage_date is within the last month for vessel "Green Wave" | CREATE TABLE vessel_fuel_consumption (vessel_name VARCHAR(255),voyage_date DATE,fuel_consumption_liters INT); | DELETE FROM vessel_fuel_consumption WHERE vessel_name = 'Green Wave' AND fuel_consumption_liters > 1000 AND voyage_date > DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH); |
What was the average amount of funding received by Indigenous-led agricultural projects in Bolivia in 2018? | CREATE TABLE Agricultural_Projects (Project_ID INT,Project_Name TEXT,Location TEXT,Funding_Received DECIMAL,Led_By TEXT,Year INT); INSERT INTO Agricultural_Projects (Project_ID,Project_Name,Location,Funding_Received,Led_By,Year) VALUES (1,'Agroforestry Project','Bolivia',35000,'Indigenous',2018); | SELECT AVG(Funding_Received) FROM Agricultural_Projects WHERE Led_By = 'Indigenous' AND Year = 2018 AND Location = 'Bolivia'; |
Update the name of all smart contracts with the word 'test' in it to 'TestSC' in the smart_contracts table. | CREATE TABLE smart_contracts (id INT,name VARCHAR(100),code VARCHAR(1000),creation_date DATE); INSERT INTO smart_contracts (id,name,code,creation_date) VALUES (1,'testSC123','0x123...','2017-01-01'); INSERT INTO smart_contracts (id,name,code,creation_date) VALUES (2,'otherSC','0x456...','2018-05-05'); | UPDATE smart_contracts SET name = 'TestSC' WHERE name LIKE '%test%'; |
How many flight accidents were recorded in the year 2000? | CREATE TABLE Flight_Safety_Table (id INT,year INT,num_accidents INT); | SELECT SUM(NUM_ACCIDENTS) FROM Flight_Safety_Table WHERE YEAR = 2000; |
Create a table named 'water_usage' | CREATE TABLE public.water_usage (id SERIAL PRIMARY KEY,location VARCHAR(255),date DATE,usage FLOAT); | CREATE TABLE public.water_usage ( id SERIAL PRIMARY KEY, location VARCHAR(255), date DATE, usage FLOAT); |
What is the average rating of movies produced by studios located in Africa? | CREATE TABLE movies (id INT,title VARCHAR(100),release_year INT,studio_country VARCHAR(50),rating DECIMAL(3,2)); | SELECT AVG(rating) FROM movies WHERE studio_country IN ('Nigeria', 'South Africa', 'Egypt'); |
What is the number of healthcare workers in each location in the "rural_clinics" table? | CREATE TABLE rural_clinics (id INT,name VARCHAR(50),location VARCHAR(50),num_workers INT,avg_age INT); | SELECT location, COUNT(num_workers) FROM rural_clinics GROUP BY location; |
Count the number of players who have played more than 50 hours in the game "Cosmic Crusaders" in the month of January 2022. | CREATE TABLE GameSessions (SessionID INT,PlayerID INT,Game TEXT,Duration INT,SessionDate DATE); INSERT INTO GameSessions (SessionID,PlayerID,Game,Duration,SessionDate) VALUES (1,1,'Cosmic Crusaders',60,'2022-01-01'),(2,2,'Cosmic Crusaders',45,'2022-01-05'),(3,3,'Cosmic Crusaders',70,'2022-01-10'); | SELECT COUNT(*) FROM GameSessions WHERE Game = 'Cosmic Crusaders' AND Duration > 50 AND EXTRACT(MONTH FROM SessionDate) = 1 AND EXTRACT(YEAR FROM SessionDate) = 2022; |
Insert new space missions into the Space_Missions table. | CREATE TABLE Space_Missions (MissionId INT,Name VARCHAR,Launch_Date DATE,Status VARCHAR,Objective TEXT); | WITH new_missions AS (VALUES (1, 'Artemis I', '2022-08-29', 'Planned', 'Uncrewed lunar flyby'), (2, 'Artemis II', '2023-11-01', 'Planned', 'Crewed lunar flyby')) INSERT INTO Space_Missions (MissionId, Name, Launch_Date, Status, Objective) SELECT * FROM new_missions; |
How many electric vehicle charging stations were installed in each province in Canada, by type, from 2016 to 2021? | CREATE TABLE charging_stations (province text,type text,year integer,stations integer); | SELECT province, type, SUM(stations) as total_stations FROM charging_stations WHERE year BETWEEN 2016 AND 2021 AND province = 'Canada' GROUP BY province, type; |
Find the top 2 countries with the highest safety incident rate in the past year, partitioned by month. | CREATE TABLE safety_incidents (incident_id INT,incident_date DATE,country TEXT,incident_type TEXT); INSERT INTO safety_incidents (incident_id,incident_date,country,incident_type) VALUES (1,'2021-01-15','USA','Chemical Spill'),(2,'2021-02-20','Canada','Fire'),(3,'2021-03-05','Mexico','Equipment Failure'); | SELECT country, COUNT(*) AS incidents, EXTRACT(MONTH FROM incident_date) AS month FROM safety_incidents WHERE incident_date >= DATEADD(year, -1, CURRENT_DATE) GROUP BY country, month ORDER BY incidents DESC FETCH FIRST 2 ROWS ONLY; |
How many alternative dispute resolution methods were used for civil cases in each county? | CREATE TABLE civil_cases (case_id INT,case_county VARCHAR(20)); CREATE TABLE dispute_resolution (case_id INT,resolution_type VARCHAR(20)); | SELECT cc.case_county, COUNT(dr.resolution_type) FROM civil_cases cc INNER JOIN dispute_resolution dr ON cc.case_id = dr.case_id GROUP BY cc.case_county; |
What is the maximum number of AI ethics complaints received by organizations in the Middle East and North Africa region, and which organization received it? | CREATE TABLE ai_ethics_complaints (organization VARCHAR(255),region VARCHAR(255),year INT,num_complaints INT); INSERT INTO ai_ethics_complaints (organization,region,year,num_complaints) VALUES ('Organization A','Saudi Arabia',2018,20),('Organization B','United Arab Emirates',2019,25),('Organization C','Egypt',2020,30); | SELECT MAX(num_complaints) as max_complaints, organization FROM ai_ethics_complaints WHERE region = 'Middle East and North Africa' GROUP BY organization HAVING max_complaints = (SELECT MAX(num_complaints) FROM ai_ethics_complaints WHERE region = 'Middle East and North Africa'); |
List all cybersecurity strategies and their respective budgets from the 'Cybersecurity' table | CREATE TABLE Cybersecurity (Strategy_Name VARCHAR(255),Budget INT,Fiscal_Year INT); INSERT INTO Cybersecurity (Strategy_Name,Budget,Fiscal_Year) VALUES ('Endpoint Protection',5000000,2022); INSERT INTO Cybersecurity (Strategy_Name,Budget,Fiscal_Year) VALUES ('Network Security',7000000,2022); | SELECT * FROM Cybersecurity; |
How many companies were founded before 2010 in the healthcare sector? | CREATE TABLE companies (id INT,name VARCHAR(255),sector VARCHAR(255),founding_year INT); INSERT INTO companies (id,name,sector,founding_year) VALUES (1,'Johnson & Johnson','Healthcare',1886),(2,'Pfizer','Healthcare',1849),(3,'Tesla','Automotive',2003); | SELECT COUNT(*) FROM companies WHERE sector = 'Healthcare' AND founding_year < 2010; |
List all the crops and their yields from 'urban_gardens' table for region '02' | CREATE TABLE urban_gardens (id INT,region VARCHAR(10),crop VARCHAR(20),yield INT); | SELECT crop, yield FROM urban_gardens WHERE region = '02'; |
Who are the vendors and their corresponding employee names who have been involved in the awarding of cybersecurity contracts? | CREATE TABLE Contracts (ContractID INT,ContractType VARCHAR(50),ContractAmount DECIMAL(10,2),MilitaryBranch VARCHAR(50),PRIMARY KEY (ContractID)); CREATE TABLE Vendors (VendorID INT,VendorName VARCHAR(50),VendorLocation VARCHAR(50),ContactPerson VARCHAR(50)); CREATE TABLE Employees (EmployeeID INT,EmployeeName VARCHAR(... | SELECT Vendors.VendorName, Employees.EmployeeName FROM Contracts INNER JOIN Vendors ON Contracts.MilitaryBranch = Vendors.VendorLocation INNER JOIN Employees ON Vendors.VendorID = Employees.VendorID WHERE ContractType = 'Cybersecurity Contract'; |
List all the debris types in the space_debris table | CREATE TABLE space_debris (id INT PRIMARY KEY,debris_name VARCHAR(100),launch_date DATE,type VARCHAR(50)); | SELECT DISTINCT type FROM space_debris; |
What is the maximum budget allocated for disability accommodations in each department? | CREATE TABLE Departments (DepartmentID INT PRIMARY KEY,DepartmentName VARCHAR(50)); CREATE TABLE Universities (UniversityID INT PRIMARY KEY,UniversityName VARCHAR(50)); CREATE TABLE UniversityDepartments (UniversityDepartmentID INT PRIMARY KEY,UniversityID INT,DepartmentID INT,BudgetForDisabilityAccommodations DECIMAL(... | SELECT d.DepartmentName, MAX(ud.BudgetForDisabilityAccommodations) as MaxBudget FROM Departments d JOIN UniversityDepartments ud ON d.DepartmentID = ud.DepartmentID GROUP BY d.DepartmentName; |
What is the average age of employees in the marketing department? | CREATE TABLE employees (id INT,name VARCHAR(50),department VARCHAR(50),age INT); INSERT INTO employees (id,name,department,age) VALUES (1,'John Doe','Marketing',35),(2,'Jane Smith','Marketing',28); | SELECT AVG(age) FROM employees WHERE department = 'Marketing'; |
What is the total number of hours spent on open pedagogy projects by students in each gender group? | CREATE TABLE open_pedagogy_gender (student_id INT,gender TEXT,total_open_pedagogy_hours INT); INSERT INTO open_pedagogy_gender (student_id,gender,total_open_pedagogy_hours) VALUES (1,'Female',30),(2,'Male',45),(3,'Female',60); | SELECT gender, SUM(total_open_pedagogy_hours) FROM open_pedagogy_gender GROUP BY gender; |
Find the total amount of money spent on public transportation in 2020 and 2021? | CREATE TABLE budget (year INT,category VARCHAR(255),amount INT); INSERT INTO budget (year,category,amount) VALUES (2018,'Education',50000),(2018,'Transport',70000),(2019,'Education',55000),(2019,'Transport',80000),(2020,'Education',60000),(2020,'Transport',90000),(2021,'Education',65000),(2021,'Transport',100000); | SELECT SUM(amount) FROM budget WHERE category = 'Transport' AND year IN (2020, 2021) |
What is the earliest delivery time for shipments to Australia? | CREATE TABLE shipment_deliveries(id INT,shipment_id INT,delivery_time INT); INSERT INTO shipment_deliveries(id,shipment_id,delivery_time) VALUES (1,1,7),(2,2,10),(3,3,8); | SELECT MIN(delivery_time) FROM shipment_deliveries JOIN shipments ON shipment_deliveries.shipment_id = shipments.id WHERE shipments.destination = 'Australia'; |
What is the total donation amount and average donation amount for the 'Arts & Culture' program in 2022? | CREATE TABLE program (id INT,name VARCHAR(50)); INSERT INTO program (id,name) VALUES (1,'Education'),(2,'Health'),(3,'Arts & Culture'); CREATE TABLE donation (id INT,amount DECIMAL(10,2),program_id INT,donation_date DATE); | SELECT d.program_id, SUM(d.amount) as total_donations, AVG(d.amount) as avg_donation_amount FROM donation d WHERE d.program_id = 3 AND YEAR(d.donation_date) = 2022 GROUP BY d.program_id; |
What is the total number of students who received accommodations by accommodation type in 2021? | CREATE TABLE Accommodations (StudentID INT,AccommodationType VARCHAR(50),AccommodationDate DATE); INSERT INTO Accommodations (StudentID,AccommodationType,AccommodationDate) VALUES (1,'Sign Language Interpreter','2021-01-01'); CREATE TABLE Students (StudentID INT,StudentName VARCHAR(50),GraduationYear INT); INSERT INTO ... | SELECT AccommodationType, COUNT(*) as Total FROM Accommodations WHERE YEAR(AccommodationDate) = 2021 GROUP BY AccommodationType; |
What is the average funding for startups founded by individuals from underrepresented communities? | CREATE TABLE startups (id INT,name TEXT,founder TEXT,community TEXT,funding FLOAT); INSERT INTO startups (id,name,founder,community,funding) VALUES (1,'Acme','John Doe','Majority',500000.00); INSERT INTO startups (id,name,founder,community,funding) VALUES (2,'Beta Corp','Jane Smith','Underrepresented',750000.00); INSER... | SELECT AVG(funding) FROM startups WHERE community = 'Underrepresented'; |
What is the maximum fare for buses in the 'south' region? | CREATE TABLE bus_fares (fare_id INT,region_id INT,fare DECIMAL(5,2)); INSERT INTO bus_fares (fare_id,region_id,fare) VALUES (1,1,1.50),(2,2,2.25),(3,3,1.75),(4,2,2.25); | SELECT MAX(bf.fare) FROM bus_fares bf INNER JOIN regions r ON bf.region_id = r.region_id WHERE r.region_name = 'south'; |
What is the average quantity and average cost of feed supplied to each species, grouped by species and month? | CREATE TABLE FeedSupply (ID INT PRIMARY KEY,Supplier VARCHAR,SpeciesID INT,Quantity INT,DeliveryDate DATE,Cost FLOAT,FOREIGN KEY (SpeciesID) REFERENCES Species(ID)); INSERT INTO FeedSupply (ID,Supplier,SpeciesID,Quantity,DeliveryDate,Cost) VALUES (3,'SustainableFeeds Inc.',3,700,'2022-04-01',1200.00); | SELECT f.Name AS SpeciesName, f.Origin, fs.Supplier, AVG(fs.Quantity) AS AvgQuantity, AVG(fs.Cost) AS AvgCost, DATE_FORMAT(fs.DeliveryDate, '%%Y-%%m') AS Month FROM FeedSupply fs JOIN Species f ON fs.SpeciesID = f.ID GROUP BY f.Name, f.Origin, MONTH(fs.DeliveryDate), fs.Supplier; |
How many travel advisories were issued for Canada in 2022? | CREATE TABLE travel_advisories (id INT,country TEXT,year INT,month INT,advisory_level INT); INSERT INTO travel_advisories (id,country,year,month,advisory_level) VALUES (1,'Canada',2022,1,2),(2,'Canada',2022,2,2),(3,'Mexico',2022,3,3); | SELECT COUNT(*) FROM travel_advisories WHERE country = 'Canada' AND year = 2022; |
Who are the top 3 clients with the highest total transaction amounts in the 'Retail' division? | CREATE TABLE Clients (ClientID int,Name varchar(50),Division varchar(50)); INSERT INTO Clients (ClientID,Name,Division) VALUES (10,'Alex Thompson','High Net Worth'),(11,'Bella Chen','Retail'),(12,'Charlie Lee','High Net Worth'); CREATE TABLE Transactions (TransactionID int,ClientID int,Amount decimal(10,2)); INSERT INT... | SELECT c.Name, SUM(t.Amount) as TotalTransactionAmount FROM Clients c INNER JOIN Transactions t ON c.ClientID = t.ClientID WHERE c.Division = 'Retail' GROUP BY c.Name ORDER BY TotalTransactionAmount DESC LIMIT 3; |
List all museums in Europe with their respective websites. | CREATE TABLE Museums (MuseumID int,MuseumName varchar(50),Country varchar(50),Website varchar(100)); INSERT INTO Museums (MuseumID,MuseumName,Country,Website) VALUES (1,'Louvre Museum','France','https://www.louvre.fr'); INSERT INTO Museums (MuseumID,MuseumName,Country,Website) VALUES (2,'British Museum','UK','https://w... | SELECT MuseumName, Website FROM Museums WHERE Country = 'Europe' |
Which countries in Southeast Asia have the most UNESCO heritage sites? | CREATE TABLE heritage_sites (id INT,name TEXT,location TEXT,category TEXT); INSERT INTO heritage_sites (id,name,location,category) VALUES (1,'Angkor Wat','Cambodia','Cultural'),(2,'Borobudur','Indonesia','Cultural'),(3,'Prambanan','Indonesia','Cultural'),(4,'Temple of Preah Vihear','Cambodia','Cultural'),(5,'Bagan','My... | SELECT location, COUNT(*) FROM heritage_sites WHERE category = 'Cultural' GROUP BY location ORDER BY COUNT(*) DESC LIMIT 1; |
How many socially responsible loans have been issued in the last 12 months? | CREATE TABLE socially_responsible_lending (loan_id INT,issue_date DATE); INSERT INTO socially_responsible_lending (loan_id,issue_date) VALUES (1,'2021-02-01'),(2,'2021-05-15'),(3,'2022-03-09'); | SELECT COUNT(loan_id) FROM socially_responsible_lending WHERE issue_date >= DATE_SUB(CURRENT_DATE, INTERVAL 12 MONTH); |
What is the average number of employees on vessels from each country? | CREATE TABLE countries (id INT,name TEXT); CREATE TABLE vessels (id INT,country_id INT,name TEXT,num_employees INT); INSERT INTO countries VALUES (1,'Brazil'),(2,'Argentina'),(3,'Colombia'); INSERT INTO vessels VALUES (1,1,'Brazilian Vessel 1',30),(2,1,'Brazilian Vessel 2',40),(3,2,'Argentine Vessel 1',50),(4,3,'Colomb... | SELECT c.name, AVG(v.num_employees) as avg_num_employees FROM countries c INNER JOIN vessels v ON c.id = v.country_id GROUP BY c.name; |
What is the average donation amount per program? | CREATE TABLE donations (id INT,donor_name VARCHAR,donation_amount DECIMAL,donation_date DATE,program VARCHAR); INSERT INTO donations (id,donor_name,donation_amount,donation_date,program) VALUES (1,'John Doe',100,'2021-01-01','Education'); | SELECT program, AVG(donation_amount) FROM donations GROUP BY program; |
Identify menu items with a high price difference between the average price and the next most popular item in the same category, for restaurants in Illinois. | CREATE TABLE MenuItems (MenuID INT,RestaurantID INT,MenuItem VARCHAR(255),Category VARCHAR(255),AveragePrice DECIMAL(5,2),Popularity INT); | SELECT MenuID, MenuItem, Category, AveragePrice, Popularity, LEAD(AveragePrice) OVER (PARTITION BY Category ORDER BY Popularity DESC) as NextItemPrice, (AveragePrice - LEAD(AveragePrice) OVER (PARTITION BY Category ORDER BY Popularity DESC)) as PriceDifference FROM MenuItems WHERE RestaurantID IN (SELECT RestaurantID F... |
Find the total revenue for each music genre in the current month. | CREATE TABLE music_revenue (song VARCHAR(255),genre VARCHAR(255),revenue INT,revenue_date DATE); INSERT INTO music_revenue (song,genre,revenue,revenue_date) VALUES ('Song1','Genre1',5000000,'2022-02-01'),('Song2','Genre2',7000000,'2022-02-02'),('Song3','Genre1',6000000,'2022-02-03'),('Song4','Genre2',8000000,'2022-02-0... | SELECT genre, SUM(revenue) as total_revenue FROM music_revenue GROUP BY genre ORDER BY total_revenue DESC; |
Update the 'oil_production' table to set the 'yearly_production' to 0 for all records where the 'company_name' is 'Global Energy Inc.' | CREATE TABLE oil_production (production_id INT PRIMARY KEY,company_name VARCHAR(255),year INT,yearly_production BIGINT); | UPDATE oil_production SET yearly_production = 0 WHERE company_name = 'Global Energy Inc.'; |
What is the maximum number of hours spent on mental health support sessions by teachers in each department? | CREATE TABLE departments (department_id INT,department_name TEXT); CREATE TABLE teachers (teacher_id INT,teacher_name TEXT,department_id INT,hours_spent_on_mental_health_sessions INT); INSERT INTO departments VALUES (1,'Mathematics'),(2,'Science'),(3,'English'); INSERT INTO teachers VALUES (1,'Mr. Patel',1,20),(2,'Ms. ... | SELECT d.department_name, MAX(t.hours_spent_on_mental_health_sessions) FROM departments d INNER JOIN teachers t ON d.department_id = t.department_id GROUP BY d.department_id; |
What is the total number of people affected by the digital divide in North America? | CREATE TABLE digital_divide (country VARCHAR(20),population INT,affected INT); INSERT INTO digital_divide (country,population,affected) VALUES ('United States',331002651,42000000),('Canada',37410003,500000); | SELECT SUM(affected) FROM digital_divide WHERE country = 'North America'; |
How many public schools were there in the city of Chicago in the year 2019? | CREATE TABLE schools (type VARCHAR(10),city VARCHAR(20),year INT); INSERT INTO schools (type,city,year) VALUES ('public','Chicago',2019); INSERT INTO schools (type,city,year) VALUES ('private','Chicago',2019); | SELECT COUNT(*) FROM schools WHERE type = 'public' AND city = 'Chicago' AND year = 2019; |
List all the wastewater treatment plants in Canada and their capacities. | CREATE TABLE wastewater_treatment (plant_name VARCHAR(50),country VARCHAR(20),capacity_m3 INT); INSERT INTO wastewater_treatment (plant_name,country,capacity_m3) VALUES ('Vancouver WWTP','Canada',1500000); | SELECT plant_name, country, capacity_m3 FROM wastewater_treatment WHERE country = 'Canada'; |
What is the average duration of group therapy sessions in the United Kingdom? | CREATE TABLE session_duration (session_id INT,duration INT,treatment VARCHAR(255),country VARCHAR(255)); INSERT INTO session_duration (session_id,duration,treatment,country) VALUES (1,60,'Group','United Kingdom'); INSERT INTO session_duration (session_id,duration,treatment,country) VALUES (2,90,'Individual','United Kin... | SELECT AVG(duration) FROM session_duration WHERE treatment = 'Group' AND country = 'United Kingdom'; |
What is the total quantity of copper and gold extracted by each company in Canada for the last 5 years? | CREATE TABLE CanadianMiningExtraction (year INT,company TEXT,country TEXT,mineral TEXT,quantity INT); INSERT INTO CanadianMiningExtraction (year,company,country,mineral,quantity) VALUES (2017,'Northstar Mining','Canada','Copper',5000),(2018,'Northstar Mining','Canada','Copper',5500),(2019,'Northstar Mining','Canada','C... | SELECT context.company, SUM(CASE WHEN context.mineral = 'Copper' THEN context.quantity ELSE 0 END) as total_copper, SUM(CASE WHEN context.mineral = 'Gold' THEN context.quantity ELSE 0 END) as total_gold FROM CanadianMiningExtraction context WHERE context.country = 'Canada' AND context.year BETWEEN 2017 AND 2021 GROUP B... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.