instruction
stringlengths 0
1.06k
| input
stringlengths 11
5.3k
| response
stringlengths 2
4.44k
|
---|---|---|
Update the funding for event with EventID 1 to 12000 | CREATE TABLE Events (EventID INT,Category VARCHAR(50),FundingReceived DECIMAL(10,2)); INSERT INTO Events (EventID,Category,FundingReceived) VALUES (1,'Music',10000),(2,'Theater',15000); | UPDATE Events SET FundingReceived = 12000 WHERE EventID = 1; |
What is the maximum number of military technology patents filed by China in a single year? | CREATE TABLE tech_patents_china (country VARCHAR(255),year INT,num_patents INT); INSERT INTO tech_patents_china (country,year,num_patents) VALUES ('China',2015,1000),('China',2016,1200),('China',2017,1400); | SELECT MAX(num_patents) FROM tech_patents_china WHERE country = 'China'; |
What is the total number of articles written by each author, and how many of those articles were written in the month of July 2022? | CREATE TABLE articles (id INT,title VARCHAR(50),author_id INT,publish_date DATE); CREATE TABLE authors (id INT,name VARCHAR(50)); INSERT INTO articles (id,title,author_id,publish_date) VALUES (1,'Article1',3,'2022-07-01'),(2,'Article2',3,'2022-07-15'),(3,'Article3',4,'2022-06-30'); INSERT INTO authors (id,name) VALUES (3,'Sofia Garcia'),(4,'Ali Bailey'); | SELECT a.name, COUNT(*) as total_articles, SUM(CASE WHEN DATE_FORMAT(a.publish_date, '%%Y-%%m') = '2022-07' THEN 1 ELSE 0 END) as articles_in_july FROM articles a JOIN authors au ON a.author_id = au.id GROUP BY a.name |
Update the 'country_targeted' to 'China' for the 'intelligence_operation' with 'operation_id' 2 in the 'intelligence_operations' table | CREATE TABLE intelligence_operations (operation_id INT PRIMARY KEY,operation_name VARCHAR(100),operation_type VARCHAR(50),country_targeted VARCHAR(50)); INSERT INTO intelligence_operations (operation_id,operation_name,operation_type,country_targeted) VALUES (1,'Operation Black Swan','Cyberwarfare','Russia'),(2,'Operation Red Sparrow','Espionage','China'); | UPDATE intelligence_operations SET country_targeted = 'China' WHERE operation_id = 2; |
What is the change in peacekeeping operation count by country between 2020 and 2021, ranked from highest to lowest? | CREATE TABLE PeacekeepingOperationsByCountry (Country VARCHAR(50),Year INT,Operations INT); INSERT INTO PeacekeepingOperationsByCountry (Country,Year,Operations) VALUES ('USA',2020,250),('China',2020,200),('India',2020,220),('USA',2021,255),('China',2021,210),('India',2021,230); | SELECT Country, (Operations - LAG(Operations, 1, 0) OVER (PARTITION BY Country ORDER BY Year)) * 100.0 / LAG(Operations, 1, 0) OVER (PARTITION BY Country ORDER BY Year) AS OperationsChangePercentage, RANK() OVER (ORDER BY OperationsChangePercentage DESC) AS Rank FROM PeacekeepingOperationsByCountry WHERE Year IN (2020, 2021) GROUP BY Country; |
Calculate the average number of digital exhibits viewed per month in Melbourne. | CREATE TABLE Visitors (id INT,city VARCHAR(50),digital_exhibits INT,visit_month INT); INSERT INTO Visitors (id,city,digital_exhibits,visit_month) VALUES (1,'Melbourne',4,1); | SELECT AVG(digital_exhibits/12) FROM (SELECT city, COUNT(DISTINCT visit_month) visitors FROM Visitors WHERE city = 'Melbourne' GROUP BY city); |
What was the total revenue for 'Impossible Burger' at 'Vegan Delight'? | CREATE TABLE restaurants (restaurant_id INT,name VARCHAR(255)); INSERT INTO restaurants (restaurant_id,name) VALUES (6,'Vegan Delight'); CREATE TABLE menu_items (menu_item_id INT,name VARCHAR(255),price DECIMAL(5,2),restaurant_id INT); INSERT INTO menu_items (menu_item_id,name,price,restaurant_id) VALUES (7,'Impossible Burger',10.99,6); CREATE TABLE orders (order_id INT,menu_item_id INT,quantity INT,order_date DATE,restaurant_id INT); INSERT INTO orders (order_id,menu_item_id,quantity,order_date,restaurant_id) VALUES (5,7,3,'2022-01-02',6); | SELECT SUM(price * quantity) FROM orders o JOIN menu_items mi ON o.menu_item_id = mi.menu_item_id WHERE mi.name = 'Impossible Burger' AND mi.restaurant_id = 6; |
What is the percentage of male workers in each industry? | CREATE TABLE workers (worker_id INT,name TEXT,industry TEXT); INSERT INTO workers (worker_id,name,industry) VALUES (1,'James Doe','manufacturing'),(2,'Jane Doe','retail'),(3,'James Smith','manufacturing'); CREATE TABLE employment (employment_id INT,worker_id INT,gender TEXT); INSERT INTO employment (employment_id,worker_id,gender) VALUES (1,1,'Male'),(2,2,'Female'),(3,3,'Male'); | SELECT industry, COUNT(*) * 100.0 / SUM(COUNT(*)) OVER () FROM workers JOIN employment ON workers.worker_id = employment.worker_id WHERE gender = 'Male' GROUP BY industry; |
What is the total sales amount for each equipment type in the defense project timelines table? | CREATE TABLE DefenseProjectTimelines (id INT PRIMARY KEY,equipment VARCHAR(50),project_start_date DATE,project_end_date DATE,project_status VARCHAR(50)); INSERT INTO EquipmentSales (id,contractor,equipment,sale_date,sale_amount) VALUES (4,'Raytheon','Patriot','2019-08-01',80000000); INSERT INTO EquipmentSales (id,contractor,equipment,sale_date,sale_amount) VALUES (5,'Northrop Grumman','Global Hawk','2020-10-01',110000000); | SELECT DefenseProjectTimelines.equipment, SUM(EquipmentSales.sale_amount) FROM EquipmentSales RIGHT JOIN DefenseProjectTimelines ON EquipmentSales.equipment = DefenseProjectTimelines.equipment GROUP BY DefenseProjectTimelines.equipment; |
What is the average calorie content in vegan meals? | CREATE TABLE meals (id INT,name TEXT,type TEXT,calories INT); INSERT INTO meals (id,name,type,calories) VALUES (1,'Quinoa Salad','vegan',400),(2,'Tofu Stir Fry','vegan',600); | SELECT AVG(calories) FROM meals WHERE type = 'vegan'; |
What is the total engagement time for virtual tours in 'New York'? | CREATE TABLE virtual_tours (tour_id INT,hotel_id INT,city TEXT,engagement_time INT); INSERT INTO virtual_tours (tour_id,hotel_id,city,engagement_time) VALUES (1,3,'New York',1200),(2,3,'New York',1500),(3,4,'Chicago',1000); | SELECT SUM(engagement_time) FROM virtual_tours WHERE city = 'New York'; |
Who are the managers in the human resources department with the highest salary? | CREATE TABLE employees (id INT PRIMARY KEY,name VARCHAR(50),position VARCHAR(50),department VARCHAR(50),salary DECIMAL(5,2),manager_id INT,FOREIGN KEY (manager_id) REFERENCES employees(id)); CREATE TABLE departments (id INT PRIMARY KEY,name VARCHAR(50),manager_id INT,FOREIGN KEY (manager_id) REFERENCES employees(id)); | SELECT employees.name AS manager_name, employees.salary AS salary FROM employees INNER JOIN departments ON employees.department = departments.name WHERE departments.name = 'Human Resources' AND employees.position = 'Manager' AND employees.salary = (SELECT MAX(employees.salary) FROM employees WHERE employees.department = departments.name AND employees.position = 'Manager'); |
Which schools have the lowest overall budget per student in CityB? | CREATE TABLE schools (id INT,name TEXT,budget INT,city TEXT); INSERT INTO schools (id,name,budget,city) VALUES (1,'SchoolA',700000,'CityB'),(2,'SchoolB',600000,'CityB'),(3,'SchoolC',500000,'CityB'); | SELECT s.name, s.budget/COUNT(ds.student_id) as avg_budget_per_student FROM schools s JOIN district_schools ds ON s.id = ds.school_id WHERE s.city = 'CityB' GROUP BY s.name HAVING avg_budget_per_student = (SELECT MIN(s.budget/COUNT(ds.student_id)) FROM schools s JOIN district_schools ds ON s.id = ds.school_id WHERE s.city = 'CityB' GROUP BY s.name); |
What is the number of properties in New York City with co-ownership and sustainable urbanism features? | CREATE TABLE co_ownership (property_id INT,city VARCHAR(20)); CREATE TABLE urbanism (property_id INT,city VARCHAR(20),sustainable BOOLEAN); INSERT INTO co_ownership (property_id,city) VALUES (1,'New_York_City'); INSERT INTO co_ownership (property_id,city) VALUES (2,'Los_Angeles'); INSERT INTO urbanism (property_id,city,sustainable) VALUES (1,'New_York_City',true); INSERT INTO urbanism (property_id,city,sustainable) VALUES (2,'Los_Angeles',false); | SELECT COUNT(*) FROM co_ownership INNER JOIN urbanism ON co_ownership.property_id = urbanism.property_id WHERE co_ownership.city = 'New_York_City' AND urbanism.sustainable = true; |
What is the total number of cases in the legal services domain? | CREATE TABLE cases (case_id INT,domain TEXT); | SELECT COUNT(DISTINCT cases.case_id) FROM cases WHERE cases.domain = 'legal services'; |
Delete all records from the 'satellite_deployment' table where the location is 'not in space' | CREATE TABLE satellite_deployment (id INT PRIMARY KEY,name VARCHAR(50),launch_year INT,location VARCHAR(50)); | DELETE FROM satellite_deployment WHERE location != 'Space'; |
What is the total number of exoplanets discovered by the Kepler space telescope? | CREATE TABLE exoplanets (id INT,name VARCHAR(255),discovery_method VARCHAR(255),discovery_date DATE,telescope VARCHAR(255)); | SELECT COUNT(*) FROM exoplanets WHERE telescope = 'Kepler'; |
What's the average safety rating of all autonomous vehicles? | CREATE TABLE autonomous_vehicles (id INT PRIMARY KEY,make VARCHAR(50),model VARCHAR(50),safety_rating FLOAT); INSERT INTO autonomous_vehicles (id,make,model,safety_rating) VALUES (1,'Tesla','Model X',9.2),(2,'Waymo','Waymo One',9.5),(3,'NVIDIA','DRIVE AGX',9.0),(4,'Baidu','Apollo',8.8),(5,'Uber','ATG',8.6); | SELECT AVG(safety_rating) FROM autonomous_vehicles; |
What is the total quantity of silver extracted by indigenous communities in Colombia in 2022? | CREATE TABLE IndigenousCommunities (CommunityID int,CommunityName varchar(50),Country varchar(50)); INSERT INTO IndigenousCommunities VALUES (1,'CommunityA','Colombia'),(2,'CommunityB','Brazil'),(3,'CommunityC','Canada'); CREATE TABLE ExtractionData (CommunityID int,ExtractionDate date,Material varchar(10),Quantity int); INSERT INTO ExtractionData VALUES (1,'2022-01-01','Silver',1000),(1,'2022-01-15','Silver',1500),(2,'2022-01-30','Silver',800),(1,'2022-02-05','Silver',1200),(3,'2022-03-01','Silver',1000); | SELECT ic.CommunityName, SUM(ed.Quantity) as TotalExtraction FROM ExtractionData ed JOIN IndigenousCommunities ic ON ed.CommunityID = ic.CommunityID WHERE ed.ExtractionDate BETWEEN '2022-01-01' AND '2022-12-31' AND ed.Material = 'Silver' AND ic.Country = 'Colombia' GROUP BY ic.CommunityName; |
Insert a new ride hailing company with EVs and hybrid vehicles. | CREATE TABLE RideHailing (id INT,company VARCHAR(20),vehicle_type VARCHAR(20),num_drivers INT); | INSERT INTO RideHailing (id, company, vehicle_type, num_drivers) VALUES (4, 'Juno', 'EV', 1000), (5, 'Juno', 'Hybrid', 2000); |
What is the average environmental impact score for chemical products launched in Q1 and Q2 of 2020? | CREATE TABLE ChemicalProducts (ProductID INT,Chemical TEXT,ManufacturerID INT,ProductLaunchDate DATE,EnvironmentalImpactScore DECIMAL(3,2)); INSERT INTO ChemicalProducts (ProductID,Chemical,ManufacturerID,ProductLaunchDate,EnvironmentalImpactScore) VALUES (1,'Acetone',1,'2020-01-01',3.2),(2,'Ethanol',1,'2020-04-01',4.5),(3,'Methanol',2,'2019-01-01',5.0),(4,'Propanol',2,'2020-06-01',4.8),(5,'Butanol',3,'2020-02-01',5.0); | SELECT AVG(CP.EnvironmentalImpactScore) AS AverageScore FROM ChemicalProducts CP WHERE QUARTER(CP.ProductLaunchDate) IN (1, 2) AND YEAR(CP.ProductLaunchDate) = 2020; |
What is the running total of Dysprosium production by quarter? | CREATE TABLE production (country VARCHAR(255),element VARCHAR(255),quantity INT,year INT,quarter INT); INSERT INTO production (country,element,quantity,year,quarter) VALUES ('China','Dysprosium',10000,2018,1),('China','Dysprosium',12000,2018,2),('China','Dysprosium',14000,2018,3),('China','Dysprosium',16000,2018,4),('China','Dysprosium',18000,2019,1); | SELECT year, quarter, SUM(quantity) OVER (PARTITION BY element ORDER BY year, quarter) as running_total FROM production WHERE element = 'Dysprosium' ORDER BY year, quarter; |
Add a new record for the Giant Pacific Octopus in the Pacific Ocean with a population of 1500. | CREATE TABLE Cephalopods (Species VARCHAR(255),Ocean VARCHAR(255),Population INT); | INSERT INTO Cephalopods (Species, Ocean, Population) VALUES ('Giant Pacific Octopus', 'Pacific Ocean', 1500); |
Smart city devices installed before 2021-06-01 | CREATE TABLE smart_city_devices (id INT,name VARCHAR(255),location VARCHAR(255),installed_date DATE); INSERT INTO smart_city_devices (id,name,location,installed_date) VALUES (1,'SmartBin1','CityE','2021-03-20'),(2,'SmartLight1','CityF','2021-07-10'),(3,'SmartSensor1','CityE','2021-04-05'),(4,'SmartSensor2','CityF','2020-12-20'); | SELECT name FROM smart_city_devices WHERE installed_date < '2021-06-01' ORDER BY installed_date DESC; |
What is the average amount of grants given for agricultural innovation projects in the Philippines? | CREATE TABLE agricultural_innovation_projects (id INT,country VARCHAR(20),grant_amount DECIMAL(10,2)); INSERT INTO agricultural_innovation_projects (id,country,grant_amount) VALUES (1,'Philippines',5000.00),(2,'Indonesia',7000.00); | SELECT AVG(grant_amount) FROM agricultural_innovation_projects WHERE country = 'Philippines'; |
What is the average customer rating for mineral-based makeup products launched in 2021? | CREATE TABLE product_details (product_id INT,launch_date DATE,product_category VARCHAR(50),customer_rating FLOAT); INSERT INTO product_details (product_id,launch_date,product_category,customer_rating) VALUES (1001,'2021-02-15','makeup',4.3),(1002,'2021-06-20','skincare',4.1),(1003,'2021-09-01','makeup',4.6),(1004,'2022-01-10','haircare',3.9); | SELECT AVG(customer_rating) FROM product_details WHERE product_category = 'makeup' AND launch_date < '2022-01-01' AND EXTRACT(YEAR FROM launch_date) = 2021 AND product_details.product_category IN (SELECT product_category FROM product_details WHERE product_category = 'makeup' AND is_mineral = true); |
How many vulnerabilities were found in the last quarter for the 'network' asset type? | CREATE TABLE vulnerabilities (id INT,vuln_date DATE,asset_type VARCHAR(50)); INSERT INTO vulnerabilities (id,vuln_date,asset_type) VALUES (1,'2021-12-01','network'),(2,'2022-01-05','server'),(3,'2022-02-10','workstation'); | SELECT COUNT(*) as vulnerability_count FROM vulnerabilities WHERE vuln_date >= DATEADD(quarter, -1, GETDATE()) AND asset_type = 'network'; |
What is the total number of volunteers who have participated in 'Green City' program? | CREATE TABLE volunteers (id INT,name TEXT,city TEXT,program TEXT); INSERT INTO volunteers (id,name,city,program) VALUES (1,'John Doe','NYC','Green City'); INSERT INTO volunteers (id,name,city,program) VALUES (2,'Jane Smith','LA','Green City'); | SELECT COUNT(*) FROM volunteers WHERE program = 'Green City'; |
What is the total revenue for the month of April 2022 for restaurants located in California? | CREATE TABLE RestaurantRevenue(restaurant_id INT,revenue DECIMAL(10,2),revenue_date DATE,restaurant_location VARCHAR(255)); | SELECT SUM(revenue) FROM RestaurantRevenue WHERE revenue_date BETWEEN '2022-04-01' AND '2022-04-30' AND restaurant_location = 'California'; |
Find the top 3 product categories with the highest sales in H1 2022. | CREATE TABLE sales (product_category VARCHAR(255),sales_amount NUMERIC,sale_date DATE); INSERT INTO sales (product_category,sales_amount,sale_date) VALUES ('men_shirts',500,'2022-01-01'); INSERT INTO sales (product_category,sales_amount,sale_date) VALUES ('women_pants',800,'2022-01-02'); INSERT INTO sales (product_category,sales_amount,sale_date) VALUES ('children_dresses',400,'2022-01-03'); | SELECT product_category, SUM(sales_amount) FROM sales WHERE sale_date BETWEEN '2022-01-01' AND '2022-06-30' GROUP BY product_category ORDER BY SUM(sales_amount) DESC LIMIT 3; |
Find the number of research grants awarded to each department in the College of Engineering, ordered from the most to least grants. | CREATE TABLE College_of_Engineering_Grants (department VARCHAR(50),grant_awarded BOOLEAN); INSERT INTO College_of_Engineering_Grants (department,grant_awarded) VALUES ('Mechanical Engineering',true),('Electrical Engineering',false),('Civil Engineering',true),('Computer Science and Engineering',true),('Chemical Engineering',false),('Biomedical Engineering',true); | SELECT department, SUM(grant_awarded) as total_grants FROM College_of_Engineering_Grants GROUP BY department ORDER BY total_grants DESC; |
What is the average water consumption per household in the city of Seattle, WA for the year 2020? | CREATE TABLE seattle_households (id INT,water_consumption FLOAT,household_size INT,year INT); INSERT INTO seattle_households (id,water_consumption,household_size,year) VALUES (1,12000,4,2020); INSERT INTO seattle_households (id,water_consumption,household_size,year) VALUES (2,15000,5,2020); | SELECT AVG(water_consumption / household_size) FROM seattle_households WHERE year = 2020; |
Which are the top 3 suppliers of organic fruits? | CREATE TABLE suppliers (id INT,name TEXT,product TEXT,is_organic BOOLEAN); INSERT INTO suppliers (id,name,product,is_organic) VALUES (1,'Green Earth Farms','Apples',true),(2,'Fresh Harvest','Bananas',true),(3,'Sunrise Produce','Oranges',false),(4,'Organic Delights','Strawberries',true); | SELECT name, product FROM suppliers WHERE is_organic = true ORDER BY product LIMIT 3; |
List the names and case numbers of cases in 'cases' table that were assigned to attorney_id 5 | CREATE TABLE cases (case_id INT,case_number VARCHAR(50),client_name VARCHAR(50),attorney_id INT); | SELECT cases.case_number, cases.client_name FROM cases WHERE cases.attorney_id = 5; |
What is the total number of mental health parity violations for each race? | CREATE TABLE MentalHealthParity (ViolationID INT,State VARCHAR(25),Race VARCHAR(25),ViolationDate DATE); INSERT INTO MentalHealthParity (ViolationID,State,Race,ViolationDate) VALUES (1,'California','Asian','2021-01-15'); INSERT INTO MentalHealthParity (ViolationID,State,Race,ViolationDate) VALUES (2,'New York','African American','2021-02-20'); INSERT INTO MentalHealthParity (ViolationID,State,Race,ViolationDate) VALUES (3,'Texas','Caucasian','2021-03-10'); INSERT INTO MentalHealthParity (ViolationID,State,Race,ViolationDate) VALUES (4,'Florida','Hispanic','2021-04-01'); | SELECT Race, COUNT(*) FROM MentalHealthParity GROUP BY Race; |
Determine the number of bioprocess engineering jobs in each country. | CREATE SCHEMA if not exists bioprocess;CREATE TABLE if not exists bioprocess.jobs (id INT,title VARCHAR(50),country VARCHAR(50)); INSERT INTO bioprocess.jobs (id,title,country) VALUES (1,'JobA','France'),(2,'JobB','Spain'),(3,'JobC','France'),(4,'JobD','USA'),(5,'JobE','Spain'); | SELECT country, COUNT(*) FROM bioprocess.jobs GROUP BY country; |
Create table 'game_sessions' with columns: session_id, player_id, session_start_time, session_duration | CREATE TABLE game_sessions (session_id INT,player_id INT,session_start_time TIMESTAMP,session_duration INTERVAL); | CREATE TABLE game_sessions (session_id INT, player_id INT, session_start_time TIMESTAMP, session_duration INTERVAL); |
Add a new artwork by Claude Monet in 1872 | CREATE TABLE Artworks (Artist VARCHAR(50),Artwork VARCHAR(50),Year INT); | INSERT INTO Artworks (Artist, Artwork, Year) VALUES ('Claude Monet', 'Water Lilies', 1872) |
What are the names of dishes that contain more than one type of meat? | CREATE TABLE Dishes (dish_id INT,dish_name VARCHAR(50),ingredients VARCHAR(50)); INSERT INTO Dishes (dish_id,dish_name,ingredients) VALUES (1,'Spaghetti Bolognese','Tomatoes,Ground Beef,Pasta'),(2,'Chicken Curry','Chicken,Coconut Milk,Spices'),(3,'Sushi Roll','Fish,Rice,Seaweed'),(4,'Beef Stew','Beef,Carrots,Potatoes'),(5,'Meat Lovers Pizza','Pepperoni,Sausage,Ham,Cheese'); | SELECT dish_name FROM Dishes WHERE ingredients LIKE '%Meat%' GROUP BY dish_name HAVING COUNT(DISTINCT REGEXP_SPLIT_TO_TABLE(ingredients, '[, ]+')) > 1; |
What is the distribution of security incidents by type (e.g., malware, phishing, etc.) for the last 30 days? | CREATE TABLE incident (incident_id INT,incident_date DATE,incident_type VARCHAR(255)); | SELECT incident_type, COUNT(*) AS incident_count FROM incident WHERE incident_date >= CURDATE() - INTERVAL 30 DAY GROUP BY incident_type; |
What is the earliest launch date for digital assets created by developers from historically underrepresented communities in Asia? | CREATE TABLE digital_assets (id INT,name VARCHAR(255),company VARCHAR(255),launch_date DATE,developer VARCHAR(255)); INSERT INTO digital_assets (id,name,company,launch_date,developer) VALUES (1,'Asset 1','Company A','2021-01-01','Jamila Nguyen'),(2,'Asset 2','Company B','2022-02-15','Minh Tran'); | SELECT MIN(launch_date) FROM digital_assets WHERE developer IN ('Jamila Nguyen', 'Minh Tran') AND country = 'Asia'; |
What's the number of companies in each sector? | CREATE TABLE companies (id INT,sector TEXT); INSERT INTO companies (id,sector) VALUES (1,'technology'),(2,'finance'),(3,'technology'),(4,'healthcare'); | SELECT sector, COUNT(*) FROM companies GROUP BY sector; |
What is the total biomass of all marine species in the Arctic region, grouped by conservation status?" | CREATE TABLE marine_species_biomass (species_name VARCHAR(255),region VARCHAR(255),biomass FLOAT,conservation_status VARCHAR(255)); INSERT INTO marine_species_biomass (species_name,region,biomass,conservation_status) VALUES ('Polar Bear','Arctic',500,'Fully Protected'),('Narwhal','Arctic',300,'Partially Protected'),('Ringed Seal','Arctic',200,'Fully Protected'); | SELECT conservation_status, SUM(biomass) as total_biomass FROM marine_species_biomass WHERE region = 'Arctic' GROUP BY conservation_status; |
Show the number of national security breaches in the last year, and the number of breaches for each country. | CREATE TABLE national_security_breaches (id INT,country TEXT,breach_date DATE); INSERT INTO national_security_breaches (id,country,breach_date) VALUES (1,'USA','2021-01-01'),(2,'UK','2021-02-15'),(3,'USA','2021-03-01'),(4,'Canada','2021-04-15'); | SELECT n.country, COUNT(n.id) as total_breaches FROM national_security_breaches n WHERE n.breach_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR) GROUP BY n.country; |
Insert a new record into the "CarbonOffset" table for a new "EnergyEfficiencyProject2" in "Rio de Janeiro" with an amount of 8000 | CREATE TABLE CarbonOffset (id INT,project_name VARCHAR(20),project_type VARCHAR(20),amount INT); | INSERT INTO CarbonOffset (project_name, project_type, amount) VALUES ('EnergyEfficiencyProject2', 'energy_efficiency', 8000); |
What are the earliest and latest departure times for buses in the city center? | CREATE TABLE schedules (route_id INT,vehicle_id INT,departure_time TIME); INSERT INTO schedules VALUES (1,1,'06:00:00'),(1,2,'06:15:00'),(1,3,'06:30:00'),(2,4,'07:00:00'),(2,5,'07:15:00'); | SELECT MIN(departure_time) AS earliest, MAX(departure_time) AS latest FROM schedules JOIN routes ON schedules.route_id = routes.route_id WHERE routes.city = 'City Center' AND routes.type = 'Bus'; |
List all donors who have made donations in the last 6 months | CREATE TABLE Donations (DonationID INT,DonorID INT,DonationDate DATE,DonationAmount DECIMAL(10,2)); | SELECT DonorID, Donations.FirstName, Donations.LastName FROM Donors JOIN Donations ON Donors.DonorID = Donations.DonorID WHERE DonationDate >= DATE_SUB(CURDATE(), INTERVAL 6 MONTH); |
How many artworks in the 'ArtCollection' table are associated with Indigenous artists? | CREATE TABLE ArtCollection (ArtworkID INT,ArtistID INT,ArtistNationality VARCHAR(50)); INSERT INTO ArtCollection (ArtworkID,ArtistID,ArtistNationality) VALUES (1,1,'American'),(2,2,'Canadian'),(3,3,'Australian'),(4,4,'Indigenous'),(5,5,'African'); | SELECT COUNT(*) AS ArtworksByIndigenousArtists FROM ArtCollection WHERE ArtistNationality = 'Indigenous'; |
What is the minimum number of military personnel in each branch for countries with a population of over 100 million? | CREATE TABLE populations (id INT,country_id INT,population INT); CREATE TABLE military_personnel (id INT,country_id INT,military_branch_id INT,number INT); | SELECT m.name as branch, MIN(mp.number) as min_personnel FROM populations p JOIN military_personnel mp ON p.country_id = mp.country_id JOIN military_branch m ON mp.military_branch_id = m.id WHERE p.population > 100000000 GROUP BY mp.military_branch_id; |
What is the total number of heritage sites in Africa? | CREATE TABLE heritage_sites (id INT,name TEXT,country TEXT,region TEXT); INSERT INTO heritage_sites (id,name,country,region) VALUES (1,'Great Zimbabwe','Zimbabwe','Africa'); | SELECT COUNT(*) FROM heritage_sites WHERE region = 'Africa'; |
Show garment categories with production costs lower than the average production cost for all garment categories. | CREATE TABLE GARMENTS (garment_id INT,category VARCHAR(20),production_cost FLOAT); INSERT INTO GARMENTS VALUES (1,'T-Shirts',10),(2,'Pants',15),(3,'Jackets',20),(4,'Dresses',25); | SELECT category, production_cost FROM GARMENTS WHERE production_cost < (SELECT AVG(production_cost) FROM GARMENTS); |
Update records in the market_trend_table for 'Gadolinium', setting the 'price' to 34.8 and 'demand_volume' to 1550 for year 2019 | CREATE TABLE market_trend_table (rare_earth_element VARCHAR(20),year INT,price FLOAT,demand_volume INT); | UPDATE market_trend_table SET price = 34.8, demand_volume = 1550 WHERE rare_earth_element = 'Gadolinium' AND year = 2019; |
What is the average CO2 emission of electric trains in Madrid? | CREATE TABLE electric_trains (train_id INT,co2_emission FLOAT,city VARCHAR(50)); | SELECT AVG(co2_emission) FROM electric_trains WHERE city = 'Madrid'; |
Show the number of days between the earliest and latest threat intelligence reports for each category. | CREATE TABLE threat_intelligence(report_date DATE,report_category VARCHAR(20)); INSERT INTO threat_intelligence(report_date,report_category) VALUES ('2021-01-01','cyber'),('2021-01-05','terrorism'),('2021-02-01','cyber'),('2021-03-01','foreign_intelligence'),('2021-03-05','foreign_intelligence'); | SELECT report_category, MAX(report_date) - MIN(report_date) as days_between FROM threat_intelligence GROUP BY report_category; |
What is the average calories burned for users from India during their workouts in the month of June 2022? | CREATE TABLE UserData (UserID INT,Country VARCHAR(255)); CREATE TABLE WorkoutData (UserID INT,CaloriesBurned INT,WorkoutDate DATE); INSERT INTO UserData (UserID,Country) VALUES (1,'India'),(2,'Australia'),(3,'India'),(4,'South Africa'),(5,'India'); INSERT INTO WorkoutData (UserID,CaloriesBurned,WorkoutDate) VALUES (1,300,'2022-06-01'),(1,350,'2022-06-02'),(2,250,'2022-06-01'),(3,400,'2022-06-01'),(3,300,'2022-06-02'),(4,200,'2022-06-01'),(5,350,'2022-06-02'); | SELECT AVG(CaloriesBurned) FROM WorkoutData INNER JOIN UserData ON WorkoutData.UserID = UserData.UserID WHERE Country = 'India' AND WorkoutDate >= '2022-06-01' AND WorkoutDate <= '2022-06-30'; |
What is the average calorie intake per meal for Canadian users? | CREATE TABLE users (id INT,name VARCHAR(50),country VARCHAR(50),meal_calories INT); INSERT INTO users (id,name,country,meal_calories) VALUES (1,'John Doe','Canada',600),(2,'Jane Smith','Canada',800); | SELECT AVG(meal_calories) FROM users WHERE country = 'Canada'; |
List the rock types in mines with a production metric between 30000 and 50000, and located in Utah. | CREATE TABLE geological_survey (id INT,mine_id INT,rock_type VARCHAR(50),FOREIGN KEY (mine_id) REFERENCES mines(id)); INSERT INTO geological_survey (id,mine_id,rock_type) VALUES (5,9,'Limestone'); INSERT INTO geological_survey (id,mine_id,rock_type) VALUES (6,10,'Sandstone'); CREATE TABLE mines (id INT,name VARCHAR(50),location VARCHAR(50),production_metric FLOAT,PRIMARY KEY(id)); INSERT INTO mines (id,name,location,production_metric) VALUES (9,'Westfield Mine','Utah',45000); INSERT INTO mines (id,name,location,production_metric) VALUES (10,'Windy Ridge','Utah',32000); | SELECT gs.rock_type FROM geological_survey gs JOIN mines m ON gs.mine_id = m.id WHERE m.production_metric BETWEEN 30000 AND 50000 AND m.location = 'Utah'; |
Show teachers who have not received any professional development in the last 2 years | CREATE TABLE teachers (id INT,name VARCHAR(20),last_pd_date DATE); INSERT INTO teachers (id,name,last_pd_date) VALUES (1,'Ms. Garcia','2020-01-01'); INSERT INTO teachers (id,name,last_pd_date) VALUES (2,'Mr. Nguyen','2021-06-15'); INSERT INTO teachers (id,name,last_pd_date) VALUES (3,'Mx. Patel','2019-12-31'); INSERT INTO teachers (id,name,last_pd_date) VALUES (4,'Mrs. Chen','2021-03-05'); | SELECT name FROM teachers WHERE last_pd_date < DATE_SUB(CURRENT_DATE, INTERVAL 2 YEAR); |
What is the total budget for each program? | CREATE TABLE Programs (id INT,program TEXT,budget DECIMAL(10,2)); INSERT INTO Programs (id,program,budget) VALUES (1,'Feeding the Hungry',5000.00),(2,'Clothing Drive',3000.00); | SELECT program, SUM(budget) FROM Programs GROUP BY program; |
What is the difference in average salary between the top and bottom quartile of employees, by job title? | CREATE TABLE Employees (EmployeeID INT,Gender VARCHAR(10),JobTitle VARCHAR(50),Salary INT); INSERT INTO Employees (EmployeeID,Gender,JobTitle,Salary) VALUES (1,'Male','Manager',70000),(2,'Female','Manager',65000),(3,'Male','Developer',60000),(4,'Female','Developer',62000); | SELECT JobTitle, AVG(CASE WHEN PERCENT_RANK() OVER (PARTITION BY JobTitle ORDER BY Salary) BETWEEN 0 AND 0.25 THEN Salary ELSE NULL END) - AVG(CASE WHEN PERCENT_RANK() OVER (PARTITION BY JobTitle ORDER BY Salary) BETWEEN 0.75 AND 1 THEN Salary ELSE NULL END) AS Salary_Difference FROM Employees GROUP BY JobTitle; |
Which claims had a payment amount greater than $1000 in Texas? | CREATE TABLE ClaimsData (ClaimID INT,Payment DECIMAL(5,2),State VARCHAR(20)); INSERT INTO ClaimsData VALUES (1,500.00,'California'),(2,1500.00,'Texas'),(3,800.00,'California'); | SELECT ClaimID, Payment FROM ClaimsData WHERE State = 'Texas' AND Payment > 1000; |
What is the total number of legal aid cases handled by lawyers from historically underrepresented communities? | CREATE TABLE legal_aid_cases (id INT,lawyer_name TEXT,lawyer_community TEXT); INSERT INTO legal_aid_cases (id,lawyer_name,lawyer_community) VALUES (1,'Aisha Williams','African American'); INSERT INTO legal_aid_cases (id,lawyer_name,lawyer_community) VALUES (2,'Pedro Rodriguez','Hispanic'); | SELECT COUNT(*) FROM legal_aid_cases WHERE lawyer_community IN ('African American', 'Hispanic', 'Indigenous', 'Asian Pacific Islander'); |
What are the top 3 strains with the highest average price in Colorado and Washington? | CREATE TABLE sales (sale_id INT,dispensary_id INT,strain VARCHAR(255),quantity INT,price INT);CREATE TABLE dispensaries (dispensary_id INT,name VARCHAR(255),state VARCHAR(255)); | SELECT strain, AVG(price) as avg_price FROM sales JOIN dispensaries ON sales.dispensary_id = dispensaries.dispensary_id WHERE state IN ('Colorado', 'Washington') GROUP BY strain HAVING COUNT(*) > 5 ORDER BY avg_price DESC LIMIT 3; |
What are the top 3 zip codes with the highest total donation amounts in 'California'? | CREATE TABLE donations (id INT,donor_id INT,org_id INT,zip_code TEXT,donation_amount DECIMAL(10,2)); INSERT INTO donations (id,donor_id,org_id,zip_code,donation_amount) VALUES (1,1,1,'90210',100.00); | SELECT zip_code, SUM(donation_amount) AS total_donated FROM donations WHERE zip_code LIKE '90%' GROUP BY zip_code ORDER BY total_donated DESC LIMIT 3; |
Which chemical has the highest emission rate in the Western region? | CREATE TABLE Emissions (chemical VARCHAR(20),emission_rate INT,location VARCHAR(20)); INSERT INTO Emissions (chemical,emission_rate,location) VALUES ('ChemicalD',150,'Western'),('ChemicalE',170,'Western'); | SELECT chemical, emission_rate FROM Emissions WHERE location = 'Western' ORDER BY emission_rate DESC LIMIT 1; |
List the top 3 states with the highest total revenue in 2022. | CREATE TABLE sales (id INT,dispensary_name TEXT,state TEXT,revenue INT,date DATE); INSERT INTO sales (id,dispensary_name,state,revenue,date) VALUES (1,'Dispensary A','California',2000,'2022-01-01'); INSERT INTO sales (id,dispensary_name,state,revenue,date) VALUES (2,'Dispensary B','Colorado',3000,'2022-01-02'); INSERT INTO sales (id,dispensary_name,state,revenue,date) VALUES (3,'Dispensary C','Washington',1500,'2022-01-03'); INSERT INTO sales (id,dispensary_name,state,revenue,date) VALUES (4,'Dispensary D','California',2500,'2022-01-04'); INSERT INTO sales (id,dispensary_name,state,revenue,date) VALUES (5,'Dispensary E','Colorado',1000,'2022-01-05'); INSERT INTO sales (id,dispensary_name,state,revenue,date) VALUES (6,'Dispensary F','Washington',4000,'2022-01-06'); | SELECT state, SUM(revenue) AS total_revenue FROM sales WHERE date BETWEEN '2022-01-01' AND '2022-12-31' GROUP BY state ORDER BY total_revenue DESC LIMIT 3; |
Which courses were added in the last month? | CREATE TABLE courses (course_id INT,course_name TEXT,added_date DATE); INSERT INTO courses (course_id,course_name,added_date) VALUES (1,'Intro to Psychology','2022-01-05'); | SELECT * FROM courses WHERE added_date >= DATEADD(month, -1, GETDATE()); |
Find the total number of medical equipment items owned by hospitals in Africa. | CREATE TABLE hospitals (id INT,name VARCHAR(50),location VARCHAR(50),equipment_count INT); | SELECT SUM(equipment_count) FROM hospitals WHERE location LIKE '%Africa%'; |
What is the total number of cases in criminal justice reform programs by program type? | CREATE TABLE criminal_justice_reform_programs (id INT,case_number INT,program_type VARCHAR(20)); | SELECT program_type, COUNT(*) FROM criminal_justice_reform_programs GROUP BY program_type; |
Insert data into diversity metrics table | CREATE TABLE diversity_metrics (metric_id INT,category VARCHAR(20),value FLOAT); | INSERT INTO diversity_metrics (metric_id, category, value) VALUES (1, 'Female Founders', 0.35), (2, 'Underrepresented Racial Groups', 0.18), (3, 'LGBTQ+ Founders', 0.05); |
What is the maximum advertising revenue generated in the "Middle East" region in the last month? | CREATE TABLE ad_revenue (post_id INT,region VARCHAR(20),revenue DECIMAL(10,2),ad_date DATE); INSERT INTO ad_revenue (post_id,region,revenue,ad_date) VALUES (1,'North America',100,'2022-01-01'),(2,'Middle East',200,'2022-02-01'),(3,'Middle East',300,'2022-03-01'),(4,'Europe',400,'2022-04-01'),(5,'Middle East',500,'2022-05-01'); | SELECT MAX(revenue) FROM ad_revenue WHERE region = 'Middle East' AND ad_date >= DATE_SUB(CURDATE(), INTERVAL 1 MONTH); |
List the hotels in the hotels table that offer a gym facility but do not offer a spa facility. | CREATE TABLE hotels (hotel_id INT,name VARCHAR(50),facility VARCHAR(50)); INSERT INTO hotels (hotel_id,name,facility) VALUES (1,'Hotel X','spa,gym'),(2,'Hotel Y','gym'),(3,'Hotel Z','spa'); | SELECT * FROM hotels WHERE facility LIKE '%gym%' AND facility NOT LIKE '%spa%'; |
List all invasive marine species in the Baltic Sea. | CREATE TABLE marine_species (id INT,species VARCHAR(255),habitat VARCHAR(255),invasive BOOLEAN); INSERT INTO marine_species (id,species,habitat,invasive) VALUES (1,'Pacific Oyster','Baltic Sea',TRUE),(2,'Green Crab','North Sea',FALSE); | SELECT species FROM marine_species WHERE habitat = 'Baltic Sea' AND invasive = TRUE; |
What is the total duration of the longest project in the 'green_buildings' table? | CREATE TABLE green_buildings (project_number INT,project_name VARCHAR(30),start_date DATE,end_date DATE); INSERT INTO green_buildings (project_number,project_name,start_date,end_date) VALUES (1,'Solar Panel Installation','2020-01-01','2020-03-15'); INSERT INTO green_buildings (project_number,project_name,start_date,end_date) VALUES (2,'Wind Turbine Construction','2019-06-01','2020-01-05'); | SELECT DATEDIFF(end_date, start_date) FROM green_buildings ORDER BY DATEDIFF(end_date, start_date) DESC LIMIT 1; |
What is the total revenue for each country's products? | CREATE TABLE sales_country (product_id INT,brand VARCHAR(255),country VARCHAR(255),revenue FLOAT); INSERT INTO sales_country (product_id,brand,country,revenue) VALUES (1,'Lush','UK',50),(2,'The Body Shop','France',75),(3,'Sephora','USA',100); | SELECT country, SUM(revenue) as total_revenue FROM sales_country GROUP BY country ORDER BY total_revenue DESC; |
What is the name of the researcher who leads the expedition starting on 2022-03-01? | CREATE TABLE Researchers (id INT PRIMARY KEY,name VARCHAR(255),affiliation VARCHAR(255)); INSERT INTO Researchers (id,name,affiliation) VALUES (1,'Sara Ahmed','University of Ottawa'); CREATE TABLE Expeditions (id INT PRIMARY KEY,leader_id INT,start_date DATE); INSERT INTO Expeditions (id,leader_id,start_date) VALUES (1,1,'2022-03-01'); | SELECT name FROM Researchers INNER JOIN Expeditions ON Researchers.id = Expeditions.leader_id WHERE start_date = '2022-03-01'; |
What is the average number of homicides in New York City per year? | CREATE TABLE CrimeStats (city VARCHAR(255),year INT,crimeType VARCHAR(255),totalCrimes INT); INSERT INTO CrimeStats (city,year,crimeType,totalCrimes) VALUES ('New York City',2019,'Homicide',300),('New York City',2020,'Homicide',350); | SELECT AVG(totalCrimes) AS avg_homicides FROM CrimeStats WHERE city = 'New York City' AND crimeType = 'Homicide'; |
How many socially responsible loans have been issued in Canada for each year? | CREATE TABLE socially_responsible_lending (id INT,year INT,country VARCHAR(255),loans INT); | SELECT year, SUM(loans) FROM socially_responsible_lending WHERE country = 'Canada' GROUP BY year; |
What is the average depth of the Indian Ocean? | CREATE TABLE ocean_facts (name TEXT,fact TEXT); INSERT INTO ocean_facts (name,fact) VALUES ('Indian Ocean','3,741 meters deep on average'); CREATE TABLE depths (name TEXT,avg_depth FLOAT); INSERT INTO depths (name,avg_depth) VALUES ('Indian Ocean',3741); | SELECT avg_depth FROM depths WHERE name = 'Indian Ocean'; |
List all mental health providers who speak a language other than English. | CREATE TABLE MentalHealthProviders (ProviderID INT,Name VARCHAR(50),Language VARCHAR(20)); INSERT INTO MentalHealthProviders (ProviderID,Name,Language) VALUES (1,'John Doe','Spanish'),(2,'Jane Smith','French'),(3,'Mary Johnson','English'); | SELECT * FROM MentalHealthProviders WHERE Language != 'English'; |
What is the average value of 'Healthcare Disparities' metric for the year 2020? | CREATE TABLE HealthcareDisparities (ID INT PRIMARY KEY,Metric VARCHAR(50),Value DECIMAL(5,2),Year INT); INSERT INTO HealthcareDisparities (ID,Metric,Value,Year) VALUES (1,'Healthcare Disparities',0.15,2018); INSERT INTO HealthcareDisparities (ID,Metric,Value,Year) VALUES (2,'Healthcare Disparities',0.12,2019); INSERT INTO HealthcareDisparities (ID,Metric,Value,Year) VALUES (3,'Healthcare Disparities',0.18,2020); | SELECT AVG(Value) FROM HealthcareDisparities WHERE Metric = 'Healthcare Disparities' AND Year = 2020; |
What is the total number of investigative journalism projects conducted in the US, Canada, and Mexico, between 2018 and 2022? | CREATE TABLE projects (id INT,title TEXT,location TEXT,start_date DATE,end_date DATE); INSERT INTO projects (id,title,location,start_date,end_date) VALUES (1,'Project 1','US','2018-01-01','2018-12-31'); INSERT INTO projects (id,title,location,start_date,end_date) VALUES (2,'Project 2','Canada','2020-01-01','2020-12-31'); INSERT INTO projects (id,title,location,start_date,end_date) VALUES (3,'Project 3','Mexico','2022-01-01','2022-12-31'); | SELECT SUM(DATEDIFF(end_date, start_date) + 1) FROM projects WHERE location IN ('US', 'Canada', 'Mexico') AND start_date BETWEEN '2018-01-01' AND '2022-12-31'; |
What is the total number of animals in the endangered_species table that have a specific conservation status? | CREATE TABLE endangered_species (id INT,animal_name VARCHAR(255),population INT,conservation_status VARCHAR(255)); | SELECT SUM(population) FROM endangered_species WHERE conservation_status = 'Critically Endangered'; |
Which countries have the most rural infrastructure projects in the 'rural_development' schema? | CREATE TABLE infrastructure_projects(project_id INT,country VARCHAR(50),completion_year INT); INSERT INTO infrastructure_projects VALUES (1,'India',2020),(2,'Brazil',2021),(3,'India',2022); | SELECT country, COUNT(*) as num_projects FROM infrastructure_projects GROUP BY country ORDER BY num_projects DESC; |
List the top 5 destinations in Oceania for international tourists, excluding Australia. | CREATE TABLE oceania_tourism (country VARCHAR(50),tourists INT); INSERT INTO oceania_tourism VALUES ('Australia',9000000),('New Zealand',4500000),('Fiji',1200000),('New Caledonia',1100000),('Vanuatu',1000000); | SELECT country FROM oceania_tourism WHERE country != 'Australia' ORDER BY tourists DESC LIMIT 5; |
Find the number of digital divide initiatives in Southeast Asia, by country. | CREATE TABLE digital_divide_indonesia(id INT,initiative VARCHAR(50),country VARCHAR(10)); INSERT INTO digital_divide_indonesia VALUES (1,'Indonesia Digital Divide','Indonesia'); CREATE TABLE digital_divide_thailand(id INT,initiative VARCHAR(50),country VARCHAR(10)); INSERT INTO digital_divide_thailand VALUES (1,'Thailand Digital Inclusion','Thailand'); CREATE TABLE digital_divide_philippines(id INT,initiative VARCHAR(50),country VARCHAR(10)); INSERT INTO digital_divide_philippines VALUES (1,'Philippines Digital Access','Philippines'); | SELECT country, COUNT(initiative) AS num_initiatives FROM digital_divide_indonesia GROUP BY country UNION ALL SELECT country, COUNT(initiative) AS num_initiatives FROM digital_divide_thailand GROUP BY country UNION ALL SELECT country, COUNT(initiative) AS num_initiatives FROM digital_divide_philippines GROUP BY country; |
List all defense projects with their start and end dates from the 'projects' table | CREATE TABLE projects (id INT,project_name VARCHAR(255),start_date DATE,end_date DATE,contractor VARCHAR(255)); INSERT INTO projects (id,project_name,start_date,end_date,contractor) VALUES (1,'Stealth Fighter Development','2017-04-01','2022-12-31','Lockheed Martin'); INSERT INTO projects (id,project_name,start_date,end_date,contractor) VALUES (2,'Missile Shield Upgrade','2018-09-15','2023-06-30','Raytheon'); | SELECT project_name, start_date, end_date FROM projects; |
List all unique donor names who have donated more than $500 in total and have also volunteered for at least one program. | CREATE TABLE Donations (id INT,donor_name VARCHAR(50),donation_amount DECIMAL(10,2),donation_date DATE); CREATE TABLE VolunteerEvents (id INT,donor_name VARCHAR(50),total_volunteers INT,event_date DATE); | SELECT Donations.donor_name FROM Donations INNER JOIN (SELECT donor_name FROM VolunteerEvents GROUP BY donor_name HAVING SUM(total_volunteers) > 0) AS VolunteeredDonors ON Donations.donor_name = VolunteeredDonors.donor_name GROUP BY Donations.donor_name HAVING SUM(Donations.donation_amount) > 500; |
Find the country with the lowest production quantity of chemical 'XY987' | CREATE TABLE chemical_production (id INT PRIMARY KEY,chemical_id VARCHAR(10),quantity INT,country VARCHAR(50)); INSERT INTO chemical_production (id,chemical_id,quantity,country) VALUES (1,'XY987',700,'Brazil'),(2,'GH247',600,'India'),(3,'XY987',300,'Australia'),(4,'GH247',500,'India'),(5,'GH247',800,'Brazil'),(6,'XY987',200,'Chile'); | SELECT country FROM chemical_production WHERE chemical_id = 'XY987' GROUP BY country ORDER BY SUM(quantity) ASC LIMIT 1; |
What is the minimum claim amount for policyholders in Florida? | CREATE TABLE claims (policyholder_id INT,claim_amount DECIMAL(10,2),state VARCHAR(2)); INSERT INTO claims (policyholder_id,claim_amount,state) VALUES (1,500,'FL'),(2,200,'FL'),(3,150,'FL'); | SELECT MIN(claim_amount) FROM claims WHERE state = 'FL'; |
How many concert tickets were sold in Sydney? | CREATE TABLE ConcertTicketSales (id INT,city VARCHAR(20),tickets_sold INT); INSERT INTO ConcertTicketSales (id,city,tickets_sold) VALUES (1,'Sydney',6000),(2,'Melbourne',8000); | SELECT tickets_sold FROM ConcertTicketSales WHERE city = 'Sydney'; |
List the top 3 most expensive ingredients sourced from Brazil? | CREATE TABLE ingredients (ingredient_id INT,ingredient_name TEXT,sourcing_country TEXT,cost DECIMAL(5,2)); INSERT INTO ingredients (ingredient_id,ingredient_name,sourcing_country,cost) VALUES (1,'Mica','Brazil',56.78),(2,'Jojoba Oil','Argentina',23.99),(3,'Rosehip Oil','Chile',34.56); | SELECT * FROM (SELECT ingredient_name, cost, ROW_NUMBER() OVER (ORDER BY cost DESC) AS rn FROM ingredients WHERE sourcing_country = 'Brazil') sub WHERE rn <= 3; |
What is the total quantity of materials used by all brands? | CREATE TABLE Brands (BrandID INT,BrandName VARCHAR(50)); INSERT INTO Brands (BrandID,BrandName) VALUES (1,'Brand1'),(2,'Brand2'),(3,'Brand3'); CREATE TABLE BrandMaterials (BrandID INT,MaterialID INT,Quantity INT); INSERT INTO BrandMaterials (BrandID,MaterialID,Quantity) VALUES (1,1,100),(1,2,200),(2,1,150); | SELECT SUM(Quantity) FROM BrandMaterials; |
What are the names of the autonomous driving research papers with a publication date in the first half of 2021? | CREATE TABLE ResearchPapers (ID INT,Title TEXT,Author TEXT,PublicationDate DATE); INSERT INTO ResearchPapers (ID,Title,Author,PublicationDate) VALUES (1,'Deep Learning for Autonomous Driving','John Doe','2021-03-15'); INSERT INTO ResearchPapers (ID,Title,Author,PublicationDate) VALUES (2,'Reinforcement Learning in Autonomous Vehicles','Jane Smith','2021-07-22'); | SELECT Title FROM ResearchPapers WHERE PublicationDate BETWEEN '2021-01-01' AND '2021-06-30'; |
What is the total quantity of women's garments made from recycled polyester sold in Canada? | CREATE TABLE sales (id INT,category VARCHAR(255),subcategory VARCHAR(255),gender VARCHAR(50),material VARCHAR(50),country VARCHAR(50),quantity INT); INSERT INTO sales (id,category,subcategory,gender,material,country,quantity) VALUES (1,'Tops','T-Shirts','Female','Recycled Polyester','Canada',50); INSERT INTO sales (id,category,subcategory,gender,material,country,quantity) VALUES (2,'Pants','Jeans','Female','Recycled Polyester','Canada',30); INSERT INTO sales (id,category,subcategory,gender,material,country,quantity) VALUES (3,'Outerwear','Jackets','Female','Recycled Polyester','Canada',20); | SELECT SUM(quantity) FROM sales WHERE gender = 'Female' AND material = 'Recycled Polyester' AND country = 'Canada'; |
What are the total labor hours for all sustainable building projects in the city of Seattle? | CREATE TABLE project (id INT,city VARCHAR(20),type VARCHAR(20),hours INT); INSERT INTO project (id,city,type,hours) VALUES (1,'Seattle','Sustainable',500),(2,'NYC','Sustainable',800),(3,'Seattle','Traditional',300); | SELECT SUM(hours) FROM project WHERE city = 'Seattle' AND type = 'Sustainable'; |
create a table for tracking social impact investments | CREATE TABLE if not exists investment_strategies (id INT PRIMARY KEY,strategy TEXT); | CREATE TABLE if not exists investment_outcomes (id INT, strategy_id INT, outcome TEXT, PRIMARY KEY (id), FOREIGN KEY (strategy_id) REFERENCES investment_strategies (id)); |
Delete all agricultural training programs that were completed before 2018 and have a duration of less than two weeks. | CREATE TABLE trainings (id INT,title VARCHAR(50),completion_date DATE,duration INT); INSERT INTO trainings (id,title,completion_date,duration) VALUES (1,'Agroecology Course','2017-02-01',7); INSERT INTO trainings (id,title,completion_date,duration) VALUES (2,'Organic Farming Workshop','2019-08-15',5); | DELETE FROM trainings WHERE completion_date < '2018-01-01' AND duration < 14; |
How many donations were received in each month of 2020? | CREATE TABLE Donations (DonationID INT,DonorID INT,Amount DECIMAL(10,2),DonationDate DATE); INSERT INTO Donations VALUES (1,1,100.00,'2020-01-01'),(2,1,200.00,'2020-02-01'),(3,2,300.00,'2020-03-01'); | SELECT MONTH(DonationDate), COUNT(DonationID) FROM Donations WHERE YEAR(DonationDate) = 2020 GROUP BY MONTH(DonationDate); |
Delete records of electric cars sold in 'South America' from the 'auto_sales' table. | CREATE TABLE auto_sales (id INT,region VARCHAR(20),vehicle_type VARCHAR(10),sale_type VARCHAR(10)); INSERT INTO auto_sales (id,region,vehicle_type,sale_type) VALUES (1,'North America','EV','Sold'),(2,'South America','EV','Sold'),(3,'Asia','Hybrid','Leased'); | DELETE FROM auto_sales WHERE vehicle_type = 'EV' AND region = 'South America'; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.