instruction
stringlengths 0
1.06k
| input
stringlengths 11
5.3k
| response
stringlengths 2
4.44k
|
---|---|---|
What is the minimum and maximum temperature range (in Celsius) for greenhouses in Spain? | CREATE TABLE greenhouses (id INT,name VARCHAR(255),location VARCHAR(255),min_temp DECIMAL(4,2),max_temp DECIMAL(4,2)); INSERT INTO greenhouses (id,name,location,min_temp,max_temp) VALUES (1,'Greenhouse A','Spain',20.1,25.6); INSERT INTO greenhouses (id,name,location,min_temp,max_temp) VALUES (2,'Greenhouse B','Spain',19.8,26.3); INSERT INTO greenhouses (id,name,location,min_temp,max_temp) VALUES (3,'Greenhouse C','France',15.7,22.4); | SELECT location, MIN(min_temp) as min_temp, MAX(max_temp) as max_temp FROM greenhouses WHERE location = 'Spain'; |
List the mental health campaigns in Asia that started after 2015. | CREATE TABLE campaigns (id INT,name VARCHAR(255),country VARCHAR(255),start_date DATE); INSERT INTO campaigns (id,name,country,start_date) VALUES (1,'Mindful Asia','China','2016-01-01'); INSERT INTO campaigns (id,name,country,start_date) VALUES (2,'Asian Hope','Japan','2018-05-01'); INSERT INTO campaigns (id,name,country,start_date) VALUES (3,'Positive Vibes','India','2015-12-31'); | SELECT name FROM campaigns WHERE country = 'Asia' AND start_date > '2015-12-31'; |
What is the total budget for support programs in the 'IT' department? | CREATE TABLE support_programs (id INT,program_name VARCHAR(50),budget INT,department VARCHAR(50)); INSERT INTO support_programs (id,program_name,budget,department) VALUES (1,'Mentorship Program',10000,'Education'),(2,'Tutoring Program',15000,'Education'),(3,'Accessibility Improvements',25000,'IT'); | SELECT SUM(support_programs.budget) AS total_budget FROM support_programs WHERE support_programs.department = 'IT'; |
List all the renewable energy sources used by manufacturers in the North America region | CREATE TABLE Manufacturers (manufacturer_id INT,manufacturer_name VARCHAR(50),region VARCHAR(50),renewable_energy_source VARCHAR(50)); INSERT INTO Manufacturers (manufacturer_id,manufacturer_name,region,renewable_energy_source) VALUES (1,'ManufacturerA','North America','Solar'),(2,'ManufacturerB','Europe','Wind'),(3,'ManufacturerC','North America','Hydro'); | SELECT manufacturer_name, renewable_energy_source FROM Manufacturers WHERE region = 'North America'; |
Delete the donation with ID 2. | CREATE TABLE Donations (DonationID INT,DonorID INT,Amount DECIMAL,DonationDate DATE); INSERT INTO Donations (DonationID,DonorID,Amount,DonationDate) VALUES (1,1,50.00,'2021-01-01'); INSERT INTO Donations (DonationID,DonorID,Amount,DonationDate) VALUES (2,1,75.00,'2021-03-15'); INSERT INTO Donations (DonationID,DonorID,Amount,DonationDate) VALUES (3,2,100.00,'2021-12-31'); | DELETE FROM Donations WHERE DonationID = 2; |
What is the total weight of each cargo type in the 'cargo_tracking' table? | CREATE TABLE cargo_tracking (cargo_id INT,cargo_type VARCHAR(50),weight FLOAT); INSERT INTO cargo_tracking (cargo_id,cargo_type,weight) VALUES (1,'CargoType1',5000),(2,'CargoType2',7000),(3,'CargoType3',6000); | SELECT cargo_type, SUM(weight) as total_weight FROM cargo_tracking GROUP BY cargo_type; |
What is the total revenue for each product category in the product_category_sales table? | CREATE TABLE product_categories (category_id INT,category_name VARCHAR(50)); CREATE TABLE product_sales (product_id INT,category_id INT,sales_amount DECIMAL(5,2)); INSERT INTO product_categories (category_id,category_name) VALUES (1,'Clothing'),(2,'Footwear'); INSERT INTO product_sales (product_id,category_id,sales_amount) VALUES (1,1,500.00),(2,1,300.00),(3,2,700.00); | SELECT pc.category_name, SUM(ps.sales_amount) FROM product_categories pc INNER JOIN product_sales ps ON pc.category_id = ps.category_id GROUP BY pc.category_name; |
How many garments were produced per country in 2021? | CREATE TABLE garment_production (production_id INT,country VARCHAR(50),garment_type VARCHAR(50),production_date DATE,quantity INT); | SELECT country, SUM(quantity) FROM garment_production WHERE production_date BETWEEN '2021-01-01' AND '2021-12-31' GROUP BY country; |
Which conservation initiatives were implemented in regions with increasing contaminant levels in 2019? | CREATE TABLE water_quality (region VARCHAR(255),year INT,contaminant_level INT); INSERT INTO water_quality (region,year,contaminant_level) VALUES ('North',2018,10),('North',2019,12),('North',2020,15),('South',2018,15),('South',2019,18),('South',2020,20); CREATE TABLE conservation_initiatives (region VARCHAR(255),year INT,initiative VARCHAR(255)); INSERT INTO conservation_initiatives (region,year,initiative) VALUES ('North',2018,'Rainwater harvesting'),('North',2019,'Greywater reuse'),('North',2020,'Smart toilets'),('South',2018,'Permeable pavements'),('South',2019,'Smart irrigation'),('South',2020,'Green roofs'); | SELECT c.initiative FROM conservation_initiatives c JOIN water_quality w ON c.region = w.region WHERE c.year = w.year AND w.contaminant_level > (SELECT contaminant_level FROM water_quality WHERE region = w.region AND year = w.year - 1); |
How many cultural competency trainings were conducted in California? | CREATE TABLE cultural_competency_trainings (training_id INT,location VARCHAR(50),date DATE); INSERT INTO cultural_competency_trainings (training_id,location,date) VALUES (1,'Los Angeles,CA','2022-01-01'),(2,'San Diego,CA','2022-02-01'),(3,'San Francisco,CA','2022-03-01'); | SELECT COUNT(*) FROM cultural_competency_trainings WHERE location LIKE '%CA%'; |
What is the minimum water salinity level for all shrimp farms in Thailand? | CREATE TABLE shrimp_farms (id INT,name TEXT,country TEXT,salinity FLOAT); INSERT INTO shrimp_farms (id,name,country,salinity) VALUES (1,'Farm M','Thailand',30.5); INSERT INTO shrimp_farms (id,name,country,salinity) VALUES (2,'Farm N','Thailand',32.1); INSERT INTO shrimp_farms (id,name,country,salinity) VALUES (3,'Farm O','Thailand',29.8); | SELECT MIN(salinity) FROM shrimp_farms WHERE country = 'Thailand'; |
How many units of each product were sold in the last month, by supplier? | CREATE TABLE sales (sale_date DATE,supplier VARCHAR(255),product VARCHAR(255),quantity INT); | SELECT supplier, product, SUM(quantity) AS qty_sold, DATE_TRUNC('month', sale_date) AS sale_month FROM sales WHERE sale_date >= DATE_TRUNC('month', CURRENT_DATE - INTERVAL '1 month') GROUP BY supplier, product, sale_month; |
What is the average installation cost of electric vehicle charging stations in the UK? | CREATE TABLE ev_charging_stations (id INT,station_type VARCHAR(50),installation_cost FLOAT,country VARCHAR(50)); INSERT INTO ev_charging_stations (id,station_type,installation_cost,country) VALUES (1,'Level 1',1200,'USA'),(2,'Level 2',2500,'UK'),(3,'DC Fast Charger',40000,'Japan'),(4,'Tesla Supercharger',50000,'USA'); | SELECT AVG(installation_cost) FROM ev_charging_stations WHERE country = 'UK'; |
How many products are made in each country? | CREATE TABLE products (product_id INT,product_name TEXT,price DECIMAL(5,2),country TEXT); INSERT INTO products (product_id,product_name,price,country) VALUES (1,'T-Shirt',20.99,'Italy'); INSERT INTO products (product_id,product_name,price,country) VALUES (2,'Jeans',50.49,'France'); INSERT INTO products (product_id,product_name,price,country) VALUES (3,'Shoes',75.99,'Italy'); INSERT INTO products (product_id,product_name,price,country) VALUES (4,'Hat',15.99,'Germany'); | SELECT country, COUNT(*) FROM products GROUP BY country; |
List the names of the precision farming equipment vendors that have more than 15 products in the European market. | CREATE TABLE farming_equipment_vendors (id INT,vendor VARCHAR(255),region VARCHAR(255),product_count INT); INSERT INTO farming_equipment_vendors (id,vendor,region,product_count) VALUES (6,'EU GreenTech','Europe',16),(7,'AgriEase','North America',10),(8,'PrecisionPlus','Europe',22),(9,'FarmMate','Asia',8); | SELECT vendor FROM farming_equipment_vendors WHERE region = 'Europe' AND product_count > 15; |
What is the total cost of sustainable building materials for projects that started in 2021 and lasted more than 3 months? | CREATE TABLE Projects (project_id INT,start_date DATE,end_date DATE,material_cost FLOAT); INSERT INTO Projects (project_id,start_date,end_date,material_cost) VALUES (1,'2021-01-01','2021-03-31',7000),(2,'2021-01-01','2021-04-15',9000),(3,'2022-01-01','2022-03-31',8000); | SELECT SUM(material_cost) FROM Projects WHERE start_date < end_date AND start_date >= '2021-01-01' AND end_date < '2022-01-01' AND material_cost > 0; |
What is the total number of visitors from African countries who engaged with | CREATE TABLE CommunityEngagement (id INT,country VARCHAR(50),year INT,num_visitors INT); | SELECT SUM(num_visitors) FROM CommunityEngagement WHERE country IN (SELECT name FROM Countries WHERE continent = 'Africa') AND year = 2022; |
What is the historical context of excavation sites with the highest number of lithic artifacts? | CREATE TABLE Sites (SiteID int,SiteName varchar(50)); INSERT INTO Sites VALUES (1,'Site A'),(2,'Site B'); CREATE TABLE Artifacts (ArtifactID int,SiteID int,ArtifactType varchar(50),Quantity int); INSERT INTO Artifacts VALUES (1,1,'Lithic',120),(2,1,'Ceramic',30),(3,2,'Lithic',150),(4,2,'Ceramic',50); CREATE TABLE HistoricalContext (SiteID int,HistoricalPeriod varchar(50)); INSERT INTO HistoricalContext VALUES (1,'Mesolithic'),(2,'Neolithic'); | SELECT Sites.SiteName, HistoricalContext.HistoricalPeriod FROM (SELECT Sites.SiteName, SUM(Artifacts.Quantity) as TotalLithics FROM Artifacts INNER JOIN Sites ON Artifacts.SiteID = Sites.SiteID WHERE ArtifactType = 'Lithic' GROUP BY Sites.SiteName ORDER BY TotalLithics DESC LIMIT 1) as Subquery INNER JOIN Sites ON Subquery.SiteName = Sites.SiteName INNER JOIN HistoricalContext ON Sites.SiteID = HistoricalContext.SiteID; |
What is the average age of therapists specializing in CBT? | CREATE TABLE therapists (id INT PRIMARY KEY,age INT,gender TEXT,specialty TEXT); INSERT INTO therapists (id,age,gender,specialty) VALUES (1,45,'Female','CBT'); INSERT INTO therapists (id,age,gender,specialty) VALUES (2,50,'Male','DBT'); | SELECT AVG(age) FROM therapists WHERE specialty = 'CBT'; |
What is the maximum salary for male reporters in the 'reporters' table? | CREATE TABLE reporters (id INT,gender VARCHAR(255),salary DECIMAL(10,2)); INSERT INTO reporters (id,gender,salary) VALUES (1,'Male',90000.00),(2,'Female',80000.00),(3,'Male',85000.00) | SELECT MAX(salary) FROM reporters WHERE gender = 'Male'; |
Which policyholders have a coverage limit over $500,000? Update their records with a new category 'High Limit'. | CREATE TABLE Policyholders (PolicyID INT,Name VARCHAR(50),CoverageLimit DECIMAL(10,2)); INSERT INTO Policyholders (PolicyID,Name,CoverageLimit) VALUES (1,'John Doe',750000.00),(2,'Jane Smith',400000.00); | WITH UpdatedLimits AS (UPDATE Policyholders SET Category = 'High Limit' WHERE CoverageLimit > 500000 RETURNING *) SELECT * FROM UpdatedLimits; |
What are the products made by women-owned suppliers? | CREATE TABLE suppliers (id INT PRIMARY KEY,name TEXT,gender TEXT,sustainable_practices BOOLEAN); CREATE TABLE products (id INT PRIMARY KEY,name TEXT,supplier_id INT,FOREIGN KEY (supplier_id) REFERENCES suppliers(id)); | SELECT products.name, suppliers.name AS supplier_name FROM products INNER JOIN suppliers ON products.supplier_id = suppliers.id WHERE suppliers.gender = 'female'; |
What is the average response time for emergency calls on weekends? | CREATE TABLE emergencies (eid INT,call_time TIME,response_time INT); | SELECT AVG(response_time) FROM emergencies WHERE DAYOFWEEK(call_time) IN (1, 7); |
Create a view for teacher professional development types | CREATE TABLE TeacherProfessionalDevelopment (TeacherID INT,DevelopmentType VARCHAR(50),StartDate DATE,EndDate DATE); INSERT INTO TeacherProfessionalDevelopment (TeacherID,DevelopmentType,StartDate,EndDate) VALUES (1,'Workshop','2022-03-01','2022-03-03'),(2,'Conference','2022-04-01','2022-04-05'),(3,'Online Course','2022-02-01','2022-03-31'); | CREATE VIEW DevelopmentTypes AS SELECT DISTINCT DevelopmentType FROM TeacherProfessionalDevelopment; |
What is the total distance traveled by autonomous vehicles in CityC? | CREATE TABLE CityC_VehicleMovement (vehicle_id INT,vehicle_type VARCHAR(20),is_autonomous BOOLEAN,distance FLOAT); INSERT INTO CityC_VehicleMovement (vehicle_id,vehicle_type,is_autonomous,distance) VALUES (1,'Car',true,56.2),(2,'Bike',false,12.4),(3,'Car',false,34.6),(4,'Bus',true,78.9); | SELECT SUM(distance) FROM CityC_VehicleMovement WHERE is_autonomous = true; |
What is the average carbon sequestration per hectare for each country in 2020? | CREATE TABLE carbon_sequestration (id INT,country VARCHAR(255),year INT,sequestration FLOAT,hectares FLOAT); INSERT INTO carbon_sequestration (id,country,year,sequestration,hectares) VALUES (1,'Canada',2018,1000.2,12000000.5),(2,'Australia',2019,1100.1,15000000.3),(3,'Brazil',2018,1300.0,20000000.7),(4,'Indonesia',2019,1500.0,17500000.6),(5,'USA',2020,1200.8,13000000.8),(6,'Canada',2020,1150.9,14000000.9),(7,'Australia',2020,1400.0,15000000.0); | SELECT country, AVG(sequestration/hectares) as avg_sequestration FROM carbon_sequestration WHERE year = 2020 GROUP BY country; |
What are the sales figures for a specific drug category in Q2 2021? | CREATE TABLE drug_sales_category(drug_category VARCHAR(255),sale_date DATE,amount DECIMAL(10,2)); INSERT INTO drug_sales_category(drug_category,sale_date,amount) VALUES ('Analgesics','2021-04-01',1000),('Analgesics','2021-04-15',1500),('Antidepressants','2021-04-01',2000),('Antidepressants','2021-04-15',2500); | SELECT drug_category, SUM(amount) as total_sales FROM drug_sales_category WHERE sale_date BETWEEN '2021-04-01' AND '2021-06-30' GROUP BY drug_category; |
What is the maximum gas limit set for transactions involving the smart contract with the address '0x8901234567890123456789012345678901234567' on the Fantom Opera network? | CREATE TABLE ftm_transactions (transaction_id INT,to_address VARCHAR(42),gas_limit INT,timestamp BIGINT); | SELECT MAX(gas_limit) FROM ftm_transactions WHERE to_address = '0x8901234567890123456789012345678901234567'; |
How many donations were made in the first half of 2021? | CREATE TABLE Donations (donation_id INT,donation_amount FLOAT,donation_date DATE); INSERT INTO Donations (donation_id,donation_amount,donation_date) VALUES (1,500.00,'2021-01-01'),(2,300.00,'2021-01-15'),(3,400.00,'2021-02-20'),(4,250.00,'2021-03-10'),(5,600.00,'2021-03-15'),(6,100.00,'2021-07-04'); | SELECT COUNT(*) FROM Donations WHERE YEAR(donation_date) = 2021 AND MONTH(donation_date) <= 6; |
Which countries have participated in the most military innovation collaborations in the last 2 decades, along with the number of collaborations? | CREATE TABLE MilitaryCollaborations (ID INT,CollaborationName TEXT,CollaborationDate DATE,Country1 TEXT,Country2 TEXT); INSERT INTO MilitaryCollaborations VALUES (1,'Collaboration 1','2003-01-01','USA','UK'); CREATE VIEW FrequentCollaborators AS SELECT Country1 as Country FROM MilitaryCollaborations UNION SELECT Country2 as Country FROM MilitaryCollaborations; | SELECT fc.Country, COUNT(*) as CollaborationCount FROM FrequentCollaborators fc JOIN MilitaryCollaborations mc ON fc.Country = mc.Country1 OR fc.Country = mc.Country2 WHERE mc.CollaborationDate BETWEEN DATEADD(year, -20, GETDATE()) AND GETDATE() GROUP BY fc.Country ORDER BY CollaborationCount DESC; |
Identify the number of vessels in the Mediterranean Sea with safety records exceeding 95% in the last 5 years. | CREATE TABLE Vessels (id INT,name VARCHAR(50),country VARCHAR(50)); CREATE TABLE SafetyRecords (id INT,vessel_id INT,safety_score DECIMAL(3,2),year INT); | SELECT COUNT(DISTINCT V.id) FROM Vessels V JOIN SafetyRecords SR ON V.id = SR.vessel_id WHERE SR.safety_score > 0.95 AND SR.year BETWEEN (YEAR(NOW()) - 5) AND YEAR(NOW()) AND V.latitude BETWEEN 30 AND 45 AND V.longitude BETWEEN -20 AND 45; |
What is the total quantity of vegan items sold per store? | CREATE TABLE Stores (StoreID INT,StoreName VARCHAR(50)); INSERT INTO Stores (StoreID,StoreName) VALUES (1,'Store A'),(2,'Store B'); CREATE TABLE Menu (MenuID INT,MenuItem VARCHAR(50),Type VARCHAR(20),StoreID INT); INSERT INTO Menu (MenuID,MenuItem,Type,StoreID) VALUES (1,'Falafel','Vegetarian',1),(2,'Chicken Shawarma','Non-Vegetarian',1),(3,'Vegetable Curry','Vegan',2),(4,'Steak Platter','Non-Vegetarian',2); CREATE TABLE Sales (SaleID INT,MenuID INT,Quantity INT,OrderDate DATE); INSERT INTO Sales (SaleID,MenuID,Quantity,OrderDate) VALUES (1,1,25,'2022-01-01'),(2,2,15,'2022-01-01'),(3,3,30,'2022-01-02'),(4,4,10,'2022-01-02'); | SELECT StoreID, SUM(Quantity) as TotalQuantity FROM Sales s JOIN Menu m ON s.MenuID = m.MenuID WHERE Type = 'Vegan' GROUP BY StoreID; |
List financial capability programs in Indonesia, ordered by start date. | CREATE TABLE financial_capability_programs (program_id INT,country VARCHAR,start_date DATE); INSERT INTO financial_capability_programs (program_id,country,start_date) VALUES (1,'Indonesia','2021-05-01'); INSERT INTO financial_capability_programs (program_id,country,start_date) VALUES (2,'Indonesia','2022-02-15'); | SELECT * FROM financial_capability_programs WHERE country = 'Indonesia' ORDER BY start_date; |
What are the top 3 military technologies by spending in the last 3 years, and which countries have invested the most in them? | CREATE TABLE military_tech (id INT,tech VARCHAR(50),country VARCHAR(50),year INT,spending INT); INSERT INTO military_tech (id,tech,country,year,spending) VALUES (1,'Drones','USA',2019,5000000),(2,'Cybersecurity','USA',2019,7000000),(3,'Artificial Intelligence','USA',2019,8000000),(4,'Drones','China',2019,4000000),(5,'Cybersecurity','China',2019,6000000),(6,'Artificial Intelligence','China',2019,7000000),(7,'Drones','Russia',2019,3000000),(8,'Cybersecurity','Russia',2019,4000000),(9,'Artificial Intelligence','Russia',2019,5000000); | SELECT tech, country, SUM(spending) as total_spending FROM military_tech WHERE year BETWEEN 2019 AND 2021 GROUP BY tech, country HAVING COUNT(*) >= 3 ORDER BY total_spending DESC; |
How many news stories have been published in each department in the "news_reporters" table? | CREATE TABLE news_reporters (id INT,name VARCHAR(50),gender VARCHAR(10),age INT,department VARCHAR(30)); CREATE TABLE news_stories (id INT,title VARCHAR(100),content TEXT,reporter_id INT,department VARCHAR(30)); | SELECT news_reporters.department, COUNT(news_stories.id) FROM news_reporters INNER JOIN news_stories ON news_reporters.department = news_stories.department GROUP BY news_reporters.department; |
Update the industry for "SmartEco" to "Green Technology" | CREATE TABLE company (id INT PRIMARY KEY AUTO_INCREMENT,name VARCHAR(255),industry VARCHAR(255),founding_date DATE); | UPDATE company SET industry = 'Green Technology' WHERE name = 'SmartEco'; |
List the products that have the highest sales quantity in each category. | CREATE TABLE product_categories (id INT,product_id INT,category VARCHAR(255)); INSERT INTO product_categories (id,product_id,category) VALUES (1,1,'Electronics'),(2,2,'Clothing'),(3,3,'Home Appliances'); CREATE TABLE sales (id INT,product_id INT,sale_date DATE,quantity_sold INT); INSERT INTO sales (id,product_id,sale_date,quantity_sold) VALUES (1,1,'2022-03-01',50),(2,2,'2022-03-02',75),(3,3,'2022-03-03',100); CREATE TABLE products (id INT,name VARCHAR(255),category VARCHAR(255)); INSERT INTO products (id,name,category) VALUES (1,'Product X','Electronics'),(2,'Product Y','Clothing'),(3,'Product Z','Home Appliances'); | SELECT p.name, p.category, MAX(s.quantity_sold) as max_quantity_sold FROM products p JOIN product_categories pc ON p.id = pc.product_id JOIN sales s ON pc.product_id = s.product_id GROUP BY p.name, p.category; |
List all security incidents in the North America region from the last quarter. | CREATE TABLE incidents (id INT,region TEXT,incident_date DATE); INSERT INTO incidents (id,region,incident_date) VALUES (1,'North America','2021-08-15'); INSERT INTO incidents (id,region,incident_date) VALUES (2,'Europe','2021-09-20'); INSERT INTO incidents (id,region,incident_date) VALUES (3,'North America','2021-11-01'); | SELECT * FROM incidents WHERE region = 'North America' AND incident_date >= DATE_SUB(CURDATE(), INTERVAL 3 MONTH); |
What is the trend of Europium price from 2016 to 2020? | CREATE TABLE Europium_Price (year INT,price FLOAT); INSERT INTO Europium_Price (year,price) VALUES (2015,300),(2016,320),(2017,340),(2018,360),(2019,380),(2020,400); | SELECT year, price FROM Europium_Price WHERE year BETWEEN 2016 AND 2020; |
What is the average smart city technology adoption budget per city in Asia? | CREATE TABLE smart_city_projects (project_id INT,city VARCHAR(50),annual_budget FLOAT); INSERT INTO smart_city_projects (project_id,city,annual_budget) VALUES (1,'Tokyo',15000000),(2,'Seoul',18000000),(3,'Hong Kong',12000000),(4,'Shanghai',16000000); | SELECT AVG(annual_budget) FROM (SELECT DISTINCT annual_budget FROM smart_city_projects WHERE city IN ('Tokyo', 'Seoul', 'Hong Kong', 'Shanghai') ORDER BY annual_budget) |
What is the total biomass of fish in farms in the Latin America region for each species? | CREATE TABLE farm_regions (farm_id INT,biomass FLOAT,region VARCHAR(50)); INSERT INTO farm_regions (farm_id,biomass,region) VALUES (1,250.3,'Latin America'),(2,320.5,'Latin America'),(3,180.7,'Latin America'),(4,450.9,'Latin America'),(5,220.1,'Latin America'),(6,370.2,'Latin America'); CREATE TABLE species_farms (farm_id INT,species VARCHAR(50)); INSERT INTO species_farms (farm_id,species) VALUES (1,'Salmon'),(2,'Tilapia'),(3,'Carp'),(4,'Salmon'),(5,'Tuna'),(6,'Cod'); | SELECT species, SUM(biomass) FROM farm_regions JOIN species_farms ON farm_regions.farm_id = species_farms.farm_id WHERE region = 'Latin America' GROUP BY species; |
Identify the policyholder with the most claims in California. | CREATE TABLE claims (claim_id INT,policyholder_id INT,claim_amount DECIMAL(10,2),claim_date DATE); INSERT INTO claims (claim_id,policyholder_id,claim_amount,claim_date) VALUES (1,3,500.00,'2022-01-01'); INSERT INTO claims (claim_id,policyholder_id,claim_amount,claim_date) VALUES (2,3,750.00,'2022-02-01'); INSERT INTO claims (claim_id,policyholder_id,claim_amount,claim_date) VALUES (3,4,250.00,'2022-03-01'); | SELECT policyholder_id, COUNT(*) as total_claims FROM claims WHERE state = 'California' GROUP BY policyholder_id ORDER BY total_claims DESC LIMIT 1; |
Which cruelty-free skincare products have the highest sales quantity? | CREATE TABLE Transparency (transparency_id INT,product_id INT,is_cruelty_free BOOLEAN); INSERT INTO Transparency (transparency_id,product_id,is_cruelty_free) VALUES (1,1,TRUE); CREATE TABLE Sales (sales_id INT,product_id INT,quantity INT,sales_date DATE); INSERT INTO Sales (sales_id,product_id,quantity,sales_date) VALUES (1,1,50,'2022-01-01'); | SELECT Product.product_name, SUM(Sales.quantity) as total_quantity FROM Product INNER JOIN Transparency ON Product.product_id = Transparency.product_id INNER JOIN Sales ON Product.product_id = Sales.product_id WHERE Transparency.is_cruelty_free = TRUE AND Product.category = 'Skincare' GROUP BY Product.product_name ORDER BY total_quantity DESC LIMIT 1; |
Update the 'operator' column to 'BC Hydro' for all records in the 'charging_stations' table where 'city' is 'Vancouver' | CREATE TABLE charging_stations (id INT,city VARCHAR(20),operator VARCHAR(20),num_chargers INT,open_date DATE); | UPDATE charging_stations SET operator = 'BC Hydro' WHERE city = 'Vancouver'; |
What is the average depth of ocean floor mapping project sites in the 'MarineLife' schema? | CREATE SCHEMA MarineLife; CREATE TABLE OceanFloorMapping (site_id INT,depth FLOAT); INSERT INTO OceanFloorMapping (site_id,depth) VALUES (1,3456.2),(2,1234.5),(3,5678.9); | SELECT AVG(depth) FROM MarineLife.OceanFloorMapping; |
How many public libraries were there in urban areas in 2019? | CREATE TABLE Library(Year INT,Location VARCHAR(10),Number INT); INSERT INTO Library VALUES (2018,'Urban',15),(2018,'Rural',5),(2019,'Urban',18),(2019,'Rural',4),(2020,'Urban',20),(2020,'Rural',3); | SELECT SUM(Number) FROM Library WHERE Year = 2019 AND Location = 'Urban'; |
What is the average rating for halal cosmetics in the Australian market? | CREATE TABLE product_reviews (product_id INT,is_halal BOOLEAN,market VARCHAR(10),rating INT); INSERT INTO product_reviews (product_id,is_halal,market,rating) VALUES (1,true,'AU',4),(2,false,'CA',3),(3,true,'AU',5); | SELECT AVG(rating) FROM product_reviews pr WHERE pr.is_halal = true AND pr.market = 'AU'; |
What is the percentage of players who prefer mobile games? | CREATE TABLE PlayerDemographics (PlayerID INT,GamePlatform VARCHAR(10)); INSERT INTO PlayerDemographics (PlayerID,GamePlatform) VALUES (1,'Mobile'),(2,'PC'),(3,'Mobile'),(4,'Console'); | SELECT (COUNT(*) FILTER(WHERE GamePlatform = 'Mobile') * 100.0 / COUNT(*)) AS Percentage FROM PlayerDemographics; |
Find the total quantity of sustainable materials used by factories owned by a specific company. | CREATE TABLE Factories (FactoryID INT,Company VARCHAR(50),Location VARCHAR(50)); CREATE TABLE Production (ProductionID INT,FactoryID INT,Material VARCHAR(50),Quantity INT,Price DECIMAL(5,2)); INSERT INTO Factories VALUES (1,'Green Enterprises','Country A'),(2,'Green Enterprises','Country B'),(3,'Another Company','Country C'); INSERT INTO Production VALUES (1,1,'Eco-Friendly Material',100,20.50),(2,1,'Eco-Friendly Material',150,22.00),(3,2,'Eco-Friendly Material',200,18.75),(4,3,'Regular Material',50,15.00); | SELECT SUM(Quantity) FROM Production p JOIN Factories f ON p.FactoryID = f.FactoryID WHERE f.Company = 'Green Enterprises' AND Material IN ('Eco-Friendly Material', 'Sustainable Material'); |
What is the total number of workers in each country, and the average age of those workers? | CREATE TABLE workers (id INT PRIMARY KEY,name VARCHAR(255),age INT,gender VARCHAR(50),country VARCHAR(255),skill_level VARCHAR(50)); INSERT INTO workers (id,name,age,gender,country,skill_level) VALUES (1,'John Doe',30,'Male','USA','Expert'),(2,'Jane Doe',25,'Female','Mexico','Intermediate'),(3,'Alex Nguyen',35,'Non-binary','Vietnam','Expert'); | SELECT country, COUNT(*) as total_workers, AVG(age) as avg_age FROM workers GROUP BY country; |
Create a view named 'high_traffic_stations' containing stations with more than 1000 entries in the 'entries' table | CREATE TABLE stations (station_id INT,name VARCHAR(255),latitude DECIMAL(9,6),longitude DECIMAL(9,6)); CREATE TABLE entries (station_id INT,entry_time TIMESTAMP); | CREATE VIEW high_traffic_stations AS SELECT s.station_id, s.name FROM stations s JOIN entries e ON s.station_id = e.station_id GROUP BY s.station_id, s.name HAVING COUNT(e.entry_time) > 1000; |
What is the number of military equipment maintenance requests in Germany in 2020? | CREATE TABLE military_equipment_requests (id INT,country VARCHAR(50),year INT,request_count INT); INSERT INTO military_equipment_requests (id,country,year,request_count) VALUES (1,'Germany',2020,150); INSERT INTO military_equipment_requests (id,country,year,request_count) VALUES (2,'Germany',2020,160); INSERT INTO military_equipment_requests (id,country,year,request_count) VALUES (3,'Germany',2019,140); INSERT INTO military_equipment_requests (id,country,year,request_count) VALUES (4,'Germany',2019,130); | SELECT SUM(request_count) FROM military_equipment_requests WHERE country = 'Germany' AND year = 2020; |
List the top three hospitals with the highest number of COVID-19 admissions in California in 2021. | CREATE TABLE public.hospitals (id SERIAL PRIMARY KEY,name TEXT,location TEXT); INSERT INTO public.hospitals (name,location) VALUES ('General Hospital','California'),('Children''s Hospital','California'),('Mountain View Hospital','California'); CREATE TABLE public.admissions (id SERIAL PRIMARY KEY,hospital TEXT,diagnosis TEXT,admission_date DATE); INSERT INTO public.admissions (hospital,diagnosis,admission_date) VALUES ('General Hospital','COVID-19','2021-01-01'),('Children''s Hospital','COVID-19','2021-02-01'),('Mountain View Hospital','COVID-19','2021-03-01'),('General Hospital','COVID-19','2021-04-01'),('Children''s Hospital','COVID-19','2021-05-01'),('General Hospital','COVID-19','2021-06-01'); | SELECT a.hospital, COUNT(*) FROM public.admissions a JOIN public.hospitals h ON a.hospital = h.name WHERE a.diagnosis = 'COVID-19' AND h.location = 'California' GROUP BY a.hospital ORDER BY COUNT(*) DESC LIMIT 3; |
How many community policing events were held in each city in 2021? | CREATE TABLE cities (id INT,name TEXT);CREATE TABLE policing_events (id INT,city_id INT,year INT,type TEXT); | SELECT c.name, COUNT(pe.id) FROM cities c JOIN policing_events pe ON c.id = pe.city_id WHERE pe.year = 2021 GROUP BY c.id; |
Identify the top 2 cities with the highest number of arts education programs funded by 'Arts Foundation' in 2021 and 2022. | CREATE TABLE EducationPrograms (program_id INT,city VARCHAR(20),funding_source VARCHAR(20),year INT); INSERT INTO EducationPrograms (program_id,city,funding_source,year) VALUES (1,'New York','Cultural Trust',2021),(2,'Miami','Cultural Trust',2021),(3,'Chicago','Cultural Trust',2021),(4,'New York','Arts Foundation',2021),(5,'Atlanta','City Grants',2022),(6,'New York','Arts Foundation',2022); | SELECT city, COUNT(*) as program_count FROM EducationPrograms WHERE funding_source = 'Arts Foundation' AND year IN (2021, 2022) GROUP BY city ORDER BY program_count DESC LIMIT 2 |
Insert a new virtual tour into the "virtual_tours" table for 'Tokyo' with an ID of 23, a description of 'A virtual tour of the Tokyo Skytree', and a price of 20.50 | CREATE TABLE virtual_tours (tour_id INT,location VARCHAR(50),description TEXT,price DECIMAL(5,2)); | INSERT INTO virtual_tours (tour_id, location, description, price) VALUES (23, 'Tokyo', 'A virtual tour of the Tokyo Skytree', 20.50); |
How many unique customers prefer halal products with a rating of 3 or higher in the United Kingdom? | CREATE TABLE CustomerPreferences (customer_id INT,product_id INT,preference_rating INT,is_halal BOOLEAN,country VARCHAR(50)); INSERT INTO CustomerPreferences (customer_id,product_id,preference_rating,is_halal,country) VALUES (3,3,5,true,'United Kingdom'); | SELECT COUNT(DISTINCT customer_id) as unique_customers FROM CustomerPreferences WHERE preference_rating >= 3 AND is_halal = true AND country = 'United Kingdom'; |
What was the average cost of spacecraft manufactured by companies in Europe? | CREATE TABLE SpacecraftManufacturing (id INT,company VARCHAR(255),cost INT,country VARCHAR(255)); | SELECT AVG(cost) FROM SpacecraftManufacturing WHERE country IN ('Germany', 'France', 'UK', 'Italy', 'Spain'); |
What is the average number of military personnel for each country involved in peacekeeping operations? | CREATE SCHEMA if not exists defense; CREATE TABLE if not exists peacekeeping_operations (id INT PRIMARY KEY,country VARCHAR(50),military_personnel INT); INSERT INTO peacekeeping_operations (id,country,military_personnel) VALUES (1,'Brazil',1200),(2,'USA',2500),(3,'Egypt',1800),(4,'India',3000); | SELECT AVG(military_personnel) FROM defense.peacekeeping_operations GROUP BY country; |
Find the community policing officers with the highest and lowest attendance? | CREATE TABLE community_policing (id INT,officer_id INT,event_type VARCHAR(255),attendance INT,timestamp TIMESTAMP); INSERT INTO community_policing (id,officer_id,event_type,attendance,timestamp) VALUES (1,30,'Neighborhood Watch',20,'2021-01-03 14:00:00'); INSERT INTO community_policing (id,officer_id,event_type,attendance,timestamp) VALUES (2,31,'Community Meeting',15,'2021-01-04 09:30:00'); | SELECT officer_id, MIN(attendance) as lowest, MAX(attendance) as highest FROM community_policing GROUP BY officer_id; |
What is the average landfill capacity in 2019 and 2020? | CREATE TABLE landfill_capacity(year INT,landfill VARCHAR(255),capacity INT); INSERT INTO landfill_capacity VALUES (2018,'Landfill A',100000),(2018,'Landfill B',150000),(2018,'Landfill C',200000),(2019,'Landfill A',110000),(2019,'Landfill B',155000),(2019,'Landfill C',210000),(2020,'Landfill A',120000),(2020,'Landfill B',160000),(2020,'Landfill C',220000); | SELECT AVG(capacity) FROM landfill_capacity WHERE year IN (2019, 2020); |
What's the average investment in socially responsible companies for each investor? | CREATE TABLE investments (id INT,investor_id INT,company_id INT,invested_amount FLOAT); CREATE TABLE companies (id INT,socially_responsible BOOLEAN); INSERT INTO investments (id,investor_id,company_id,invested_amount) VALUES (1,1,2,5000),(2,1,3,8000),(3,2,1,7000),(4,3,3,6000); INSERT INTO companies (id,socially_responsible) VALUES (1,true),(2,true),(3,true); | SELECT i.investor_id, AVG(i.invested_amount) as avg_investment FROM investments i JOIN companies c ON i.company_id = c.id WHERE c.socially_responsible = true GROUP BY i.investor_id; |
How many drought assessments were conducted in 'DroughtAssessments' table? | CREATE TABLE DroughtAssessments (assessment_id INT,region VARCHAR(20),drought_severity VARCHAR(20)); INSERT INTO DroughtAssessments (assessment_id,region,drought_severity) VALUES (1,'RegionA','Moderate'),(2,'RegionB','Severe'),(3,'RegionC','Critical'); | SELECT COUNT(assessment_id) FROM DroughtAssessments; |
What is the average amount of fines given by each police station in London? | CREATE TABLE police_stations (id INT,name TEXT,city TEXT,avg_fines FLOAT); INSERT INTO police_stations (id,name,city,avg_fines) VALUES (1,'West End Police','London',500.0),(2,'Croydon Police','London',400.0); | SELECT name, AVG(avg_fines) as avg_fines FROM police_stations GROUP BY name; |
Which aquatic species have health metrics above the average? | CREATE TABLE health_metrics (id INT,species VARCHAR(50),metric FLOAT); INSERT INTO health_metrics (id,species,metric) VALUES (1,'Tilapia',75.0),(2,'Catfish',80.0),(3,'Salmon',60.0); | SELECT species FROM health_metrics WHERE metric > (SELECT AVG(metric) FROM health_metrics); |
What was the minimum number of hours served by a volunteer in 'New Mexico' in the year 2022? | CREATE TABLE Volunteers (volunteer_id INT,state VARCHAR(20),total_hours INT,volunteer_year INT); INSERT INTO Volunteers (volunteer_id,state,total_hours,volunteer_year) VALUES (1,'New Mexico',15,2022),(2,'New Mexico',20,2022); | SELECT MIN(total_hours) FROM Volunteers WHERE state = 'New Mexico' AND volunteer_year = 2022; |
What is the total fare collected from the 'Red Line' on June 1st, 2022? | CREATE TABLE route (route_id INT,route_name VARCHAR(50)); INSERT INTO route (route_id,route_name) VALUES (1,'Red Line'); CREATE TABLE fare (fare_id INT,route_id INT,fare_amount DECIMAL(5,2),collection_date DATE); INSERT INTO fare (fare_id,route_id,fare_amount,collection_date) VALUES (1,1,3.50,'2022-06-01'),(2,1,3.50,'2022-06-01'),(3,1,3.25,'2022-06-01'); | SELECT SUM(fare_amount) FROM fare WHERE route_id = 1 AND collection_date = '2022-06-01'; |
Calculate the percentage of employees in each department who are recent college graduates. | CREATE TABLE Employees (EmployeeID int,Department varchar(20),Degree varchar(50),GraduationYear int); INSERT INTO Employees (EmployeeID,Department,Degree,GraduationYear) VALUES (1,'IT','BS in Computer Science',2021),(2,'IT','MS in Computer Science',2019),(3,'Sales','BA in Marketing',2018),(4,'Sales','BS in Business Administration',2020),(5,'Sales','BA in Marketing',2021); | SELECT e.Department, ROUND(COUNT(CASE WHEN e.GraduationYear >= YEAR(CURRENT_DATE) - 2 THEN 1 END) * 100.0 / COUNT(*), 1) AS Percent_Recent_Grads FROM Employees e GROUP BY e.Department; |
Which renewable energy sources are available in Spain and their corresponding capacities? | CREATE TABLE renewable_energy (country VARCHAR(20),energy_source VARCHAR(20),capacity INT); INSERT INTO renewable_energy (country,energy_source,capacity) VALUES ('Spain','Solar',8000),('Spain','Wind',25000),('Spain','Hydro',18000); | SELECT energy_source, capacity FROM renewable_energy WHERE country = 'Spain'; |
What is the total number of community development initiatives in Country V? | CREATE TABLE rural_communities (id INT,community_name VARCHAR(255),location VARCHAR(255),country VARCHAR(255),initiative_type VARCHAR(255),start_date DATE,end_date DATE); INSERT INTO rural_communities (id,community_name,location,country,initiative_type,start_date,end_date) VALUES (1,'Community A','Village B,Country V','Country V','Community Development','2019-01-01','2023-12-31'); | SELECT COUNT(*) FROM rural_communities WHERE country = 'Country V' AND initiative_type = 'Community Development'; |
What is the number of joint military exercises conducted by each country with its allies in the last 3 years? | CREATE TABLE Joint_Military_Exercises (id INT,country VARCHAR(50),year INT,allies VARCHAR(50)); | SELECT country, COUNT(country) as joint_exercises FROM Joint_Military_Exercises WHERE year BETWEEN (YEAR(CURRENT_DATE) - 3) AND YEAR(CURRENT_DATE) GROUP BY country; |
What is the total number of cybersecurity incidents reported for each type of incident in FY2021? | CREATE TABLE FiscalYear (fiscal_year INT,year INT); INSERT INTO FiscalYear (fiscal_year,year) VALUES (2021,2021),(2022,2022),(2023,2023); CREATE TABLE IncidentTypes (id INT,type VARCHAR(30)); INSERT INTO IncidentTypes (id,type) VALUES (1,'Malware'),(2,'Phishing'),(3,'Ransomware'),(4,'Data Breach'); CREATE TABLE Incidents (id INT,fiscal_year_id INT,incident_type_id INT,reported_date DATE,description TEXT); INSERT INTO Incidents (id,fiscal_year_id,incident_type_id,reported_date,description) VALUES (1,1,1,'2021-01-01','A computer was infected with malware.'),(2,1,3,'2021-02-15','A ransomware attack encrypted sensitive data.'),(3,1,2,'2021-03-05','A phishing email was sent to employees.'),(4,1,1,'2021-04-10','A server was compromised with malware.'); | SELECT i.type, COUNT(*) FROM Incidents i INNER JOIN FiscalYear fy ON i.fiscal_year_id = fy.id WHERE fy.year = 2021 GROUP BY i.type; |
What is the number of articles published per day on 'investigative journalism'? | CREATE TABLE articles_by_day (title text,topic text,publish_date date); INSERT INTO articles_by_day (title,topic,publish_date) VALUES ('Article 9','investigative journalism','2022-03-01'); INSERT INTO articles_by_day (title,topic,publish_date) VALUES ('Article 10','investigative journalism','2022-03-02'); | SELECT EXTRACT(DAY FROM publish_date) as day, COUNT(*) as count FROM articles_by_day WHERE topic = 'investigative journalism' GROUP BY day; |
What is the average safety rating of AI models developed for education applications, and how many of these models have been developed by organizations based in Asia? | CREATE TABLE AIModels (id INT,model_name VARCHAR(50),organization VARCHAR(50),application_type VARCHAR(50),safety_rating INT),AIOrganizations (id INT,organization VARCHAR(50),region VARCHAR(50)); INSERT INTO AIModels (id,model_name,organization,application_type,safety_rating) VALUES (1,'AI4Education','Microsoft','Education',85),(2,'AI4Learning','Google','Education',90),(3,'AI4Teaching','IBM','Education',88),(4,'AI4Students','Alibaba','Education',92),(5,'AI4Classroom','Tencent','Education',80); INSERT INTO AIOrganizations (id,organization,region) VALUES (1,'Microsoft','North America'),(2,'Google','North America'),(3,'IBM','North America'),(4,'Alibaba','Asia'),(5,'Tencent','Asia'); | SELECT AVG(safety_rating) as avg_safety_rating FROM AIModels WHERE application_type = 'Education'; SELECT COUNT(*) as asian_org_count FROM AIOrganizations WHERE region = 'Asia' AND organization IN (SELECT organization FROM AIModels WHERE application_type = 'Education'); |
What is the total cost of fair trade coffee products in the last 6 months? | CREATE TABLE Dates (date DATE); CREATE TABLE Sales (sale_id INT,date DATE,product_id INT,quantity INT,cost INT); CREATE TABLE Products (product_id INT,product_name VARCHAR(255),is_fair_trade BOOLEAN); | SELECT SUM(s.cost) as total_cost FROM Sales s JOIN Dates d ON s.date = d.date JOIN Products p ON s.product_id = p.product_id WHERE d.date >= DATE(NOW()) - INTERVAL 6 MONTH AND p.is_fair_trade = TRUE; |
Which industries had the highest number of non-binary founded startups in 2017? | CREATE TABLE company (id INT,name TEXT,industry TEXT,founding_date DATE,founder_gender TEXT); INSERT INTO company (id,name,industry,founding_date,founder_gender) VALUES (1,'Omega Inc','Renewable Energy','2017-01-01','Non-binary'); INSERT INTO company (id,name,industry,founding_date,founder_gender) VALUES (2,'Sigma Corp','Technology','2016-01-01','Male'); | SELECT industry, COUNT(*) as num_non_binary_startups FROM company WHERE founding_date >= '2017-01-01' AND founder_gender = 'Non-binary' GROUP BY industry ORDER BY num_non_binary_startups DESC; |
List the names of esports events and their respective number of participants, ordered by the number of participants in descending order. | CREATE TABLE EsportsEvents (EventID INT,EventName VARCHAR(20)); INSERT INTO EsportsEvents (EventID,EventName) VALUES (1,'ESWC'),(2,'EVO'),(3,'BlizzCon'),(4,'The International'),(5,'MLG'); CREATE TABLE EventParticipants (EventID INT,PlayerID INT); INSERT INTO EventParticipants (EventID,PlayerID) VALUES (1,1),(1,2),(2,1),(2,3),(3,2),(3,4),(4,1),(4,2),(4,3),(4,4),(5,5); | SELECT EsportsEvents.EventName, COUNT(EventParticipants.PlayerID) AS Participants FROM EsportsEvents INNER JOIN EventParticipants ON EsportsEvents.EventID = EventParticipants.EventID GROUP BY EsportsEvents.EventName ORDER BY Participants DESC; |
Delete flight safety records from 2017 | CREATE SCHEMA if not exists aerospace;CREATE TABLE if not exists aerospace.flight_safety (id INT,incident VARCHAR(255),incident_date DATE);INSERT INTO aerospace.flight_safety (id,incident,incident_date) VALUES (1,'Inc1','2017-01-01'),(2,'Inc2','2018-01-01'); | DELETE FROM aerospace.flight_safety WHERE incident_date >= '2017-01-01' AND incident_date < '2018-01-01'; |
How many environmental impact assessments were conducted in Region Z? | CREATE TABLE EnvironmentalImpact (id INT,mine_id INT,region TEXT,year INT,assessment_count INT); INSERT INTO EnvironmentalImpact (id,mine_id,region,year,assessment_count) VALUES (1,1,'Region Z',2015,3),(2,1,'Region Z',2016,4),(3,2,'Region Y',2015,2); | SELECT SUM(assessment_count) FROM EnvironmentalImpact WHERE region = 'Region Z'; |
What is the average humidity (%) in tea plantations in Sri Lanka during the last month? | CREATE TABLE humidity_data (humidity DECIMAL(3,1),reading_date DATE,location TEXT); INSERT INTO humidity_data (humidity,reading_date,location) VALUES (82.5,'2021-07-01','Sri Lanka'),(85.3,'2021-07-02','Sri Lanka'),(79.2,'2021-01-01','Sri Lanka'); | SELECT AVG(humidity) FROM humidity_data WHERE location = 'Sri Lanka' AND reading_date > DATE_SUB(CURDATE(), INTERVAL 1 MONTH) AND location LIKE '%tea%'; |
Show all regulatory frameworks for digital assets in South Korea and Germany? | CREATE TABLE regulatory_frameworks (framework_id INT,country VARCHAR(100),framework VARCHAR(100)); INSERT INTO regulatory_frameworks (framework_id,country,framework) VALUES (1,'South Korea','FrameworkA'),(2,'Germany','FrameworkB'),(3,'Australia','FrameworkC'); | SELECT framework_id, country, framework FROM regulatory_frameworks WHERE country IN ('South Korea', 'Germany'); |
What is the number of esports events for each game type? | CREATE TABLE esports_events (id INT,player_id INT,event_date DATE,game_type VARCHAR(255)); INSERT INTO esports_events (id,player_id,event_date,game_type) VALUES (1,1,'2022-01-01','FPS'),(2,1,'2022-02-01','RPG'),(3,2,'2021-12-01','FPS'),(4,2,'2022-01-01','FPS'); | SELECT game_type, COUNT(DISTINCT id) AS events_count FROM esports_events GROUP BY game_type; |
What is the average number of oil rigs active per year in the 'Brazil' region over the last 5 years? | CREATE TABLE oil_rig_years (rig_id INT,region VARCHAR(20),year INT,active INT); INSERT INTO oil_rig_years (rig_id,region,year,active) VALUES (1,'Brazil',2018,1),(2,'Brazil',2019,1),(3,'Brazil',2020,1),(4,'Nigeria',2018,2),(5,'Nigeria',2019,2); | SELECT AVG(active) FROM oil_rig_years WHERE region = 'Brazil' AND year >= 2018; |
Insert a new record for a military innovation in the 'innovations' table | CREATE TABLE innovations (id INT PRIMARY KEY,innovation_name VARCHAR(100),description TEXT,category VARCHAR(50),funding FLOAT); | INSERT INTO innovations (innovation_name, description, category, funding) VALUES ('Stealth Drone', 'Unmanned aerial vehicle with low radar cross-section', 'Air', 5000000.00); |
Show the number of donations for each donor. | CREATE TABLE Donors (DonorID INT,Name TEXT); INSERT INTO Donors VALUES (1,'John Doe'),(2,'Jane Smith'),(3,'Mike Johnson'); CREATE TABLE Donations (DonationID INT,DonorID INT,Amount DECIMAL); INSERT INTO Donations VALUES (1,1,50.00),(2,1,100.00),(3,2,75.00); | SELECT Donors.Name, COUNT(Donations.DonationID) as NumberOfDonations FROM Donors INNER JOIN Donations ON Donors.DonorID = Donations.DonorID GROUP BY Donors.Name; |
Update fairness evaluations for model 'ModelC' in 2024 | CREATE TABLE fairness_evaluations (model_name VARCHAR(255),year INT,fairness_score DECIMAL(5,4)); INSERT INTO fairness_evaluations (model_name,year,fairness_score) VALUES ('ModelA',2024,0.85),('ModelB',2024,0.92),('ModelC',2024,0.78),('ModelD',2024,0.88),('ModelE',2024,0.90); | UPDATE fairness_evaluations SET fairness_score = 0.82 WHERE model_name = 'ModelC' AND year = 2024; |
Insert a new record into the programs table with the following information: id = 4, name = 'Clothing Drive'. | CREATE TABLE programs (id INT,name VARCHAR(50)); INSERT INTO programs (id,name) VALUES (1,'Education Support'),(2,'Food Assistance'),(3,'Health Services'); | INSERT INTO programs (id, name) VALUES (4, 'Clothing Drive'); |
Delete all records in the "waste_management" table where the "waste_type" is 'Non-Toxic' | CREATE TABLE waste_management (waste_id INT PRIMARY KEY,waste_type VARCHAR(20)); INSERT INTO waste_management (waste_id,waste_type) VALUES (1,'Non-Toxic'),(2,'Toxic'),(3,'Non-Toxic'),(4,'Non-Toxic'); | DELETE FROM waste_management WHERE waste_type = 'Non-Toxic'; |
Find the total number of Energy Storage projects in each country? | CREATE TABLE EnergyStorageProjects (ProjectID INT,Name VARCHAR(255),Country VARCHAR(255),Type VARCHAR(255)); | SELECT Country, COUNT(*) FROM EnergyStorageProjects GROUP BY Country; |
What is the total billing amount for each attorney, by practice area? | CREATE TABLE Attorneys (AttorneyID INT,Name VARCHAR(50),PracticeArea VARCHAR(50)); INSERT INTO Attorneys (AttorneyID,Name,PracticeArea) VALUES (1,'Smith','Civil Rights'); INSERT INTO Attorneys (AttorneyID,Name,PracticeArea) VALUES (2,'Johnson','Criminal Law'); CREATE TABLE Billing (BillingID INT,AttorneyID INT,Amount DECIMAL(10,2)); INSERT INTO Billing (BillingID,AttorneyID,Amount) VALUES (1,1,5000.00); INSERT INTO Billing (BillingID,AttorneyID,Amount) VALUES (2,1,6000.00); INSERT INTO Billing (BillingID,AttorneyID,Amount) VALUES (3,2,3000.00); | SELECT A.PracticeArea, SUM(B.Amount) AS TotalBillingAmount FROM Attorneys A JOIN Billing B ON A.AttorneyID = B.AttorneyID GROUP BY A.PracticeArea; |
What is the total CO2 emission for coal mines that have more than 300 employees? | CREATE TABLE coal_mines (id INT,name VARCHAR(50),location VARCHAR(50),size INT,num_employees INT,co2_emissions INT); INSERT INTO coal_mines VALUES (1,'Coal Mine 1','West Virginia',450,350,25000); INSERT INTO coal_mines VALUES (2,'Coal Mine 2','Wyoming',600,400,30000); INSERT INTO coal_mines VALUES (3,'Coal Mine 3','Kentucky',200,150,15000); | SELECT SUM(co2_emissions) FROM coal_mines WHERE num_employees > 300; |
What is the average speed of all passenger vessels? | CREATE TABLE Vessels (ID VARCHAR(20),Name VARCHAR(20),Type VARCHAR(20),AverageSpeed FLOAT); INSERT INTO Vessels VALUES ('V009','Vessel I','Passenger',22.5),('V010','Vessel J','Passenger',25.0),('V011','Vessel K','Cargo',15.5); | SELECT AVG(AverageSpeed) FROM Vessels WHERE Type = 'Passenger'; |
What is the average market value of rare earth elements? | CREATE TABLE element_market_value (element VARCHAR(50),market_value DECIMAL(10,2)); INSERT INTO element_market_value (element,market_value) VALUES ('Neodymium',110.54),('Praseodymium',72.34),('Dysprosium',143.87),('Samarium',51.76),('Gadolinium',42.58); | SELECT AVG(market_value) FROM element_market_value; |
What are the names, locations, and lengths of monorails constructed after 1995, excluding those in Japan? | CREATE TABLE monorails (id INT,name TEXT,location TEXT,length INT,type TEXT,year INT); INSERT INTO monorails (id,name,location,length,type,year) VALUES (1,'Las Vegas Monorail','Nevada,USA',6,'Monorail',2004); INSERT INTO monorails (id,name,location,length,type,year) VALUES (2,'Sydney Monorail','Australia',3,'Monorail',1988); | SELECT name, location, length FROM monorails WHERE year > 1995 AND location NOT LIKE '%Japan%'; |
List the names and locations of all suppliers who have not supplied to any factories with a diversity score above 90. | CREATE TABLE suppliers (supplier_id INT,name TEXT,factories TEXT); CREATE TABLE factories (factory_id INT,name TEXT,location TEXT,diversity_score FLOAT); | SELECT suppliers.name, suppliers.location FROM suppliers LEFT JOIN factories ON factories.factory_id = ANY(string_to_array(suppliers.factories, ',')) WHERE factories.factory_id IS NULL OR factories.diversity_score <= 90; |
Update the budget for the 'ASL Interpreter' service in the 'SupportServices' table. | CREATE TABLE Regions (RegionID INT,RegionName VARCHAR(50)); CREATE TABLE SupportServices (ServiceID INT,ServiceName VARCHAR(50),ServiceType VARCHAR(50),Budget DECIMAL(10,2)); INSERT INTO Regions (RegionID,RegionName) VALUES (1,'Northeast'),(2,'Southeast'),(3,'Midwest'),(4,'South'),(5,'West'); INSERT INTO SupportServices (ServiceID,ServiceName,ServiceType,Budget) VALUES (1,'ASL Interpreter','SignLanguage',15000),(2,'Wheelchair Ramp','PhysicalAccess',8000),(3,'Braille Materials','VisualAssistance',12000),(4,'Assistive Listening Devices','AuditoryAssistance',10000); | UPDATE SupportServices SET Budget = 16000 WHERE ServiceName = 'ASL Interpreter'; |
What is the minimum number of infectious disease tracking cases per month in urban areas, grouped by month? | CREATE TABLE infectious_disease_tracking_3 (id INT,location TEXT,cases_per_month INT,month TEXT); INSERT INTO infectious_disease_tracking_3 (id,location,cases_per_month,month) VALUES (1,'Rural A',10,'January'),(2,'Rural B',15,'February'),(3,'Urban A',20,'March'),(4,'Urban A',5,'April'); | SELECT month, MIN(cases_per_month) FROM infectious_disease_tracking_3 WHERE location = 'urban' GROUP BY month; |
What is the total value of construction contracts awarded to minority-owned businesses in California during 2018? | CREATE TABLE Contracts (Contract_ID INT,Business_Owner VARCHAR(50),Contract_Value DECIMAL(10,2),Award_Date DATE,State VARCHAR(50)); | SELECT SUM(Contract_Value) FROM Contracts WHERE Business_Owner LIKE '%Minority%' AND State = 'California' AND Award_Date BETWEEN '2018-01-01' AND '2018-12-31'; |
List all autonomous driving research projects with a budget over $5 million. | CREATE TABLE autonomous_projects (project_name VARCHAR(50),budget DECIMAL(10,2),year INT); INSERT INTO autonomous_projects (project_name,budget,year) VALUES ('Project Apollo',7000000,2018),('Wayve',6000000,2020),('Project Baidu',5500000,2017),('Project Zoox',9000000,2019); | SELECT * FROM autonomous_projects WHERE budget > 5000000; |
What is the recycling rate for India in 2017 and 2018? | CREATE TABLE recycling_rates (country VARCHAR(50),year INT,recycling_rate FLOAT); INSERT INTO recycling_rates (country,year,recycling_rate) VALUES ('India',2017,0.18),('India',2018,0.20); | SELECT year, recycling_rate FROM recycling_rates WHERE country = 'India' ORDER BY year; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.