instruction stringlengths 0 1.06k | input stringlengths 11 5.3k | response stringlengths 2 4.44k |
|---|---|---|
What is the maximum daily production for each well in the Eagle Ford Shale, grouped by county and well name? | CREATE TABLE eagle_ford_wells (well_id INT,well_name VARCHAR(100),county VARCHAR(50),shale VARCHAR(50),production FLOAT);INSERT INTO eagle_ford_wells (well_id,well_name,county,shale,production) VALUES (1,'Well D','La Salle','Eagle Ford',20000),(2,'Well E','Fayette','Eagle Ford',22000),(3,'Well F','De Witt','Eagle Ford',25000); | SELECT county, well_name, MAX(production) FROM eagle_ford_wells WHERE shale = 'Eagle Ford' GROUP BY county, well_name; |
What are the names of donors who are older than 50% of recipients? | CREATE TABLE Donors (Id INT,Name VARCHAR(50),Age INT,Amount DECIMAL(10,2)); INSERT INTO Donors (Id,Name,Age,Amount) VALUES (1,'Grace Wilson',53,1200.00),(2,'Evelyn Thompson',58,1500.00),(3,'Violet Walker',63,1800.00); CREATE TABLE Recipients (Id INT,Name VARCHAR(50),Age INT,Amount DECIMAL(10,2)); INSERT INTO Recipients (Id,Name,Age,Amount) VALUES (1,'Refugee Aid',30,1100.00),(2,'Animal Welfare',35,1400.00),(3,'Arts and Culture',40,1700.00); | SELECT Name FROM Donors WHERE Age > (SELECT AVG(Age) FROM Recipients); |
Delete all grant records for faculty members who do not have a research interest in 'Physics'. | CREATE TABLE grants (id INT,title TEXT,amount FLOAT,faculty_name VARCHAR(50)); CREATE TABLE faculty (id INT,name VARCHAR(50),research_interest TEXT); INSERT INTO grants (id,title,amount,faculty_name) VALUES (1,'Fundamentals of Organic Chemistry',50000,'Alice'); INSERT INTO grants (id,title,amount,faculty_name) VALUES (2,'Advanced Physical Chemistry',75000,'Bob'); INSERT INTO faculty (id,name,research_interest) VALUES (1,'Alice','Chemistry'); INSERT INTO faculty (id,name,research_interest) VALUES (2,'Bob','Physics'); | DELETE g FROM grants g INNER JOIN faculty f ON g.faculty_name = f.name WHERE f.research_interest != 'Physics'; |
What is the total revenue for each region? | CREATE TABLE Restaurants (id INT,name VARCHAR(50),region VARCHAR(50),revenue INT); INSERT INTO Restaurants (id,name,region,revenue) VALUES (1,'Asian Fusion','North',60000),(2,'Bistro Bella','South',75000),(3,'Tacos & More','East',45000); | SELECT region, SUM(revenue) as total_revenue FROM Restaurants GROUP BY region; |
Delete records from the cultural competency table where language is not Spanish or English. | CREATE TABLE CulturalCompetency (PatientID int,Language varchar(10)); INSERT INTO CulturalCompetency (PatientID,Language) VALUES (1,'Spanish'),(2,'English'),(3,'French'),(4,'Mandarin'),(5,'English'),(6,'Spanish'); | DELETE FROM CulturalCompetency WHERE Language NOT IN ('Spanish', 'English'); |
List all mental health conditions and their corresponding treatment approaches that have been implemented in the African region. | CREATE TABLE conditions (id INT,name VARCHAR(50)); CREATE TABLE treatments (id INT,condition_id INT,name VARCHAR(50),region VARCHAR(50)); INSERT INTO conditions (id,name) VALUES (1,'Anxiety Disorder'); INSERT INTO treatments (id,condition_id,name,region) VALUES (1,1,'Cognitive Behavioral Therapy','Africa'); | SELECT conditions.name, treatments.name FROM conditions INNER JOIN treatments ON conditions.id = treatments.condition_id WHERE treatments.region = 'Africa'; |
Find the total revenue for each product category, partitioned by year, ordered by product name? | CREATE TABLE Sales (SaleID INT,ProductID INT,ProductName VARCHAR(50),ProductCategory VARCHAR(50),Year INT,Revenue INT); INSERT INTO Sales VALUES (1,1,'ProductA','CategoryA',2020,1000),(2,2,'ProductB','CategoryB',2021,1500); | SELECT ProductName, SUM(Revenue) OVER (PARTITION BY ProductCategory, Year ORDER BY ProductName) AS TotalRevenueByProduct FROM Sales; |
What is the minimum safety stock level for chemical W? | CREATE TABLE SafetyStock (id INT,chemical VARCHAR(255),level INT); INSERT INTO SafetyStock (id,chemical,level) VALUES (1,'chemical W',200),(2,'chemical V',150); | SELECT MIN(level) FROM SafetyStock WHERE chemical = 'chemical W'; |
What is the total number of photos taken by all photographers in the photo_data table? | CREATE TABLE photo_data (id INT,photographer_name TEXT,photo_count INT); INSERT INTO photo_data (id,photographer_name,photo_count) VALUES (1,'James Wilson',600); INSERT INTO photo_data (id,photographer_name,photo_count) VALUES (2,'Nancy Adams',400); | SELECT SUM(photo_count) FROM photo_data; |
Which countries have experienced the highest number of cybersecurity threats in the last 5 years? | CREATE TABLE CyberThreats (id INT,year INT,country TEXT,threats INT); INSERT INTO CyberThreats (id,year,country,threats) VALUES (1,2018,'USA',5000),(2,2017,'China',4000); | SELECT CyberThreats.country, SUM(CyberThreats.threats) as total_threats FROM CyberThreats WHERE CyberThreats.year BETWEEN 2017 AND 2022 GROUP BY CyberThreats.country ORDER BY total_threats DESC LIMIT 5; |
Which machine type has the highest zinc production? | CREATE TABLE zinc_production (id INT,machine_type VARCHAR(20),zinc_production FLOAT); INSERT INTO zinc_production (id,machine_type,zinc_production) VALUES (1,'TypeA',1200.5),(2,'TypeB',1500.3),(3,'TypeA',1300.0),(4,'TypeC',1800.5); | SELECT machine_type, MAX(zinc_production) as max_production FROM zinc_production; |
Calculate the maximum and minimum funding amounts for startups in the "fintech" sector | CREATE TABLE funding (startup_id INT,amount INT,sector VARCHAR(20)); | SELECT MAX(funding.amount), MIN(funding.amount) FROM funding INNER JOIN startups ON funding.startup_id = startups.id WHERE startups.sector = 'fintech'; |
What is the average attendance at cultural events in 'CityA' and 'CityB' from the 'CulturalEvents' table? | CREATE TABLE CulturalEvents (City VARCHAR(50),EventType VARCHAR(50),Attendance INT); INSERT INTO CulturalEvents (City,EventType,Attendance) VALUES ('CityA','Theater',450),('CityA','Concert',600),('CityA','Museum',700),('CityB','Theater',550),('CityB','Concert',750),('CityB','Museum',850); | SELECT AVG(Attendance) AS AvgAttendance FROM CulturalEvents WHERE City IN ('CityA', 'CityB'); |
Update mining site records with new productivity metrics, preserving the original records. | CREATE TABLE NewProductivity(SiteID INT,NewProductivity FLOAT); INSERT INTO NewProductivity VALUES (1,55.3),(2,51.9),(3,57.6),(4,53.1); | UPDATE MiningSites SET Productivity = (SELECT NewProductivity FROM NewProductivity WHERE MiningSites.SiteID = NewProductivity.SiteID); |
How many vessels arrived in Canada before April 2021 with a speed greater than 15 knots? | CREATE TABLE vessel_performance (id INT,name TEXT,speed DECIMAL(5,2),arrived_date DATE,country TEXT); INSERT INTO vessel_performance (id,name,speed,arrived_date,country) VALUES (1,'Vessel A',18.5,'2021-03-12','Canada'),(2,'Vessel B',14.2,'2021-04-05','Canada'),(3,'Vessel C',16.8,'2021-02-20','Canada'); | SELECT COUNT(*) FROM vessel_performance WHERE arrived_date < '2021-04-01' AND speed > 15 AND country = 'Canada'; |
What is the average number of volunteer hours per volunteer per month? | CREATE TABLE volunteer_hours_2 (id INT,volunteer_name VARCHAR(50),volunteer_date DATE,volunteer_hours INT); INSERT INTO volunteer_hours_2 (id,volunteer_name,volunteer_date,volunteer_hours) VALUES (1,'Alice','2022-01-01',10),(2,'Bob','2022-01-15',15),(3,'Alice','2022-02-01',12); | SELECT volunteer_name, AVG(volunteer_hours) as avg_volunteer_hours FROM (SELECT volunteer_name, DATE_TRUNC('month', volunteer_date) as month, volunteer_hours FROM volunteer_hours_2) subquery GROUP BY volunteer_name; |
What is the average donation for each cause by the top 3 donors? | CREATE TABLE cause_donations (donor_id INT,donation_amount DECIMAL(10,2),cause_id INT); INSERT INTO cause_donations (donor_id,donation_amount,cause_id) VALUES (1,5000.00,1),(2,7500.00,1),(3,12000.00,1),(4,3000.00,2),(5,1500.00,2),(6,2000.00,2); | SELECT cause_id, AVG(donation_amount) AS avg_donation FROM (SELECT cause_id, donation_amount, ROW_NUMBER() OVER (PARTITION BY cause_id ORDER BY donation_amount DESC) AS donor_rank FROM cause_donations) donor_averages WHERE donor_rank <= 3 GROUP BY cause_id; |
Who is responsible for AI governance in the EU? | CREATE TABLE ai_governance (id INT,organization VARCHAR(50),region VARCHAR(50)); INSERT INTO ai_governance (id,organization,region) VALUES (1,'European Commission','EU'),(2,'AI Ethics Board','Canada'),(3,'Data Protection Authority','Germany'); | SELECT organization FROM ai_governance WHERE region = 'EU'; |
How many renewable energy plants are there in India? | CREATE TABLE renewable_energy_plants_india (id INT,name TEXT); INSERT INTO renewable_energy_plants_india (id,name) VALUES (1,'Plant 1'),(2,'Plant 2'),(3,'Plant 3'); | SELECT COUNT(*) FROM renewable_energy_plants_india; |
What is the total number of customers and total revenue for each sales region? | CREATE TABLE sales (sales_region VARCHAR(255),product_category VARCHAR(255),sale_date DATE,revenue DECIMAL(10,2)); INSERT INTO sales (sales_region,product_category,sale_date,revenue) VALUES ('Northeast','Electronics','2022-01-02',500.00),('Northeast','Fashion','2022-01-03',300.00),('Midwest','Home Appliances','2022-01-04',700.00); | SELECT sales_region, COUNT(DISTINCT customer_id) as total_customers, SUM(revenue) as total_revenue FROM sales GROUP BY sales_region; |
Which vessels visited the port of Vancouver in the last week of August? | CREATE TABLE ports (id INT,name VARCHAR(255)); CREATE TABLE vessel_movements (id INT,vessel_id INT,departure_port_id INT,arrival_port_id INT,speed DECIMAL(5,2),date DATE); INSERT INTO ports (id,name) VALUES (1,'Vancouver'); INSERT INTO vessel_movements (id,vessel_id,departure_port_id,arrival_port_id,speed,date) VALUES (1,101,1,2,15.2,'2022-08-22'),(2,102,1,2,17.3,'2022-08-25'),(3,103,1,2,14.8,'2022-08-30'),(4,104,3,1,18.5,'2022-07-05'); | SELECT DISTINCT vessel_id FROM vessel_movements WHERE arrival_port_id = (SELECT id FROM ports WHERE name = 'Vancouver') AND date BETWEEN '2022-08-22' AND '2022-08-30'; |
Present the number of evidence-based policy decisions made in each government department | CREATE TABLE policy_decisions (decision_id INT,topic VARCHAR(255),department VARCHAR(255),evidence_based BOOLEAN); INSERT INTO policy_decisions (decision_id,topic,department,evidence_based) VALUES (1,'Transportation','Department of Transportation',TRUE); INSERT INTO policy_decisions (decision_id,topic,department,evidence_based) VALUES (2,'Education','Department of Education',TRUE); | SELECT department, COUNT(*) FROM policy_decisions WHERE evidence_based = TRUE GROUP BY department; |
What is the total playtime of all players who have played the game "Space Pirates" for more than 5 hours in the last week? | CREATE TABLE playtime (id INT,player_id INT,game VARCHAR(50),playtime FLOAT); INSERT INTO playtime VALUES (1,1,'Space Pirates',360.5); INSERT INTO playtime VALUES (2,2,'Space Pirates',420.75); | SELECT SUM(playtime) FROM playtime WHERE game = 'Space Pirates' AND playtime > 5 * 60; |
What is the total recycling rate for Oceania countries? | CREATE TABLE RecyclingRates (country VARCHAR(50),recycling_rate FLOAT); INSERT INTO RecyclingRates (country,recycling_rate) VALUES ('Australia',0.3),('New Zealand',0.4); | SELECT SUM(recycling_rate) FROM RecyclingRates WHERE country IN ('Australia', 'New Zealand'); |
Insert new records of policy changes in the 'Healthcare' area in the last month. | CREATE TABLE policy_changes (id INT,area VARCHAR(255),change_date DATE,description TEXT); INSERT INTO policy_changes (id,area,change_date,description) VALUES (1,'Healthcare','2022-06-01','Change 1'),(2,'Healthcare','2022-05-15','Change 2'),(3,'Healthcare','2022-07-04','Change 3'); | INSERT INTO policy_changes (id, area, change_date, description) VALUES (4, 'Healthcare', '2022-06-10', 'New Policy'), (5, 'Healthcare', '2022-06-25', 'Updated Guidelines'); |
What's the average safety score for AI models developed by for-profit organizations? | CREATE TABLE ai_models (model_name TEXT,organization_type TEXT,safety_score INTEGER); INSERT INTO ai_models (model_name,organization_type,safety_score) VALUES ('ModelA','For-Profit',85),('ModelB','For-Profit',92),('ModelC','Non-Profit',88); | SELECT AVG(safety_score) FROM ai_models WHERE organization_type = 'For-Profit'; |
List the product codes, manufacturing dates, and supplier names for products that were manufactured using raw materials sourced from at least two different countries. | CREATE TABLE products (product_code TEXT,manufacturing_date DATE); CREATE TABLE raw_materials (raw_material_id INT,product_code TEXT,source_country TEXT,supplier_name TEXT); INSERT INTO products (product_code,manufacturing_date) VALUES ('P1','2022-03-15'),('P2','2021-12-21'); INSERT INTO raw_materials (raw_material_id,product_code,source_country,supplier_name) VALUES (1,'P1','India','Supplier A'),(2,'P1','Mexico','Supplier B'),(3,'P2','China','Supplier C'); | SELECT products.product_code, products.manufacturing_date, raw_materials.supplier_name FROM products INNER JOIN raw_materials ON products.product_code = raw_materials.product_code GROUP BY products.product_code, products.manufacturing_date HAVING COUNT(DISTINCT raw_materials.source_country) >= 2; |
Show all autonomous driving research organizations in the USA and Germany, excluding those with a focus on 'Simulation'. | CREATE TABLE AutonomousResearch (Id INT,Organization VARCHAR(255),Focus VARCHAR(255),Country VARCHAR(255)); INSERT INTO AutonomousResearch (Id,Organization,Focus,Country) VALUES (4,'Volvo Autonomous','Autonomous Driving','USA'); | SELECT Organization, Country FROM AutonomousResearch WHERE Country IN ('USA', 'Germany') AND Focus NOT IN ('Simulation'); |
What was the total cost of all infrastructure projects in the rural development sector in South Africa in 2020?' | CREATE TABLE infrastructure_projects (id INT,country VARCHAR(255),year INT,sector VARCHAR(255),cost FLOAT); INSERT INTO infrastructure_projects (id,country,year,sector,cost) VALUES (1,'South Africa',2020,'Rural Development',500000.00); | SELECT SUM(cost) FROM infrastructure_projects WHERE country = 'South Africa' AND year = 2020 AND sector = 'Rural Development'; |
How many Freedom of Information Act (FOIA) requests were made in California, Florida, and Texas in 2020? | CREATE TABLE foia_requests (state VARCHAR(20),year INT,num_requests INT); INSERT INTO foia_requests (state,year,num_requests) VALUES ('California',2020,12300),('Florida',2020,9800),('Texas',2020,15600); | SELECT SUM(num_requests) FROM foia_requests WHERE state IN ('California', 'Florida', 'Texas') AND year = 2020; |
Delete all 'Train' routes | CREATE TABLE train_routes (route_id INT PRIMARY KEY,start_location TEXT,end_location TEXT); | DELETE FROM train_routes; |
How many sustainable tourism initiatives are there in Canada and how many annual visitors do they have in total? | CREATE TABLE SustainableTourism (InitiativeID INT,InitiativeName VARCHAR(255),Country VARCHAR(255)); INSERT INTO SustainableTourism (InitiativeID,InitiativeName,Country) VALUES (1,'Initiative1','Canada'),(2,'Initiative2','Canada'),(3,'Initiative3','Canada'); CREATE TABLE VisitorCounts (InitiativeID INT,Year INT,VisitorCount INT); INSERT INTO VisitorCounts (InitiativeID,Year,VisitorCount) VALUES (1,2020,5000),(1,2019,5500),(2,2020,3000),(2,2019,3500),(3,2020,4000),(3,2019,4500); | SELECT SustainableTourism.Country, COUNT(SustainableTourism.InitiativeName) AS InitiativeCount, SUM(VisitorCounts.VisitorCount) AS TotalVisitors FROM SustainableTourism INNER JOIN VisitorCounts ON SustainableTourism.InitiativeID = VisitorCounts.InitiativeID WHERE SustainableTourism.Country = 'Canada' GROUP BY SustainableTourism.Country; |
How many esports events were held in Asia in 2020? | CREATE TABLE esports_events (id INT,year INT,region VARCHAR(20)); INSERT INTO esports_events (id,year,region) VALUES (1,2018,'North America'),(2,2019,'Europe'),(3,2020,'Asia'); | SELECT COUNT(*) FROM esports_events WHERE year = 2020 AND region = 'Asia'; |
Delete the 'athlete_stats' table | CREATE TABLE athlete_stats (athlete_id INT PRIMARY KEY,name VARCHAR(100),sport VARCHAR(50),team VARCHAR(50),games_played INT,goals_scored INT,assists INT); | DROP TABLE athlete_stats; |
What is the total number of emergency medical calls in each borough of New York City? | CREATE TABLE nyc_boroughs (borough_id INT,name VARCHAR(255)); INSERT INTO nyc_boroughs (borough_id,name) VALUES (1,'Manhattan'),(2,'Brooklyn'),(3,'Queens'); CREATE TABLE emergency_calls (call_id INT,borough_id INT,type VARCHAR(255),date DATE); INSERT INTO emergency_calls (call_id,borough_id,type,date) VALUES (1,1,'Medical','2022-01-01'),(2,2,'Fire','2022-01-02'),(3,3,'Medical','2022-01-03'); | SELECT borough_id, name, COUNT(*) as total_medical_calls FROM emergency_calls WHERE type = 'Medical' GROUP BY borough_id, name; |
Count the number of green buildings in the 'smart_cities' schema with an area greater than 6000 sq ft. | CREATE TABLE green_buildings (id INT,area FLOAT,city VARCHAR(20),state VARCHAR(20)); INSERT INTO green_buildings (id,area,city,state) VALUES (1,5000.5,'San Francisco','CA'),(2,7000.3,'Los Angeles','CA'); | SELECT COUNT(*) FROM green_buildings WHERE area > 6000; |
How many pollution incidents have been recorded in the Atlantic Ocean each year? | CREATE TABLE pollution_incidents (event_date DATE,location TEXT,incident_type TEXT); INSERT INTO pollution_incidents VALUES ('2019-03-04','Atlantic Ocean','Oil Spill'),('2020-08-12','Atlantic Ocean','Plastic Waste'),('2019-07-21','Atlantic Ocean','Chemical Pollution'); | SELECT EXTRACT(YEAR FROM event_date) AS year, COUNT(*) AS num_incidents FROM pollution_incidents WHERE location = 'Atlantic Ocean' GROUP BY year ORDER BY year; |
Insert a new record into the 'market_trends' table for 'Argentina' in 2018 with a 'price' of 50.75 | CREATE TABLE market_trends (id INT,country VARCHAR(50),year INT,price FLOAT); | INSERT INTO market_trends (id, country, year, price) VALUES (1, 'Argentina', 2018, 50.75); |
What is the total number of kills and deaths for each player in the 'games' table? | CREATE TABLE players (id INT,name VARCHAR(50)); CREATE TABLE games (id INT,player_id INT,kills INT,deaths INT,assists INT); INSERT INTO players VALUES (1,'Aarav Singh'); INSERT INTO players VALUES (2,'Bella Rodriguez'); INSERT INTO games VALUES (1,1,12,6,8); INSERT INTO games VALUES (2,1,18,4,12); INSERT INTO games VALUES (3,2,7,3,2); INSERT INTO games VALUES (4,2,10,5,6); | SELECT player_id, SUM(kills) as total_kills, SUM(deaths) as total_deaths FROM games GROUP BY player_id; |
What is the percentage change in water consumption from the previous year for each country? | CREATE TABLE global_water_usage (id INT,country VARCHAR(50),year INT,monthly_consumption FLOAT); INSERT INTO global_water_usage (id,country,year,monthly_consumption) VALUES (1,'USA',2020,170),(2,'USA',2021,175),(3,'Canada',2020,125),(4,'Canada',2021,130); | SELECT country, (monthly_consumption - LAG(monthly_consumption) OVER (PARTITION BY country ORDER BY year)) / LAG(monthly_consumption) OVER (PARTITION BY country ORDER BY year) * 100 AS consumption_percentage_change FROM global_water_usage; |
What is the total workout duration by type for each member in the last week? | CREATE TABLE workout (id INT,member_id INT,duration INT,date DATE,type VARCHAR(50)); CREATE VIEW recent_workouts AS SELECT * FROM workout WHERE date >= CURRENT_DATE - INTERVAL '7' DAY; | SELECT member_id, type, SUM(duration) total_duration FROM recent_workouts GROUP BY member_id, type; |
Update the 'email' column with the donor's email address in the 'donor_emails' table if it exists. | CREATE TABLE donors (donor_id INT,donor_name VARCHAR(50),email VARCHAR(50)); INSERT INTO donors (donor_id,donor_name,email) VALUES (1,'John Doe',NULL),(2,'Jane Smith',NULL),(3,'Alice Johnson',NULL); CREATE TABLE donor_emails (donor_id INT,email VARCHAR(50)); INSERT INTO donor_emails (donor_id,email) VALUES (1,'johndoe@email.com'),(3,'alicejohnson@email.com'); | UPDATE donors d SET email = (SELECT email FROM donor_emails de WHERE d.donor_id = de.donor_id) WHERE EXISTS (SELECT 1 FROM donor_emails de WHERE d.donor_id = de.donor_id); |
What is the total weight of cargo for vessels manufactured in India? | CREATE TABLE Vessels (VesselID INT,VesselName VARCHAR(50),Manufacturer VARCHAR(50)); INSERT INTO Vessels (VesselID,VesselName,Manufacturer) VALUES (1,'Ocean Titan','ABC Shipyard'),(2,'Maritime Queen','Indian Ocean Shipbuilders'); CREATE TABLE Cargo (CargoID INT,VesselID INT,CargoType VARCHAR(50),Weight FLOAT); INSERT INTO Cargo (CargoID,VesselID,CargoType,Weight) VALUES (1,1,'Container',15000),(2,2,'Bulk',35000); | SELECT SUM(Cargo.Weight) FROM Cargo INNER JOIN Vessels ON Cargo.VesselID = Vessels.VesselID WHERE Vessels.Manufacturer = 'Indian Ocean Shipbuilders'; |
How many size 14 dresses were sold in the last quarter? | CREATE TABLE sales (sale_id INT,dress_size INT,sale_date DATE); INSERT INTO sales (sale_id,dress_size,sale_date) VALUES (1,8,'2021-01-05'),(2,14,'2021-02-10'),(3,12,'2021-03-15'),(4,10,'2021-04-20'),(5,14,'2021-05-01'); | SELECT COUNT(*) FROM sales WHERE dress_size = 14 AND sale_date >= DATE_SUB(CURRENT_DATE, INTERVAL 3 MONTH); |
What genetic research projects were conducted in France? | CREATE TABLE research (id INT,name VARCHAR(100),type VARCHAR(50),location VARCHAR(100)); INSERT INTO research (id,name,type,location) VALUES (1,'ProjectX','Genetic','Canada'); INSERT INTO research (id,name,type,location) VALUES (2,'ProjectY','Bioprocess','France'); | SELECT name FROM research WHERE type = 'Genetic' AND location = 'France'; |
Which biosensors are used in the bioprocesses 'Process_1' and 'Process_3'? | CREATE TABLE Bioprocess (ID INT,Name TEXT,Biosensors TEXT); INSERT INTO Bioprocess (ID,Name,Biosensors) VALUES (1,'Process_1','BS1,BS2'),(3,'Process_3','BS3,BS4'); | SELECT DISTINCT Biosensors FROM Bioprocess WHERE Name IN ('Process_1', 'Process_3'); |
Which public transportation systems are available in Tokyo? | CREATE TABLE Public_Transportation (id INT,system_name TEXT,location TEXT,type TEXT); INSERT INTO Public_Transportation (id,system_name,location,type) VALUES (1,'Tokyo Metro','Tokyo','Subway'),(2,'Toei Subway','Tokyo','Subway'),(3,'JR East','Tokyo','Rail'); | SELECT DISTINCT system_name FROM Public_Transportation WHERE location = 'Tokyo' AND type = 'Subway'; |
Find the banks with the highest and lowest average financial wellbeing scores among their customers. | CREATE TABLE banks_customers (bank_id INT,customer_id INT,financial_wellbeing_score INT); INSERT INTO banks_customers (bank_id,customer_id,financial_wellbeing_score) VALUES (1,1,75),(1,2,80),(2,3,90),(2,4,85),(3,5,80); | SELECT b.name, AVG(bc.financial_wellbeing_score) as avg_score FROM banks_customers bc JOIN banks b ON bc.bank_id = b.id GROUP BY b.id ORDER BY avg_score DESC, b.name LIMIT 1; SELECT b.name, AVG(bc.financial_wellbeing_score) as avg_score FROM banks_customers bc JOIN banks b ON bc.bank_id = b.id GROUP BY b.id ORDER BY avg_score ASC, b.name LIMIT 1; |
What is the total value of socially responsible loans issued to clients in the last month, partitioned by region? | CREATE TABLE loan (loan_id INT,client_id INT,region VARCHAR(50),loan_amount DECIMAL(10,2),date DATE); INSERT INTO loan (loan_id,client_id,region,loan_amount,date) VALUES (1,1,'North',1000.00,'2022-01-01'); | SELECT region, SUM(loan_amount) FROM loan WHERE date >= DATEADD(month, -1, GETDATE()) GROUP BY region; |
What is the minimum energy efficiency rating of buildings in Colorado that have received energy efficiency upgrades since 2010? | CREATE TABLE buildings (id INT,name VARCHAR(50),state VARCHAR(50),rating FLOAT,upgrade_year INT); | SELECT MIN(rating) FROM buildings WHERE state = 'Colorado' AND upgrade_year >= 2010; |
What is the average price of makeup products that contain shea butter as an ingredient? | CREATE TABLE Product (id INT,productName VARCHAR(50),price DECIMAL(5,2)); INSERT INTO Product (id,productName,price) VALUES (4,'Blush',14.99),(5,'Foundation',29.99),(6,'Lip Liner',16.99); CREATE TABLE Ingredient (id INT,productId INT,ingredient VARCHAR(50),sourceCountry VARCHAR(50),crueltyFree BOOLEAN); INSERT INTO Ingredient (id,productId,ingredient,sourceCountry,crueltyFree) VALUES (6,4,'Shea Butter','Ghana',true),(7,4,'Rosehip Oil','Chile',true),(8,5,'Vitamin E','Argentina',true),(9,5,'Zinc Oxide','Australia',true),(10,6,'Jojoba Oil','Peru',true); | SELECT AVG(P.price) as avgPrice FROM Product P INNER JOIN Ingredient I ON P.id = I.productId WHERE I.ingredient = 'Shea Butter'; |
Calculate the average visitor spending in Asia in the last 3 years. | CREATE TABLE spending (year INT,continent TEXT,spending DECIMAL(10,2)); INSERT INTO spending (year,continent,spending) VALUES (2019,'Asia',1200),(2020,'Asia',1000),(2021,'Asia',1500); | SELECT AVG(spending) as avg_spending FROM spending WHERE continent = 'Asia' AND year >= (SELECT MAX(year) - 3); |
List all unique AI safety research topics from the 'research_topics' table. | CREATE TABLE research_topics (topic_id INTEGER,topic_name TEXT); INSERT INTO research_topics (topic_id,topic_name) VALUES (1,'Explainable AI'),(2,'Algorithmic Fairness'),(3,'AI Safety'),(4,'Creative AI'); | SELECT DISTINCT topic_name FROM research_topics; |
Insert new records for users who signed up using email | CREATE TABLE users (id INT PRIMARY KEY,name VARCHAR(50),email VARCHAR(50),signup_date DATE,signup_source VARCHAR(20)); | INSERT INTO users (id, name, email, signup_date, signup_source) VALUES (432, 'Alex', 'alex@example.com', '2022-11-15', 'email'), (543, 'Ben', 'ben@example.com', '2022-11-16', 'email'); |
List the top 2 green building projects by investment amount in each country? | CREATE TABLE green_building_projects (project_name TEXT,country TEXT,investment_amount FLOAT); INSERT INTO green_building_projects VALUES ('ProjectX','Country1',1000000.0),('ProjectY','Country1',1200000.0),('ProjectZ','Country2',800000.0),('ProjectW','Country2',1500000.0); | SELECT project_name, country, investment_amount FROM (SELECT project_name, country, investment_amount, ROW_NUMBER() OVER (PARTITION BY country ORDER BY investment_amount DESC) as rn FROM green_building_projects) WHERE rn <= 2; |
Delete records of players who haven't played for 30 days | CREATE TABLE players (id INT,name TEXT,last_login DATETIME); | DELETE FROM players WHERE last_login < NOW() - INTERVAL 30 DAY; |
Get the number of games played by each player in the last month | game_stats(player_id,game_id,score,date_played) | SELECT player_id, COUNT(DISTINCT game_id) as games_played FROM game_stats WHERE date_played >= CURDATE() - INTERVAL 1 MONTH GROUP BY player_id; |
What is the average yield of crops for each farm type, ordered by the highest average yield? | CREATE TABLE farm (farm_id INT,farm_type VARCHAR(20),yield INT); INSERT INTO farm (farm_id,farm_type,yield) VALUES (1,'Organic',120),(2,'Conventional',150),(3,'Urban',180); | SELECT farm_type, AVG(yield) as avg_yield FROM farm GROUP BY farm_type ORDER BY avg_yield DESC; |
Find the total number of virtual tours conducted by each sales representative in the sales_representatives and virtual_tours tables. | CREATE TABLE sales_representatives (rep_id INT,name VARCHAR(50)); INSERT INTO sales_representatives (rep_id,name) VALUES (1,'John Doe'),(2,'Jane Smith'); CREATE TABLE virtual_tours (tour_id INT,rep_id INT,date DATE); INSERT INTO virtual_tours (tour_id,rep_id,date) VALUES (1,1,'2021-01-01'),(2,1,'2021-01-02'),(3,2,'2021-01-03'); | SELECT s.name, COUNT(v.tour_id) as total_tours FROM sales_representatives s JOIN virtual_tours v ON s.rep_id = v.rep_id GROUP BY s.name; |
Who are the top 5 donors to ocean conservation efforts by total contribution?' | CREATE TABLE donors (donor_id INT,name VARCHAR(50),total_contribution FLOAT); | SELECT name, total_contribution FROM donors ORDER BY total_contribution DESC LIMIT 5; |
How many disability support programs were implemented in each city in the last 3 years, sorted by the number of programs? | CREATE TABLE Support_Programs (city VARCHAR(255),program_date DATE); INSERT INTO Support_Programs (city,program_date) VALUES ('New York','2018-01-01'),('Los Angeles','2017-01-01'),('Chicago','2019-01-01'),('Houston','2016-01-01'),('Phoenix','2020-01-01'); | SELECT city, COUNT(*) as num_programs FROM Support_Programs WHERE program_date >= DATE_SUB(CURRENT_DATE, INTERVAL 3 YEAR) GROUP BY city ORDER BY num_programs DESC; |
Retrieve the top 3 countries by music streaming | CREATE TABLE music_streaming (user_id INT,song_id INT,timestamp TIMESTAMP,country VARCHAR(255)); INSERT INTO music_streaming (user_id,song_id,timestamp,country) VALUES (1,123,'2022-01-01 10:00:00','USA'); INSERT INTO music_streaming (user_id,song_id,timestamp,country) VALUES (2,456,'2022-01-01 11:00:00','Canada'); | SELECT * FROM top_3_countries; |
Insert a new record into the 'Volunteers' table for 'Jasmine Patel' | CREATE TABLE Volunteers (volunteer_id INT,volunteer_name VARCHAR(50),hours INT); INSERT INTO Volunteers (volunteer_id,volunteer_name,hours) VALUES (1,'Jasmine Patel',0); | INSERT INTO Volunteers (volunteer_id, volunteer_name, hours) VALUES (2, 'Aaliyah Gupta', 0); |
How many public health policy violations were reported in the Western and Asian regions? | CREATE TABLE western_policy_violations (region VARCHAR(255),violation VARCHAR(255)); INSERT INTO western_policy_violations (region,violation) VALUES ('Western','Smoking Ban Violation'); INSERT INTO western_policy_violations (region,violation) VALUES ('Western','Noise Complaint'); CREATE TABLE asian_policy_violations (region VARCHAR(255),violation VARCHAR(255)); INSERT INTO asian_policy_violations (region,violation) VALUES ('Asian','Food Safety Violation'); INSERT INTO asian_policy_violations (region,violation) VALUES ('Asian','Building Code Violation'); | SELECT COUNT(*) FROM western_policy_violations UNION ALL SELECT COUNT(*) FROM asian_policy_violations; |
What is the total salary paid to part-time workers who are union members in the 'retail' industry? | CREATE TABLE parttime_workers (id INT,industry VARCHAR(20),salary FLOAT,union_member BOOLEAN); INSERT INTO parttime_workers (id,industry,salary,union_member) VALUES (1,'healthcare',30000.0,false),(2,'healthcare',32000.0,false),(3,'manufacturing',25000.0,true),(4,'retail',20000.0,true),(5,'retail',22000.0,true); | SELECT SUM(salary) FROM parttime_workers WHERE industry = 'retail' AND union_member = true; |
Display the number of visitors and exhibitions per country. | CREATE TABLE visitors_by_country (id INT,country VARCHAR(50),num_visitors INT); INSERT INTO visitors_by_country (id,country,num_visitors) VALUES (1,'USA',1000),(2,'Canada',800); CREATE TABLE exhibitions_by_country (id INT,country VARCHAR(50),num_exhibitions INT); INSERT INTO exhibitions_by_country (id,country,num_exhibitions) VALUES (1,'USA',5),(2,'Canada',3); | SELECT vbc.country, vbc.num_visitors, ebc.num_exhibitions FROM visitors_by_country vbc INNER JOIN exhibitions_by_country ebc ON vbc.country = ebc.country; |
What is the total number of policies and total claim amount, grouped by policy type, for policies issued in New York state? | CREATE TABLE policy (policy_id INT,policy_type VARCHAR(20),issue_date DATE,zip_code INT,risk_score INT); CREATE TABLE claim (claim_id INT,policy_id INT,claim_amount INT); | SELECT policy_type, COUNT(policy_id) as policy_count, SUM(claim_amount) as total_claim_amount FROM claim JOIN policy ON claim.policy_id = policy.policy_id WHERE zip_code = (SELECT zip_code FROM zip_codes WHERE state = 'NY' AND city = 'New York City') GROUP BY policy_type; |
What is the total number of packages shipped from the 'LA' warehouse? | CREATE TABLE warehouses (warehouse_id INT,warehouse_name VARCHAR(20)); INSERT INTO warehouses (warehouse_id,warehouse_name) VALUES (1,'LA'),(2,'NY'),(3,'Chicago'); CREATE TABLE shipments (shipment_id INT,package_count INT,warehouse_id INT); INSERT INTO shipments (shipment_id,package_count,warehouse_id) VALUES (1,50,1),(2,30,1),(3,75,2); | SELECT SUM(package_count) FROM shipments JOIN warehouses ON shipments.warehouse_id = warehouses.warehouse_id WHERE warehouses.warehouse_name = 'LA'; |
What is the average donation amount for each month in the year 2021? | CREATE TABLE donations (id INT,donation_date DATE,donation_amount DECIMAL(10,2)); INSERT INTO donations (id,donation_date,donation_amount) VALUES (1,'2021-01-01',100.00),(2,'2021-02-14',200.00),(3,'2021-03-05',150.00); | SELECT DATE_FORMAT(donation_date, '%Y-%m') as month, AVG(donation_amount) as avg_donation FROM donations WHERE YEAR(donation_date) = 2021 GROUP BY month; |
What are the top mining operations in terms of resource depletion? | CREATE TABLE MiningOperations (OperationID INT,OperationName VARCHAR(20),Location VARCHAR(20),ResourcesDepleted INT,OperationDate DATE); | SELECT OperationName, ResourcesDepleted FROM MiningOperations WHERE ROW_NUMBER() OVER(ORDER BY ResourcesDepleted DESC) <= 3; |
Who are the top 3 agricultural innovators based on the number of projects? | CREATE TABLE Agricultural_Innovators (innovator_id INT,innovator_name TEXT,project_count INT); INSERT INTO Agricultural_Innovators (innovator_id,innovator_name,project_count) VALUES (1,'Ahmed Al-Sayed',5),(2,'Fatima Al-Fahad',4),(3,'Rami Al-Khalaf',6); | SELECT * FROM (SELECT innovator_name, ROW_NUMBER() OVER (ORDER BY project_count DESC) AS rank FROM Agricultural_Innovators) sub WHERE rank <= 3; |
Find the number of unique patients enrolled in public health initiatives in 'central' regions. | CREATE TABLE public_health (id INT,patient_id INT,name TEXT,region TEXT); INSERT INTO public_health (id,patient_id,name,region) VALUES (1,1,'Initiative A','central'); INSERT INTO public_health (id,patient_id,name,region) VALUES (2,2,'Initiative B','central'); INSERT INTO public_health (id,patient_id,name,region) VALUES (3,1,'Initiative C','central'); | SELECT COUNT(DISTINCT patient_id) FROM public_health WHERE region = 'central'; |
How many vessels sank in the Atlantic Ocean? | CREATE TABLE maritime_safety (vessel_name TEXT,region TEXT); INSERT INTO maritime_safety (vessel_name,region) VALUES ('Titanic','North Atlantic'),('Endurance','Arctic'),('Karluk','Arctic'); | SELECT COUNT(*) FROM maritime_safety WHERE region LIKE '%%Atlantic%%'; |
What is the total number of digital assets created by developers from the Asia-Pacific region? | CREATE TABLE digital_assets(id INT,name VARCHAR(255),developer_region VARCHAR(255)); INSERT INTO digital_assets(id,name,developer_region) VALUES (1,'AssetA','Asia-Pacific'),(2,'AssetB','North America'),(3,'AssetC','Asia-Pacific'); | SELECT SUM( CASE WHEN developer_region = 'Asia-Pacific' THEN 1 ELSE 0 END) as total_assets FROM digital_assets; |
What is the percentage of consumers in South America who prefer sustainable fashion? | CREATE TABLE consumer_preferences (country TEXT,prefers_sustainable BOOLEAN); INSERT INTO consumer_preferences (country,prefers_sustainable) VALUES ('Brazil',TRUE),('Argentina',FALSE),('Colombia',TRUE),('Chile',TRUE),('Peru',FALSE),('Ecuador',TRUE); | SELECT (COUNT(*) FILTER (WHERE prefers_sustainable)) * 100.0 / COUNT(*) FROM consumer_preferences WHERE country IN ('Brazil', 'Argentina', 'Colombia', 'Chile', 'Peru', 'Ecuador'); |
How many properties in the "Boston" city have a co-ownership agreement? | CREATE TABLE cities (city_id INT,city_name TEXT,PRIMARY KEY (city_id)); INSERT INTO cities (city_id,city_name) VALUES (1,'Boston'),(2,'Chicago'),(3,'Oakland'); CREATE TABLE properties (property_id INT,co_ownership BOOLEAN,city_id INT,PRIMARY KEY (property_id),FOREIGN KEY (city_id) REFERENCES cities(city_id)); | SELECT COUNT(*) FROM properties WHERE co_ownership = TRUE AND city_id = 1; |
Show the locations and dates of all sightings of critically endangered species. | CREATE TABLE species (id INT PRIMARY KEY,name VARCHAR(255),conservation_status VARCHAR(255)); CREATE TABLE sightings (id INT PRIMARY KEY,species_id INT,location VARCHAR(255),date DATE); INSERT INTO species (id,name,conservation_status) VALUES (1,'Vaquita','Critically Endangered'); INSERT INTO sightings (id,species_id,location,date) VALUES (1,1,'Gulf of California','2021-01-01'); | SELECT sightings.location, sightings.date FROM sightings INNER JOIN species ON sightings.species_id = species.id WHERE species.conservation_status = 'Critically Endangered'; |
What is the total waste generation by region for the year 2021? | CREATE TABLE regional_waste_generation (region VARCHAR(20),year INT,quantity INT); INSERT INTO regional_waste_generation (region,year,quantity) VALUES ('North',2021,50000),('South',2021,60000),('East',2021,70000),('West',2021,80000); | SELECT region, SUM(quantity) as total_waste FROM regional_waste_generation WHERE year = 2021 GROUP BY region; |
What is the total cost of accommodations for students with autism in the last 3 months? | CREATE TABLE Accommodations (student_id INT,accommodation_type VARCHAR(255),cost FLOAT,month INT); | SELECT SUM(cost) FROM Accommodations WHERE accommodation_type = 'Autism' AND month BETWEEN DATE_SUB(NOW(), INTERVAL 3 MONTH) AND NOW(); |
What is the total number of employees working in mining companies located in Canada, and what is their average salary? | CREATE TABLE mining_companies (company_id INT,company_name TEXT,location TEXT); INSERT INTO mining_companies (company_id,company_name,location) VALUES (1,'ABC Mining','Canada'),(2,'XYZ Mining','USA'); CREATE TABLE employees (employee_id INT,employee_name TEXT,company_id INT,salary INT); INSERT INTO employees (employee_id,employee_name,company_id,salary) VALUES (1,'John Doe',1,50000),(2,'Jane Smith',1,55000),(3,'Alice Johnson',2,60000); | SELECT SUM(salary), AVG(salary) FROM employees INNER JOIN mining_companies ON employees.company_id = mining_companies.company_id WHERE location = 'Canada'; |
What is the minimum dissolved oxygen level in freshwater fish farms in each state in the Western United States over the past six months? | CREATE TABLE fish_farms_fw (id INT,name TEXT,type TEXT,location TEXT,dissolved_oxygen FLOAT); INSERT INTO fish_farms_fw (id,name,type,location,dissolved_oxygen) VALUES (1,'Farm Y','Fish','California',6.5),(2,'Farm Z','Fish','Oregon',7.0); CREATE TABLE states (state TEXT,region TEXT); INSERT INTO states (state,region) VALUES ('California','Western United States'),('Oregon','Western United States'); | SELECT state, MIN(dissolved_oxygen) FROM fish_farms_fw JOIN states ON fish_farms_fw.location = states.state WHERE type = 'Fish' AND region = 'Western United States' AND record_date BETWEEN DATE('now', '-6 month') AND DATE('now') GROUP BY state; |
What is the total CO2 emissions reduction from all carbon offset programs in the United States? | CREATE TABLE carbon_offsets (id INT,name TEXT,country TEXT,co2_reduction INT); INSERT INTO carbon_offsets (id,name,country,co2_reduction) VALUES (1,'Green-e Climate','United States',100000),(2,'Carbonfund.org','United States',200000); | SELECT SUM(co2_reduction) FROM carbon_offsets WHERE country = 'United States'; |
What is the average number of posts per user in the social_media schema? | CREATE TABLE users (id INT,name VARCHAR(50),age INT,gender VARCHAR(10)); CREATE TABLE posts (id INT,user_id INT,content TEXT,timestamp TIMESTAMP); INSERT INTO users (id,name,age,gender) VALUES (1,'Alice',25,'Female'); INSERT INTO posts (id,user_id,content,timestamp) VALUES (1,1,'Hello World!','2022-01-01 10:00:00'); | SELECT AVG(post_count) as avg_posts_per_user FROM (SELECT COUNT(p.id) as post_count, u.id as user_id FROM posts p JOIN users u ON p.user_id = u.id GROUP BY u.id) t; |
Update the 'Art of the Americas' event date. | CREATE TABLE events (id INT,name VARCHAR(50),date DATE); INSERT INTO events (id,name,date) VALUES (1,'Art of the Americas','2022-06-01'),(2,'Women in Art','2022-07-01'); | UPDATE events SET date = '2023-06-01' WHERE name = 'Art of the Americas'; |
How many cases of Tuberculosis were reported in the African region in 2021? | CREATE TABLE tb_cases (case_id INT,patient_id INT,region TEXT,year INT,cases INT); INSERT INTO tb_cases (case_id,patient_id,region,year,cases) VALUES (1,1,'Africa',2021,1); | SELECT SUM(cases) FROM tb_cases WHERE region = 'Africa' AND year = 2021; |
What is the average CO2 emissions of textile products from manufacturers in Asia? | CREATE TABLE products (product_id int,product_name varchar(255),product_category varchar(255),manufacturer_region varchar(255),CO2_emissions float); INSERT INTO products (product_id,product_name,product_category,manufacturer_region,CO2_emissions) VALUES (1,'Product A','Textile','Asia',12.5),(2,'Product B','Electronics','Asia',17.2),(3,'Product C','Textile','Europe',9.8); | SELECT AVG(CO2_emissions) FROM products WHERE product_category = 'Textile' AND manufacturer_region = 'Asia'; |
Determine the number of players who joined in each month from 'gaming_players' table | CREATE TABLE gaming_players (player_id INT,name VARCHAR(50),join_date DATE); | SELECT MONTH(join_date) as join_month, COUNT(*) as num_players FROM gaming_players GROUP BY join_month; |
List the defense projects with timelines exceeding 2 years in Canada. | CREATE TABLE DefenseProjects (project_id INT,country VARCHAR(50),start_date DATE,end_date DATE); INSERT INTO DefenseProjects (project_id,country,start_date,end_date) VALUES (1,'Canada','2018-01-01','2023-12-31'); INSERT INTO DefenseProjects (project_id,country,start_date,end_date) VALUES (2,'Canada','2020-01-01','2021-12-31'); | SELECT project_id, country, start_date, end_date FROM DefenseProjects WHERE DATEDIFF(end_date, start_date) > 730 AND country = 'Canada'; |
What is the maximum duration of space missions for each country's space agency, and how many such missions were there? | CREATE TABLE space_agencies (agency_id INT,name VARCHAR(50),country VARCHAR(50)); CREATE TABLE missions (mission_id INT,agency_id INT,duration INT); | SELECT sa.country, MAX(m.duration), COUNT(*) FROM space_agencies sa INNER JOIN missions m ON sa.agency_id = m.agency_id GROUP BY sa.country HAVING MAX(m.duration) = (SELECT MAX(duration) FROM missions GROUP BY agency_id); |
What was the total cost of community development initiatives in Zimbabwe from 2015 to 2018? | CREATE TABLE initiatives (id INT,country VARCHAR(50),start_date DATE,end_date DATE,cost FLOAT); INSERT INTO initiatives (id,country,start_date,end_date,cost) VALUES (1,'Zimbabwe','2015-01-01','2016-12-31',200000),(2,'Zimbabwe','2016-01-01','2017-12-31',250000),(3,'Zimbabwe','2017-01-01','2018-12-31',300000),(4,'Zimbabwe','2018-01-01','2019-12-31',350000); | SELECT SUM(cost) FROM initiatives WHERE country = 'Zimbabwe' AND YEAR(start_date) BETWEEN 2015 AND 2018; |
What is the average rainfall in 'asia' during the monsoon season? | CREATE TABLE asia_weather (date TEXT,rainfall INTEGER); INSERT INTO asia_weather (date,rainfall) VALUES ('2022-06-01',120),('2022-06-02',150),('2022-06-03',130),('2022-07-01',200),('2022-07-02',220); | SELECT AVG(rainfall) FROM asia_weather WHERE date LIKE '2022-06-%' OR date LIKE '2022-07-%'; |
What are the projects using sustainable practices in Chicago? | CREATE TABLE Projects (ProjectID INT,Name VARCHAR(50),City VARCHAR(50),Budget INT); INSERT INTO Projects (ProjectID,Name,City,Budget) VALUES (1,'GreenTowers','Chicago',800000); CREATE TABLE SustainablePractices (PracticeID INT,Practice VARCHAR(50),ProjectID INT); INSERT INTO SustainablePractices (PracticeID,Practice,ProjectID) VALUES (1,'Wind Turbines',1); | SELECT p.Name FROM Projects p JOIN SustainablePractices sp ON p.ProjectID = sp.ProjectID WHERE p.City = 'Chicago' AND sp.Practice = 'Wind Turbines' |
Who is the manager of the Finance department? | CREATE TABLE Employees (EmployeeID INT,Department VARCHAR(50),Manager VARCHAR(50)); INSERT INTO Employees (EmployeeID,Department,Manager) VALUES (1,'IT','John Doe'); INSERT INTO Employees (EmployeeID,Department,Manager) VALUES (2,'IT','John Doe'); INSERT INTO Employees (EmployeeID,Department,Manager) VALUES (3,'HR','Jane Smith'); INSERT INTO Employees (EmployeeID,Department,Manager) VALUES (4,'Finance',NULL); | SELECT Manager FROM Employees WHERE Department = 'Finance' |
What is the minimum depth of any underwater mountain in the Pacific ocean? | CREATE TABLE underwater_mountains (mountain_name TEXT,location TEXT,min_depth FLOAT); INSERT INTO underwater_mountains (mountain_name,location,min_depth) VALUES ('Mountain 1','Pacific Ocean',1200.0),('Mountain 2','Atlantic Ocean',900.0),('Mountain 3','Pacific Ocean',1500.0); | SELECT MIN(min_depth) FROM underwater_mountains WHERE location = 'Pacific Ocean'; |
what is the total number of electric vehicles in the world? | CREATE TABLE electric_vehicles (vehicle_id INT,vehicle_type VARCHAR(255),city VARCHAR(255),state VARCHAR(255)); | SELECT COUNT(*) FROM electric_vehicles; |
What is the average number of cybersecurity personnel in each country in the European region, with roles of 'Security Analyst' or 'Security Engineer'? | CREATE TABLE personnel (id INT,country VARCHAR(50),role VARCHAR(50),region VARCHAR(50)); INSERT INTO personnel (id,country,role,region) VALUES (1,'Germany','Security Analyst','Europe'); INSERT INTO personnel (id,country,role,region) VALUES (2,'France','Security Engineer','Europe'); INSERT INTO personnel (id,country,role,region) VALUES (3,'Spain','Security Manager','Europe'); | SELECT region, AVG(CASE WHEN role IN ('Security Analyst', 'Security Engineer') THEN 1 ELSE 0 END) FROM personnel WHERE region = 'Europe' GROUP BY region; |
How many financially capable individuals are there in each region? | CREATE TABLE regions (region_id INT,region_name VARCHAR(50),total_population INT);CREATE TABLE financial_capability (person_id INT,region_id INT,financially_capable BOOLEAN); | SELECT r.region_name, COUNT(fc.person_id) as num_financially_capable FROM regions r INNER JOIN financial_capability fc ON r.region_id = fc.region_id WHERE fc.financially_capable = TRUE GROUP BY r.region_name; |
How many movies were released per year? | CREATE TABLE movies (title VARCHAR(255),release_year INT); INSERT INTO movies (title,release_year) VALUES ('Movie1',2010),('Movie2',2005),('Movie3',2015),('Movie4',2010),('Movie5',2005),('Movie6',2020); | SELECT release_year, COUNT(*) as movie_count FROM movies GROUP BY release_year; |
What is the total value of veteran employment grants awarded to organizations in the Midwest region? | CREATE TABLE VeteranEmploymentGrants (Id INT,GrantName VARCHAR(50),Organization VARCHAR(50),GrantValue DECIMAL(10,2),Region VARCHAR(50)); INSERT INTO VeteranEmploymentGrants (Id,GrantName,Organization,GrantValue,Region) VALUES (1,'Grant X','Org A',5000,'Midwest'),(2,'Grant Y','Org B',7000,'Northeast'); | SELECT SUM(GrantValue) FROM VeteranEmploymentGrants WHERE Region = 'Midwest'; |
What is the average safety rating for cosmetic products launched in 2020? | CREATE TABLE product_safety (product_name VARCHAR(100),launch_year INT,safety_rating DECIMAL(3,2)); INSERT INTO product_safety (product_name,launch_year,safety_rating) VALUES ('Lush Cleanser',2020,4.8),('The Body Shop Moisturizer',2020,4.6),('Pacifica Serum',2019,4.9); | SELECT AVG(safety_rating) FROM product_safety WHERE launch_year = 2020; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.