instruction stringlengths 0 1.06k | input stringlengths 11 5.3k | response stringlengths 2 4.44k |
|---|---|---|
What is the average number of daily active players for each game genre? | CREATE TABLE games (id INT,genre VARCHAR(255),daily_active_players INT); | SELECT genre, AVG(daily_active_players) FROM games GROUP BY genre; |
How many satellites were deployed by each organization in 2020? | CREATE TABLE Satellites (ID INT,Organization VARCHAR(50),Year INT,Number_Of_Satellites INT); INSERT INTO Satellites (ID,Organization,Year,Number_Of_Satellites) VALUES (1,'NASA',2018,21),(2,'SpaceX',2018,18),(3,'ESA',2019,15),(4,'NASA',2020,32),(5,'SpaceX',2020,60); | SELECT Organization, Number_Of_Satellites FROM Satellites WHERE Year = 2020 GROUP BY Organization; |
What is the average number of posts per day for users from the United States, for the month of January 2022? | CREATE TABLE users (user_id INT,user_country VARCHAR(50),post_date DATE); | SELECT AVG(post_count) FROM (SELECT user_country, COUNT(post_date) AS post_count FROM users WHERE user_country = 'United States' AND post_date BETWEEN '2022-01-01' AND '2022-01-31' GROUP BY user_country) AS subquery; |
What is the average age of readers who prefer print news in 'news_pubs' table, grouped by their city? | CREATE TABLE news_pubs (pub_id INT,pub_name VARCHAR(50),city VARCHAR(50),avg_age FLOAT); | SELECT city, AVG(avg_age) FROM news_pubs WHERE pub_name = 'Print News' GROUP BY city; |
What is the total revenue generated from sustainable fashion sales in Africa? | CREATE TABLE Sales (id INT,garmentID INT,quantity INT,saleDate DATE,isSustainable BOOLEAN); INSERT INTO Sales (id,garmentID,quantity,saleDate,isSustainable) VALUES (1,301,7,'2021-01-10',true),(2,302,4,'2021-02-15',false),(3,303,6,'2021-03-20',true),(4,304,5,'2021-04-12',true); CREATE TABLE Garments (id INT,garmentID IN... | SELECT SUM(quantity * price) FROM Sales INNER JOIN Garments ON Sales.garmentID = Garments.garmentID INNER JOIN Countries ON Garments.country = Countries.country WHERE isSustainable = true AND Countries.continent = 'Africa'; |
List the names and addresses of properties in the city of Austin that have been sold in the past year and have a sustainable urbanism certification. | CREATE TABLE properties (property_id INT,name VARCHAR(255),address VARCHAR(255),city VARCHAR(255),sold_date DATE,sustainable_urbanism_certified BOOLEAN); INSERT INTO properties (property_id,name,address,city,sold_date,sustainable_urbanism_certified) VALUES (1,'The Green House','123 Main St','Austin','2021-01-01',true),... | SELECT name, address FROM properties WHERE city = 'Austin' AND sold_date >= DATEADD(year, -1, GETDATE()) AND sustainable_urbanism_certified = true; |
What is the trend of crime rate over the last 6 months? | CREATE TABLE crime_rates (month VARCHAR(255),rate INT); INSERT INTO crime_rates (month,rate) VALUES ('Jan',10),('Feb',12),('Mar',15),('Apr',18),('May',20),('Jun',22); | SELECT month, rate, LAG(rate) OVER (ORDER BY month) AS previous_rate FROM crime_rates; |
What is the total number of players who have played VR games and have participated in esports events? | CREATE TABLE PlayerVRData (PlayerID INT,VRGame VARCHAR(20),Playtime INT); INSERT INTO PlayerVRData (PlayerID,VRGame,Playtime) VALUES (1,'VR',50),(2,'VR',30),(3,'Racing',70); | SELECT COUNT(DISTINCT PlayerID) FROM Players WHERE Game = 'VR' INTERSECT SELECT DISTINCT PlayerID FROM EsportsEvents; |
How many times did each vessel visit ports in the Pacific Ocean in the last month? | CREATE TABLE vessel_port_visits (id INT,vessel_id INT,port_id INT,visit_date DATE); INSERT INTO vessel_port_visits (id,vessel_id,port_id,visit_date) VALUES (3,18,51,'2022-03-07'); INSERT INTO vessel_port_visits (id,vessel_id,port_id,visit_date) VALUES (4,19,52,'2022-03-14'); | SELECT vessel_id, COUNT(DISTINCT visit_date) as visits_to_pacific_ports FROM vessel_port_visits WHERE port_id BETWEEN 41 AND 90 AND visit_date BETWEEN '2022-02-01' AND '2022-03-01' GROUP BY vessel_id; |
How many multimodal trips were taken in New York City in the last month? | CREATE TABLE MM_Trips (id INT,trip_type VARCHAR(20),city VARCHAR(50),trips INT,date DATE); INSERT INTO MM_Trips (id,trip_type,city,trips,date) VALUES (1,'Bike-Transit','New York City',15000,'2022-01-01'),(2,'Bus-Subway','New York City',22000,'2022-01-02'),(3,'Car-Transit','New York City',18000,'2022-01-03'); ALTER TABL... | SELECT SUM(total_trips) as total_trips FROM MM_Trips WHERE city = 'New York City' AND date >= DATE_SUB(CURDATE(), INTERVAL 1 MONTH); |
Update the assets value of the customer 'Jane Smith' to $800,000.00. | CREATE TABLE customers (id INT,name VARCHAR(100),assets_value FLOAT); INSERT INTO customers (id,name,assets_value) VALUES (1,'Jane Smith',600000.00); | UPDATE customers SET assets_value = 800000.00 WHERE name = 'Jane Smith'; |
What is the percentage of technology for social good projects in Africa that focus on accessibility? | CREATE TABLE social_good_projects (project_id INT,region VARCHAR(20),focus VARCHAR(50)); INSERT INTO social_good_projects (project_id,region,focus) VALUES (1,'Africa','accessibility'),(2,'Africa','education'),(3,'Europe','infrastructure'),(4,'North America','policy'); | SELECT (COUNT(*) * 100.0 / (SELECT COUNT(*) FROM social_good_projects WHERE region = 'Africa')) as percentage FROM social_good_projects WHERE region = 'Africa' AND focus = 'accessibility'; |
Which are the top 3 countries with the most satellite deployments in the past 5 years? | CREATE TABLE satellite_deployments (country VARCHAR(255),launch_date DATE); INSERT INTO satellite_deployments (country,launch_date) VALUES ('USA','2020-01-01'),('China','2019-06-15'),('Russia','2021-08-27'),('India','2018-03-04'),('Japan','2021-02-12'); | SELECT country, COUNT(*) as count FROM satellite_deployments WHERE launch_date >= DATEADD(year, -5, CURRENT_DATE) GROUP BY country ORDER BY count DESC LIMIT 3; |
What are the top three countries in Asia with the most military bases? | CREATE TABLE military_bases (base_name VARCHAR(255),country VARCHAR(255),personnel INT); INSERT INTO military_bases (base_name,country,personnel) VALUES ('Osan Air Base','South Korea',1800),('Yokota Air Base','Japan',3000),('Camp Humphreys','South Korea',4000),('Taegu Air Base','South Korea',2500),('Iwakuni Air Base','... | SELECT country, COUNT(*) as base_count FROM military_bases WHERE country IN ('South Korea', 'Japan', 'Okinawa') GROUP BY country ORDER BY base_count DESC LIMIT 3; |
Display the safety protocol names and their corresponding safety measure codes, in alphabetical order based on safety protocol names from the safety_protocols table. | CREATE TABLE safety_protocols (protocol_name TEXT,safety_measure_code TEXT); INSERT INTO safety_protocols (protocol_name,safety_measure_code) VALUES ('Fire Safety','FS01'),('Chemical Handling','CH01'),('Personal Protective Equipment','PPE01'); | SELECT protocol_name, safety_measure_code FROM safety_protocols ORDER BY protocol_name ASC; |
What was the average salary of workers in the 'research' department compared to the 'operations' department? | CREATE TABLE salaries (id INT,worker_id INT,department VARCHAR(50),salary DECIMAL(10,2)); INSERT INTO salaries (id,worker_id,department,salary) VALUES (1,1,'Research',85000.00),(2,2,'Operations',75000.00),(3,3,'Research',88000.00); | SELECT department, AVG(salary) as avg_salary FROM salaries GROUP BY department; |
How many hybrid vehicles have been sold in each month of the year 2018 in the 'sales_data' table? | CREATE TABLE sales_data (id INT,sale_date DATE,make VARCHAR(50),model VARCHAR(50),vehicle_type VARCHAR(50),price FLOAT); | SELECT MONTH(sale_date), COUNT(*) FROM sales_data WHERE vehicle_type = 'Hybrid' AND YEAR(sale_date) = 2018 GROUP BY MONTH(sale_date); |
What is the maximum temperature in the Indian Ocean? | CREATE TABLE oceanography_data (id INT,location VARCHAR(50),depth INT,temperature FLOAT,salinity FLOAT); INSERT INTO oceanography_data (id,location,depth,temperature,salinity) VALUES (1,'Indian Ocean',5000,29.5,34.9); INSERT INTO oceanography_data (id,location,depth,temperature,salinity) VALUES (2,'Southern Ocean',6000... | SELECT MAX(temperature) FROM oceanography_data WHERE location = 'Indian Ocean'; |
What is the average amount of water consumption (in liters) per household in the city of Austin, Texas, for the year 2020? | CREATE TABLE house_water_usage (house_id INT,city VARCHAR(255),usage_liters INT,year INT); INSERT INTO house_water_usage (house_id,city,usage_liters,year) VALUES (1,'Austin',12000,2020),(2,'Austin',15000,2020),(3,'Austin',11000,2020); | SELECT AVG(usage_liters) FROM house_water_usage WHERE city = 'Austin' AND year = 2020; |
What is the total number of digital assets launched by company 'A'? | CREATE TABLE digital_assets (id INT,name TEXT,company TEXT,launch_date DATE); INSERT INTO digital_assets (id,name,company,launch_date) VALUES (1,'Asset1','A','2020-01-01'); INSERT INTO digital_assets (id,name,company,launch_date) VALUES (2,'Asset2','A','2021-05-15'); | SELECT COUNT(*) FROM digital_assets WHERE company = 'A'; |
Find the total number of wells in the North Sea | CREATE TABLE wells (id INT,well_name VARCHAR(100),location VARCHAR(50),status VARCHAR(20)); INSERT INTO wells VALUES (1,'Well A','North Sea','Producing'); INSERT INTO wells VALUES (2,'Well B','Gulf of Mexico','Abandoned'); | SELECT COUNT(*) FROM wells WHERE location = 'North Sea'; |
Update the bike sharing station with ID 601 to change its name | CREATE TABLE bike_sharing_stations (station_id INT,station_name TEXT,city TEXT,country TEXT,latitude FLOAT,longitude FLOAT); | UPDATE bike_sharing_stations SET station_name = 'South Lake Union' WHERE station_id = 601; |
Delete marine species records with a conservation_status of 'extinct'. | CREATE TABLE marine_species (id INT PRIMARY KEY,name VARCHAR(255),conservation_status VARCHAR(255)); | DELETE FROM marine_species WHERE conservation_status = 'extinct'; |
What is the total amount of funding for social impact projects in Asia in the year 2020? | CREATE TABLE social_impact_funding (id INT,project_name VARCHAR(50),funding_date DATE,region VARCHAR(30),amount DECIMAL(10,2)); INSERT INTO social_impact_funding (id,project_name,funding_date,region,amount) VALUES (1,'Education Initiative A','2020-03-15','Asia',25000.00),(2,'Healthcare Program B','2019-10-05','Europe',... | SELECT SUM(amount) FROM social_impact_funding WHERE funding_date >= '2020-01-01' AND funding_date < '2021-01-01' AND region = 'Asia'; |
Delete all records of bridges in the 'Africa' region. | CREATE TABLE bridges (id INT,name TEXT,region TEXT,resilience_score FLOAT); INSERT INTO bridges (id,name,region,resilience_score) VALUES (1,'Golden Gate Bridge','West Coast',85.2),(2,'Brooklyn Bridge','East Coast',76.3),(3,'Bay Bridge','West Coast',78.1),(4,'Chenab Bridge','South Asia',89.6),(5,'Maputo Bay Bridge','Afr... | DELETE FROM bridges WHERE region = 'Africa'; |
What is the minimum budget for agricultural innovation projects in 2020? | CREATE TABLE agricultural_innovation_budget (id INT,project_id INT,budget DECIMAL(10,2)); INSERT INTO agricultural_innovation_budget (id,project_id,budget) VALUES (1,1,50000.00),(2,2,75000.00); CREATE TABLE rural_innovation (id INT,project_name VARCHAR(255),sector VARCHAR(255),location VARCHAR(255),start_date DATE,end_... | SELECT MIN(budget) FROM agricultural_innovation_budget JOIN rural_innovation ON agricultural_innovation_budget.project_id = rural_innovation.id WHERE YEAR(start_date) = 2020 AND YEAR(end_date) = 2020; |
What are the total greenhouse gas emissions for each mine, ranked from highest to lowest? | CREATE TABLE Mine (MineID int,MineName varchar(50),Location varchar(50)); CREATE TABLE Emission (EmissionID int,MineID int,EmissionType varchar(50),EmissionQuantity int); INSERT INTO Mine VALUES (1,'ABC Mine','Colorado'),(2,'DEF Mine','Wyoming'),(3,'GHI Mine','West Virginia'); INSERT INTO Emission VALUES (1,1,'CO2',100... | SELECT MineName, SUM(EmissionQuantity) as TotalEmissionQuantity FROM Emission INNER JOIN Mine ON Emission.MineID = Mine.MineID GROUP BY MineName ORDER BY TotalEmissionQuantity DESC; |
Identify the top 5 countries with the highest number of ethical fashion brands. | CREATE TABLE brands (id INT PRIMARY KEY,name TEXT,country TEXT,sustainability_score INT); | SELECT country, COUNT(*) as brand_count FROM brands GROUP BY country ORDER BY brand_count DESC LIMIT 5; |
What is the total number of cruelty-free ingredients in products, grouped by their category? | CREATE TABLE Ingredients (IngredientID INT,ProductID INT,IngredientName VARCHAR(50),CrueltyFree BOOLEAN,Category VARCHAR(50)); INSERT INTO Ingredients (IngredientID,ProductID,IngredientName,CrueltyFree,Category) VALUES (1,1,'Rose Oil',TRUE,'Skincare'),(2,1,'Paraben',FALSE,'Skincare'),(3,2,'Silicone',FALSE,'Hair Care'),... | SELECT Category, COUNT(*) FROM Ingredients WHERE CrueltyFree = TRUE GROUP BY Category; |
What is the total number of manned space missions that have traveled to the Moon? | CREATE TABLE SpaceMissions (id INT,name VARCHAR(50),destination VARCHAR(50)); INSERT INTO SpaceMissions (id,name,destination) VALUES (1,'Apollo 11','Moon'); | SELECT COUNT(*) FROM SpaceMissions WHERE destination = 'Moon' AND type = 'Manned'; |
Calculate the average number of volunteer hours per week for each age group. | CREATE TABLE volunteer_hours (id INT,age_group VARCHAR(50),volunteer_date DATE,volunteer_hours FLOAT); INSERT INTO volunteer_hours (id,age_group,volunteer_date,volunteer_hours) VALUES (1,'18-24','2023-03-20',5.0),(2,'25-34','2023-02-01',8.0),(3,'35-44','2023-01-15',10.0),(4,'18-24','2023-04-01',15.0),(5,'55-64','2023-0... | SELECT age_group, AVG(volunteer_hours / 7) FROM volunteer_hours GROUP BY age_group; |
What is the total asset value for all customers in Canada? | CREATE TABLE customers (id INT,name VARCHAR(100),age INT,gender VARCHAR(10),city VARCHAR(50),state VARCHAR(50),account_balance DECIMAL(10,2),assets DECIMAL(10,2)); | SELECT SUM(assets) FROM customers WHERE state='Canada'; |
Update the "technology_for_social_good" table to set the "funding_status" to "Approved" for the records with "region" as "Europe" and "funding_amount" greater than 50000 | CREATE TABLE technology_for_social_good (id INT PRIMARY KEY,project_name VARCHAR(100),region VARCHAR(50),funding_amount INT,funding_status VARCHAR(20)); INSERT INTO technology_for_social_good (id,project_name,region,funding_amount,funding_status) VALUES (1,'Clean Water AI','Europe',60000,'Pending'); INSERT INTO technol... | UPDATE technology_for_social_good SET funding_status = 'Approved' WHERE region = 'Europe' AND funding_amount > 50000; |
What is the minimum mental health score of students in the 'Remote Learning' district? | CREATE TABLE students (id INT,district TEXT,mental_health_score INT); INSERT INTO students (id,district,mental_health_score) VALUES (1,'Remote Learning',80),(2,'Remote Learning',85),(3,'Remote Learning',90); | SELECT MIN(mental_health_score) FROM students WHERE district = 'Remote Learning'; |
What is the minimum amount of gold extracted in a single day in the 'production_data' table? | CREATE TABLE production_data (id INT,date DATE,coal_production INT,gold_production INT); INSERT INTO production_data (id,date,coal_production,gold_production) VALUES (1,'2022-01-01',200,10); INSERT INTO production_data (id,date,coal_production,gold_production) VALUES (2,'2022-01-02',250,15); | SELECT MIN(gold_production) as min_gold_production FROM production_data; |
Calculate the average sustainability score for accommodations in Australia and New Zealand. | CREATE TABLE accommodations (id INT,country VARCHAR(50),accommodation_type VARCHAR(50),sustainability_score INT); INSERT INTO accommodations (id,country,accommodation_type,sustainability_score) VALUES (1,'Australia','Hotel',75); INSERT INTO accommodations (id,country,accommodation_type,sustainability_score) VALUES (2,'... | SELECT AVG(sustainability_score) FROM accommodations WHERE country IN ('Australia', 'New Zealand'); |
What is the total number of medals won by each country in the 'olympic_medals' table? | CREATE TABLE olympic_countries (country_id INT,name VARCHAR(50)); CREATE TABLE olympic_medals (medal_id INT,country_id INT,medal VARCHAR(50)); INSERT INTO olympic_countries (country_id,name) VALUES (1,'USA'),(2,'Canada'),(3,'Mexico'); INSERT INTO olympic_medals (medal_id,country_id,medal) VALUES (1,1,'Gold'),(2,1,'Silv... | SELECT name AS country, SUM(CASE WHEN medal = 'Gold' THEN 1 ELSE 0 END) AS total_gold, SUM(CASE WHEN medal = 'Silver' THEN 1 ELSE 0 END) AS total_silver, SUM(CASE WHEN medal = 'Bronze' THEN 1 ELSE 0 END) AS total_bronze, SUM(CASE WHEN medal IN ('Gold', 'Silver', 'Bronze') THEN 1 ELSE 0 END) AS total_medals FROM olympic... |
How many electric vehicles are in the 'clean_transport' table? | CREATE TABLE clean_transport (vehicle_type TEXT,num_vehicles INTEGER); INSERT INTO clean_transport (vehicle_type,num_vehicles) VALUES ('Tesla Model 3',1000),('Nissan Leaf',1500),('Chevy Bolt',500); | SELECT SUM(num_vehicles) FROM clean_transport; |
List all community development initiatives in Brazil and their respective coordinators. | CREATE TABLE CommunityDev (id INT,initiative VARCHAR(255),country VARCHAR(255),coordinator VARCHAR(255)); INSERT INTO CommunityDev (id,initiative,country,coordinator) VALUES (1,'Youth Empowerment','Brazil','Maria Silva'),(2,'Elderly Care','Brazil','Jose Pires'); | SELECT initiative, coordinator FROM CommunityDev WHERE country = 'Brazil'; |
What was the highest revenue generating day in 'Pizzeria Z'? | CREATE TABLE Pizzeria (Date DATE,Revenue INT); INSERT INTO Pizzeria (Date,Revenue) VALUES ('2022-01-01',500),('2022-01-02',700),('2022-01-03',800),('2022-01-04',600); | SELECT Date, MAX(Revenue) FROM Pizzeria WHERE Date BETWEEN '2022-01-01' AND '2022-01-04' GROUP BY Date; |
Find the total number of shipments made from South Africa to Cape Town in the past week. | CREATE TABLE shipments (id INT,source_country VARCHAR(20),destination_city VARCHAR(20),shipment_date DATE); INSERT INTO shipments (id,source_country,destination_city,shipment_date) VALUES (1,'South Africa','Cape Town','2022-07-10'),(2,'South Africa','Cape Town','2022-07-15'); | SELECT COUNT(*) FROM shipments WHERE source_country = 'South Africa' AND destination_city = 'Cape Town' AND shipment_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 WEEK); |
What are the names of the top 5 cities with the highest CO2 emissions in the 'energy_efficiency' table? | CREATE TABLE energy_efficiency (city VARCHAR(255),co2_emissions INT); | SELECT city FROM energy_efficiency ORDER BY co2_emissions DESC LIMIT 5; |
List the names and sports of athletes in the 'multi_sport_athletes' table. | CREATE TABLE multi_sport_athletes (athlete_id INT,name VARCHAR(50),sport VARCHAR(30)); | SELECT name, sport FROM multi_sport_athletes; |
Identify the top 2 creative AI applications with the highest user ratings in 2023 | CREATE TABLE creative_ai_apps (app_name VARCHAR(255),user_rating INT,year INT); INSERT INTO creative_ai_apps (app_name,user_rating,year) VALUES ('App1',85,2023),('App2',92,2023),('App3',78,2023),('App4',90,2023),('App5',88,2023),('App6',75,2023); | SELECT app_name, user_rating FROM (SELECT app_name, user_rating, ROW_NUMBER() OVER (ORDER BY user_rating DESC) as rank FROM creative_ai_apps WHERE year = 2023) tmp WHERE rank <= 2; |
What is the minimum budget for AI ethics research in the 'ai_ethics' table? | CREATE TABLE ai_ethics (project TEXT,budget INTEGER); INSERT INTO ai_ethics (project,budget) VALUES ('AI Ethics Research Project A',100000); INSERT INTO ai_ethics (project,budget) VALUES ('AI Ethics Research Project B',120000); | SELECT MIN(budget) FROM ai_ethics; |
What is the average rating of garments by textile source, ordered by rating? | CREATE TABLE textile_sustainability (source VARCHAR(50),rating FLOAT); INSERT INTO textile_sustainability (source,rating) VALUES ('Organic Cotton',4.2),('Recycled Polyester',3.9),('Hemp',4.5); | SELECT source, AVG(rating) as avg_rating FROM textile_sustainability GROUP BY source ORDER BY avg_rating DESC; |
What is the total sustainability score of companies located in Africa? | CREATE TABLE company_location_sustainability (company_id INT,location TEXT,sustainability_score INT); INSERT INTO company_location_sustainability (company_id,location,sustainability_score) VALUES (1,'Asia-Pacific',85),(2,'Europe',92),(3,'Asia-Pacific',78),(4,'Europe',60),(5,'Europe',88),(6,'Africa',95),(7,'Africa',80); | SELECT SUM(sustainability_score) FROM company_location_sustainability WHERE location = 'Africa'; |
Identify the number of airports, their respective runway lengths, and the total number of aircraft movements in each region of Australia, along with their airport types (e.g., international, domestic, or military). | CREATE TABLE AirportsAustralia (AirportID INT,Name VARCHAR(255),Region VARCHAR(255),RunwayLength INT,AirportType VARCHAR(255),AircraftMovements INT); INSERT INTO AirportsAustralia VALUES (1,'Airport A','New South Wales',2000,'International',10000); INSERT INTO AirportsAustralia VALUES (2,'Airport B','Queensland',1500,'... | SELECT Region, AirportType, COUNT(*) as AirportCount, SUM(RunwayLength) as TotalRunwayLength, SUM(AircraftMovements) as TotalAircraftMovements FROM AirportsAustralia GROUP BY Region, AirportType; |
What's the average ESG rating for all companies in the 'technology' sector? | CREATE TABLE sectors (sector_id INT,sector_name VARCHAR(20)); CREATE TABLE companies (company_id INT,company_name VARCHAR(30),sector_id INT,esg_rating FLOAT); | SELECT AVG(c.esg_rating) FROM companies c INNER JOIN sectors s ON c.sector_id = s.sector_id WHERE s.sector_name = 'technology'; |
What is the number of donations made by first-time donors from the United Kingdom? | CREATE TABLE Donations (DonationID int,DonorID int,DonationDate date); | SELECT COUNT(*) FROM Donations D INNER JOIN (SELECT DISTINCT DonorID FROM Donations WHERE YEAR(DonationDate) = YEAR(CURRENT_DATE) - 1) FD ON D.DonorID = FD.DonorID WHERE Country = 'UK'; |
How many marine species are listed as endangered in the Mediterranean Sea? | CREATE TABLE marine_species (name VARCHAR(255),status VARCHAR(255),location VARCHAR(255)); INSERT INTO marine_species (name,status,location) VALUES ('Mediterranean Monk Seal','Endangered','Mediterranean Sea'),('Bluefin Tuna','Endangered','Mediterranean Sea'); | SELECT COUNT(*) FROM marine_species WHERE status = 'Endangered' AND location = 'Mediterranean Sea'; |
Which programs received donations in Q4 2021 but did not have any volunteers? | CREATE TABLE ProgramVolunteers (ProgramID INT,VolunteerCount INT); INSERT INTO ProgramVolunteers (ProgramID,VolunteerCount) VALUES (1,5),(3,0); | SELECT ProgramName FROM Programs LEFT JOIN ProgramVolunteers ON Programs.ProgramID = ProgramVolunteers.ProgramID WHERE DonationDate BETWEEN '2021-10-01' AND '2021-12-31' AND VolunteerCount = 0; |
Find dispensaries in Washington D.C. that sell both indica and sativa strains. | CREATE TABLE DispensarySales (dispensary_id INT,strain VARCHAR(20),quantity INT); INSERT INTO DispensarySales (dispensary_id,strain,quantity) VALUES (1,'Sour Diesel',50),(1,'Blue Dream',75),(2,'Green Crack',60),(2,'Jack Herer',80); CREATE TABLE DCDispensaries (dispensary_id INT,location VARCHAR(20)); INSERT INTO DCDisp... | SELECT ds.dispensary_id FROM DispensarySales ds JOIN DCDispensaries dcd ON ds.dispensary_id = dcd.dispensary_id WHERE strain LIKE '%Indica%' INTERSECT SELECT ds.dispensary_id FROM DispensarySales ds JOIN DCDispensaries dcd ON ds.dispensary_id = dcd.dispensary_id WHERE strain LIKE '%Sativa%'; |
What is the maximum number of patients served per medical facility in Nigeria? | CREATE TABLE medical_facilities_nigeria (id INT,name TEXT,patients INT); INSERT INTO medical_facilities_nigeria (id,name,patients) VALUES (1,'Facility X',5000); | SELECT MAX(patients) FROM medical_facilities_nigeria; |
Display the cost of the project with the ID 4 and the department of the project with the ID 5. | CREATE TABLE projects (id INT,engineer_id INT,department VARCHAR(20),cost DECIMAL(10,2)); INSERT INTO projects (id,engineer_id,department,cost) VALUES (1,1001,'civil',5000),(2,1002,'civil',6000),(3,1003,'structural',4000),(4,1001,'civil',7000),(5,1002,'civil',3000),(6,1003,'structural',6000); | SELECT cost FROM projects WHERE id = 4; SELECT department FROM projects WHERE id = 5; |
Which artists have the highest and lowest average concert ticket revenue? | CREATE TABLE ArtistConcerts (ArtistID INT,ConcertID INT,Revenue INT); INSERT INTO ArtistConcerts VALUES (1,1,10000); INSERT INTO ArtistConcerts VALUES (2,2,15000); INSERT INTO ArtistConcerts VALUES (3,3,12000); CREATE TABLE Artists (ArtistID INT,ArtistName VARCHAR(100),Age INT,Genre VARCHAR(50)); INSERT INTO Artists VA... | SELECT ArtistName, AVG(Revenue) FROM ArtistConcerts AC INNER JOIN Artists A ON AC.ArtistID = A.ArtistID GROUP BY ArtistID ORDER BY AVG(Revenue) DESC, ArtistName ASC; |
What is the minimum number of tickets sold for football games in the 'Northern Division'? | CREATE TABLE tickets_sold (ticket_id INT,game_type VARCHAR(50),division VARCHAR(50),tickets_sold INT); INSERT INTO tickets_sold (ticket_id,game_type,division,tickets_sold) VALUES (1,'Basketball','Atlantic Division',500),(2,'Football','Atlantic Division',700),(3,'Basketball','Atlantic Division',600),(4,'Hockey','Central... | SELECT MIN(tickets_sold) FROM tickets_sold WHERE game_type = 'Football' AND division = 'Northern Division'; |
Get the top 3 consumers with the highest total spending on ethical products? | CREATE TABLE consumers (consumer_id INT,consumer_name TEXT); CREATE TABLE purchases (purchase_id INT,consumer_id INT,supplier_id INT,product_id INT,quantity INT,price DECIMAL); CREATE TABLE suppliers (supplier_id INT,supplier_name TEXT,labor_practice TEXT); | SELECT consumers.consumer_name, SUM(quantity * price) AS total_spending FROM consumers JOIN purchases ON consumers.consumer_id = purchases.consumer_id JOIN suppliers ON purchases.supplier_id = suppliers.supplier_id WHERE suppliers.labor_practice = 'Ethical' GROUP BY consumers.consumer_id ORDER BY total_spending DESC LI... |
What is the maximum amount of donations received by an organization in Asia? | CREATE TABLE organizations (id INT,name TEXT,location TEXT,donations DECIMAL(10,2)); INSERT INTO organizations (id,name,location,donations) VALUES (1,'Aid for Africa','Africa',50000.00),(2,'Hope for Asia','Asia',75000.00),(3,'Charity for Europe','Europe',100000.00); | SELECT MAX(donations) FROM organizations WHERE location = 'Asia'; |
What is the total CO2 offset for each country in the carbon_offset_initiatives table? | CREATE TABLE IF NOT EXISTS carbon_offset_initiatives (initiative_id INT,initiative_name VARCHAR(255),co2_offset FLOAT,country VARCHAR(255),PRIMARY KEY (initiative_id)); INSERT INTO carbon_offset_initiatives (initiative_id,initiative_name,co2_offset,country) VALUES (1,'Tree Planting',50,'USA'),(2,'Solar Power Installati... | SELECT country, SUM(co2_offset) FROM carbon_offset_initiatives GROUP BY country; |
What is the total revenue for each region in the last quarter? | CREATE TABLE regional_sales (region TEXT,sale_date DATE,revenue DECIMAL(10,2)); INSERT INTO regional_sales (region,sale_date,revenue) VALUES ('North','2022-01-01',500.00),('South','2022-01-03',300.00),('East','2022-02-14',800.00),('West','2022-03-01',600.00); | SELECT region, SUM(revenue) FROM regional_sales WHERE sale_date BETWEEN DATE_SUB(NOW(), INTERVAL 3 MONTH) AND NOW() GROUP BY region; |
What is the minimum installed capacity of solar projects in 'country2'? | CREATE TABLE renewable_energy_projects (id INT,project_name TEXT,country TEXT,technology TEXT,installed_capacity FLOAT); INSERT INTO renewable_energy_projects (id,project_name,country,technology,installed_capacity) VALUES (1,'Project A','country1','solar',200.0),(2,'Project B','country2','wind',150.0),(3,'Project C','c... | SELECT MIN(installed_capacity) FROM renewable_energy_projects WHERE country = 'country2' AND technology = 'solar'; |
What is the maximum account balance for financial wellbeing accounts in the Western region? | CREATE TABLE western_region (region VARCHAR(20),account_type VARCHAR(30),account_balance DECIMAL(10,2)); INSERT INTO western_region (region,account_type,account_balance) VALUES ('Western','Financial Wellbeing',9000.00),('Western','Financial Wellbeing',10000.00),('Western','Financial Stability',8000.00); | SELECT MAX(account_balance) FROM western_region WHERE account_type = 'Financial Wellbeing'; |
Find the total ad spend for campaigns targeting users aged 18-24 in the past month. | CREATE TABLE ad_campaigns (id INT,start_date TIMESTAMP,end_date TIMESTAMP,target_age INT,ad_spend DECIMAL(10,2)); | SELECT SUM(ad_spend) FROM ad_campaigns WHERE target_age BETWEEN 18 AND 24 AND start_date BETWEEN DATE_SUB(CURRENT_TIMESTAMP(), INTERVAL 1 MONTH) AND CURRENT_TIMESTAMP(); |
Delete all rows with an autonomy_level less than 1 from the autonomous_driving_research table. | CREATE TABLE autonomous_driving_research (id INT,make VARCHAR(50),model VARCHAR(50),autonomy_level INT); | DELETE FROM autonomous_driving_research WHERE autonomy_level < 1; |
How many unique donors have there been in each of the last 3 months? | CREATE TABLE donation_timeline (id INT,donor_id INT,donation_date DATE); | SELECT DATE_FORMAT(donation_date, '%Y-%m') as donation_month, COUNT(DISTINCT donor_id) as unique_donors FROM donation_timeline WHERE donation_date >= DATE_SUB(CURDATE(), INTERVAL 3 MONTH) GROUP BY donation_month; |
What is the average depth of marine species habitats in the Pacific Ocean? | CREATE TABLE marine_species (id INT,species_name VARCHAR(50),habitat_depth FLOAT); INSERT INTO marine_species (id,species_name,habitat_depth) VALUES (1,'Dolphin',50.0,(2,'Shark',300.0)); | SELECT AVG(habitat_depth) FROM marine_species WHERE ocean = 'Pacific'; |
How many humanitarian assistance missions were conducted in Africa? | CREATE TABLE Humanitarian_Assistance (Mission_ID INT,Mission_Name VARCHAR(50),Location VARCHAR(50),Start_Date DATE,End_Date DATE); INSERT INTO Humanitarian_Assistance (Mission_ID,Mission_Name,Location,Start_Date,End_Date) VALUES (1,'Operation Restore Hope','Somalia','1992-01-01','1993-12-31'); | SELECT COUNT(*) as Total_Missions FROM Humanitarian_Assistance WHERE Location = 'Africa'; |
Remove any duplicate ticket sales records from the 'ticket_sales' table | CREATE TABLE ticket_sales (sale_id INT PRIMARY KEY,ticket_price DECIMAL(5,2),sale_date DATE); | DELETE FROM ticket_sales WHERE sale_id IN (SELECT sale_id FROM ticket_sales GROUP BY sale_id HAVING COUNT(*) > 1); |
What is the percentage of citizens who are satisfied with the public transportation service in 'CityG' and 'CityH' in 2021? | CREATE TABLE CityG_Satis (ID INT,Year INT,Satisfaction VARCHAR(10)); INSERT INTO CityG_Satis (ID,Year,Satisfaction) VALUES (1,2021,'Satisfied'),(2,2021,'Neutral'); CREATE TABLE CityH_Satis (ID INT,Year INT,Satisfaction VARCHAR(10)); INSERT INTO CityH_Satis (ID,Year,Satisfaction) VALUES (1,2021,'Satisfied'),(3,2021,'Dis... | SELECT 100.0 * COUNT(CASE WHEN CityG_Satis.Satisfaction = 'Satisfied' OR CityH_Satis.Satisfaction = 'Satisfied' THEN 1 END) / COUNT(*) FROM CityG_Satis, CityH_Satis WHERE CityG_Satis.Year = 2021 AND CityH_Satis.Year = 2021; |
What is the total number of security incidents in the last year that involved a user from a department that has more than 100 users? | CREATE TABLE security_incidents (incident_id INT,incident_date DATE,user_id INT);CREATE TABLE users (user_id INT,user_name VARCHAR(255),department VARCHAR(255),department_size INT); | SELECT COUNT(*) FROM security_incidents si JOIN users u ON si.user_id = u.user_id WHERE incident_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR) AND u.department_size > 100; |
Show the total oil and gas production for each company in the third quarter of 2021 | CREATE TABLE company (id INT,name VARCHAR(50)); CREATE TABLE oil_production (company_id INT,date DATE,oil_production FLOAT); CREATE TABLE gas_production (company_id INT,date DATE,gas_production FLOAT); | SELECT c.name, SUM(op.oil_production) + SUM(gp.gas_production) FROM company c JOIN oil_production op ON c.id = op.company_id JOIN gas_production gp ON c.id = gp.company_id WHERE op.date BETWEEN '2021-07-01' AND '2021-09-30' AND gp.date BETWEEN '2021-07-01' AND '2021-09-30' GROUP BY c.id; |
What is the maximum number of hours of speech-to-text interpretation provided in a week? | CREATE TABLE InterpretationServices (service_id INT,hours_per_week INT,accommodation_type VARCHAR(255)); | SELECT MAX(hours_per_week) FROM InterpretationServices WHERE accommodation_type = 'Speech-to-Text'; |
Which marine species are found in the Southern Ocean? | CREATE TABLE marine_species (name VARCHAR(255),region VARCHAR(255)); CREATE TABLE southern_ocean (name VARCHAR(255),region_type VARCHAR(255)); INSERT INTO marine_species (name,region) VALUES ('SPECIES1','Southern Ocean'),('SPECIES2','Arctic Ocean'); INSERT INTO southern_ocean (name,region_type) VALUES ('SPECIES1',... | SELECT marine_species.name FROM marine_species INNER JOIN southern_ocean ON marine_species.name = southern_ocean.name; |
How many organizations are working on technology accessibility in Africa? | CREATE TABLE organizations (id INT,name VARCHAR(50),location VARCHAR(50),focus VARCHAR(50)); INSERT INTO organizations (id,name,location,focus) VALUES (1,'TechForAll','Africa','Technology Accessibility'),(2,'SocialGoodAI','Global','Ethical AI'),(3,'DigitalDivideInitiative','Asia','Digital Divide'); | SELECT COUNT(*) FROM organizations WHERE location = 'Africa' AND focus = 'Technology Accessibility'; |
How many vessels visited Sydney in June 2022? | CREATE TABLE Port (port_id INT PRIMARY KEY,port_name VARCHAR(255)); INSERT INTO Port (port_id,port_name) VALUES (1,'Sydney'); CREATE TABLE Vessel (vessel_id INT PRIMARY KEY,vessel_name VARCHAR(255)); CREATE TABLE Vessel_Movement (vessel_id INT,movement_date DATE,port_id INT,PRIMARY KEY (vessel_id,movement_date)); | SELECT COUNT(DISTINCT V.vessel_id) FROM Vessel V JOIN Vessel_Movement VM ON V.vessel_id = VM.vessel_id WHERE VM.movement_date = '2022-06-01' AND VM.port_id = (SELECT port_id FROM Port WHERE port_name = 'Sydney'); |
Update the workout type for ID 102 to 'Pilates' | CREATE TABLE workouts (member_id INT,workout_date DATE,workout_type VARCHAR(50),duration INT,calories_burned INT); | UPDATE workouts SET workout_type = 'Pilates' WHERE member_id = 102; |
What is the average budget for AI projects in Southeast Asia? | CREATE TABLE ai_projects (id INT,region VARCHAR(255),budget DECIMAL(10,2)); INSERT INTO ai_projects (id,region,budget) VALUES (1,'North America',500000.00),(2,'Southeast Asia',350000.00),(3,'South America',400000.00); | SELECT AVG(budget) FROM ai_projects WHERE region = 'Southeast Asia'; |
Which countries have climate communication initiatives that received funding higher than the average funding amount? | CREATE TABLE climate_communication (country VARCHAR(50),initiative VARCHAR(50),funding DECIMAL(10,2)); INSERT INTO climate_communication (country,initiative,funding) VALUES ('Canada','Climate Change Documentary',1000000),('Mexico','Climate Communication Symposium',2000000); | SELECT country, initiative, funding FROM climate_communication WHERE funding > (SELECT AVG(funding) FROM climate_communication); |
Update the model of aircraft with ID 102 to 'A321' | CREATE TABLE aircraft (id INT PRIMARY KEY,model VARCHAR(50),engine VARCHAR(50)); INSERT INTO aircraft (id,model,engine) VALUES (101,'747','CFM56'),(102,'A320','IAE V2500'),(103,'A350','Rolls-Royce Trent XWB'),(104,'787','GE GEnx'),(105,'737','CFM56'); | UPDATE aircraft SET model = 'A321' WHERE id = 102; |
What is the total biomass of fish species in the 'Atlantic Ocean' for each year? | CREATE TABLE fish_biomass (year INT,region VARCHAR(255),species VARCHAR(255),biomass FLOAT); INSERT INTO fish_biomass (year,region,species,biomass) VALUES (2020,'Atlantic Ocean','Cod',1500),(2020,'Atlantic Ocean','Haddock',1000),(2021,'Atlantic Ocean','Cod',1600); | SELECT year, region, SUM(biomass) AS total_biomass FROM fish_biomass WHERE region = 'Atlantic Ocean' GROUP BY year; |
Military technology patents by the US vs. Russia in 2020 | CREATE TABLE tech_patents (country VARCHAR(50),year INT,patent_count INT); | SELECT country, patent_count FROM tech_patents WHERE year = 2020 AND country IN ('United States', 'Russia') ORDER BY patent_count DESC; |
What was the combined mass of spacecraft involved in space missions before 2010? | CREATE TABLE Spacecraft (SpacecraftID INT,Name VARCHAR(50),Manufacturer VARCHAR(50),Mass FLOAT);CREATE TABLE SpaceMissions (MissionID INT,SpacecraftID INT,Name VARCHAR(50),LaunchDate DATE); INSERT INTO Spacecraft (SpacecraftID,Name,Manufacturer,Mass) VALUES (1,'Voyager 1','NASA',770),(2,'Voyager 2','NASA',770); INSERT ... | SELECT SUM(s.Mass) FROM Spacecraft s INNER JOIN SpaceMissions sm ON s.SpacecraftID = sm.SpacecraftID WHERE sm.LaunchDate < '2010-01-01'; |
List the total number of IoT devices deployed in each field in the 'PrecisionFarm' farm as of the end of 2021. | CREATE TABLE IoTData (id INT,field VARCHAR(255),device_type VARCHAR(255),deployment_date DATE); | SELECT field, COUNT(DISTINCT device_type) FROM IoTData WHERE field IN ('PrecisionFarm1', 'PrecisionFarm2', 'PrecisionFarm3') AND YEAR(deployment_date) = 2021 AND MONTH(deployment_date) = 12 GROUP BY field; |
What is the difference in the number of events for each traditional art between the current year and the previous year? | CREATE TABLE TraditionalArtEvents (ID INT,Art VARCHAR(50),Year INT,Events INT); INSERT INTO TraditionalArtEvents (ID,Art,Year,Events) VALUES (1,'Kabuki',2022,50); INSERT INTO TraditionalArtEvents (ID,Art,Year,Events) VALUES (2,'Flamenco',2022,60); | SELECT Art, Events AS CurrentYearEvents, LEAD(Events) OVER (PARTITION BY Art ORDER BY Year) AS PreviousYearEvents, CurrentYearEvents - PreviousYearEvents AS Difference FROM TraditionalArtEvents; |
Which country has the least number of fair trade certified factories? | CREATE TABLE factories (factory_id INT,country VARCHAR(255),certification VARCHAR(255)); INSERT INTO factories (factory_id,country,certification) VALUES (1,'India','fair trade'),(2,'Bangladesh','not fair trade'),(3,'India','fair trade'),(4,'Nepal','fair trade'); | SELECT country, COUNT(*) as factory_count FROM factories WHERE certification = 'fair trade' GROUP BY country ORDER BY factory_count ASC LIMIT 1; |
How many bridges were built in the Northeast region before 2010? | CREATE TABLE InfrastructureProjects (id INT,name VARCHAR(100),region VARCHAR(50),project_type VARCHAR(50),completion_date DATE); INSERT INTO InfrastructureProjects (id,name,region,project_type,completion_date) VALUES (1,'Boston Bridge','Northeast','bridge','2005-01-01'); | SELECT COUNT(*) FROM InfrastructureProjects WHERE region = 'Northeast' AND project_type = 'bridge' AND completion_date < '2010-01-01'; |
What is the total quantity of eco-friendly textiles used in manufacturing for each trend? | CREATE TABLE EcoManufacturing (id INT,trend VARCHAR(20),fabric VARCHAR(20),quantity INT); INSERT INTO EcoManufacturing (id,trend,fabric,quantity) VALUES (1,'minimalism','organic cotton',500),(2,'vintage','recycled polyester',700); | SELECT trend, SUM(quantity) FROM EcoManufacturing WHERE fabric LIKE '%eco%' GROUP BY trend; |
What is the minimum response time for police assistance in the 'South' district? | CREATE TABLE districts (id INT,name VARCHAR(255)); CREATE TABLE police_responses (id INT,district_id INT,response_time INT); INSERT INTO districts (id,name) VALUES (1,'South'); INSERT INTO police_responses (id,district_id,response_time) VALUES (1,1,7); | SELECT MIN(response_time) FROM police_responses WHERE district_id = (SELECT id FROM districts WHERE name = 'South'); |
What are the total sales of sustainable material products per month? | CREATE TABLE sales (id INT,product_id INT,material VARCHAR(50),sale_date DATE,quantity INT); | SELECT MONTH(sale_date) AS sale_month, SUM(quantity) AS total_sales FROM sales WHERE material IN ('organic_cotton', 'recycled_polyester', 'tencel') GROUP BY sale_month; |
How many pallets were moved between 'warehouse1' and 'warehouse3' in July 2021? | CREATE TABLE warehouse (id INT,location VARCHAR(255),capacity INT); INSERT INTO warehouse (id,location,capacity) VALUES (1,'warehouse1',5000),(2,'warehouse2',7000),(3,'warehouse3',6000); CREATE TABLE movements (id INT,source_id INT,destination_id INT,quantity INT,moved_date DATE); INSERT INTO movements (id,source_id,de... | SELECT SUM(quantity) FROM movements WHERE source_id = 1 AND destination_id = 3 AND moved_date BETWEEN '2021-07-01' AND '2021-07-31'; |
Who is the communication lead for 'climate_mitigation'? | CREATE TABLE staff (id INT PRIMARY KEY,name VARCHAR(255),role VARCHAR(255),department VARCHAR(255)); INSERT INTO staff (id,name,role,department) VALUES (1,'Alice','Communication Lead','climate_mitigation'),(2,'Bob','Project Manager','climate_adaptation'),(3,'Charlie','Finance Analyst','climate_finance'),(4,'David','Dat... | SELECT name FROM staff WHERE role = 'Communication Lead' AND department = 'climate_mitigation'; |
Find the number of aquaculture farms in each country, sorted by the number of farms in descending order. | CREATE TABLE Farm (id INT,name VARCHAR(50),country VARCHAR(50)); | SELECT f.country, COUNT(f.id) FROM Farm f GROUP BY f.country ORDER BY COUNT(f.id) DESC; |
What is the highest-rated eco-friendly hotel in Germany? | CREATE TABLE Hotels (id INT,name TEXT,country TEXT,rating FLOAT,eco_friendly BOOLEAN); INSERT INTO Hotels (id,name,country,rating,eco_friendly) VALUES (1,'Eco Hotel','Germany',4.6,true),(2,'Green Lodge','Germany',4.3,true),(3,'Classic Hotel','Germany',4.8,false); | SELECT name, rating FROM Hotels WHERE country = 'Germany' AND eco_friendly = true ORDER BY rating DESC LIMIT 1; |
What is the total supply of ERC20 tokens issued by addresses located in India? | CREATE TABLE addresses (address VARCHAR(42),country VARCHAR(2)); INSERT INTO addresses (address,country) VALUES ('0x123','IN'),('0x456','US'),('0x789','IN'); CREATE TABLE erc20_tokens (token_name VARCHAR(10),address VARCHAR(42),total_supply BIGINT); INSERT INTO erc20_tokens (token_name,address,total_supply) VALUES ('To... | SELECT SUM(total_supply) FROM erc20_tokens t JOIN addresses a ON t.address = a.address WHERE a.country = 'IN'; |
What is the success rate of the 'Depression Screening Campaign'? | CREATE TABLE campaigns (campaign_name VARCHAR(30),reach INT,conversions INT); INSERT INTO campaigns (campaign_name,reach,conversions) VALUES ('Mental Health Awareness Campaign',12000,1800); INSERT INTO campaigns (campaign_name,reach,conversions) VALUES ('Suicide Prevention Campaign',8500,1300); INSERT INTO campaigns (c... | SELECT (CONVERT(FLOAT, conversions) / reach) * 100.0 FROM campaigns WHERE campaign_name = 'Depression Screening Campaign'; |
Add a new record into the "company_founding" table for 'Delta Inc.' with the founding date 2018-05-15 | CREATE TABLE company_founding (id INT,company_name VARCHAR(100),founding_date DATE); | INSERT INTO company_founding (id, company_name, founding_date) VALUES (4, 'Delta Inc.', '2018-05-15'); |
Find the average temperature increase for each year in the 'Temperature_Data' table and the 'Climate_Trends' table, then sum the results. | CREATE TABLE Temperature_Data (year INT,temperature FLOAT); CREATE TABLE Climate_Trends (year INT,temperature FLOAT); | SELECT AVG(temperature) FROM Temperature_Data GROUP BY year UNION ALL SELECT AVG(temperature) FROM Climate_Trends GROUP BY year |
What is the total quantity of each resource type depleted in the current year? | CREATE TABLE mining_operations (operation_id INT,operation_name VARCHAR(50),resource_type VARCHAR(50),depletion_date DATE,quantity INT); INSERT INTO mining_operations (operation_id,operation_name,resource_type,depletion_date,quantity) VALUES (1,'Operation A','Coal','2022-01-01',100),(2,'Operation B','Iron','2022-02-15'... | SELECT resource_type, SUM(quantity) AS total_depleted FROM mining_operations WHERE depletion_date >= DATE_SUB(CURDATE(), INTERVAL 1 YEAR) GROUP BY resource_type; |
Which services in city 1 have the highest average rating in the last month? | CREATE TABLE Citizen_Feedback (id INT,city_id INT,service VARCHAR(50),rating INT,date_created DATETIME); INSERT INTO Citizen_Feedback (id,city_id,service,rating,date_created) VALUES (9,1,'Road Maintenance',4,'2022-01-15 12:00:00'),(10,1,'Waste Management',3,'2022-02-20 14:30:00'),(11,1,'Road Maintenance',5,'2022-06-05 ... | SELECT CF.service, AVG(CF.rating) as avg_rating FROM Citizen_Feedback CF INNER JOIN City C ON CF.city_id = C.id WHERE C.name = 'City1' AND CF.date_created >= DATE_SUB(CURDATE(), INTERVAL 1 MONTH) GROUP BY CF.service ORDER BY avg_rating DESC; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.