instruction stringlengths 0 1.06k | input stringlengths 11 5.3k | response stringlengths 2 4.44k |
|---|---|---|
Update the pollution_level for 'Mariana Trench' to 9000. | CREATE TABLE pollution_levels (location TEXT,pollution_level INTEGER); INSERT INTO pollution_levels (location,pollution_level) VALUES ('Gulf of Mexico',5000),('Mariana Trench',8000),('Atlantic Ocean',2000); | UPDATE pollution_levels SET pollution_level = 9000 WHERE location = 'Mariana Trench'; |
List the military equipment types that had the highest maintenance costs per incident in 2020 | CREATE TABLE equipment_maintenance (equipment_type VARCHAR(255),maintenance_cost DECIMAL(10,2),maintenance_incident_date DATE); | SELECT equipment_type, AVG(maintenance_cost) AS avg_cost_per_incident FROM equipment_maintenance WHERE EXTRACT(YEAR FROM maintenance_incident_date) = 2020 GROUP BY equipment_type ORDER BY avg_cost_per_incident DESC |
What is the sum of flight hours for all Space Shuttle missions? | CREATE TABLE shuttle_missions (id INT,shuttle VARCHAR(255),flight_hours INT); INSERT INTO shuttle_missions (id,shuttle,flight_hours) VALUES (1,'Atlantis',4848),(2,'Columbia',3005); | SELECT SUM(flight_hours) FROM shuttle_missions; |
Find the number of artists who have created more pieces than the average number of pieces created by artists in Rio de Janeiro. | CREATE TABLE artists_rio (artist_id INT,name VARCHAR(50),city VARCHAR(50),pieces INT); | SELECT COUNT(*) FROM artists_rio WHERE pieces > (SELECT AVG(pieces) FROM artists_rio WHERE city = 'Rio de Janeiro'); |
What is the total number of educational institutions and medical facilities in 'disaster_response' database? | CREATE TABLE educational_institutions (id INT,name VARCHAR(255),type VARCHAR(255),location VARCHAR(255)); INSERT INTO educational_institutions (id,name,type,location) VALUES (1,'School A','Primary School','City X'),(2,'University B','University','City Y'); CREATE TABLE medical_facilities (id INT,name VARCHAR(255),type ... | SELECT COUNT(*) FROM educational_institutions UNION ALL SELECT COUNT(*) FROM medical_facilities; |
How many members have an active membership in each state? | CREATE TABLE gym_locations (id INT,location_name VARCHAR(50),state VARCHAR(50),city VARCHAR(50),members INT); | SELECT state, COUNT(DISTINCT member_name) AS active_members FROM gym_locations JOIN gym_memberships ON gym_locations.location_name = gym_memberships.location WHERE end_date > CURDATE() GROUP BY state; |
List the names of all vessels that have visited port 'NY' | CREATE TABLE vessels (vessel_id INT,vessel_name VARCHAR(50)); INSERT INTO vessels (vessel_id,vessel_name) VALUES (1,'Vessel1'),(2,'Vessel2'),(3,'Vessel3'); CREATE TABLE port_visits (visit_id INT,vessel_id INT,port_id INT); INSERT INTO port_visits (visit_id,vessel_id,port_id) VALUES (1,1,1),(2,2,2),(3,3,1),(4,1,2); | SELECT DISTINCT vessel_name FROM vessels v JOIN port_visits pv ON v.vessel_id = pv.vessel_id WHERE pv.port_id = (SELECT port_id FROM ports WHERE port_name = 'NY'); |
What was the average crop yield in 2020 for farmers in the 'rural_development' schema? | CREATE TABLE farmers (farmer_id INT,name TEXT,location TEXT,crop_yield INT,year INT); INSERT INTO farmers (farmer_id,name,location,crop_yield,year) VALUES (1,'John Doe','Smithville',500,2020); INSERT INTO farmers (farmer_id,name,location,crop_yield,year) VALUES (2,'Jane Smith','Brownfield',600,2020); | SELECT AVG(crop_yield) FROM farmers WHERE year = 2020 AND location LIKE 'rural_development%'; |
How many justice technology grants were awarded to organizations in each justice district? | CREATE TABLE JusticeTechnologyGrants (ID INT,GrantID VARCHAR(20),JusticeDistrict VARCHAR(20),Amount INT,Year INT); INSERT INTO JusticeTechnologyGrants (ID,GrantID,JusticeDistrict,Amount,Year) VALUES (1,'JTG2015','North Valley',15000,2015),(2,'JTG2016','South Peak',20000,2016),(3,'JTG2017','East River',10000,2017); | SELECT JusticeDistrict, COUNT(*) FROM JusticeTechnologyGrants GROUP BY JusticeDistrict; |
What is the average international visitor spending on accommodation per day in Canada and France? | CREATE TABLE Country (name VARCHAR(255),visitor_count INT,accommodation_spend DECIMAL(10,2)); INSERT INTO Country (name,visitor_count,accommodation_spend) VALUES ('Canada',15000,85.67),('France',20000,70.54); | SELECT AVG(accommodation_spend) FROM Country WHERE name IN ('Canada', 'France') |
How many crimes were reported in the state of Texas in 2020? | CREATE TABLE crimes (id INT,state VARCHAR(255),year INT,number_of_crimes INT); INSERT INTO crimes (id,state,year,number_of_crimes) VALUES (1,'Texas',2020,150000),(2,'California',2020,200000); | SELECT SUM(number_of_crimes) FROM crimes WHERE state = 'Texas' AND year = 2020; |
Identify the earliest founding year among startups with at least one female founder | CREATE TABLE startup (id INT,name TEXT,founding_year INT,founder_gender TEXT); INSERT INTO startup (id,name,founding_year,founder_gender) VALUES (1,'Acme Inc',2010,'Female'); INSERT INTO startup (id,name,founding_year,founder_gender) VALUES (2,'Beta Corp',2015,'Male'); INSERT INTO startup (id,name,founding_year,founder... | SELECT MIN(founding_year) FROM startup WHERE founder_gender = 'Female'; |
What is the total amount of resources depleted for each mining operation? | CREATE TABLE resources_depleted (operation_id INT,resource VARCHAR(50),quantity_depleted INT); INSERT INTO resources_depleted (operation_id,resource,quantity_depleted) VALUES (1,'Coal',1000),(1,'Iron Ore',2000),(2,'Gold',500),(2,'Silver',1000),(3,'Copper',1500); | SELECT mining_operations.operation_name, SUM(resources_depleted.quantity_depleted) AS total_resources_depleted FROM mining_operations INNER JOIN resources_depleted ON mining_operations.operation_id = resources_depleted.operation_id GROUP BY mining_operations.operation_name; |
What is the average monthly water usage per household in the Los Angeles region for the past year? | CREATE TABLE water_usage (household_id INT,region VARCHAR(255),usage FLOAT,date DATE); INSERT INTO water_usage (household_id,region,usage,date) VALUES (1,'Los Angeles',500,'2022-01-01'); INSERT INTO water_usage (household_id,region,usage,date) VALUES (1,'Los Angeles',600,'2022-02-01'); | SELECT AVG(usage) FROM (SELECT usage, DATE_TRUNC('month', date) AS month FROM water_usage WHERE region = 'Los Angeles' AND date >= '2021-01-01' AND date < '2022-01-01' GROUP BY month, usage ORDER BY month) subquery; |
Insert new records of workplaces, including safety violations and union affiliations. | CREATE TABLE workplaces (id INT,name TEXT,safety_violation BOOLEAN,union_affiliation TEXT); | INSERT INTO workplaces (id, name, safety_violation, union_affiliation) VALUES (5, 'RST Industries', TRUE, 'Union C'), (6, 'UVW Corporation', FALSE, 'Union D'); |
What is the distribution of media types by region? | CREATE TABLE Media (id INT,title VARCHAR(255),type VARCHAR(255),region VARCHAR(255)); INSERT INTO Media (id,title,type,region) VALUES (1,'Content1','Video','North America'),(2,'Content2','Audio','Europe'),(3,'Content3','Video','Asia'),(4,'Content4','Text','Africa'); | SELECT region, type, COUNT(*) as num_contents FROM Media GROUP BY region, type; |
What are the defense projects with a duration of more than 3 years in the European region? | CREATE TABLE Projects (ProjectID INT,ProjectName VARCHAR(50),StartDate DATE,EndDate DATE,Region VARCHAR(50)); INSERT INTO Projects (ProjectID,ProjectName,StartDate,EndDate,Region) VALUES (1,'Project A','2022-01-01','2023-12-31','Asia-Pacific'),(2,'Project B','2022-03-15','2024-02-28','Europe'),(3,'Project C','2022-06-0... | SELECT ProjectName FROM Projects WHERE DATEDIFF(day, StartDate, EndDate) > 1095 AND Region = 'Europe'; |
What is the correlation between the population density and the number of available hospital beds per capita in rural areas? | CREATE TABLE regions (region_id INT,name VARCHAR(20),population INT,population_density FLOAT); INSERT INTO regions (region_id,name,population,population_density) VALUES (1,'Rural',10000,25.0),(2,'Urban',50000,200.0); CREATE TABLE hospitals (hospital_id INT,region_id INT,beds INT); INSERT INTO hospitals (hospital_id,reg... | SELECT correlation(r.population_density, (h.beds + c.beds) / r.population) FROM regions r JOIN hospitals h ON r.region_id = h.region_id JOIN clinics c ON r.region_id = c.region_id; |
What is the maximum number of open pedagogy projects per department? | CREATE TABLE department_open_pedagogy (department_id INT,project_count INT); | SELECT department_id, MAX(project_count) as max_projects FROM department_open_pedagogy; |
How many unique garment types were manufactured in Bangladesh in 2020? | CREATE TABLE Manufacturing (id INT,garment_type VARCHAR(20),country VARCHAR(20),year INT); INSERT INTO Manufacturing (id,garment_type,country,year) VALUES (1,'Dress','Bangladesh',2020),(2,'Shirt','Bangladesh',2020),(3,'Pant','Bangladesh',2020),(4,'Dress','Bangladesh',2021); | SELECT COUNT(DISTINCT garment_type) as unique_garment_types FROM Manufacturing WHERE country = 'Bangladesh' AND year = 2020; |
How many cases were handled by attorneys in each state, based on the 'attorney_state' column in the 'attorneys' table? | CREATE TABLE attorneys (attorney_id INT,attorney_state VARCHAR(255)); CREATE TABLE cases (case_id INT,attorney_id INT); | SELECT a.attorney_state, COUNT(c.case_id) FROM attorneys a INNER JOIN cases c ON a.attorney_id = c.attorney_id GROUP BY a.attorney_state; |
What is the rank of each country based on the number of critical vulnerabilities in the last 60 days? | CREATE TABLE vulnerabilities (id INT,date DATE,severity VARCHAR(10),ip VARCHAR(15),country VARCHAR(30)); INSERT INTO vulnerabilities (id,date,severity,ip,country) VALUES (1,'2021-01-01','critical','192.168.1.100','Brazil'); | SELECT country, RANK() OVER (ORDER BY critical_vulnerability_count DESC) as country_rank FROM (SELECT country, COUNT(*) as critical_vulnerability_count FROM vulnerabilities WHERE severity = 'critical' AND date >= (CURRENT_DATE - INTERVAL '60' DAY) GROUP BY country) as subquery; |
Calculate the total number of autonomous vehicles sold in 2021 | CREATE TABLE autonomous_sales (id INT,vehicle_type VARCHAR(20),year INT,quantity INT); INSERT INTO autonomous_sales (id,vehicle_type,year,quantity) VALUES (1,'autonomous',2019,2000),(2,'autonomous',2020,3000),(3,'autonomous',2021,5000); | SELECT SUM(quantity) FROM autonomous_sales WHERE vehicle_type = 'autonomous' AND year = 2021; |
How many albums were released in total by Pop artists in 2021? | CREATE TABLE artists (artist_id INT,genre VARCHAR(20)); INSERT INTO artists (artist_id,genre) VALUES (1,'Latin'),(2,'Pop'),(3,'Rock'),(4,'Jazz'),(5,'Folk'); CREATE TABLE albums (album_id INT,artist_id INT,release_date DATE); INSERT INTO albums (album_id,artist_id,release_date) VALUES (1,2,'2021-04-12'),(2,3,'2020-08-21... | SELECT COUNT(albums.album_id) FROM albums INNER JOIN artists ON albums.artist_id = artists.artist_id WHERE artists.genre = 'Pop' AND albums.release_date BETWEEN '2021-01-01' AND '2021-12-31'; |
What is the latest fare collection date for 'Yellow Line'? | CREATE TABLE route (route_id INT,route_name VARCHAR(50)); INSERT INTO route (route_id,route_name) VALUES (1,'Red Line'),(2,'Green Line'),(3,'Blue Line'),(4,'Yellow Line'); CREATE TABLE fare (fare_id INT,route_id INT,fare_amount DECIMAL(5,2),collection_date DATE); INSERT INTO fare (fare_id,route_id,fare_amount,collectio... | SELECT MAX(collection_date) FROM fare WHERE route_id = 4; |
List the most popular dish in each cuisine type. | CREATE TABLE orders (order_id INT,location_id INT,item_id INT,quantity INT,date DATE); CREATE TABLE menu (item_id INT,item_name VARCHAR(50),category VARCHAR(50),cuisine VARCHAR(50),price DECIMAL(5,2)); | SELECT menu.cuisine, menu.item_name, SUM(orders.quantity) as total_quantity FROM orders JOIN menu ON orders.item_id = menu.item_id GROUP BY menu.cuisine, menu.item_id ORDER BY total_quantity DESC; |
What is the minimum and maximum number of animals on pasture-based farms in Wisconsin? | CREATE TABLE pasture_farms (id INT,farm_name VARCHAR(50),state VARCHAR(20),num_animals INT); INSERT INTO pasture_farms (id,farm_name,state,num_animals) VALUES (1,'Farm 1','Wisconsin',50),(2,'Farm 2','Wisconsin',75),(3,'Farm 3','Wisconsin',100),(4,'Farm 4','Wisconsin',125),(5,'Farm 5','Wisconsin',150); | SELECT state, MIN(num_animals) as min_animals, MAX(num_animals) as max_animals FROM pasture_farms WHERE state = 'Wisconsin'; |
What is the average attendance for games played at 'Estadio Nacional'? | CREATE TABLE games (stadium TEXT,attendance INT); INSERT INTO games (stadium,attendance) VALUES ('Estadio Nacional',65000),('Estadio Nacional',70000),('Wembley Stadium',80000); | SELECT AVG(attendance) FROM games WHERE stadium = 'Estadio Nacional'; |
Find the average rating and price of vegan cosmetics | CREATE TABLE products (id INT,name VARCHAR(255),price DECIMAL(5,2),rating DECIMAL(2,1),is_vegan BOOLEAN); | SELECT AVG(price), AVG(rating) FROM products WHERE is_vegan = TRUE; |
What is the total calorie count for vegetarian options? | CREATE TABLE menu (menu_id INT,menu_item VARCHAR(30),is_vegetarian BOOLEAN,calorie_count INT); INSERT INTO menu (menu_id,menu_item,is_vegetarian,calorie_count) VALUES (1,'Vegetable Lasagna',true,500),(2,'Beef Burger',false,800); | SELECT SUM(calorie_count) FROM menu WHERE is_vegetarian = true; |
What are the names and reviews of eco-friendly accommodations in Canada? | CREATE TABLE countries (id INT PRIMARY KEY,name VARCHAR(255));CREATE TABLE accommodations (id INT PRIMARY KEY,name VARCHAR(255),country_id INT,eco_friendly BOOLEAN);CREATE TABLE reviews (id INT PRIMARY KEY,accommodation_id INT,review TEXT,FOREIGN KEY (accommodation_id) REFERENCES accommodations(id)); | SELECT accommodations.name, reviews.review FROM accommodations JOIN reviews ON accommodations.id = reviews.accommodation_id WHERE accommodations.eco_friendly = true AND accommodations.country_id = (SELECT id FROM countries WHERE name = 'Canada'); |
How many marine species are threatened with extinction? | CREATE TABLE marine_species_status (species TEXT,status TEXT); | SELECT COUNT(*) FROM marine_species_status WHERE status = 'Threatened'; |
What is the maximum number of likes for a single post in the 'social_media' table? | CREATE TABLE social_media (user_id INT,post_id INT,post_date DATE,likes INT); | SELECT MAX(likes) FROM social_media; |
What is the minimum price for organic snacks? | CREATE TABLE Cost (id INT,is_organic BOOLEAN,category VARCHAR(20),price INT); INSERT INTO Cost (id,is_organic,category,price) VALUES (1,true,'snack',4),(2,false,'snack',6),(3,true,'dessert',5); | SELECT MIN(price) FROM Cost WHERE is_organic = true AND category = 'snack'; |
What is the average number of volunteer hours per program in 2023, ranked in ascending order? | CREATE TABLE Programs (ProgramID INT,ProgramName VARCHAR(50),StartDate DATE); CREATE TABLE Volunteers (VolunteerID INT,ProgramID INT,SignUpDate DATE,Hours DECIMAL(10,2)); INSERT INTO Programs (ProgramID,ProgramName,StartDate) VALUES (1,'ProgramA','2023-01-01'),(2,'ProgramB','2023-01-01'),(3,'ProgramC','2023-01-01'); IN... | SELECT p.ProgramName, AVG(v.Hours) AS AvgHoursPerProgram FROM Programs p JOIN Volunteers v ON p.ProgramID = v.ProgramID WHERE YEAR(v.SignUpDate) = 2023 GROUP BY p.ProgramName ORDER BY AvgHoursPerProgram ASC; |
Create a table named 'MentalHealthParity' | CREATE TABLE MentalHealthParity (ID INT PRIMARY KEY,State VARCHAR(2),ParityStatus VARCHAR(10)); | CREATE TABLE MentalHealthParity (ID INT PRIMARY KEY, State VARCHAR(2), ParityStatus VARCHAR(10)); |
Calculate the moving average of failed login attempts, for each user, over the last 7 days. | CREATE TABLE login_attempts (id INT,user_name VARCHAR(255),success BOOLEAN,login_time TIMESTAMP); INSERT INTO login_attempts (id,user_name,success,login_time) VALUES (1,'user1',false,'2022-06-01 10:00:00'),(2,'user2',false,'2022-06-02 11:00:00'); | SELECT user_name, AVG(CASE WHEN success = false THEN 1 ELSE 0 END) OVER (PARTITION BY user_name ORDER BY login_time ROWS BETWEEN 6 PRECEDING AND CURRENT ROW) as moving_average FROM login_attempts WHERE login_time >= DATE(NOW()) - INTERVAL '7 days'; |
What was the budget for defense project Z in 2019 and 2020? | CREATE TABLE defense_projects (id INT,project VARCHAR(50),year INT,budget FLOAT); INSERT INTO defense_projects (id,project,year,budget) VALUES (1,'Project Z',2019,1100000),(2,'Project Z',2020,1300000); | SELECT project, year, budget FROM defense_projects WHERE project = 'Project Z'; |
How many vehicles were serviced in the Queens garage on February 15th, 2022? | CREATE TABLE garages (garage_id INT,garage_name VARCHAR(255)); INSERT INTO garages (garage_id,garage_name) VALUES (1,'Bronx'),(2,'Manhattan'),(3,'Queens'); CREATE TABLE service (service_id INT,garage_id INT,service_date DATE); INSERT INTO service (service_id,garage_id,service_date) VALUES (1,1,'2021-12-15'),(2,2,'2022-... | SELECT COUNT(*) FROM service WHERE garage_id = 3 AND service_date = '2022-02-15'; |
Which author has the most publications in the 'Journal of Machine Learning' in the past three years? | CREATE TABLE Publications (ID INT,Author VARCHAR(50),Journal VARCHAR(50),Year INT,CitationCount INT); INSERT INTO Publications (ID,Author,Journal,Year,CitationCount) VALUES (1,'John Doe','Journal of Machine Learning',2021,50),(2,'Jane Smith','Journal of Mathematics',2019,40); | SELECT Author, COUNT(*) AS PublicationCount FROM Publications WHERE Journal = 'Journal of Machine Learning' AND Year >= 2019 GROUP BY Author ORDER BY PublicationCount DESC LIMIT 1; |
How many hotels are there in Tokyo? | CREATE TABLE hotels (id INT,city VARCHAR(20)); INSERT INTO hotels (id,city) VALUES (1,'Tokyo'),(2,'Osaka'),(3,'Tokyo'); | SELECT COUNT(*) FROM hotels WHERE city = 'Tokyo'; |
Which countries in 'Africa' had geopolitical risk assessments in '2022'? | CREATE TABLE Geopolitical_Risk_Assessments (country VARCHAR(255),year INT,risk_level INT); INSERT INTO Geopolitical_Risk_Assessments (country,year,risk_level) VALUES ('Egypt',2022,3),('Nigeria',2022,5); | SELECT DISTINCT country FROM Geopolitical_Risk_Assessments WHERE year = 2022 AND country IN ('Egypt', 'Nigeria', 'South Africa', 'Algeria'); |
What is the distribution of article lengths in 'investigative_reports' table? | CREATE TABLE investigative_reports (article_id INT,article_topic VARCHAR(50),investigation_length INT,publication_date DATE); | SELECT investigation_length, COUNT(*) FROM investigative_reports GROUP BY investigation_length; |
Insert a new company into the 'renewable_energy' sector with id 6, ESG rating 8.5 and risk score 2.0 | CREATE TABLE companies (id INT,sector TEXT,ESG_rating FLOAT,risk_score FLOAT); | INSERT INTO companies (id, sector, ESG_rating, risk_score) VALUES (6, 'renewable_energy', 8.5, 2.0); |
List the names and number of campaigns for public awareness campaigns related to depression, ordered by the number of campaigns in descending order. | CREATE TABLE campaigns (campaign_id INT,name TEXT,condition TEXT,start_date DATE,end_date DATE); INSERT INTO campaigns (campaign_id,name,condition,start_date,end_date) VALUES (1,'Break the Stigma','Depression','2018-01-01','2018-12-31'); INSERT INTO campaigns (campaign_id,name,condition,start_date,end_date) VALUES (2,'... | SELECT name, COUNT(*) as total FROM campaigns WHERE condition = 'Depression' GROUP BY name ORDER BY total DESC; |
Update the outcome of case #3 to 'Under Appeal' if handled by attorney Maria Rodriguez from the city of Miami. | CREATE TABLE attorneys (attorney_id INT,name VARCHAR(50),city VARCHAR(50)); INSERT INTO attorneys (attorney_id,name,city) VALUES (1,'Maria Rodriguez','Miami'); CREATE TABLE cases (case_id INT,attorney_id INT,outcome VARCHAR(50)); INSERT INTO cases (case_id,attorney_id,outcome) VALUES (1,NULL,'Settled'),(2,1,'Dismissed'... | UPDATE cases SET outcome = 'Under Appeal' WHERE case_id = 3 AND attorney_id IN (SELECT attorney_id FROM attorneys WHERE name = 'Maria Rodriguez' AND city = 'Miami'); |
What was the total humanitarian assistance provided by the US in 2018? | CREATE TABLE HumanitarianAssistance (Country VARCHAR(50),Year INT,Amount FLOAT); INSERT INTO HumanitarianAssistance (Country,Year,Amount) VALUES ('USA',2018,8112000); | SELECT Amount FROM HumanitarianAssistance WHERE Country = 'USA' AND Year = 2018; |
What is the total number of community policing events held in each district in 2021? | CREATE TABLE districts (id INT,name TEXT);CREATE TABLE policing_events (id INT,district_id INT,year INT,type TEXT); | SELECT d.name, COUNT(pe.id) FROM districts d JOIN policing_events pe ON d.id = pe.district_id WHERE pe.year = 2021 GROUP BY d.id; |
How many public health policies were implemented in California in 2020? | CREATE TABLE PublicHealthPolicies (PolicyID INT,State VARCHAR(20),Year INT,Policy VARCHAR(100)); INSERT INTO PublicHealthPolicies (PolicyID,State,Year,Policy) VALUES (1,'California',2020,'COVID-19 Mask Mandate'); INSERT INTO PublicHealthPolicies (PolicyID,State,Year,Policy) VALUES (2,'California',2019,'Flu Vaccination ... | SELECT COUNT(*) FROM PublicHealthPolicies WHERE State = 'California' AND Year = 2020; |
What is the minimum number of artworks displayed in solo exhibitions by artists from African diaspora in Berlin in the last 3 years? | CREATE TABLE solo_exhibitions (id INT,city VARCHAR(20),year INT,artist_origin VARCHAR(30),num_artworks INT); INSERT INTO solo_exhibitions (id,city,year,artist_origin,num_artworks) VALUES (1,'Berlin',2018,'German',10),(2,'Berlin',2019,'African diaspora',15),(3,'Berlin',2020,'German',12),(4,'Berlin',2020,'African diaspor... | SELECT MIN(num_artworks) FROM solo_exhibitions WHERE city = 'Berlin' AND artist_origin = 'African diaspora' AND year BETWEEN 2018 AND 2020; |
What is the number of unique artists who have streamed in the "latin" genre for each year? | CREATE TABLE ArtistStreams(id INT,artist VARCHAR(20),genre VARCHAR(10),year INT,streams INT); | SELECT year, COUNT(DISTINCT artist) FROM ArtistStreams WHERE genre = 'latin' GROUP BY year; |
What is the total number of animals in all habitats, and how many community education programs are there in total? | CREATE TABLE animal_population (id INT,type VARCHAR(50),animals INT); INSERT INTO animal_population (id,type,animals) VALUES (1,'Forest',500),(2,'Savannah',750),(3,'Wetlands',450); CREATE TABLE education (id INT,type VARCHAR(50),programs INT); INSERT INTO education (id,type,programs) VALUES (1,'Forest',10),(2,'Savannah... | SELECT SUM(animals) as total_animals, SUM(programs) as total_programs FROM animal_population, education; |
What is the maximum depth reached by any marine species in the Atlantic basin? | CREATE TABLE marine_species_depths (name VARCHAR(255),basin VARCHAR(255),depth FLOAT); INSERT INTO marine_species_depths (name,basin,depth) VALUES ('Species1','Atlantic',123.45),('Species2','Pacific',567.89),('Species3','Indian',345.67),('Species4','Atlantic',789.10); | SELECT MAX(depth) as max_depth FROM marine_species_depths WHERE basin = 'Atlantic'; |
Create a view for ocean acidification data | CREATE TABLE ocean_acidification (id INT PRIMARY KEY,location VARCHAR(255),pH DECIMAL(3,2),timestamp TIMESTAMP); INSERT INTO ocean_acidification (id,location,pH,timestamp) VALUES (1,'Pacific Ocean',7.8,'2021-08-01 12:00:00'),(2,'Atlantic Ocean',8.0,'2021-08-02 15:30:00'); | CREATE VIEW ocean_acidification_view AS SELECT * FROM ocean_acidification; |
What is the total weight of perishable items in the Sydney warehouse? | CREATE TABLE Warehouse (id INT,location VARCHAR(50),type VARCHAR(50),quantity INT,weight FLOAT); INSERT INTO Warehouse (id,location,type,quantity,weight) VALUES (1,'USA','non-perishable',300,12.5),(2,'Canada','perishable',250,11.0),(3,'France','non-perishable',500,13.2),(4,'Germany','perishable',400,14.7),(5,'UK','non-... | SELECT SUM(weight) FROM Warehouse WHERE location = 'Sydney' AND type = 'perishable'; |
What is the total number of farmers in the Karen community who grow rice? | CREATE TABLE farmers (name VARCHAR(255),tribe VARCHAR(255),crop VARCHAR(255)); INSERT INTO farmers (name,tribe,crop) VALUES ('Kaew Tawee','Karen','rice'),('Nongluck Panya','Karen','corn'),('Pinit Duangmanee','Karen','rice'),('Thippawan Duangmanee','Karen','rice'),('Chanin Tawee','Karen','cassava'); | SELECT COUNT(*) FROM farmers WHERE tribe = 'Karen' AND crop = 'rice'; |
How many electric vehicles are available in the vehicle_inventory table? | CREATE TABLE vehicle_inventory (id INT,make VARCHAR(20),model VARCHAR(20),is_electric BOOLEAN); INSERT INTO vehicle_inventory (id,make,model,is_electric) VALUES (1,'Tesla','Model 3',true),(2,'Ford','Mustang',false),(3,'Chevrolet','Bolt',true); | SELECT COUNT(*) FROM vehicle_inventory WHERE is_electric = true; |
What is the total budget allocated to each agency in the year 2022? | CREATE TABLE agency (id INT,name VARCHAR(255)); INSERT INTO agency (id,name) VALUES (1,'Transportation'); INSERT INTO agency (id,name) VALUES (2,'Education'); CREATE TABLE budget (id INT,agency_id INT,year INT,amount INT); INSERT INTO budget (id,agency_id,year,amount) VALUES (1,1,2022,50000); INSERT INTO budget (id,age... | SELECT agency.name, SUM(budget.amount) as total_budget FROM agency JOIN budget ON agency.id = budget.agency_id WHERE budget.year = 2022 GROUP BY agency.name; |
List all contracts that started after the equipment was delivered | CREATE TABLE Equipment (EquipmentID INT,EquipmentName VARCHAR(100),DeliveryDate DATE); INSERT INTO Equipment (EquipmentID,EquipmentName,DeliveryDate) VALUES (1,'Tank','2020-01-01'); INSERT INTO Equipment (EquipmentID,EquipmentName,DeliveryDate) VALUES (2,'Missile','2019-07-01'); CREATE TABLE Contracts (ContractID INT,E... | SELECT Equipment.EquipmentName, Contracts.ContractValue, Contracts.StartDate FROM Equipment INNER JOIN Contracts ON Equipment.EquipmentID = Contracts.EquipmentID WHERE Contracts.StartDate > Equipment.DeliveryDate; |
Calculate the percentage of global Ytterbium production for each quarter. | CREATE TABLE production (id INT,country VARCHAR(255),element VARCHAR(255),quantity INT,quarter INT,year INT); INSERT INTO production (id,country,element,quantity,quarter,year) VALUES (1,'China','Ytterbium',400,1,2021),(2,'China','Ytterbium',450,2,2021),(3,'USA','Ytterbium',300,1,2021),(4,'USA','Ytterbium',350,2,2021); ... | SELECT country, (quantity * 100.0 / world_quantity) as pct FROM production, world_production WHERE element = 'Ytterbium' AND production.element = world_production.element AND production.quarter = world_production.quarter AND production.year = world_production.year GROUP BY country, world_quantity, quarter, year; |
What is the total weight of the top 3 ingredients, by product, for products with a sustainability score greater than 80, ordered by total weight in descending order? | CREATE TABLE ingredients (product_id INT,ingredient VARCHAR(255),weight FLOAT,sustainability_score INT); INSERT INTO ingredients (product_id,ingredient,weight,sustainability_score) VALUES (1,'IngredientA',10,85),(1,'IngredientB',5,80),(2,'IngredientA',8,90),(2,'IngredientC',12,75); | SELECT product_id, SUM(weight) as total_weight FROM ingredients WHERE sustainability_score > 80 GROUP BY product_id ORDER BY total_weight DESC LIMIT 3; |
What is the maximum price of vegan dishes? | CREATE TABLE Restaurants (id INT,name VARCHAR(50),type VARCHAR(20)); INSERT INTO Restaurants (id,name,type) VALUES (1,'Green Garden','Vegan'); INSERT INTO Restaurants (id,name,type) VALUES (2,'Bistro Bella','Italian'); CREATE TABLE Menu (id INT,restaurant_id INT,dish VARCHAR(50),price DECIMAL(5,2)); INSERT INTO Menu (i... | SELECT MAX(price) FROM Menu WHERE dish LIKE '%vegan%'; |
What is the total number of military technologies developed by each country since 2010? | CREATE TABLE if not exists military_technologies (country VARCHAR(50),technology_name VARCHAR(50),year INT); | SELECT country, COUNT(technology_name) as total_technologies FROM military_technologies WHERE year >= 2010 GROUP BY country; |
How many building permits were issued per day in CA in 2020? | CREATE TABLE PermitsByDay (PermitID int,Date date,State varchar(25)); INSERT INTO PermitsByDay (PermitID,Date,State) VALUES (1,'2020-01-01','CA'),(2,'2020-02-01','CA'),(3,'2020-03-01','CA'); | SELECT DATEPART(YEAR, Date) AS Year, DATEPART(MONTH, Date) AS Month, DATEPART(DAY, Date) AS Day, COUNT(*) AS PermitsIssued FROM PermitsByDay WHERE State = 'CA' AND YEAR(Date) = 2020 GROUP BY DATEPART(YEAR, Date), DATEPART(MONTH, Date), DATEPART(DAY, Date); |
Count the number of museums in Oceania with more than 10000 visitors per year | CREATE TABLE Museums (MuseumID INT PRIMARY KEY,MuseumName VARCHAR(255),MuseumLocation VARCHAR(255),AnnualVisitors INT); INSERT INTO Museums (MuseumID,MuseumName,MuseumLocation,AnnualVisitors) VALUES (1,'Te Papa','Oceania',15000),(2,'Australian Museum','Oceania',20000),(3,'Museum of New Zealand Te Papa Tongarewa','Ocean... | SELECT COUNT(MuseumID) AS MuseumCount FROM Museums WHERE MuseumLocation = 'Oceania' AND AnnualVisitors > 10000; |
What is the average daily revenue for virtual tours in Asia? | CREATE TABLE virtual_tour_revenue (date TEXT,region TEXT,revenue FLOAT); INSERT INTO virtual_tour_revenue (date,region,revenue) VALUES ('2021-01-01','Asia',500),('2021-01-02','Asia',700),('2021-01-03','Asia',800),('2021-01-04','Asia',600),('2021-01-05','Asia',900); | SELECT AVG(revenue) AS avg_daily_revenue FROM virtual_tour_revenue WHERE region = 'Asia'; |
What is the percentage of security incidents in the last year that involved a user from the finance department? | CREATE TABLE security_incidents (incident_id INT,incident_date DATE,user_id INT);CREATE TABLE users (user_id INT,user_name VARCHAR(255),department VARCHAR(255)); | SELECT (COUNT(*) * 100.0 / (SELECT COUNT(*) FROM security_incidents WHERE incident_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR))) as percentage FROM security_incidents si JOIN users u ON si.user_id = u.user_id WHERE u.department = 'Finance' AND incident_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR); |
Get the minimum price of sustainable clothing items, grouped by brand, for brands that have at least one sustainable item. | CREATE TABLE Clothing (id INT,brand VARCHAR(255),price DECIMAL(5,2),sustainable VARCHAR(10)); INSERT INTO Clothing (id,brand,price,sustainable) VALUES (1,'BrandA',25.99,'yes'),(2,'BrandB',150.00,'no'),(3,'BrandC',79.99,'yes'),(4,'BrandD',19.99,'yes'); | SELECT brand, MIN(price) FROM Clothing WHERE sustainable = 'yes' GROUP BY brand HAVING COUNT(*) > 0; |
Find the title and genre of the bottom 2 movies with the lowest ratings from studios based in Brazil, ordered by ratings in ascending order. | CREATE TABLE movies (title VARCHAR(255),genre VARCHAR(255),studio VARCHAR(255),rating FLOAT); INSERT INTO movies (title,genre,studio,rating) VALUES ('Movie15','Action','Brazil Studio1',6.5),('Movie16','Drama','Brazil Studio2',5.0); | SELECT title, genre FROM (SELECT title, genre, studio, rating, ROW_NUMBER() OVER (PARTITION BY studio ORDER BY rating ASC) as rank FROM movies WHERE studio LIKE '%Brazil%') subquery WHERE rank <= 2 ORDER BY rating ASC; |
List the top 3 sustainable suppliers based on delivery frequency? | CREATE TABLE supplier_deliveries (supplier VARCHAR(50),deliveries INT,date DATE); INSERT INTO supplier_deliveries (supplier,deliveries,date) VALUES ('GreenGrowers',15,'2022-01-01'),('OrganicOrigins',20,'2022-01-02'); CREATE VIEW supplier_frequencies AS SELECT supplier,COUNT(*) as delivery_frequency FROM supplier_delive... | SELECT supplier FROM supplier_frequencies ORDER BY delivery_frequency DESC LIMIT 3; |
Delete all records from the student_scores table where the student_name is 'Sarah Kim' and the department is 'Electrical Engineering' | CREATE TABLE student_scores (student_id INT,student_name VARCHAR(255),gender VARCHAR(10),department VARCHAR(255)); INSERT INTO student_scores (student_id,student_name,gender,department) VALUES (18,'Sarah Kim','Female','Electrical Engineering'),(19,'David Lee','Male','Civil Engineering'),(20,'Grace Ahn','Female','Electr... | DELETE FROM student_scores WHERE student_name = 'Sarah Kim' AND department = 'Electrical Engineering'; |
What is the total cost of all fines issued to companies from Africa in the last quarter? | CREATE TABLE company (id INT,name TEXT,region TEXT); CREATE TABLE fine (id INT,company_id INT,date DATE,cost INT); INSERT INTO company (id,name,region) VALUES (1,'ABC Shipping','Africa'),(2,'XYZ Maritime','Europe'),(3,'DEF Transport','Africa'); INSERT INTO fine (id,company_id,date,cost) VALUES (1,1,'2022-01-01',5000),(... | SELECT SUM(f.cost) FROM fine f INNER JOIN company c ON f.company_id = c.id WHERE c.region = 'Africa' AND f.date >= DATEADD(quarter, -1, GETDATE()); |
What is the total number of followers for accounts that have posted about mental health awareness in the past month, located in Mexico? | CREATE TABLE accounts (id INT,name VARCHAR(255),location VARCHAR(255),followers INT); CREATE TABLE posts (id INT,account_id INT,content TEXT,timestamp TIMESTAMP); INSERT INTO accounts (id,name,location,followers) VALUES (1,'mental_health_advocate','Mexico',8000); INSERT INTO posts (id,account_id,content,timestamp) VALU... | SELECT SUM(accounts.followers) FROM accounts JOIN posts ON accounts.id = posts.account_id WHERE posts.timestamp >= NOW() - INTERVAL '1 month' AND posts.content LIKE '%mental health%' AND accounts.location = 'Mexico'; |
Delete all records from the smart_contracts table. | CREATE SCHEMA if not exists blockchain; CREATE TABLE if not exists blockchain.smart_contracts (contract_id INT AUTO_INCREMENT,contract_name VARCHAR(255),contract_address VARCHAR(255),ROW_NUM INT,PRIMARY KEY (contract_id)); INSERT INTO blockchain.smart_contracts (contract_name,contract_address) VALUES ('Uniswap','0x1f98... | DELETE FROM blockchain.smart_contracts; |
What is the total amount spent on imported organic food by each country in the past year? | CREATE TABLE ImportData (ImportID int,Country varchar(50),Product varchar(50),Amount decimal(10,2),Date date); | SELECT Country, SUM(Amount) FROM ImportData WHERE Product LIKE '%organic food%' AND Date >= ADD_MONTHS(TRUNC(CURRENT_DATE, 'MM'), -12) GROUP BY Country ORDER BY SUM(Amount) DESC; |
What is the total investment raised by companies founded in the last 5 years? | CREATE TABLE investments (company_id INT,round_type TEXT,raised_amount INT); INSERT INTO investments (company_id,round_type,raised_amount) VALUES (1,'Series A',5000000); INSERT INTO investments (company_id,round_type,raised_amount) VALUES (2,'Seed',1000000); | SELECT SUM(raised_amount) as total_investment FROM investments JOIN companies ON investments.company_id = companies.id WHERE companies.founding_year >= YEAR(CURRENT_DATE) - 5; |
List energy efficiency scores in 2022 and the previous year for the bottom 2 performing countries | CREATE TABLE energy_efficiency_scores (country VARCHAR(255),year INT,score FLOAT); INSERT INTO energy_efficiency_scores (country,year,score) VALUES ('Brazil',2020,60),('Argentina',2020,65),('Chile',2020,70); | SELECT country, year, score FROM (SELECT country, year, score, ROW_NUMBER() OVER (ORDER BY score ASC) AS rn FROM energy_efficiency_scores WHERE year IN (2020, 2022)) t WHERE rn <= 2 ORDER BY year, score DESC; |
What is the landfill capacity in Mumbai for 2020? | CREATE TABLE landfill_capacity (city VARCHAR(255),year INT,capacity_m3 INT); INSERT INTO landfill_capacity (city,year,capacity_m3) VALUES ('Mumbai',2020,1500000); | SELECT capacity_m3 FROM landfill_capacity WHERE city = 'Mumbai' AND year = 2020; |
insert new viewer 'Lia' into the viewership table | CREATE TABLE viewership(id INT PRIMARY KEY,movie VARCHAR(255),viewer VARCHAR(255)); | INSERT INTO viewership(id, movie, viewer) VALUES(1, 'The Witcher', 'Lia'); |
What is the average donation amount to 'Disaster Relief' programs in '2020'? | CREATE TABLE Donors (donor_id INT,donor_name VARCHAR(255)); CREATE TABLE Donations (donation_id INT,donor_id INT,donation_amount INT,donation_date DATE,program_area VARCHAR(255)); INSERT INTO Donors (donor_id,donor_name) VALUES (1,'James Smith'); INSERT INTO Donations (donation_id,donor_id,donation_amount,donation_date... | SELECT AVG(Donations.donation_amount) FROM Donations INNER JOIN Programs ON Donations.program_area = Programs.program_name WHERE Programs.program_name = 'Disaster Relief' AND YEAR(Donations.donation_date) = 2020; |
What is the minimum property price in each neighborhood? | CREATE TABLE min_prices (neighborhood VARCHAR(50),price DECIMAL(10,2)); INSERT INTO min_prices (neighborhood,price) VALUES ('Westwood',850000.00),('Beverly Hills',2500000.00),('Venice',1200000.00); | SELECT neighborhood, MIN(price) OVER (PARTITION BY neighborhood) AS min_price FROM min_prices; |
What is the daily usage of bike-sharing systems in Seoul? | CREATE TABLE seoul_bikes (id INT,ride_id VARCHAR(20),start_time TIMESTAMP,end_time TIMESTAMP,bike_id INT); | SELECT DATE(start_time) AS ride_date, COUNT(DISTINCT bike_id) FROM seoul_bikes GROUP BY ride_date; |
Find the total count of defense contracts awarded by the 'Army' and 'Navy' departments | CREATE TABLE defense_contracts (contract_id INT,department VARCHAR(50),value FLOAT); INSERT INTO defense_contracts (contract_id,department,value) VALUES (1,'Army',500000),(2,'Navy',700000); | SELECT SUM(value) FROM defense_contracts WHERE department IN ('Army', 'Navy'); |
What's the total revenue of movies released in 2010? | CREATE TABLE movie_revenue (id INT,title VARCHAR(255),release_year INT,revenue INT); INSERT INTO movie_revenue (id,title,release_year,revenue) VALUES (1,'Toy Story 3',2010,1103000000),(2,'Iron Man 2',2010,623970000); | SELECT SUM(revenue) FROM movie_revenue WHERE release_year = 2010; |
What is the minimum yield per acre for each crop type in urban agriculture? | CREATE TABLE crop_types_min (crop_type TEXT,acres NUMERIC,yield NUMERIC); INSERT INTO crop_types_min (crop_type,acres,yield) VALUES ('Wheat',2.1,12500),('Rice',3.5,17500),('Corn',4.2,24500),('Soybeans',2.9,15500); | SELECT crop_type, MIN(yield/acres) as min_yield_per_acre FROM crop_types_min GROUP BY crop_type; |
What is the total number of shipments sent to each country from China in the last year? | CREATE TABLE shipments(id INT,source VARCHAR(255),destination VARCHAR(255),shipment_date DATE); INSERT INTO shipments(id,source,destination,shipment_date) VALUES (1,'China','Japan','2022-01-01'),(2,'China','South Korea','2022-01-05'),(3,'China','Japan','2022-01-10'),(4,'China','India','2022-02-01'),(5,'China','Indone... | SELECT destination, COUNT(*) FROM shipments WHERE source = 'China' AND shipment_date >= CURDATE() - INTERVAL 365 DAY GROUP BY destination; |
What is the total water usage by residential customers in a specific neighborhood in 2022? | CREATE TABLE water_usage (id INT PRIMARY KEY,customer_id INT,usage_date DATE,usage_type VARCHAR(255),amount FLOAT); CREATE TABLE customers (id INT PRIMARY KEY,name VARCHAR(255),neighborhood VARCHAR(255)); | SELECT SUM(wu.amount) as total_water_usage FROM water_usage wu JOIN customers c ON wu.customer_id = c.id WHERE wu.usage_type = 'Residential' AND wu.usage_date BETWEEN '2022-01-01' AND '2022-12-31' AND c.neighborhood = 'Specific Neighborhood'; |
What is the average age of the animals in the 'animal_population' table per species? | CREATE TABLE animal_population (species VARCHAR(255),animal_id INT,name VARCHAR(255),age INT,health_status VARCHAR(255)); INSERT INTO animal_population (species,animal_id,name,age,health_status) VALUES ('Tiger',1,'Tara',5,'Healthy'),('Tiger',2,'Tim',3,'Sick'),('Elephant',3,'Ella',10,'Healthy'); | SELECT species, AVG(age) as avg_age FROM animal_population GROUP BY species; |
List all attorneys who have not handled any criminal cases. | CREATE TABLE attorneys (attorney_id INT,name VARCHAR(50)); CREATE TABLE criminal_cases (case_id INT,attorney_id INT); INSERT INTO attorneys (attorney_id,name) VALUES (1,'Smith'),(2,'Johnson'),(3,'Brown'); INSERT INTO criminal_cases (case_id,attorney_id) VALUES (1,1),(2,3); | SELECT a.name FROM attorneys a LEFT JOIN criminal_cases cc ON a.attorney_id = cc.attorney_id WHERE cc.attorney_id IS NULL; |
List the unique AI chatbot models used by the hotels in the hotels table, the adoption count, and the number of hotels with ratings above 4.5. | CREATE TABLE hotels (hotel_id INT,name VARCHAR(50),chatbot VARCHAR(50),rating FLOAT); INSERT INTO hotels (hotel_id,name,chatbot,rating) VALUES (1,'Hotel X','Model A',4.5),(2,'Hotel Y','Model B',4.2),(3,'Hotel Z','Model A',4.7),(4,'Hotel W','Model C',4.3),(5,'Hotel V','Model A',4.6),(6,'Hotel U','Model D',4.9); | SELECT chatbot, COUNT(DISTINCT hotel_id) as adoption_count, COUNT(CASE WHEN rating > 4.5 THEN 1 END) as high_rating_hotels_count FROM hotels GROUP BY chatbot; |
What are the total hours worked by construction laborers for permits issued in 2020, grouped by permit_id? | CREATE TABLE construction_labor (labor_id INT,permit_id INT,worker_name TEXT,hours_worked INT,wage FLOAT); INSERT INTO construction_labor (labor_id,permit_id,worker_name,hours_worked,wage) VALUES (3,3,'Maria Garcia',180,28.0); | SELECT permit_id, SUM(hours_worked) FROM construction_labor WHERE permit_id IN (SELECT permit_id FROM building_permits WHERE EXTRACT(YEAR FROM issue_date) = 2020) GROUP BY permit_id; |
List all mines in Australia and their respective mineral types. | CREATE TABLE australia_mines (id INT,mine_name TEXT,location TEXT,mineral TEXT); INSERT INTO australia_mines (id,mine_name,location,mineral) VALUES (1,'Opal Outback','Western Australia','Opal'),(2,'Emerald Empire','Queensland,Australia','Emerald'); | SELECT id, mine_name, location, mineral FROM australia_mines; |
Find the maximum response time for emergency calls in 'New York' | CREATE TABLE emergency_calls (id INT,city VARCHAR(20),response_time INT); INSERT INTO emergency_calls (id,city,response_time) VALUES (1,'San Francisco',120),(2,'New York',150),(3,'Los Angeles',100); | SELECT MAX(response_time) FROM emergency_calls WHERE city = 'New York'; |
What is the total volume of recycled water in Florida during 2020? | CREATE TABLE RecycledWater (id INT,state VARCHAR(20),year INT,volume FLOAT); INSERT INTO RecycledWater (id,state,year,volume) VALUES (1,'Florida',2020,500000.0),(2,'Florida',2019,450000.0),(3,'Georgia',2020,550000.0); | SELECT SUM(volume) FROM RecycledWater WHERE state = 'Florida' AND year = 2020; |
What is the percentage of donations received by the top 3 cities? | CREATE TABLE DonorCities (City VARCHAR(50),Population INT); INSERT INTO DonorCities (City,Population) VALUES ('San Francisco',884363),('Seattle',753359),('Boston',694543); CREATE TABLE Donations (DonationID INT,City VARCHAR(50),DonationAmount DECIMAL(10,2)); INSERT INTO Donations (DonationID,City,DonationAmount) VALUES... | SELECT City, SUM(DonationAmount) * 100.0 / (SELECT SUM(DonationAmount) FROM Donations) AS percentage FROM Donations GROUP BY City ORDER BY percentage DESC LIMIT 3; |
Which natural foundations have the highest customer ratings? | CREATE TABLE cosmetics_info(product_name TEXT,is_natural BOOLEAN,rating DECIMAL); INSERT INTO cosmetics_info(product_name,is_natural,rating) VALUES('Natural Foundation 1',true,4.5); | SELECT product_name FROM cosmetics_info WHERE is_natural = true AND rating = (SELECT MAX(rating) FROM cosmetics_info WHERE is_natural = true); |
What is the average score and total games played by players from the United States and Canada? | CREATE TABLE Players (PlayerID INT,PlayerName TEXT,Country TEXT,Score INT,GamesPlayed INT); INSERT INTO Players (PlayerID,PlayerName,Country,Score,GamesPlayed) VALUES (1,'John Doe','USA',100,50),(2,'Jane Smith','Canada',200,75); | SELECT AVG(Score) AS AvgScore, SUM(GamesPlayed) AS TotalGames FROM Players WHERE Country IN ('USA', 'Canada'); |
What is the minimum price of vegan menu items? | CREATE TABLE menus (menu_id INT,menu_name VARCHAR(50),menu_type VARCHAR(20),price DECIMAL(5,2)); INSERT INTO menus (menu_id,menu_name,menu_type,price) VALUES (1,'Quinoa Salad','Vegetarian',9.99),(2,'Margherita Pizza','Non-vegetarian',12.99),(3,'Tofu Stir Fry','Vegetarian',10.99),(4,'Vegan Burger','Vegan',11.99),(5,'Veg... | SELECT MIN(price) FROM menus WHERE menu_type = 'Vegan'; |
What is the average biosensor output for each biosensor type in India? | CREATE SCHEMA if not exists biosensors;CREATE TABLE if not exists biosensors.devices(id INT,name VARCHAR(255),type VARCHAR(255),output DECIMAL(10,2),country VARCHAR(255)); INSERT INTO biosensors.devices VALUES (1,'BioSensorA','Type1',5.2,'India'); INSERT INTO biosensors.devices VALUES (2,'BioSensorB','Type2',7.3,'India... | SELECT type, AVG(output) FROM biosensors.devices WHERE country = 'India' GROUP BY type; |
Who are the top 5 donors from India? | CREATE TABLE Donors (DonorID int,DonorName varchar(100),Country varchar(50),DonationDate date,AmountDonated decimal(10,2)); INSERT INTO Donors (DonorID,DonorName,Country,DonationDate,AmountDonated) VALUES (1,'Rajesh Patel','India','2022-01-01',1000.00),(2,'Priya Gupta','India','2022-02-01',2000.00),(3,'Ravi Singh','Ind... | SELECT DonorName, SUM(AmountDonated) as TotalDonated FROM Donors WHERE Country = 'India' GROUP BY DonorName ORDER BY TotalDonated DESC LIMIT 5; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.