instruction stringlengths 0 1.06k | input stringlengths 11 5.3k | response stringlengths 2 4.44k |
|---|---|---|
What is the minimum distance between Earth and any other planet? | CREATE TABLE space_planets (name TEXT,distance_from_sun FLOAT); INSERT INTO space_planets (name,distance_from_sun) VALUES ('Mercury',0.39),('Venus',0.72),('Earth',1.00),('Mars',1.52),('Jupiter',5.20),('Saturn',9.58),('Uranus',19.18),('Neptune',30.07); | SELECT MIN(ABS(distance_from_sun - 1.00)) FROM space_planets; |
Find the species with the lowest total habitat area in 'habitat_preservation' table. | CREATE TABLE habitat_preservation (id INT,species VARCHAR(255),area INT); | SELECT species, SUM(area) AS total_area FROM habitat_preservation GROUP BY species ORDER BY total_area LIMIT 1; |
What is the minimum depth recorded in the Sargasso Sea? | CREATE TABLE sargasso_sea (location TEXT,depth INTEGER); INSERT INTO sargasso_sea (location,depth) VALUES ('Sargasso Sea',4000); | SELECT MIN(depth) FROM sargasso_sea; |
What are the top 5 most represented cultural groups in media content? | CREATE TABLE media_content (id INT,content_id INT,represents_group BOOLEAN,group_name VARCHAR); INSERT INTO media_content (id,content_id,represents_group,group_name) VALUES (1,1,true,'LGBTQ+'); INSERT INTO media_content (id,content_id,represents_group,group_name) VALUES (2,2,false,'Women'); | SELECT group_name, represents_group, COUNT(*) as num_representations FROM media_content WHERE represents_group = true GROUP BY group_name ORDER BY num_representations DESC LIMIT 5; |
What is the average CO2 emission of factories in Europe? | CREATE TABLE factory_emissions (id INT,factory VARCHAR(100),location VARCHAR(100),co2_emissions DECIMAL(5,2)); INSERT INTO factory_emissions (id,factory,location,co2_emissions) VALUES (1,'Germany Factory','Germany',50),(2,'France Factory','France',70),(3,'Italy Factory','Italy',60); | SELECT AVG(co2_emissions) FROM factory_emissions WHERE location = 'Europe'; |
What is the change in energy storage capacity in South Korea between 2016 and 2019? | CREATE TABLE energy_storage_sk (id INT,year INT,country VARCHAR(255),capacity FLOAT); INSERT INTO energy_storage_sk (id,year,country,capacity) VALUES (1,2016,'South Korea',120.5),(2,2017,'South Korea',135.2),(3,2018,'South Korea',142.1),(4,2019,'South Korea',150.9); | SELECT (capacity - LAG(capacity) OVER (PARTITION BY country ORDER BY year)) FROM energy_storage_sk WHERE country = 'South Korea' AND year IN (2017, 2018, 2019); |
What is the percentage of citizens who are satisfied with public transportation in each district? | CREATE TABLE districts (district_name VARCHAR(50),num_citizens INT,num_satisfied_citizens INT); INSERT INTO districts VALUES ('District A',10000,8000); INSERT INTO districts VALUES ('District B',12000,9500); INSERT INTO districts VALUES ('District C',15000,11000); | SELECT district_name, (num_satisfied_citizens * 100.0 / num_citizens) as percentage_satisfied FROM districts; |
Find the total quantity of sustainable fabric used by the 'Eco-friendly Fashions' brand in the 'Textiles' table. | CREATE TABLE Textiles (brand VARCHAR(20),fabric_type VARCHAR(20),quantity INT); INSERT INTO Textiles (brand,fabric_type,quantity) VALUES ('Eco-friendly Fashions','Organic Cotton',1500),('Eco-friendly Fashions','Recycled Polyester',2000),('Fab Fashions','Viscose',1200); | SELECT SUM(quantity) FROM Textiles WHERE brand = 'Eco-friendly Fashions' AND fabric_type = 'Organic Cotton' OR fabric_type = 'Recycled Polyester'; |
What is the minimum number of hours spent on lifelong learning by students who have a mental health score above the average? | CREATE TABLE students (id INT PRIMARY KEY,mental_health_score INT,hours_spent_on_ll INT); | SELECT MIN(st.hours_spent_on_ll) FROM students st WHERE st.mental_health_score > (SELECT AVG(st2.mental_health_score) FROM students st2); |
Insert new geopolitical risk assessments for 'Europe' | CREATE TABLE risk_assessments (assess_id INT,assess_description TEXT,region VARCHAR(50)); | INSERT INTO risk_assessments (assess_id, assess_description, region) VALUES (1, 'Rising political tensions', 'Europe'), (2, 'Economic instability', 'Europe'); |
What is the average salary for geologists in the 'geology_company' table? | CREATE TABLE geology_company (id INT,name VARCHAR,position VARCHAR,department VARCHAR,salary DECIMAL); INSERT INTO geology_company (id,name,position,department,salary) VALUES (1,'Amy Pond','Geologist','Geology',80000.00),(2,'Rory Williams','Assistant Geologist','Geology',60000.00),(3,'Melody Pond','Lab Technician','Geo... | SELECT AVG(salary) FROM geology_company WHERE position LIKE '%Geologist%'; |
What is the carbon price for Brazil and South Africa on April 1, 2023? | CREATE TABLE carbon_prices (id INT,country VARCHAR(50),price FLOAT,start_date DATE,end_date DATE); INSERT INTO carbon_prices (id,country,price,start_date,end_date) VALUES (1,'Brazil',12.0,'2023-04-01','2023-12-31'); INSERT INTO carbon_prices (id,country,price,start_date,end_date) VALUES (2,'South Africa',10.5,'2023-04-... | SELECT country, price FROM carbon_prices WHERE start_date <= '2023-04-01' AND end_date >= '2023-04-01' AND country IN ('Brazil', 'South Africa'); |
How many male players have designed a puzzle game and have more than 5,000 players? | CREATE TABLE game_designers (designer_id INT,gender VARCHAR(10),genre VARCHAR(10),players INT); | SELECT COUNT(*) FROM game_designers WHERE gender = 'male' AND genre = 'puzzle' AND players > 5000; |
What is the total revenue for the 'Seafood' cuisine category in the 'North America' region for the month of April 2022? | CREATE TABLE restaurant_revenue(restaurant_id INT,cuisine VARCHAR(255),region VARCHAR(255),revenue DECIMAL(10,2),revenue_date DATE); | SELECT SUM(revenue) FROM restaurant_revenue WHERE cuisine = 'Seafood' AND region = 'North America' AND revenue_date BETWEEN '2022-04-01' AND '2022-04-30'; |
Which members have an age greater than 50? | CREATE TABLE member_age (id INT,member_id INT,age INT); INSERT INTO member_age (id,member_id,age) VALUES (1,501,55),(2,502,45),(3,503,60),(4,504,35); | SELECT DISTINCT member_id FROM member_age WHERE age > 50; |
What is the average amount donated by donors from the United States? | CREATE TABLE donors (id INT,name TEXT,country TEXT,amount_donated DECIMAL); INSERT INTO donors (id,name,country,amount_donated) VALUES (1,'John Doe','USA',500.00),(2,'Jane Smith','Canada',300.00); | SELECT AVG(amount_donated) FROM donors WHERE country = 'USA'; |
Update the ticket sales for the artist 'BTS' in 'Asia' by 10%. | CREATE TABLE ticket_sales(artist_id INT,region VARCHAR(50),sales INT); | UPDATE ticket_sales SET sales = sales * 1.1 WHERE artist_id = (SELECT artist_id FROM artists WHERE name = 'BTS') AND region = 'Asia'; |
Who is the most prolific artist in the 'Modern Art' category? | CREATE TABLE artists(id INT,name VARCHAR(255),category VARCHAR(255),num_works INT); INSERT INTO artists (id,name,category,num_works) VALUES (1,'Picasso','Modern Art',1000),(2,'Matisse','Modern Art',800),(3,'Warhol','Contemporary Art',700); | SELECT name FROM artists WHERE category = 'Modern Art' ORDER BY num_works DESC LIMIT 1; |
List the top 3 states with the highest water consumption in the residential sector in 2019? | CREATE TABLE states (state_id INT,state_name TEXT); INSERT INTO states (state_id,state_name) VALUES (1,'California'),(2,'Texas'),(3,'New York'),(4,'Florida'),(5,'Illinois'); CREATE TABLE residential_water_usage (id INT,state_id INT,year INT,water_consumption FLOAT); INSERT INTO residential_water_usage (id,state_id,year... | SELECT s.state_name, SUM(r.water_consumption) as total_water_consumption FROM states s JOIN residential_water_usage r ON s.state_id = r.state_id WHERE r.year = 2019 GROUP BY s.state_name ORDER BY total_water_consumption DESC LIMIT 3; |
What is the total number of electric ferries in Oslo and their total passenger capacity? | CREATE TABLE electric_ferries (ferry_id INT,passenger_capacity INT,city VARCHAR(50)); | SELECT COUNT(*), SUM(passenger_capacity) FROM electric_ferries WHERE city = 'Oslo'; |
What is the total value of assets for clients in the 'Americas' region, grouped by currency? | CREATE TABLE clients (client_id INT,region VARCHAR(20),currency VARCHAR(10)); INSERT INTO clients (client_id,region,currency) VALUES (1,'Europe','EUR'),(2,'Asia','USD'),(3,'Africa','USD'),(4,'Americas','USD'),(5,'Americas','CAD'); CREATE TABLE assets (asset_id INT,client_id INT,value INT); INSERT INTO assets (asset_id,... | SELECT clients.currency, SUM(assets.value) AS total_assets FROM clients INNER JOIN assets ON clients.client_id = assets.client_id WHERE clients.region = 'Americas' GROUP BY clients.currency; |
Update the current capacity of landfill 'site3' by a specified amount. | CREATE TABLE landfill_capacity (location TEXT,current_capacity INTEGER,total_capacity INTEGER); INSERT INTO landfill_capacity (location,current_capacity,total_capacity) VALUES ('site3',90000,120000); | UPDATE landfill_capacity SET current_capacity = current_capacity - 2000 WHERE location = 'site3'; |
What is the average donation amount for each program? | CREATE TABLE program_donations (program_id INT,donation_id INT,donation_amount DECIMAL(10,2)); INSERT INTO program_donations (program_id,donation_id,donation_amount) VALUES (1,1,50.00); INSERT INTO program_donations (program_id,donation_id,donation_amount) VALUES (1,2,50.00); INSERT INTO program_donations (program_id,d... | SELECT program_id, AVG(donation_amount) FROM program_donations GROUP BY program_id; |
What is the minimum speed for vessels of type 'container ship'? | CREATE TABLE vessel_types (vessel_type VARCHAR(50),min_speed DECIMAL(5,2)); CREATE TABLE vessel_performance (vessel_id INT,vessel_type VARCHAR(50),speed DECIMAL(5,2)); | SELECT min_speed FROM vessel_types WHERE vessel_type = 'container ship'; |
Update 'John Smith's' policy coverage amount to $750,000 in the policy_info table | CREATE TABLE policy_info (policy_id INT,policy_holder TEXT,coverage_amount INT); INSERT INTO policy_info (policy_id,policy_holder,coverage_amount) VALUES (1,'John Smith',600000),(2,'Jane Doe',400000),(3,'Mike Johnson',700000); | UPDATE policy_info SET coverage_amount = 750000 WHERE policy_holder = 'John Smith'; |
What is the average local economic impact of eco-friendly tours in Costa Rica? | CREATE TABLE EcoFriendlyTours (tour_id INT,tour_name TEXT,country TEXT,local_economic_impact FLOAT); INSERT INTO EcoFriendlyTours (tour_id,tour_name,country,local_economic_impact) VALUES (1,'Rainforest Adventure','Costa Rica',11000.0),(2,'Volcano Hike','Costa Rica',10000.0); | SELECT AVG(local_economic_impact) FROM EcoFriendlyTours WHERE country = 'Costa Rica'; |
What is the average account balance for the top 25% of socially responsible lending customers in the South region? | CREATE TABLE customers (customer_id INT,name VARCHAR(50),region VARCHAR(20),account_balance DECIMAL(10,2)); INSERT INTO customers (customer_id,name,region,account_balance) VALUES (1,'John Doe','South',5000.00),(2,'Jane Smith','North',7000.00); | SELECT AVG(account_balance) FROM (SELECT account_balance FROM customers WHERE region = 'South' AND product_type = 'Socially Responsible Lending' ORDER BY account_balance DESC LIMIT 25) AS top_customers; |
How many cases were won by attorneys from the 'Downtown' office location? | CREATE TABLE Cases (CaseID INT,AttorneyID INT,OfficeLocation VARCHAR(20)); INSERT INTO Cases (CaseID,AttorneyID,OfficeLocation) VALUES (101,1,'Downtown'),(102,3,'Uptown'),(103,2,'Downtown'); CREATE TABLE Attorneys (AttorneyID INT,OfficeLocation VARCHAR(20)); INSERT INTO Attorneys (AttorneyID,OfficeLocation) VALUES (1,'... | SELECT COUNT(*) FROM Cases JOIN Attorneys ON Cases.AttorneyID = Attorneys.AttorneyID WHERE OfficeLocation = 'Downtown'; |
List all patients who received both therapy and medication management? | CREATE TABLE patients (id INT,name TEXT); CREATE TABLE therapy_sessions (id INT,patient_id INT); CREATE TABLE medication_management (id INT,patient_id INT); INSERT INTO patients (id,name) VALUES (1,'John Doe'); INSERT INTO patients (id,name) VALUES (2,'Jane Smith'); INSERT INTO therapy_sessions (id,patient_id) VALUES (... | SELECT patients.name FROM patients INNER JOIN therapy_sessions ON patients.id = therapy_sessions.patient_id INNER JOIN medication_management ON patients.id = medication_management.patient_id; |
Which warehouse has the least inventory? | CREATE TABLE inventory (warehouse_id VARCHAR(5),total_quantity INT); INSERT INTO inventory (warehouse_id,total_quantity) VALUES ('W01',600),('W02',450),('W03',700),('W04',300); | SELECT warehouse_id FROM inventory ORDER BY total_quantity LIMIT 1; |
What is the average production output of factories in the wind energy sector? | CREATE TABLE factories (factory_id INT,name VARCHAR(100),location VARCHAR(100),sector VARCHAR(100),production_output INT); INSERT INTO factories (factory_id,name,location,sector,production_output) VALUES (1,'ABC Factory','New York','Wind',5500),(2,'XYZ Factory','California','Solar',4000),(3,'LMN Factory','Texas','Wind'... | SELECT AVG(production_output) FROM factories WHERE sector = 'Wind'; |
Determine the maximum temperature for soybeans in the last week | CREATE TABLE temperature_data (crop_type VARCHAR(50),measurement_date DATE,temperature DECIMAL(5,2)); | SELECT MAX(temperature) FROM temperature_data WHERE crop_type = 'soybeans' AND measurement_date >= NOW() - INTERVAL '7 days'; |
Which chemicals require 'Respirator' safety measures in the USA? | CREATE TABLE Chemicals (Id INT,Name VARCHAR(255),Manufacturing_Country VARCHAR(255)); CREATE TABLE Safety_Protocols (Id INT,Chemical_Id INT,Safety_Measure VARCHAR(255)); INSERT INTO Chemicals (Id,Name,Manufacturing_Country) VALUES (1,'Hydrochloric Acid','USA'); INSERT INTO Safety_Protocols (Id,Chemical_Id,Safety_Measur... | SELECT Chemicals.Name FROM Chemicals INNER JOIN Safety_Protocols ON Chemicals.Id = Safety_Protocols.Chemical_Id WHERE Safety_Protocols.Safety_Measure = 'Respirator'; |
What is the maximum amount of seafood (in tons) produced by aquaculture farms in Australia and New Zealand, for the year 2018? | CREATE TABLE SeafoodAustraliaNZ (id INT,country VARCHAR(50),year INT,tons_produced INT); INSERT INTO SeafoodAustraliaNZ (id,country,year,tons_produced) VALUES (1,'Australia',2018,1800),(2,'New Zealand',2018,1900),(3,'Australia',2018,1700),(4,'New Zealand',2018,1600); | SELECT MAX(tons_produced) FROM SeafoodAustraliaNZ WHERE country IN ('Australia', 'New Zealand') AND year = 2018; |
What was the total revenue for each salesperson in the first quarter of 2022? | CREATE TABLE salesperson_sales (salesperson_id INT,salesperson_name VARCHAR(255),sale_date DATE,revenue DECIMAL(10,2)); INSERT INTO salesperson_sales (salesperson_id,salesperson_name,sale_date,revenue) VALUES (1,'John Doe','2022-01-02',100.00),(2,'Jane Smith','2022-01-03',150.00),(3,'Bob Johnson','2022-01-04',200.00); | SELECT salesperson_name, SUM(revenue) as total_revenue FROM salesperson_sales WHERE sale_date BETWEEN '2022-01-01' AND '2022-03-31' GROUP BY salesperson_name; |
What is the minimum donation amount received for the 'Housing for All' campaign? | CREATE TABLE donations (id INT,donor_name TEXT,campaign TEXT,amount INT,donation_date DATE); INSERT INTO donations (id,donor_name,campaign,amount,donation_date) VALUES (1,'John Doe','Housing for All',25,'2021-01-01'); INSERT INTO donations (id,donor_name,campaign,amount,donation_date) VALUES (2,'Jane Smith','Housing fo... | SELECT MIN(amount) FROM donations WHERE campaign = 'Housing for All'; |
Find the 'Production Time' for 'Jackets' in 'North America'. | CREATE TABLE production_time(garment VARCHAR(20),region VARCHAR(20),production_time INT); INSERT INTO production_time VALUES('Jackets','North America',20); | SELECT production_time FROM production_time WHERE garment = 'Jackets' AND region = 'North America'; |
Get the total production quantity of Dysprosium Oxide in 2022 from the reo_production table | CREATE TABLE reo_production (id INT PRIMARY KEY,reo_type VARCHAR(50),production_quantity INT,production_year INT); | SELECT SUM(production_quantity) FROM reo_production WHERE reo_type = 'Dysprosium Oxide' AND production_year = 2022; |
What is the infection rate for Tuberculosis in each region, ordered by the infection rate? | CREATE TABLE TuberculosisInfections (ID INT,PatientName VARCHAR(50),Region VARCHAR(50),InfectionDate DATE); INSERT INTO TuberculosisInfections (ID,PatientName,Region,InfectionDate) VALUES (1,'John','North','2021-01-01'); | SELECT Region, COUNT(*) * 100000 / (SELECT COUNT(*) FROM TuberculosisInfections) AS InfectionRate FROM TuberculosisInfections GROUP BY Region ORDER BY InfectionRate DESC; |
How many landfills had reached their capacity in 2018, including only data from South America and Africa? | CREATE TABLE LandfillCapacity (year INT,region VARCHAR(50),landfill VARCHAR(50),capacity FLOAT,filled_volume FLOAT); INSERT INTO LandfillCapacity (year,region,landfill,capacity,filled_volume) VALUES (2018,'North America','Landfill A',100000,95000),(2018,'Europe','Landfill B',120000,110000),(2018,'Asia','Landfill C',150... | SELECT COUNT(*) FROM LandfillCapacity WHERE year = 2018 AND region IN ('South America', 'Africa') AND filled_volume >= capacity; |
What is the average monthly data usage for customers in the 'rural' region? | CREATE TABLE subscribers (id INT,name TEXT,data_usage FLOAT,region TEXT); INSERT INTO subscribers (id,name,data_usage,region) VALUES (1,'John Doe',15.0,'rural'); INSERT INTO subscribers (id,name,data_usage,region) VALUES (2,'Jane Smith',20.0,'rural'); | SELECT AVG(data_usage) FROM subscribers WHERE region = 'rural'; |
What are the names of the volunteers who have participated in both the Education and Health programs from the VolunteerPrograms table? | CREATE TABLE VolunteerPrograms (VolunteerID INT,ProgramID INT,VolunteerName TEXT); | SELECT VolunteerName FROM VolunteerPrograms WHERE ProgramID IN (1, 2) GROUP BY VolunteerName HAVING COUNT(DISTINCT ProgramID) = 2; |
What is the total revenue for each brand, excluding returns? | CREATE TABLE sales (id INT,brand VARCHAR(255),revenue FLOAT,return_reason VARCHAR(255)); | SELECT brand, SUM(revenue) FROM sales WHERE return_reason IS NULL GROUP BY brand; |
Determine the yearly increase in carbon sequestration for all forest types | CREATE TABLE forests_carbon_trend (id INT,type VARCHAR(20),year INT,carbon FLOAT); INSERT INTO forests_carbon_trend (id,type,year,carbon) VALUES (1,'Temperate',2020,1200000),(2,'Temperate',2021,1300000); | SELECT type, YEAR(creation_date) AS year, SUM(carbon) - LAG(SUM(carbon)) OVER (PARTITION BY type ORDER BY YEAR(creation_date)) AS yearly_increase FROM forests_carbon_trend GROUP BY type, year; |
What is the count of startups founded by people with disabilities in the retail sector? | CREATE TABLE startups(id INT,name TEXT,industry TEXT,founder_ability TEXT); INSERT INTO startups (id,name,industry,founder_ability) VALUES (1,'RetailAbility','Retail','Disabled'); | SELECT COUNT(*) FROM startups WHERE industry = 'Retail' AND founder_ability = 'Disabled'; |
What is the total revenue of organic skincare products in the UK? | CREATE TABLE OrganicProducts (product VARCHAR(255),country VARCHAR(255),revenue DECIMAL(10,2)); INSERT INTO OrganicProducts (product,country,revenue) VALUES ('Cleanser','UK',500),('Toner','UK',700),('Moisturizer','UK',800),('Cleanser','UK',600); | SELECT SUM(revenue) FROM OrganicProducts WHERE product LIKE 'Cleanser%' OR product LIKE 'Toner%' OR product LIKE 'Moisturizer%' AND country = 'UK'; |
Which aquatic species have health metrics below average? | CREATE TABLE health_metrics (id INT,species VARCHAR(50),metric FLOAT); INSERT INTO health_metrics (id,species,metric) VALUES (1,'Tilapia',75.0),(2,'Catfish',80.0),(3,'Salmon',60.0); | SELECT species FROM health_metrics WHERE metric < (SELECT AVG(metric) FROM health_metrics); |
Create a table named 'mitigation_projects' | CREATE TABLE mitigation_projects (id INT PRIMARY KEY,name VARCHAR(255),location VARCHAR(255),budget FLOAT,start_date DATE,end_date DATE); | CREATE TABLE mitigation_projects (id INT PRIMARY KEY, name VARCHAR(255), location VARCHAR(255), budget FLOAT, start_date DATE, end_date DATE); |
List the names and professional development hours of teachers who have completed more than 20 hours of professional development in the last 6 months. | CREATE TABLE teacher_pd (teacher_id INT,name TEXT,pd_hours INT,pd_date DATE); INSERT INTO teacher_pd (teacher_id,name,pd_hours,pd_date) VALUES (1,'John Doe',15,'2022-01-01'),(2,'Jane Smith',25,'2022-01-15'),(3,'Mike Johnson',10,'2022-02-01'); | SELECT name, pd_hours FROM teacher_pd WHERE pd_date >= DATEADD(month, -6, GETDATE()) AND pd_hours > 20; |
How many artifacts of each type were found during the 'Ancient City' excavation? | CREATE TABLE Excavations (ExcavationID INT,Site VARCHAR(50)); INSERT INTO Excavations (ExcavationID,Site) VALUES (1,'Ancient City'); INSERT INTO Excavations (ExcavationID,Site) VALUES (2,'Lost Village'); CREATE TABLE Artifacts (ArtifactID INT,ExcavationID INT,Type VARCHAR(50),Quantity INT); INSERT INTO Artifacts (Artif... | SELECT E.Site, A.Type, SUM(A.Quantity) FROM Artifacts A INNER JOIN Excavations E ON A.ExcavationID = E.ExcavationID GROUP BY E.Site, A.Type; |
What is the daily trading volume for the top 5 digital assets? | CREATE TABLE trades (id INT,asset VARCHAR(20),volume DECIMAL(20,2),trade_date DATE); INSERT INTO trades VALUES (1,'BTC',1000000,'2022-01-01'); INSERT INTO trades VALUES (2,'ETH',2000000,'2022-01-01'); INSERT INTO trades VALUES (3,'USDT',500000,'2022-01-01'); INSERT INTO trades VALUES (4,'ADA',800000,'2022-01-01'); INSE... | SELECT asset, SUM(volume) as daily_volume FROM trades WHERE trade_date = '2022-01-01' GROUP BY asset ORDER BY daily_volume DESC LIMIT 5; |
What is the total market capitalization of all digital assets on the Stellar network? | CREATE TABLE stellar_network (network_name VARCHAR(20),total_market_cap DECIMAL(10,2)); INSERT INTO stellar_network (network_name,total_market_cap) VALUES ('Stellar',15000000.56); | SELECT total_market_cap FROM stellar_network WHERE network_name = 'Stellar'; |
What are the names and safety scores of aircraft manufactured by 'EagleTech' with safety scores greater than 85? | CREATE TABLE Aircraft (id INT,name VARCHAR(50),manufacturer VARCHAR(50),safety_score INT); INSERT INTO Aircraft (id,name,manufacturer,safety_score) VALUES (1,'F-16','AeroCorp',80),(2,'F-35','AeroCorp',95),(3,'A-10','EagleTech',88),(4,'A-11','EagleTech',82),(5,'A-12','EagleTech',90); | SELECT name, safety_score FROM Aircraft WHERE manufacturer = 'EagleTech' AND safety_score > 85; |
What are the names and locations of all factories with a workforce diversity score above 0.8? | CREATE TABLE factories (factory_id INT,name TEXT,location TEXT,diversity_score DECIMAL(3,2)); INSERT INTO factories VALUES (1,'ABC Factory','New York',0.75),(2,'XYZ Factory','California',0.82),(3,'LMN Factory','Texas',0.68); | SELECT name, location FROM factories WHERE diversity_score > 0.8; |
Update the exhibitions table with start dates for all exhibitions | CREATE TABLE exhibitions (id INT,name TEXT,start_date DATE,end_date DATE); | UPDATE exhibitions SET start_date = CURDATE(); |
What is the average depth of marine protected areas in the Atlantic Ocean? | CREATE TABLE marine_protected_areas (name TEXT,location TEXT,depth FLOAT); INSERT INTO marine_protected_areas (name,location,depth) VALUES ('Bermuda Ridge','Atlantic',4000.0),('Sargasso Sea','Atlantic',2000.0),('Great Barrier Reef','Pacific',344.0); | SELECT AVG(depth) FROM marine_protected_areas WHERE location = 'Atlantic'; |
Drop the space_debris table | CREATE TABLE space_debris (id INT PRIMARY KEY,debris_name VARCHAR(100),launch_date DATE,type VARCHAR(50)); | DROP TABLE space_debris; |
What is the maximum revenue for restaurants serving Vietnamese food? | CREATE TABLE Restaurants (id INT,name TEXT,type TEXT,revenue FLOAT); INSERT INTO Restaurants (id,name,type,revenue) VALUES (1,'Restaurant A','Italian',5000.00),(2,'Restaurant B','Vietnamese',8000.00),(3,'Restaurant C','Vietnamese',9000.00),(4,'Restaurant D','Vietnamese',10000.00); | SELECT MAX(revenue) FROM Restaurants WHERE type = 'Vietnamese'; |
How many violations were recorded per restaurant? | CREATE TABLE inspections (restaurant_id INT,violation_date DATE,description VARCHAR(255)); INSERT INTO inspections VALUES (1,'2021-01-01','Fly infestation'),(1,'2021-02-01','Missing date markers'),(2,'2021-01-01','Cleanliness issues'),(2,'2021-03-01','Improper food storage'); | SELECT restaurant_id, COUNT(*) as num_violations FROM inspections GROUP BY restaurant_id; |
List the names of each company, their associated refinery, and the refinery's continent. | CREATE TABLE company (id INT,name VARCHAR(255),refinery_id INT,country VARCHAR(255)); INSERT INTO company (id,name,refinery_id,country) VALUES (1,'ABC Corp',1,'Africa'),(2,'XYZ Corp',2,'Asia'); | SELECT c.name AS company_name, r.name AS refinery_name, CONCAT(SUBSTRING(r.location, 1, 1), ' continent') AS continent FROM company c JOIN refinery r ON c.refinery_id = r.id; |
Delete all soccer matches that had less than 2 goals scored. | CREATE TABLE matches (match_id INT,match_name VARCHAR(50),goals INT); INSERT INTO matches (match_id,match_name,goals) VALUES (1,'Match 1',1),(2,'Match 2',3),(3,'Match 3',0),(4,'Match 4',2),(5,'Match 5',4); | DELETE FROM matches WHERE goals < 2; |
How many ports are in the 'ports' table? | CREATE TABLE ports (port_id INT,name VARCHAR(50),un_locode VARCHAR(10)); INSERT INTO ports (port_id,name,un_locode) VALUES (1,'Port of Los Angeles','USLAX'),(2,'Port of Long Beach','USLGB'),(3,'Port of New York','USNYC'); | SELECT COUNT(*) FROM ports; |
What is the total funding allocated for climate adaptation projects in Oceania between 2018 and 2020? | CREATE TABLE Funding (Year INT,Region VARCHAR(20),Initiative VARCHAR(30),Funding DECIMAL(10,2)); INSERT INTO Funding (Year,Region,Initiative,Funding) VALUES (2018,'Oceania','Climate Adaptation',150000.00); INSERT INTO Funding (Year,Region,Initiative,Funding) VALUES (2019,'Oceania','Climate Adaptation',200000.00); INSER... | SELECT SUM(Funding) FROM Funding WHERE Year BETWEEN 2018 AND 2020 AND Region = 'Oceania' AND Initiative = 'Climate Adaptation'; |
What was the difference in average artifact weight before and after 2010? | CREATE TABLE artifacts (artifact_id INT,excavation_year INT,weight DECIMAL(5,2)); INSERT INTO artifacts (artifact_id,excavation_year,weight) VALUES (1,2005,5.2); | SELECT AVG(CASE WHEN excavation_year < 2010 THEN weight ELSE NULL END) as avg_weight_before_2010, AVG(CASE WHEN excavation_year >= 2010 THEN weight ELSE NULL END) as avg_weight_after_2010 FROM artifacts; |
What is the average rating of beauty products with natural ingredients in the skincare category? | CREATE TABLE ProductRatings (ProductID INT,ProductType VARCHAR(20),HasNaturalIngredients BOOLEAN,Rating INT,ReviewDate DATE); INSERT INTO ProductRatings (ProductID,ProductType,HasNaturalIngredients,Rating,ReviewDate) VALUES (1,'Facial Cleanser',TRUE,4,'2022-04-10'); INSERT INTO ProductRatings (ProductID,ProductType,Has... | SELECT AVG(Rating) FROM ProductRatings WHERE ProductType = 'Skincare' AND HasNaturalIngredients = TRUE; |
Which oceanography data locations have a depth greater than 4000 meters? | CREATE TABLE oceanography_data (id INT,location VARCHAR(50),depth INT,temperature FLOAT,salinity FLOAT); INSERT INTO oceanography_data (id,location,depth,temperature,salinity) VALUES (1,'Mariana Trench',10994,1.48,34.6); INSERT INTO oceanography_data (id,location,depth,temperature,salinity) VALUES (2,'Puerto Rico Trenc... | SELECT location, depth FROM oceanography_data WHERE depth > 4000; |
What is the total number of crimes committed in each district, separated by crime type and sorted by total number of crimes in descending order? | CREATE TABLE Districts (DId INT,Name VARCHAR(50)); CREATE TABLE Crimes (CrimeId INT,DId INT,CrimeType VARCHAR(50),Date DATE); | SELECT D.Name, C.CrimeType, COUNT(C.CrimeId) AS TotalCrimes FROM Districts D INNER JOIN Crimes C ON D.DId = C.DId GROUP BY D.Name, C.CrimeType ORDER BY TotalCrimes DESC; |
Which organizations have a location in 'India' and are of type 'Non-profit'? | CREATE TABLE organizations (id INT PRIMARY KEY,name VARCHAR(50),type VARCHAR(50),location VARCHAR(50)); INSERT INTO organizations (id,name,type,location) VALUES (1,'Greenpeace','Non-profit','India'); INSERT INTO organizations (id,name,type,location) VALUES (2,'The Climate Group','Non-profit','UK'); INSERT INTO organiza... | SELECT organizations.name, organizations.type, organizations.location FROM organizations WHERE organizations.location = 'India' AND organizations.type = 'Non-profit'; |
What is the maximum number of collective bargaining agreements negotiated by unions in the European region? | CREATE TABLE UnionCB (Union VARCHAR(50),Region VARCHAR(50),Agreements INT); INSERT INTO UnionCB (Union,Region,Agreements) VALUES ('UnionO','Europe',250),('UnionP','Europe',300),('UnionQ','Europe',200); | SELECT MAX(Agreements) FROM UnionCB WHERE Region = 'Europe' |
How many graduate students in the Engineering department come from each country? | CREATE TABLE student_demographics (id INT,student_id INT,country VARCHAR(50),department VARCHAR(50)); INSERT INTO student_demographics (id,student_id,country,department) VALUES (1,1,'USA','Engineering'),(2,2,'Canada','Engineering'),(3,3,'Mexico','Engineering'); | SELECT country, COUNT(DISTINCT student_id) FROM student_demographics WHERE department = 'Engineering' GROUP BY country; |
How many autonomous vehicle research papers were published by authors from the United States and China in 2021? | CREATE TABLE Research_Papers (id INT,title VARCHAR(255),author_country VARCHAR(50),publication_year INT); INSERT INTO Research_Papers (id,title,author_country,publication_year) VALUES (1,'Autonomous Vehicles and Traffic Flow','USA',2021); INSERT INTO Research_Papers (id,title,author_country,publication_year) VALUES (2,... | SELECT COUNT(*) FROM Research_Papers WHERE author_country IN ('USA', 'China') AND publication_year = 2021; |
Add a new sustainable practice to the SustainablePractices table. | CREATE TABLE SustainablePractices (PracticeID INT,PracticeName VARCHAR(50),Description VARCHAR(255),ProjectID INT,FOREIGN KEY (ProjectID) REFERENCES Projects(ProjectID)); | INSERT INTO SustainablePractices (PracticeID, PracticeName, Description, ProjectID) VALUES (2, 'Geothermal Heating', 'Installation of geothermal heating systems', 2); |
What are the names and total cargo weights for all shipments that arrived at the 'LAX' warehouse between '2021-01-01' and '2021-03-31'? | CREATE TABLE warehouse (warehouse_id VARCHAR(5),name VARCHAR(10),location VARCHAR(10)); INSERT INTO warehouse (warehouse_id,name,location) VALUES ('W001','LAX','Los Angeles'),('W002','JFK','New York'); CREATE TABLE shipment (shipment_id VARCHAR(5),warehouse_id VARCHAR(5),cargo_weight INT,arrival_date DATE); INSERT INTO... | SELECT w.name, SUM(s.cargo_weight) FROM shipment s INNER JOIN warehouse w ON s.warehouse_id = w.warehouse_id WHERE w.location = 'LAX' AND s.arrival_date BETWEEN '2021-01-01' AND '2021-03-31' GROUP BY w.name; |
Who are the top 3 players with the highest scores in the 'Action' game category? | CREATE TABLE Scores (PlayerID int,PlayerName varchar(50),Game varchar(50),Score int); INSERT INTO Scores (PlayerID,PlayerName,Game,Score) VALUES (1,'Player1','Game1',1000),(2,'Player2','Game1',1200),(3,'Player3','Game1',1500),(4,'Player4','Game1',800); | SELECT * FROM (SELECT PlayerID, PlayerName, Game, Score, ROW_NUMBER() OVER (PARTITION BY Game ORDER BY Score DESC) as Rank FROM Scores) T WHERE T.Game = 'Game1' AND T.Rank <= 3; |
What is the maximum market price of Holmium in Germany? | CREATE TABLE Holmium_Market_Prices (id INT,year INT,country VARCHAR(20),market_price DECIMAL(10,2)); | SELECT MAX(market_price) FROM Holmium_Market_Prices WHERE country = 'Germany'; |
What is the total number of articles published on topics related to media literacy? | CREATE TABLE articles (title VARCHAR(255),topic VARCHAR(255)); | SELECT COUNT(*) FROM articles WHERE topic LIKE '%media literacy%'; |
What is the total number of collaborations between 'K-Pop' artists and 'Hip Hop' artists? | CREATE TABLE genres (genre_id INT,genre VARCHAR(50)); INSERT INTO genres (genre_id,genre) VALUES (1,'Pop'),(2,'Rock'),(3,'Hip Hop'),(4,'Jazz'),(5,'K-Pop'); CREATE TABLE collaborations (collab_id INT,track_name VARCHAR(100),artist_id1 INT,artist_id2 INT,genre_id INT); INSERT INTO collaborations (collab_id,track_name,art... | SELECT COUNT(*) FROM collaborations c INNER JOIN genres g1 ON c.genre_id = g1.genre_id INNER JOIN genres g2 ON c.genre_id = g2.genre_id WHERE g1.genre = 'K-Pop' AND g2.genre = 'Hip Hop'; |
What is the total number of hours played by users in Japan for action games? | CREATE TABLE player_sessions (session_id INT,player_id INT,game_id INT,date_played DATE,start_time TIME,end_time TIME,playtime TIME,country VARCHAR(20),game_genre VARCHAR(20)); | SELECT SUM(TIMESTAMPDIFF(MINUTE, start_time, end_time)) FROM player_sessions WHERE country = 'Japan' AND game_genre = 'action'; |
List all funding sources for 'Music' programs in 2022. | CREATE TABLE if not exists program (id INT,name VARCHAR(50),category VARCHAR(50)); CREATE TABLE if not exists funding (id INT,program_id INT,year INT,amount DECIMAL(10,2),source VARCHAR(50)); INSERT INTO program (id,name,category) VALUES (1,'Jazz Ensemble','Music'),(2,'Classical Orchestra','Music'),(3,'Rock Band','Musi... | SELECT DISTINCT source FROM funding f JOIN program p ON f.program_id = p.id WHERE p.category = 'Music' AND f.year = 2022; |
What is the total number of hospital admissions for each primary care physician in the state of Florida? | CREATE TABLE public.physicians (id SERIAL PRIMARY KEY,name TEXT,hospital TEXT); INSERT INTO public.physicians (name,hospital) VALUES ('Dr. Smith','Florida General Hospital'),('Dr. Johnson','Florida Children''s Hospital'); CREATE TABLE public.admissions (id SERIAL PRIMARY KEY,physician TEXT,hospital TEXT,admission_date ... | SELECT p.name, COUNT(*) FROM public.admissions a JOIN public.physicians p ON a.physician = p.name GROUP BY p.name; |
What was the total number of citizen complaints received by the city of Chicago in 2024, categorized by utilities, parks, and sanitation? | CREATE TABLE city_complaints (city varchar(50),year int,category varchar(50),num_complaints int); INSERT INTO city_complaints (city,year,category,num_complaints) VALUES ('Chicago',2024,'Utilities',2000),('Chicago',2024,'Parks',1000),('Chicago',2024,'Sanitation',1500); | SELECT SUM(num_complaints) FROM city_complaints WHERE city = 'Chicago' AND (category = 'Utilities' OR category = 'Parks' OR category = 'Sanitation') AND year = 2024; |
Identify hotel features that are not AI-related in Africa. | CREATE TABLE hotel_features (hotel_id INT,location VARCHAR(20),feature VARCHAR(30)); | SELECT feature FROM hotel_features WHERE location = 'Africa' AND feature NOT LIKE '%AI%' GROUP BY feature |
Find the top 3 ESG scores for companies in the technology sector in Q2 2021, ordered by the scores in descending order. | CREATE TABLE if not exists companies (company_id INT,sector VARCHAR(50),esg_score DECIMAL(3,2),quarter INT,year INT); INSERT INTO companies (company_id,sector,esg_score,quarter,year) VALUES (1,'Technology',8.2,2,2021),(2,'Technology',7.8,2,2021),(3,'Technology',9.1,2,2021); | SELECT company_id, sector, esg_score FROM companies WHERE sector = 'Technology' AND quarter = 2 AND year = 2021 ORDER BY esg_score DESC LIMIT 3; |
How many marine species live at a depth less than or equal to 100 meters? | CREATE TABLE species (id INT,name VARCHAR(255),habitat VARCHAR(255),depth FLOAT); INSERT INTO species (id,name,habitat,depth) VALUES (1,'Clownfish','Coral Reef',20.0); INSERT INTO species (id,name,habitat,depth) VALUES (2,'Blue Whale','Open Ocean',2000.0); INSERT INTO species (id,name,habitat,depth) VALUES (3,'Sea Otte... | SELECT COUNT(*) FROM species WHERE depth <= 100; |
Delete all incidents recorded after 2022-12-31 from the 'incidents' table | CREATE TABLE incidents (id INT,incident_type VARCHAR(255),location VARCHAR(255),occurred_on DATE); | DELETE FROM incidents WHERE occurred_on > '2022-12-31'; |
What is the maximum threat level reported in country YZ in 2022? | CREATE TABLE threat_intelligence (id INT,country VARCHAR(50),year INT,threat_level FLOAT); INSERT INTO threat_intelligence (id,country,year,threat_level) VALUES (1,'USA',2022,4.5); INSERT INTO threat_intelligence (id,country,year,threat_level) VALUES (2,'YZ',2022,5.2); | SELECT MAX(threat_level) FROM threat_intelligence WHERE country = 'YZ' AND year = 2022; |
Calculate the average number of research publications for graduate students from each university. | CREATE TABLE Universities (UniversityID int,UniversityName varchar(255)); CREATE TABLE GraduateStudents (StudentID int,StudentName varchar(255),UniversityID int); CREATE TABLE Publications (PublicationID int,StudentID int,Title varchar(255)); | SELECT UniversityName, AVG(NumPublications) as AvgPublicationsPerStudent FROM (SELECT UniversityName, StudentName, COUNT(*) as NumPublications FROM GraduateStudents gs JOIN Publications p ON gs.StudentID = p.StudentID JOIN Universities u ON gs.UniversityID = u.UniversityID GROUP BY UniversityName, StudentName) subquery... |
List the names of all cities with a population over 1 million that have no records in the 'climate_communication' table. | CREATE TABLE cities (city_name TEXT,population INTEGER); INSERT INTO cities (city_name,population) VALUES ('New York',8500000),('Los Angeles',4000000),('Toronto',2700000),('Montreal',1700000); CREATE TABLE climate_communication (city_name TEXT); INSERT INTO climate_communication (city_name) VALUES ('New York'),('Los An... | SELECT city_name FROM cities WHERE population > 1000000 AND city_name NOT IN (SELECT city_name FROM climate_communication); |
Update the age of the inmate with ID 1 to 40 in the prison table. | CREATE TABLE prison (id INT,name TEXT,security_level TEXT,age INT); INSERT INTO prison (id,name,security_level,age) VALUES (1,'John Doe','low_security',35); | UPDATE prison SET age = 40 WHERE id = 1; |
Which countries had the highest and lowest drug approval rates in H1 2021? | CREATE TABLE drug_approval_rates(country VARCHAR(255),approval_count INT,total_drugs INT,year INT,semester INT); INSERT INTO drug_approval_rates(country,approval_count,total_drugs,year,semester) VALUES ('USA',50,100,2021,1),('Canada',30,80,2021,1),('Japan',40,90,2021,1); | SELECT country, approval_count/total_drugs as approval_rate FROM drug_approval_rates WHERE year = 2021 AND semester = 1 ORDER BY approval_rate DESC, country ASC; |
What is the maximum heart rate achieved by a female member? | CREATE TABLE MemberWorkouts (MemberID INT,WorkoutDate DATE,HeartRate INT); INSERT INTO MemberWorkouts (MemberID,WorkoutDate,HeartRate) VALUES (1,'2023-02-01',165),(2,'2023-02-02',150),(3,'2023-02-03',170); | SELECT MAX(HeartRate) FROM MemberWorkouts WHERE MemberID IN (SELECT MemberID FROM Members WHERE Gender = 'Female'); |
What is the change in water demand and price for each city over time? | CREATE TABLE if not exists water_demand (id INT PRIMARY KEY,city VARCHAR(50),water_demand FLOAT,usage_date DATE); CREATE TABLE if not exists water_price (id INT PRIMARY KEY,city VARCHAR(50),price FLOAT,usage_date DATE); CREATE VIEW if not exists water_demand_price AS SELECT wd.city,wd.water_demand,wp.price FROM water_d... | SELECT city, usage_date, LAG(water_demand) OVER (PARTITION BY city ORDER BY usage_date) as prev_water_demand, water_demand, LAG(price) OVER (PARTITION BY city ORDER BY usage_date) as prev_price, price FROM water_demand_price ORDER BY city, usage_date; |
What is the average heart rate for members from each country? | CREATE TABLE member_demographics (member_id INT,country VARCHAR(50),heart_rate INT); INSERT INTO member_demographics (member_id,country,heart_rate) VALUES (1,'USA',70),(2,'Canada',80),(3,'Mexico',65),(4,'Brazil',75),(5,'Argentina',78),(6,'USA',75),(7,'Canada',70),(8,'Mexico',80),(9,'Brazil',85),(10,'Argentina',72); | SELECT country, AVG(heart_rate) FROM member_demographics GROUP BY country; |
What is the maximum temperature in field 4 over the last month? | CREATE TABLE field_temperature (field_id INT,date DATE,temperature FLOAT); INSERT INTO field_temperature (field_id,date,temperature) VALUES (4,'2021-06-01',28.5),(4,'2021-06-02',29.3),(4,'2021-06-03',30.1); | SELECT MAX(temperature) FROM field_temperature WHERE field_id = 4 AND date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH); |
Delete the record with the 'subscriber_id' 5 from the 'subscribers' table. | CREATE TABLE subscribers (subscriber_id INT,name VARCHAR(50),data_usage FLOAT); | DELETE FROM subscribers WHERE subscriber_id = 5; |
What is the total playtime, in hours, for all players from Canada, for games in the 'RPG' 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 SUM(playtime_mins / 60) FROM games JOIN players ON games.player_id = players.player_id WHERE players.player_country = 'Canada' AND game_genre = 'RPG'; |
List the ports and their respective countries from the 'ports' and 'countries' tables. | CREATE TABLE ports (id INT PRIMARY KEY,name VARCHAR(50),country_id INT); CREATE TABLE countries (id INT PRIMARY KEY,name VARCHAR(50)); | SELECT ports.name, countries.name AS country_name FROM ports INNER JOIN countries ON ports.country_id = countries.id; |
What is the maximum allocation for a climate adaptation project in the year 2020? | CREATE TABLE climate_adaptation_max (project_id INT,project_name TEXT,allocation DECIMAL(10,2),year INT); INSERT INTO climate_adaptation_max (project_id,project_name,allocation,year) VALUES (7,'Sea Level Rise G',13000000,2020),(8,'Heatwave Resilience H',10000000,2020),(9,'Biodiversity Protection I',14000000,2020); | SELECT MAX(allocation) FROM climate_adaptation_max WHERE year = 2020; |
How many shipments were sent to country 'US' in February 2022? | CREATE TABLE shipments (id INT,shipment_date DATE,country VARCHAR(10)); INSERT INTO shipments (id,shipment_date,country) VALUES (1001,'2022-01-03','Canada'),(1002,'2022-01-15','Mexico'),(1003,'2022-02-01','US'),(1004,'2022-02-15','Canada'); | SELECT COUNT(*) FROM shipments WHERE MONTH(shipment_date) = 2 AND country = 'US'; |
How many times has the firewall blocked traffic from country FR in the last month? | CREATE TABLE firewall_logs (id INT,ip TEXT,country TEXT,timestamp TIMESTAMP); INSERT INTO firewall_logs (id,ip,country,timestamp) VALUES (1,'192.168.0.11','US','2021-02-01 12:00:00'),(2,'192.168.0.10','FR','2021-02-04 14:30:00'),(3,'192.168.0.12','CN','2021-02-05 10:15:00'); | SELECT COUNT(*) FROM firewall_logs WHERE country = 'FR' AND timestamp >= NOW() - INTERVAL '1 month'; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.