instruction
stringlengths 0
1.06k
| input
stringlengths 11
5.3k
| response
stringlengths 2
4.44k
|
---|---|---|
What is the average rating of eco-friendly hotels in Barcelona? | CREATE TABLE eco_hotels (hotel_id INT,name TEXT,city TEXT,rating FLOAT); INSERT INTO eco_hotels (hotel_id,name,city,rating) VALUES (1,'EcoHotel Barcelona','Barcelona',4.3),(2,'GreenSuites BCN','Barcelona',4.6); | SELECT AVG(rating) FROM eco_hotels WHERE city = 'Barcelona'; |
What is the maximum financial capability score for individuals in India, grouped by gender? | CREATE TABLE individuals (id INT,country VARCHAR(255),gender VARCHAR(255),financial_capability_score INT); | SELECT gender, MAX(financial_capability_score) FROM individuals WHERE country = 'India' GROUP BY gender; |
How many auto shows have featured electric vehicles in the past 2 years? | CREATE TABLE AutoShows (id INT,event_name VARCHAR(50),event_date DATE); INSERT INTO AutoShows (id,event_name,event_date) VALUES (1,'Auto Show A','2021-01-01'); | SELECT COUNT(*) FROM AutoShows WHERE event_date >= DATEADD(year, -2, GETDATE()) AND event_name LIKE '%Electric%'; |
List community health workers who received cultural competency training in 2022 and their scores. | CREATE TABLE community_health_workers (id INT,name VARCHAR(50),age INT,state VARCHAR(20)); CREATE TABLE cultural_competency_training (id INT,community_health_worker_id INT,date_trained DATE,score INT); INSERT INTO community_health_workers (id,name,age,state) VALUES (1,'John Doe',35,'Texas'),(2,'Jane Smith',40,'California'); INSERT INTO cultural_competency_training (id,community_health_worker_id,date_trained,score) VALUES (1,1,'2022-01-01',85),(2,2,'2022-01-01',90); | SELECT c.name, cct.score FROM community_health_workers c INNER JOIN cultural_competency_training cct ON c.id = cct.community_health_worker_id WHERE cct.date_trained >= '2022-01-01'; |
Delete the "DiveSite" record with a name of Blue Hole | CREATE TABLE DiveSite (Name VARCHAR(50) PRIMARY KEY,Depth INT); INSERT INTO DiveSite (Name,Depth) VALUES ('Blue Hole',120); | DELETE FROM DiveSite WHERE Name = 'Blue Hole'; |
What is the average cost of permits issued in the Midwest region in Q1 2021? | CREATE TABLE permit (permit_id INT,region VARCHAR(20),cost FLOAT,issue_date DATE); INSERT INTO permit VALUES (1,'Midwest',5000,'2021-01-05'); INSERT INTO permit VALUES (2,'Midwest',6000,'2021-03-15'); | SELECT AVG(cost) FROM permit WHERE region = 'Midwest' AND issue_date BETWEEN '2021-01-01' AND '2021-03-31'; |
What is the maximum connection speed in Mbps for broadband customers in the Latin America region in the last 2 years? | CREATE TABLE subscribers (id INT,service VARCHAR(10),region VARCHAR(10)); INSERT INTO subscribers (id,service,region) VALUES (1,'broadband','Latin America'),(2,'mobile','Latin America'); CREATE TABLE speeds (subscriber_id INT,connection_speed INT,year INT); INSERT INTO speeds (subscriber_id,connection_speed,year) VALUES (1,650,2022),(1,630,2021),(1,600,2020),(2,550,2022),(2,530,2021),(2,500,2020); | SELECT MAX(speeds.connection_speed) FROM speeds JOIN subscribers ON speeds.subscriber_id = subscribers.id WHERE subscribers.service = 'broadband' AND subscribers.region = 'Latin America' AND speeds.year BETWEEN 2021 AND 2022; |
What is the maximum ocean acidification level in the Arctic ocean? | CREATE TABLE oceanography (ocean TEXT,location TEXT,acidification_level REAL); | SELECT MAX(acidification_level) FROM oceanography WHERE ocean = 'Arctic'; |
How many species of birds were observed in the Arctic tundra during each year? | CREATE TABLE BirdObservations (id INT,location VARCHAR(20),year INT,bird_species VARCHAR(30)); INSERT INTO BirdObservations (id,location,year,bird_species) VALUES (1,'Arctic Tundra',2020,'Snow Bunting'); INSERT INTO BirdObservations (id,location,year,bird_species) VALUES (2,'Arctic Tundra',2021,'Lapland Longspur'); | SELECT year, COUNT(DISTINCT bird_species) FROM BirdObservations WHERE location LIKE 'Arctic%' GROUP BY year; |
Show the number of unique wallet addresses that have interacted with 'DeFi' dapps on the 'Binance Smart Chain' in the last month. | CREATE TABLE binance_smart_chain (wallet_address TEXT,interaction_date DATE,dapp_category TEXT,network_name TEXT); | SELECT wallet_address, COUNT(DISTINCT interaction_date) as interactions FROM binance_smart_chain WHERE network_name = 'Binance Smart Chain' AND dapp_category = 'DeFi' GROUP BY wallet_address HAVING COUNT(DISTINCT interaction_date) >= 1 ORDER BY interactions DESC; |
What are the top 2 labor categories with the highest average wage? | CREATE TABLE labor_statistics (labor_category VARCHAR(50),average_wage NUMERIC(10,2)); INSERT INTO labor_statistics (labor_category,average_wage) VALUES ('Carpenters','35.56'),('Electricians','38.42'),('Plumbers','42.15'); | SELECT labor_category, AVG(average_wage) FROM labor_statistics GROUP BY labor_category ORDER BY AVG(average_wage) DESC LIMIT 2; |
What is the minimum age of volunteers in the 'Habitat Preservation' program? | CREATE TABLE Volunteers (VolunteerID INT,Age INT,Gender VARCHAR(10),Program VARCHAR(20)); INSERT INTO Volunteers (VolunteerID,Age,Gender,Program) VALUES (1,25,'Male','Education'); INSERT INTO Volunteers (VolunteerID,Age,Gender,Program) VALUES (2,30,'Female','Habitat Preservation'); INSERT INTO Volunteers (VolunteerID,Age,Gender,Program) VALUES (3,35,'Male','Habitat Preservation'); | SELECT MIN(Age) FROM Volunteers WHERE Program = 'Habitat Preservation'; |
What is the minimum CO2 emission reduction achieved by climate mitigation projects in South America in 2018? | CREATE TABLE climate_mitigation_projects (id INT,project VARCHAR(255),location VARCHAR(255),reduction_percentage DECIMAL(5,2),start_year INT,end_year INT); | SELECT MIN(reduction_percentage) FROM climate_mitigation_projects WHERE location LIKE '%South America%' AND start_year <= 2018 AND end_year >= 2018; |
What was the total number of smart contract vulnerabilities discovered in the 'Insurance' sector during Q1 2022? | CREATE TABLE vulnerabilities (sector VARCHAR(10),quarter INT,vulnerabilities_count INT); INSERT INTO vulnerabilities (sector,quarter,vulnerabilities_count) VALUES ('Insurance',1,30),('Insurance',2,45),('Insurance',3,60),('Insurance',4,75); | SELECT vulnerabilities_count FROM vulnerabilities WHERE sector = 'Insurance' AND quarter = 1; |
List the departments with no research grants. | CREATE TABLE Departments (DepartmentID INT,DepartmentName VARCHAR(50),ResearchGrants INT); | SELECT DepartmentName FROM Departments WHERE ResearchGrants = 0; |
What is the minimum investment in climate adaptation projects in Least Developed Countries (LDCs) in the last 5 years? | CREATE TABLE climate_adaptation_projects (project_id INT,location VARCHAR(50),investment_amount FLOAT,investment_year INT); INSERT INTO climate_adaptation_projects (project_id,location,investment_amount,investment_year) VALUES (1,'Mozambique',1000000,2018),(2,'Bangladesh',1500000,2019),(3,'Ethiopia',2000000,2020),(4,'Afghanistan',1200000,2017),(5,'Nepal',1800000,2021); | SELECT MIN(investment_amount) FROM climate_adaptation_projects WHERE location LIKE 'LDCs' AND investment_year BETWEEN 2017 AND 2021; |
What is the total amount spent on raw materials for each product line, including the cost of sub-components? | CREATE TABLE raw_materials (id INT,product_line VARCHAR(50),amount INT,sub_components VARCHAR(50)); INSERT INTO raw_materials (id,product_line,amount,sub_components) VALUES (1,'product1',10000,'component1,component2'); INSERT INTO raw_materials (id,product_line,amount,sub_components) VALUES (2,'product2',15000,'component3,component4'); | SELECT product_line, SUM(amount + (SELECT SUM(amount) FROM raw_materials WHERE sub_components LIKE CONCAT('%', product_line, '%'))) FROM raw_materials GROUP BY product_line; |
What is the total value of Shariah-compliant investments in a specific sector? | CREATE TABLE shariah_compliant_investments (investment_id INT,sector VARCHAR(255),investment_value DECIMAL); INSERT INTO shariah_compliant_investments (investment_id,sector,investment_value) VALUES (1,'Technology',5000),(2,'Healthcare',7000),(3,'Finance',3000); | SELECT SUM(investment_value) FROM shariah_compliant_investments WHERE sector = 'Technology'; |
List all exhibitions and their average visitor rating | CREATE TABLE Exhibition (id INT,name TEXT,rating INT); INSERT INTO Exhibition (id,name,rating) VALUES (1,'Exhibition1',4),(2,'Exhibition2',5); | SELECT name, AVG(rating) FROM Exhibition GROUP BY name; |
What is the minimum energy storage utilization rate for the province of Ontario in 2021? | CREATE TABLE energy_storage_utilization (province VARCHAR(20),utilization DECIMAL(4,2),year INT); INSERT INTO energy_storage_utilization (province,utilization,year) VALUES ('Ontario',80.5,2021),('Ontario',82.3,2021),('Ontario',79.2,2021); | SELECT MIN(utilization) FROM energy_storage_utilization WHERE province = 'Ontario' AND year = 2021; |
What is the total amount of transactions and their count for customers who have made a transaction in both Europe and Asia? | CREATE TABLE Transactions (id INT,customer_id INT,region VARCHAR(10)); INSERT INTO Transactions (id,customer_id,region) VALUES (1,10,'Europe'),(2,10,'Asia'),(3,11,'Asia'),(4,12,'Europe'); | SELECT SUM(amount) as total_amount, COUNT(*) as transaction_count FROM Transactions t1 INNER JOIN (SELECT customer_id FROM Transactions WHERE region IN ('Europe', 'Asia') GROUP BY customer_id HAVING COUNT(DISTINCT region) = 2) t2 ON t1.customer_id = t2.customer_id; |
Which union has the greatest increase in members in the manufacturing sector between 2020 and 2021? | CREATE TABLE union_membership (year INT,union_name TEXT,industry TEXT,members INT); INSERT INTO union_membership (year,union_name,industry,members) VALUES (2020,'United Auto Workers','Manufacturing',350000),(2021,'United Auto Workers','Manufacturing',400000),(2020,'UAW Local 600','Manufacturing',20000),(2021,'UAW Local 600','Manufacturing',25000); | SELECT union_name, MAX(members) - MIN(members) AS member_growth FROM union_membership WHERE industry = 'Manufacturing' AND year IN (2020, 2021) GROUP BY union_name ORDER BY member_growth DESC LIMIT 1; |
List the top 3 mines with the highest annual coal production in the USA. | CREATE TABLE mines (id INT,name VARCHAR(255),location VARCHAR(255),annual_coal_production INT); INSERT INTO mines (id,name,location,annual_coal_production) VALUES (1,'Mine A','USA',1000000),(2,'Mine B','Canada',800000),(3,'Mine C','USA',1200000),(4,'Mine D','USA',1100000); | SELECT m.name, m.annual_coal_production FROM mines m ORDER BY m.annual_coal_production DESC LIMIT 3; |
What is the number of flu cases in urban areas compared to rural areas? | CREATE TABLE infectious_disease (id INT,location VARCHAR(10),disease VARCHAR(50),cases INT); INSERT INTO infectious_disease (id,location,disease,cases) VALUES (1,'Urban','Flu',3000),(2,'Rural','Flu',2000),(3,'Urban','Measles',500),(4,'Rural','Measles',300),(5,'Urban','COVID-19',10000),(6,'Rural','COVID-19',2000); | SELECT location, SUM(cases) as total_cases FROM infectious_disease WHERE disease = 'Flu' GROUP BY location; |
What is the number of unique donors by city and state? | CREATE TABLE Donors (id INT,donor_name TEXT,city TEXT,state TEXT); | SELECT city, state, COUNT(DISTINCT donor_name) as unique_donors FROM Donors GROUP BY city, state; |
How many units of each product were sold in the last month, by salesperson? | CREATE TABLE sales (sale_date DATE,salesperson VARCHAR(255),product VARCHAR(255),quantity INT); | SELECT salesperson, product, SUM(quantity) AS qty_sold, DATE_TRUNC('month', sale_date) AS sale_month FROM sales WHERE sale_date >= DATE_TRUNC('month', CURRENT_DATE - INTERVAL '1 month') GROUP BY salesperson, product, sale_month; |
How many defense projects were negotiated with the Australian government in the last 3 years? | CREATE TABLE ContractNegotiations (id INT,contractor VARCHAR(255),government VARCHAR(255),contract_value INT,negotiation_date DATE); INSERT INTO ContractNegotiations (id,contractor,government,contract_value,negotiation_date) VALUES (1,'Contractor A','US Government',20000000,'2020-01-01'),(2,'Contractor B','Australian Government',12000000,'2021-06-15'),(3,'Contractor A','US Government',25000000,'2021-03-30'),(4,'Contractor C','Australian Government',8000000,'2020-07-01'); | SELECT COUNT(*) FROM ContractNegotiations WHERE government = 'Australian Government' AND negotiation_date >= DATE_SUB(CURRENT_DATE, INTERVAL 3 YEAR); |
What is the average mental health parity score for mental health facilities in New York? | CREATE TABLE mental_health_facilities (facility_id INT,name VARCHAR(50),state VARCHAR(25),mental_health_parity_score INT); INSERT INTO mental_health_facilities (facility_id,name,state,mental_health_parity_score) VALUES (1,'Sunshine Mental Health','New York',85); INSERT INTO mental_health_facilities (facility_id,name,state,mental_health_parity_score) VALUES (2,'Serenity Mental Health','California',90); INSERT INTO mental_health_facilities (facility_id,name,state,mental_health_parity_score) VALUES (3,'Harmony Mental Health','Texas',80); | SELECT AVG(mental_health_parity_score) FROM mental_health_facilities WHERE state = 'New York'; |
What is the average consumer awareness score for each continent in the 'consumer_awareness' table? | CREATE TABLE consumer_awareness (id INT,country VARCHAR(20),continent VARCHAR(20),score FLOAT); INSERT INTO consumer_awareness (id,country,continent,score) VALUES (1,'Bangladesh','Asia',3.2),(2,'India','Asia',3.5),(3,'Cambodia','Asia',3.0),(4,'Vietnam','Asia',3.7),(5,'Indonesia','Asia',3.3),(6,'Kenya','Africa',2.8),(7,'Ethiopia','Africa',2.5),(8,'SouthAfrica','Africa',3.1),(9,'Brazil','South America',3.6),(10,'Colombia','South America',3.4); | SELECT continent, AVG(score) FROM consumer_awareness GROUP BY continent; |
Retrieve the policy numbers, claim amounts, and claim dates for claims that were processed in 'January' of any year | CREATE TABLE claims (claim_id INT,policy_number INT,claim_amount DECIMAL(10,2),claim_date DATE); | SELECT policy_number, claim_amount, claim_date FROM claims WHERE MONTH(claim_date) = 1; |
What is the percentage of hotels in Los Angeles that have adopted AI technology? | CREATE TABLE hotels (hotel_id INT,hotel_name TEXT,city TEXT,ai_adoption INT); INSERT INTO hotels (hotel_id,hotel_name,city,ai_adoption) VALUES (1,'The Beverly Hills Hotel','Los Angeles',1),(2,'The Four Seasons Hotel','Los Angeles',1),(3,'The W Hotel','Los Angeles',0),(4,'The InterContinental Hotel','Los Angeles',1),(5,'The Millennium Biltmore Hotel','Los Angeles',0); | SELECT city, 100.0 * SUM(ai_adoption) / COUNT(*) as adoption_percentage FROM hotels WHERE city = 'Los Angeles' GROUP BY city; |
What is the maximum cost of a sustainable building material used in green construction projects in Japan? | CREATE TABLE Sustainable_Materials (id INT,material_name TEXT,cost FLOAT,sustainability_rating INT,country TEXT); | SELECT MAX(cost) FROM Sustainable_Materials WHERE country = 'Japan' AND sustainability_rating >= 4; |
Identify the total mass of space debris collected by NASA and JAXA. | CREATE TABLE space_debris (id INT,name VARCHAR(255),collection_date DATE,collecting_agency VARCHAR(255),mass FLOAT); INSERT INTO space_debris (id,name,collection_date,collecting_agency,mass) VALUES (1,'RemoveDEBRIS','2018-04-16','NASA',220.0); INSERT INTO space_debris (id,name,collection_date,collecting_agency,mass) VALUES (2,'RAMA','2024-09-27','JAXA',550.5); CREATE VIEW space_debris_nasa AS SELECT * FROM space_debris WHERE collecting_agency = 'NASA'; CREATE VIEW space_debris_jaxa AS SELECT * FROM space_debris WHERE collecting_agency = 'JAXA'; | SELECT SUM(s.mass) as total_mass FROM space_debris s INNER JOIN space_debris_nasa n ON s.id = n.id INNER JOIN space_debris_jaxa j ON s.id = j.id; |
What is the average depth of marine trenches in the Pacific Ocean? | CREATE TABLE marine_trenches (id INT,name VARCHAR(255),depth FLOAT,location VARCHAR(255)); | SELECT AVG(depth) FROM marine_trenches WHERE location LIKE '%Pacific%'; |
What are the products that are not in any trend? | CREATE TABLE Products (id INT PRIMARY KEY,name VARCHAR(255),category VARCHAR(255),supplier_id INT,FOREIGN KEY (supplier_id) REFERENCES Suppliers(id)); CREATE TABLE Trends (id INT PRIMARY KEY,product_id INT,trend VARCHAR(255),popularity INT); INSERT INTO Products (id,name,category,supplier_id) VALUES (1,'Product A','Tops',1); INSERT INTO Products (id,name,category,supplier_id) VALUES (2,'Product B','Bottoms',2); INSERT INTO Trends (id,product_id,trend,popularity) VALUES (1,1,'Color Blocking',20); INSERT INTO Trends (id,product_id,trend,popularity) VALUES (2,2,'Sustainable Fabrics',25); INSERT INTO Trends (id,product_id,trend,popularity) VALUES (3,1,'Animal Print',18); INSERT INTO Trends (id,product_id,trend,popularity) VALUES (4,2,'Neutrals',22); INSERT INTO Products (id,name,category,supplier_id) VALUES (5,'Product C','Shoes',3); | SELECT Products.name FROM Products LEFT JOIN Trends ON Products.id = Trends.product_id WHERE Trends.product_id IS NULL |
What is the total quantity of unsold garments for each brand, grouped by country, which have a quantity greater than 500? | CREATE TABLE Countries (id INT,country VARCHAR(50)); INSERT INTO Countries (id,country) VALUES (1,'USA'),(2,'Canada'),(3,'Mexico'); CREATE TABLE Brands (id INT,brand VARCHAR(50)); INSERT INTO Brands (id,brand) VALUES (1,'Gucci'),(2,'Chanel'),(3,'Louis Vuitton'); CREATE TABLE Inventory (id INT,country_id INT,brand_id INT,quantity INT); INSERT INTO Inventory (id,country_id,brand_id,quantity) VALUES (1,1,1,800),(2,1,2,600),(3,2,1,300),(4,3,2,700),(5,1,3,900),(6,2,3,400); | SELECT c.country, b.brand, SUM(i.quantity) as total_unsold_quantity FROM Inventory i JOIN Countries c ON i.country_id = c.id JOIN Brands b ON i.brand_id = b.id GROUP BY c.country, b.brand HAVING total_unsold_quantity > 500; |
What is the percentage of patients who improved after therapy? | CREATE TABLE outcomes (id INT,patient_id INT,improvement VARCHAR(10)); INSERT INTO outcomes (id,patient_id,improvement) VALUES (1,1,'improved'),(2,2,'did not improve'),(3,3,'improved'),(4,4,'did not improve'),(5,5,'improved'),(6,6,'did not improve'),(7,7,'improved'),(8,8,'did not improve'); | SELECT (COUNT(*) FILTER (WHERE improvement = 'improved')) * 100.0 / COUNT(*) AS percentage FROM outcomes; |
What biotech startups in San Francisco received Series A funding over 3 million since 2020? | CREATE TABLE company (id INT PRIMARY KEY,name VARCHAR(255),location VARCHAR(255),industry VARCHAR(255)); INSERT INTO company (id,name,location,industry) VALUES (1,'BioCatalyst','San Francisco,CA','Biotech Startup'); CREATE TABLE funding (id INT PRIMARY KEY,company_id INT,fund_type VARCHAR(255),amount INT,funding_date DATE); INSERT INTO funding (id,company_id,fund_type,amount,funding_date) VALUES (1,1,'Series A',4000000,'2021-03-15'); | SELECT c.name, f.fund_type, f.amount FROM company c JOIN funding f ON c.id = f.company_id WHERE c.location = 'San Francisco, CA' AND f.fund_type = 'Series A' AND f.amount > 3000000 AND f.funding_date >= '2020-01-01'; |
What is the total number of local businesses partnered with tourism initiatives in Canada? | CREATE TABLE local_businesses (id INT,name TEXT,partnered_with_tourism BOOLEAN); INSERT INTO local_businesses (id,name,partnered_with_tourism) VALUES (1,'Vancouver Bike Tours',true),(2,'Toronto Artisan Market',false),(3,'Montreal Food Tours',true); | SELECT COUNT(*) FROM local_businesses WHERE partnered_with_tourism = true AND country = 'Canada'; |
What is the percentage of new hires who identify as LGBTQ+ in the HR department in the past year? | CREATE TABLE Employees (EmployeeID INT,HireDate DATE,Community VARCHAR(25),Department VARCHAR(25)); INSERT INTO Employees (EmployeeID,HireDate,Community,Department) VALUES (1,'2022-01-01','LGBTQ+','HR'),(2,'2022-02-15','Allied','Marketing'),(3,'2022-02-15','LGBTQ+','IT'),(4,'2021-12-01','LGBTQ+','HR'); | SELECT Department, COUNT(*) * 100.0 / (SELECT COUNT(*) FROM Employees WHERE HireDate >= DATEADD(year, -1, GETDATE())) AS Percentage FROM Employees WHERE Community = 'LGBTQ+' AND Department = 'HR' GROUP BY Department; |
What is the distribution of digital divide index scores by region in Africa? | CREATE TABLE africa_scores (region TEXT,index_score INT); INSERT INTO africa_scores (region,index_score) VALUES ('Region1',65),('Region2',75),('Region3',85),('Region4',95),('Region5',55); | SELECT region, index_score, COUNT(*) FROM africa_scores GROUP BY index_score ORDER BY index_score; |
Identify the economic diversification efforts in Sub-Saharan Africa with an investment of over 1 million USD. | CREATE TABLE DiversificationEfforts (id INT,effort_name TEXT,location TEXT,investment FLOAT); INSERT INTO DiversificationEfforts (id,effort_name,location,investment) VALUES (1,'Renewable Energy','Sub-Saharan Africa',1500000); INSERT INTO DiversificationEfforts (id,effort_name,location,investment) VALUES (2,'Tourism Development','Sub-Saharan Africa',800000); | SELECT effort_name, location FROM DiversificationEfforts WHERE investment > 1000000 AND location LIKE '%Sub-Saharan Africa%'; |
Which defense contractors had contracts with Russia in 2018? | CREATE SCHEMA if not exists contract_negotiations;CREATE TABLE if not exists defense_contractor_negotiations(contractor text,partner text,negotiation_year integer);INSERT INTO defense_contractor_negotiations(contractor,partner,negotiation_year) VALUES('Lockheed Martin','Russia',2018),('Boeing','China',2018),('BAE Systems','India',2018); | SELECT DISTINCT contractor FROM defense_contractor_negotiations WHERE partner = 'Russia' AND negotiation_year = 2018; |
Show the number of cultural heritage accommodations in each continent. | CREATE TABLE accommodations (accom_id INT,name VARCHAR(50),continent VARCHAR(50),sustainability_rating INT); | SELECT continent, COUNT(accom_id) AS num_cultural_heritage_accoms FROM accommodations WHERE sustainability_rating = 5 GROUP BY continent; |
What is the average temperature for each crop type in the 'crop_temperature' table? | CREATE TABLE crop_temperature (crop_name VARCHAR(255),avg_temperature FLOAT); INSERT INTO crop_temperature (crop_name,avg_temperature) VALUES ('Corn',20.5),('Soybean',22.3),('Wheat',18.7); | SELECT crop_name, AVG(avg_temperature) as avg_temp FROM crop_temperature GROUP BY crop_name; |
What is the minimum number of military personnel in each branch of the military? | CREATE TABLE MilitaryPersonnel (branch TEXT,num_personnel INTEGER); INSERT INTO MilitaryPersonnel (branch,num_personnel) VALUES ('Army',500000),('Navy',350000),('AirForce',300000),('Marines',200000); | SELECT branch, MIN(num_personnel) FROM MilitaryPersonnel GROUP BY branch; |
Delete records with a quantity of zero from the Inventory table | CREATE TABLE Inventory (item_id INT,item_name VARCHAR(50),quantity INT,warehouse_id INT); | DELETE FROM Inventory WHERE quantity = 0; |
What is the maximum safety rating of sports utility vehicles (SUVs) in India in 2019? | CREATE TABLE SUVs (id INT,name VARCHAR(255),safety_rating DECIMAL(3,2),release_year INT,country VARCHAR(50)); INSERT INTO SUVs (id,name,safety_rating,release_year,country) VALUES (1,'Mahindra XUV500',4.6,2019,'India'); INSERT INTO SUVs (id,name,safety_rating,release_year,country) VALUES (2,'Tata Hexa',4.4,2019,'India'); | SELECT MAX(safety_rating) FROM SUVs WHERE country = 'India' AND release_year = 2019 AND name IN ('Mahindra XUV500', 'Tata Hexa'); |
What is the total number of union members in the retail and hospitality industries? | CREATE TABLE retail (id INT,union_member BOOLEAN); INSERT INTO retail (id,union_member) VALUES (1,TRUE),(2,FALSE); CREATE TABLE hospitality (id INT,union_member BOOLEAN); INSERT INTO hospitality (id,union_member) VALUES (1,TRUE),(2,TRUE); | SELECT SUM(IF(union_member = TRUE, 1, 0)) FROM retail; SELECT SUM(IF(union_member = TRUE, 1, 0)) FROM hospitality; SELECT SUM(result) FROM (SELECT SUM(IF(union_member = TRUE, 1, 0)) AS result FROM retail) AS retail_result CROSS JOIN (SELECT SUM(IF(union_member = TRUE, 1, 0)) AS result FROM hospitality) AS hospitality_result; |
Identify the most popular vegan dish in the West region. | CREATE TABLE inventory (item_id INT,quantity INT,unit_price DECIMAL(5,2)); INSERT INTO inventory (item_id,quantity,unit_price) VALUES (1,10,12.99),(2,20,7.50),(3,30,9.99),(4,40,15.49),(5,50,8.99); CREATE TABLE orders (order_id INT,item_id INT,order_date DATE,restaurant_id INT); INSERT INTO orders (order_id,item_id,order_date,restaurant_id) VALUES (1,1,'2022-04-01',3),(2,3,'2022-04-02',2),(3,2,'2022-04-03',1),(4,4,'2022-04-04',1),(5,5,'2022-04-05',2); CREATE TABLE menu_items (item_id INT,name TEXT,is_vegan BOOLEAN,is_vegetarian BOOLEAN,price DECIMAL(5,2)); INSERT INTO menu_items (item_id,name,is_vegan,is_vegetarian,price) VALUES (1,'Quinoa Salad',true,true,12.99),(2,'Tofu Stir Fry',true,true,7.50),(3,'Chickpea Curry',true,true,9.99),(4,'Cheesecake',false,false,15.49),(5,'Veggie Pizza',false,true,8.99); CREATE TABLE restaurants (restaurant_id INT,name TEXT,region TEXT); INSERT INTO restaurants (restaurant_id,name,region) VALUES (1,'Big Burger','East'),(2,'Veggies R Us','Midwest'),(3,'Tasty Bites','West'); | SELECT m.name, SUM(i.quantity) as total_quantity FROM inventory i JOIN orders o ON i.item_id = o.item_id JOIN menu_items m ON i.item_id = m.item_id JOIN restaurants r ON o.restaurant_id = r.restaurant_id WHERE m.is_vegan = true GROUP BY i.item_id ORDER BY total_quantity DESC LIMIT 1; |
What is the total number of bicycles in public bike-sharing programs in Tokyo? | CREATE TABLE public_bikes (bike_id INT,bike_type VARCHAR(20)); INSERT INTO public_bikes (bike_id,bike_type) VALUES (1,'Standard'),(2,'Electric'),(3,'Standard'),(4,'Standard'),(5,'Electric'); | SELECT COUNT(*) as total_bikes FROM public_bikes WHERE bike_type IN ('Standard', 'Electric'); |
Find the number of healthcare providers per 100,000 people in Kenya. | CREATE TABLE healthcare_providers (id INT,provider_id INT,provider_type VARCHAR(50),location VARCHAR(100),population INT); INSERT INTO healthcare_providers (id,provider_id,provider_type,location,population) VALUES (1,501,'Doctor','Nairobi,Kenya',500000); INSERT INTO healthcare_providers (id,provider_id,provider_type,location,population) VALUES (2,502,'Nurse','Mombasa,Kenya',250000); | SELECT location, COUNT(*) * 100000.0 / SUM(population) FROM healthcare_providers WHERE location LIKE '%Kenya' GROUP BY location; |
Which countries have the most unvaccinated children under 5 in the children_under_5 table? | CREATE TABLE children_under_5 (id INT PRIMARY KEY,country VARCHAR(50),unvaccinated_children INT); INSERT INTO children_under_5 (id,country,unvaccinated_children) VALUES (1,'Afghanistan',500000); INSERT INTO children_under_5 (id,country,unvaccinated_children) VALUES (2,'Brazil',250000); | SELECT country, SUM(unvaccinated_children) as total_unvaccinated_children FROM children_under_5 GROUP BY country ORDER BY total_unvaccinated_children DESC; |
What is the number of peacekeeping operations conducted by each country in 2019 and 2020? | CREATE TABLE peacekeeping_operations (id INT,country VARCHAR(255),year INT,operations INT); INSERT INTO peacekeeping_operations (id,country,year,operations) VALUES (1,'Brazil',2019,10),(2,'Brazil',2020,15),(3,'China',2019,12),(4,'China',2020,25),(5,'Canada',2019,18),(6,'Canada',2020,20); | SELECT country, year, SUM(operations) as total_operations FROM peacekeeping_operations WHERE year IN (2019, 2020) GROUP BY country, year; |
Delete all impact investments in the 'Africa' region. | CREATE TABLE impact_investments (id INT,region VARCHAR(20),investment_year INT,investment_amount FLOAT); INSERT INTO impact_investments (id,region,investment_year,investment_amount) VALUES (1,'Asia',2020,150000),(2,'Africa',2019,120000),(3,'Asia',2020,180000); | DELETE FROM impact_investments WHERE region = 'Africa'; |
Which external IP addresses have been associated with suspicious activity in the last month, according to the threat intelligence database? | CREATE TABLE threat_intelligence (id INT,ip_address VARCHAR(15),activity VARCHAR(20)); | SELECT ip_address FROM threat_intelligence WHERE activity = 'suspicious' AND timestamp >= NOW() - INTERVAL 1 MONTH; |
What is the average speed of vessels arriving from Japan to San Francisco? | CREATE TABLE ports (id INT,name VARCHAR(255)); INSERT INTO ports (id,name) VALUES (1,'Japan'),(2,'San Francisco'); CREATE TABLE vessel_movements (id INT,vessel_id INT,departure_port_id INT,arrival_port_id INT,speed DECIMAL(5,2),date DATE); INSERT INTO vessel_movements (id,vessel_id,departure_port_id,arrival_port_id,speed,date) VALUES (1,101,1,2,15.2,'2022-01-01'),(2,102,1,2,17.3,'2022-01-05'),(3,103,1,2,14.8,'2022-01-10'); | SELECT AVG(speed) FROM vessel_movements WHERE departure_port_id = (SELECT id FROM ports WHERE name = 'Japan') AND arrival_port_id = (SELECT id FROM ports WHERE name = 'San Francisco'); |
What is the total budget for each department that has a program outcome in 2021? | CREATE TABLE Departments (DepartmentID INT,DepartmentName VARCHAR(255)); CREATE TABLE Programs (ProgramID INT,DepartmentID INT,ProgramName VARCHAR(255)); CREATE TABLE Budget (BudgetID INT,DepartmentID INT,Amount DECIMAL(10,2),BudgetDate DATE); CREATE TABLE ProgramOutcomes (ProgramID INT,ProgramOutcomeDate DATE); | SELECT Departments.DepartmentID, Departments.DepartmentName, SUM(Budget.Amount) as TotalBudget FROM Budget INNER JOIN Departments ON Budget.DepartmentID = Departments.DepartmentID INNER JOIN Programs ON Departments.DepartmentID = Programs.DepartmentID INNER JOIN ProgramOutcomes ON Programs.ProgramID = ProgramOutcomes.ProgramID WHERE YEAR(ProgramOutcomes.ProgramOutcomeDate) = 2021 GROUP BY Departments.DepartmentID, Departments.DepartmentName; |
How many workplace incidents were reported in 'Construction' unions in 2021? | CREATE TABLE WorkplaceSafety (union_id INT,year INT,incidents INT); CREATE TABLE Unions (union_id INT,industry TEXT); | SELECT SUM(incidents) FROM WorkplaceSafety INNER JOIN Unions ON WorkplaceSafety.union_id = Unions.union_id WHERE Unions.industry = 'Construction' AND WorkplaceSafety.year = 2021; |
Which eSports events are happening in the USA? | CREATE TABLE Events (EventID INT,Name VARCHAR(50),Country VARCHAR(50),StartDate DATE,EndDate DATE); INSERT INTO Events (EventID,Name,Country,StartDate,EndDate) VALUES (1,'Evo','USA','2023-08-04','2023-08-06'); INSERT INTO Events (EventID,Name,Country,StartDate,EndDate) VALUES (2,'DreamHack','Sweden','2023-06-16','2023-06-18'); | SELECT * FROM Events WHERE Country = 'USA'; |
Provide the names and deployment years for all satellites launched by NASA. | CREATE TABLE SatelliteInfo (Id INT,Agency VARCHAR(50),Name VARCHAR(50),LaunchYear INT); INSERT INTO SatelliteInfo (Id,Agency,Name,LaunchYear) VALUES (1,'NASA','Explorer 1',1958),(2,'NASA','TIROS-1',1960); | SELECT Agency, Name FROM SatelliteInfo WHERE Agency = 'NASA'; |
What is the average mental health score of students in each district, only showing districts with an average score below 70? | CREATE TABLE districts (district_id INT,district_name TEXT,avg_mental_health_score FLOAT); INSERT INTO districts (district_id,district_name,avg_mental_health_score) VALUES (1,'Downtown',75.2),(2,'Uptown',68.9),(3,'Midtown',82.1); | SELECT district_name, AVG(avg_mental_health_score) as avg_score FROM districts GROUP BY district_name HAVING AVG(avg_mental_health_score) < 70; |
How many plastic waste recycling facilities are there in China and Indonesia? | CREATE TABLE RecyclingFacilities (facility_id INT,country VARCHAR(50),type VARCHAR(50)); | SELECT COUNT(*) FROM RecyclingFacilities WHERE country IN ('China', 'Indonesia') AND type = 'plastic'; |
Delete all records from the 'animal_population' table where the 'population' is 0 | CREATE TABLE animal_population (id INT PRIMARY KEY,species VARCHAR(30),name VARCHAR(20),population INT); | DELETE FROM animal_population WHERE population = 0; |
List the number of mental health appointments for each cultural competency level, in descending order. | CREATE TABLE CulturalCompetency (ID INT,Level TEXT); INSERT INTO CulturalCompetency (ID,Level) VALUES (1,'Beginner'); INSERT INTO CulturalCompetency (ID,Level) VALUES (2,'Intermediate'); INSERT INTO CulturalCompetency (ID,Level) VALUES (3,'Advanced'); CREATE TABLE MentalHealthAppointment (AppointmentID INT,CulturalCompetencyID INT); | SELECT CulturalCompetencyID, COUNT(AppointmentID) as NumAppointments FROM MentalHealthAppointment GROUP BY CulturalCompetencyID ORDER BY NumAppointments DESC; |
What is the distribution of electric vehicle adoption rates by make? | CREATE TABLE electric_vehicle_stats (country VARCHAR(50),adoption_rate DECIMAL(3,1),year INT,make VARCHAR(50)); | SELECT make, AVG(adoption_rate) FROM electric_vehicle_stats GROUP BY make; |
Identify the top 3 countries with the highest seafood consumption by weight in the past year. | CREATE TABLE country_data (country VARCHAR(255),seafood_weight FLOAT,year INT); CREATE TABLE country (id INT,name VARCHAR(255),continent VARCHAR(255)); | SELECT c.country, SUM(country_data.seafood_weight) as total_weight, RANK() OVER (ORDER BY SUM(country_data.seafood_weight) DESC) as rank FROM country_data JOIN country ON c.country = country_data.country WHERE country_data.year = EXTRACT(YEAR FROM CURRENT_DATE) - 1 GROUP BY c.country ORDER BY total_weight DESC LIMIT 3; |
List all customers who have made fraudulent transactions in Q4 2022. | CREATE TABLE customers (customer_id INT,customer_name TEXT); CREATE TABLE transactions (transaction_id INT,customer_id INT,transaction_date DATE,is_fraudulent BOOLEAN); | SELECT c.customer_id, c.customer_name FROM customers c JOIN transactions t ON c.customer_id = t.customer_id WHERE t.transaction_date BETWEEN '2022-10-01' AND '2022-12-31' AND t.is_fraudulent = TRUE; |
Which regions have more than 50% female representation in technology for social good initiatives? | CREATE TABLE Tech_Social_Good (region VARCHAR(50),gender VARCHAR(10),participants INT); INSERT INTO Tech_Social_Good (region,gender,participants) VALUES ('Africa','Female',30000),('Asia','Female',45000),('South America','Female',25000),('Europe','Male',55000),('North America','Female',60000); | SELECT region, CASE WHEN SUM(CASE WHEN gender = 'Female' THEN participants ELSE 0 END) / SUM(participants) > 0.5 THEN 'Yes' ELSE 'No' END as high_female_representation FROM Tech_Social_Good GROUP BY region; |
How many space missions were launched per year? | CREATE TABLE space_missions (id INT,mission_name VARCHAR(255),launch_date DATE); INSERT INTO space_missions (id,mission_name,launch_date) VALUES (1,'Apollo 11','1969-07-16'),(2,'Mars Rover','2004-01-04'),(3,'Apollo 13','1970-04-11'),(4,'Cassini','1997-10-15'); | SELECT EXTRACT(YEAR FROM launch_date) AS Year, COUNT(*) OVER (PARTITION BY EXTRACT(YEAR FROM launch_date)) as MissionsPerYear FROM space_missions; |
What is the total quantity of items in warehouse 2 and 3? | CREATE TABLE warehouses (id INT,location VARCHAR(10),item VARCHAR(10),quantity INT); INSERT INTO warehouses (id,location,item,quantity) VALUES (1,'NY','A101',200),(2,'NJ','A101',300),(3,'CA','B203',150),(4,'NY','C304',50); | SELECT SUM(quantity) FROM warehouses WHERE id IN (2, 3); |
How many community events were held in New York between 2018 and 2020? | CREATE TABLE CommunityEvents (id INT,location VARCHAR(255),start_date DATE,end_date DATE); | SELECT COUNT(*) FROM CommunityEvents WHERE location = 'New York' AND start_date BETWEEN '2018-01-01' AND '2020-12-31'; |
Get the names of all marine life research stations that are not part of any maritime law compliance initiatives | CREATE TABLE marine_life_research_stations (station_id INT,station_name TEXT); INSERT INTO marine_life_research_stations (station_id,station_name) VALUES (1,'Station A'),(2,'Station B'),(3,'Station C'); CREATE TABLE maritime_law_compliance_initiatives (initiative_id INT,initiative_name TEXT,station_id INT); INSERT INTO maritime_law_compliance_initiatives (initiative_id,initiative_name,station_id) VALUES (1,'Initiative X',2),(2,'Initiative Y',3); | SELECT m.station_name FROM marine_life_research_stations m LEFT JOIN maritime_law_compliance_initiatives mlci ON m.station_id = mlci.station_id WHERE mlci.initiative_id IS NULL; |
What is the maximum CO2 emission for fairly traded products? | CREATE TABLE products (product_id INT,product_name TEXT,price DECIMAL,CO2_emission INT,fairly_traded BOOLEAN); INSERT INTO products (product_id,product_name,price,CO2_emission,fairly_traded) VALUES (1,'ProductA',25.99,450,true),(2,'ProductB',18.49,600,false),(3,'ProductC',29.99,350,true); | SELECT MAX(CO2_emission) FROM products WHERE fairly_traded = true; |
What is the total funding raised by startups founded by underrepresented racial or ethnic groups? | CREATE TABLE founders (id INT,name TEXT,race TEXT); INSERT INTO founders (id,name,race) VALUES (1,'Charles','African American'),(2,'Dana','Latinx'),(3,'Eli','Asian'),(4,'Fiona','Caucasian'); CREATE TABLE startups (id INT,name TEXT,funding FLOAT); INSERT INTO startups (id,name,funding) VALUES (1,'Delta Inc',6000000.0),(2,'Echo Corp',8000000.0),(3,'Foxtrot Ltd',9000000.0),(4,'Gamma Inc',1000000.0); CREATE VIEW underrepresented_founders AS SELECT * FROM founders WHERE race NOT IN ('Caucasian'); | SELECT SUM(startups.funding) FROM startups INNER JOIN underrepresented_founders ON startups.id = underrepresented_founders.id; |
How many indigenous women farmers in 'tribal_area_3' produce food for their community? | CREATE TABLE tribal_area_3 (farmer_id TEXT,indigenous BOOLEAN,gender TEXT,community_food BOOLEAN); INSERT INTO tribal_area_3 (farmer_id,indigenous,gender,community_food) VALUES ('i010',true,'female',true),('i011',true,'male',false),('i012',false,'non-binary',true),('i013',false,'male',false); | SELECT COUNT(*) FROM tribal_area_3 WHERE indigenous = true AND gender = 'female' AND community_food = true; |
What are the top 3 countries with the most jazz albums released? | CREATE TABLE Countries (CountryName VARCHAR(50)); CREATE TABLE JazzAlbums (AlbumID INT,CountryName VARCHAR(50)); INSERT INTO Countries VALUES ('USA','Canada','France','UK','Japan'); INSERT INTO JazzAlbums VALUES (1,'USA'),(2,'USA'),(3,'Canada'),(4,'France'),(5,'Japan'),(6,'USA'); | SELECT CountryName, COUNT(*) as JazzAlbumCount FROM JazzAlbums JOIN Countries ON JazzAlbums.CountryName = Countries.CountryName GROUP BY CountryName ORDER BY JazzAlbumCount DESC LIMIT 3; |
Delete records of users who have not logged in for the past 6 months from the "Members" table | CREATE TABLE Members (Id INT PRIMARY KEY,FirstName VARCHAR(50),LastName VARCHAR(50),LastLogin DATETIME); | DELETE FROM Members WHERE LastLogin < DATE_SUB(CURDATE(), INTERVAL 6 MONTH); |
What is the average temperature of the ocean surface in each month for the past year, and the corresponding sea level anomalies? | CREATE TABLE temperature (date DATE,location TEXT,temperature FLOAT); CREATE TABLE sea_level_anomalies (date DATE,location TEXT,anomaly FLOAT); | SELECT MONTH(temperature.date) AS month, AVG(temperature.temperature) AS avg_temperature, sea_level_anomalies.anomaly FROM temperature INNER JOIN sea_level_anomalies ON temperature.date = sea_level_anomalies.date GROUP BY month; |
What is the total number of vulnerabilities found in the 'vulnerability_assessments' table for each department? | CREATE TABLE vulnerability_assessments (id INT,department VARCHAR(50),vulnerability_count INT); | SELECT department, SUM(vulnerability_count) as total_vulnerabilities FROM vulnerability_assessments GROUP BY department; |
What is the total number of accommodations provided by type, across all countries? | CREATE TABLE Accommodations (ID INT PRIMARY KEY,Country VARCHAR(50),AccommodationType VARCHAR(50),Quantity INT); INSERT INTO Accommodations (ID,Country,AccommodationType,Quantity) VALUES (1,'USA','Sign Language Interpretation',300),(2,'Canada','Wheelchair Ramp',250),(3,'Mexico','Assistive Listening Devices',150); | SELECT AccommodationType, SUM(Quantity) as Total FROM Accommodations GROUP BY AccommodationType; |
What is the average salary of employees in the IT department? | CREATE TABLE Employees (EmployeeID INT,Department VARCHAR(20),Salary FLOAT); INSERT INTO Employees (EmployeeID,Department,Salary) VALUES (1,'IT',75000.00),(2,'IT',80000.00),(3,'HR',60000.00); | SELECT AVG(Salary) FROM Employees WHERE Department = 'IT'; |
Update the status of completed economic diversification projects in the Caribbean to 'closed'. | CREATE TABLE economic_div (id INT,name VARCHAR(255),region VARCHAR(255),status VARCHAR(255)); INSERT INTO economic_div (id,name,region,status) VALUES (1,'Sustainable Tourism','Caribbean','completed'); | UPDATE economic_div SET status = 'closed' WHERE region = 'Caribbean' AND status = 'completed'; |
What is the average volume of timber produced annually for the 'Coniferous' forest type? | CREATE TABLE timber_production (year INT,forest_type VARCHAR(255),volume INT); INSERT INTO timber_production (year,forest_type,volume) VALUES (2018,'Coniferous',300),(2019,'Coniferous',350),(2020,'Coniferous',400),(2018,'Deciduous',200),(2019,'Deciduous',250),(2020,'Deciduous',300); | SELECT AVG(volume) FROM timber_production WHERE forest_type = 'Coniferous'; |
What is the safety record of the Airbus A320? | CREATE TABLE accidents (accident_id INT,aircraft_model VARCHAR(50),num_injuries INT); INSERT INTO accidents (accident_id,aircraft_model,num_injuries) VALUES (1,'Boeing 747',50),(2,'Airbus A320',20),(3,'Boeing 777',30); | SELECT AVG(num_injuries) FROM accidents WHERE aircraft_model = 'Airbus A320'; |
List all companies with diverse founding teams (more than one gender represented) | CREATE TABLE companies (company_id INT,company_name VARCHAR(50),founder_1_gender VARCHAR(10),founder_2_gender VARCHAR(10)); INSERT INTO companies VALUES (1,'Gamma Ltd','Female','Male'); INSERT INTO companies VALUES (2,'Delta Co','Non-binary',NULL); | SELECT company_name FROM companies WHERE founder_1_gender IS NOT NULL AND founder_2_gender IS NOT NULL; |
What is the average age of visitors who attended events in New York in 2021? | CREATE TABLE event_attendees (id INT,name VARCHAR(100),age INT,city VARCHAR(50),event_date DATE); INSERT INTO event_attendees (id,name,age,city,event_date) VALUES (1,'John Doe',30,'New York','2021-06-01'); INSERT INTO event_attendees (id,name,age,city,event_date) VALUES (2,'Jane Smith',45,'New York','2021-07-15'); | SELECT AVG(age) FROM event_attendees WHERE city = 'New York' AND YEAR(event_date) = 2021; |
What is the percentage of mobile customers who have used more than 10GB of data in a month? | CREATE TABLE mobile_customers (customer_id INT,data_usage FLOAT); INSERT INTO mobile_customers (customer_id,data_usage) VALUES (1,12.5),(2,3.2),(3,7.8); | SELECT (COUNT(*) FILTER (WHERE data_usage > 10)) * 100.0 / COUNT(*) FROM mobile_customers; |
Find the well with the highest production volume in 2019 | CREATE TABLE production (id INT,well_name VARCHAR(50),year INT,production_volume INT); INSERT INTO production (id,well_name,year,production_volume) VALUES (1,'Well X',2019,1000); INSERT INTO production (id,well_name,year,production_volume) VALUES (2,'Well Y',2020,1500); INSERT INTO production (id,well_name,year,production_volume) VALUES (3,'Well X',2020,1200); INSERT INTO production (id,well_name,year,production_volume) VALUES (4,'Well Z',2019,1800); | SELECT well_name, MAX(production_volume) FROM production WHERE year = 2019; |
What is the total mass of space debris smaller than 1 cm? | CREATE TABLE space_debris_tiny (id INT,mass FLOAT,size FLOAT); INSERT INTO space_debris_tiny (id,mass,size) VALUES (1,0.01,0.1),(2,0.02,0.2),(3,0.03,0.3),(4,0.04,0.4),(5,0.05,0.5); | SELECT SUM(mass) FROM space_debris_tiny WHERE size < 1; |
What is the average number of research grants awarded to non-binary faculty members in the College of Education? | CREATE TABLE faculty (id INT,name VARCHAR(100),department VARCHAR(50),gender VARCHAR(50),grant_amount DECIMAL(10,2)); INSERT INTO faculty (id,name,department,gender,grant_amount) VALUES (1,'Kavi','Education','Non-binary',120000.00); | SELECT AVG(grant_amount) FROM faculty WHERE department = 'Education' AND gender = 'Non-binary'; |
What is the success rate of cases handled by attorneys with more than 10 years of experience? | CREATE TABLE attorneys (attorney_id INT,years_of_experience INT); CREATE TABLE cases (case_id INT,attorney_id INT,outcome TEXT); | SELECT AVG(CASE WHEN cases.outcome = 'Success' THEN 1.0 ELSE 0.0 END) AS success_rate FROM cases INNER JOIN attorneys ON cases.attorney_id = attorneys.attorney_id WHERE attorneys.years_of_experience > 10; |
List the names and total funding of startups founded by individuals who identify as Latinx or Hispanic in the technology sector. | CREATE TABLE startups (id INT,name TEXT,founder_ethnicity TEXT); CREATE TABLE investments (id INT,startup_id INT,funding_amount INT); | SELECT startups.name, SUM(investments.funding_amount) FROM startups INNER JOIN investments ON startups.id = investments.startup_id WHERE startups.founder_ethnicity IN ('Latinx', 'Hispanic') AND startups.name IN (SELECT name FROM startups WHERE industry = 'Technology'); |
Delete a volunteer's record, given their ID | CREATE TABLE Volunteers (id INT,first_name VARCHAR,last_name VARCHAR,email VARCHAR,phone_number VARCHAR,date_joined DATE); INSERT INTO Volunteers (id,first_name,last_name,email,phone_number,date_joined) VALUES (1,'John','Doe','[email protected]','555-123-4567','2021-05-01'),(2,'Jane','Doe','[email protected]','555-987-6543','2021-06-01'); | DELETE FROM Volunteers WHERE id = 2; |
How many unique IP addresses have been associated with each threat category in the last week? | CREATE TABLE threats (id INT,category VARCHAR(50),ip_address VARCHAR(50),threat_date DATE); INSERT INTO threats (id,category,ip_address,threat_date) VALUES (1,'Malware','192.168.0.1','2022-01-01'),(2,'Phishing','192.168.0.2','2022-01-03'),(3,'Ransomware','192.168.0.3','2022-01-02'); | SELECT category, COUNT(DISTINCT ip_address) as unique_ips FROM threats WHERE threat_date >= DATE_SUB(CURDATE(), INTERVAL 1 WEEK) GROUP BY category; |
What is the minimum legal limit of nitrogen oxide emissions for ships in the Baltic Sea? | CREATE TABLE Baltic_Maritime_Law (law_name TEXT,nox_limit INT); INSERT INTO Baltic_Maritime_Law (law_name,nox_limit) VALUES ('Baltic Sea Emission Control Area',8.3); | SELECT nox_limit FROM Baltic_Maritime_Law WHERE law_name = 'Baltic Sea Emission Control Area'; |
What is the employment rate for veterans in the defense industry in New York in Q2 2021? | CREATE TABLE Veteran_Employment (employment_id INT,industry TEXT,state TEXT,employment_rate FLOAT,quarter INT,year INT); INSERT INTO Veteran_Employment (employment_id,industry,state,employment_rate,quarter,year) VALUES (1,'Defense','New York',0.12,2,2021); | SELECT employment_rate FROM Veteran_Employment WHERE industry = 'Defense' AND state = 'New York' AND quarter = 2 AND year = 2021; |
What is the total number of construction permits issued in Texas in the past 12 months, ranked by the permit value? | CREATE TABLE tx_permits (id INT,permit_id VARCHAR(50),permit_value FLOAT,permit_date DATE,city VARCHAR(50),state VARCHAR(50)); INSERT INTO tx_permits (id,permit_id,permit_value,permit_date,city,state) VALUES (1,'123456',1000000,'2021-07-01','Dallas','TX'),(2,'789101',1500000,'2021-06-15','Houston','TX'),(3,'111213',800000,'2021-05-05','Austin','TX'); | SELECT permit_id, permit_value, RANK() OVER (ORDER BY permit_value DESC) as rank FROM tx_permits WHERE state = 'TX' AND permit_date >= DATEADD(YEAR, -1, CURRENT_DATE) GROUP BY permit_id, permit_value ORDER BY permit_value DESC; |
Insert new record into 'orders' table for customer 'John Doe' and order_date '2022-03-21' | CREATE TABLE orders (customer_name VARCHAR(255),order_date DATE); | INSERT INTO orders (customer_name, order_date) VALUES ('John Doe', '2022-03-21'); |
Show the number of volunteer hours contributed by city in the 'volunteer_hours' table. | CREATE TABLE volunteer_hours (id INT,volunteer_name VARCHAR(50),city VARCHAR(50),hours DECIMAL(5,2)); | SELECT city, COUNT(*) FROM volunteer_hours GROUP BY city; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.