instruction
stringlengths 0
1.06k
| input
stringlengths 11
5.3k
| response
stringlengths 2
4.44k
|
---|---|---|
Add a new vessel 'Yamato' with maximum speed 32.7 knots to the 'vessel_performance' table | CREATE TABLE IF NOT EXISTS vessel_performance (id INT PRIMARY KEY,vessel_name VARCHAR(255),maximum_speed DECIMAL(5,2)); | INSERT INTO vessel_performance (id, vessel_name, maximum_speed) VALUES (1, 'Yamato', 32.7); |
What is the average age of museum members from the Asia-Pacific region? | CREATE TABLE members(member_id INT,name VARCHAR(50),age INT,member_region VARCHAR(50)); INSERT INTO members (member_id,name,age,member_region) VALUES (1,'John Doe',25,'North America'),(2,'Jane Smith',30,'Europe'),(3,'Alice Johnson',35,'Asia-Pacific'); | SELECT AVG(age) FROM members WHERE member_region = 'Asia-Pacific'; |
What is the minimum heart rate for each member in the past year? | CREATE TABLE member_data(id INT,heart_rate INT,registration_date DATE); INSERT INTO member_data(id,heart_rate,registration_date) VALUES (1,70,'2021-01-02'),(2,80,'2021-03-14'),(3,65,'2021-05-29'),(4,90,'2021-07-15'),(5,75,'2021-10-01'),(6,85,'2021-12-18'); | SELECT id, MIN(heart_rate) FROM member_data WHERE registration_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR) GROUP BY id; |
How many agricultural innovations were introduced between 2018 and 2020? | CREATE TABLE agri_innovations (id INT,innovation_name VARCHAR(255),introduction_year INT); INSERT INTO agri_innovations (id,innovation_name,introduction_year) VALUES (1,'Precision Agriculture',2018),(2,'Drip Irrigation',2019),(3,'Vertical Farming',2021); | SELECT COUNT(*) FROM agri_innovations WHERE introduction_year BETWEEN 2018 AND 2020; |
List the top 5 aircraft models with the most flight hours in the Southwest region. | CREATE TABLE Flight_Hours (aircraft_model VARCHAR(255),region VARCHAR(255),flight_hours INT); INSERT INTO Flight_Hours (aircraft_model,region,flight_hours) VALUES ('B737','Southwest',5000),('A320','Northeast',6000),('B737','Southwest',5500); | SELECT aircraft_model, SUM(flight_hours) FROM Flight_Hours WHERE region = 'Southwest' GROUP BY aircraft_model ORDER BY SUM(flight_hours) DESC LIMIT 5; |
What is the latest launch date for a satellite from any country in Asia? | CREATE TABLE Satellite (ID INT,Name TEXT,Country TEXT,LaunchDate DATE); INSERT INTO Satellite (ID,Name,Country,LaunchDate) VALUES (1,'GSAT-1','India','2004-06-18'),(2,'INSAT-3A','India','2003-04-10'),(3,'RS-1','Russia','2012-06-17'),(4,'Sentinel-1A','Europe','2014-04-03'),(5,'Yaogan-20','China','2014-09-25'),(6,'GSAT-16','India','2014-12-06'); | SELECT MAX(LaunchDate) AS LatestLaunchDate FROM Satellite WHERE Country IN ('India', 'China'); |
What is the total number of research projects conducted in the aerospace domain per year? | CREATE TABLE Research_Projects (ID INT,Year INT,Domain VARCHAR(50),Number_Of_Projects INT); INSERT INTO Research_Projects (ID,Year,Domain,Number_Of_Projects) VALUES (1,2015,'Aerospace',50),(2,2016,'Aerospace',60),(3,2017,'Aerospace',70),(4,2018,'Aerospace',80),(5,2019,'Aerospace',90); | SELECT Year, SUM(Number_Of_Projects) FROM Research_Projects GROUP BY Year; |
What are the dissolved oxygen levels for fish farms in the Atlantic ocean? | CREATE TABLE atlantic_fish_farms (id INT,name VARCHAR(50),country VARCHAR(50),dissolved_oxygen FLOAT); INSERT INTO atlantic_fish_farms (id,name,country,dissolved_oxygen) VALUES (1,'Farm G','USA',6.8),(2,'Farm H','Canada',7.2),(3,'Farm I','USA',7.0),(4,'Farm J','Brazil',6.5); | SELECT country, dissolved_oxygen FROM atlantic_fish_farms WHERE country IN ('USA', 'Canada', 'Brazil'); |
How many people with disabilities attended dance performances in the past 6 months? | CREATE TABLE dance_performances (id INT,performance_date DATE,attendee_count INT,attendee_disability BOOLEAN); INSERT INTO dance_performances (id,performance_date,attendee_count,attendee_disability) VALUES (1,'2021-06-10',200,true),(2,'2021-06-11',300,false),(3,'2021-06-12',150,true),(4,'2021-12-01',400,false); | SELECT SUM(attendee_count) FROM dance_performances WHERE attendee_disability = true AND performance_date BETWEEN '2021-06-01' AND '2021-12-31'; |
What percentage of visitors to jazz events in New Orleans are repeat attendees? | CREATE TABLE Visitors (visitor_id INT,event_name TEXT,city TEXT); INSERT INTO Visitors (visitor_id,event_name,city) VALUES (1,'Jazz Festival','New Orleans'),(2,'Jazz Festival','New Orleans'),(3,'Jazz Concert','New Orleans'),(4,'Jazz Festival','New Orleans'); | SELECT COUNT(DISTINCT visitor_id) * 100.0 / (SELECT COUNT(DISTINCT visitor_id) FROM Visitors WHERE city = 'New Orleans' AND event_name LIKE '%Jazz%') FROM Visitors WHERE city = 'New Orleans' AND event_name LIKE '%Jazz%'; |
How many chemical spills occurred in the southeast region in the past year, grouped by month? | CREATE TABLE spills (id INT,date DATE,location TEXT,chemical TEXT); INSERT INTO spills (id,date,location,chemical) VALUES (1,'2022-01-01','Georgia','Acetone'),(2,'2022-02-15','Florida','Ammonia'),(3,'2022-03-05','Alabama','Benzene'); | SELECT EXTRACT(MONTH FROM date) AS month, COUNT(*) AS num_spills FROM spills WHERE location LIKE 'Southeast%' AND date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR) GROUP BY month; |
Which countries have not received any climate finance for climate adaptation? | CREATE TABLE country_climate_finance(country TEXT,sector TEXT,amount_funded FLOAT); | SELECT country FROM country_climate_finance WHERE sector = 'climate adaptation' GROUP BY country HAVING SUM(amount_funded) = 0; |
Find the number of transactions involving 'non-GMO' produce in the 'Midwest' region. | CREATE TABLE transactions (id INT,product TEXT,region TEXT,non_gmo BOOLEAN); INSERT INTO transactions (id,product,region,non_gmo) VALUES (3,'Product 3','Midwest',true),(4,'Product 4','West',false); | SELECT COUNT(*) FROM transactions WHERE region = 'Midwest' AND non_gmo = true; |
What is the average price of crops grown using 'permaculture' techniques? | CREATE TABLE crops (id INT,name VARCHAR(20),farming_system VARCHAR(20),price DECIMAL(6,2)); | SELECT AVG(price) FROM crops WHERE farming_system = 'permaculture'; |
What is the total budget allocated for accessibility improvements across all departments and years? | CREATE TABLE Budget_Allocation (id INT,department VARCHAR(50),year INT,allocation DECIMAL(10,2)); INSERT INTO Budget_Allocation (id,department,year,allocation) VALUES (1,'Student Services',2020,50000.00),(2,'Faculty Development',2020,35000.00),(3,'Student Services',2021,60000.00),(4,'Faculty Development',2021,40000.00),(5,'Accessibility',2020,25000.00),(6,'Accessibility',2021,30000.00); | SELECT SUM(Budget_Allocation.allocation) as total_allocation FROM Budget_Allocation WHERE Budget_Allocation.department = 'Accessibility'; |
List all regulatory frameworks that have been associated with at least one smart contract, ordered by the name of the regulatory framework in ascending order. | CREATE TABLE regulatory_framework (id INT,name VARCHAR(255)); CREATE TABLE smart_contracts (id INT,name VARCHAR(255),framework_id INT); INSERT INTO regulatory_framework (id,name) VALUES (1,'EU GDPR'),(2,'US CFTC'),(3,'Japan FSA'),(4,'UK FCA'); INSERT INTO smart_contracts (id,name,framework_id) VALUES (1,'SC1',1),(2,'SC2',1),(3,'SC3',2),(4,'SC4',NULL); | SELECT r.name FROM regulatory_framework r JOIN smart_contracts s ON r.id = s.framework_id WHERE s.framework_id IS NOT NULL ORDER BY r.name ASC; |
What is the total carbon sequestered per supplier? | CREATE TABLE suppliers (supplier_id INT,supplier_name TEXT);CREATE TABLE carbon_sequestration (sequestration_id INT,supplier_id INT,sequestration_rate FLOAT,year INT); INSERT INTO suppliers (supplier_id,supplier_name) VALUES (1,'Supplier X'),(2,'Supplier Y'); INSERT INTO carbon_sequestration (sequestration_id,supplier_id,sequestration_rate,year) VALUES (1,1,12.5,2010),(2,1,13.2,2011),(3,2,15.3,2010),(4,2,15.6,2011); | SELECT supplier_id, supplier_name, SUM(sequestration_rate) FROM carbon_sequestration JOIN suppliers ON carbon_sequestration.supplier_id = suppliers.supplier_id GROUP BY supplier_id, supplier_name; |
What is the average rating of foundations with a vegan label? | CREATE TABLE products (product_id INT,name VARCHAR(255),category VARCHAR(255),rating FLOAT,vegan BOOLEAN); | SELECT AVG(rating) FROM products WHERE category = 'foundation' AND vegan = TRUE; |
What is the maximum response time for emergencies in the 'Central' district? | CREATE TABLE districts (district_id INT,district_name TEXT);CREATE TABLE emergencies (emergency_id INT,district_id INT,response_time INT); | SELECT MAX(response_time) FROM emergencies WHERE district_id = (SELECT district_id FROM districts WHERE district_name = 'Central'); |
What is the maximum threat intelligence report score for cyber threats originating from Russia? | CREATE TABLE threat_intelligence (report_id INT,source_country VARCHAR(20),score INT); INSERT INTO threat_intelligence (report_id,source_country,score) VALUES (1,'Russia',85),(2,'China',80),(3,'Iran',70); | SELECT MAX(score) FROM threat_intelligence WHERE source_country = 'Russia'; |
What are the names of the countries where peacekeeping operations were conducted by the European Union in 2010? | CREATE TABLE eu_peacekeeping_operations (id INT,country VARCHAR(255),operation_name VARCHAR(255),start_date DATE); INSERT INTO eu_peacekeeping_operations (id,country,operation_name,start_date) VALUES (1,'Democratic Republic of the Congo','European Union Force','2010-01-01'); | SELECT DISTINCT country FROM eu_peacekeeping_operations WHERE start_date LIKE '2010%'; |
What is the client's total investment and the number of investments they have made? | CREATE TABLE clients (client_id INT,name TEXT,investment_type TEXT,investment FLOAT); INSERT INTO clients (client_id,name,investment_type,investment) VALUES (1,'John Doe','Stocks',3000.00),(1,'John Doe','Bonds',2000.00),(2,'Jane Smith','Stocks',5000.00); | SELECT client_id, name, SUM(investment) OVER (PARTITION BY client_id ORDER BY client_id) as total_investment, COUNT(*) OVER (PARTITION BY client_id ORDER BY client_id) as number_of_investments FROM clients; |
Which clients have investments in both Tech Stocks and Renewable Energy Stocks? | CREATE TABLE ClientStockInvestments (ClientID INT,StockSymbol VARCHAR(10)); INSERT INTO ClientStockInvestments (ClientID,StockSymbol) VALUES (1,'AAPL'),(2,'GOOG'),(3,'MSFT'),(4,'TSLA'),(5,'SPWR'),(6,'ENPH'); CREATE TABLE Stocks (Symbol VARCHAR(10),Sector VARCHAR(20)); INSERT INTO Stocks (Symbol,Sector) VALUES ('AAPL','Tech'),('GOOG','Tech'),('MSFT','Tech'),('TSLA','Tech'),('FB','Tech'),('SPWR','Renewable Energy'),('ENPH','Renewable Energy'); | SELECT C1.ClientID FROM ClientStockInvestments C1 JOIN Stocks S1 ON C1.StockSymbol = S1.Symbol JOIN ClientStockInvestments C2 ON C1.ClientID = C2.ClientID JOIN Stocks S2 ON C2.StockSymbol = S2.Symbol WHERE S1.Sector = 'Tech' AND S2.Sector = 'Renewable Energy'; |
List all the unique destinations of container vessels for the month of June 2022 | CREATE TABLE vessel_destinations (vessel_name VARCHAR(50),destination VARCHAR(50),departure_date DATE,arrival_date DATE); INSERT INTO vessel_destinations VALUES ('Ever Given','Rotterdam','2022-06-01','2022-06-05'); INSERT INTO vessel_destinations VALUES ('HMM Algeciras','New York','2022-06-03','2022-06-10'); INSERT INTO vessel_destinations VALUES ('CMA CGM Jacques Saade','Singapore','2022-06-05','2022-06-15'); INSERT INTO vessel_destinations VALUES ('Seaspan Amazon','Tokyo','2022-06-10','2022-06-17'); INSERT INTO vessel_destinations VALUES ('MSC Virtuosa','Sydney','2022-06-15','2022-06-22'); | SELECT DISTINCT destination FROM vessel_destinations WHERE departure_date BETWEEN '2022-06-01' AND '2022-06-30'; |
List all materials used in the manufacturing sector in Brazil and South Africa. | CREATE TABLE material_data (material_name VARCHAR(50),country VARCHAR(50),industry VARCHAR(50)); INSERT INTO material_data (material_name,country,industry) VALUES ('Steel','Brazil','Manufacturing'),('Aluminum','Brazil','Manufacturing'),('Plastic','Brazil','Manufacturing'),('Glass','Brazil','Manufacturing'),('Titanium','South Africa','Manufacturing'),('Steel','South Africa','Manufacturing'),('Aluminum','South Africa','Manufacturing'); | SELECT DISTINCT material_name FROM material_data WHERE country IN ('Brazil', 'South Africa') AND industry = 'Manufacturing'; |
Find the excavation site with the highest total artifact weight for each country, along with the country and total weight. | CREATE TABLE ExcavationSites (SiteID INT,SiteName VARCHAR(50),Country VARCHAR(50),Year INT,ArtifactWeight FLOAT,ArtifactType VARCHAR(50)); INSERT INTO ExcavationSites (SiteID,SiteName,Country,Year,ArtifactWeight,ArtifactType) VALUES (1,'SiteA','USA',2020,23.5,'Pottery'),(2,'SiteB','Mexico',2020,14.2,'Stone Tool'),(3,'SiteC','USA',2019,34.8,'Bone Tool'),(4,'SiteD','Canada',2019,45.6,'Ceramic Figurine'),(5,'SiteE','Canada',2019,56.7,'Metal Artifact'); | SELECT SiteName, Country, SUM(ArtifactWeight) AS TotalWeight FROM ExcavationSites GROUP BY SiteName, Country HAVING COUNT(DISTINCT Year) = (SELECT COUNT(DISTINCT Year) FROM ExcavationSites GROUP BY Year); |
Find the top 3 longest songs in the Rock genre. | CREATE TABLE songs (song_id INT,song_length FLOAT,genre TEXT); INSERT INTO songs VALUES (1,450.3,'Rock'),(2,320.2,'Pop'),(3,500.5,'Rock'),(4,200.1,'Jazz'),(5,400.0,'Rock'); | SELECT * FROM (SELECT song_id, song_length, genre, ROW_NUMBER() OVER (ORDER BY song_length DESC) AS row_num FROM songs WHERE genre = 'Rock') AS subquery WHERE row_num <= 3; |
Insert a new donation from donor with ID 3 for $200 on 2022-03-20 to program ID 1. | CREATE TABLE Donors (DonorID INT,Name TEXT,Address TEXT); INSERT INTO Donors (DonorID,Name,Address) VALUES (1,'John Doe','123 Main St'); INSERT INTO Donors (DonorID,Name,Address) VALUES (2,'Jane Smith','456 Elm St'); INSERT INTO Donors (DonorID,Name,Address) VALUES (3,'Alice Johnson','789 Oak St'); CREATE TABLE Programs (ProgramID INT,Name TEXT,Budget DECIMAL); INSERT INTO Programs (ProgramID,Name,Budget) VALUES (1,'Education Support',5000); INSERT INTO Programs (ProgramID,Name,Budget) VALUES (2,'Senior Care',7000); CREATE TABLE Donations (DonationID INT,DonorID INT,ProgramID INT,Amount DECIMAL,DonationDate DATE); INSERT INTO Donations (DonationID,DonorID,ProgramID,Amount,DonationDate) VALUES (1,1,1,50.00,'2021-01-01'); INSERT INTO Donations (DonationID,DonorID,ProgramID,Amount,DonationDate) VALUES (2,1,2,75.00,'2021-03-15'); INSERT INTO Donations (DonationID,DonorID,ProgramID,Amount,DonationDate) VALUES (3,2,2,100.00,'2021-12-31'); | INSERT INTO Donations (DonationID, DonorID, ProgramID, Amount, DonationDate) VALUES (4, 3, 1, 200.00, '2022-03-20'); |
What was the total amount donated by the top 3 donors in 'q2_2022' donation period? | CREATE TABLE donors (id INT,name TEXT,total_donation FLOAT,donation_period TEXT); INSERT INTO donors (id,name,total_donation,donation_period) VALUES (1,'Sophia Garcia',700.00,'q2_2022'),(2,'James Kim',600.00,'q2_2022'),(3,'Lea Nguyen',500.00,'q2_2022'),(4,'Kevin Hernandez',400.00,'q2_2022'); | SELECT SUM(total_donation) FROM (SELECT total_donation FROM donors WHERE donors.id IN (SELECT id FROM donors WHERE donation_period = 'q2_2022' ORDER BY total_donation DESC LIMIT 3)) subquery; |
What is the total capacity of renewable energy plants in Australia? | CREATE TABLE renewable_plants (name TEXT,country TEXT,capacity FLOAT); INSERT INTO renewable_plants (name,country,capacity) VALUES ('Wind Farm A','Australia',150.0),('Solar Farm B','Australia',200.0),('Geothermal Plant C','Australia',75.0),('Hydroelectric Plant D','Australia',400.0); | SELECT SUM(capacity) FROM renewable_plants WHERE country = 'Australia'; |
Which solar power plants in Spain have a capacity greater than 50 MW? | CREATE TABLE solar_plants (id INT,name TEXT,country TEXT,capacity FLOAT); INSERT INTO solar_plants (id,name,country,capacity) VALUES (1,'La Solana','Spain',52.0),(2,'Don Rodrigo','Spain',174.4); | SELECT name, capacity FROM solar_plants WHERE country = 'Spain' AND capacity > 50.0; |
How many refugees are there in each region of 'regions' table and what are their names? | CREATE TABLE refugees (refugee_id INT,region_id INT,refugee_name VARCHAR(50)); CREATE TABLE regions (region_id INT,region_name VARCHAR(50)); INSERT INTO refugees (refugee_id,region_id,refugee_name) VALUES (1,1,'Ahmed'),(2,1,'Fatima'),(3,2,'Ali'),(4,2,'Aisha'),(5,3,'Hassan'),(6,3,'Zainab'),(7,4,'Khalid'),(8,4,'Noor'),(9,5,'Ayman'),(10,5,'Sara'),(11,1,'Hamza'),(12,1,'Hana'); INSERT INTO regions (region_id,region_name) VALUES (1,'Middle East'),(2,'North Africa'),(3,'East Africa'),(4,'Central Asia'),(5,'West Africa'); | SELECT region_name, COUNT(*) as num_refugees FROM refugees INNER JOIN regions ON refugees.region_id = regions.region_id GROUP BY region_name; |
What is the average score for AI tools designed for persons with disabilities? | CREATE TABLE ai_tools (id INT,name TEXT,type TEXT,score FLOAT); INSERT INTO ai_tools (id,name,type,score) VALUES (1,'ToolA','PersonsWithDisabilities',4.4),(2,'ToolB','SocialGood',4.6),(3,'ToolC','PersonsWithDisabilities',4.1); | SELECT AVG(score) FROM ai_tools WHERE type = 'PersonsWithDisabilities'; |
How many trains are there in total in the city of Tokyo? | CREATE TABLE trains (id INT,city VARCHAR(20),model VARCHAR(20)); INSERT INTO trains (id,city,model) VALUES (1,'Tokyo','E231'),(2,'Tokyo','E657'),(3,'Osaka','E001'); | SELECT COUNT(*) FROM trains WHERE city = 'Tokyo'; |
What is the average capacity of factories in Spain, France, and the United Kingdom? | CREATE TABLE factories (factory_id INT,location VARCHAR(50),capacity INT); INSERT INTO factories (factory_id,location,capacity) VALUES (1,'Madrid,Spain',5000),(2,'Paris,France',7000),(3,'London,UK',6000); | SELECT AVG(capacity) FROM factories WHERE location LIKE '%Spain%' OR location LIKE '%France%' OR location LIKE '%UK%'; |
Identify the bank with the highest percentage of loans above $10,000 for Shariah-compliant loans? | CREATE TABLE bank (id INT,name VARCHAR(50),type VARCHAR(50)); INSERT INTO bank (id,name,type) VALUES (1,'Green Bank','Shariah-compliant'),(2,'Fair Lending Bank','Socially Responsible'),(3,'Community Bank','Shariah-compliant'); CREATE TABLE loans (bank_id INT,amount DECIMAL(10,2),type VARCHAR(50)); INSERT INTO loans (bank_id,amount,type) VALUES (1,12000.00,'Shariah-compliant'),(1,15000.00,'Shariah-compliant'),(2,10000.00,'Socially Responsible'),(2,11000.00,'Socially Responsible'),(3,20000.00,'Shariah-compliant'),(3,25000.00,'Shariah-compliant'); | SELECT bank_id, 100.0 * SUM(CASE WHEN type = 'Shariah-compliant' AND amount > 10000 THEN amount ELSE 0 END) / SUM(CASE WHEN type = 'Shariah-compliant' THEN amount ELSE 0 END) as large_shariah_loan_percentage FROM loans GROUP BY bank_id ORDER BY large_shariah_loan_percentage DESC FETCH FIRST 1 ROW ONLY; |
What is the average salary for female managers in the financial institutions table? | CREATE TABLE financial_institutions (id INT PRIMARY KEY,name VARCHAR(255),type VARCHAR(255),location VARCHAR(255)); | SELECT AVG(salary) FROM employee_demographics WHERE role = 'Manager' AND gender = 'Female'; |
Find programs with no financial donations | CREATE TABLE programs (id INT,name VARCHAR); CREATE TABLE financial_donations (id INT,program_id INT,amount INT) | SELECT p.name FROM programs p LEFT JOIN financial_donations fd ON p.id = fd.program_id WHERE fd.program_id IS NULL; |
How many unique donors are there in each region? | CREATE TABLE donations (id INT,donor_name VARCHAR,donation_amount DECIMAL,donation_date DATE,region VARCHAR); INSERT INTO donations (id,donor_name,donation_amount,donation_date,region) VALUES (1,'John Doe',100,'2021-01-01','North America'); | SELECT region, COUNT(DISTINCT donor_name) FROM donations GROUP BY region; |
Update the total_donation column in the donors table to set the value to 600.00 for the record with id = 1. | CREATE TABLE donors (id INT,name VARCHAR(50),total_donation FLOAT); INSERT INTO donors (id,name,total_donation) VALUES (1,'John Doe',500.00),(2,'Jane Smith',350.00),(3,'Mike Johnson',200.00); | UPDATE donors SET total_donation = 600.00 WHERE id = 1; |
Which biotech startups were founded in the last 2 years and received funding from Angel Investors? | CREATE TABLE startups (id INT,name VARCHAR(50),funding_source_id INT,founded_date DATE); INSERT INTO startups VALUES (1,'StartupP',1003,'2021-01-01'); INSERT INTO startups VALUES (2,'StartupQ',1001,'2020-06-15'); INSERT INTO startups VALUES (3,'StartupR',1002,'2019-03-04'); | SELECT name FROM startups INNER JOIN funding_sources ON startups.funding_source_id = funding_sources.id WHERE founded_date >= DATE_SUB(CURRENT_DATE, INTERVAL 2 YEAR) AND funding_sources.name = 'Angel Investors'; |
What is the average income for all households in each city? | CREATE TABLE cities (id INT,name VARCHAR(255)); CREATE TABLE households (id INT,city_id INT,income INT); | SELECT c.name, AVG(h.income) AS avg_income FROM cities c JOIN households h ON c.id = h.city_id GROUP BY c.name; |
What is the total number of mental health parity violations reported in Illinois in 2020? | CREATE TABLE mental_health_parity (id INT,violation_date DATE,location TEXT); INSERT INTO mental_health_parity (id,violation_date,location) VALUES (1,'2020-01-01','Illinois'); INSERT INTO mental_health_parity (id,violation_date,location) VALUES (2,'2020-02-01','California'); INSERT INTO mental_health_parity (id,violation_date,location) VALUES (3,'2020-03-01','Illinois'); | SELECT COUNT(*) FROM mental_health_parity WHERE violation_date >= '2020-01-01' AND violation_date < '2021-01-01' AND location = 'Illinois'; |
What is the average rating of cultural heritage sites with virtual tours in Germany and Brazil? | CREATE TABLE Ratings(id INT,site_id INT,rating FLOAT); INSERT INTO Ratings(id,site_id,rating) VALUES (1,1,4.6),(2,2,3.9),(3,3,4.2),(4,4,4.9),(5,5,5.0); CREATE TABLE Sites(id INT,name TEXT,country TEXT,has_virtual_tour BOOLEAN); INSERT INTO Sites(id,name,country,has_virtual_tour) VALUES (1,'Taj Mahal','India',true),(2,'Red Fort','India',false),(3,'Pink Palace','India',true),(4,'Brandenburg Gate','Germany',true),(5,'Christ the Redeemer','Brazil',true); | SELECT AVG(Ratings.rating) FROM Ratings JOIN Sites ON Ratings.site_id = Sites.id WHERE Sites.country IN ('Germany', 'Brazil') AND Sites.has_virtual_tour = true; |
How many artworks were sold by each gallery in 2021? | CREATE TABLE GallerySales (Gallery VARCHAR(255),ArtWork VARCHAR(255),Year INT,QuantitySold INT); INSERT INTO GallerySales (Gallery,ArtWork,Year,QuantitySold) VALUES ('Gallery 1','Artwork 1',2021,5),('Gallery 1','Artwork 2',2021,3),('Gallery 2','Artwork 3',2021,1),('Gallery 2','Artwork 4',2021,4); | SELECT Gallery, SUM(QuantitySold) as TotalQuantitySold FROM GallerySales WHERE Year = 2021 GROUP BY Gallery; |
What are the top 3 species with the most sightings across all arctic research stations? | CREATE TABLE research_station (id INT,name TEXT); INSERT INTO research_station (id,name) VALUES (1,'Station A'); INSERT INTO research_station (id,name) VALUES (2,'Station B'); CREATE TABLE species_observations (station_id INT,species_name TEXT,sightings INT); INSERT INTO species_observations (station_id,species_name,sightings) VALUES (1,'Species 1',10); INSERT INTO species_observations (station_id,species_name,sightings) VALUES (1,'Species 2',5); INSERT INTO species_observations (station_id,species_name,sightings) VALUES (2,'Species 1',8); INSERT INTO species_observations (station_id,species_name,sightings) VALUES (2,'Species 3',15); | SELECT species_name, SUM(sightings) as total_sightings, RANK() OVER (ORDER BY SUM(sightings) DESC) as rank FROM species_observations GROUP BY species_name HAVING rank <= 3; |
What is the maximum temperature per month in the 'temperature_readings' table? | CREATE TABLE temperature_readings (reading_date DATE,temperature FLOAT); | SELECT DATE_TRUNC('month', reading_date) AS month, MAX(temperature) FROM temperature_readings GROUP BY month; |
Update the visitors_per_month of Taj Mahal to 25000? | CREATE TABLE HeritageSite (name VARCHAR(255),visitors_per_month INT); INSERT INTO HeritageSite (name,visitors_per_month) VALUES ('Taj Mahal',20000); | UPDATE HeritageSite SET visitors_per_month = 25000 WHERE name = 'Taj Mahal'; |
What is the average age of traditional dances per country? | CREATE TABLE Countries (CountryID INT,CountryName VARCHAR(50),Continent VARCHAR(50)); CREATE TABLE Dances (DanceID INT,DanceName VARCHAR(50),DanceAge INT,CountryID INT); INSERT INTO Countries VALUES (1,'Mexico','Americas'),(2,'Nigeria','Africa'),(3,'Japan','Asia'); INSERT INTO Dances VALUES (1,'Ballet Folklorico',80,1),(2,'Agbekor',300,2),(3,'Kabuki',400,3); | SELECT Context.CountryName, AVG(Dances.DanceAge) AS AvgDanceAge FROM (SELECT * FROM Countries WHERE Continent = 'Americas' OR Continent = 'Africa' OR Continent = 'Asia') AS Context INNER JOIN Dances ON Context.CountryID = Dances.CountryID GROUP BY Context.CountryName; |
What is the total number of patients treated with medication and therapy in each country? | CREATE TABLE patients (patient_id INT,name VARCHAR(50),age INT,state VARCHAR(50),country VARCHAR(50)); CREATE TABLE therapy_sessions (session_id INT,patient_id INT,therapist_id INT,session_date DATE); CREATE TABLE medications (medication_id INT,patient_id INT,medication_name VARCHAR(50),prescription_date DATE); INSERT INTO patients VALUES (1,'John Doe',35,'California','USA'); INSERT INTO patients VALUES (2,'Jane Smith',28,'Ontario','Canada'); INSERT INTO therapy_sessions VALUES (1,1,101,'2022-01-01'); INSERT INTO therapy_sessions VALUES (2,2,102,'2022-02-01'); INSERT INTO medications VALUES (1,1,'Prozac','2022-01-05'); INSERT INTO medications VALUES (2,2,'Lexapro','2022-02-05'); | SELECT countries.country, COUNT(DISTINCT patients.patient_id) FROM patients JOIN medications ON patients.patient_id = medications.patient_id JOIN therapy_sessions ON patients.patient_id = therapy_sessions.patient_id JOIN (SELECT DISTINCT country FROM patients) AS countries ON patients.country = countries.country GROUP BY countries.country; |
What's the most common therapy type among patients? | CREATE TABLE patients (id INT,name TEXT,age INT,therapy TEXT); INSERT INTO patients (id,name,age,therapy) VALUES (1,'Alice',30,'CBT'),(2,'Bob',45,'DBT'),(3,'Charlie',60,'CBT'),(4,'David',50,'CBT'),(5,'Eve',55,'DBT'); | SELECT therapy, COUNT(*) AS therapy_count FROM patients GROUP BY therapy ORDER BY therapy_count DESC LIMIT 1; |
Find the average HearingDuration for each District in the CommunityCourts table. | CREATE TABLE CommunityCourts (CourtID INT,District VARCHAR(20)); CREATE TABLE CommunityCourtHearings (HearingID INT,CourtID INT,HearingDate DATE,HearingDuration INT); INSERT INTO CommunityCourts (CourtID,District) VALUES (1,'Downtown'),(2,'Uptown'),(3,'Midtown'); INSERT INTO CommunityCourtHearings (HearingID,CourtID,HearingDate,HearingDuration) VALUES (1,1,'2021-06-15',60),(2,1,'2021-07-20',75),(3,2,'2021-08-12',90),(4,3,'2021-08-15',45),(5,3,'2021-09-01',30); | SELECT District, AVG(HearingDuration) as AverageHearingDuration FROM CommunityCourtHearings JOIN CommunityCourts ON CommunityCourtHearings.CourtID = CommunityCourts.CourtID GROUP BY District; |
What is the maximum grant_amount awarded by a funding_source in the 'civil_court_grants' table? | CREATE TABLE civil_court_grants (id INT,funding_source TEXT,grant_amount INT,grant_type TEXT,recipient TEXT); | SELECT funding_source, MAX(grant_amount) FROM civil_court_grants GROUP BY funding_source; |
What is the average depth of all marine protected areas (MPAs) in the Pacific Ocean? | CREATE TABLE pacific_ocean (id INT,name TEXT,depth FLOAT);CREATE TABLE marine_protected_areas (id INT,name TEXT,mpa_type TEXT); INSERT INTO pacific_ocean (id,name,depth) VALUES (1,'Marianas Trench',10994); INSERT INTO marine_protected_areas (id,name,mpa_type) VALUES (1,'Papahānaumokuākea Marine National Monument','No-take'); | SELECT AVG(pacific_ocean.depth) FROM pacific_ocean JOIN marine_protected_areas ON pacific_ocean.name = marine_protected_areas.name WHERE marine_protected_areas.mpa_type = 'No-take'; |
What is the change in population size for each marine species from 2020 to 2021? | CREATE TABLE marine_species_population (id INT,species VARCHAR(255),year INT,population_size INT); INSERT INTO marine_species_population (id,species,year,population_size) VALUES (1,'Clownfish',2020,10000),(2,'Sea Turtle',2020,5000),(3,'Dolphin',2020,20000),(1,'Clownfish',2021,10500),(2,'Sea Turtle',2021,5500),(3,'Dolphin',2021,21000); | SELECT species, (population_size - LAG(population_size) OVER (PARTITION BY species ORDER BY year)) change_in_population FROM marine_species_population; |
Count the number of unique viewers who watched a series on Netflix by country | CREATE TABLE viewership (id INT,viewer_id INT,series_title VARCHAR(100),platform VARCHAR(50),watch_date DATE); INSERT INTO viewership (id,viewer_id,series_title,platform,watch_date) VALUES (1,123,'Series1','Netflix','2022-01-01'),(2,456,'Series2','Netflix','2022-02-01'),(3,789,'Series1','Netflix','2022-03-01'); | SELECT production_country, COUNT(DISTINCT viewer_id) as unique_viewers FROM viewership v JOIN movies m ON v.series_title = m.title WHERE platform = 'Netflix' GROUP BY production_country; |
What is the maximum number of likes received by posts about media literacy from users in Asia? | CREATE TABLE posts (id INT,title TEXT,likes INT,domain TEXT,region TEXT); INSERT INTO posts (id,title,likes,domain,region) VALUES (1,'Post1',500,'Media Literacy','Asia'); INSERT INTO posts (id,title,likes,domain,region) VALUES (2,'Post2',700,'Disinformation','Europe'); | SELECT MAX(likes) FROM posts WHERE domain = 'Media Literacy' AND region = 'Asia'; |
What is the total quantity of organic ingredients in the inventory? | CREATE TABLE Inventory (item_id INT,name VARCHAR(50),is_organic BOOLEAN,quantity INT); INSERT INTO Inventory (item_id,name,is_organic,quantity) VALUES (1,'Apples',true,100),(2,'Broccoli',true,50),(3,'Beef',false,75); | SELECT SUM(quantity) FROM Inventory WHERE is_organic = true; |
Delete all military sales records with supplier 'Thales' | CREATE TABLE military_sales (supplier VARCHAR(255),country VARCHAR(255),sale_value INT,sale_year INT); INSERT INTO military_sales (supplier,country,sale_value,sale_year) VALUES ('Thales','Australia',7000000,2021),('Boeing','India',100000000,2021),('Boeing','India',120000000,2020); | DELETE FROM military_sales WHERE supplier = 'Thales'; |
Compare coal production and employment rates in China and India between 2018 and 2020. | CREATE TABLE china_coal_production (year INT,production FLOAT); INSERT INTO china_coal_production (year,production) VALUES (2018,3500.0),(2019,3600.0),(2020,3700.0); CREATE TABLE china_employment (year INT,employment FLOAT); INSERT INTO china_employment (year,employment) VALUES (2018,8000000.0),(2019,8100000.0),(2020,8200000.0); CREATE TABLE india_coal_production (year INT,production FLOAT); INSERT INTO india_coal_production (year,production) VALUES (2018,700.0),(2019,750.0),(2020,800.0); CREATE TABLE india_employment (year INT,employment FLOAT); INSERT INTO india_employment (year,employment) VALUES (2018,1000000.0),(2019,1050000.0),(2020,1100000.0); | SELECT 'China' AS country, china_coal_production.production, china_employment.employment FROM china_coal_production INNER JOIN china_employment ON china_coal_production.year = china_employment.year WHERE china_coal_production.year BETWEEN 2018 AND 2020 UNION ALL SELECT 'India', india_coal_production.production, india_employment.employment FROM india_coal_production INNER JOIN india_employment ON india_coal_production.year = india_employment.year WHERE india_coal_production.year BETWEEN 2018 AND 2020; |
What are the monthly trends of resource depletion for coal and iron? | CREATE TABLE resource_depletion (id INT,date DATE,resource VARCHAR(50),quantity INT); INSERT INTO resource_depletion (id,date,resource,quantity) VALUES (1,'2022-01-01','Coal',1000); INSERT INTO resource_depletion (id,date,resource,quantity) VALUES (2,'2022-01-01','Iron',2000); INSERT INTO resource_depletion (id,date,resource,quantity) VALUES (3,'2022-02-01','Coal',1200); INSERT INTO resource_depletion (id,date,resource,quantity) VALUES (4,'2022-02-01','Iron',2100); | SELECT date, SUM(CASE WHEN resource = 'Coal' THEN quantity ELSE 0 END) as coal_quantity, SUM(CASE WHEN resource = 'Iron' THEN quantity ELSE 0 END) as iron_quantity FROM resource_depletion GROUP BY date; |
What is the total data usage in GB for each customer in the last quarter, ordered by usage in descending order? | CREATE TABLE customers (customer_id INT,name VARCHAR(50),data_usage FLOAT); INSERT INTO customers VALUES (1,'John Doe',45.6),(2,'Jane Smith',30.1); | SELECT customer_id, SUM(data_usage)/1024/1024/1024 as total_usage_gb FROM customers WHERE date_of_usage >= DATEADD(quarter, -1, GETDATE()) GROUP BY customer_id ORDER BY total_usage_gb DESC; |
Delete the record for the author 'Jane Smith' from the 'authors' table | CREATE TABLE authors (author_id INT PRIMARY KEY,first_name VARCHAR(50),last_name VARCHAR(50)); | DELETE FROM authors WHERE first_name = 'Jane' AND last_name = 'Smith'; |
What is the average age of readers who prefer opinion pieces, categorized by gender? | CREATE TABLE readers (id INT,name TEXT,age INT,gender TEXT,interest TEXT); INSERT INTO readers (id,name,age,gender,interest) VALUES (1,'John Doe',35,'Male','opinion'); | SELECT gender, AVG(age) FROM readers WHERE interest = 'opinion' GROUP BY gender; |
What is the average number of views per reader for readers who have viewed more than 10 articles? | CREATE TABLE Readers (ReaderID int,Name varchar(50),Age int,Gender varchar(10),Country varchar(50),Views int); INSERT INTO Readers (ReaderID,Name,Age,Gender,Country,Views) VALUES (1,'Reader 1',40,'Male','USA',10); INSERT INTO Readers (ReaderID,Name,Age,Gender,Country,Views) VALUES (2,'Reader 2',45,'Female','Canada',15); INSERT INTO Readers (ReaderID,Name,Age,Gender,Country,Views) VALUES (3,'Reader 3',50,'Male','Mexico',20); INSERT INTO Readers (ReaderID,Name,Age,Gender,Country,Views) VALUES (4,'Reader 4',55,'Female','UK',25); INSERT INTO Readers (ReaderID,Name,Age,Gender,Country,Views) VALUES (5,'Reader 5',60,'Male','India',30); | SELECT AVG(Views) as AvgViews FROM Readers GROUP BY ReaderID HAVING COUNT(ReaderID) > 10; |
List all countries with deep-sea exploration programs. | CREATE TABLE countries (name varchar(255),deep_sea_program boolean); INSERT INTO countries (name,deep_sea_program) VALUES ('United States',true),('Canada',false),('China',true),('France',true),('Japan',true); | SELECT name FROM countries WHERE deep_sea_program = true; |
Find the top 3 recipients of grants in the Education sector? | CREATE TABLE Grants (GrantID INT,GrantName TEXT,Sector TEXT,Amount DECIMAL); | SELECT GrantName, Sector, Amount, ROW_NUMBER() OVER (PARTITION BY Sector ORDER BY Amount DESC) AS Rank FROM Grants WHERE Sector = 'Education' LIMIT 3; |
What is the average playtime, in hours, for players from Germany, for games in the 'Simulation' genre? | CREATE TABLE games (game_id INT,game_genre VARCHAR(255),player_id INT,playtime_mins INT); CREATE TABLE players (player_id INT,player_country VARCHAR(255)); | SELECT AVG(playtime_mins / 60) FROM games JOIN players ON games.player_id = players.player_id WHERE players.player_country = 'Germany' AND game_genre = 'Simulation'; |
Find the country with the highest number of esports event participants. | CREATE TABLE Events (EventID INT,Name VARCHAR(100),Country VARCHAR(50),Participants INT); INSERT INTO Events (EventID,Name,Country,Participants) VALUES (1,'Event1','USA',500),(2,'Event2','Canada',400),(3,'Event3','England',600),(4,'Event4','France',300); | SELECT Country, Participants FROM Events ORDER BY Participants DESC LIMIT 1; |
List all games and their average playing time, ordered by the average playing time in ascending order | CREATE TABLE games (game_id INT,name VARCHAR(255)); CREATE TABLE player_games (player_id INT,game_id INT,hours_played INT); | SELECT games.name, AVG(player_games.hours_played) as avg_playing_time FROM games JOIN player_games ON games.game_id = player_games.game_id GROUP BY games.game_id ORDER BY avg_playing_time ASC; |
What is the average prize money awarded at esports events in Europe? | CREATE TABLE EsportsPrizes (EventID INT,Country VARCHAR(20),PrizeMoney DECIMAL(10,2)); INSERT INTO EsportsPrizes (EventID,Country,PrizeMoney) VALUES (1,'Germany',5000.00),(2,'France',7000.00); | SELECT AVG(PrizeMoney) FROM EsportsPrizes WHERE Country IN ('Germany', 'France', 'Italy'); |
What is the percentage of players who prefer fighting games? | CREATE TABLE PlayerGamePreferences (PlayerID INT,GamePreference VARCHAR(20)); INSERT INTO PlayerGamePreferences (PlayerID,GamePreference) VALUES (1,'fighting'); CREATE TABLE Players (PlayerID INT,Age INT); INSERT INTO Players (PlayerID,Age) VALUES (1,22); | SELECT (COUNT(*) * 100.0 / (SELECT COUNT(*) FROM Players)) FROM PlayerGamePreferences WHERE GamePreference = 'fighting'; |
How many public libraries are there in the state of New South Wales? | CREATE TABLE public_libraries (name VARCHAR(255),state VARCHAR(255)); INSERT INTO public_libraries (name,state) VALUES ('State Library of New South Wales','New South Wales'),('Newcastle Region Library','New South Wales'),('Wollongong Library','New South Wales'); | SELECT COUNT(*) FROM public_libraries WHERE state = 'New South Wales'; |
Update the budget for Education policy to 10 | CREATE TABLE Policy_Budget (Policy_ID INT PRIMARY KEY,Policy_Area VARCHAR(30),Budget INT); INSERT INTO Policy_Budget (Policy_ID,Policy_Area,Budget) VALUES (1,'Transportation',8000000),(2,'Education',7000000),(3,'Environment',5000000),(4,'Housing',9000000); | UPDATE Policy_Budget SET Budget = 10 WHERE Policy_Area = 'Education'; |
What is the total budget allocated for infrastructure in 2023, in the 'annual_budget' table? | CREATE TABLE annual_budget (year INT,category VARCHAR(255),budget INT); INSERT INTO annual_budget (year,category,budget) VALUES (2022,'Education',1000000),(2023,'Infrastructure',1500000); | SELECT budget FROM annual_budget WHERE year = 2023 AND category = 'Infrastructure'; |
Find the percentage of properties with sustainable features in each neighborhood. | CREATE TABLE properties (property_id INT,neighborhood VARCHAR(255),sustainable BOOLEAN); | SELECT neighborhood, (COUNT(*) FILTER (WHERE sustainable = TRUE)) * 100.0 / COUNT(*) as percentage_sustainable FROM properties GROUP BY neighborhood; |
What is the total installed capacity (in MW) of renewable energy projects in the 'solar' category? | CREATE TABLE renewable_energy_projects (id INT,project_name VARCHAR(100),category VARCHAR(50),capacity_mw DECIMAL(10,2)); | SELECT SUM(capacity_mw) FROM renewable_energy_projects WHERE category = 'solar'; |
List all sustainable sourcing costs for 'Eco-Friendly Eats' in 2021. | CREATE TABLE SustainableSourcing (restaurant_id INT,year INT,cost INT); INSERT INTO SustainableSourcing (restaurant_id,year,cost) VALUES (9,2021,1200); | SELECT * FROM SustainableSourcing WHERE restaurant_id = 9 AND year = 2021; |
Count the number of products in the 'grocery' category | CREATE TABLE products (product_id INT,category VARCHAR(20),quantity INT); INSERT INTO products (product_id,category,quantity) VALUES (1,'grocery',10),(2,'grocery',20),(3,'grocery',30); | SELECT COUNT(*) FROM products WHERE category = 'grocery'; |
How many unique products are available in each store location? | CREATE TABLE StoreLocations (LocationID int,LocationName varchar(50)); INSERT INTO StoreLocations (LocationID,LocationName) VALUES (1,'Location A'),(2,'Location B'),(3,'Location C'); CREATE TABLE Inventory (ProductID int,LocationID int); INSERT INTO Inventory (ProductID,LocationID) VALUES (1,1),(1,2),(2,1),(3,2),(4,3),(5,1); | SELECT i.LocationName, COUNT(DISTINCT i.ProductID) AS UniqueProducts FROM Inventory i GROUP BY i.LocationName; |
How many space missions were launched in the last 5 years by continent? | CREATE TABLE missions(mission_id INT,name VARCHAR(50),country VARCHAR(50),launch_date DATE,continent VARCHAR(50)); INSERT INTO missions VALUES (1,'Mission1','USA','2018-01-01','North America'); INSERT INTO missions VALUES (2,'Mission2','Canada','2019-01-01','North America'); INSERT INTO missions VALUES (3,'Mission3','China','2020-01-01','Asia'); | SELECT continent, COUNT(*) as mission_count FROM missions WHERE launch_date >= DATE_SUB(CURRENT_DATE, INTERVAL 5 YEAR) GROUP BY continent; |
Calculate the total mass of asteroids studied by mission 'Voyager 1' | CREATE TABLE missions (id INT,name VARCHAR(50),spacecraft VARCHAR(50),launch_year INT);CREATE TABLE asteroids (id INT,name VARCHAR(50),mass DECIMAL(10,2),mission VARCHAR(50)); | SELECT SUM(mass) FROM asteroids WHERE mission = 'Voyager 1'; |
Which incident response policies were implemented in Asia, and what is the rank of each policy based on the number of incidents it covers? | CREATE TABLE incidents (id INT,date DATE,category VARCHAR(20),source_ip VARCHAR(15),target_ip VARCHAR(15)); CREATE TABLE policies (id INT,date DATE,type VARCHAR(20),region VARCHAR(30)); INSERT INTO incidents (id,date,category,source_ip,target_ip) VALUES (1,'2021-01-01','malware','192.168.1.100','8.8.8.8'); INSERT INTO policies (id,date,type,region) VALUES (1,'2021-01-01','incident response','Asia'); | SELECT policies.type, RANK() OVER (ORDER BY incident_count DESC) as policy_rank FROM (SELECT policy.type, COUNT(*) as incident_count FROM incidents JOIN policies ON incidents.date = policies.date WHERE policies.region = 'Asia' GROUP BY policy.type) as subquery JOIN policies ON policies.type = subquery.type; |
Which systems were scanned the most in the last month, and what were their maximum CVE scores? | CREATE TABLE systems (system_id INT,system_name VARCHAR(255));CREATE TABLE scan_dates (scan_date DATE,system_id INT);CREATE TABLE cve_scores (system_id INT,score INT,scan_date DATE); | SELECT s.system_name, MAX(c.score) as max_score FROM systems s INNER JOIN (SELECT system_id, COUNT(*) as scan_count FROM scan_dates GROUP BY system_id) sd ON s.system_id = sd.system_id LEFT JOIN cve_scores c ON s.system_id = c.system_id AND sd.scan_date = c.scan_date WHERE sd.scan_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) GROUP BY s.system_name ORDER BY scan_count DESC; |
Show the total quantity of each garment in the inventory table | CREATE TABLE inventory (id INT,garment_id INT,quantity INT); | SELECT garment_id, SUM(quantity) as total_quantity FROM inventory GROUP BY garment_id; |
What are the names and locations of suppliers established after 2010? | CREATE TABLE suppliers (supplier_id INT PRIMARY KEY,name VARCHAR(255),location VARCHAR(255),establishment_date DATE); | SELECT name, location FROM suppliers WHERE establishment_date > '2010-01-01'; |
What is the maximum salary increase percentage for union workers in the 'Hospitality' sector since 2010? | CREATE TABLE SalaryIncreases (id INT,UnionID INT,Sector TEXT,SalaryIncreasePercentage DECIMAL,EffectiveDate DATE); | SELECT MAX(SalaryIncreasePercentage) FROM SalaryIncreases WHERE Sector = 'Hospitality' AND EffectiveDate >= '2010-01-01'; |
What is the total revenue generated from members in each age group? | CREATE TABLE member_demographics (member_id INT,age INT,revenue FLOAT); INSERT INTO member_demographics (member_id,age,revenue) VALUES (1,25,500),(2,35,750),(3,45,1000),(4,55,1250); | SELECT age, SUM(revenue) FROM member_demographics GROUP BY age; |
What is the distribution of AI safety research topics by year? | CREATE TABLE if not exists ai_safety_research (year INT,topic VARCHAR(255)); INSERT INTO ai_safety_research (year,topic) VALUES (2018,'Explainable AI'),(2019,'Algorithmic fairness'),(2020,'AI safety'),(2021,'Robust AI'),(2022,'AI ethics'); | SELECT year, topic, COUNT(*) OVER (PARTITION BY year) as research_count FROM ai_safety_research ORDER BY year; |
How many economic diversification efforts in the 'diversification' table have been unsuccessful or have been abandoned? | CREATE TABLE diversification (id INT,effort VARCHAR(50),status VARCHAR(20)); | SELECT COUNT(*) FROM diversification WHERE status IN ('unsuccessful', 'abandoned'); |
List all rural infrastructure projects in South America, along with their start and end dates, and the number of beneficiaries. | CREATE SCHEMA if not exists rural_dev; use rural_dev; CREATE TABLE if not exists rural_infrastructure_projects (id INT,project_name VARCHAR(255),country VARCHAR(255),start_date DATE,end_date DATE,num_beneficiaries INT,PRIMARY KEY (id)); | SELECT project_name, start_date, end_date, num_beneficiaries FROM rural_dev.rural_infrastructure_projects WHERE country LIKE 'South%' OR country LIKE 'Sur%'; |
What is the minimum budget (in USD) for agricultural innovation projects in the Caribbean? | CREATE TABLE Agricultural_Projects (id INT,project_name TEXT,budget FLOAT,region TEXT); INSERT INTO Agricultural_Projects (id,project_name,budget,region) VALUES (1,'Sustainable Farming',100000.00,'Caribbean'),(2,'AgriTech Solutions',120000.00,'Caribbean'); | SELECT MIN(budget) FROM Agricultural_Projects WHERE region = 'Caribbean'; |
Which community development initiatives had the lowest cost in Nepal between 2019 and 2021? | CREATE TABLE community_development_nepal (id INT,country VARCHAR(255),initiative VARCHAR(255),cost FLOAT,year INT); INSERT INTO community_development_nepal (id,country,initiative,cost,year) VALUES (1,'Nepal','Education Program',150000,2019),(2,'Nepal','Healthcare Program',120000,2020),(3,'Nepal','Clean Water Access',180000,2021); | SELECT initiative, MIN(cost) as min_cost FROM community_development_nepal WHERE country = 'Nepal' AND year BETWEEN 2019 AND 2021 GROUP BY initiative; |
Which aircraft models were involved in the highest number of accidents in 2020? | CREATE TABLE Aircraft(id INT,model VARCHAR(50),manufacturer VARCHAR(50)); CREATE TABLE Accidents(id INT,aircraft_id INT,year INT); INSERT INTO Aircraft(id,model,manufacturer) VALUES (1,'A320','Airbus'),(2,'737','Boeing'); INSERT INTO Accidents(id,aircraft_id,year) VALUES (1,1,2020),(2,1,2020),(3,2,2020),(4,2,2020),(5,2,2020); | SELECT Aircraft.model, COUNT(*) as num_accidents FROM Aircraft INNER JOIN Accidents ON Aircraft.id = Accidents.aircraft_id WHERE Accidents.year = 2020 GROUP BY Aircraft.model ORDER BY num_accidents DESC LIMIT 1; |
Delete the 'community_education' table | CREATE TABLE community_education (id INT PRIMARY KEY,location_id INT,program_name VARCHAR(50),start_date DATE,end_date DATE,attendees INT); | DROP TABLE community_education; |
What is the total number of animals in the 'sanctuary_a' and 'sanctuary_b'? | CREATE TABLE sanctuary_a (animal_id INT,animal_name VARCHAR(50),population INT); INSERT INTO sanctuary_a VALUES (1,'tiger',25); INSERT INTO sanctuary_a VALUES (2,'elephant',30); CREATE TABLE sanctuary_b (animal_id INT,animal_name VARCHAR(50),population INT); INSERT INTO sanctuary_b VALUES (1,'tiger',20); INSERT INTO sanctuary_b VALUES (3,'monkey',35); | SELECT SUM(s1.population + s2.population) FROM sanctuary_a s1 FULL OUTER JOIN sanctuary_b s2 ON s1.animal_id = s2.animal_id; |
Delete the record with date '2022-01-02' in the FishTank table. | CREATE TABLE FishTank (date DATE,temperature FLOAT); INSERT INTO FishTank (date,temperature) VALUES ('2022-01-01',20.5),('2022-01-02',21.0),('2022-01-03',21.5); | DELETE FROM FishTank WHERE date = '2022-01-02'; |
How many events were attended by the 'Senior' demographic in the year 2020? | CREATE SCHEMA if not exists arts_culture; CREATE TABLE if not exists arts_culture.events(event_id INT,event_name VARCHAR(50),event_date DATE); CREATE TABLE if not exists arts_culture.attendance(attendance_id INT,event_id INT,demographic VARCHAR(10)); | SELECT COUNT(*) FROM arts_culture.events JOIN arts_culture.attendance ON events.event_id = attendance.event_id WHERE attendance.demographic = 'Senior' AND YEAR(events.event_date) = 2020; |
How many visual art events took place in each location in the last 3 years? | CREATE TABLE Events (event_id INT,event_type VARCHAR(50),location VARCHAR(50),event_date DATE); INSERT INTO Events (event_id,event_type,location,event_date) VALUES (1,'Visual Art','New York','2021-01-01'),(2,'Theater','Los Angeles','2020-01-01'),(3,'Visual Art','New York','2019-01-01'),(4,'Visual Art','Los Angeles','2018-01-01'); | SELECT location, COUNT(event_id) FROM Events WHERE event_type = 'Visual Art' AND event_date >= DATE(NOW()) - INTERVAL 3 YEAR GROUP BY location |
What is the average age of attendees for each event type? | CREATE TABLE Events (event_id INT,event_type VARCHAR(50)); INSERT INTO Events (event_id,event_type) VALUES (1,'Concert'),(2,'Theater'),(3,'Exhibition'); CREATE TABLE Audience (audience_id INT,event_id INT,attendee_age INT); INSERT INTO Audience (audience_id,event_id,attendee_age) VALUES (1,1,30),(2,1,45),(3,2,25),(4,2,32),(5,3,40),(6,3,50); | SELECT e.event_type, AVG(a.attendee_age) AS avg_age FROM Events e JOIN Audience a ON e.event_id = a.event_id GROUP BY e.event_type; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.