instruction stringlengths 0 1.06k | input stringlengths 11 5.3k | response stringlengths 2 4.44k |
|---|---|---|
What is the minimum budget for a single climate finance project in Asia? | CREATE TABLE climate_finance_projects (project_id INT,project_name VARCHAR(255),location VARCHAR(255),budget DECIMAL(10,2)); INSERT INTO climate_finance_projects (project_id,project_name,location,budget) VALUES (1,'Renewable Energy in India','India',2000000.00),(2,'Energy Efficiency in China','China',3000000.00),(3,'Climate Resilience in Indonesia','Indonesia',1000000.00); | SELECT MIN(budget) FROM climate_finance_projects WHERE location = 'Asia'; |
Count the number of vehicles in the 'ElectricVehicleAdoption' table for each MPG range (0-50, 51-100, 101-150, 151-200). | CREATE TABLE ElectricVehicleAdoption (Vehicle VARCHAR(255),MPG INT); INSERT INTO ElectricVehicleAdoption (Vehicle,MPG) VALUES ('TeslaModel3',120),('TeslaModelS',105),('NissanLeaf',115),('ChevroletBolt',128),('RivianR1T',65),('AudiETron',75); | SELECT (CASE WHEN MPG BETWEEN 0 AND 50 THEN '0-50' WHEN MPG BETWEEN 51 AND 100 THEN '51-100' WHEN MPG BETWEEN 101 AND 150 THEN '101-150' ELSE '151-200' END) as MPGRange, COUNT(*) as VehicleCount FROM ElectricVehicleAdoption GROUP BY MPGRange; |
Add a new record to the 'football_stadiums' table for a stadium with a capacity of 70000 located in 'Los Angeles', 'USA' | CREATE TABLE football_stadiums (stadium_id INT,stadium_name VARCHAR(50),capacity INT,city VARCHAR(50),country VARCHAR(50)); | INSERT INTO football_stadiums (stadium_id, stadium_name, capacity, city, country) VALUES (1, 'Los Angeles Stadium', 70000, 'Los Angeles', 'USA'); |
Which movies were released in the US between 2015-2017 and received a user rating higher than 3.5? | CREATE TABLE movies (id INT,title TEXT,release_year INT,country TEXT,user_rating DECIMAL(3,2)); | SELECT title FROM movies WHERE release_year BETWEEN 2015 AND 2017 AND country = 'USA' AND user_rating > 3.5; |
List all co-owned properties in cities with sustainable urbanism policies | CREATE TABLE properties (id INT,city VARCHAR(50),coowners INT,sustainable_urbanism BOOLEAN); INSERT INTO properties VALUES (1,'NYC',2,TRUE); INSERT INTO properties VALUES (2,'NYC',1,FALSE); INSERT INTO properties VALUES (3,'LA',3,TRUE); INSERT INTO properties VALUES (4,'LA',1,FALSE); INSERT INTO properties VALUES (5,'Chicago',1,TRUE); | SELECT city FROM properties WHERE coowners > 1 AND sustainable_urbanism = TRUE; |
List all drugs approved by the EMA in 2020 | CREATE TABLE drug_approval(drug_name TEXT,approval_date DATE,approval_agency TEXT); INSERT INTO drug_approval(drug_name,approval_date,approval_agency) VALUES('DrugC','2020-06-06','EMA'); | SELECT drug_name FROM drug_approval WHERE approval_agency = 'EMA' AND approval_date BETWEEN '2020-01-01' AND '2020-12-31'; |
Find the total number of games played by each team in the 'nba_games' table. | CREATE TABLE nba_teams (team_id INT,team_name VARCHAR(255)); INSERT INTO nba_teams (team_id,team_name) VALUES (1,'Atlanta Hawks'),(2,'Boston Celtics'); CREATE TABLE nba_games (game_id INT,home_team_id INT,away_team_id INT); | SELECT home_team_id AS team_id, COUNT(*) AS total_games FROM nba_games GROUP BY home_team_id UNION ALL SELECT away_team_id, COUNT(*) FROM nba_games GROUP BY away_team_id; |
What is the total number of fish added to the Shrimp farm in 2021? | CREATE TABLE FarmStock (farm_id INT,date DATE,action VARCHAR(10),quantity INT); INSERT INTO FarmStock (farm_id,date,action,quantity) VALUES (3,'2021-01-01','added',300),(3,'2021-01-05','added',250); | SELECT SUM(quantity) total_fish FROM FarmStock WHERE farm_id = 3 AND YEAR(date) = 2021 AND action = 'added'; |
How many volunteers signed up for each program in 2021? | CREATE TABLE volunteer_signups (id INT,volunteer_id INT,program_id INT,signup_date DATE); INSERT INTO volunteer_signups (id,volunteer_id,program_id,signup_date) VALUES (1,201,1001,'2021-01-01'),(2,202,1002,'2021-02-01'),(3,203,1001,'2021-03-01'); CREATE TABLE programs (id INT,name VARCHAR); INSERT INTO programs (id,name) VALUES (1001,'Education'),(1002,'Environment'); CREATE TABLE volunteers (id INT,name VARCHAR); INSERT INTO volunteers (id,name) VALUES (201,'Alice Johnson'),(202,'Bob Brown'),(203,'Charlie Green'); | SELECT p.name as program_name, COUNT(vs.program_id) as num_volunteers FROM volunteer_signups vs JOIN programs p ON vs.program_id = p.id WHERE YEAR(vs.signup_date) = 2021 GROUP BY vs.program_id; |
What is the sum of orders placed with ethical fashion brands in Africa? | CREATE TABLE orders (id INT,brand VARCHAR(20),region VARCHAR(20),order_amount DECIMAL(5,2)); INSERT INTO orders (id,brand,region,order_amount) VALUES (1,'Brand A','Africa',150.99),(2,'Brand B','Europe',204.55),(3,'Brand A','Africa',125.44); | SELECT SUM(order_amount) FROM orders WHERE brand IN ('Brand A', 'Brand C') AND region = 'Africa'; |
Delete all records related to water consumption in the residential sector for the year 2019. | CREATE TABLE industrial_sectors (id INT,sector VARCHAR(255)); INSERT INTO industrial_sectors (id,sector) VALUES (1,'Manufacturing'),(2,'Mining'),(3,'Construction'),(4,'Residential'); CREATE TABLE water_consumption (year INT,sector_id INT,consumption INT); INSERT INTO water_consumption (year,sector_id,consumption) VALUES (2019,4,8000),(2020,4,9000); | DELETE FROM water_consumption WHERE sector_id = (SELECT id FROM industrial_sectors WHERE sector = 'Residential') AND year = 2019; |
List all cases with a 'Settled' outcome, their corresponding attorney's name, and the client's region. | CREATE TABLE Cases (CaseID INT,ClientID INT,Outcome TEXT); CREATE TABLE CaseAttorneys (CaseID INT,AttorneyID INT); CREATE TABLE Attorneys (AttorneyID INT,Name TEXT); CREATE TABLE Clients (ClientID INT,Region TEXT); INSERT INTO Cases (CaseID,ClientID,Outcome) VALUES (1,1,'Settled'); INSERT INTO CaseAttorneys (CaseID,AttorneyID) VALUES (1,1); INSERT INTO Attorneys (AttorneyID,Name) VALUES (1,'Liam Smith'); INSERT INTO Clients (ClientID,Region) VALUES (1,'Northeast'); | SELECT Clients.Region, Attorneys.Name, Cases.Outcome FROM Cases INNER JOIN CaseAttorneys ON Cases.CaseID = CaseAttorneys.CaseID INNER JOIN Attorneys ON CaseAttorneys.AttorneyID = Attorneys.AttorneyID INNER JOIN Clients ON Cases.ClientID = Clients.ClientID WHERE Cases.Outcome = 'Settled'; |
What is the name and location of the refugee camp with the highest population? | CREATE TABLE camp (camp_id INT,name VARCHAR(50),location VARCHAR(50),population INT); INSERT INTO camp (camp_id,name,location,population) VALUES (1,'Camp A','City A',500),(2,'Camp B','City B',700),(3,'Camp C','City C',300); | SELECT name, location FROM camp ORDER BY population DESC LIMIT 1; |
What is the total number of military personnel in the 'army' branch? | CREATE TABLE military_personnel (id INT,name VARCHAR(50),branch VARCHAR(20),rank VARCHAR(20),country VARCHAR(50)); INSERT INTO military_personnel (id,name,branch,rank,country) VALUES (1,'John Doe','army','Colonel','USA'); | SELECT COUNT(*) FROM military_personnel WHERE branch = 'army'; |
What is the minimum temperature ever recorded in the Southern Ocean, grouped by measurement month? | CREATE TABLE temperature_records (record_id INTEGER,month INTEGER,temperature FLOAT,ocean TEXT); | SELECT month, MIN(temperature) FROM temperature_records WHERE ocean = 'Southern Ocean' GROUP BY month; |
What is the percentage of companies founded by people of color, per country? | CREATE TABLE companies (id INT,name TEXT,country TEXT,founding_year INT,total_funding FLOAT,people_of_color_founded INT); INSERT INTO companies (id,name,country,founding_year,total_funding,people_of_color_founded) VALUES (1,'Acme Corp','USA',2010,20000000.0,0); | SELECT country, 100.0 * AVG(people_of_color_founded) / COUNT(*) AS percentage_founded_by_people_of_color FROM companies GROUP BY country; |
What is the total mass of space debris grouped by the debris type in the space_debris table? | CREATE TABLE space_debris (debris_type VARCHAR(30),mass FLOAT,debris_id INT); INSERT INTO space_debris VALUES ('Fuel Tank',1500.20,1),('Upper Stage',3000.50,2),('Payload Adapter',700.30,3),('Instrument',100.10,4); | SELECT debris_type, SUM(mass) OVER (PARTITION BY debris_type) FROM space_debris; |
What is the average carbon footprint of products in the Carbon_Footprint view? | CREATE VIEW Carbon_Footprint AS SELECT product_id,product_name,(transportation_emissions + production_emissions + packaging_emissions) AS total_carbon_footprint FROM Products; INSERT INTO Products (product_id,product_name,transportation_emissions,production_emissions,packaging_emissions) VALUES (401,'T-Shirt',5,10,1); INSERT INTO Products (product_id,product_name,transportation_emissions,production_emissions,packaging_emissions) VALUES (402,'Jeans',8,12,2); INSERT INTO Products (product_id,product_name,transportation_emissions,production_emissions,packaging_emissions) VALUES (403,'Hoodie',10,15,3); | SELECT AVG(total_carbon_footprint) FROM Carbon_Footprint; |
Find the percentage of donations made by each donor relative to the total donations received. | CREATE TABLE donations (donation_id INT,donor_id INT,donation_amount DECIMAL(10,2)); INSERT INTO donations VALUES (1,1,500.00),(2,2,300.00),(3,3,800.00),(4,1,200.00),(5,2,400.00),(6,3,100.00); | SELECT donor_id, donation_amount, PERCENT_RANK() OVER (ORDER BY SUM(donation_amount) ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) as donation_percentage FROM donations GROUP BY donor_id; |
Delete records in the "humanitarian_assistance" table for "Medical Aid" in Syria from 2018 | CREATE TABLE humanitarian_assistance (assistance_id INT PRIMARY KEY,assistance_type VARCHAR(50),country VARCHAR(50),year INT); INSERT INTO humanitarian_assistance (assistance_id,assistance_type,country,year) VALUES (1,'Food Aid','Kenya',2016),(2,'Water Supply','Pakistan',2017),(3,'Medical Aid','Syria',2018); | DELETE FROM humanitarian_assistance WHERE assistance_type = 'Medical Aid' AND country = 'Syria' AND year = 2018; |
Find total fertilizer usage for each crop type | CREATE TABLE fertilizer_usage (crop_type TEXT,fertilizer_amount INTEGER,application_date DATE); INSERT INTO fertilizer_usage (crop_type,fertilizer_amount,application_date) VALUES ('Corn',50,'2022-01-01'),('Soybeans',30,'2022-01-01'),('Corn',55,'2022-01-02'); | SELECT crop_type, SUM(fertilizer_amount) FROM fertilizer_usage GROUP BY crop_type; |
What is the average price of vegan menu items? | CREATE TABLE MenuItems (menu_item_id INT,name VARCHAR(255),price DECIMAL(5,2),is_vegan BOOLEAN); INSERT INTO MenuItems (menu_item_id,name,price,is_vegan) VALUES (1,'Burger',12.99,false),(2,'Steak',25.99,false),(3,'Fries',3.99,true); | SELECT AVG(price) FROM MenuItems WHERE is_vegan = true; |
What is the total amount of funding raised by biotech startups in the top 3 countries with the most funding, grouped by their founding year? | CREATE TABLE biotech_startups (id INT PRIMARY KEY,name VARCHAR(255),total_funding DECIMAL(10,2),founding_year INT,country VARCHAR(255)); | SELECT founding_year, country, SUM(total_funding) FROM biotech_startups WHERE country IN (SELECT country FROM biotech_startups GROUP BY country ORDER BY SUM(total_funding) DESC LIMIT 3) GROUP BY founding_year, country; |
What is the average time spent on each post by users from France, grouped by post type and day of the week? | CREATE TABLE posts (post_id INT,user_id INT,post_type VARCHAR(20),time_spent FLOAT,posted_at TIMESTAMP); INSERT INTO posts (post_id,user_id,post_type,time_spent,posted_at) VALUES (1,101,'Text',300.0,'2021-01-01 12:00:00'),(2,102,'Image',600.0,'2021-01-02 13:00:00'); | SELECT post_type, DATE_PART('dow', posted_at) AS day_of_week, AVG(time_spent) AS avg_time_spent FROM posts WHERE country = 'France' GROUP BY post_type, day_of_week; |
How many customers were impacted by droughts in each year? | CREATE TABLE drought_impact (customer_id INT,year INT,impact_level TEXT); INSERT INTO drought_impact (customer_id,year,impact_level) VALUES (1,2019,'severe'),(1,2020,'moderate'),(2,2019,'none'),(3,2020,'severe'),(3,2019,'moderate'),(4,2018,'severe'),(4,2019,'severe'); | SELECT year, COUNT(DISTINCT customer_id) as num_impacted_customers FROM drought_impact GROUP BY year; |
What is the minimum salary for engineers in 'african_mines'? | CREATE SCHEMA if not exists africa_schema_2;CREATE TABLE africa_schema_2.african_mines (id INT,name VARCHAR,role VARCHAR,salary DECIMAL);INSERT INTO africa_schema_2.african_mines (id,name,role,salary) VALUES (1,'G engineer','Engineer',60000.00),(2,'K engineer','Engineer',75000.00); | SELECT MIN(salary) FROM africa_schema_2.african_mines WHERE role = 'Engineer'; |
What is the maximum ocean acidification level in the Pacific Ocean? | CREATE TABLE ocean_acidification (region TEXT,level FLOAT); INSERT INTO ocean_acidification (region,level) VALUES ('Atlantic Ocean',7.5),('Pacific Ocean',7.9),('Indian Ocean',7.6); | SELECT MAX(level) FROM ocean_acidification WHERE region = 'Pacific Ocean'; |
What is the average sales for albums released in the 2010s? | CREATE TABLE Albums (AlbumID INT,AlbumName VARCHAR(50),ReleaseYear INT,Sales INT); | SELECT AVG(Sales) as AverageSales FROM Albums WHERE ReleaseYear BETWEEN 2010 AND 2019; |
What's the total transaction volume for digital assets in Africa in the last month? | CREATE TABLE digital_assets (id INT,name VARCHAR(255),transaction_volume DECIMAL(10,2),country VARCHAR(255)); INSERT INTO digital_assets (id,name,transaction_volume,country) VALUES (1,'Asset 1',1000.50,'Nigeria'),(2,'Asset 2',1500.25,'South Africa'),(3,'Asset 3',2000.00,'Egypt'); CREATE TABLE transactions (id INT,digital_asset_id INT,transaction_date DATE); INSERT INTO transactions (id,digital_asset_id,transaction_date) VALUES (1,1,'2022-01-01'),(2,2,'2022-01-05'),(3,3,'2022-01-10'); | SELECT SUM(transaction_volume) FROM digital_assets JOIN transactions ON digital_assets.id = transactions.digital_asset_id WHERE transaction_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) AND country IN ('Nigeria', 'South Africa', 'Egypt'); |
What was the total number of comments on posts in the 'travel' interest group in February 2022? | CREATE SCHEMA commentsdata; CREATE TABLE comments_per_post(post_id INT,interest_group VARCHAR(255),comments INT); INSERT INTO commentsdata.comments_per_post (post_id,interest_group,comments) VALUES (1,'travel',20); INSERT INTO commentsdata.comments_per_post (post_id,interest_group,comments) VALUES (2,'travel',30); | SELECT SUM(comments) FROM commentsdata.comments_per_post WHERE interest_group = 'travel' AND post_date >= '2022-02-01' AND post_date <= '2022-02-28'; |
What is the minimum number of hospital beds in rural hospitals of Arkansas? | CREATE TABLE hospitals (id INT,name TEXT,location TEXT,beds INT,rural BOOLEAN); INSERT INTO hospitals (id,name,location,beds,rural) VALUES (1,'Hospital A','Arkansas',100,true),(2,'Hospital B','Arkansas',150,true); | SELECT MIN(beds) FROM hospitals WHERE location = 'Arkansas' AND rural = true; |
Display the names of restaurants in the 'chain_restaurants' schema that do not serve any vegan dishes. | CREATE TABLE chain_restaurants.menu_items (menu_item_id INT,name TEXT,category TEXT); INSERT INTO chain_restaurants.menu_items (menu_item_id,name,category) VALUES (1,'Cheeseburger','Meat'),(2,'Fish Tacos','Seafood'),(3,'Chicken Caesar Salad','Poultry'); | SELECT name FROM chain_restaurants.menu_items WHERE category NOT LIKE '%Vegan%'; |
List all the renewable energy sources and their corresponding capacities in MW for the region of New England in 2022. | CREATE TABLE renewable_energy (region VARCHAR(20),energy_source VARCHAR(20),capacity INT,year INT); INSERT INTO renewable_energy (region,energy_source,capacity,year) VALUES ('New England','Solar',1000,2022),('New England','Wind',2000,2022),('New England','Hydro',3000,2022); | SELECT energy_source, capacity FROM renewable_energy WHERE region = 'New England' AND year = 2022; |
What was the total cost of ESA missions between 2010 and 2020? | CREATE SCHEMA SpaceMissionsCost;CREATE TABLE ESA_Missions (MissionID INT,Agency VARCHAR(50),Cost FLOAT);INSERT INTO ESA_Missions VALUES (1,'ESA',1500000000),(2,'ESA',1800000000),(3,'ESA',2000000000); | SELECT SUM(Cost) FROM ESA_Missions WHERE Agency = 'ESA' AND LaunchYear BETWEEN 2010 AND 2020; |
List all countries with a TV show budget over $10M. | CREATE TABLE tv_shows (id INT,title VARCHAR(50),country VARCHAR(50),budget DECIMAL(10,2)); | SELECT DISTINCT country FROM tv_shows WHERE budget > 10000000; |
Rank the strains of cannabis flower by their average retail price per gram, in descending order in Washington. | CREATE TABLE Sales (Sale_ID INT,Strain TEXT,Retail_Price DECIMAL); INSERT INTO Sales (Sale_ID,Strain,Retail_Price) VALUES (1,'White Widow',18.00); CREATE TABLE Dispensaries (Dispensary_ID INT,Dispensary_Name TEXT,State TEXT); INSERT INTO Dispensaries (Dispensary_ID,Dispensary_Name,State) VALUES (1,'Washington Weed','WA'); | SELECT Strain, AVG(Retail_Price) as Avg_Price, RANK() OVER (ORDER BY AVG(Retail_Price) DESC) as Rank FROM Sales JOIN Dispensaries ON Sales.State = Dispensaries.State WHERE State = 'WA' GROUP BY Strain; |
What is the difference in safety ratings between the latest and earliest tests for vehicle model 'M3'? | CREATE TABLE safety_tests_detailed (vehicle_model VARCHAR(10),safety_rating INT,year INT,test_number INT); | SELECT MAX(year) - MIN(year) AS years_diff, MAX(safety_rating) - MIN(safety_rating) AS safety_rating_diff FROM safety_tests_detailed WHERE vehicle_model = 'M3'; |
How many employees have been trained in circular economy principles since the beginning of the program? | CREATE TABLE employee_training (employee_id INT,training_date DATE,topic VARCHAR(50)); | SELECT COUNT(*) FROM employee_training WHERE topic = 'Circular Economy'; |
What is the count of IoT sensors in "DE-BW" and "CH-AG"? | CREATE TABLE Sensor (id INT,sensor_id INT,location VARCHAR(255)); INSERT INTO Sensor (id,sensor_id,location) VALUES (1,1003,'DE-BW'); | SELECT COUNT(DISTINCT sensor_id) FROM Sensor WHERE location IN ('DE-BW', 'CH-AG'); |
What is the average price of cosmetic products that are cruelty-free certified? | CREATE TABLE Cosmetics (ProductID INT,ProductName VARCHAR(50),Price DECIMAL(5,2),IsCrueltyFree BIT); INSERT INTO Cosmetics (ProductID,ProductName,Price,IsCrueltyFree) VALUES (1,'Lipstick',15.99,1),(2,'Mascara',12.49,1),(3,'Foundation',25.99,0); | SELECT AVG(Price) FROM Cosmetics WHERE IsCrueltyFree = 1; |
What is the average capacity of completed solar projects? | CREATE TABLE solar_projects (id INT PRIMARY KEY,project_name VARCHAR(255),location VARCHAR(255),capacity_mw FLOAT,completion_date DATE); | SELECT AVG(capacity_mw) FROM solar_projects WHERE completion_date IS NOT NULL; |
What is the total number of military technology patents filed by countries in the Middle East region in the last 2 years? | CREATE TABLE patents (id INT,country VARCHAR(50),filed_date DATE,patent_type VARCHAR(50)); INSERT INTO patents (id,country,filed_date,patent_type) VALUES (1,'Iran','2020-01-01','Military Tech'); INSERT INTO patents (id,country,filed_date,patent_type) VALUES (2,'Saudi Arabia','2019-05-01','Military Tech'); | SELECT COUNT(*) FROM patents WHERE country IN ('Iran', 'Iraq', 'Saudi Arabia', 'Turkey', 'United Arab Emirates') AND filed_date >= (SELECT DATE_SUB(CURRENT_DATE, INTERVAL 2 YEAR)) AND patent_type = 'Military Tech'; |
What is the total revenue generated by restaurants in Texas offering sustainable seafood? | CREATE TABLE restaurants (id INT,name TEXT,location TEXT,offers_sustainable_seafood BOOLEAN); INSERT INTO restaurants (id,name,location,offers_sustainable_seafood) VALUES (1,'Restaurant A','Texas',TRUE),(2,'Restaurant B','Texas',FALSE),(3,'Restaurant C','Texas',TRUE),(4,'Restaurant D','California',FALSE),(5,'Restaurant E','Texas',TRUE); CREATE TABLE orders (id INT,restaurant_id INT,revenue DECIMAL(5,2)); INSERT INTO orders (id,restaurant_id,revenue) VALUES (1,1,500.00),(2,1,700.00),(3,2,600.00),(4,3,1200.00),(5,4,900.00),(6,5,800.00); | SELECT SUM(revenue) FROM restaurants INNER JOIN orders ON restaurants.id = orders.restaurant_id WHERE offers_sustainable_seafood = TRUE AND location = 'Texas'; |
What are the names of the agricultural innovation projects in the 'rural_infrastructure' table that have a budget between 100000 and 200000? | CREATE TABLE rural_infrastructure (id INT,name VARCHAR(50),type VARCHAR(50),budget FLOAT); INSERT INTO rural_infrastructure (id,name,type,budget) VALUES (1,'Solar Irrigation','Agricultural Innovation',150000.00),(2,'Wind Turbines','Rural Infrastructure',200000.00),(3,'Drip Irrigation','Agricultural Innovation',110000.00); | SELECT name FROM rural_infrastructure WHERE type = 'Agricultural Innovation' AND budget > 100000 AND budget < 200000; |
What is the minimum heart rate of users from South Korea? | CREATE TABLE wearable_tech (user_id INT,heart_rate INT,country VARCHAR(50)); INSERT INTO wearable_tech (user_id,heart_rate,country) VALUES (1,70,'South Korea'),(2,75,'South Korea'),(3,80,'South Korea'),(4,65,'South Korea'),(5,60,'South Korea'),(6,55,'South Korea'); | SELECT MIN(heart_rate) FROM wearable_tech WHERE country = 'South Korea'; |
List all green building certifications that have been issued in the city of Toronto. | CREATE TABLE green_buildings (building_id INT,building_name VARCHAR(255),city VARCHAR(255),certification_date DATE); | SELECT building_name FROM green_buildings WHERE city = 'Toronto'; |
List all warehouses in Europe and their respective capacities. | CREATE TABLE Warehouses (id INT,warehouse_name VARCHAR(50),warehouse_location VARCHAR(50),warehouse_capacity INT); INSERT INTO Warehouses (id,warehouse_name,warehouse_location,warehouse_capacity) VALUES (1,'London Warehouse','England',5000),(2,'Berlin Warehouse','Germany',6000),(3,'Paris Warehouse','France',4000); | SELECT warehouse_name, warehouse_capacity FROM Warehouses WHERE warehouse_location IN ('England', 'Germany', 'France'); |
Delete projects that have a CO2 emission reduction lower than 1500 metric tons. | CREATE TABLE projects (id INT,CO2_reduction_tons INT); INSERT INTO projects (id,CO2_reduction_tons) VALUES (1,1500),(2,1200),(3,500),(4,2500); | DELETE FROM projects WHERE CO2_reduction_tons < 1500; |
List all the autonomous vehicles from the US | autonomous_vehicles | SELECT * FROM autonomous_vehicles WHERE country = 'United States'; |
What is the average number of visitors to South American countries with the highest biodiversity score? | CREATE TABLE regions (id INT PRIMARY KEY,name VARCHAR(255));CREATE TABLE countries (id INT PRIMARY KEY,name VARCHAR(255),region_id INT,FOREIGN KEY (region_id) REFERENCES regions(id));CREATE TABLE tourism (id INT PRIMARY KEY,country_id INT,visitors INT,FOREIGN KEY (country_id) REFERENCES countries(id));CREATE TABLE biodiversity (id INT PRIMARY KEY,country_id INT,score INT,FOREIGN KEY (country_id) REFERENCES countries(id)); | SELECT AVG(visitors) FROM tourism JOIN countries ON tourism.country_id = countries.id JOIN biodiversity ON countries.id = biodiversity.country_id WHERE biodiversity.score = (SELECT MAX(score) FROM biodiversity WHERE region_id = (SELECT id FROM regions WHERE name = 'South America')); |
What is the total budget for all resilience projects in 2022? | CREATE TABLE ResilienceProjects (ProjectID int,Budget decimal(10,2),Year int); INSERT INTO ResilienceProjects (ProjectID,Budget,Year) VALUES (1,500000,2022),(2,750000,2022),(3,600000,2023); | SELECT SUM(Budget) FROM ResilienceProjects WHERE Year = 2022; |
How many solar power projects were completed in the year 2020? | CREATE TABLE solar_projects (project_id INT,project_name VARCHAR(255),completion_date DATE); | SELECT COUNT(*) FROM solar_projects WHERE YEAR(completion_date) = 2020; |
How many missions were launched by each space agency in 2020? | CREATE TABLE missions (mission_id INT,name VARCHAR(50),space_agency VARCHAR(50),launch_date DATE); | SELECT space_agency, COUNT(*) FROM missions WHERE EXTRACT(YEAR FROM launch_date) = 2020 GROUP BY space_agency; |
What is the daily production rate of silver in Bolivia? | CREATE TABLE daily_production (id INT,country VARCHAR(255),mineral VARCHAR(255),date DATE,quantity INT); INSERT INTO daily_production (id,country,mineral,date,quantity) VALUES (1,'Bolivia','Silver','2022-01-01',50),(2,'Bolivia','Silver','2022-01-02',60),(3,'Bolivia','Silver','2022-01-03',70); | SELECT date, AVG(quantity) as daily_production_rate FROM daily_production WHERE country = 'Bolivia' AND mineral = 'Silver' GROUP BY date; |
What is the total number of smart city initiatives in South America? | CREATE TABLE smart_cities_2 (initiative_id INT,initiative_name TEXT,region TEXT); INSERT INTO smart_cities_2 (initiative_id,initiative_name,region) VALUES (1,'Smart City A','South America'),(2,'Smart City B','South America'); | SELECT COUNT(*) FROM smart_cities_2 WHERE region = 'South America'; |
How many broadband subscribers have there been in each country in the past month? | CREATE TABLE broadband_subscribers (subscriber_id INT,subscriber_name VARCHAR(255),subscribe_date DATE,country VARCHAR(255)); | SELECT country, COUNT(subscriber_id) as total_subscribers FROM broadband_subscribers WHERE subscribe_date >= DATE_SUB(CURDATE(), INTERVAL 1 MONTH) GROUP BY country; |
List the names of all bridges designed by the firm "Structural Integrity Inc." that have a length greater than 500 meters. | CREATE TABLE Bridges (id INT,name VARCHAR(100),length FLOAT,designer VARCHAR(100)); | SELECT name FROM Bridges WHERE designer = 'Structural Integrity Inc.' AND length > 500; |
What is the total number of employees working in the 'Manufacturing' department across all plants? | CREATE TABLE plants (plant_id INT,plant_name VARCHAR(50),department VARCHAR(50)); INSERT INTO plants (plant_id,plant_name,department) VALUES (1,'PlantA','Manufacturing'),(2,'PlantB','Engineering'),(3,'PlantC','Manufacturing'); | SELECT SUM(plant_count) FROM (SELECT COUNT(*) AS plant_count FROM plants WHERE department = 'Manufacturing' GROUP BY plant_name) AS plant_summary; |
Show cities with the highest number of arts events funded by "Local Arts Agency" | CREATE TABLE events (event_id INT,event_name VARCHAR(50),city VARCHAR(30),funding_source VARCHAR(30)); INSERT INTO events (event_id,event_name,city,funding_source) VALUES (1,'Theater Play','Chicago','Local Arts Agency'),(2,'Art Exhibit','New York','Private Donors'),(3,'Music Festival','Chicago','Local Arts Agency'),(4,'Dance Performance','Chicago','Local Arts Agency'); | SELECT city, COUNT(*) as num_events FROM events WHERE funding_source = 'Local Arts Agency' GROUP BY city ORDER BY num_events DESC LIMIT 1; |
Update the representation data for films in Africa. | CREATE TABLE film_representation (id INT,country VARCHAR(50),film_title VARCHAR(100),representation_score INT); INSERT INTO film_representation (id,country,film_title,representation_score) VALUES (1,'Nigeria','Movie1',75),(2,'South Africa','Movie2',85); | UPDATE film_representation SET representation_score = 90 WHERE country = 'Africa'; |
Find the industry with the highest average total funding per company for companies that have had more than 1 investment round. | CREATE TABLE Companies (id INT,name TEXT,industry TEXT,total_funding FLOAT,num_investments INT); INSERT INTO Companies (id,name,industry,total_funding,num_investments) VALUES (1,'Acme Inc','Software',2500000,2),(2,'Beta Corp','Software',5000000,1),(3,'Gamma Startup','Hardware',1000000,3),(4,'Delta LLC','Hardware',2000000,1); | SELECT industry, AVG(total_funding) AS industry_avg_funding FROM Companies WHERE num_investments > 1 GROUP BY industry ORDER BY industry_avg_funding DESC LIMIT 1; |
Find the minimum and maximum daily water consumption for residential buildings in Texas. | CREATE TABLE texas_water_usage (id INT,building_type VARCHAR(20),day VARCHAR(10),consumption FLOAT); INSERT INTO texas_water_usage (id,building_type,day,consumption) VALUES (1,'Residential','Monday',1000),(2,'Residential','Tuesday',1500); | SELECT MIN(consumption), MAX(consumption) FROM texas_water_usage WHERE building_type = 'Residential'; |
Identify the top three community health workers with the most unique patients served who identify as Native Hawaiian or Other Pacific Islander, along with the number of patients they have served. | CREATE TABLE CommunityHealthWorker (ID INT,Name TEXT); INSERT INTO CommunityHealthWorker (ID,Name) VALUES (1,'Leilani Kawakami'); INSERT INTO CommunityHealthWorker (ID,Name) VALUES (2,'Kekoa Keliipaakaua'); INSERT INTO CommunityHealthWorker (ID,Name) VALUES (3,'Noelani Ahia'); CREATE TABLE PatientCommunityHealthWorker (PatientID INT,CommunityHealthWorkerID INT,Ethnicity TEXT); | SELECT CommunityHealthWorkerID, COUNT(DISTINCT PatientID) as PatientsServed FROM PatientCommunityHealthWorker WHERE Ethnicity = 'Native Hawaiian or Other Pacific Islander' GROUP BY CommunityHealthWorkerID ORDER BY PatientsServed DESC LIMIT 3; |
What is the minimum budget for rural infrastructure projects in Brazil's Bahia state? | CREATE TABLE rural_infrastructure (id INT,project_name VARCHAR(255),budget FLOAT,state VARCHAR(50)); INSERT INTO rural_infrastructure (id,project_name,budget,state) VALUES (1,'Road Maintenance',95000.00,'Bahia'),(2,'Water Supply System',120000.00,'Bahia'),(3,'Sanitation Services',110000.00,'Bahia'); | SELECT MIN(budget) FROM rural_infrastructure WHERE state = 'Bahia' |
What is the total amount of research grants awarded to each country? | CREATE TABLE country_grants (id INT,country VARCHAR(255),grant_amount INT); INSERT INTO country_grants (id,country,grant_amount) VALUES (1,'USA',100000),(2,'Canada',75000),(3,'Mexico',50000),(4,'USA',125000); | SELECT country, SUM(grant_amount) as total_grants FROM country_grants GROUP BY country; |
Circular economy initiatives count by type in 2021? | CREATE TABLE circular_economy (initiative_type VARCHAR(50),year INT,initiative_count INT); INSERT INTO circular_economy (initiative_type,year,initiative_count) VALUES ('Composting',2021,50),('Reuse',2021,40),('Recycling',2021,60),('Reduce',2021,30); | SELECT initiative_type, initiative_count FROM circular_economy WHERE year = 2021; |
List the top 3 most affordable inclusive housing communities by median property price. | CREATE TABLE inclusive_housing (id INT,community TEXT,price FLOAT); INSERT INTO inclusive_housing (id,community,price) VALUES (1,'Sunshine Gardens',250000),(2,'Rainbow Village',300000),(3,'Harmony Heights',275000),(4,'Diversity Estates',400000); | SELECT community, price FROM (SELECT community, price, ROW_NUMBER() OVER (ORDER BY price) rn FROM inclusive_housing) tmp WHERE rn <= 3; |
What is the minimum price of eco-friendly products? | CREATE TABLE eco_friendly_products (product_id INT,product_name TEXT,price DECIMAL); INSERT INTO eco_friendly_products (product_id,product_name,price) VALUES (1,'Organic Cotton Shirt',30),(2,'Bamboo Toothbrush',5); | SELECT MIN(price) FROM eco_friendly_products; |
What is the average carbon footprint of tours in Amsterdam? | CREATE TABLE tours (tour_id INT,name TEXT,city TEXT,country TEXT,carbon_footprint DECIMAL(5,2)); INSERT INTO tours (tour_id,name,city,country,carbon_footprint) VALUES (7,'Amsterdam Canals Tour','Amsterdam','Netherlands',2.5); | SELECT AVG(carbon_footprint) FROM tours WHERE city = 'Amsterdam'; |
What is the average number of safety issues in workplaces per state? | CREATE TABLE workplaces (id INT,state VARCHAR(2),safety_issues INT); INSERT INTO workplaces (id,state,safety_issues) VALUES (1,'NY',10),(2,'CA',5),(3,'TX',15),(4,'FL',8); | SELECT state, AVG(safety_issues) OVER (PARTITION BY state) AS avg_safety_issues FROM workplaces; |
Create a view showing the number of tickets sold per quarter for each sport. | CREATE TABLE Sports (sport_id INT,sport_name VARCHAR(50)); CREATE TABLE Tickets (ticket_id INT,sport_id INT,quantity INT,purchase_date DATE); | CREATE VIEW quarterly_sales AS SELECT sport_id, EXTRACT(QUARTER FROM purchase_date) as quarter, EXTRACT(YEAR FROM purchase_date) as year, SUM(quantity) as total_sales FROM Tickets GROUP BY sport_id, quarter, year; |
How many vessels were reported in the Mediterranean Sea in 2020 with a length greater than 50 meters? | CREATE TABLE vessels (id INT,name TEXT,length FLOAT,year INT,region TEXT); INSERT INTO vessels (id,name,length,year,region) VALUES (1,'Vessel A',65.2,2020,'Mediterranean Sea'),(2,'Vessel B',48.9,2020,'Mediterranean Sea'),(3,'Vessel C',70.1,2019,'Mediterranean Sea'); | SELECT COUNT(*) FROM vessels WHERE region = 'Mediterranean Sea' AND length > 50 AND year = 2020; |
What is the average grant amount awarded to female researchers in the College of Engineering? | CREATE TABLE engineer_grants (researcher_id INT,researcher_gender VARCHAR(10),grant_amount DECIMAL(10,2)); INSERT INTO engineer_grants (researcher_id,researcher_gender,grant_amount) VALUES (1,'Female',50000.00),(2,'Male',75000.00),(3,'Female',60000.00); | SELECT AVG(grant_amount) FROM engineer_grants WHERE researcher_gender = 'Female'; |
Determine the percentage of organic products in the inventory for each product type. | CREATE TABLE inventory(id INT PRIMARY KEY,product VARCHAR(50),quantity INT,organic BOOLEAN,product_type VARCHAR(50)); INSERT INTO inventory(id,product,quantity,organic,product_type) VALUES (1,'apples',100,TRUE,'fruit'),(2,'bananas',200,FALSE,'fruit'),(3,'oranges',150,TRUE,'fruit'),(4,'carrots',250,TRUE,'vegetable'),(5,'broccoli',300,FALSE,'vegetable'); CREATE TABLE product_types(id INT PRIMARY KEY,type VARCHAR(50)); INSERT INTO product_types(id,type) VALUES (1,'fruit'),(2,'vegetable'),(3,'meat'),(4,'dairy'); | SELECT pt.type, AVG(CASE WHEN i.organic THEN 100.0 ELSE 0.0 END) AS percentage_organic FROM inventory i JOIN product_types pt ON i.product_type = pt.type GROUP BY pt.type; |
What is the total population of marine life research data entries for species that have the word 'Tuna' in their name? | CREATE TABLE marine_life_research(id INT,species VARCHAR(50),population INT); INSERT INTO marine_life_research(id,species,population) VALUES (1,'Beluga Whale',250),(2,'Whale Shark',300),(3,'Dolphin',600),(4,'Yellowfin Tuna',500); | SELECT SUM(population) FROM marine_life_research WHERE species LIKE '%Tuna%'; |
What is the average price per gram of cannabis flower in Washington? | CREATE TABLE Inventory (InventoryID INT,Product TEXT,Price DECIMAL,State TEXT); INSERT INTO Inventory (InventoryID,Product,Price,State) VALUES (1,'Cannabis Flower',15.00,'Washington'); INSERT INTO Inventory (InventoryID,Product,Price,State) VALUES (2,'Cannabis Flower',20.00,'Washington'); | SELECT AVG(Price) FROM Inventory WHERE Product = 'Cannabis Flower' AND State = 'Washington'; |
What is the trend of marine species richness in different depth zones? | CREATE TABLE depth_zones (id INT,depth_zone TEXT,species_count INT); INSERT INTO depth_zones (id,depth_zone,species_count) VALUES (1,'0-1000m',500),(2,'1000-2000m',300),(3,'2000-3000m',150); | SELECT depth_zone, AVG(species_count) OVER (ORDER BY depth_zone ROWS BETWEEN UNBOUNDED PRECEDING AND 1 PRECEDING) AS avg_species_count FROM depth_zones; |
What is the number of hospitalizations by cause of illness in 2020? | CREATE TABLE hospitalizations (id INT,cause_illness VARCHAR(255),year INT); INSERT INTO hospitalizations VALUES (1,'Pneumonia',2020),(2,'Heart disease',2020),(3,'Pneumonia',2020); | SELECT cause_illness, COUNT(*) AS hospitalizations FROM hospitalizations WHERE year = 2020 GROUP BY cause_illness; |
How many wheelchair-accessible vehicles are available in each depot? | CREATE TABLE Depots (DepotID INT,DepotName VARCHAR(50)); CREATE TABLE Vehicles (VehicleID INT,DepotID INT,VehicleType VARCHAR(50),IsWheelchairAccessible BIT); INSERT INTO Depots (DepotID,DepotName) VALUES (1,'DepotA'),(2,'DepotB'),(3,'DepotC'); INSERT INTO Vehicles (VehicleID,DepotID,VehicleType,IsWheelchairAccessible) VALUES (1,1,'Bus',1),(2,1,'Bus',0),(3,2,'Tram',1),(4,2,'Tram',1),(5,3,'Bus',0); | SELECT D.DepotName, COUNT(V.VehicleID) AS WheelchairAccessibleVehicles FROM Depots D JOIN Vehicles V ON D.DepotID = V.DepotID WHERE V.IsWheelchairAccessible = 1 GROUP BY D.DepotName; |
Find the number of unique funding sources supporting visual arts programs and music events. | CREATE TABLE programs (id INT,type VARCHAR(20)); INSERT INTO programs (id,type) VALUES (1,'Painting'),(2,'Sculpture'),(3,'Music'); CREATE TABLE funding (id INT,program_id INT,source VARCHAR(25)); INSERT INTO funding (id,program_id,source) VALUES (1,1,'Grant 1'),(2,1,'Grant 2'),(3,2,'Donation'),(4,3,'Sponsorship'),(5,3,'Crowdfunding'); | SELECT COUNT(DISTINCT f.source) FROM funding f WHERE f.program_id IN (SELECT p.id FROM programs p WHERE p.type IN ('Visual Arts', 'Music')); |
What is the total budget for community development initiatives in 'community_development' table, grouped by year? | CREATE TABLE community_development (id INT,initiative_type VARCHAR(50),budget INT,start_year INT); INSERT INTO community_development (id,initiative_type,budget,start_year) VALUES (1,'Education',50000,2020); INSERT INTO community_development (id,initiative_type,budget,start_year) VALUES (2,'Housing',75000,2019); | SELECT start_year, SUM(budget) FROM community_development GROUP BY start_year; |
What is the average CO2 emission of hybrid vehicles in the United Kingdom? | CREATE TABLE Vehicle_Types (Id INT,Name VARCHAR(50)); CREATE TABLE Vehicle_Releases (Id INT,Name VARCHAR(50),Release_Date DATE,Origin_Country VARCHAR(50),CO2_Emission INT,Vehicle_Type_Id INT); | SELECT AVG(CO2_Emission) FROM Vehicle_Releases WHERE Vehicle_Type_Id = (SELECT Id FROM Vehicle_Types WHERE Name = 'Hybrid') AND Origin_Country = 'United Kingdom'; |
What is the minimum range of electric scooters in the "electric_scooters" table? | CREATE TABLE electric_scooters (id INT,scooter_type VARCHAR(255),range INT); INSERT INTO electric_scooters (id,scooter_type,range) VALUES (1,'Stand-Up',20); | SELECT MIN(range) FROM electric_scooters WHERE scooter_type = 'Stand-Up'; |
What are the total R&D expenditures for a specific drug in the past 5 years, regardless of region? | CREATE TABLE rd_expenditure (id INT,drug_name VARCHAR(255),region VARCHAR(255),expenditure DECIMAL(10,2),expenditure_year INT); INSERT INTO rd_expenditure (id,drug_name,region,expenditure,expenditure_year) VALUES (1,'DrugF','North America',50000,2018); INSERT INTO rd_expenditure (id,drug_name,region,expenditure,expenditure_year) VALUES (2,'DrugF','North America',60000,2019); | SELECT SUM(expenditure) FROM rd_expenditure WHERE drug_name = 'DrugF' AND expenditure_year BETWEEN (YEAR(CURRENT_DATE) - 5) AND YEAR(CURRENT_DATE); |
What are the top 3 countries where most security incidents occurred in the past month? | CREATE TABLE security_incidents (id INT,country VARCHAR(255),incident_time TIMESTAMP); INSERT INTO security_incidents (id,country,incident_time) VALUES (1,'USA','2022-02-03 12:30:00'),(2,'Canada','2022-02-01 14:15:00'),(3,'Mexico','2022-02-05 09:20:00'); | SELECT country, COUNT(*) as count FROM security_incidents WHERE incident_time >= DATE_SUB(CURRENT_TIMESTAMP(), INTERVAL 1 MONTH) GROUP BY country ORDER BY count DESC LIMIT 3; |
What is the total price of products in the Organic segment? | CREATE TABLE products (product_id INT,segment VARCHAR(20),price DECIMAL(5,2)); INSERT INTO products (product_id,segment,price) VALUES (1,'Natural',15.99),(2,'Organic',20.99),(3,'Natural',12.49); | SELECT SUM(price) FROM products WHERE segment = 'Organic'; |
What is the maximum price of organic skincare products? | CREATE TABLE products (product_id INT,product_type VARCHAR(50),price DECIMAL(5,2)); INSERT INTO products VALUES (1,'Organic Skincare',35.99),(2,'Organic Skincare',20.99),(3,'Natural Makeup',15.49),(4,'Natural Makeup',22.50),(5,'Organic Skincare',50.00),(6,'Natural Makeup',9.99),(7,'Cruelty-Free',12.35),(8,'Organic Skincare',14.55),(9,'Cruelty-Free',18.99),(10,'Cruelty-Free',25.00); | SELECT MAX(p.price) FROM products p WHERE p.product_type = 'Organic Skincare'; |
Find the chemical with the lowest quantity produced in the last 30 days. | CREATE TABLE chemical_production_new2 (id INT PRIMARY KEY,chemical_name VARCHAR(50),quantity INT,production_date DATE); | SELECT chemical_name, MIN(quantity) as min_quantity FROM chemical_production_new2 WHERE production_date > CURDATE() - INTERVAL 30 DAY GROUP BY chemical_name LIMIT 1; |
How many legal aid cases were opened in the state of Texas in 2021? | CREATE TABLE legal_aid (id INT,state VARCHAR(20),year INT,case_number INT); INSERT INTO legal_aid (id,state,year,case_number) VALUES (1,'Texas',2021,123),(2,'California',2020,456),(3,'Texas',2021,789); | SELECT SUM(case_number) FROM legal_aid WHERE state = 'Texas' AND year = 2021; |
Who is the most prolific artist in the contemporary art domain? | CREATE TABLE ArtistWorks (id INT,artist VARCHAR(50),domain VARCHAR(50),quantity INT); INSERT INTO ArtistWorks (id,artist,domain,quantity) VALUES (1,'Banksy','Contemporary',30),(2,'Shepard Fairey','Contemporary',40),(3,'Yayoi Kusama','Contemporary',50); | SELECT artist, MAX(quantity) FROM ArtistWorks WHERE domain = 'Contemporary'; |
Identify the number of clinical trials per year for a specific drug. | CREATE TABLE clinical_trials (drug_name TEXT,year INTEGER,trial_count INTEGER); | SELECT year, COUNT(*) AS trials_per_year FROM clinical_trials WHERE drug_name = 'DrugX' GROUP BY year ORDER BY year; |
How many songs were released by artists who have more than 100k followers on a social media platform? | CREATE TABLE artist (artist_id INT,artist_name VARCHAR(50),followers INT); INSERT INTO artist (artist_id,artist_name,followers) VALUES (1,'Artist A',120000),(2,'Artist B',80000); CREATE TABLE song (song_id INT,song_name VARCHAR(50),artist_id INT); INSERT INTO song (song_id,song_name,artist_id) VALUES (1,'Song 1',1),(2,'Song 2',2),(3,'Song 3',1); | SELECT COUNT(s.song_id) FROM song s JOIN artist a ON s.artist_id = a.artist_id WHERE a.followers > 100000; |
Update the community engagement status of a heritage site | CREATE TABLE community_engagement (id INT PRIMARY KEY,site_id INT,status VARCHAR(255)); | UPDATE community_engagement SET status = 'Active' WHERE site_id = 1; |
How many jobs have been created by virtual tourism in India, Japan, and Brazil? | CREATE TABLE VirtualTourism (TourismID int,Location varchar(50),JobsCreated int); INSERT INTO VirtualTourism (TourismID,Location,JobsCreated) VALUES (1,'India',500); INSERT INTO VirtualTourism (TourismID,Location,JobsCreated) VALUES (2,'Japan',600); INSERT INTO VirtualTourism (TourismID,Location,JobsCreated) VALUES (3,'Brazil',700); | SELECT SUM(JobsCreated) FROM VirtualTourism WHERE Location IN ('India', 'Japan', 'Brazil') |
Update the 'end_year' of all records in the 'clean_energy_policy_trends' table where the 'policy_type' is 'Standard' to 2028 | CREATE TABLE clean_energy_policy_trends (id INT,policy_type VARCHAR(255),start_year INT,end_year INT,description TEXT); | UPDATE clean_energy_policy_trends SET end_year = 2028 WHERE policy_type = 'Standard'; |
What's the total number of employees by department for the mining company? | CREATE TABLE departments (id INT,name VARCHAR(255)); INSERT INTO departments (id,name) VALUES (1,'HR'),(2,'Operations'),(3,'Engineering'); CREATE TABLE employees (id INT,name VARCHAR(255),department_id INT); INSERT INTO employees (id,name,department_id) VALUES (1,'John',2),(2,'Jane',3),(3,'Mike',1),(4,'Lucy',2); | SELECT e.department_id, COUNT(e.id) as total FROM employees e GROUP BY e.department_id; |
How many countries are in the 'countries' table? | CREATE TABLE countries (id INT PRIMARY KEY,name VARCHAR(255),region VARCHAR(255)); INSERT INTO countries (id,name,region) VALUES (1,'Canada','North America'),(2,'Mexico','North America'),(3,'Brazil','South America'),(4,'Argentina','South America'),(5,'India','Asia'),(6,'China','Asia'); | SELECT COUNT(*) FROM countries; |
List the top 5 cities with the highest total installed capacity of renewable energy projects in the renewable_projects table. | CREATE TABLE renewable_projects (project_id INT,project_name VARCHAR(255),location VARCHAR(255),technology VARCHAR(255),installed_capacity FLOAT); | SELECT location, SUM(installed_capacity) AS total_capacity FROM renewable_projects GROUP BY location ORDER BY total_capacity DESC LIMIT 5; |
How many autonomous taxis are there in San Francisco? | CREATE TABLE if not exists taxi_service (id INT,city VARCHAR(20),taxi_type VARCHAR(20),quantity INT);INSERT INTO taxi_service (id,city,taxi_type,quantity) VALUES (1,'San Francisco','autonomous_taxi',120),(2,'San Francisco','manual_taxi',700),(3,'Los Angeles','autonomous_taxi',90),(4,'Los Angeles','manual_taxi',850); | SELECT SUM(quantity) FROM taxi_service WHERE city = 'San Francisco' AND taxi_type = 'autonomous_taxi'; |
Update the location of the reader with reader_id 1 in the 'audience_demographics' table | CREATE TABLE audience_demographics (reader_id INT PRIMARY KEY,age INT,gender VARCHAR(10),location VARCHAR(100)); | UPDATE audience_demographics SET location = 'Los Angeles, CA' WHERE reader_id = 1; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.