instruction stringlengths 0 1.06k | input stringlengths 11 5.3k | response stringlengths 2 4.44k |
|---|---|---|
What is the total water consumption by agricultural customers in the state of California, excluding the Central Valley region? | CREATE TABLE agricultural_customers (customer_id INT,state VARCHAR(20),region VARCHAR(20),water_usage FLOAT); INSERT INTO agricultural_customers (customer_id,state,region,water_usage) VALUES (1,'California','Central Valley',15000),(2,'California','Los Angeles',12000),(3,'California','San Diego',10000); | SELECT SUM(water_usage) FROM agricultural_customers WHERE state = 'California' AND region != 'Central Valley'; |
What is the average price of 'Beef' in 'EcoFarm' and 'HealthyHarvest'? | CREATE TABLE EcoFarm (product_id INT,product_name VARCHAR(50),price FLOAT); CREATE TABLE HealthyHarvest (product_id INT,product_name VARCHAR(50),price FLOAT); INSERT INTO EcoFarm (product_id,product_name,price) VALUES (1,'Eggs',4.0),(2,'Milk',3.5),(3,'Chicken',6.5),(4,'Beef',12.0); INSERT INTO HealthyHarvest (product_i... | SELECT AVG(price) FROM (SELECT price FROM EcoFarm WHERE product_name = 'Beef' UNION ALL SELECT price FROM HealthyHarvest WHERE product_name = 'Beef') AS subquery; |
Find the total number of vegan products sold in each continent. | CREATE TABLE vegan_sales AS SELECT sales_continents.*,products.is_vegan FROM sales_continents JOIN products ON sales_continents.product_id = products.product_id; | SELECT continents.continent_name, SUM(CASE WHEN vegan_sales.is_vegan = true THEN 1 ELSE 0 END) as total_vegan_sales FROM continents JOIN vegan_sales ON continents.continent_id = vegan_sales.continent_id GROUP BY continents.continent_name |
What are the types of artifacts found in the 'artifacts' table? | CREATE TABLE artifacts (artifact_id INT PRIMARY KEY,artifact_name VARCHAR(100),artifact_type VARCHAR(50)); INSERT INTO artifacts (artifact_id,artifact_name,artifact_type) VALUES (1,'Pottery Shard','Ceramic'),(2,'Flint Tool','Stone'); | SELECT DISTINCT artifact_type FROM artifacts; |
How many goals has each player scored in the UEFA Champions League this season? | CREATE TABLE teams (team_id INT,team_name VARCHAR(255),league VARCHAR(255));CREATE TABLE players (player_id INT,player_name VARCHAR(255),position VARCHAR(50),team_id INT,goals INT);CREATE TABLE games (game_id INT,home_team_id INT,away_team_id INT,home_team_score INT,away_team_score INT,season VARCHAR(50)); INSERT INTO ... | SELECT players.player_name, SUM(players.goals) AS total_goals FROM players JOIN games ON players.team_id IN (games.home_team_id, games.away_team_id) WHERE games.season = '2022-2023' GROUP BY players.player_name; |
Calculate the total defense diplomacy expenditures for the years 2017 and 2018 | CREATE TABLE defense_diplomacy (year INT,expenditure FLOAT); INSERT INTO defense_diplomacy (year,expenditure) VALUES (2017,2500000),(2017,3000000),(2018,2000000),(2018,3500000),(2018,4000000); | SELECT year, SUM(expenditure) as total_expenditure FROM defense_diplomacy GROUP BY year; |
What is the adoption rate of 'AI' in 'hotels'? | CREATE TABLE tech_adoption (hotel_id INT,hotel_name TEXT,technology TEXT,adoption_rate FLOAT); INSERT INTO tech_adoption (hotel_id,hotel_name,technology,adoption_rate) VALUES (1,'Hotel Ritz','AI',0.7),(2,'Hotel George V','AI',0.8),(3,'Grand Hotel','AI',0.6); | SELECT hotel_name, AVG(adoption_rate) as avg_adoption_rate FROM tech_adoption WHERE technology = 'AI' GROUP BY hotel_name; |
Update the production volume of the 'Brazilian Gold Mine 1' to 9000. | CREATE TABLE mines (id INT,name TEXT,location TEXT,production_volume INT); INSERT INTO mines (id,name,location,production_volume) VALUES (1,'Brazilian Gold Mine 1','Brazil',8000); | UPDATE mines SET production_volume = 9000 WHERE name = 'Brazilian Gold Mine 1'; |
Which customers have accounts in the 'High Value' category but no transactions? | CREATE TABLE customers (customer_id INT,name TEXT); INSERT INTO customers (customer_id,name) VALUES (1,'John Doe'); INSERT INTO customers (customer_id,name) VALUES (2,'Jane Smith'); CREATE TABLE accounts (account_id INT,account_type TEXT,customer_id INT); INSERT INTO accounts (account_id,account_type,customer_id) VALUE... | SELECT customers.name FROM customers LEFT JOIN accounts ON customers.customer_id = accounts.customer_id LEFT JOIN customer_transactions ON accounts.account_id = customer_transactions.account_id WHERE accounts.account_type = 'High Value' AND customer_transactions.transaction_id IS NULL; |
Delete esports events without a game | esports_event (event_id,name,location,start_date,end_date,prize_pool,game_id) | DELETE FROM esports_event WHERE game_id IS NULL |
Calculate the total defense diplomacy events in 2020 and 2021 | CREATE TABLE defense_diplomacy (event_date DATE,event_type VARCHAR(255)); INSERT INTO defense_diplomacy (event_date,event_type) VALUES ('2020-01-01','Summit'),('2021-01-01','Conference'),('2020-06-01','Workshop'); | SELECT YEAR(event_date) as year, COUNT(*) as total_events FROM defense_diplomacy WHERE YEAR(event_date) IN (2020, 2021) GROUP BY year; |
What is the total budget allocation for sustainable materials in Project 2? | CREATE TABLE Budget_Allocation (Allocation_ID INT,Allocation_Type VARCHAR(255),Allocation_Amount DECIMAL(10,2),Project_ID INT,FOREIGN KEY (Project_ID) REFERENCES Projects(Project_ID)); INSERT INTO Budget_Allocation (Allocation_ID,Allocation_Type,Allocation_Amount,Project_ID) VALUES (1,'Sustainable Materials',125000.00,... | SELECT SUM(Allocation_Amount) FROM Budget_Allocation WHERE Allocation_Type = 'Sustainable Materials' AND Project_ID = 2; |
What is the total funding allocated for climate communication initiatives in Africa in the year 2020? | CREATE TABLE climate_finance (id INT,initiative_name VARCHAR(50),country VARCHAR(50),amount FLOAT,date DATE); INSERT INTO climate_finance (id,initiative_name,country,amount,date) VALUES (1,'Climate Talks','Africa',500000,'2020-01-01'); | SELECT SUM(amount) FROM climate_finance WHERE country = 'Africa' AND date = '2020-01-01' AND initiative_name LIKE '%climate communication%'; |
Delete all records from the 'ocean_temperature' table where the temperature is below -2°C. | CREATE TABLE ocean_temperature (temperature REAL,depth INTEGER); INSERT INTO ocean_temperature (temperature,depth) VALUES (-1.5,100),(0.2,200),(-2.1,300); | DELETE FROM ocean_temperature WHERE temperature < -2; |
List the number of new hires in each quarter, ranked by the number of new hires in descending order. | CREATE TABLE Employees (EmployeeID INT,HireDate DATE); | SELECT QUARTER(HireDate) AS Quarter, COUNT(*) AS NewHires FROM Employees GROUP BY Quarter ORDER BY NewHires DESC; |
What is the average salary of data analysts in the Analytics department, grouped by race? | CREATE TABLE Employees (EmployeeID INT,FirstName VARCHAR(50),LastName VARCHAR(50),Department VARCHAR(50),Position VARCHAR(50),Salary FLOAT,Race VARCHAR(50)); | SELECT e.Race, AVG(e.Salary) FROM Employees e INNER JOIN (SELECT EmployeeID, 'Data Analyst' AS Position FROM TalentAcquisition WHERE Position = 'Data Analyst') ta ON e.EmployeeID = ta.EmployeeID WHERE e.Department = 'Analytics' GROUP BY e.Race; |
What is the maximum 'quantity' for each chemical, if any, that is part of a 'reaction' and has a safety rating above 80 in the 'chemicals' table? | CREATE TABLE reaction (id INT,chemical_id INT,quantity INT); CREATE TABLE chemicals (id INT,chemical_name VARCHAR(255),safety_rating INT); INSERT INTO reaction (id,chemical_id,quantity) VALUES (1,1,100),(2,2,200),(3,3,300); INSERT INTO chemicals (id,chemical_name,safety_rating) VALUES (1,'H2O',95),(2,'CO2',70),(3,'N2',... | SELECT r.chemical_id, MAX(r.quantity) as max_quantity FROM reaction r JOIN chemicals c ON r.chemical_id = c.id WHERE c.safety_rating > 80 GROUP BY r.chemical_id; |
Who are the eSports players with the fewest losses in "Counter-Strike: Global Offensive" tournaments? | CREATE TABLE Players (PlayerName VARCHAR(255),TournamentLosses INT); INSERT INTO Players (PlayerName,TournamentLosses) VALUES ('PlayerA',2),('PlayerB',0),('PlayerC',1),('PlayerD',3),('PlayerE',1); | SELECT PlayerName FROM Players WHERE TournamentLosses = (SELECT MIN(TournamentLosses) FROM Players WHERE TournamentLosses > 0); |
Insert data into innovation trends table | CREATE TABLE innovation_trends (trend_id INT,trend_name VARCHAR(50),description VARCHAR(200)); | INSERT INTO innovation_trends (trend_id, trend_name, description) VALUES (1, 'Artificial Intelligence', 'The use of algorithms and machine learning to automate tasks and analyze data.'), (2, 'Blockchain', 'A decentralized and distributed digital ledger for securely recording transactions.'), (3, 'Virtual Reality', 'A s... |
How many virtual tours were conducted in Japan in the year 2022? | CREATE TABLE virtual_tours (id INT,country VARCHAR(255),year INT,num_tours INT); INSERT INTO virtual_tours (id,country,year,num_tours) VALUES (1,'Japan',2022,100),(2,'China',2022,80); | SELECT SUM(num_tours) FROM virtual_tours WHERE country = 'Japan' AND year = 2022; |
What is the average acquisition cost of military equipment for the Army? | CREATE TABLE Equipment (Id INT,Name VARCHAR(50),Type VARCHAR(50),Agency VARCHAR(50),Cost FLOAT); INSERT INTO Equipment (Id,Name,Type,Agency,Cost) VALUES (1,'M1 Abrams','Tank','Army',8000000); INSERT INTO Equipment (Id,Name,Type,Agency,Cost) VALUES (2,'F-35','Fighter Jet','Air Force',100000000); | SELECT AVG(Cost) FROM Equipment WHERE Agency = 'Army'; |
What is the average response time for fire calls in the 'coastal' schema in Q1 2022? | CREATE SCHEMA if not exists coastal; CREATE TABLE if not exists coastal.fire_responses (id INT,response_time TIME,call_date DATE); INSERT INTO coastal.fire_responses (id,response_time,call_date) VALUES (1,'00:15:00','2022-01-05'),(2,'00:20:00','2022-03-12'),(3,'00:10:00','2022-02-27'); | SELECT AVG(TIME_TO_SEC(response_time)) FROM coastal.fire_responses WHERE QUARTER(call_date) = 1 AND YEAR(call_date) = 2022; |
What is the name and country of manufacturers who are not certified fair trade? | CREATE TABLE manufacturers (id INT,name VARCHAR(255),country VARCHAR(255),certified_fair_trade BOOLEAN); INSERT INTO manufacturers (id,name,country,certified_fair_trade) VALUES (1,'Manufacturer B','India',false); | SELECT name, country FROM manufacturers WHERE certified_fair_trade = false; |
List all unique accommodation types provided to students with hearing impairments, ordered alphabetically. | CREATE TABLE students (id INT,name TEXT,hearing_impairment BOOLEAN,accommodation_type TEXT); INSERT INTO students (id,name,hearing_impairment,accommodation_type) VALUES (1,'John Doe',false,'Note-taking service'),(2,'Jane Doe',true,'Sign language interpreter'); | SELECT DISTINCT accommodation_type FROM students WHERE hearing_impairment = true ORDER BY accommodation_type; |
What is the maximum network investment made in a single day in the Western region? | CREATE TABLE network_investments (investment_id INT,region VARCHAR(255),investment_amount DECIMAL(10,2),investment_date DATE); INSERT INTO network_investments (investment_id,region,investment_amount,investment_date) VALUES (1,'Western',50000.00,'2022-01-01'),(2,'Western',75000.00,'2022-02-03'),(3,'Western',60000.00,'20... | SELECT region, MAX(investment_amount) FROM network_investments WHERE region = 'Western' GROUP BY region, DATE(investment_date); |
Count the number of reservations for each hotel_id | CREATE TABLE hotel_reservations (reservation_id INT,hotel_id INT,guest_name TEXT,arrival_date DATE,departure_date DATE,num_guests INT,payment_amount FLOAT,is_cancelled BOOLEAN); | SELECT hotel_id, COUNT(*) FROM hotel_reservations GROUP BY hotel_id; |
How many artworks were created during the 'Cubism' period and are currently in the 'London' museum? | CREATE TABLE Artworks (ArtworkID INT,Title VARCHAR(255),Period VARCHAR(255),MuseumID INT); INSERT INTO Artworks VALUES (1,'Guernica','Cubism',2); CREATE TABLE Museums (MuseumID INT,Name VARCHAR(255),Location VARCHAR(255)); INSERT INTO Museums VALUES (2,'Tate Modern','London'); | SELECT COUNT(Artworks.ArtworkID) FROM Artworks INNER JOIN Museums ON Artworks.MuseumID = Museums.MuseumID WHERE Artworks.Period = 'Cubism' AND Museums.Location = 'London'; |
What is the maximum distance for routes that originate from 'City C'? | CREATE TABLE Routes (id INT,origin_city VARCHAR(255),destination_city VARCHAR(255),distance INT,eta INT); INSERT INTO Routes (id,origin_city,destination_city,distance,eta) VALUES (1,'City A','City C',200,2); INSERT INTO Routes (id,origin_city,destination_city,distance,eta) VALUES (2,'City B','City D',250,3); INSERT INT... | SELECT origin_city, MAX(distance) FROM Routes WHERE origin_city = 'City C' GROUP BY origin_city; |
List the number of accessibility requests made by each department, excluding any duplicate request types. | CREATE TABLE accessibility_requests (request_type VARCHAR(50),department VARCHAR(50)); INSERT INTO accessibility_requests VALUES ('Wheelchair Access','General'),('Sign Language Interpreter','General'),('Wheelchair Access','Science'),('Assistive Listening Device','English'); | SELECT department, COUNT(DISTINCT request_type) FROM accessibility_requests GROUP BY department; |
What is the total revenue generated from organic cosmetic products? | CREATE TABLE cosmetics (product_id INT,product_name VARCHAR(50),is_organic BOOLEAN,revenue FLOAT); | SELECT SUM(revenue) FROM cosmetics WHERE is_organic = TRUE; |
What is the average communication budget for each organization between 2018 and 2020? | CREATE TABLE org_communication_budget (org_name VARCHAR(50),year INT,budget FLOAT); INSERT INTO org_communication_budget (org_name,year,budget) VALUES ('UN',2018,800000),('Greenpeace',2018,900000),('WWF',2018,1000000),('UN',2019,900000),('Greenpeace',2019,1100000),('WWF',2019,1200000),('UN',2020,1000000),('Greenpeace',... | SELECT org_name, AVG(budget) as avg_budget FROM org_communication_budget WHERE year BETWEEN 2018 AND 2020 GROUP BY org_name; |
What is the total claim amount and the number of claims for policyholders in the South? | CREATE TABLE policyholders (id INT,policyholder_state VARCHAR(2)); INSERT INTO policyholders (id,policyholder_state) VALUES (1,'TX'),(2,'CA'),(3,'TX'),(4,'NY'),(5,'FL'); CREATE TABLE claims (id INT,policyholder_id INT,claim_amount DECIMAL(10,2)); INSERT INTO claims (id,policyholder_id,claim_amount) VALUES (1,1,500),(2,... | SELECT policyholder_state, SUM(claim_amount) AS total_claim_amount, COUNT(*) AS num_claims FROM claims JOIN policyholders ON claims.policyholder_id = policyholders.id WHERE policyholder_state IN ('TX', 'FL') GROUP BY policyholder_state; |
What is the total revenue and quantity sold for each menu item, excluding those that were not sold in any restaurant, in Texas during the month of May 2021?' | CREATE TABLE Restaurants (RestaurantID int,Name varchar(50),Location varchar(50)); CREATE TABLE Menu (MenuID int,ItemName varchar(50),Category varchar(50)); CREATE TABLE MenuSales (MenuID int,RestaurantID int,QuantitySold int,Revenue decimal(5,2),SaleDate date); | SELECT M.ItemName, SUM(M.Revenue) as Revenue, SUM(M.QuantitySold) as QuantitySold FROM Menu M JOIN MenuSales MS ON M.MenuID = MS.MenuID JOIN Restaurants R ON MS.RestaurantID = R.RestaurantID WHERE R.Location LIKE '%Texas%' AND MS.SaleDate >= '2021-05-01' AND MS.SaleDate <= '2021-05-31' GROUP BY M.ItemName HAVING SUM(MS... |
What is the average age of teachers who have completed a professional development program in the last year? | CREATE TABLE Teachers (TeacherID INT PRIMARY KEY,Name VARCHAR(100),Age INT,ProfessionalDevelopment DATE); INSERT INTO Teachers (TeacherID,Name,Age,ProfessionalDevelopment) VALUES (1,'John Doe',35,'2021-12-15'); | SELECT AVG(Age) FROM Teachers WHERE ProfessionalDevelopment >= DATEADD(year, -1, GETDATE()); |
List the destinations with at least 5 tourists from Australia in 2023. | CREATE TABLE tourism_data (id INT,name VARCHAR(50),country VARCHAR(50),destination VARCHAR(50),visit_year INT); INSERT INTO tourism_data (id,name,country,destination,visit_year) VALUES (1,'Sarah Thompson','Australia','Sydney',2023),(2,'James Clark','Australia','Melbourne',2023),(3,'Grace White','Australia','Perth',2023... | SELECT DISTINCT destination FROM tourism_data WHERE country = 'Australia' AND visit_year = 2023 GROUP BY destination HAVING COUNT(*) >= 5; |
What is the number of inspections for vessels that have a safety score below 75 and have traveled to the Antarctic Ocean in 2021? | CREATE TABLE vessels (id INT,name TEXT,type TEXT,safety_score FLOAT);CREATE TABLE inspections (id INT,vessel_id INT,date DATE,result TEXT); INSERT INTO vessels (id,name,type,safety_score) VALUES (1,'VesselJ','Research',70); INSERT INTO inspections (id,vessel_id,date,result) VALUES (1,1,'2021-05-01','Passed'); | SELECT COUNT(*) FROM inspections i JOIN vessels v ON i.vessel_id = v.id WHERE v.safety_score < 75 AND i.date BETWEEN '2021-01-01' AND '2021-12-31' AND v.type = 'Research' AND i.result = 'Passed'; |
Rank spacecraft by the number of missions they have had, with ties handled by the earliest launch date. | CREATE TABLE Spacecraft_Mission_Ranks (id INT,spacecraft_id INT,mission_name VARCHAR(100),mission_date DATE,launch_order INT); INSERT INTO Spacecraft_Mission_Ranks (id,spacecraft_id,mission_name,mission_date,launch_order) VALUES (1,1,'Apollo 11','1969-07-16',1); | SELECT spacecraft_id, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC, MIN(mission_date) ASC) as mission_rank FROM Spacecraft_Mission_Ranks GROUP BY spacecraft_id |
How many volunteers have signed up in each region over the last 6 months? | CREATE TABLE Volunteers (VolunteerID int,VolunteerName varchar(50),Region varchar(50),SignUpDate date); | SELECT Region, COUNT(*) AS NumberOfVolunteers, DATE_TRUNC('month', SignUpDate) AS Month FROM Volunteers WHERE SignUpDate >= CURRENT_DATE - INTERVAL '6 months' GROUP BY Region, Month ORDER BY Month; |
What is the average CO2 emission (tonnes) for vehicles in 'Germany'? | CREATE TABLE co2_emissions (vehicle_id INT,country VARCHAR(50),co2_emission FLOAT); INSERT INTO co2_emissions (vehicle_id,country,co2_emission) VALUES (1,'Germany',130.4),(2,'France',110.3); | SELECT AVG(co2_emission) FROM co2_emissions WHERE country = 'Germany'; |
What is the percentage of the population that has access to clean water in each country in South America? | CREATE TABLE WaterAccess (Country VARCHAR(255),Continent VARCHAR(255),AccessToCleanWater FLOAT); INSERT INTO WaterAccess (Country,Continent,AccessToCleanWater) VALUES ('Argentina','South America',100.0),('Bolivia','South America',92.1),('Brazil','South America',99.6),('Chile','South America',99.7),('Colombia','South Am... | SELECT Country, AccessToCleanWater FROM WaterAccess WHERE Continent = 'South America'; |
List all security incidents that involved user 'johndoe' and occurred in the last week, excluding any incidents related to phishing. | CREATE TABLE security_incidents (id INT,user VARCHAR(255),incident_date DATE,incident_type VARCHAR(255)); INSERT INTO security_incidents (id,user,incident_date,incident_type) VALUES (1,'johndoe','2022-01-02','Malware'); INSERT INTO security_incidents (id,user,incident_date,incident_type) VALUES (2,'johndoe','2022-01-05... | SELECT * FROM security_incidents WHERE user = 'johndoe' AND incident_date >= DATEADD(week, -1, GETDATE()) AND incident_type != 'Phishing'; |
What is the average daily return for all stocks in the 'America' region, ordered by return in descending order? | CREATE TABLE stocks (id INT,symbol VARCHAR(10),region VARCHAR(20),return DECIMAL(5,4)); INSERT INTO stocks (id,symbol,region,return) VALUES (1,'AAPL','Asia',0.0234); INSERT INTO stocks (id,symbol,region,return) VALUES (2,'GOOG','America',0.0187); INSERT INTO stocks (id,symbol,region,return) VALUES (3,'BABA','Asia',0.01... | SELECT region, AVG(return) as avg_return FROM stocks WHERE region = 'America' GROUP BY region ORDER BY avg_return DESC; |
Which sustainable material has the highest total revenue? | CREATE TABLE orders (id INT,product_id INT,quantity INT,price DECIMAL(5,2)); INSERT INTO orders (id,product_id,quantity,price) VALUES (1,1,2,30.00),(2,2,1,60.00),(3,4,1,40.00),(4,3,3,15.00); CREATE TABLE products (id INT,name VARCHAR(255),material VARCHAR(255),price DECIMAL(5,2)); INSERT INTO products (id,name,material... | SELECT material, SUM(quantity * price) as total_revenue FROM orders JOIN products ON orders.product_id = products.id WHERE products.material IN ('Organic Cotton', 'Recycled Polyester', 'Hemp') GROUP BY material ORDER BY total_revenue DESC LIMIT 1; |
What is the total quantity of seafood sold to each customer in the 'customer_sales' table? | CREATE TABLE customer_sales (customer VARCHAR(255),product VARCHAR(255),quantity INT); INSERT INTO customer_sales (customer,product,quantity) VALUES ('Alice','Tilapia',150),('Bob','Salmon',200),('Alice','Catfish',75),('Charlie','Tilapia',100),('Bob','Catfish',50),('Charlie','Salmon',75); | SELECT customer, SUM(quantity) as total_quantity FROM customer_sales GROUP BY customer; |
What is the percentage of culturally competent healthcare providers in Texas, based on language fluency? | CREATE TABLE healthcare_providers (id INT,name VARCHAR(50),location VARCHAR(50),language_fluency VARCHAR(50),culturally_competent BOOLEAN); INSERT INTO healthcare_providers (id,name,location,language_fluency,culturally_competent) VALUES (1,'John Doe','Texas','Spanish',TRUE),(2,'Jane Smith','Texas','English',FALSE); | SELECT location, PERCENTAGE(COUNT(*)) as percentage_culturally_competent FROM healthcare_providers WHERE location = 'Texas' AND language_fluency IN ('Spanish', 'English') AND culturally_competent = TRUE GROUP BY location; |
What is the diversity percentage of new hires in the last year, by department? | CREATE TABLE Employees (EmployeeID INT,FirstName VARCHAR(50),LastName VARCHAR(50),Department VARCHAR(50),HireDate DATE); INSERT INTO Employees (EmployeeID,FirstName,LastName,Department,HireDate) VALUES (1,'John','Doe','IT','2021-01-01'),(2,'Jane','Doe','HR','2021-06-15'),(3,'Mike','Johnson','IT','2021-03-20'),(4,'Sara'... | SELECT D.Department, COUNT(CASE WHEN DATEDIFF(year, E.HireDate, GETDATE()) = 1 THEN 1 END) / COUNT(*) * 100 AS DiversityPercentage FROM Employees E INNER JOIN Departments D ON E.Department = D.Department WHERE DATEDIFF(year, E.HireDate, GETDATE()) = 1 GROUP BY D.Department; |
What are the carbon prices for Canada, Mexico, and the United States? | CREATE TABLE carbon_pricing (country VARCHAR(50),price DECIMAL(5,2)); INSERT INTO carbon_pricing (country,price) VALUES ('Canada',20.50),('Mexico',5.25),('United States',0.00); | SELECT country, price FROM carbon_pricing WHERE country IN ('Canada', 'Mexico', 'United States'); |
Show the names of startups that have 'diverse' teams. | CREATE TABLE diversity (id INT,startup_name VARCHAR(50),team_diversity VARCHAR(10)); | SELECT startup_name FROM diversity WHERE team_diversity = 'diverse'; |
How many veteran-owned businesses are there in the state of California? | CREATE TABLE veteran_businesses (business_id INT,business_name TEXT,owner_type TEXT,state TEXT); | SELECT COUNT(*) FROM veteran_businesses WHERE state = 'California' AND owner_type = 'veteran'; |
What is the average age of visitors who attended exhibitions in Paris in 2020?' | CREATE TABLE Visitors (ID INT,Age INT,Gender VARCHAR(10),City VARCHAR(20),Country VARCHAR(20)); INSERT INTO Visitors (ID,Age,Gender,City,Country) VALUES (1,34,'Male','Paris','France'); CREATE TABLE Exhibitions (ID INT,Title VARCHAR(50),City VARCHAR(20),Country VARCHAR(20),Date DATE); INSERT INTO Exhibitions (ID,Title,C... | SELECT AVG(Visitors.Age) FROM Visitors INNER JOIN Exhibitions ON Visitors.City = Exhibitions.City AND Visitors.Country = Exhibitions.Country WHERE Exhibitions.Date BETWEEN '2020-01-01' AND '2020-12-31'; |
Find the total budget allocated to 'Policy Advocacy' in the first half of the fiscal year. | CREATE TABLE BudgetAllocations (ID INT,Category TEXT,Quarter INT,Amount FLOAT); INSERT INTO BudgetAllocations (ID,Category,Quarter,Amount) VALUES (1,'Policy Advocacy',1,10000.00),(2,'Policy Advocacy',2,15000.00),(3,'Disability Accommodations',1,20000.00); | SELECT SUM(Amount) FROM BudgetAllocations WHERE Category = 'Policy Advocacy' AND Quarter IN (1, 2); |
List the top 3 countries with the most visitors to the museum. | CREATE TABLE visitors (visitor_id INT,country VARCHAR(255)); INSERT INTO visitors (visitor_id,country) VALUES (123,'USA'),(456,'Canada'),(789,'Mexico'),(111,'France'),(222,'Germany'); | SELECT country, COUNT(*) AS visitor_count FROM visitors GROUP BY country ORDER BY visitor_count DESC LIMIT 3; |
What is the maximum price of cruelty-free skincare products sold in the UK? | CREATE TABLE skincare_sales(product_name TEXT,price DECIMAL(5,2),is_cruelty_free BOOLEAN,country TEXT); INSERT INTO skincare_sales VALUES ('Cleanser',10.99,true,'UK'); INSERT INTO skincare_sales VALUES ('Toner',8.99,true,'UK'); INSERT INTO skincare_sales VALUES ('Serum',15.99,false,'UK'); | SELECT MAX(price) FROM skincare_sales subquery WHERE subquery.is_cruelty_free = true AND subquery.country = 'UK' AND subquery.price = (SELECT MAX(price) FROM skincare_sales subquery2 WHERE subquery2.is_cruelty_free = true AND subquery2.country = 'UK'); |
What is the average ocean acidification level ('level') in the Indian Ocean ('ocean')? | CREATE TABLE ocean (id INT,name VARCHAR(50)); CREATE TABLE level (id INT,value FLOAT,ocean_id INT); INSERT INTO ocean (id,name) VALUES (1,'Atlantic'),(2,'Pacific'),(3,'Indian'); INSERT INTO level (id,value,ocean_id) VALUES (1,7.8,1),(2,7.9,2),(3,8.0,3),(4,7.7,3); | SELECT AVG(level.value) FROM level INNER JOIN ocean ON level.ocean_id = ocean.id WHERE ocean.name = 'Indian'; |
What is the total number of visitors for the "Art of the Renaissance" and "Modern Art" exhibitions? | CREATE TABLE Exhibitions (exhibition_name TEXT,visitor_count INTEGER); INSERT INTO Exhibitions (exhibition_name,visitor_count) VALUES ('Art of the Renaissance',3000),('Modern Art',4000); | SELECT SUM(visitor_count) FROM Exhibitions WHERE exhibition_name IN ('Art of the Renaissance', 'Modern Art'); |
What is the maximum solar power capacity (in MW) of solar power projects in India, completed in 2020? | CREATE TABLE solar_power_projects_capacity (id INT,project_type VARCHAR(255),project_date DATE,capacity INT); | SELECT project_type, MAX(capacity / 1000000) FROM solar_power_projects_capacity WHERE project_type = 'Solar Power' AND project_date BETWEEN '2020-01-01' AND '2020-12-31' GROUP BY project_type; |
What is the total number of autonomous vehicles in the London public transportation system? | CREATE TABLE vehicles (vehicle_id INT,is_autonomous BOOLEAN,system_type VARCHAR(20)); INSERT INTO vehicles (vehicle_id,is_autonomous,system_type) VALUES (1,true,'Public Transportation'),(2,false,'Public Transportation'),(3,true,'Personal'); | SELECT COUNT(*) FROM vehicles WHERE is_autonomous = true AND system_type = 'Public Transportation'; |
What was the total number of emergency incidents reported in the Bronx and Brooklyn in 2021? | CREATE TABLE emergency_incidents (id INT,location VARCHAR(255),incident_type VARCHAR(255),reported_date DATE); INSERT INTO emergency_incidents (id,location,incident_type,reported_date) VALUES (1,'Bronx','Fire','2021-01-01'); INSERT INTO emergency_incidents (id,location,incident_type,reported_date) VALUES (2,'Brooklyn',... | SELECT SUM(number_of_incidents) FROM (SELECT location, COUNT(*) as number_of_incidents FROM emergency_incidents WHERE location IN ('Bronx', 'Brooklyn') AND reported_date >= '2021-01-01' AND reported_date < '2022-01-01' GROUP BY location) as incident_counts; |
What is the total playtime for players who own a VR headset and have played games in the Action genre? | CREATE TABLE players_vr (player_id INT,vr_headset TEXT); INSERT INTO players_vr VALUES (1,'Oculus Rift'),(2,'HTC Vive'),(3,'Valve Index'); CREATE TABLE games (game_id INT,game_name TEXT,genre TEXT); INSERT INTO games VALUES (1,'Game 1','Action'),(2,'Game 2','Simulation'); CREATE TABLE player_games (player_id INT,game_i... | SELECT SUM(player_games.playtime) FROM player_games JOIN players_vr ON player_games.player_id = players_vr.player_id JOIN games ON player_games.game_id = games.game_id WHERE players_vr.vr_headset IS NOT NULL AND games.genre = 'Action'; |
What was the combined cost of the Hubble Space Telescope and the Spitzer Space Telescope? | CREATE TABLE telescope_costs (id INT,telescope VARCHAR(50),cost FLOAT);INSERT INTO telescope_costs (id,telescope,cost) VALUES (1,'Hubble Space Telescope',4700000000.0); | SELECT SUM(cost) FROM telescope_costs WHERE telescope IN ('Hubble Space Telescope', 'Spitzer Space Telescope'); |
List all community health workers who have a cultural competency score greater than or equal to 90 | CREATE TABLE healthcare.CommunityHealthWorker(worker_id INT PRIMARY KEY,name VARCHAR(100),cultural_competency_score FLOAT); INSERT INTO healthcare.CommunityHealthWorker (worker_id,name,cultural_competency_score) VALUES (1,'Jane Smith',85.5),(2,'Maria Garcia',92.3),(3,'David Kim',88.7),(4,'Fatima Patel',93.1); | SELECT * FROM healthcare.CommunityHealthWorker WHERE cultural_competency_score >= 90; |
Find the total volume of timber produced by each tree type in mature_forest table. | CREATE TABLE mature_forest (id INT,tree_type VARCHAR(255),planted_date DATE,volume INT); | SELECT tree_type, SUM(volume) FROM mature_forest GROUP BY tree_type; |
What is the maximum number of hospital beds in rural hospitals of Georgia that have less than 200 beds? | 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','Georgia',180,true),(2,'Hospital B','Georgia',150,true); | SELECT MAX(beds) FROM hospitals WHERE location = 'Georgia' AND rural = true AND beds < 200; |
Calculate the total funds raised by underrepresented founders in the technology sector. | CREATE TABLE founders (id INT,name TEXT,race TEXT,industry TEXT,funds_raised FLOAT); INSERT INTO founders (id,name,race,industry,funds_raised) VALUES (1,'Alice','Asian','Technology',5000000),(2,'Bob','Black','Finance',2000000),(3,'Charlie','Latinx','Technology',3000000),(4,'Diana','White','Technology',1000000),(5,'Eve'... | SELECT SUM(funds_raised) FROM founders WHERE industry = 'Technology' AND race NOT IN ('White'); |
Insert a new record into the "electric_vehicles" table with the following values: "2023", "Nissan", "Leaf", 250, "2023-01-01" | CREATE TABLE electric_vehicles (year INT,make VARCHAR(50),model VARCHAR(50),range INT,PRIMARY KEY (year,make,model)); | INSERT INTO electric_vehicles (year, make, model, range, last_updated) VALUES (2023, 'Nissan', 'Leaf', 250, '2023-01-01'); |
What is the average data usage in gigabytes per month for customers in the state of New York? | CREATE TABLE customers_usa (customer_id INT,name VARCHAR(255),state VARCHAR(255)); INSERT INTO customers_usa (customer_id,name,state) VALUES (1,'John Doe','California'),(2,'Jane Smith','New York'); CREATE TABLE data_usage_usa (customer_id INT,monthly_data_usage DECIMAL(10,2)); INSERT INTO data_usage_usa (customer_id,mo... | SELECT AVG(monthly_data_usage) FROM data_usage_usa INNER JOIN customers_usa ON data_usage_usa.customer_id = customers_usa.customer_id WHERE state = 'New York'; |
What was the total cost of all construction projects in the city of Austin, TX in the year 2020? | CREATE TABLE ConstructionProjects (id INT,city VARCHAR(50),state VARCHAR(50),cost FLOAT,year INT); | SELECT SUM(cost) FROM ConstructionProjects WHERE city = 'Austin' AND year = 2020; |
What is the percentage of patients who improved after 3 months of therapy in New Delhi? | CREATE TABLE progress (progress_id INT,patient_id INT,progress_date DATE,improvement_status TEXT,city TEXT); INSERT INTO progress (progress_id,patient_id,progress_date,improvement_status,city) VALUES (1,1,'2018-03-01','Improved','New Delhi'); | SELECT 100.0 * COUNT(CASE WHEN improvement_status = 'Improved' THEN 1 END) / COUNT(*) as percentage FROM progress WHERE city = 'New Delhi' AND EXTRACT(MONTH FROM progress_date) = 3 AND EXTRACT(YEAR FROM progress_date) = EXTRACT(YEAR FROM progress_date) - 3; |
Which claims were processed by the claims adjuster 'Hiroshi Tanaka'? | CREATE TABLE claim (claim_id INT,processed_by VARCHAR(50)); INSERT INTO claim VALUES (1,'Laura Smith'); INSERT INTO claim VALUES (2,'Hiroshi Tanaka'); | SELECT claim_id FROM claim WHERE processed_by = 'Hiroshi Tanaka'; |
Identify top 5 products with highest sales in the last 6 months | CREATE TABLE products (product_id INT PRIMARY KEY,product_name VARCHAR(50)); CREATE TABLE sales (sale_id INT PRIMARY KEY,product_id INT,sale_date DATE,quantity INT,price DECIMAL(10,2)); | SELECT p.product_name, SUM(s.quantity * s.price) AS total_sales FROM products p JOIN sales s ON p.product_id = s.product_id WHERE s.sale_date >= DATE_SUB(NOW(), INTERVAL 6 MONTH) GROUP BY p.product_id ORDER BY total_sales DESC LIMIT 5; |
Find the average temperature and humidity for the crops in field 3 during the last week. | CREATE TABLE field_sensors (field_id INT,sensor_type VARCHAR(20),value FLOAT,timestamp TIMESTAMP); INSERT INTO field_sensors (field_id,sensor_type,value,timestamp) VALUES (3,'temperature',28.5,'2023-02-15 10:00:00'),(3,'humidity',35.0,'2023-02-15 10:00:00'); | SELECT field_id, AVG(value) FROM field_sensors WHERE sensor_type IN ('temperature', 'humidity') AND timestamp >= NOW() - INTERVAL 7 DAY GROUP BY field_id; |
Find the number of natural haircare products sold in Canada and the United States in Q1 of 2021 | CREATE TABLE HaircareSales (sale_id INT,product_name TEXT,is_natural BOOLEAN,sale_amount FLOAT,sale_date DATE,country TEXT); INSERT INTO HaircareSales (sale_id,product_name,is_natural,sale_amount,sale_date,country) VALUES (1,'Natural Shampoo',TRUE,15.00,'2021-01-05','Canada'); INSERT INTO HaircareSales (sale_id,product... | SELECT COUNT(*) FROM HaircareSales WHERE is_natural = TRUE AND (country = 'Canada' OR country = 'United States') AND QUARTER(sale_date) = 1 AND YEAR(sale_date) = 2021; |
How many size 10 customers have not made a purchase in the last year? | CREATE TABLE customers(id INT PRIMARY KEY,size INT,last_purchase DATE); INSERT INTO customers(id,size,last_purchase) VALUES (1,16,'2022-01-15'),(2,12,'2022-02-01'),(3,10,'2021-02-10'),(4,14,'2021-05-01'),(5,10,'2020-12-31'); | SELECT COUNT(*) FROM customers WHERE size = 10 AND last_purchase <= DATE_SUB(CURDATE(), INTERVAL 1 YEAR); |
Which countries in Africa have delivery times for textile shipments greater than 14 days, and what are their average delivery times? | CREATE TABLE Shipments (id INT,product_id INT,source_country VARCHAR(50),delivery_time INT); INSERT INTO Shipments (id,product_id,source_country,delivery_time) VALUES (1,1,'Africa',14),(2,2,'Asia',10); | SELECT source_country, AVG(delivery_time) FROM Shipments WHERE source_country IN ('Nigeria', 'Kenya', 'Ethiopia') AND delivery_time > 14 GROUP BY source_country; |
Display the top 3 songs with the highest revenue in descending order. | CREATE TABLE SongRevenue (SongID INT,Revenue DECIMAL(10,2)); INSERT INTO SongRevenue (SongID,Revenue) VALUES (1,1000); INSERT INTO SongRevenue (SongID,Revenue) VALUES (2,2000); INSERT INTO SongRevenue (SongID,Revenue) VALUES (3,3000); | SELECT SongID, Revenue FROM SongRevenue ORDER BY Revenue DESC LIMIT 3; |
Get the number of military equipment maintenance requests for each branch of the military | CREATE TABLE military_equipment (equipment_id INT,branch VARCHAR(10),maintenance_requested BOOLEAN); | SELECT branch, COUNT(*) FROM military_equipment WHERE maintenance_requested = TRUE GROUP BY branch; |
List all metro stations with bike-sharing facilities in Paris and Rome. | CREATE TABLE paris_metro (station_id INT,station_name VARCHAR(50),has_bikes BOOLEAN); INSERT INTO paris_metro (station_id,station_name,has_bikes) VALUES (1,'Gare du Nord',true),(2,'Châtelet',false),(3,'Bastille',true); CREATE TABLE rome_metro (station_id INT,station_name VARCHAR(50),has_bikes BOOLEAN); INSERT INTO rome... | SELECT station_name FROM paris_metro WHERE has_bikes = true UNION SELECT station_name FROM rome_metro WHERE has_bikes = true; |
How many professional development courses did each teacher complete in 2020? | CREATE TABLE teacher_development (teacher_id INT,course_year INT,courses_completed INT); INSERT INTO teacher_development (teacher_id,course_year,courses_completed) VALUES (101,2018,3),(101,2019,2),(101,2020,5),(102,2018,4),(102,2019,1),(102,2020,6); | SELECT teacher_id, SUM(courses_completed) FROM teacher_development WHERE course_year = 2020 GROUP BY teacher_id; |
What is the total number of police reports and 911 calls in the city of Houston? | CREATE TABLE houston_police_reports (id INT,report_type VARCHAR(255),report_date TIMESTAMP); INSERT INTO houston_police_reports (id,report_type,report_date) VALUES (1,'Burglary','2022-01-01 12:00:00'); CREATE TABLE houston_ninety_one_calls (id INT,call_type VARCHAR(255),call_date TIMESTAMP); INSERT INTO houston_ninety_... | SELECT COUNT(*) FROM houston_police_reports UNION ALL SELECT COUNT(*) FROM houston_ninety_one_calls; |
What is the total number of COVID-19 cases in each city by ZIP code? | CREATE TABLE covid_cases (case_id INT,date DATE,zip_code VARCHAR(10),city VARCHAR(20),cases INT); INSERT INTO covid_cases VALUES (1,'2021-01-01','10001','New York City',5),(2,'2021-01-02','10002','New York City',3),(3,'2021-01-03','10001','New York City',7); INSERT INTO covid_cases VALUES (4,'2021-01-01','20001','Chica... | SELECT city, zip_code, SUM(cases) FROM covid_cases GROUP BY city, zip_code; |
Update the 'score' column by adding 10 for all 'games' records where 'player_id' is 2 | CREATE TABLE games (id INT,player_id INT,score INT); | UPDATE games SET score = score + 10 WHERE player_id = 2; |
What is the total quantity of resources extracted by month and year, and the resource type? | CREATE TABLE Resources (ResourceID INT,ResourceType VARCHAR(10),ExtractionDate DATE,Quantity INT); | SELECT EXTRACT(MONTH FROM ExtractionDate) AS Month, EXTRACT(YEAR FROM ExtractionDate) AS Year, ResourceType, SUM(Quantity) FROM Resources GROUP BY EXTRACT(MONTH FROM ExtractionDate), EXTRACT(YEAR FROM ExtractionDate), ResourceType; |
What is the total weight of all sharks in the 'shark_population' table, grouped by species? | CREATE TABLE shark_population (shark_id INTEGER,species TEXT,weight REAL); INSERT INTO shark_population (shark_id,species,weight) VALUES (1,'Great White',750.2),(2,'Tiger Shark',450.1),(3,'Great White',800.3); | SELECT species, SUM(weight) FROM shark_population GROUP BY species; |
List all the unique sectors in the 'disaster_response' schema. | CREATE TABLE disaster_response.sectors (sector_id INT,sector_name VARCHAR(255)); INSERT INTO disaster_response.sectors (sector_id,sector_name) VALUES (1,'Education'),(2,'Health'),(3,'Water'),(4,'Shelter'); | SELECT DISTINCT sector_name FROM disaster_response.sectors; |
Find the element with the lowest production quantity for each month. | CREATE TABLE production (id INT,country VARCHAR(255),element VARCHAR(255),quantity INT,month INT,year INT); INSERT INTO production (id,country,element,quantity,month,year) VALUES (1,'China','Lutetium',300,1,2021),(2,'China','Lutetium',250,2,2021),(3,'USA','Lutetium',200,1,2021),(4,'USA','Lutetium',150,2,2021); | SELECT country, element, min(quantity) as min_quantity FROM production GROUP BY country, element, month, year HAVING min_quantity = min(min_quantity) OVER (PARTITION BY country); |
What percentage of tourists visiting Japan are from Asia? | CREATE TABLE tourists (tourist_id INT,country_of_origin VARCHAR(50),destination VARCHAR(50)); | SELECT 100.0 * COUNT(*) / (SELECT COUNT(*) FROM tourists) as percentage FROM tourists WHERE country_of_origin = 'Asia' AND destination = 'Japan'; |
What is the number of concerts in Canada for artists from underrepresented communities? | CREATE TABLE Artists (ArtistID int,ArtistName varchar(100),Community varchar(50),Country varchar(50)); INSERT INTO Artists (ArtistID,ArtistName,Community,Country) VALUES (1,'Tanya Tagaq','Indigenous','Canada'),(2,'A Tribe Called Red','Indigenous','Canada'),(3,'B.B. King','African American','United States'); CREATE TABL... | SELECT COUNT(DISTINCT Concerts.ConcertID) as NumberOfConcerts FROM Artists JOIN Concerts ON Artists.ArtistID = Concerts.ArtistID WHERE Artists.Community = 'Indigenous' AND Concerts.Country = 'Canada'; |
List the marine research projects in descending order by their budget and rank them by tier based on their budget percentile. | CREATE TABLE marine_research_projects (id INT,name VARCHAR(255),location VARCHAR(255),budget DECIMAL(10,2)); INSERT INTO marine_research_projects (id,name,location,budget) VALUES (1,'Coral Reef Study','Indian Ocean',250000.00),(2,'Ocean Current Analysis','Atlantic Ocean',350000.00); | SELECT name, budget, NTILE(4) OVER (ORDER BY budget DESC) tier_rank FROM marine_research_projects; |
Create a table 'climate_mitigation_projects' | CREATE TABLE climate_mitigation_projects (id INT PRIMARY KEY,name VARCHAR(50),location VARCHAR(50),start_date DATE,end_date DATE,budget FLOAT); | CREATE TABLE climate_mitigation_projects (id INT PRIMARY KEY, name VARCHAR(50), location VARCHAR(50), start_date DATE, end_date DATE, budget FLOAT); |
What is the minimum budget of documentaries produced in Africa and released after 2015? | CREATE TABLE Documentaries (id INT,title VARCHAR(100),budget INT,production_country VARCHAR(50),release_year INT); INSERT INTO Documentaries (id,title,budget,production_country,release_year) VALUES (1,'Documentary1',3000000,'Africa',2016),(2,'Documentary2',5000000,'Africa',2018),(3,'Documentary3',4000000,'Africa',2017)... | SELECT MIN(budget) FROM Documentaries WHERE production_country = 'Africa' AND release_year > 2015; |
What is the average threat intelligence score for each country in the month of June 2022? | CREATE TABLE ThreatIntelligence (ID int,Country varchar(50),ThreatScore numeric(5,2),ThreatDate date); INSERT INTO ThreatIntelligence (ID,Country,ThreatScore,ThreatDate) VALUES (1,'USA',7.5,'2022-06-01'),(2,'Canada',6.2,'2022-06-03'),(3,'Mexico',8.8,'2022-06-05'),(4,'USA',7.2,'2022-06-07'),(5,'Canada',6.5,'2022-06-09')... | SELECT Country, AVG(ThreatScore) as AverageScore FROM ThreatIntelligence WHERE ThreatDate BETWEEN '2022-06-01' AND '2022-06-30' GROUP BY Country; |
Identify the number of companies founded in each country that have received funding from both VCs and angel investors, excluding companies that have also received funding from crowdfunding platforms. | CREATE TABLE Companies (id INT,name TEXT,country TEXT); CREATE TABLE Funding (id INT,company_id INT,investor_type TEXT,amount INT,funding_round TEXT); INSERT INTO Companies (id,name,country) VALUES (1,'Multi Funding','India'),(2,'No Crowdfunding','USA'); INSERT INTO Funding (id,company_id,investor_type,amount,funding_r... | SELECT Companies.country, COUNT(DISTINCT Companies.id) as company_count FROM Companies INNER JOIN Funding funding_vc ON Companies.id = funding_vc.company_id INNER JOIN Funding funding_angel ON Companies.id = funding_angel.company_id WHERE funding_vc.investor_type = 'VC' AND funding_angel.investor_type = 'Angel' AND Com... |
Delete records of manufacturers who have not used any sustainable materials. | CREATE TABLE Manufacturers (ManufacturerID INT,ManufacturerName VARCHAR(50),Region VARCHAR(50)); INSERT INTO Manufacturers (ManufacturerID,ManufacturerName,Region) VALUES (1,'EcoFriendlyFabrics','Europe'),(2,'GreenYarns','Asia'); CREATE TABLE ManufacturersSustainableMaterials (ManufacturerID INT,MaterialID INT); INSERT... | DELETE FROM Manufacturers WHERE ManufacturerID NOT IN (SELECT ManufacturerID FROM ManufacturersSustainableMaterials); |
How many goals has each player scored, and how many games have they played, in the soccer_matches table? | CREATE TABLE soccer_matches (player VARCHAR(50),goals INT,match_date DATE); | SELECT player, SUM(goals) AS total_goals, COUNT(DISTINCT match_date) AS games_played FROM soccer_matches GROUP BY player; |
What is the average production cost of companies in Germany? | CREATE TABLE companies (company_id INT,name TEXT,production_cost FLOAT,country TEXT); INSERT INTO companies (company_id,name,production_cost,country) VALUES (1,'GreenFashions',15000,'Germany'); INSERT INTO companies (company_id,name,production_cost,country) VALUES (2,'EcoFabrics',12000,'Germany'); | SELECT AVG(production_cost) FROM companies WHERE country = 'Germany'; |
What are the names of unique freight forwarders operating in countries with more than 3 fulfillment centers? | CREATE TABLE FreightForwarder (FFID INT,FFName TEXT,Country TEXT); INSERT INTO FreightForwarder (FFID,FFName,Country) VALUES (1,'Global Freight','USA'),(2,'Northern Shipping','Canada'),(3,'Pacific Logistics','Australia'),(4,'African Logistics','SouthAfrica'); CREATE TABLE FulfillmentCenter (FCID INT,FCName TEXT,Country... | SELECT DISTINCT FFName, Country FROM FreightForwarder WHERE Country IN (SELECT Country FROM FulfillmentCenter GROUP BY Country HAVING COUNT(DISTINCT FCID) > 3); |
What is the average capacity of vessels owned by company 'JKL Transport'? | CREATE TABLE companies (id INT,name VARCHAR(20)); INSERT INTO companies (id,name) VALUES (1,'ABC Shipping'),(2,'JKL Transport'),(3,'MNO Freight'); CREATE TABLE vessels (id INT,capacity INT,company_id INT); INSERT INTO vessels (id,capacity,company_id) VALUES (1,5000,1),(2,7000,1),(3,6000,2),(4,8000,2),(5,9000,3); | SELECT AVG(capacity) FROM vessels WHERE company_id = (SELECT id FROM companies WHERE name = 'JKL Transport'); |
Which art program received the most funding in 2019? | CREATE TABLE programs (program_id INT,program_name VARCHAR(50),program_type VARCHAR(50)); CREATE TABLE funding (funding_id INT,program_id INT,amount INT,funding_date DATE); INSERT INTO programs (program_id,program_name,program_type) VALUES (1,'Art Education','Education'),(2,'Symphony Orchestra','Music'); INSERT INTO fu... | SELECT programs.program_name, MAX(funding.amount) FROM programs INNER JOIN funding ON programs.program_id = funding.program_id WHERE YEAR(funding_date) = 2019 GROUP BY programs.program_name; |
Identify the country of origin with the lowest total quantity of unsustainable fabric orders, in the current year. | CREATE TABLE Suppliers (SupplierID INT,SupplierName VARCHAR(50),Country VARCHAR(50),Sustainable BOOLEAN); INSERT INTO Suppliers (SupplierID,SupplierName,Country,Sustainable) VALUES (1,'Green Textiles','Brazil',false),(2,'Fashion Fabrics','China',true),(3,'Eco-Friendly Materials','India',false); CREATE TABLE PurchaseOrd... | SELECT s.Country, SUM(po.Quantity) as TotalQuantity FROM Suppliers s INNER JOIN PurchaseOrders po ON s.SupplierID = po.SupplierID WHERE s.Sustainable = false AND YEAR(po.OrderDate) = YEAR(GETDATE()) GROUP BY s.Country HAVING MIN(TotalQuantity); |
What is the average biomass of fish in the Indian Ocean? | CREATE TABLE indian_fish_stock (id INT,species VARCHAR(255),biomass INT); INSERT INTO indian_fish_stock (id,species,biomass) VALUES (1,'Tuna',400000),(2,'Swordfish',300000),(3,'Marlin',450000); | SELECT AVG(biomass) AS avg_biomass FROM indian_fish_stock; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.