instruction
stringlengths 0
1.06k
| input
stringlengths 11
5.3k
| response
stringlengths 2
4.44k
|
---|---|---|
How many repeat attendees have visited 'MuseumY' in the past year, and what is the average number of visits per attendee? | CREATE TABLE MuseumY (attendee_id INT,visit_date DATE); CREATE TABLE Attendees (attendee_id INT,first_name VARCHAR(50),last_name VARCHAR(50)); | SELECT AVG(visits) FROM (SELECT a.attendee_id, COUNT(*) AS visits FROM MuseumY m JOIN Attendees a ON m.attendee_id = a.attendee_id WHERE m.visit_date >= DATEADD(year, -1, GETDATE()) GROUP BY a.attendee_id) AS repeat_attendees; |
Which songs have the highest and lowest streams within their genre? | CREATE TABLE Music (SongId INT,SongName VARCHAR(50),Artist VARCHAR(50),Genre VARCHAR(50),Streams INT); INSERT INTO Music (SongId,SongName,Artist,Genre,Streams) VALUES (1,'SongA','ArtistX','Pop',1000000),(2,'SongB','ArtistY','Rock',800000),(3,'SongC','ArtistZ','Pop',1200000); | SELECT SongName, Genre, Streams, RANK() OVER(PARTITION BY Genre ORDER BY Streams DESC) AS Rank FROM Music; |
What is the total construction labor cost for plumbers in Georgia? | CREATE TABLE construction_labor (state VARCHAR(20),job VARCHAR(50),cost FLOAT); INSERT INTO construction_labor VALUES ('Georgia','Plumber',58.0),('Georgia','Plumber',59.0),('Georgia','Carpenter',52.0); | SELECT SUM(cost) FROM construction_labor WHERE state = 'Georgia' AND job = 'Plumber'; |
Find the total rainfall for each country and year, and rank them. | CREATE TABLE RainfallData (Country VARCHAR(50),Year INT,Rainfall DECIMAL(5,2)); INSERT INTO RainfallData (Country,Year,Rainfall) VALUES ('Canada',2020,53.1),('Canada',2019,60.2),('Mexico',2020,21.2),('Mexico',2019,22.5); | SELECT Country, Year, SUM(Rainfall) as TotalRainfall, RANK() OVER (PARTITION BY Year ORDER BY SUM(Rainfall) DESC) as Rank FROM RainfallData GROUP BY Country, Year; |
What are the average climate finances spent by organizations in 'americas' and 'europe'? | CREATE TABLE org_climate_finance (region VARCHAR(20),amount FLOAT); INSERT INTO org_climate_finance (region,amount) VALUES ('americas',30000),('europe',45000),('africa',35000),('asia',25000); | SELECT AVG(amount) FROM org_climate_finance WHERE region IN ('americas', 'europe'); |
Delete records of R&D expenditures greater than $100,000 in Q1 2021 | CREATE TABLE rd_expenditures (expenditure_date DATE,amount DECIMAL(10,2),quarter INT,year INT); INSERT INTO rd_expenditures VALUES ('2021-01-01',75000,1,2021),('2021-02-01',50000,1,2021),('2021-03-01',120000,1,2021) | DELETE FROM rd_expenditures WHERE amount > 100000 AND quarter = 1 AND year = 2021 |
Average healthcare access score in urban areas by year. | CREATE TABLE HealthcareAccessScore (Area VARCHAR(50),Score INT,Year INT); INSERT INTO HealthcareAccessScore (Area,Score,Year) VALUES ('Urban',80,2018),('Urban',82,2019),('Rural',70,2018); | SELECT Year, AVG(Score) FROM HealthcareAccessScore WHERE Area = 'Urban' GROUP BY Year; |
How many males in Texas have accessed healthcare services in the last month? | CREATE TABLE HealthcareAccess (ID INT,Gender VARCHAR(10),AccessDate DATE); INSERT INTO HealthcareAccess (ID,Gender,AccessDate) VALUES (1,'Male','2022-01-15'); | SELECT COUNT(*) FROM HealthcareAccess WHERE Gender = 'Male' AND AccessDate >= DATEADD(MONTH, -1, GETDATE()) AND State = 'Texas'; |
Show the sum of investments by year and industry | CREATE TABLE investments (id INT,investment_year INT,industry VARCHAR(255),investment_amount DECIMAL(10,2)); INSERT INTO investments (id,investment_year,industry,investment_amount) VALUES (1,2020,'Tech',50000.00),(2,2019,'Biotech',20000.00),(3,2020,'Tech',75000.00); | SELECT investment_year, industry, SUM(investment_amount) as total_investments FROM investments GROUP BY investment_year, industry; |
Update the policy advocacy budget for the Native American community in California to $500,000 for the current fiscal year. | CREATE TABLE policy_advocacy_budget (id INT PRIMARY KEY,community VARCHAR(255),state VARCHAR(255),fiscal_year INT,budget DECIMAL(10,2)); | UPDATE policy_advocacy_budget SET budget = 500000.00 WHERE community = 'Native American' AND state = 'California' AND fiscal_year = YEAR(CURDATE()); |
How many whale sharks have been spotted in each location? | CREATE TABLE whale_sharks (id INT,name TEXT,location TEXT); INSERT INTO whale_sharks (id,name,location) VALUES (1,'Whale Shark 1','Atlantic'),(2,'Whale Shark 2','Pacific'),(3,'Whale Shark 3','Atlantic'),(4,'Whale Shark 4','Indian'),(5,'Whale Shark 5','Atlantic'); | SELECT location, COUNT(*) as spotted_count FROM whale_sharks GROUP BY location; |
What is the average depth of all marine protected areas, grouped by country? | CREATE TABLE marine_protected_areas (id INT,country VARCHAR(50),name VARCHAR(50),area_sqkm FLOAT,avg_depth FLOAT); INSERT INTO marine_protected_areas (id,country,name,area_sqkm,avg_depth) VALUES (1,'Australia','Great Barrier Reef',344400,-2000); INSERT INTO marine_protected_areas (id,country,name,area_sqkm,avg_depth) VALUES (2,'Canada','Gwaii Haanas National Park',14280,-220); | SELECT country, AVG(avg_depth) FROM marine_protected_areas GROUP BY country; |
What is the total number of transactions for the digital asset 'ETH' on a given date? | CREATE TABLE digital_assets (asset_name VARCHAR(10),transaction_count INT); INSERT INTO digital_assets (asset_name,transaction_count) VALUES ('BTC',5000),('ETH',7000),('LTC',3000); | SELECT transaction_count FROM digital_assets WHERE asset_name = 'ETH'; |
How many vegan makeup products were sold in India in Q1 of 2022? | CREATE TABLE MakeupSales (sale_id INT,product_id INT,sale_price DECIMAL(5,2),sale_date DATE,is_vegan BOOLEAN,country TEXT); INSERT INTO MakeupSales (sale_id,product_id,sale_price,sale_date,is_vegan,country) VALUES (1,701,14.99,'2022-01-25',true,'India'); | SELECT COUNT(*) FROM MakeupSales WHERE is_vegan = true AND country = 'India' AND sale_date BETWEEN '2022-01-01' AND '2022-03-31'; |
What is the total sales revenue of non-organic skincare products in the North American market? | CREATE TABLE SkincareSales (productID INT,productName VARCHAR(50),region VARCHAR(50),revenue DECIMAL(10,2)); INSERT INTO SkincareSales (productID,productName,region,revenue) VALUES (1,'Nourishing Cream','Europe',5000.00),(2,'Soothing Lotion','Europe',7000.00),(3,'Regenerating Serum','Europe',8000.00),(4,'Revitalizing Moisturizer','North America',6000.00),(5,'Purifying Cleanser','North America',9000.00); CREATE TABLE ProductIngredients (productID INT,ingredient VARCHAR(50),organic BOOLEAN); INSERT INTO ProductIngredients (productID,ingredient,organic) VALUES (1,'Aloe Vera',true),(2,'Chamomile',true),(3,'Retinol',false),(4,'Hyaluronic Acid',false),(5,'Glycerin',false); | SELECT SUM(revenue) FROM SkincareSales INNER JOIN ProductIngredients ON SkincareSales.productID = ProductIngredients.productID WHERE organic = false AND region = 'North America'; |
What was the maximum ticket sales for any event in Tokyo? | CREATE TABLE EventData (id INT,city VARCHAR(50),ticket_sales INT); INSERT INTO EventData (id,city,ticket_sales) VALUES (1,'Tokyo',1200),(2,'Tokyo',1500),(3,'Seoul',1800),(4,'Seoul',1000),(5,'Osaka',1300); | SELECT MAX(ticket_sales) FROM EventData WHERE city = 'Tokyo'; |
Which defense contracts have the highest total value, and what are their respective values? | CREATE TABLE Defense_Contracts (Contract_ID INT,Contract_Name VARCHAR(255),Agency VARCHAR(255),Value DECIMAL(18,2)); INSERT INTO Defense_Contracts (Contract_ID,Contract_Name,Agency,Value) VALUES (1,'Contract A','DOD',5000000),(2,'Contract B','DOJ',6000000),(3,'Contract C','DOD',7000000),(4,'Contract D','CIA',8000000); | SELECT Contract_Name, Value FROM (SELECT Contract_Name, Value, ROW_NUMBER() OVER (ORDER BY Value DESC) as Rank FROM Defense_Contracts) as Ranked_Contracts WHERE Rank <= 3; |
How many peacekeeping operations were conducted by each country in Q3 of 2018? | CREATE TABLE peacekeeping_operations (operation_id INT,country_id INT,quarter INT,year INT,FOREIGN KEY (country_id) REFERENCES country(id)); | SELECT c.name, COUNT(p.operation_id) as total_operations FROM country c INNER JOIN peacekeeping_operations p ON c.id = p.country_id WHERE p.year = 2018 AND p.quarter BETWEEN 3 AND 3 GROUP BY c.name; |
List all transactions with a value greater than $10,000, along with the customer ID and the transaction date, in descending order of transaction date? | CREATE TABLE transactions (transaction_id INT,customer_id INT,transaction_value DECIMAL(10,2),transaction_date DATE); INSERT INTO transactions (transaction_id,customer_id,transaction_value,transaction_date) VALUES (1,1,12000,'2021-07-01'),(2,2,35000,'2021-06-15'),(3,1,8000,'2021-05-05'); | SELECT * FROM transactions WHERE transaction_value > 10000 ORDER BY transaction_date DESC; |
What is the average account balance for customers in each investment strategy? | CREATE TABLE customers (customer_id INT,name VARCHAR(50),age INT,region VARCHAR(20),account_balance DECIMAL(10,2),strategy_name VARCHAR(50)); INSERT INTO customers (customer_id,name,age,region,account_balance,strategy_name) VALUES (1,'John Doe',35,'Southeast',15000.00,'Equity'),(2,'Jane Smith',45,'Northeast',20000.00,'Bond'),(3,'Mike Johnson',50,'Southeast',25000.00,'Equity'),(4,'Alice Davis',25,'Midwest',10000.00,'Bond'),(5,'Bob Brown',60,'Northwest',30000.00,'Real Estate'); | SELECT strategy_name, AVG(account_balance) FROM customers GROUP BY strategy_name; |
What is the total number of high-risk accounts in the Northwest region? | CREATE TABLE accounts_by_region (id INT,region VARCHAR(20),risk_level VARCHAR(10)); INSERT INTO accounts_by_region (id,region,risk_level) VALUES (1,'Northwest','high'),(2,'Southwest','medium'),(3,'Northwest','high'); | SELECT COUNT(*) FROM accounts_by_region WHERE region = 'Northwest' AND risk_level = 'high'; |
What is the average weight of cargo handled by vessels in the 'Bulk Carrier' type at each port? | CREATE TABLE ports (id INT,name VARCHAR(50),location VARCHAR(50),un_code VARCHAR(10)); CREATE TABLE vessels (id INT,name VARCHAR(50),type VARCHAR(50),year_built INT,port_id INT); CREATE TABLE cargo (id INT,description VARCHAR(50),weight FLOAT,port_id INT,vessel_id INT); CREATE VIEW vessel_cargo AS SELECT v.name AS vessel_name,c.description AS cargo_description,c.weight FROM vessels v JOIN cargo c ON v.id = c.vessel_id; | SELECT p.name AS port_name, AVG(vc.weight) AS avg_weight FROM ports p JOIN vessels v ON p.id = v.port_id JOIN vessel_cargo vc ON v.name = vc.vessel_name WHERE v.type = 'Bulk Carrier' GROUP BY p.name; |
What is the total weight of cargo handled by each port in february_2022 from the cargo_handling table? | CREATE TABLE cargo_handling (transaction_id INT,port VARCHAR(255),date DATE,weight INT); INSERT INTO cargo_handling (transaction_id,port,date,weight) VALUES (1,'PortA','2022-02-01',500),(2,'PortB','2022-02-05',700),(3,'PortA','2022-02-10',400); | SELECT port, SUM(weight) as february_total_weight FROM cargo_handling WHERE date BETWEEN '2022-02-01' AND '2022-02-28' GROUP BY port; |
What is the average salary of employees in factories with a certain certification? | CREATE TABLE factories (factory_id INT,name VARCHAR(100),location VARCHAR(100),certified BOOLEAN); CREATE TABLE employees (employee_id INT,factory_id INT,name VARCHAR(100),position VARCHAR(100),salary INT); INSERT INTO factories (factory_id,name,location,certified) VALUES (1,'ABC Factory','New York',TRUE),(2,'XYZ Factory','California',FALSE),(3,'LMN Factory','Texas',TRUE),(4,'PQR Factory','Canada',FALSE); INSERT INTO employees (employee_id,factory_id,name,position,salary) VALUES (1,1,'John Doe','Engineer',70000),(2,1,'Jane Smith','Manager',80000),(3,2,'Mike Johnson','Operator',60000),(4,3,'Sara Brown','Engineer',75000),(5,3,'David Williams','Manager',85000),(6,4,'Emily Davis','Engineer',90000); | SELECT AVG(employees.salary) FROM factories INNER JOIN employees ON factories.factory_id = employees.factory_id WHERE factories.certified = TRUE; |
What is the minimum and maximum average age of healthcare workers in 'rural_hospitals' table? | CREATE TABLE rural_hospitals (id INT,name TEXT,location TEXT,num_workers INT,avg_age FLOAT); INSERT INTO rural_hospitals (id,name,location,num_workers,avg_age) VALUES (1,'Rural Hospital A','Rural Area 1',50,50.1),(2,'Rural Hospital B','Rural Area 2',75,48.5); | SELECT MIN(avg_age), MAX(avg_age) FROM rural_hospitals; |
Display the number of unique users who have streamed or downloaded music on each platform in Africa. | CREATE TABLE users (id INT,name TEXT,country TEXT); CREATE TABLE user_actions (id INT,user_id INT,action TEXT,album_id INT,platform TEXT); CREATE VIEW platform_users_africa AS SELECT platform,COUNT(DISTINCT user_id) as user_count FROM user_actions JOIN users u ON user_actions.user_id = u.id WHERE u.country IN ('Nigeria','South Africa','Egypt','Algeria','Morocco'); | SELECT platform, user_count FROM platform_users_africa; |
What is the average mental health score of students for each grade level, ordered by the average score? | CREATE TABLE grades (grade_id INT,grade_name VARCHAR(50)); INSERT INTO grades VALUES (1,'Grade 1'),(2,'Grade 2'),(3,'Grade 3'); CREATE TABLE student_mental_health (student_id INT,grade_id INT,mental_health_score INT); INSERT INTO student_mental_health VALUES (1,1,85),(2,1,80),(3,2,90),(4,2,80),(5,3,75),(6,3,70); | SELECT grade_id, AVG(mental_health_score) as avg_score FROM student_mental_health GROUP BY grade_id ORDER BY avg_score DESC; |
How many renewable energy power plants are there in Texas? | CREATE TABLE power_plants (state VARCHAR(255),source_type VARCHAR(255),count INT); INSERT INTO power_plants (state,source_type,count) VALUES ('Texas','Wind',45),('Texas','Solar',25),('Texas','Hydro',10); | SELECT SUM(count) FROM power_plants WHERE state = 'Texas'; |
What is the maximum solar capacity in Mexico? | CREATE TABLE solar_capacity (id INT,name TEXT,country TEXT,capacity FLOAT); | SELECT MAX(capacity) FROM solar_capacity WHERE country = 'Mexico'; |
Count the number of wells drilled by CompanyA | CREATE TABLE wells (id INT,well_name VARCHAR(255),location VARCHAR(255),drill_year INT,company VARCHAR(255)); INSERT INTO wells (id,well_name,location,drill_year,company) VALUES (1,'Well001','Texas',2020,'CompanyA'); INSERT INTO wells (id,well_name,location,drill_year,company) VALUES (2,'Well002','Colorado',2019,'CompanyB'); INSERT INTO wells (id,well_name,location,drill_year,company) VALUES (3,'Well003','California',2019,'CompanyC'); INSERT INTO wells (id,well_name,location,drill_year,company) VALUES (4,'Well004','Texas',2018,'CompanyA'); | SELECT COUNT(*) FROM wells WHERE company = 'CompanyA'; |
What is the average number of points scored by each hockey player in the NHL? | CREATE TABLE hockey_players (id INT,name VARCHAR(50),position VARCHAR(20),points INT); INSERT INTO hockey_players (id,name,position,points) VALUES (1,'Sidney Crosby','Center',100),(2,'Alex Ovechkin','Left Wing',110),(3,'Connor McDavid','Center',120); CREATE TABLE nhl_teams (id INT,team_name VARCHAR(50),players_id INT); INSERT INTO nhl_teams (id,team_name,players_id) VALUES (1,'Penguins',1),(2,'Capitals',2),(3,'Oilers',3); | SELECT position, AVG(points) FROM hockey_players JOIN nhl_teams ON hockey_players.id = nhl_teams.players_id GROUP BY position; |
Find the intersection of AI and accessibility research projects in the EU and those in Africa. | CREATE SCHEMA if not exists accessibility; CREATE TABLE if not exists accessibility.research (id INT PRIMARY KEY,project_name VARCHAR(255),region VARCHAR(255)); INSERT INTO accessibility.research (id,project_name,region) VALUES (1,'AI for Accessibility EU','EU'),(2,'Accessibility Africa','Africa'),(3,'AI for Accessibility Africa','Africa'),(4,'Accessibility EU','EU'); | SELECT project_name FROM accessibility.research WHERE region = 'EU' INTERSECT SELECT project_name FROM accessibility.research WHERE region = 'Africa'; |
Update the "registration_date" of the student "Sofia Garcia" in the "students" table to "2021-10-01" | CREATE TABLE students (id INT PRIMARY KEY,name VARCHAR(50),country VARCHAR(50),registration_date DATE); | UPDATE students SET registration_date = '2021-10-01' WHERE name = 'Sofia Garcia'; |
What is the average price of eco-friendly materials used in garment production across different countries? | CREATE TABLE eco_materials (id INT,country VARCHAR(50),material VARCHAR(50),price DECIMAL(5,2)); INSERT INTO eco_materials (id,country,material,price) VALUES (1,'Nepal','Organic Cotton',2.50),(2,'Bangladesh','Hemp',3.20),(3,'India','Tencel',2.80); | SELECT AVG(price) as avg_price, country FROM eco_materials GROUP BY country; |
Which sustainable materials are used by companies in the 'Asia-Pacific' region? | CREATE TABLE Companies (id INT,name VARCHAR(255),region VARCHAR(255)); INSERT INTO Companies (id,name,region) VALUES (1,'CompanyA','Asia-Pacific'),(2,'CompanyB','Europe'),(3,'CompanyC','Asia-Pacific'); CREATE TABLE Materials (id INT,company_id INT,material VARCHAR(255),quantity INT); INSERT INTO Materials (id,company_id,material,quantity) VALUES (1,1,'Organic cotton',500),(2,1,'Recycled polyester',300),(3,2,'Organic linen',400),(4,3,'Organic cotton',600),(5,3,'Tencel',700); | SELECT DISTINCT Materials.material FROM Companies JOIN Materials ON Companies.id = Materials.company_id WHERE Companies.region = 'Asia-Pacific'; |
List all Shariah-compliant financial products offered in the Southeast Asian region | CREATE TABLE shariah_compliant_products (id INT PRIMARY KEY,product_name VARCHAR(100),region VARCHAR(50)); INSERT INTO shariah_compliant_products (id,product_name,region) VALUES (1,'Product A','Southeast Asia'),(2,'Product B','Middle East'),(3,'Product C','Southeast Asia'); | SELECT product_name FROM shariah_compliant_products WHERE region = 'Southeast Asia'; |
List the names and account balances for customers who have both a Shariah-compliant mortgage and a socially responsible loan? | CREATE TABLE shariah_mortgages (mortgage_id INT,customer_id INT,customer_name TEXT,account_balance DECIMAL); CREATE TABLE socially_responsible_loans (loan_id INT,customer_id INT,customer_name TEXT,account_balance DECIMAL); CREATE TABLE shariah_loans (loan_id INT,mortgage_id INT); | SELECT sm.customer_name, sm.account_balance FROM shariah_mortgages sm JOIN shariah_loans sl ON sm.mortgage_id = sl.mortgage_id JOIN socially_responsible_loans srl ON sm.customer_id = srl.customer_id; |
How many volunteers are there in total, and how many of them are from Africa? | CREATE TABLE volunteers (id INT,name TEXT,region TEXT); INSERT INTO volunteers (id,name,region) VALUES (1,'Alice','North America'),(2,'Bob','Europe'),(3,'Charlie','Africa'); | SELECT COUNT(*), SUM(region = 'Africa') FROM volunteers; |
List all suppliers from India with more than 3 delivery incidents in the last 6 months. | CREATE TABLE FoodSuppliers (supplier_id INTEGER,supplier_name TEXT,country TEXT,delivery_incidents INTEGER,last_delivery_date DATETIME); INSERT INTO FoodSuppliers (supplier_id,supplier_name,country,delivery_incidents,last_delivery_date) VALUES (1,'Supplier A','India',4,'2022-01-15 12:00:00'); | SELECT supplier_name, country FROM FoodSuppliers WHERE country = 'India' AND delivery_incidents > 3 AND last_delivery_date >= DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH); |
What was the total number of open data initiatives in Africa in 2018? | CREATE TABLE africa_countries (id INT PRIMARY KEY,country VARCHAR(20)); INSERT INTO africa_countries (id,country) VALUES (1,'Nigeria'); INSERT INTO africa_countries (id,country) VALUES (2,'South Africa'); INSERT INTO open_data (id,country,year,num_initiatives) VALUES (1,'Nigeria',2018,20); INSERT INTO open_data (id,country,year,num_initiatives) VALUES (2,'South Africa',2018,30); | SELECT SUM(num_initiatives) FROM open_data INNER JOIN africa_countries ON open_data.country = africa_countries.country WHERE open_data.year = 2018; |
Who are the top 3 donors for open data initiatives in the city of Chicago? | CREATE TABLE donors (id INT,name VARCHAR(100),city VARCHAR(50),amount DECIMAL(10,2)); INSERT INTO donors VALUES (1,'Donor A','Chicago',5000.00); INSERT INTO donors VALUES (2,'Donor B','Chicago',10000.00); INSERT INTO donors VALUES (3,'Donor C','Chicago',7500.00); | SELECT d.name, d.amount FROM donors d WHERE d.city = 'Chicago' ORDER BY d.amount DESC LIMIT 3; |
Who are the top 3 authors with the most citations in the Mathematics department in the past 5 years? | CREATE TABLE authors (id INT,name VARCHAR(50),department VARCHAR(50)); INSERT INTO authors (id,name,department) VALUES (1,'Author Name','Mathematics'); CREATE TABLE publications (id INT,title VARCHAR(100),author VARCHAR(50),journal VARCHAR(50),year INT,cites INT); INSERT INTO publications (id,title,author,journal,year,cites) VALUES (1,'Publication Title','Author Name','Journal Name',2021,10); | SELECT author, SUM(cites) as total_cites FROM publications WHERE author IN (SELECT name FROM authors WHERE department = 'Mathematics') AND year BETWEEN YEAR(CURRENT_DATE) - 5 AND YEAR(CURRENT_DATE) GROUP BY author ORDER BY total_cites DESC LIMIT 3; |
What is the average renewable energy capacity per project in each country? | CREATE TABLE renewable_energy_projects (project_name TEXT,country TEXT,capacity FLOAT); INSERT INTO renewable_energy_projects VALUES ('ProjectX','Country1',1000.0),('ProjectY','Country1',1200.0),('ProjectZ','Country2',800.0),('ProjectW','Country2',1500.0); | SELECT project_name, country, capacity, AVG(capacity) OVER (PARTITION BY country) AS avg_capacity FROM renewable_energy_projects; |
Which cultural heritage sites in Japan have the highest visitor count? | CREATE TABLE cultural_heritage_sites(site_id INT,site_name VARCHAR(50),country VARCHAR(50),visitor_count INT); | SELECT site_name, visitor_count FROM cultural_heritage_sites WHERE country = 'Japan' ORDER BY visitor_count DESC LIMIT 5; |
How many tunnels in Washington state were constructed after 2010? | CREATE TABLE tunnels (id INT,name TEXT,state TEXT,build_year INT); INSERT INTO tunnels (id,name,state,build_year) VALUES (1,'WA-1 Underpass','WA',2012); | SELECT COUNT(*) FROM tunnels WHERE state = 'WA' AND build_year > 2010; |
What is the average resilience score for each type of infrastructure project in Texas in 2021? | CREATE TABLE Infrastructure_Projects (Project_ID INT,Project_Name VARCHAR(255),Project_Type VARCHAR(255),Resilience_Score FLOAT,Year INT,State VARCHAR(255)); | SELECT Project_Type, AVG(Resilience_Score) FROM Infrastructure_Projects WHERE Year = 2021 AND State = 'Texas' GROUP BY Project_Type; |
What is the total cost of all resilience projects in the state of 'California'? | CREATE TABLE Infrastructure_Projects (id INT,name VARCHAR(100),state VARCHAR(50),cost FLOAT); INSERT INTO Infrastructure_Projects (id,name,state,cost) VALUES (1,'Seawall Upgrade','California',5000000); | SELECT SUM(cost) FROM Infrastructure_Projects WHERE state = 'California'; |
List all active legal technology providers in the justice_schemas.legal_tech_providers table, along with the number of tools they offer. | CREATE TABLE justice_schemas.legal_tech_providers (id INT PRIMARY KEY,name TEXT,is_active BOOLEAN,num_tools INT); | SELECT name, num_tools FROM justice_schemas.legal_tech_providers WHERE is_active = TRUE; |
Delete pollution records from the ocean_pollution table that are older than 10 years. | CREATE TABLE ocean_pollution (id INT,pollution_type VARCHAR(255),pollution_date DATE); INSERT INTO ocean_pollution (id,pollution_type,pollution_date) VALUES (1,'Oil Spill','2010-01-01'),(2,'Plastic Waste','2021-01-01'); | DELETE FROM ocean_pollution WHERE pollution_date < (CURRENT_DATE - INTERVAL '10 years'); |
Find marine pollution control projects that started after 2015, ordered by budget | CREATE TABLE pollution_control_projects (id INT PRIMARY KEY,project_name VARCHAR(255),start_date DATE,end_date DATE,budget FLOAT); | SELECT * FROM pollution_control_projects WHERE start_date > '2015-01-01' ORDER BY budget; |
List all whale shark sightings in the Pacific Ocean. | CREATE TABLE marine_sightings (id INT,species TEXT,location TEXT,date DATE); INSERT INTO marine_sightings (id,species,location,date) VALUES (1,'Whale Shark','Monterey Bay','2022-08-01'),(2,'Whale Shark','Hawaii','2022-07-15'); | SELECT species, location, date FROM marine_sightings WHERE species = 'Whale Shark' AND location LIKE '%Pacific%'; |
What are the maximum and minimum depths of the Arctic Ocean? | CREATE TABLE ocean_depths (ocean TEXT,max_depth FLOAT,min_depth FLOAT); INSERT INTO ocean_depths (ocean,max_depth,min_depth) VALUES ('Atlantic Ocean',9218.0,200.0); INSERT INTO ocean_depths (ocean,max_depth,min_depth) VALUES ('Arctic Ocean',5600.0,4000.0); | SELECT ocean, max_depth, min_depth FROM ocean_depths WHERE ocean = 'Arctic Ocean'; |
How many movies were released each year? | CREATE TABLE movies (id INT,title TEXT,release_year INT); INSERT INTO movies (id,title,release_year) VALUES (1,'Movie1',2005),(2,'Movie2',2007),(3,'Movie3',2010),(4,'Movie4',2015),(5,'Movie5',2018); | SELECT release_year, COUNT(*) FROM movies GROUP BY release_year; |
What are the menu items with a sustainability score above 90 and their corresponding categories? | CREATE TABLE Menu (menu_id INT,item_name VARCHAR(50),category VARCHAR(50),sustainability_score INT); INSERT INTO Menu (menu_id,item_name,category,sustainability_score) VALUES (1,'Quinoa Salad','Entree',92),(2,'Carrot Cake','Dessert',88); | SELECT category, item_name FROM Menu WHERE sustainability_score > 90; |
What is the total cost of ingredients for gluten-free dishes in the healthy menu? | CREATE TABLE ingredients (id INT,dish_id INT,name TEXT,cost FLOAT,is_gluten_free BOOLEAN); INSERT INTO ingredients (id,dish_id,name,cost,is_gluten_free) VALUES (1,1,'Quinoa',2.00,true),(2,1,'Olive Oil',1.50,true),(3,2,'Chickpeas',2.75,false),(4,2,'Coconut Milk',3.00,true),(5,3,'Beef',8.00,false); | SELECT SUM(cost) FROM ingredients WHERE is_gluten_free = true; |
Insert a new mining operation 'Operation E' in Australia with water consumption of 500 cubic meters | CREATE TABLE mining_operations (operation_id INT,operation_name VARCHAR(50),location VARCHAR(50)); CREATE TABLE water_consumption (operation_id INT,water_consumption_cubic_meters INT); INSERT INTO mining_operations (operation_id,operation_name,location) VALUES (1,'Operation A','USA'),(2,'Operation B','Canada'),(3,'Operation C','Mexico'); INSERT INTO water_consumption (operation_id,water_consumption_cubic_meters) VALUES (1,1000),(2,1500),(3,500); | INSERT INTO mining_operations (operation_id, operation_name, location) VALUES (4, 'Operation E', 'Australia'); INSERT INTO water_consumption (operation_id, water_consumption_cubic_meters) VALUES (4, 500); |
What is the total number of employees by role at each mining site in the Western US? | CREATE TABLE mining_sites(id INT,name VARCHAR,location VARCHAR); CREATE TABLE employees(id INT,site_id INT,gender VARCHAR,role VARCHAR); INSERT INTO mining_sites(id,name,location) VALUES (1,'Delta Mining','Western US'),(2,'Echo Mining','Eastern US'),(3,'Charlie Mining','Western US'); INSERT INTO employees(id,site_id,gender,role) VALUES (1,1,'Male','Engineer'),(2,1,'Female','Operator'),(3,2,'Male','Manager'),(4,2,'Female','Engineer'),(5,3,'Male','Operator'),(6,3,'Female','Manager'); | SELECT mining_sites.name, role, COUNT(*) FROM mining_sites INNER JOIN employees ON mining_sites.id = employees.site_id GROUP BY mining_sites.name, role, location; |
Delete any customer records with data usage below 5 GB. | CREATE TABLE customers (id INT,name TEXT,data_usage FLOAT); INSERT INTO customers (id,name,data_usage) VALUES (1,'John Doe',12.5),(2,'Jane Smith',4.0),(3,'Mike Johnson',7.5); | DELETE FROM customers WHERE data_usage < 5.0; |
What is the total number of customer complaints regarding mobile and broadband services by region? | CREATE TABLE complaints (complaint_id INT,complaint_type VARCHAR(255),region VARCHAR(255)); INSERT INTO complaints (complaint_id,complaint_type,region) VALUES (1,'Mobile','North'),(2,'Broadband','South'),(3,'Mobile','East'),(4,'Broadband','West'),(5,'Mobile','North'),(6,'Broadband','South'),(7,'Mobile','East'),(8,'Broadband','West'); | SELECT region, COUNT(*) AS total_complaints FROM complaints WHERE complaint_type IN ('Mobile', 'Broadband') GROUP BY region; |
Delete all comments made by users under 18 years old. | CREATE TABLE comments (id INT,user_id INT,article_id INT,comment TEXT,created_at DATETIME); INSERT INTO comments (id,user_id,article_id,comment,created_at) VALUES (1,123,456,'Great article!','2021-12-20 15:22:00'); | DELETE FROM comments WHERE DATEDIFF('day', created_at, NOW()) < 18 * 365 |
What is the minimum depth at which a deep-sea expedition has been conducted in the Atlantic Ocean? | CREATE TABLE deep_sea_expeditions (expedition_id INT,location VARCHAR(255),depth INT); | SELECT MIN(depth) FROM deep_sea_expeditions WHERE location = 'Atlantic Ocean'; |
Identify the top 2 teams with the highest number of kills in a specific game category. | CREATE TABLE GameStats (Team VARCHAR(50),Game VARCHAR(50),Kills INT); INSERT INTO GameStats (Team,Game,Kills) VALUES ('Team A','FPS Game',500); INSERT INTO GameStats (Team,Game,Kills) VALUES ('Team B','FPS Game',450); INSERT INTO GameStats (Team,Game,Kills) VALUES ('Team C','FPS Game',600); INSERT INTO GameStats (Team,Game,Kills) VALUES ('Team A','RPG Game',300); INSERT INTO GameStats (Team,Game,Kills) VALUES ('Team B','RPG Game',400); INSERT INTO GameStats (Team,Game,Kills) VALUES ('Team C','RPG Game',550); | SELECT Team, SUM(Kills) AS TotalKills FROM GameStats WHERE Game = 'FPS Game' GROUP BY Team ORDER BY TotalKills DESC FETCH FIRST 2 ROWS ONLY; |
Update the 'player_achievements' table to mark achievements as 'completed' where the achievement_difficulty is 'easy' | CREATE TABLE player_achievements (achievement_id INT,player_id INT,achievement_name TEXT,achievement_difficulty TEXT); INSERT INTO player_achievements (achievement_id,player_id,achievement_name,achievement_difficulty) VALUES (1,1,'First Blood','easy'),(2,2,'Double Kill','medium'),(3,3,'Triple Kill','hard'); | WITH easy_achievements AS (UPDATE player_achievements SET completed = 'true' WHERE achievement_difficulty = 'easy') SELECT * FROM easy_achievements; |
Which region has the highest number of esports events? | CREATE TABLE Events (EventID INT,Region VARCHAR(10)); INSERT INTO Events (EventID,Region) VALUES (1,'NA'),(2,'EU'),(3,'APAC'); | SELECT Region, COUNT(*) as EventCount FROM Events GROUP BY Region ORDER BY EventCount DESC LIMIT 1 |
Delete soil moisture data for sensor 010 before 2023-02-28 | CREATE TABLE SoilMoistureData (date DATE,moisture FLOAT,sensor_id INT,FOREIGN KEY (sensor_id) REFERENCES SensorData(sensor_id)); | DELETE FROM SoilMoistureData WHERE sensor_id = 10 AND date < '2023-02-28'; |
What is the total budget allocated to public services in the state of New York, and what percentage of the total state budget does this represent? | CREATE TABLE budget_allocation (state VARCHAR(20),category VARCHAR(20),budget FLOAT); INSERT INTO budget_allocation (state,category,budget) VALUES ('New York','Education',15000000),('New York','Healthcare',20000000),('New York','Transportation',10000000),('New York','Infrastructure',12000000); CREATE TABLE total_budget (state VARCHAR(20),total_budget FLOAT); INSERT INTO total_budget (state,total_budget) VALUES ('New York',200000000); | SELECT (budget / total_budget) * 100 as percentage FROM budget_allocation INNER JOIN total_budget ON budget_allocation.state = total_budget.state WHERE budget_allocation.state = 'New York' AND budget_allocation.category = 'Public services'; |
What are the top 3 countries with the most rare earth element production? | CREATE TABLE production (country VARCHAR(50),production INT); INSERT INTO production (country,production) VALUES ('China',105000),('USA',38000),('Australia',20000),('India',2800),('Brazil',1200); | SELECT country FROM production ORDER BY production DESC LIMIT 3; |
Count the number of properties in Austin with a listing price below $400,000 and sustainable features. | CREATE TABLE properties (id INT,city VARCHAR(20),listing_price INT,sustainable BOOLEAN); INSERT INTO properties (id,city,listing_price,sustainable) VALUES (1,'Austin',350000,true); INSERT INTO properties (id,city,listing_price,sustainable) VALUES (2,'Austin',450000,false); | SELECT COUNT(*) FROM properties WHERE city = 'Austin' AND listing_price < 400000 AND sustainable = true; |
What is the average property value in historically underrepresented communities? | CREATE TABLE Property_Value_History (Property_ID INT,Underrepresented VARCHAR(20),Property_Value INT); INSERT INTO Property_Value_History (Property_ID,Underrepresented,Property_Value) VALUES (1,'Yes',1000000),(2,'No',800000),(3,'Yes',1200000),(4,'No',900000); CREATE TABLE Property_Details (Property_ID INT,Underrepresented VARCHAR(20)); INSERT INTO Property_Details (Property_ID,Underrepresented) VALUES (1,'Yes'),(2,'No'),(3,'Yes'),(4,'No'); | SELECT AVG(Property_Value) FROM Property_Value_History pvh JOIN Property_Details pd ON pvh.Property_ID = pd.Property_ID WHERE Underrepresented = 'Yes'; |
How many wind power projects were completed in Germany and Sweden in 2019 and 2020? | CREATE TABLE wind_projects_2 (project_id INT,country VARCHAR(50),completion_year INT); INSERT INTO wind_projects_2 (project_id,country,completion_year) VALUES (1,'Germany',2019),(2,'Sweden',2020),(3,'Germany',2018),(4,'Sweden',2019),(5,'Germany',2020),(6,'Sweden',2018); | SELECT country, COUNT(*) FROM wind_projects_2 WHERE completion_year IN (2019, 2020) GROUP BY country; |
What is the average energy efficiency rating for residential buildings in the United States, grouped by state? | CREATE TABLE Residential_Buildings (state VARCHAR(255),rating INT); INSERT INTO Residential_Buildings (state,rating) VALUES ('California',80),('Texas',75),('New York',85); | SELECT state, AVG(rating) AS avg_rating FROM Residential_Buildings GROUP BY state; |
Find the number of vegetarian dishes that are not offered at any restaurant. | CREATE TABLE dishes (id INT,name VARCHAR(255),type VARCHAR(255)); INSERT INTO dishes (id,name,type) VALUES (1,'Quinoa Salad','vegetarian'),(2,'Chickpea Curry','vegetarian'),(3,'Cheeseburger','non-vegetarian'); CREATE TABLE restaurants (id INT,name VARCHAR(255)); CREATE TABLE menus (id INT,dish_id INT,restaurant_id INT); INSERT INTO menus (id,dish_id,restaurant_id) VALUES (1,1,1),(2,2,1),(3,3,2); | SELECT COUNT(*) FROM dishes WHERE type = 'vegetarian' AND id NOT IN (SELECT dish_id FROM menus); |
What is the total revenue for 'Breakfast' menu items in the 'Downtown' location? | CREATE TABLE menus (menu_id INT,dish_name VARCHAR(50),dish_type VARCHAR(50),price DECIMAL(5,2),sales INT,location VARCHAR(50)); CREATE TABLE revenue (menu_id INT,date DATE,revenue INT); | SELECT SUM(r.revenue) FROM menus m JOIN revenue r ON m.menu_id = r.menu_id WHERE m.dish_type = 'Breakfast' AND m.location = 'Downtown'; |
Create a view to display suppliers with a sustainability score greater than 80 | CREATE VIEW sustainable_suppliers AS SELECT * FROM suppliers WHERE sustainability_score > 80; | CREATE VIEW sustainable_suppliers AS SELECT * FROM suppliers WHERE sustainability_score > 80; |
Display the number of employees working in each store in Canada. | CREATE TABLE employees (employee_id INT,store_id INT,first_name VARCHAR(50),last_name VARCHAR(50),role VARCHAR(50),hourly_wage DECIMAL(5,2)); CREATE TABLE stores (store_id INT,location VARCHAR(50),country VARCHAR(50)); CREATE VIEW store_employee_view AS SELECT stores.store_id,stores.location,stores.country,COUNT(employees.employee_id) as num_employees FROM stores LEFT JOIN employees ON stores.store_id = employees.store_id GROUP BY stores.store_id,stores.location,stores.country; | SELECT location, num_employees FROM store_employee_view WHERE country = 'Canada'; |
What is the total mass of space objects in high Earth orbit? | CREATE TABLE space_objects_heo (id INT,name VARCHAR(255),mass FLOAT,orbit VARCHAR(255)); INSERT INTO space_objects_heo (id,name,mass,orbit) VALUES (1,'Space Object 1',1000.0,'High Earth Orbit'),(2,'Space Object 2',1500.0,'High Earth Orbit'); | SELECT SUM(mass) FROM space_objects_heo; |
What is the percentage of male and female fans who participated in athlete wellbeing programs in the last 6 months, by age group? | CREATE TABLE wellbeing_participants (fan_id INT,gender VARCHAR(50),age INT,last_event_date DATE); INSERT INTO wellbeing_participants (fan_id,gender,age,last_event_date) VALUES (1,'Male',25,'2022-01-01'),(2,'Female',35,'2022-02-01'),(3,'Male',28,'2022-03-01'),(4,'Female',45,'2022-04-01'),(5,'Male',32,'2022-05-01'); | SELECT age_group, gender, COUNT(*) * 100.0 / (SELECT COUNT(*) FROM wellbeing_participants WHERE gender = age_group AND last_event_date >= CURDATE() - INTERVAL 6 MONTH) AS percentage FROM (SELECT CASE WHEN age < 30 THEN '18-29' WHEN age < 40 THEN '30-39' ELSE '40+' END AS age_group, gender FROM wellbeing_participants WHERE last_event_date >= CURDATE() - INTERVAL 6 MONTH) AS age_groups GROUP BY age_group, gender; |
What is the total revenue generated by the Los Angeles Lakers from merchandise sales in Q1 of 2021? | CREATE TABLE merchandise_sales(id INT,team VARCHAR(50),quarter VARCHAR(10),revenue DECIMAL(5,2)); INSERT INTO merchandise_sales(id,team,quarter,revenue) VALUES (1,'Los Angeles Lakers','Q1',550000.00),(2,'Los Angeles Lakers','Q2',600000.00),(3,'Los Angeles Lakers','Q3',700000.00); | SELECT SUM(revenue) FROM merchandise_sales WHERE team = 'Los Angeles Lakers' AND quarter = 'Q1' AND year = 2021; |
Remove the 'Zero-day exploit' record from the 'exploits' table | CREATE TABLE exploits (id INT,name VARCHAR,description TEXT,date_discovered DATE); INSERT INTO exploits (id,name,description,date_discovered) VALUES (1,'Zero-day exploit','Exploit for a previously unknown vulnerability','2022-03-15'); | DELETE FROM exploits WHERE name='Zero-day exploit'; |
What is the average severity of vulnerabilities in the 'Malware' category? | CREATE TABLE vulnerabilities (id INT,name TEXT,category TEXT,severity TEXT,date_discovered DATE); INSERT INTO vulnerabilities (id,name,category,severity,date_discovered) VALUES (1,'Remote Code Execution','Malware','Critical','2022-01-01'); | SELECT AVG(severity = 'Critical') + AVG(severity = 'High') * 0.75 + AVG(severity = 'Medium') * 0.5 + AVG(severity = 'Low') * 0.25 as average FROM vulnerabilities WHERE category = 'Malware'; |
How many bicycle-sharing systems are available in the 'transportation_systems' table? | CREATE TABLE transportation_systems (id INT PRIMARY KEY,system_name VARCHAR(50),system_type VARCHAR(50),location VARCHAR(50)); INSERT INTO transportation_systems (id,system_name,system_type,location) VALUES (1,'NYC Citi Bike','Bicycle-Sharing','New York'); INSERT INTO transportation_systems (id,system_name,system_type,location) VALUES (2,'London Santander Cycles','Bicycle-Sharing','London'); | SELECT COUNT(*) FROM transportation_systems WHERE system_type = 'Bicycle-Sharing'; |
What is the maximum number of bike-share trips in a day in Paris? | CREATE TABLE bike_trips (trip_id INT,city VARCHAR(20),trips_per_day INT); INSERT INTO bike_trips (trip_id,city,trips_per_day) VALUES (1,'Paris',3000),(2,'Paris',2500),(3,'Paris',3500); | SELECT MAX(trips_per_day) FROM bike_trips WHERE city = 'Paris'; |
What is the average claim amount in the 'East' region? | CREATE TABLE Claims (ClaimID INT,PolicyID INT,Amount INT,Region VARCHAR(10)); INSERT INTO Claims (ClaimID,PolicyID,Amount,Region) VALUES (1,101,500,'North'); INSERT INTO Claims (ClaimID,PolicyID,Amount,Region) VALUES (2,102,750,'South'); INSERT INTO Claims (ClaimID,PolicyID,Amount,Region) VALUES (3,103,300,'East'); | SELECT AVG(Amount) FROM Claims WHERE Region = 'East'; |
What is the total number of electric vehicles adopted in Canada and the UK? | CREATE TABLE ElectricVehicleAdoptionCAUK (Model VARCHAR(20),Country VARCHAR(10),AdoptionRate FLOAT,IsCAUK BIT); | SELECT SUM(AdoptionRate) FROM ElectricVehicleAdoptionCAUK WHERE IsCAUK IN (1, 2); |
Show the number of visitors for each exhibition type | CREATE TABLE Exhibitions (id INT,name VARCHAR(255),type VARCHAR(255)); CREATE TABLE Tickets (id INT,visitor_id INT,exhibition_id INT); | SELECT Exhibitions.type, COUNT(Tickets.visitor_id) FROM Exhibitions JOIN Tickets ON Exhibitions.id = Tickets.exhibition_id GROUP BY Exhibitions.type; |
How many landfills are there in Tokyo with a capacity over 100,000 tons? | CREATE TABLE landfills(location VARCHAR(50),capacity INT); INSERT INTO landfills(location,capacity) VALUES ('Tokyo',120000),('Tokyo',90000),('Osaka',150000),('Osaka',80000),('Kyoto',50000); | SELECT COUNT(*) FROM landfills WHERE location = 'Tokyo' AND capacity > 100000; |
What is the maximum duration of 'Yoga' workouts in the 'workout_data' table? | CREATE TABLE workout_data (user_id INT,workout_type VARCHAR(20),duration INT); INSERT INTO workout_data (user_id,workout_type,duration) VALUES (1,'Running',30),(1,'Cycling',60),(2,'Yoga',45),(3,'Pilates',50),(1,'Running',45),(2,'Yoga',60),(3,'Pilates',75),(1,'Running',75),(2,'Yoga',90),(3,'Pilates',105); | SELECT MAX(duration) as max_duration FROM workout_data WHERE workout_type = 'Yoga'; |
What is the total investment in agricultural innovation in the 'Investment_Data' table for each crop type? | CREATE TABLE Investment_Data (investment_id INT,crop_type TEXT,investment_amount INT); INSERT INTO Investment_Data (investment_id,crop_type,investment_amount) VALUES (1,'Corn',50000),(2,'Soybeans',75000),(3,'Wheat',60000); | SELECT crop_type, SUM(investment_amount) FROM Investment_Data GROUP BY crop_type; |
List the top 3 countries with the highest number of satellites launched | CREATE TABLE Satellites (SatelliteID INT,Name VARCHAR(50),LaunchDate DATE,Manufacturer VARCHAR(50),Country VARCHAR(50),Weight DECIMAL(10,2)); INSERT INTO Satellites (SatelliteID,Name,LaunchDate,Manufacturer,Country,Weight) VALUES (1,'Kompsat-5','2013-08-10','KARI','South Korea',1250.00),(2,'GSAT-7','2013-09-30','ISRO','India',2650.00),(3,'Haiyang-2B','2011-11-15','CNSA','China',1100.00); | SELECT Country, COUNT(*) as SatelliteCount, RANK() OVER(ORDER BY COUNT(*) DESC) as Rank FROM Satellites GROUP BY Country HAVING COUNT(*) > 0 ORDER BY Rank; |
What is the total number of fish in fish farms located in the North Atlantic Ocean? | CREATE TABLE fish_farms (id INT,name TEXT,location TEXT,number_of_fish INT); INSERT INTO fish_farms (id,name,location,number_of_fish) VALUES (1,'Farm A','North Atlantic Ocean',1000),(2,'Farm B','South Atlantic Ocean',1200),(3,'Farm C','North Atlantic Ocean',1500); | SELECT SUM(number_of_fish) FROM fish_farms WHERE location = 'North Atlantic Ocean'; |
What was the total attendance at poetry readings in San Francisco? | CREATE TABLE events (id INT,event_type VARCHAR(50),city VARCHAR(50),attendance INT); INSERT INTO events (id,event_type,city,attendance) VALUES (1,'Poetry Reading','San Francisco',50),(2,'Music Concert','Los Angeles'),(3,'Poetry Reading','San Francisco',75); | SELECT SUM(attendance) FROM events WHERE event_type = 'Poetry Reading' AND city = 'San Francisco'; |
What's the average rating of K-dramas released between 2016 and 2018? | CREATE TABLE kdramas (id INT,title VARCHAR(255),release_year INT,rating DECIMAL(3,2)); INSERT INTO kdramas (id,title,release_year,rating) VALUES (1,'Goblin',2016,9.2),(2,'Descendants of the Sun',2016,8.9),(3,'Stranger',2017,8.8),(4,'Hotel Del Luna',2019,8.5); | SELECT AVG(rating) FROM kdramas WHERE release_year BETWEEN 2016 AND 2018; |
How many cases were opened in 2021? | CREATE TABLE cases (id INT,open_date DATE); INSERT INTO cases (id,open_date) VALUES (1,'2021-01-05'),(2,'2022-02-10'),(3,'2021-07-20'),(4,'2021-12-31'); | SELECT COUNT(*) FROM cases WHERE YEAR(open_date) = 2021; |
What is the number of flu cases in each region? | CREATE TABLE flu_cases(id INT,patient_id INT,region TEXT,date DATE); | SELECT region, COUNT(*) FROM flu_cases GROUP BY region; |
What is the obesity rate among adults in North American countries in 2019? | CREATE TABLE ObesityRates (Country VARCHAR(50),Continent VARCHAR(50),Year INT,ObesityRate FLOAT); INSERT INTO ObesityRates (Country,Continent,Year,ObesityRate) VALUES ('Canada','North America',2019,26.8),('Mexico','North America',2019,32.4),('USA','North America',2019,36.2); | SELECT Country, Continent, ObesityRate FROM ObesityRates WHERE Continent = 'North America' AND Year = 2019; |
Update the common name of the scientific name "Loligo opalescens" to "California market squid". | CREATE TABLE marine_species (scientific_name TEXT,common_name TEXT); INSERT INTO marine_species (scientific_name,common_name) VALUES ('Loligo opalescens','California market squid'); | UPDATE marine_species SET common_name = 'California market squid' WHERE scientific_name = 'Loligo opalescens'; |
What is the minimum depth at which a marine species can be found? | CREATE TABLE marine_species_depths (species TEXT,min_depth FLOAT); | SELECT MIN(min_depth) FROM marine_species_depths; |
What is the minimum ocean temperature, grouped by ocean basin? | CREATE TABLE ocean_temperature (id INT,location VARCHAR(255),temperature FLOAT,ocean_basin VARCHAR(255)); INSERT INTO ocean_temperature (id,location,temperature,ocean_basin) VALUES (1,'Hawaii',27,'Pacific'); INSERT INTO ocean_temperature (id,location,temperature,ocean_basin) VALUES (2,'Gibraltar',14,'Atlantic'); INSERT INTO ocean_temperature (id,location,temperature,ocean_basin) VALUES (3,'Darwin',29,'Indian'); | SELECT ocean_basin, MIN(temperature) FROM ocean_temperature GROUP BY ocean_basin; |
What is the total number of transactions performed by all decentralized applications? | CREATE TABLE transactions (id INT,app_id INT,timestamp TIMESTAMP); INSERT INTO transactions (id,app_id,timestamp) VALUES (1,1,'2022-01-01 10:00:00'),(2,1,'2022-01-01 12:00:00'),(3,2,'2022-01-01 14:00:00'); | SELECT COUNT(*) FROM transactions; |
Create a table to store ingredient sourcing information | CREATE TABLE ingredient_sourcing (ingredient_id INT,supplier_id INT,sourcing_date DATE,PRIMARY KEY (ingredient_id,sourcing_date)); | CREATE TABLE ingredient_sourcing (ingredient_id INT, supplier_id INT, sourcing_date DATE, PRIMARY KEY (ingredient_id, sourcing_date)); |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.