instruction stringlengths 0 1.06k | input stringlengths 11 5.3k | response stringlengths 2 4.44k |
|---|---|---|
What is the sum of sales for sustainable fashion items in the UK, France, and Germany? | CREATE TABLE sales (sale_id INT,country VARCHAR(50),amount DECIMAL(5,2),sustainable BOOLEAN); INSERT INTO sales (sale_id,country,amount,sustainable) VALUES (1,'UK',50.00,TRUE); INSERT INTO sales (sale_id,country,amount,sustainable) VALUES (2,'France',75.00,TRUE); INSERT INTO sales (sale_id,country,amount,sustainable) V... | SELECT SUM(amount) FROM sales WHERE country IN ('UK', 'France', 'Germany') AND sustainable = TRUE; |
List the names of volunteers who have donated more than $2000 but have not volunteered any hours? | CREATE TABLE VolunteerDonations (VolunteerID INT,DonationAmount DECIMAL(10,2),VolunteerHours INT); INSERT INTO VolunteerDonations (VolunteerID,DonationAmount,VolunteerHours) VALUES (1,3000.00,0),(2,1000.00,25),(3,500.00,15),(4,2500.00,NULL); | SELECT VolunteerName FROM Volunteers INNER JOIN VolunteerDonations ON Volunteers.VolunteerID = VolunteerDonations.VolunteerID WHERE DonationAmount > 2000 AND VolunteerHours IS NULL; |
Display the names of investment firms that have funded at least one startup founded by an individual who identifies as Indigenous. | CREATE TABLE investment (id INT,firm TEXT,startup TEXT); INSERT INTO investment (id,firm,startup) VALUES (1,'Tiger Global','GreenSolutions'),(2,'Sequoia','InnovateIT'),(3,'Accel','DataDriven'),(4,'Kleiner Perkins','EcoTech'),(5,'Andreessen Horowitz','AI4Good'),(6,'Two Spirit Capital','Indigenous Tech'); | SELECT DISTINCT firm FROM investment WHERE startup IN (SELECT name FROM startup WHERE founder_identity LIKE '%Indigenous%'); |
Which art pieces were removed from the museum collection in the last decade? | CREATE TABLE ArtPieces (ArtPieceID INT,Name TEXT,Artist TEXT,YearAdded INT,YearRemoved INT); INSERT INTO ArtPieces (ArtPieceID,Name,Artist,YearAdded,YearRemoved) VALUES (1,'Starry Night','Vincent van Gogh',1889,2020); INSERT INTO ArtPieces (ArtPieceID,Name,Artist,YearAdded,YearRemoved) VALUES (2,'The Persistence of Mem... | SELECT Name FROM ArtPieces WHERE YearRemoved > 2010; |
What is the total number of military vehicles manufactured in Germany and Japan? | CREATE TABLE MilitaryVehicles(id INT PRIMARY KEY,country VARCHAR(50),quantity INT);INSERT INTO MilitaryVehicles(id,country,quantity) VALUES (1,'Germany',300),(2,'Japan',250); | SELECT SUM(quantity) FROM MilitaryVehicles WHERE country IN ('Germany', 'Japan'); |
Identify national security operations that used military technology in the same year | CREATE TABLE NationalSecurity (Id INT PRIMARY KEY,Country VARCHAR(50),Operation VARCHAR(50),Year INT); | SELECT NationalSecurity.Country, NationalSecurity.Operation FROM NationalSecurity INNER JOIN MilitaryTechnology ON NationalSecurity.Country = MilitaryTechnology.Country AND NationalSecurity.Year = MilitaryTechnology.Year; |
Return the song_name and genre of songs that are in playlists created by users from the United Kingdom. | ALTER TABLE users ADD COLUMN region VARCHAR(50); UPDATE users SET region = 'United Kingdom' WHERE country = 'United Kingdom'; CREATE VIEW playlists_uk AS SELECT * FROM playlists JOIN users ON playlists.user_id = users.user_id WHERE users.region = 'United Kingdom'; CREATE VIEW playlist_songs_uk AS SELECT songs.* FROM so... | SELECT song_name, genre FROM playlist_songs_uk; |
How many volunteers joined each month in the last year? | CREATE TABLE volunteer_registrations (id INT,registration_date DATE); | SELECT MONTH(vr.registration_date) as month, YEAR(vr.registration_date) as year, COUNT(*) as num_volunteers FROM volunteer_registrations vr WHERE vr.registration_date >= DATE_SUB(CURDATE(), INTERVAL 1 YEAR) GROUP BY month, year; |
Find the total number of trades executed in the 'Small Cap' portfolio during the last month. | CREATE TABLE trades (trade_id INT,team VARCHAR(20),portfolio VARCHAR(20),trade_date DATE,ticker VARCHAR(10),quantity INT); INSERT INTO trades (trade_id,team,portfolio,trade_date,ticker,quantity) VALUES (1,'Investment','Tech Growth','2022-01-05','AAPL',50),(2,'Investment','Tech Growth','2022-01-10','MSFT',75),(3,'Invest... | SELECT COUNT(*) FROM trades WHERE portfolio = 'Small Cap' AND trade_date >= DATEADD(month, -1, GETDATE()); |
What is the maximum value of returns from the United Kingdom? | CREATE TABLE UK_Returns (id INT,return_country VARCHAR(50),return_value FLOAT); INSERT INTO UK_Returns (id,return_country,return_value) VALUES (1,'United Kingdom',1500),(2,'United Kingdom',1100),(3,'Ireland',1300); | SELECT MAX(return_value) FROM UK_Returns WHERE return_country = 'United Kingdom'; |
Get the number of biotech patents filed by year. | CREATE TABLE patents (id INT,title VARCHAR(50),filed_by VARCHAR(50),filed_date DATE,type VARCHAR(50),industry VARCHAR(50)); | SELECT EXTRACT(YEAR FROM filed_date) AS year, COUNT(*) FROM patents WHERE industry = 'biotech' GROUP BY year; |
How many players from Africa have spent more than $500 in the 'gaming_facts' table? | CREATE TABLE gaming_facts (player_id INT,country VARCHAR(50),total_spending FLOAT); INSERT INTO gaming_facts (player_id,country,total_spending) VALUES (1,'USA',450.25),(2,'Canada',520.35),(3,'Egypt',600),(4,'Japan',375.89),(5,'Nigeria',550); | SELECT COUNT(*) as african_players_over_500 FROM gaming_facts WHERE country IN ('Egypt', 'Nigeria'); |
What is the average sustainability rating for garments manufactured in Africa? | CREATE TABLE garment_info (garment_id INT,sustainability_rating DECIMAL(3,2)); INSERT INTO garment_info (garment_id,sustainability_rating) VALUES (1001,4.2),(1002,3.5),(1003,4.8),(1004,2.9),(1005,4.5),(1006,3.7); CREATE TABLE garment_manufacturing (manufacturing_id INT,garment_id INT,country VARCHAR(255)); INSERT INTO ... | SELECT AVG(g.sustainability_rating) AS avg_sustainability_rating FROM garment_info g INNER JOIN garment_manufacturing m ON g.garment_id = m.garment_id WHERE m.country IN ('Nigeria', 'Egypt'); |
What was the total cargo weight transported by vessels from Brazil to Africa in H1 2020? | CREATE TABLE vessels(id INT,name VARCHAR(100),region VARCHAR(50));CREATE TABLE shipments(id INT,vessel_id INT,cargo_weight FLOAT,ship_date DATE,origin VARCHAR(50),destination VARCHAR(50)); | SELECT SUM(cargo_weight) FROM shipments WHERE (origin, destination) = ('Brazil', 'Africa') AND ship_date BETWEEN '2020-01-01' AND '2020-06-30'; |
What is the total quantity of sustainable materials used by each brand, and the corresponding CO2 emissions, for brands that have operations in the US? | CREATE TABLE brands (brand_id INT,brand_name TEXT,country TEXT); INSERT INTO brands (brand_id,brand_name,country) VALUES (1,'BrandA','USA'),(2,'BrandB','Canada'),(3,'BrandC','USA'); CREATE TABLE material_usage (brand_id INT,material_type TEXT,quantity INT,co2_emissions INT); INSERT INTO material_usage (brand_id,materia... | SELECT b.brand_name, SUM(mu.quantity) AS total_quantity, SUM(mu.co2_emissions) AS total_co2_emissions FROM brands b JOIN material_usage mu ON b.brand_id = mu.brand_id WHERE b.country = 'USA' GROUP BY b.brand_name; |
What is the name of the rural health center with the least number of patients in "New York"? | CREATE TABLE HealthCenters (HealthCenterID INT,Name VARCHAR(50),State VARCHAR(20),PatientCount INT); INSERT INTO HealthCenters (HealthCenterID,Name,State,PatientCount) VALUES (1,'Rural Health Center A','New York',2000); INSERT INTO HealthCenters (HealthCenterID,Name,State,PatientCount) VALUES (2,'Rural Health Center B'... | SELECT Name FROM HealthCenters WHERE State = 'New York' AND PatientCount = (SELECT MIN(PatientCount) FROM HealthCenters WHERE State = 'New York'); |
Count the number of fishing vessels that have been inspected in the last month, grouped by region | CREATE TABLE FishingVesselInspections (InspectionID INT,VesselID INT,VesselType VARCHAR(50),InspectionDate DATE,Region VARCHAR(50)); INSERT INTO FishingVesselInspections (InspectionID,VesselID,VesselType,InspectionDate,Region) VALUES (1,1,'Fishing Vessel','2022-03-10','Pacific'),(2,2,'Fishing Vessel','2022-02-20','Atla... | SELECT Region, COUNT(*) FROM FishingVesselInspections WHERE InspectionDate >= DATE_SUB(CURDATE(), INTERVAL 1 MONTH) GROUP BY Region; |
Find the number of times each menu item has been ordered, grouped by its category. | CREATE TABLE orders (order_id INT,menu_id INT,quantity INT,category VARCHAR(50)); | SELECT category, menu_id, name, SUM(quantity) as total_orders FROM orders o JOIN menu_items m ON o.menu_id = m.menu_id GROUP BY category, menu_id; |
What is the total number of security incidents per country, ordered by the highest number of incidents? | CREATE TABLE security_incidents (id INT,country VARCHAR(255),incident_type VARCHAR(255),timestamp TIMESTAMP);CREATE VIEW incident_count_by_country AS SELECT country,COUNT(*) as total_incidents FROM security_incidents GROUP BY country; | SELECT country, total_incidents FROM incident_count_by_country ORDER BY total_incidents DESC; |
What is the total revenue for each dispensary in Arizona in the last month? | CREATE TABLE Dispensaries (id INT,name TEXT,state TEXT);CREATE TABLE Sales (id INT,dispensary_id INT,revenue DECIMAL(10,2),sale_date DATE); INSERT INTO Dispensaries (id,name,state) VALUES (1,'Dispensary A','Arizona'); INSERT INTO Sales (id,dispensary_id,revenue,sale_date) VALUES (1,1,15000,'2022-06-01'); | SELECT d.name, SUM(s.revenue) FROM Dispensaries d JOIN Sales s ON d.id = s.dispensary_id WHERE d.state = 'Arizona' AND s.sale_date BETWEEN DATE_SUB(CURDATE(), INTERVAL 1 MONTH) AND CURDATE() GROUP BY d.name; |
How many unique volunteers have there been in each program in the past year? | CREATE TABLE volunteers (id INT,name VARCHAR(255),program VARCHAR(255),volunteer_date DATE); CREATE TABLE all_programs (id INT,name VARCHAR(255),focus_area VARCHAR(255)); | SELECT program, COUNT(DISTINCT id) FROM volunteers JOIN all_programs ON volunteers.program = all_programs.name WHERE volunteer_date >= DATEADD(year, -1, GETDATE()) GROUP BY program; |
Insert a new record into the 'fields' table for a field named 'Offshore Field X' located in the Gulf of Mexico. | CREATE TABLE fields (field_id INT,field_name TEXT,location TEXT); | INSERT INTO fields (field_name, location) VALUES ('Offshore Field X', 'Gulf of Mexico'); |
Add a new carbon offset project called 'Peatland Restoration' to the 'carbon_offset_projects' table | CREATE TABLE carbon_offset_projects (id INT PRIMARY KEY,project_name VARCHAR(100),location VARCHAR(50)); | INSERT INTO carbon_offset_projects (project_name, location) VALUES ('Peatland Restoration', 'Boreal Forest'); |
What is the total number of spacecraft that have visited Mars? | CREATE SCHEMA space; USE space; CREATE TABLE spacecraft (name VARCHAR(50),destination VARCHAR(50),visits INT); INSERT INTO spacecraft (name,destination,visits) VALUES ('Mariner 4','Mars',1),('Mariner 6','Mars',1),('Mariner 7','Mars',1),('Viking 1','Mars',1),('Viking 2','Mars',1),('Mars Global Surveyor','Mars',1),('Mars... | SELECT COUNT(name) FROM space.spacecraft WHERE destination = 'Mars'; |
Which international news article has the highest rating? | CREATE TABLE news_articles (id INT,title VARCHAR(100),section VARCHAR(50),rating INT); INSERT INTO news_articles (id,title,section,rating) VALUES (1,'Article 1','technology',4),(2,'Article 2','politics',5),(3,'Article 3','sports',3),(4,'Article 4','international',7); CREATE TABLE news_ratings (article_id INT,rating INT... | SELECT title FROM news_articles WHERE id = (SELECT article_id FROM news_ratings WHERE rating = (SELECT MAX(rating) FROM news_ratings WHERE section = 'international')); |
Calculate the total number of indigenous communities in each Arctic country. | CREATE TABLE IndigenousCommunities (id INT PRIMARY KEY,community VARCHAR(255),location VARCHAR(255),population INT); INSERT INTO IndigenousCommunities (id,community,location,population) VALUES (1,'Inuit','Canada',60000); INSERT INTO IndigenousCommunities (id,community,location,population) VALUES (2,'Sami','Norway',8000... | SELECT location, COUNT(DISTINCT community) as total_communities FROM IndigenousCommunities GROUP BY location; |
Find the wildlife species that are present in both temperate and tropical forests. | CREATE TABLE wildlife_habitat (species VARCHAR(255),forest_type VARCHAR(255)); | SELECT species FROM wildlife_habitat WHERE forest_type IN ('temperate', 'tropical') GROUP BY species HAVING COUNT(DISTINCT forest_type) = 2; |
How many rural infrastructure projects were completed in South Asia in each year? | CREATE TABLE RuralInfrastructure (region TEXT,year INTEGER,project_status TEXT); INSERT INTO RuralInfrastructure (region,year,project_status) VALUES ('South Asia',2019,'completed'),('South Asia',2020,'completed'),('South Asia',2021,'completed'),('South Asia',2019,'in progress'),('South Asia',2020,'in progress'),('South... | SELECT year, COUNT(*) FROM RuralInfrastructure WHERE region = 'South Asia' AND project_status = 'completed' GROUP BY year; |
What percentage of patients in Europe have anxiety as a primary condition? | CREATE TABLE patients (id INT,condition VARCHAR(50),region VARCHAR(50)); INSERT INTO patients (id,condition,region) VALUES (1,'Anxiety','Europe'),(2,'Depression','Europe'),(3,'Bipolar Disorder','Europe'),(4,'Anxiety','USA'); | SELECT (COUNT(*) * 100.0 / (SELECT COUNT(*) FROM patients WHERE region = 'Europe')) AS percentage FROM patients WHERE region = 'Europe' AND condition = 'Anxiety'; |
What is the total water usage per month for the last year? | CREATE TABLE date (date_id INT,date DATE); INSERT INTO date (date_id,date) VALUES (1,'2022-01-01'),(2,'2022-02-01'),(3,'2022-03-01'),(4,'2022-04-01'),(5,'2022-05-01'),(6,'2022-06-01'),(7,'2022-07-01'),(8,'2022-08-01'),(9,'2022-09-01'),(10,'2022-10-01'),(11,'2022-11-01'),(12,'2022-12-01'); CREATE TABLE water_usage (usag... | SELECT EXTRACT(MONTH FROM d.date) as month, AVG(w.water_usage_m3) as avg_water_usage_m3 FROM water_usage w JOIN date d ON w.date_id = d.date_id WHERE d.date BETWEEN '2021-01-01' AND '2022-12-31' GROUP BY EXTRACT(MONTH FROM d.date); |
What is the total funding received by startups founded by women? | CREATE TABLE companies (id INT,name TEXT,founder_gender TEXT); INSERT INTO companies (id,name,founder_gender) VALUES (1,'Acme Inc','female'),(2,'Beta Corp','male'); CREATE TABLE funding (company_id INT,amount INT); INSERT INTO funding (company_id,amount) VALUES (1,500000),(2,750000); | SELECT SUM(funding.amount) FROM companies INNER JOIN funding ON companies.id = funding.company_id WHERE companies.founder_gender = 'female'; |
How many timber production records were inserted in 2022? | CREATE TABLE timber_production (id INT,year INT,volume FLOAT); INSERT INTO timber_production (id,year,volume) VALUES (1,2020,1200.5),(2,2021,1500.7),(3,2022,1700.3); | SELECT COUNT(*) FROM timber_production WHERE year = 2022; |
Insert new records into the heritage_preservation table for a new project. | CREATE TABLE heritage_preservation (project_id INT,project_name TEXT,start_date DATE,end_date DATE,budget INT); | INSERT INTO heritage_preservation (project_id, project_name, start_date, end_date, budget) VALUES (2001, 'Conservation of Indigenous Art', '2023-01-01', '2023-12-31', 500000); |
What is the maximum number of students enrolled in a support program in the SupportPrograms table? | CREATE TABLE SupportPrograms (programID INT,programName VARCHAR(50),enrollment INT); | SELECT MAX(enrollment) FROM SupportPrograms; |
What is the average incident response time in Dallas? | CREATE TABLE dallas_emergency_response (id INT,incident_type TEXT,response_time INT); INSERT INTO dallas_emergency_response (id,incident_type,response_time) VALUES (1,'Fire',120),(2,'Medical',150),(3,'Police',180); | SELECT AVG(response_time) FROM dallas_emergency_response WHERE incident_type = 'Police'; |
How many citizens provided feedback in District K and L in Q3 and Q4 of 2021? | CREATE TABLE CitizenFeedback (District VARCHAR(10),Quarter INT,Year INT,FeedbackCount INT); INSERT INTO CitizenFeedback VALUES ('District K',3,2021,700),('District K',4,2021,800),('District L',3,2021,600),('District L',4,2021,700); | SELECT SUM(FeedbackCount) FROM CitizenFeedback WHERE District IN ('District K', 'District L') AND Quarter IN (3, 4) AND Year = 2021; |
List all marine species found in the Arctic Ocean | CREATE TABLE marine_species (species_name TEXT,conservation_status TEXT,habitat TEXT); INSERT INTO marine_species (species_name,conservation_status,habitat) VALUES ('Beluga Whale','Near Threatened','Arctic Ocean'),('Greenland Shark','Least Concern','Atlantic and Arctic Oceans'),('Polar Bear','Vulnerable','Arctic Ocean'... | SELECT species_name FROM marine_species WHERE habitat = 'Arctic Ocean'; |
What is the maximum food safety score for restaurants in 'California'? | CREATE TABLE inspection_scores (restaurant_name TEXT,location TEXT,score INTEGER); INSERT INTO inspection_scores (restaurant_name,location,score) VALUES ('Restaurant A','California',90),('Restaurant B','California',85),('Restaurant C','California',95); | SELECT MAX(score) FROM inspection_scores WHERE location = 'California'; |
What is the total quantity of sustainable fabrics used by each fashion brand? | CREATE TABLE FashionBrands (BrandID INT,BrandName VARCHAR(50),SustainableFabricsUsed INT); CREATE TABLE FabricUsage (BrandID INT,FabricType VARCHAR(50),QuantityUsed INT); | SELECT FB.BrandName, SUM(FU.QuantityUsed) AS TotalSustainableFabricsUsed FROM FashionBrands FB INNER JOIN FabricUsage FU ON FB.BrandID = FU.BrandID WHERE FB.SustainableFabricsUsed = 1 GROUP BY FB.BrandName; |
What was the average crude oil production in Canada by month? | CREATE TABLE canada_platforms (platform_id INT,platform_name VARCHAR(50),location VARCHAR(50),operational_status VARCHAR(15)); INSERT INTO canada_platforms VALUES (1,'Suncor 1','Alberta','Active'); INSERT INTO canada_platforms VALUES (2,'Imperial Oil 1','Alberta','Active'); CREATE TABLE oil_production (platform_id INT,... | SELECT month, AVG(production) FROM oil_production GROUP BY month; |
List all cosmetics with a price greater than 40 USD from the organic line. | CREATE TABLE Organic_Cosmetics (product_id INT,product_name VARCHAR(255),category VARCHAR(255),price DECIMAL(10,2)); INSERT INTO Organic_Cosmetics (product_id,product_name,category,price) VALUES (1,'Organic Cosmetic 1','Organic',35.99),(2,'Organic Cosmetic 2','Organic',45.99),(3,'Organic Cosmetic 3','Organic',25.99),(4... | SELECT * FROM Organic_Cosmetics WHERE price > 40; |
What is the average donation amount for new and returning donors in H1 2022? | CREATE TABLE Donors (DonorID INT,DonorName TEXT,DonationAmount DECIMAL(10,2),FirstDonationDate DATE); INSERT INTO Donors (DonorID,DonorName,DonationAmount,FirstDonationDate) VALUES (1,'Grace',250.00,'2021-08-20'),(2,'Harry',550.00,'2022-02-10'); | SELECT CASE WHEN FirstDonationDate BETWEEN '2022-01-01' AND '2022-06-30' THEN 'New Donor' ELSE 'Returning Donor' END as DonorType, AVG(DonationAmount) as AvgDonation FROM Donors WHERE DonationDate BETWEEN '2022-01-01' AND '2022-06-30' GROUP BY DonorType; |
What is the average age of individuals who have completed a restorative justice program in the last year? | CREATE TABLE restorative_justice_program (id INT,age INT,completion_date DATE); | SELECT AVG(age) FROM restorative_justice_program WHERE completion_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR); |
What is the total production cost for each sustainable material? | CREATE TABLE production (id INT,product_id INT,material VARCHAR(50),production_cost DECIMAL(5,2)); | SELECT material, SUM(production_cost) AS total_production_cost FROM production WHERE material IN ('organic_cotton', 'recycled_polyester', 'tencel', 'hemp', 'modal') GROUP BY material; |
How many AI ethics research papers were published in the past year by authors affiliated with universities in Africa, and what is the minimum number of citations for a single paper? | CREATE TABLE AIEthicsPapers (id INT,paper_title VARCHAR(50),author_name VARCHAR(50),affiliation VARCHAR(50),publication_date DATE,num_citations INT); INSERT INTO AIEthicsPapers (id,paper_title,author_name,affiliation,publication_date,num_citations) VALUES (1,'AI Ethics in Africa: A Review','John Doe','University of Cap... | SELECT affiliation, COUNT(*) as paper_count FROM AIEthicsPapers WHERE affiliation IN (SELECT affiliation FROM AIEthicsPapers WHERE publication_date >= '2022-01-01' AND author_name IN (SELECT author_name FROM AIEthicsPapers WHERE affiliation LIKE '%Africa%')) GROUP BY affiliation; SELECT MIN(num_citations) as min_citati... |
What is the distribution of mental health conditions among different genders? | CREATE TABLE mental_health (patient_id INT,gender VARCHAR(10),condition VARCHAR(50)); INSERT INTO mental_health (patient_id,gender,condition) VALUES (1,'Male','Depression'),(2,'Female','Anxiety'),(3,'Non-binary','Bipolar'),(4,'Male','PTSD'),(5,'Female','Depression'),(6,'Non-binary','Anxiety'),(7,'Male','Bipolar'),(8,'F... | SELECT gender, condition, COUNT(*) as count FROM mental_health GROUP BY gender, condition; |
List all marine mammal species and their population trends in the Arctic Ocean. | CREATE TABLE marine_mammals (mammal_id INT,mammal_name VARCHAR(255),PRIMARY KEY(mammal_id)); INSERT INTO marine_mammals (mammal_id,mammal_name) VALUES (1,'Polar Bear'); CREATE TABLE population_trends (population_id INT,mammal_id INT,region VARCHAR(255),population_status VARCHAR(255),PRIMARY KEY(population_id,mammal_id)... | SELECT marine_mammals.mammal_name, population_trends.population_status FROM marine_mammals INNER JOIN population_trends ON marine_mammals.mammal_id = population_trends.mammal_id WHERE population_trends.region = 'Arctic Ocean'; |
What was the total number of artifacts found in 'IslandSite1' and 'IslandSite2' in '2019'? | CREATE TABLE IslandSite (site VARCHAR(50),date DATE,artifacts INT); INSERT INTO IslandSite (site,date,artifacts) VALUES ('IslandSite1','2019-01-01',5),('IslandSite1','2019-01-02',7); INSERT INTO IslandSite (site,date,artifacts) VALUES ('IslandSite2','2019-01-01',3),('IslandSite2','2019-01-02',4); | SELECT SUM(artifacts) FROM IslandSite WHERE site IN ('IslandSite1', 'IslandSite2') AND date LIKE '2019-%'; |
Rank countries by the number of eco-tourism activities offered, highest first. | CREATE TABLE countries (country_name VARCHAR(50),eco_tourism_activities INT); INSERT INTO countries (country_name,eco_tourism_activities) VALUES ('Costa Rica',100),('Nepal',80),('Bhutan',60),('New Zealand',120); | SELECT country_name, ROW_NUMBER() OVER(ORDER BY eco_tourism_activities DESC) as rank FROM countries; |
What is the total number of eco-friendly tours in South Africa? | CREATE TABLE Tours (id INT,country TEXT,type TEXT,participants INT); INSERT INTO Tours (id,country,type,participants) VALUES (1,'South Africa','Eco-friendly',200),(2,'South Africa','Regular',300),(3,'South Africa','Eco-friendly',250); | SELECT SUM(participants) FROM Tours WHERE country = 'South Africa' AND type = 'Eco-friendly'; |
What is the average movie rating for each director? | CREATE TABLE movies (title VARCHAR(255),rating INT,director VARCHAR(50)); INSERT INTO movies (title,rating,director) VALUES ('Movie1',8,'DirectorA'),('Movie2',7,'DirectorB'),('Movie3',9,'DirectorA'),('Movie4',6,'DirectorB'); | SELECT director, AVG(rating) as avg_rating FROM movies GROUP BY director; |
What is the number of mental health parity regulations implemented in New York and Florida since 2015? | CREATE TABLE MentalHealthParityRegulations (State VARCHAR(20),Year INT,Regulation VARCHAR(100)); INSERT INTO MentalHealthParityRegulations (State,Year,Regulation) VALUES ('New York',2016,'Regulation 1'),('New York',2018,'Regulation 2'),('Florida',2017,'Regulation A'),('Florida',2019,'Regulation B'); | SELECT * FROM MentalHealthParityRegulations WHERE State IN ('New York', 'Florida') AND Year >= 2015; |
Calculate the average miles per gallon for domestic vehicles | CREATE TABLE vehicle_stats (id INT,vehicle_make VARCHAR(50),mpg INT,is_domestic BOOLEAN); INSERT INTO vehicle_stats (id,vehicle_make,mpg,is_domestic) VALUES (1,'Toyota',32,false),(2,'Honda',35,false),(3,'Ford',28,true),(4,'Chevy',25,true),(5,'Tesla',null,true); | SELECT AVG(mpg) as avg_mpg FROM vehicle_stats WHERE is_domestic = true; |
What is the number of projects in the 'Water_Distribution' table that have a total cost greater than $3,000,000.00? | CREATE TABLE Water_Distribution (project_id INT,project_name VARCHAR(100),total_cost FLOAT); INSERT INTO Water_Distribution (project_id,project_name,total_cost) VALUES (1,'Water Treatment Plant',5000000.00),(2,'Pipe Replacement',2000000.00),(4,'Water Main Installation',4000000.00); | SELECT COUNT(*) FROM Water_Distribution WHERE total_cost > 3000000.00; |
What is the health equity metric performance for each community health worker? | CREATE TABLE HealthEquityMetrics (ID INT,CommunityHealthWorker VARCHAR(50),Score INT); INSERT INTO HealthEquityMetrics (ID,CommunityHealthWorker,Score) VALUES (1,'John Doe',95),(2,'Jane Smith',88); | SELECT CommunityHealthWorker, Score, RANK() OVER (PARTITION BY Score ORDER BY CommunityHealthWorker) as Rank FROM HealthEquityMetrics; |
How many unique audience members attended events in 2021? | CREATE TABLE Audience (AudienceID INT,AudienceName VARCHAR(50)); CREATE TABLE AudienceAttendance (EventID INT,AudienceID INT); INSERT INTO Audience (AudienceID,AudienceName) VALUES (1,'Alice'),(2,'Bob'),(3,'Charlie'); INSERT INTO AudienceAttendance (EventID,AudienceID) VALUES (1,1),(1,2),(2,1),(2,3); | SELECT COUNT(DISTINCT a.AudienceID) as NumUniqueAudienceMembers FROM Audience a INNER JOIN AudienceAttendance aa ON a.AudienceID = aa.AudienceID INNER JOIN Events e ON aa.EventID = e.EventID WHERE e.EventDate >= '2021-01-01' AND e.EventDate < '2022-01-01'; |
Delete the record for Maria Garcia from the 'volunteers' table | CREATE TABLE volunteers (id INT PRIMARY KEY,name VARCHAR(255),email VARCHAR(255),hours_per_week FLOAT); | DELETE FROM volunteers WHERE name = 'Maria Garcia'; |
List patients who have used interpreter services but do not have mental health parity. | CREATE TABLE patients (id INT,name VARCHAR(50),ethnicity VARCHAR(50),mental_health_parity BOOLEAN); INSERT INTO patients (id,name,ethnicity,mental_health_parity) VALUES (1,'Alice','Caucasian',true),(2,'Brian','African American',false); CREATE TABLE interpreter_services (id INT,patient_id INT,interpreter_language VARCHA... | SELECT patients.name FROM patients WHERE mental_health_parity = false INTERSECT SELECT patients.name FROM patients INNER JOIN interpreter_services ON patients.id = interpreter_services.patient_id; |
What is the maximum recycling rate for plastic in 2020 for each state? | CREATE TABLE recycling_rates(year INT,state VARCHAR(255),plastic_recycling FLOAT,paper_recycling FLOAT,glass_recycling FLOAT); INSERT INTO recycling_rates VALUES (2020,'California',0.6,0.7,0.5),(2020,'Texas',0.5,0.6,0.4); | SELECT MAX(plastic_recycling) AS max_plastic_recycling, state FROM recycling_rates WHERE year = 2020 GROUP BY state; |
What is the average speed of vessels in the Arctic, grouped by month and vessel type? | CREATE TABLE vessels (id INT,name TEXT,type TEXT,speed FLOAT,gps_position TEXT); CREATE TABLE gps_positions (id INT,latitude FLOAT,longitude FLOAT,country TEXT,month INT); | SELECT v.type, AVG(v.speed), g.month FROM vessels v JOIN gps_positions g ON v.gps_position = g.id WHERE g.country = 'Arctic' GROUP BY v.type, g.month; |
What is the average tourist spending in Indonesia? | CREATE TABLE Spending (id INT,country TEXT,year INT,spending FLOAT); INSERT INTO Spending (id,country,year,spending) VALUES (1,'Indonesia',2018,1000),(2,'Indonesia',2019,1200),(3,'Indonesia',2020,800); | SELECT AVG(spending) FROM Spending WHERE country = 'Indonesia'; |
List all marine protected areas in the Atlantic Ocean and their depths. | CREATE TABLE marine_protected_areas (area_name TEXT,ocean_basin TEXT,depth FLOAT); INSERT INTO marine_protected_areas (area_name,ocean_basin,depth) VALUES ('Galapagos Islands','Pacific',2000.0),('Great Barrier Reef','Pacific',1000.0),('Palau National Marine Sanctuary','Pacific',5000.0),('Northwest Atlantic Marine Natio... | SELECT area_name, depth FROM marine_protected_areas WHERE ocean_basin = 'Atlantic'; |
What is the total investment in the Energy sector, broken down by ESG factors? | CREATE TABLE investments_esg (id INT,sector VARCHAR(255),esg_factor VARCHAR(255),investment_amount INT); INSERT INTO investments_esg (id,sector,esg_factor,investment_amount) VALUES (1,'Energy','E',500000),(2,'Energy','S',350000),(3,'Energy','G',450000); | SELECT sector, esg_factor, SUM(investment_amount) FROM investments_esg WHERE sector = 'Energy' GROUP BY sector, esg_factor; |
Delete records from the 'multimodal_mobility' table where the 'mode' is 'Bus' | CREATE TABLE multimodal_mobility (id INT,city VARCHAR(50),mode VARCHAR(50),users INT); | DELETE FROM multimodal_mobility WHERE mode = 'Bus'; |
What's the average age of male members who do yoga? | CREATE TABLE Members (ID INT,Gender VARCHAR(10),Age INT,Activity VARCHAR(20)); INSERT INTO Members (ID,Gender,Age,Activity) VALUES (1,'Male',35,'Yoga'); | SELECT AVG(Age) FROM Members WHERE Gender = 'Male' AND Activity = 'Yoga'; |
How many games were played in the 'Strategy' genre that have more than 1000 players? | CREATE TABLE games (game_id INT,game_genre VARCHAR(255),num_players INT); | SELECT COUNT(game_id) FROM games WHERE game_genre = 'Strategy' HAVING num_players > 1000; |
Identify the number of threat intelligence reports generated in the last 6 months by region | CREATE TABLE threat_intelligence (report_id INT,report_date DATE,region TEXT); INSERT INTO threat_intelligence (report_id,report_date,region) VALUES (1,'2022-01-01','Northeast'),(2,'2022-02-15','Midwest'); | SELECT region, COUNT(report_id) FROM threat_intelligence WHERE report_date >= DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH) GROUP BY region; |
List all unique station names and their corresponding latitudes and longitudes from the stations table | CREATE TABLE stations (station_id INTEGER,name TEXT,latitude REAL,longitude REAL); INSERT INTO stations (station_id,name,latitude,longitude) VALUES (1,'Downtown',40.7128,-74.0060); | SELECT DISTINCT name, latitude, longitude FROM stations; |
What is the percentage of dishes that meet the daily recommended intake of fiber? | CREATE TABLE dishes (dish_id INT,name VARCHAR(50),fiber INT,serving_size INT); INSERT INTO dishes (dish_id,name,fiber,serving_size) VALUES (1,'Quinoa Salad',8,200),(2,'Lentil Soup',12,300),(3,'Chickpea Curry',10,350); | SELECT 100.0 * COUNT(*) / (SELECT COUNT(*) FROM dishes) AS percentage FROM dishes WHERE fiber >= (SELECT serving_size * 0.5); |
What is the total value of defense contracts signed by vendors from California in Q1 2020? | CREATE TABLE defense_contracts (contract_id INT,vendor_state VARCHAR(2),contract_value DECIMAL(10,2),contract_date DATE); INSERT INTO defense_contracts VALUES (1,'CA',500000.00,'2020-01-05'),(2,'CA',600000.00,'2020-01-10'),(3,'TX',400000.00,'2020-01-15'); | SELECT SUM(contract_value) FROM defense_contracts WHERE vendor_state = 'CA' AND contract_date >= '2020-01-01' AND contract_date < '2020-04-01'; |
What is the average labor productivity per mine by state in the USA? | CREATE TABLE labor_productivity (id INT,mine_id INT,state TEXT,employees INT,production INT); INSERT INTO labor_productivity (id,mine_id,state,employees,production) VALUES (1,3,'Texas',50,2000),(2,3,'Texas',50,2000),(3,4,'California',75,3000); | SELECT state, AVG(production/employees) as avg_productivity FROM labor_productivity GROUP BY state; |
What is the total number of posts created by users in 'California' between '2021-01-01' and '2021-03-31'? | CREATE TABLE users (id INT,name VARCHAR(50),gender VARCHAR(10),age INT,location VARCHAR(50)); CREATE TABLE posts (id INT,user_id INT,content TEXT,timestamp TIMESTAMP); | SELECT COUNT(posts.id) AS total_posts FROM posts JOIN users ON posts.user_id = users.id WHERE users.location = 'California' AND posts.timestamp BETWEEN '2021-01-01' AND '2021-03-31'; |
Add a new innovation trend for the industry 'technology' in the 'trends' table | trends(id,industry,innovation_trend,trend_impact) | INSERT INTO trends (id, industry, innovation_trend, trend_impact) VALUES (4, 'technology', 'AI in healthcare', 0.9); |
What is the number of policy advocacy events held in 2021? | CREATE TABLE Policy_Advocacy_Events (event_id INT,year INT,type VARCHAR(255)); INSERT INTO Policy_Advocacy_Events VALUES (1,2021,'Webinar'); | SELECT COUNT(*) FROM Policy_Advocacy_Events WHERE year = 2021; |
What was the average donation amount by payment method in Q2 2023? | CREATE TABLE payment_methods (id INT,payment_method VARCHAR(50),donation_date DATE,donation_amount FLOAT); INSERT INTO payment_methods (id,payment_method,donation_date,donation_amount) VALUES (1,'Credit Card','2023-04-01',50.0),(2,'Debit Card','2023-05-15',100.0),(3,'PayPal','2023-06-30',200.0); | SELECT payment_method, AVG(donation_amount) FROM payment_methods WHERE donation_date BETWEEN '2023-04-01' AND '2023-06-30' GROUP BY payment_method; |
What is the average income by occupation and gender, and how does it compare to the overall average income? | CREATE TABLE OccupationGenderData (Occupation VARCHAR(255),Gender VARCHAR(10),AvgIncome DECIMAL(10,2)); INSERT INTO OccupationGenderData (Occupation,Gender,AvgIncome) VALUES ('Occupation A','Male',50000.00),('Occupation A','Female',45000.00),('Occupation B','Male',60000.00),('Occupation B','Female',55000.00); CREATE TA... | SELECT Occupation, Gender, AvgIncome, AvgIncome * 100.0 / (SELECT OverallAvgIncome FROM OverallData) AS Percentage FROM OccupationGenderData; |
Create a new view that shows the hotels and their sustainable practices | CREATE TABLE hotels (id INT PRIMARY KEY,name VARCHAR(255),country VARCHAR(255)); CREATE TABLE sustainable_practices (id INT PRIMARY KEY,hotel_id INT,practice VARCHAR(255)); INSERT INTO hotels (id,name,country) VALUES (1,'Eco-Friendly Hotel','Sweden'); INSERT INTO hotels (id,name,country) VALUES (2,'Sustainable Resort',... | CREATE VIEW hotel_sustainable_practices AS SELECT hotels.name, sustainable_practices.practice FROM hotels INNER JOIN sustainable_practices ON hotels.id = sustainable_practices.hotel_id; |
What is the latest transaction time in the 'transactions' table? | CREATE TABLE transactions (id INT,tx_hash VARCHAR(50),tx_type VARCHAR(10),block_height INT,tx_time TIMESTAMP); INSERT INTO transactions (id,tx_hash,tx_type,block_height,tx_time) VALUES (1,'0x123...','transfer',1000000,'2021-01-01 00:00:00'),(2,'0x456...','deploy',1000001,'2021-01-02 00:00:00'); | SELECT MAX(tx_time) FROM transactions; |
Update the price of 'Silk' garments to $25.00 in the garment table. | CREATE TABLE garment (id INT PRIMARY KEY,garment_name VARCHAR(255),quantity INT,price DECIMAL(5,2)); INSERT INTO garment (id,garment_name,quantity,price) VALUES (1,'Rayon',100,15.00),(2,'Silk',0,0),(3,'Cotton',200,20.00); | UPDATE garment SET price = 25.00 WHERE garment_name = 'Silk'; |
How many workers in the 'Retail' industry have a 'Full-time' status? | CREATE TABLE Workers (id INT,industry VARCHAR(20),employment_status VARCHAR(20)); INSERT INTO Workers (id,industry,employment_status) VALUES (1,'Manufacturing','Part-time'),(2,'Retail','Full-time'),(3,'Manufacturing','Full-time'); | SELECT COUNT(*) FROM Workers WHERE industry = 'Retail' AND employment_status = 'Full-time'; |
Show the number of new users who signed up from India in the past week and the number of new users who signed up from India in the past month. | CREATE TABLE users (id INT,country VARCHAR(255),created_at TIMESTAMP); | SELECT COUNT(*) as last_week, (SELECT COUNT(*) FROM users WHERE country = 'India' AND created_at > NOW() - INTERVAL '1 month') as last_month FROM users WHERE country = 'India' AND created_at > NOW() - INTERVAL '1 week'; |
What is the maximum number of streams for a song by an artist from Canada? | CREATE TABLE Songs (id INT,title VARCHAR(100),artist VARCHAR(100),streams INT); CREATE TABLE Artists (id INT,name VARCHAR(100),country VARCHAR(100)); | SELECT MAX(s.streams) FROM Songs s JOIN Artists a ON s.artist = a.name WHERE a.country = 'Canada'; |
Insert a new player, 'Leila Zhang', aged 28 from China | CREATE TABLE players (id INT PRIMARY KEY,name VARCHAR(50),age INT,country VARCHAR(50)); | INSERT INTO players (name, age, country) VALUES ('Leila Zhang', 28, 'China'); |
What is the average number of people affected by the digital divide in Asia? | CREATE TABLE digital_divide_asia (country VARCHAR(20),population INT,affected INT); INSERT INTO digital_divide_asia (country,population,affected) VALUES ('China',1439323776,197243372),('India',1380004385,191680581),('Indonesia',273523615,39032361); | SELECT AVG(affected) FROM digital_divide_asia WHERE country = 'Asia'; |
What is the total number of mobile customers in the telecom company's database who are using exactly 3GB of data per month? | CREATE TABLE mobile_data_usage (customer_id INT,data_usage FLOAT); INSERT INTO mobile_data_usage (customer_id,data_usage) VALUES (1,3.0),(2,4.5),(3,1.9),(4,3.1); | SELECT COUNT(*) FROM mobile_data_usage WHERE data_usage = 3.0; |
Get the number of cybersecurity vulnerabilities for each product in the last year | CREATE TABLE products (product_name VARCHAR(50),vendor VARCHAR(50)); CREATE TABLE vulnerabilities (product_name VARCHAR(50),published DATE,cvss_score FLOAT); INSERT INTO products (product_name,vendor) VALUES ('Windows 10','Microsoft'),('Office 365','Microsoft'),('iPhone','Apple'),('macOS','Apple'); INSERT INTO vulnerab... | SELECT products.product_name, COUNT(*) as vulnerability_count FROM products INNER JOIN vulnerabilities ON products.product_name = vulnerabilities.product_name WHERE vulnerabilities.published >= DATE(NOW()) - INTERVAL 1 YEAR GROUP BY products.product_name; |
How many patients started therapy in Paris each quarter of 2021? | CREATE TABLE therapy (therapy_id INT,patient_id INT,therapist_id INT,therapy_date DATE,city TEXT); INSERT INTO therapy (therapy_id,patient_id,therapist_id,therapy_date,city) VALUES (1,1,101,'2018-01-02','Paris'); | SELECT DATE_TRUNC('quarter', therapy_date) as quarter, COUNT(DISTINCT patient_id) as num_patients FROM therapy WHERE city = 'Paris' AND EXTRACT(YEAR FROM therapy_date) = 2021 GROUP BY quarter ORDER BY quarter; |
What is the total number of users who have posted a story on Snapchat in the past week and who are located in a state with a population of over 10 million? | CREATE TABLE snapchat_stories (story_id INT,user_id INT,story_date DATE);CREATE TABLE users (user_id INT,state VARCHAR(50),registration_date DATE);CREATE TABLE state_populations (state VARCHAR(50),population INT); | SELECT COUNT(DISTINCT s.user_id) as num_users FROM snapchat_stories s JOIN users u ON s.user_id = u.user_id JOIN state_populations sp ON u.state = sp.state WHERE s.story_date >= DATE(NOW()) - INTERVAL 1 WEEK AND sp.population > 10000000; |
What is the average budget for public transportation projects in the "projects" table for projects with a budget between $5 million and $15 million? | CREATE TABLE projects (project_id INT,project_name VARCHAR(50),budget DECIMAL(10,2),area VARCHAR(50)); INSERT INTO projects (project_id,project_name,budget,area) VALUES (1,'ProjectQ',6000000.00,'Urban'),(2,'ProjectR',12000000.00,'Urban'),(3,'ProjectS',18000000.00,'Urban'); | SELECT AVG(budget) FROM projects WHERE budget BETWEEN 5000000.00 AND 15000000.00; |
Update the safety protocol for 'Ammonia' in the "safety_protocols" table | CREATE TABLE safety_protocols (id INT PRIMARY KEY,chemical_name VARCHAR(255),safety_protocol VARCHAR(255),date_implemented DATE); INSERT INTO safety_protocols (id,chemical_name,safety_protocol,date_implemented) VALUES (1,'Ammonia','Always wear safety goggles when handling','2022-01-01'); | UPDATE safety_protocols SET safety_protocol = 'Always wear safety goggles and gloves when handling' WHERE chemical_name = 'Ammonia'; |
Find the total quantity of products made from recycled materials. | CREATE TABLE ProductTransparency (product_id INT,recycled_materials BOOLEAN); INSERT INTO ProductTransparency (product_id,recycled_materials) VALUES (1,TRUE),(2,FALSE),(3,TRUE); CREATE TABLE Products (product_id INT,quantity INT); INSERT INTO Products (product_id,quantity) VALUES (1,10),(2,20),(3,30); | SELECT SUM(quantity) FROM Products INNER JOIN ProductTransparency ON Products.product_id = ProductTransparency.product_id WHERE ProductTransparency.recycled_materials = TRUE; |
Who is the lead researcher for the genetic research project 'Genome Mapping' in Brazil? | CREATE TABLE genetics_research (id INT,project_name VARCHAR(50),lead_name VARCHAR(50),lead_email VARCHAR(50),location VARCHAR(50)); INSERT INTO genetics_research (id,project_name,lead_name,lead_email,location) VALUES (1,'Genome Mapping','Jose Silva','jose.silva@email.com.br','Brazil'); INSERT INTO genetics_research (id... | SELECT lead_name FROM genetics_research WHERE project_name = 'Genome Mapping' AND location = 'Brazil'; |
List all the unique investment products and their associated asset classes. | CREATE TABLE investment_products (id INT,name VARCHAR(50),asset_class VARCHAR(50)); INSERT INTO investment_products (id,name,asset_class) VALUES (1,'Stock A','Equities'),(2,'Bond B','Fixed Income'),(3,'Mutual Fund C','Equities'),(4,'ETF D','Commodities'); | SELECT DISTINCT name, asset_class FROM investment_products; |
List the unique professional development courses attended by teachers in 'New York'? | CREATE TABLE teacher_pd (teacher_id INT,course_name VARCHAR(50),location VARCHAR(20)); INSERT INTO teacher_pd (teacher_id,course_name,location) VALUES (101,'Python for Educators','New York'),(102,'Data Science for Teachers','Chicago'),(103,'Open Pedagogy','New York'); | SELECT DISTINCT course_name FROM teacher_pd WHERE location = 'New York'; |
What is the total installed capacity of solar farms in 'Arizona'? | CREATE TABLE solar_farms (id INT,state VARCHAR(20),capacity FLOAT); INSERT INTO solar_farms (id,state,capacity) VALUES (1,'Arizona',120.5),(2,'Nevada',150.2),(3,'Arizona',180.1),(4,'Oregon',200.5); | SELECT SUM(capacity) FROM solar_farms WHERE state = 'Arizona'; |
List the top 5 cities with the highest number of green buildings in the 'GreenBuildings' table. | CREATE TABLE GreenBuildings (id INT,name VARCHAR(100),location VARCHAR(100),energy_consumption FLOAT); | SELECT location, COUNT(*) as building_count FROM GreenBuildings GROUP BY location ORDER BY building_count DESC LIMIT 5; |
List the names and maximum depths of all deep-sea trenches in the Indian ocean. | CREATE TABLE deep_sea_trenches (trench_name TEXT,location TEXT,max_depth FLOAT); INSERT INTO deep_sea_trenches (trench_name,location,max_depth) VALUES ('Trench 1','Indian Ocean',7600.0),('Trench 2','Pacific Ocean',8601.0),('Trench 3','Indian Ocean',8000.0); | SELECT trench_name, max_depth FROM deep_sea_trenches WHERE location = 'Indian Ocean'; |
Identify the top 3 cities with the highest budget allocated for environmental services, for the fiscal year 2023, and their respective budgets. | CREATE TABLE city_environmental_budget (city VARCHAR(255),fiscal_year INT,budget DECIMAL(10,2)); INSERT INTO city_environmental_budget (city,fiscal_year,budget) VALUES ('New York',2023,12000000.00),('Los Angeles',2023,10000000.00),('Chicago',2023,15000000.00),('Houston',2023,8000000.00),('Miami',2023,9000000.00); | SELECT city, budget FROM (SELECT city, budget, ROW_NUMBER() OVER (ORDER BY budget DESC) as rank FROM city_environmental_budget WHERE fiscal_year = 2023 AND service = 'Environmental') as ranked_cities WHERE rank <= 3 |
What was the total construction labor cost for a specific project with project_id = 123? | CREATE TABLE labor_costs (project_id INT,labor_cost DECIMAL(10,2)); | SELECT SUM(labor_cost) FROM labor_costs WHERE project_id = 123; |
Show the average cargo weight per vessel, ranked in descending order. | CREATE TABLE VESSEL_CARGO (ID INT,VESSEL_ID INT,CARGO_TYPE VARCHAR(50),WEIGHT INT); INSERT INTO VESSEL_CARGO VALUES (1,1,'Container',2500); INSERT INTO VESSEL_CARGO VALUES (2,1,'Bulk',50000); INSERT INTO VESSEL_CARGO VALUES (3,2,'Container',3000); | SELECT V.NAME, AVG(VC.WEIGHT) AS AVG_WEIGHT, ROW_NUMBER() OVER(ORDER BY AVG(VC.WEIGHT) DESC) AS RANK FROM VESSEL_CARGO VC JOIN VESSELS V ON VC.VESSEL_ID = V.ID GROUP BY V.ID, V.NAME |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.