instruction stringlengths 0 1.06k | input stringlengths 11 5.3k | response stringlengths 2 4.44k |
|---|---|---|
What is the total investment in the 'Equity' fund type for customers in the 'Europe' region? | CREATE TABLE investments (id INT,customer_id INT,fund_type VARCHAR(50),investment_amount DECIMAL(10,2)); INSERT INTO investments (id,customer_id,fund_type,investment_amount) VALUES (1,1,'Bond',10000.00); INSERT INTO investments (id,customer_id,fund_type,investment_amount) VALUES (2,2,'Equity',15000.00); INSERT INTO investments (id,customer_id,fund_type,investment_amount) VALUES (3,3,'Bond',20000.00); INSERT INTO investments (id,customer_id,fund_type,investment_amount) VALUES (4,4,'Equity',25000.00); | SELECT SUM(investment_amount) FROM investments WHERE fund_type = 'Equity' AND customer_id IN (SELECT id FROM customers WHERE region = 'Europe'); |
Calculate the average score for each game category in the 'GameScores' table | CREATE TABLE GameScores (GameID INT,GameCategory VARCHAR(255),Score INT); | SELECT GameCategory, AVG(Score) as AverageScore FROM GameScores GROUP BY GameCategory; |
What is the maximum production capacity of all diamond mines in the 'mine_stats' table? | CREATE TABLE mine_stats (mine_name VARCHAR(255),mine_type VARCHAR(255),production_capacity FLOAT); INSERT INTO mine_stats (mine_name,mine_type,production_capacity) VALUES ('Diamond Dell','diamond',5000.2),('Gemstone Gorge','diamond',6000.4),('Precious Point','diamond',7000.1); | SELECT MAX(production_capacity) FROM mine_stats WHERE mine_type = 'diamond'; |
What is the total number of unions advocating for workplace safety and their total number of collective bargaining agreements? | CREATE TABLE unions (union_id INT,union_name TEXT,advocacy TEXT,cb_agreements INT); INSERT INTO unions (union_id,union_name,advocacy,cb_agreements) VALUES (1001,'United Steelworkers','workplace safety',20); INSERT INTO unions (union_id,union_name,advocacy,cb_agreements) VALUES (1002,'Transport Workers Union','collective bargaining',30); | SELECT u.advocacy, SUM(u.cb_agreements), COUNT(u.union_id) FROM unions u WHERE u.advocacy = 'workplace safety' GROUP BY u.advocacy; |
How many mining operations are there in the United States, and what is the total amount of minerals extracted in the state of Nevada? | CREATE TABLE countries (country_id INT,country_name TEXT); INSERT INTO countries VALUES (1,'United States'); CREATE TABLE states (state_id INT,state_name TEXT,country_id INT); INSERT INTO states VALUES (1,'Nevada',1); CREATE TABLE mining_operations (operation_id INT,state_id INT,minerals_extracted FLOAT); | SELECT COUNT(*) AS num_operations, SUM(minerals_extracted) AS total_minerals_extracted FROM mining_operations MO JOIN states S ON MO.state_id = S.state_id WHERE S.country_name = 'United States' AND S.state_name = 'Nevada'; |
What is the average depth of all expeditions for the 'Ocean Explorer' organization? | CREATE TABLE expedition (org VARCHAR(20),depth INT); INSERT INTO expedition VALUES ('Ocean Explorer',2500),('Ocean Explorer',3000),('Sea Discoverers',2000); | SELECT AVG(depth) FROM expedition WHERE org = 'Ocean Explorer'; |
How many crimes were reported in each district last year? | CREATE TABLE CrimeStats (ID INT,District VARCHAR(50),Year INT,NumberOfCrimes INT); | SELECT District, Year, SUM(NumberOfCrimes) FROM CrimeStats GROUP BY District, Year; |
What is the correlation between AI adoption and hotel ratings in South America? | CREATE TABLE hotel_ai_rating (hotel_id INT,hotel_name TEXT,country TEXT,ai_services TEXT,rating FLOAT); INSERT INTO hotel_ai_rating (hotel_id,hotel_name,country,ai_services,rating) VALUES (1,'The Smart Hotel','Brazil','yes',4.5),(2,'The Traditional Inn','Brazil','no',3.8),(3,'The AI Resort','Argentina','yes',4.8),(4,'The Classic Hotel','Argentina','yes',4.2),(5,'The Innovative Hotel','Chile','no',3.5); | SELECT correlation(ai_services, rating) FROM hotel_ai_rating WHERE country = 'South America' |
What is the total number of transactions and the total transaction value per client? | CREATE TABLE transactions (transaction_id INT,client_id INT,transaction_value FLOAT); INSERT INTO transactions (transaction_id,client_id,transaction_value) VALUES (1,1,1000.00),(2,1,2000.00),(3,2,500.00); | SELECT c.name, COUNT(t.transaction_id) as total_transactions, SUM(t.transaction_value) as total_transaction_value FROM clients c JOIN transactions t ON c.client_id = t.client_id GROUP BY c.name; |
List the number of incidents for each vessel type in the safety records. | CREATE TABLE VesselTypes (TypeID INT,Type TEXT); CREATE TABLE Incidents (IncidentID INT,VesselID INT,IncidentType TEXT,Date DATE); INSERT INTO VesselTypes VALUES (1,'Oil Tanker'),(2,'Cargo Ship'); INSERT INTO Incidents VALUES (1,1,'Oil Spill','2020-01-01'); INSERT INTO Incidents VALUES (2,2,'Collision','2020-02-01'); | SELECT VesselTypes.Type, COUNT(Incidents.IncidentID) FROM VesselTypes LEFT JOIN Incidents ON VesselTypes.TypeID = Incidents.VesselID GROUP BY VesselTypes.Type; |
What is the total number of visitors to Africa in the last 6 months? | CREATE TABLE visitors (id INT,location TEXT,date DATE); INSERT INTO visitors (id,location,date) VALUES (1,'Kenya','2022-01-15'),(2,'Egypt','2021-12-01'); | SELECT COUNT(*) FROM visitors WHERE location LIKE 'Africa%' AND date >= DATEADD(month, -6, GETDATE()); |
What is the average price of products, grouped by their material, that were manufactured in the US? | CREATE TABLE products (product_id INT,product_name TEXT,material TEXT,price DECIMAL,country_of_manufacture TEXT); INSERT INTO products (product_id,product_name,material,price,country_of_manufacture) VALUES (1,'Cotton Shirt','Cotton',25.99,'United States'); | SELECT material, AVG(price) FROM products WHERE country_of_manufacture = 'United States' GROUP BY material; |
Find the percentage change in agricultural innovation metrics for each country between 2021 and 2022, sorted by the highest increase? | CREATE TABLE agricultural_metrics (id INT,country TEXT,metric INT,year INT,PRIMARY KEY (id,year)); INSERT INTO agricultural_metrics (id,country,metric,year) VALUES (1,'Country A',200,2021),(2,'Country B',150,2021),(3,'Country A',250,2022),(4,'Country B',180,2022); | SELECT country, ((LAG(metric, 1) OVER (PARTITION BY country ORDER BY year) - metric) * 100.0 / LAG(metric, 1) OVER (PARTITION BY country ORDER BY year)) as pct_change FROM agricultural_metrics WHERE year IN (2021, 2022) GROUP BY country ORDER BY pct_change DESC; |
Determine the average explainability score for AI models involved in autonomous driving systems, in the last 4 years, and display the average score, model name, and training location, grouped by the year of training. | CREATE TABLE ai_models (model_id INT,model_name VARCHAR(50),domain VARCHAR(50),training_location VARCHAR(50),training_date DATE,explainability_score DECIMAL(3,2)); | SELECT YEAR(training_date) AS year, AVG(explainability_score) AS avg_explainability_score, model_name, training_location FROM ai_models WHERE domain = 'autonomous driving systems' AND training_date >= DATE(CURRENT_DATE) - INTERVAL 4 YEAR GROUP BY year, model_name, training_location ORDER BY year ASC; |
Find the total number of pallets shipped from the 'AMER' region | CREATE TABLE packages (id INT,type TEXT); INSERT INTO packages (id,type) VALUES (1,'Box'),(2,'Pallet'),(3,'Envelope'); CREATE TABLE shipments (id INT,package_id INT,warehouse_id INT); INSERT INTO shipments (id,package_id,warehouse_id) VALUES (1,1,3),(2,2,3),(3,3,4),(4,1,2); CREATE TABLE warehouses (id INT,name TEXT,region TEXT); INSERT INTO warehouses (id,name,region) VALUES (1,'Warehouse A','EMEA'),(2,'Warehouse B','APAC'),(3,'Warehouse C','AMER'),(4,'Warehouse D','AMER'); | SELECT SUM(shipments.id) AS total_pallets FROM shipments JOIN packages ON shipments.package_id = packages.id JOIN warehouses ON shipments.warehouse_id = warehouses.id WHERE packages.type = 'Pallet' AND warehouses.region = 'AMER'; |
What is the maximum number of emergency calls in each hour of the day? | CREATE TABLE calls (cid INT,call_time TIME); | SELECT HOUR(call_time) AS hour_of_day, MAX(COUNT(*)) FROM calls GROUP BY hour_of_day; |
What is the average salary for employees who were hired in 2020? | CREATE TABLE Employees (EmployeeID INT,HireDate DATE,Salary DECIMAL(10,2)); INSERT INTO Employees (EmployeeID,HireDate,Salary) VALUES (1,'2020-01-01',75000.00),(2,'2019-01-01',60000.00),(3,'2020-03-01',80000.00),(4,'2018-01-01',90000.00),(5,'2020-05-01',95000.00),(6,'2019-06-01',65000.00); | SELECT AVG(Salary) FROM Employees WHERE YEAR(HireDate) = 2020; |
What is the count of aircraft manufactured by Boeing? | CREATE TABLE aircraft (maker TEXT,model TEXT); INSERT INTO aircraft (maker,model) VALUES ('Boeing','747'),('Boeing','777'),('Airbus','A320'),('Airbus','A350'); | SELECT COUNT(*) FROM aircraft WHERE maker = 'Boeing'; |
Display the total budget allocated for 'national security' and 'cybersecurity' combined. | CREATE TABLE budget (category TEXT,amount INTEGER); INSERT INTO budget (category,amount) VALUES ('national security',15000),('intelligence operations',10000),('cybersecurity',12000); | SELECT (SUM(CASE WHEN category = 'national security' THEN amount ELSE 0 END) + SUM(CASE WHEN category = 'cybersecurity' THEN amount ELSE 0 END)) FROM budget |
How many sculptures are there in the 'Modern' style that cost over $2000? | CREATE TABLE Artworks (artwork_id INT,type VARCHAR(20),style VARCHAR(20),price DECIMAL(10,2)); INSERT INTO Artworks (artwork_id,type,style,price) VALUES (1,'Painting','Impressionist',1200.00),(2,'Sculpture','Modern',2500.00),(3,'Painting','Impressionist',1800.00); | SELECT COUNT(*) FROM Artworks WHERE type = 'Sculpture' AND style = 'Modern' AND price > 2000.00; |
What is the percentage of rural healthcare providers that offer telemedicine services, grouped by provider type? | CREATE TABLE healthcare_providers (id INT,name TEXT,type TEXT,services TEXT); | SELECT type, AVG(telemedicine) * 100 AS percentage FROM (SELECT type, (CASE WHEN services LIKE '%Telemedicine%' THEN 1 ELSE 0 END) AS telemedicine FROM healthcare_providers) AS telemedicine_providers GROUP BY type; |
What is the total revenue generated from garment manufacturing in 'Africa' in Q3 2022? | CREATE TABLE manufacturing(region VARCHAR(20),revenue INT,manufacturing_date DATE); INSERT INTO manufacturing (region,revenue,manufacturing_date) VALUES ('Africa',5000,'2022-07-01'); INSERT INTO manufacturing (region,revenue,manufacturing_date) VALUES ('Europe',7000,'2022-07-02'); | SELECT SUM(revenue) FROM manufacturing WHERE region = 'Africa' AND manufacturing_date >= '2022-07-01' AND manufacturing_date <= '2022-09-30'; |
What is the minimum carbon price (USD/ton) in the California Cap-and-Trade Program since its inception? | CREATE TABLE carbon_prices_ca (id INT,market TEXT,state TEXT,price FLOAT,year INT); INSERT INTO carbon_prices_ca (id,market,state,price,year) VALUES (1,'California Cap-and-Trade Program','California',13.57,2013); | SELECT MIN(price) FROM carbon_prices_ca WHERE market = 'California Cap-and-Trade Program' AND state = 'California'; |
What are the total sales, in terms of quantity, for each cannabis strain in the state of California for the year 2021, excluding strains with no sales? | CREATE TABLE strains (id INT PRIMARY KEY,name VARCHAR(255),type VARCHAR(255),state VARCHAR(255),cultivation_date DATE); CREATE TABLE sales (id INT PRIMARY KEY,strain_id INT,quantity INT,sale_date DATE); | SELECT strains.name, SUM(sales.quantity) as total_sales FROM strains INNER JOIN sales ON strains.id = sales.strain_id WHERE strains.state = 'California' AND YEAR(sales.sale_date) = 2021 GROUP BY strains.name HAVING total_sales > 0; |
What is the percentage of the population in each state that is below the poverty line? | CREATE TABLE poverty (state VARCHAR(255),population INT,below_poverty_line INT); INSERT INTO poverty (state,population,below_poverty_line) VALUES ('California',40000000,5000000),('Texas',30000000,4000000),('New York',20000000,3000000); | SELECT s1.state, (s1.below_poverty_line * 100.0 / s1.population) as pct_below_poverty_line FROM poverty s1; |
How many volunteers have participated in each program, in the last 12 months? | CREATE TABLE Volunteers (id INT,name VARCHAR(100),program_id INT,signup_date DATE); INSERT INTO Volunteers (id,name,program_id,signup_date) VALUES (1,'John Doe',1,'2020-06-01'); INSERT INTO Volunteers (id,name,program_id,signup_date) VALUES (2,'Jane Smith',2,'2021-03-15'); | SELECT program_id, COUNT(*) as total_volunteers FROM Volunteers WHERE signup_date >= DATE_SUB(CURRENT_DATE, INTERVAL 12 MONTH) GROUP BY program_id; |
What are the names and types of columns in the 'threat_intelligence' table? | CREATE TABLE threat_intelligence (id INT,name VARCHAR(255),ip_address VARCHAR(50),threat_level VARCHAR(10)); | SELECT * FROM information_schema.columns WHERE table_name = 'threat_intelligence'; |
Delete all records from the 'construction_equipment' table where the 'equipment_age' is greater than 10 | CREATE TABLE construction_equipment (equipment_id INT,equipment_name TEXT,equipment_age INT,equipment_status TEXT); | DELETE FROM construction_equipment WHERE equipment_age > 10; |
What is the total number of defense diplomacy events held in the Asia-Pacific region? | CREATE TABLE defense_diplomacy (region VARCHAR(255),event_count INT); | SELECT SUM(event_count) FROM defense_diplomacy WHERE region = 'Asia-Pacific'; |
List the military technologies used in Operation Desert Storm. | CREATE TABLE Military_Technologies (Name VARCHAR(255),Operation VARCHAR(255)); INSERT INTO Military_Technologies (Name,Operation) VALUES ('M1 Abrams','Operation Desert Storm'),('AH-64 Apache','Operation Desert Storm'),('M2 Bradley','Operation Desert Storm'); | SELECT Name FROM Military_Technologies WHERE Operation = 'Operation Desert Storm'; |
What is the average training program duration by department? | CREATE TABLE departments (id INT,name VARCHAR(255)); INSERT INTO departments (id,name) VALUES (1,'HR'),(2,'IT'),(3,'Sales'); CREATE TABLE training_programs (id INT,department_id INT,duration INT); INSERT INTO training_programs (id,department_id,duration) VALUES (1,1,20),(2,2,30),(3,3,15); | SELECT departments.name, AVG(training_programs.duration) as avg_duration FROM departments JOIN training_programs ON departments.id = training_programs.department_id GROUP BY departments.name; |
List the carbon offset programs in Canada and Australia that have a start date on or after 2015. | CREATE TABLE carbon_offset_programs (id INT,name TEXT,country TEXT,start_date DATE); INSERT INTO carbon_offset_programs (id,name,country,start_date) VALUES (1,'GreenEra','Canada','2016-01-01'); | SELECT name, country, start_date FROM carbon_offset_programs WHERE country IN ('Canada', 'Australia') AND start_date >= '2015-01-01'; |
What was the total amount of grants awarded to organizations in Asia in 2021? | CREATE TABLE grants (id INT,organization_id INT,country TEXT,grant_amount DECIMAL(10,2),grant_date DATE); INSERT INTO grants (id,organization_id,country,grant_amount,grant_date) VALUES (1,1,'India',10000.00,'2021-01-01'),(2,2,'China',20000.00,'2021-02-15'),(3,1,'India',15000.00,'2021-12-31'); | SELECT SUM(grant_amount) FROM grants WHERE country = 'Asia' AND grant_date >= '2021-01-01' AND grant_date <= '2021-12-31'; |
Calculate the average sentence length for inmates in each legal organization | CREATE TABLE inmates (inmate_id INT,inmate_name VARCHAR(255),org_id INT,sentence_length INT,PRIMARY KEY (inmate_id)); CREATE TABLE legal_organizations (org_id INT,org_name VARCHAR(255),PRIMARY KEY (org_id)); INSERT INTO inmates (inmate_id,inmate_name,org_id,sentence_length) VALUES (1,'Inmate 1',1,60),(2,'Inmate 2',1,36),(3,'Inmate 3',2,72),(4,'Inmate 4',3,48); INSERT INTO legal_organizations (org_id,org_name) VALUES (1,'Community Healing Center'),(2,'Justice for All'),(3,'New Leaf Foundation'); | SELECT o.org_name, AVG(i.sentence_length) FROM inmates i INNER JOIN legal_organizations o ON i.org_id = o.org_id GROUP BY o.org_name; |
What is the total amount donated by individuals in the "donors" table? | CREATE TABLE donors (donor_id INT,donor_name TEXT,donation_amount DECIMAL); INSERT INTO donors (donor_id,donor_name,donation_amount) VALUES (1,'John Doe',50.00),(2,'Jane Smith',100.00); | SELECT SUM(donation_amount) FROM donors WHERE donor_type = 'individual'; |
Insert a new case record into the 'cases' table | CREATE TABLE cases (case_number INT PRIMARY KEY,case_name VARCHAR(255),date_filed DATE,case_type VARCHAR(255),status VARCHAR(50),victim_id INT,defendant_id INT,program_id INT); | INSERT INTO cases (case_number, case_name, date_filed, case_type, status, victim_id, defendant_id, program_id) VALUES (2022002, 'USA v. Garcia', '2022-01-03', 'Misdemeanor', 'In Progress', 1005, 2006, 3006); |
Display the names and countries of excavation sites without artifacts | CREATE TABLE ExcavationSites (SiteID int,Name varchar(50),Country varchar(50),StartDate date); INSERT INTO ExcavationSites (SiteID,Name,Country,StartDate) VALUES (6,'Site F','France','2014-12-12'); CREATE TABLE Artifacts (ArtifactID int,SiteID int,Name varchar(50),Description text,DateFound date); | SELECT es.Name, es.Country FROM ExcavationSites es LEFT JOIN Artifacts a ON es.SiteID = a.SiteID WHERE a.ArtifactID IS NULL; |
How many customers from marginalized communities have purchased sustainable fashion items in the US? | CREATE TABLE customers (customer_id INT,name VARCHAR(50),community VARCHAR(50),country VARCHAR(50)); INSERT INTO customers (customer_id,name,community,country) VALUES (1,'Jamal Johnson','Black','US'),(2,'Maria Rodriguez','Latino','US'); CREATE TABLE products (product_id INT,name VARCHAR(50),sustainable BOOLEAN); INSERT INTO products (product_id,name,sustainable) VALUES (1,'Eco-Friendly Dress',TRUE); CREATE TABLE sales (sale_id INT,customer_id INT,product_id INT); INSERT INTO sales (sale_id,customer_id,product_id) VALUES (1,1,1); | SELECT COUNT(*) FROM sales s INNER JOIN customers c ON s.customer_id = c.customer_id INNER JOIN products p ON s.product_id = p.product_id WHERE c.country = 'US' AND p.name = 'Eco-Friendly Dress' AND c.community IN ('Black', 'Latino', 'Native American', 'Asian', 'Pacific Islander'); |
Create a table named 'Teachers' with columns 'TeacherID', 'Name', 'Subject' | CREATE TABLE Teachers (TeacherID INT,Name VARCHAR(100),Subject VARCHAR(50)); | CREATE TABLE Teachers (TeacherID INT, Name VARCHAR(100), Subject VARCHAR(50)); |
Which countries have marine protected areas deeper than 1000 meters? | CREATE TABLE country_protected_areas (country TEXT,protected_area TEXT,max_depth_m FLOAT); INSERT INTO country_protected_areas (country,protected_area,max_depth_m) VALUES ('Canada','Fathom Five National Marine Park',150.0),('USA','Channel Islands National Marine Sanctuary',1500.0),('Australia','Lord Howe Marine Park',1000.0); | SELECT country FROM country_protected_areas WHERE max_depth_m > 1000; |
How many users have commented on articles about climate change, excluding users who have commented more than 5 times? | CREATE TABLE articles (article_id INT,title TEXT,topic TEXT); INSERT INTO articles (article_id,title,topic) VALUES (1,'Climate Change Impact','climate change'),(2,'Climate Change Solutions','climate change'); CREATE TABLE user_comments (comment_id INT,article_id INT,user_id INT,comment TEXT); INSERT INTO user_comments (comment_id,article_id,user_id) VALUES (1,1,1),(2,2,2),(3,1,3),(4,2,3),(5,1,3),(6,2,4),(7,1,5); | SELECT COUNT(DISTINCT user_id) FROM user_comments JOIN articles ON user_comments.article_id = articles.article_id WHERE articles.topic = 'climate change' HAVING COUNT(user_comments.user_id) <= 5; |
Insert new records for a 'hydro' table: Canada, 10, operational | CREATE TABLE hydro (country VARCHAR(20),capacity INT,status VARCHAR(20)); | INSERT INTO hydro (country, capacity, status) VALUES ('Canada', 10, 'operational'); |
How many military innovations were made by Russia between 2010 and 2015? | CREATE TABLE MilitaryInnovations (id INT PRIMARY KEY,country VARCHAR(50),year INT,innovation VARCHAR(100)); INSERT INTO MilitaryInnovations (id,country,year,innovation) VALUES (2,'Russia',2012,'Stealth submarine'); | SELECT COUNT(*) FROM MilitaryInnovations WHERE country = 'Russia' AND year BETWEEN 2010 AND 2015; |
Return all flight safety records with a severity level of "High" for aircraft manufactured by Boeing from the flight_safety table | CREATE TABLE flight_safety (id INT PRIMARY KEY,aircraft_model VARCHAR(100),manufacturer VARCHAR(100),severity VARCHAR(50),report_date DATE); | SELECT * FROM flight_safety WHERE manufacturer = 'Boeing' AND severity = 'High'; |
How many hybrid vehicles were sold in Japan in 2020? | CREATE TABLE SalesData (Id INT,Country VARCHAR(50),Year INT,VehicleType VARCHAR(50),QuantitySold INT); INSERT INTO SalesData (Id,Country,Year,VehicleType,QuantitySold) VALUES (1,'Japan',2018,'Hybrid',250000),(2,'Japan',2020,'Hybrid',400000),(3,'Japan',2019,'Hybrid',300000),(4,'Japan',2021,'Hybrid',500000); | SELECT SUM(QuantitySold) FROM SalesData WHERE Country = 'Japan' AND VehicleType = 'Hybrid' AND Year = 2020; |
Which AI conferences have been held in Canada? | CREATE TABLE ai_conferences(id INT PRIMARY KEY,name VARCHAR(50),location VARCHAR(50)); INSERT INTO ai_conferences (id,name,location) VALUES (1,'NeurIPS','USA'),(2,'ICML','Canada'),(3,'AAAI','Australia'); | SELECT * FROM ai_conferences WHERE location = 'Canada'; |
What is the total budget for rural infrastructure projects in 'Bridgetown'? | CREATE TABLE rural_infrastructure (id INT,project_name VARCHAR(50),location VARCHAR(50),budget DECIMAL(10,2)); INSERT INTO rural_infrastructure (id,project_name,location,budget) VALUES (1,'Bridge A','Bridgetown',50000.00); INSERT INTO rural_infrastructure (id,project_name,location,budget) VALUES (2,'Bridge B','Bridgetown',75000.00); | SELECT SUM(budget) FROM rural_infrastructure WHERE location = 'Bridgetown'; |
What is the number of organizations that support more than 1000 people? | CREATE TABLE refugee_support.organizations (id INT,name VARCHAR(50),people_supported INT); | SELECT COUNT(*) FROM refugee_support.organizations WHERE people_supported > 1000; |
What is the average number of military personnel in defense diplomacy operations by country, for countries with more than 150 personnel? | CREATE TABLE CountryDefenseDiplomacyOperations (id INT,country VARCHAR(50),military_personnel INT); | SELECT country, AVG(military_personnel) FROM CountryDefenseDiplomacyOperations GROUP BY country HAVING COUNT(*) > 150; |
What is the average depth of all marine protected areas in the Atlantic Ocean, ranked by depth? | CREATE TABLE atlantic_protected_areas (id INT,name VARCHAR(255),depth FLOAT,area_size FLOAT); INSERT INTO atlantic_protected_areas (id,name,depth,area_size) VALUES (1,'Azores',1500,97810); | SELECT depth, name FROM (SELECT depth, name, ROW_NUMBER() OVER (ORDER BY depth DESC) AS rn FROM atlantic_protected_areas) t WHERE rn = 1; |
What is the total capacity of all vessels in the 'vessels' table? | CREATE TABLE vessels (vessel_id INT,name VARCHAR(50),type VARCHAR(50),capacity INT); INSERT INTO vessels (vessel_id,name,type,capacity) VALUES (1,'MV Ocean Wave','Container Ship',12000),(2,'MS Ocean Breeze','Tanker',8000); | SELECT SUM(capacity) FROM vessels; |
How many citizen feedback records were received for each public service in the state of California in the last month? | CREATE TABLE feedback (service VARCHAR(255),date DATE); INSERT INTO feedback (service,date) VALUES ('education','2023-01-01'),('education','2023-01-15'),('healthcare','2023-02-01'),('transportation','2023-03-01'); | SELECT service, COUNT(*) FROM feedback WHERE date >= DATEADD(month, -1, GETDATE()) GROUP BY service; |
What is the total amount of scandium exported to Europe in the last 3 years? | CREATE TABLE exports (id INT,element TEXT,location TEXT,date DATE,quantity INT); INSERT INTO exports (id,element,location,date,quantity) VALUES (1,'scandium','Europe','2019-01-01',500),(2,'scandium','Europe','2020-01-01',600); | SELECT SUM(quantity) FROM exports WHERE element = 'scandium' AND location = 'Europe' AND extract(year from date) >= 2019; |
Calculate the total claim amount for policyholder 1003 for the year 2021. | CREATE TABLE Claims (id INT,policyholder_id INT,claim_amount DECIMAL(10,2),claim_date DATE); INSERT INTO Claims (id,policyholder_id,claim_amount,claim_date) VALUES (3,1003,7000.00,'2021-03-20'); INSERT INTO Claims (id,policyholder_id,claim_amount,claim_date) VALUES (4,1003,2000.00,'2021-08-12'); | SELECT policyholder_id, SUM(claim_amount) FROM Claims WHERE policyholder_id = 1003 AND claim_date BETWEEN '2021-01-01' AND '2021-12-31' GROUP BY policyholder_id; |
How many healthcare facilities are there in each district? | CREATE TABLE Healthcare (District VARCHAR(255),FacilityType VARCHAR(255),Quantity INT); INSERT INTO Healthcare (District,FacilityType,Quantity) VALUES ('DistrictA','Hospital',2),('DistrictA','Clinic',5),('DistrictB','Hospital',3),('DistrictB','Clinic',4); | SELECT District, FacilityType, SUM(Quantity) FROM Healthcare GROUP BY District, FacilityType; |
Find the top 10 customers by the total balance in their Shariah-compliant accounts. | CREATE TABLE shariah_accounts (customer_id INT,account_type VARCHAR(20),balance DECIMAL(10,2)); | SELECT customer_id, SUM(balance) FROM shariah_accounts WHERE account_type = 'Shariah-compliant' GROUP BY customer_id ORDER BY SUM(balance) DESC FETCH FIRST 10 ROWS ONLY; |
What is the average revenue per day for a specific restaurant? | CREATE TABLE daily_revenue (restaurant_id INT,revenue FLOAT,date DATE); INSERT INTO daily_revenue (restaurant_id,revenue,date) VALUES (1,5000.00,'2022-01-01'),(1,6000.00,'2022-01-02'),(1,4000.00,'2022-01-03'); | SELECT AVG(revenue) as avg_daily_revenue FROM daily_revenue WHERE restaurant_id = 1; |
What is the average budget for all infrastructure projects in 'Paris'? | CREATE TABLE InfrastructureC(id INT,city VARCHAR(20),project VARCHAR(30),budget DECIMAL(10,2)); INSERT INTO InfrastructureC(id,city,project,budget) VALUES (1,'Paris','Storm Drainage',750000.00),(2,'Berlin','Sewer System',1000000.00); | SELECT AVG(budget) FROM InfrastructureC WHERE city = 'Paris'; |
Create a table named 'farmers' | CREATE TABLE farmers (id INT PRIMARY KEY,name VARCHAR(100),age INT,gender VARCHAR(10),location VARCHAR(50)); | CREATE TABLE farmers (id INT PRIMARY KEY, name VARCHAR(100), age INT, gender VARCHAR(10), location VARCHAR(50)); |
Display the names and salaries of employees who were hired before 2020, ordered by salary. | CREATE TABLE Employees (EmployeeID INT,Name VARCHAR(50),Salary DECIMAL(10,2),HireDate DATE); INSERT INTO Employees (EmployeeID,Name,Salary,HireDate) VALUES (1,'John Doe',50000,'2018-01-01'),(2,'Jane Smith',55000,'2020-03-15'),(3,'Mike Johnson',60000,'2019-08-25'),(4,'Sara Doe',45000,'2019-11-04'); | SELECT Name, Salary FROM Employees WHERE YEAR(HireDate) < 2020 ORDER BY Salary; |
Update the salary of all employees hired in the North America region in 2021 to 55000. | CREATE TABLE employees (id INT,first_name VARCHAR(50),last_name VARCHAR(50),hire_date DATE,salary INT,country VARCHAR(50)); | UPDATE employees SET salary = 55000 WHERE hire_date >= '2021-01-01' AND hire_date < '2022-01-01' AND country IN (SELECT region FROM regions WHERE region_name = 'North America'); |
What's the average age of players who play action games? | CREATE TABLE player_demographics (player_id INT,age INT,favorite_genre VARCHAR(20)); INSERT INTO player_demographics (player_id,age,favorite_genre) VALUES (1,25,'Action'),(2,30,'RPG'),(3,22,'Action'),(4,35,'Simulation'); | SELECT AVG(age) FROM player_demographics WHERE favorite_genre = 'Action'; |
What is the total number of participants in disability support programs by country? | CREATE TABLE DisabilitySupportPrograms (ProgramID int,ProgramName varchar(50),Country varchar(50)); INSERT INTO DisabilitySupportPrograms (ProgramID,ProgramName,Country) VALUES (1,'Assistive Technology','USA'),(2,'Sign Language Interpretation','Canada'),(3,'Mental Health Services','Australia'),(4,'Physical Therapy','UK'),(5,'Speech Therapy','India'),(6,'Accessible Transportation','Germany'),(7,'Inclusive Education','Brazil'); | SELECT Country, COUNT(*) as TotalParticipants FROM DisabilitySupportPrograms GROUP BY Country; |
Show the total savings of customers who have a socially responsible loan in a specific region | CREATE TABLE customers (customer_id INT,region VARCHAR(255),savings DECIMAL(10,2),has_socially_responsible_loan BOOLEAN); | SELECT SUM(savings) FROM customers WHERE region = 'Asia' AND has_socially_responsible_loan = TRUE; |
What was the average daily fare collection for the 'Red Line' in June 2021? | CREATE SCHEMA trans schemas.trans; CREATE TABLE red_line (route_id INT,fare FLOAT,date DATE); INSERT INTO red_line (route_id,fare,date) VALUES (101,2.50,'2021-06-01'),(101,2.50,'2021-06-02'),(101,2.50,'2021-06-03'),(101,2.50,'2021-06-04'),(101,2.50,'2021-06-05'),(101,2.50,'2021-06-06'),(101,2.50,'2021-06-07'),(101,2.50,'2021-06-08'),(101,2.50,'2021-06-09'),(101,2.50,'2021-06-10'); | SELECT AVG(fare) FROM red_line WHERE route_id = 101 AND EXTRACT(MONTH FROM date) = 6; |
What is the average medical data record frequency for each astronaut during space missions? | CREATE TABLE Astronauts (id INT,name TEXT); CREATE TABLE MedicalData (id INT,astronaut_id INT,timestamp TIMESTAMP); CREATE TABLE SpaceMissions (id INT,astronaut_id INT,mission TEXT,start_date DATE,end_date DATE); | SELECT a.name, AVG(DATEDIFF('second', m.start_date, m.end_date) / COUNT(*)) FROM Astronauts a JOIN MedicalData m ON a.id = m.astronaut_id JOIN SpaceMissions s ON a.id = s.astronaut_id GROUP BY a.name; |
What is the average number of healthcare workers per hospital in each state? | CREATE TABLE hospitals (id INT,name TEXT,state TEXT,workers INT); INSERT INTO hospitals (id,name,state,workers) VALUES (1,'Hospital A','NY',50),(2,'Hospital B','NY',75),(3,'Hospital C','FL',60),(4,'Hospital D','FL',80),(5,'Hospital E','CA',65),(6,'Hospital F','CA',70); | SELECT state, AVG(workers) FROM hospitals GROUP BY state; |
What is the percentage of unvaccinated children in each state? | CREATE TABLE states (state_id INT,state_name TEXT,unvaccinated_children INT); INSERT INTO states (state_id,state_name,unvaccinated_children) VALUES (1,'California',2500),(2,'Texas',3000),(3,'New York',1800); | SELECT state_name, (unvaccinated_children::float/SUM(unvaccinated_children) OVER ()) * 100 AS percentage FROM states; |
What is the total weight of fair trade coffee beans imported to Australia? | CREATE TABLE imports (id INT,product TEXT,weight FLOAT,is_fair_trade BOOLEAN,country TEXT); INSERT INTO imports (id,product,weight,is_fair_trade,country) VALUES (1,'Coffee Beans',150.0,true,'Australia'); INSERT INTO imports (id,product,weight,is_fair_trade,country) VALUES (2,'Coffee Beans',200.0,false,'Australia'); | SELECT SUM(weight) FROM imports WHERE product = 'Coffee Beans' AND is_fair_trade = true AND country = 'Australia'; |
What is the average donation amount for donors in each region? | CREATE TABLE donors (donor_id INT,donor_name VARCHAR(50),region VARCHAR(20)); INSERT INTO donors (donor_id,donor_name,region) VALUES (1,'John Doe','North'),(2,'Jane Smith','South'),(3,'Alice Johnson','East'),(4,'Bob Brown','North'),(5,'Charlie Davis','West'); CREATE TABLE donations (donor_id INT,donation_amount DECIMAL(10,2)); INSERT INTO donations (donor_id,donation_amount) VALUES (1,50000.00),(2,75000.00),(3,60000.00),(4,45000.00),(5,30000.00); | SELECT AVG(donation_amount) AS avg_donation, region FROM donations d JOIN donors don ON d.donor_id = don.donor_id GROUP BY region; |
What is the number of tuberculosis cases for each country in the tuberculosis_cases table? | CREATE TABLE tuberculosis_cases (country TEXT,num_cases INT); INSERT INTO tuberculosis_cases (country,num_cases) VALUES ('India',2500000),('Indonesia',1000000),('China',850000),('Philippines',600000),('Pakistan',500000); | SELECT country, num_cases FROM tuberculosis_cases; |
Calculate the average daily balance for each customer in Q3 2021. | CREATE TABLE accounts (id INT,customer_id INT,balance DECIMAL(10,2),transaction_date DATE); | SELECT customer_id, AVG(balance) as avg_balance FROM accounts WHERE transaction_date >= '2021-07-01' AND transaction_date < '2021-10-01' GROUP BY customer_id, DATEADD(day, DATEDIFF(day, 0, transaction_date), 0) ORDER BY customer_id; |
What is the average cost of accommodations per student in the AssistiveTechnology table? | CREATE TABLE AssistiveTechnology (studentID INT,accommodationType VARCHAR(50),cost DECIMAL(5,2)); | SELECT AVG(cost) FROM AssistiveTechnology; |
Update the age of the player with PlayerID 1 to 26. | CREATE TABLE Players (PlayerID INT,Age INT,Gender VARCHAR(10)); INSERT INTO Players VALUES (1,25,'Male'),(2,30,'Female'),(3,35,'Non-binary'); | UPDATE Players SET Age = 26 WHERE PlayerID = 1; |
Find the number of vessels in the 'vessel_registry' table that were built after 2015 | CREATE TABLE vessel_registry (id INT,vessel_name VARCHAR(50),build_date DATE); | SELECT COUNT(*) FROM vessel_registry WHERE YEAR(build_date) > 2015; |
What is the survival rate of seabass and mussels by country, and which countries have the lowest survival rates for these species over a specific time period? | CREATE TABLE Survival (Country VARCHAR(20),Species VARCHAR(20),SurvivalRate FLOAT,TimePeriod INT); INSERT INTO Survival (Country,Species,SurvivalRate,TimePeriod) VALUES ('Norway','Seabass',0.85,2),('Norway','Mussels',0.92,2),('Spain','Seabass',0.88,3),('Spain','Mussels',0.90,3),('Japan','Seabass',0.90,1),('Japan','Mussels',0.95,1); | SELECT Country, Species, SurvivalRate, TimePeriod FROM Survival WHERE Species IN ('Seabass', 'Mussels') AND SurvivalRate = (SELECT MIN(SurvivalRate) FROM Survival WHERE Species IN ('Seabass', 'Mussels') AND TimePeriod = Survival.TimePeriod) ORDER BY TimePeriod; |
What is the average age of vessels launched in 2017 in the fleet_management table? | CREATE TABLE fleet_management (vessel_id INT,vessel_name VARCHAR(50),launch_date DATE); INSERT INTO fleet_management (vessel_id,vessel_name,launch_date) VALUES (1,'Vessel_A','2015-01-01'),(2,'Vessel_B','2016-01-01'),(3,'Vessel_C','2017-01-01'),(4,'Vessel_D','2017-01-02'); | SELECT AVG(DATEDIFF(CURDATE(), launch_date) / 365.25) FROM fleet_management WHERE YEAR(launch_date) = 2017; |
What is the highest number of touchdowns scored by the 'Seattle Seahawks' in a single game in the 'NFL'? | CREATE TABLE teams (team_id INT,team_name TEXT,league TEXT,sport TEXT); INSERT INTO teams (team_id,team_name,league,sport) VALUES (1,'Seattle Seahawks','NFL','American Football'); CREATE TABLE games (game_id INT,team_id INT,touchdowns INT,season_year INT); INSERT INTO games (game_id,team_id,touchdowns,season_year) VALUES (1,1,5,2020),(2,1,4,2020),(3,1,6,2019); | SELECT MAX(touchdowns) FROM games WHERE team_id = (SELECT team_id FROM teams WHERE team_name = 'Seattle Seahawks') AND league = 'NFL'; |
Show the number of climate-related grants and their total value awarded to each African country from 2015 to 2020? | CREATE TABLE grants (country VARCHAR(50),year INT,grant_amount INT,grant_type VARCHAR(20)); INSERT INTO grants (country,year,grant_amount,grant_type) VALUES ('Kenya',2015,50000,'climate'),('Kenya',2016,55000,'climate'),('Nigeria',2015,60000,'climate'),('Nigeria',2016,65000,'climate'),('Egypt',2015,40000,'climate'),('Egypt',2016,45000,'climate'); | SELECT country, COUNT(grant_amount) as num_grants, SUM(grant_amount) as total_grant_value FROM grants WHERE country IN ('Kenya', 'Nigeria', 'Egypt') AND grant_type = 'climate' AND year BETWEEN 2015 AND 2020 GROUP BY country; |
What is the average water requirement for crops grown in each province in India? | CREATE TABLE irrigation (id INT,farm_id INT,irrigation_amount INT); INSERT INTO irrigation (id,farm_id,irrigation_amount) VALUES (1,1,1000),(2,2,1500); | SELECT provinces.name, AVG(crops.water_requirement) FROM crops JOIN (SELECT farm_id FROM farms WHERE provinces.name = provinces.name) as subquery ON crops.id = subquery.farm_id JOIN irrigation ON crops.id = irrigation.farm_id JOIN provinces ON farms.id = provinces.id GROUP BY provinces.name; |
What is the total runtime of all movies produced by a specific studio? | CREATE TABLE movies (movie_id INT,movie_title VARCHAR(100),release_year INT,studio VARCHAR(50),runtime INT); INSERT INTO movies (movie_id,movie_title,release_year,studio,runtime) VALUES (1,'Gladiator',2000,'DreamWorks Pictures',155); | SELECT studio, SUM(runtime) as total_runtime FROM movies WHERE studio = 'DreamWorks Pictures' GROUP BY studio; |
What is the minimum budget allocated for disability accommodations in each department in a specific university? | CREATE TABLE Universities (UniversityID INT PRIMARY KEY,UniversityName VARCHAR(50),UniversityLocation VARCHAR(50)); CREATE TABLE Departments (DepartmentID INT PRIMARY KEY,DepartmentName VARCHAR(50),BudgetForDisabilityAccommodations DECIMAL(10,2)); CREATE TABLE UniversityDepartments (UniversityDepartmentID INT PRIMARY KEY,UniversityID INT,DepartmentID INT,FOREIGN KEY (UniversityID) REFERENCES Universities(UniversityID),FOREIGN KEY (DepartmentID) REFERENCES Departments(DepartmentID)); | SELECT d.DepartmentName, MIN(ud.BudgetForDisabilityAccommodations) as MinBudget FROM Departments d JOIN UniversityDepartments ud ON d.DepartmentID = ud.DepartmentID JOIN Universities u ON ud.UniversityID = u.UniversityID WHERE u.UniversityName = 'University of Toronto' GROUP BY d.DepartmentName; |
Delete funding records older than 2021 for "GreenTech Solutions" | CREATE TABLE funding (id INT PRIMARY KEY AUTO_INCREMENT,company_id INT,amount FLOAT,funding_date DATE); | DELETE FROM funding WHERE funding_date < '2021-01-01' AND company_id IN (SELECT id FROM company WHERE name = 'GreenTech Solutions'); |
Display the number of peacekeeping operations by country | CREATE TABLE peacekeeping_operations (id INT PRIMARY KEY,name VARCHAR(255),location VARCHAR(255),start_date DATE,end_date DATE); | SELECT location, COUNT(*) FROM peacekeeping_operations GROUP BY location; |
What is the total budget for successful community development initiatives in the 'community_development' table? | CREATE TABLE community_development (id INT,initiative VARCHAR(50),budget FLOAT,status VARCHAR(20)); | SELECT SUM(budget) FROM community_development WHERE status = 'successful'; |
Calculate the total revenue of sustainable fabric sales in the US | CREATE TABLE sales (id INT,garment_id INT,price DECIMAL(5,2),country VARCHAR(255)); CREATE TABLE garments (id INT,garment_type VARCHAR(255),material VARCHAR(255),sustainable BOOLEAN); | SELECT SUM(sales.price) FROM sales JOIN garments ON sales.garment_id = garments.id WHERE garments.sustainable = TRUE AND sales.country = 'United States'; |
What is the average number of days between permit issuance and project completion, for sustainable building projects in each state, ordered from shortest to longest? | CREATE TABLE ProjectTimeline (Project VARCHAR(50),PermitIssueDate DATE,ProjectCompletionDate DATE,SustainableBuilding INT); | SELECT State, AVG(DATEDIFF(ProjectCompletionDate, PermitIssueDate)) as AvgDays FROM ProjectTimeline WHERE SustainableBuilding = 1 GROUP BY State ORDER BY AvgDays; |
What is the average water temperature in the Pacific Ocean for fish species with a maximum size over 200 cm? | CREATE TABLE oceans (id INT,name VARCHAR(50)); CREATE TABLE species (id INT,ocean_id INT,name VARCHAR(50),max_size FLOAT,avg_temp FLOAT); INSERT INTO oceans VALUES (1,'Pacific Ocean'); INSERT INTO species VALUES (1,1,'Whale Shark',1200,22),(2,1,'Basking Shark',1000,18),(3,1,'Swordfish',450,28); | SELECT AVG(s.avg_temp) as avg_temp FROM species s INNER JOIN oceans o ON s.ocean_id = o.id WHERE o.name = 'Pacific Ocean' AND s.max_size > 200; |
Update marine species records in 'Europe' from 2015 to 'Dolphin'. | CREATE TABLE Species_5 (id INT,name VARCHAR(255),region VARCHAR(255),year INT); INSERT INTO Species_5 (id,name,region,year) VALUES (1,'Shark','Europe',2015); INSERT INTO Species_5 (id,name,region,year) VALUES (2,'Whale','Europe',2016); INSERT INTO Species_5 (id,name,region,year) VALUES (3,'Turtle','Europe',2017); INSERT INTO Species_5 (id,name,region,year) VALUES (4,'Squid','Europe',2018); | UPDATE Species_5 SET name = 'Dolphin' WHERE region = 'Europe' AND year IN (2015, 2016, 2017, 2018); |
How many farmers are involved in each community development initiative? | CREATE TABLE community_initiatives (initiative VARCHAR(50),farmer_count INT); INSERT INTO community_initiatives (initiative,farmer_count) VALUES ('Clean Water Access',350),('Renewable Energy',200),('Education',400); | SELECT initiative, farmer_count FROM community_initiatives; |
List all waste types and their descriptions | CREATE TABLE WasteTypes (waste_type_id INT PRIMARY KEY,name VARCHAR,description VARCHAR); | SELECT name, description FROM WasteTypes; |
What is the total construction cost for bridges in California? | CREATE TABLE Bridge (bridge_id INT,state VARCHAR(20),construction_cost DECIMAL(10,2)); INSERT INTO Bridge (bridge_id,state,construction_cost) VALUES (1,'California',1500000.00),(2,'Texas',2000000.00); | SELECT SUM(construction_cost) FROM Bridge WHERE state = 'California'; |
Count the number of healthcare providers in each state in the rural healthcare system. | CREATE TABLE Providers (ID INT,Name TEXT,State TEXT,Type TEXT); INSERT INTO Providers VALUES (1,'Dr. Smith','KY','Doctor'); INSERT INTO Providers VALUES (2,'Jane Doe,RN','WV','Nurse'); INSERT INTO Providers VALUES (3,'Mobile Medical Unit','KY','Clinic'); | SELECT State, COUNT(*) AS Total FROM Providers GROUP BY State; |
Determine the number of road maintenance activities performed in Texas | CREATE TABLE Infrastructure (id INT,name VARCHAR(255),type VARCHAR(255),location VARCHAR(255)); CREATE TABLE Maintenance (id INT,infrastructure_id INT,maintenance_date DATE,maintenance_type VARCHAR(255)); INSERT INTO Infrastructure (id,name,type,location) VALUES (1,'Road A','Road','Texas'); INSERT INTO Infrastructure (id,name,type,location) VALUES (2,'Bridge B','Bridge','California'); INSERT INTO Maintenance (id,infrastructure_id,maintenance_date,maintenance_type) VALUES (1,1,'2022-01-01','Road Maintenance'); INSERT INTO Maintenance (id,infrastructure_id,maintenance_date,maintenance_type) VALUES (2,1,'2022-02-01','Inspection'); | SELECT COUNT(*) FROM Maintenance WHERE maintenance_type = 'Road Maintenance' AND infrastructure_id IN (SELECT id FROM Infrastructure WHERE location = 'Texas' AND type = 'Road'); |
What is the minimum budget for any project related to social services in the state of Texas in the year 2022? | CREATE TABLE SocialServicesProjects (ProjectID INT,Name VARCHAR(100),Budget DECIMAL(10,2),Year INT,State VARCHAR(50)); INSERT INTO SocialServicesProjects (ProjectID,Name,Budget,Year,State) VALUES (1,'Homeless Shelter',2000000,2022,'Texas'),(2,'Food Assistance Program',500000,2022,'Texas'),(3,'Job Training Center',800000,2021,'California'); | SELECT MIN(Budget) FROM SocialServicesProjects WHERE Year = 2022 AND State = 'Texas' AND Name LIKE '%social services%'; |
Identify the top 3 countries with the highest increase in international visitor expenditure between 2018 and 2022 that have implemented sustainable tourism practices. | CREATE TABLE tourism_spending_ext (id INT,country VARCHAR(50),year INT,international_visitors INT,total_expenditure FLOAT,sustainability_practice BOOLEAN); INSERT INTO tourism_spending_ext (id,country,year,international_visitors,total_expenditure,sustainability_practice) VALUES (1,'Canada',2018,21000000,22000000000,true); | SELECT t1.country, (t1.total_expenditure - t2.total_expenditure) as expenditure_increase FROM tourism_spending_ext t1 JOIN tourism_spending_ext t2 ON t1.country = t2.country AND t1.year = 2022 AND t2.year = 2018 WHERE t1.sustainability_practice = true GROUP BY t1.country ORDER BY expenditure_increase DESC LIMIT 3; |
Insert records for three new tree species into the tree_species table | CREATE TABLE tree_species (id INT,name VARCHAR(50),avg_carbon_seq_rate FLOAT); | INSERT INTO tree_species (id, name, avg_carbon_seq_rate) VALUES (1, 'Cherry', 26.3), (2, 'Mahogany', 31.5), (3, 'Walnut', 29.7); |
Delete recycling rate records for the 'Rural' region in the year 2021. | CREATE TABLE recycling_rates(region VARCHAR(20),year INT,recycling_rate FLOAT); INSERT INTO recycling_rates(region,year,recycling_rate) VALUES('Urban',2021,35.5),('Urban',2022,37.3),('Urban',2023,0),('Rural',2021,28.2),('Rural',2022,30.1); | DELETE FROM recycling_rates WHERE region = 'Rural' AND year = 2021; |
Identify the top 3 garment manufacturing locations with the highest total sales volume and their corresponding sustainability scores. | CREATE TABLE manufacturers (id INT PRIMARY KEY,name VARCHAR(255),location VARCHAR(255),sustainability_score INT); INSERT INTO manufacturers (id,name,location,sustainability_score) VALUES (1,'Manufacturer A','Location A',85); INSERT INTO manufacturers (id,name,location,sustainability_score) VALUES (2,'Manufacturer B','Location B',90); CREATE TABLE retailers (id INT PRIMARY KEY,name VARCHAR(255),location VARCHAR(255),sales_volume INT); INSERT INTO retailers (id,name,location,sales_volume) VALUES (1,'Retailer A','Location A',500); INSERT INTO retailers (id,name,location,sales_volume) VALUES (2,'Retailer B','Location B',700); | SELECT r.location, SUM(r.sales_volume) AS total_sales_volume, m.sustainability_score FROM retailers r INNER JOIN manufacturers m ON r.location = m.location GROUP BY r.location, m.sustainability_score ORDER BY total_sales_volume DESC LIMIT 3; |
Show production figures for wells in the Gulf of Mexico. | CREATE TABLE wells (well_id INT,country VARCHAR(50),production FLOAT); INSERT INTO wells (well_id,country,production) VALUES (1,'USA - Gulf of Mexico',1000),(2,'Canada',1500),(3,'Norway',800); | SELECT production FROM wells WHERE country LIKE '%Gulf of Mexico%'; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.