instruction stringlengths 0 1.06k | input stringlengths 11 5.3k | response stringlengths 2 4.44k |
|---|---|---|
How many cases were handled by each attorney? | CREATE TABLE cases (case_id INT,attorney_id INT); | SELECT attorney_id, COUNT(*) FROM cases GROUP BY attorney_id; |
Which size category has the highest number of customers? | CREATE TABLE CustomerDemographics (id INT,customer_id INT,age INT,size_category TEXT); INSERT INTO CustomerDemographics (id,customer_id,age,size_category) VALUES (1,1,25,'S'),(2,2,35,'M'),(3,3,45,'L'),(4,4,55,'XL'),(5,5,65,'XXL'); | SELECT size_category, COUNT(*) AS count FROM CustomerDemographics GROUP BY size_category ORDER BY count DESC LIMIT 1; |
What is the minimum transaction value for Smart Contracts located in the 'Ethereum' blockchain? | CREATE TABLE Smart_Contracts (contract_name TEXT,transaction_value NUMERIC,blockchain TEXT); INSERT INTO Smart_Contracts (contract_name,transaction_value,blockchain) VALUES ('Contract A',50,'Ethereum'),('Contract A',75,'Ethereum'),('Contract A',100,'Ethereum'),('Contract B',25,'Bitcoin'),('Contract B',30,'Bitcoin'),('Contract C',15,'Ethereum'); | SELECT MIN(transaction_value) FROM Smart_Contracts WHERE blockchain = 'Ethereum'; |
What is the maximum depth of oceanic trenches in the Indian plate? | CREATE TABLE indian_plate (trench_name TEXT,location TEXT,average_depth FLOAT); INSERT INTO indian_plate (trench_name,location,average_depth) VALUES ('Java Trench','Indonesia',7680.0); | SELECT MAX(average_depth) FROM indian_plate WHERE trench_name = 'Java Trench'; |
Show top 3 most mentioned brands in India in 2022 | CREATE TABLE posts (post_id INT,post_text TEXT,brand_mentioned TEXT,post_date DATE); INSERT INTO posts (post_id,post_text,brand_mentioned,post_date) VALUES (1,'I love using @brandA','brandA','2022-01-01'),(2,'Check out @brandB,it is amazing!','brandB','2022-01-02'); | SELECT brand_mentioned, COUNT(*) as mention_count FROM posts WHERE YEAR(post_date) = 2022 AND country = 'India' GROUP BY brand_mentioned ORDER BY mention_count DESC LIMIT 3; |
Count of creative AI applications submitted from Africa in H2 of 2020? | CREATE TABLE creative_ai (application_id TEXT,region TEXT,submission_half TEXT); INSERT INTO creative_ai (application_id,region,submission_half) VALUES ('App1','North America','H2 2020'),('App2','Africa','H2 2020'),('App3','Europe','H1 2021'),('App4','Africa','H1 2021'); | SELECT COUNT(*) FROM creative_ai WHERE region = 'Africa' AND submission_half = 'H2 2020'; |
Insert a new player with a score of 1500 in the 'Sports' game category. | CREATE TABLE SportsScores (PlayerID int,PlayerName varchar(50),Game varchar(50),Score int); | INSERT INTO SportsScores (PlayerID, PlayerName, Game, Score) VALUES (1, 'Player5', 'Game5', 1500); |
List the top 5 mining sites with the highest environmental impact scores in the 'Americas' region. | CREATE TABLE mining_sites (id INT,site_name VARCHAR(50),location VARCHAR(50),environmental_score FLOAT); INSERT INTO mining_sites (id,site_name,location,environmental_score) VALUES (1,'Site A','USA',78.50); | SELECT site_name, environmental_score FROM mining_sites WHERE location LIKE 'Americas' ORDER BY environmental_score DESC LIMIT 5; |
Delete all records of hotels with a rating above 4.5 in the 'Asia-Pacific' region. | CREATE TABLE hotels (hotel_id INT,hotel_name VARCHAR(255),rating DECIMAL(2,1),country VARCHAR(255)); INSERT INTO hotels (hotel_id,hotel_name,rating,country) VALUES (1,'Hotel Sydney',4.8,'Australia'),(2,'Hotel Tokyo',4.2,'Japan'),(3,'Hotel Singapore',4.6,'Singapore'); | DELETE FROM hotels WHERE country IN ('Australia', 'Japan', 'Singapore', 'China', 'India') AND rating > 4.5; |
Update the 'equipment' table to set the temperature to 35 where the bioprocess_id is 1 | CREATE TABLE bioprocess (id INT PRIMARY KEY,name TEXT); CREATE TABLE equipment (bioprocess_id INT,reactor_id INT,temperature INT,pressure INT,volume INT,stir_speed INT,pH REAL,FOREIGN KEY (bioprocess_id) REFERENCES bioprocess(id)); | UPDATE equipment SET temperature = 35 WHERE bioprocess_id = 1; |
What is the average price of foundation products in Canada? | CREATE TABLE ProductPrices (product VARCHAR(255),country VARCHAR(255),price DECIMAL(10,2)); INSERT INTO ProductPrices (product,country,price) VALUES ('Foundation','Canada',25),('Foundation','Canada',30),('Mascara','Canada',20); | SELECT AVG(price) FROM ProductPrices WHERE product = 'Foundation' AND country = 'Canada'; |
What is the number of public schools in each city of Brazil? | CREATE TABLE schools (id INT,name VARCHAR(100),city VARCHAR(50),public BOOLEAN); INSERT INTO schools (id,name,city,public) VALUES (1,'School 1','City 1',true); INSERT INTO schools (id,name,city,public) VALUES (2,'School 2','City 2',false); | SELECT city, COUNT(*) FROM schools WHERE public = true GROUP BY city; |
What is the total number of volunteers for organizations in the 'Health' category? | CREATE TABLE volunteers (id INT,name VARCHAR(50)); CREATE TABLE volunteer_events (id INT,volunteer_id INT,organization_id INT,hours DECIMAL(10,2)); CREATE TABLE organizations (id INT,name VARCHAR(50),category VARCHAR(20)); INSERT INTO volunteers (id,name) VALUES (1,'Volunteer1'),(2,'Volunteer2'),(3,'Volunteer3'),(4,'Volunteer4'),(5,'Volunteer5'); INSERT INTO volunteer_events (id,volunteer_id,organization_id,hours) VALUES (1,1,1,2.5),(2,2,1,3.5),(3,3,2,5),(4,4,2,6),(5,5,3,4); INSERT INTO organizations (id,name,category) VALUES (1,'Org1','Health'),(2,'Org2','Health'),(3,'Org3','Arts & Culture'); | SELECT COUNT(DISTINCT volunteer_id) FROM volunteer_events JOIN organizations ON volunteer_events.organization_id = organizations.id WHERE organizations.category = 'Health'; |
What is the number of hotel bookings made through mobile devices in the last month? | CREATE TABLE bookings (booking_id INT,hotel_name VARCHAR(255),booking_date DATE,device_type VARCHAR(255)); | SELECT COUNT(*) FROM bookings WHERE device_type = 'mobile' AND booking_date >= DATEADD(month, -1, GETDATE()); |
How many 'pottery' items in 'asia_artifacts' weigh more than 200g? | CREATE TABLE asia_artifacts (id INT,site_name VARCHAR(50),artifact_name VARCHAR(50),period VARCHAR(20),weight INT); | SELECT COUNT(*) FROM asia_artifacts WHERE artifact_name = 'pottery' AND weight > 200; |
List the names of companies that have had at least one round of funding over $10 million and were founded before 2010. | CREATE TABLE companies (id INT,name TEXT,founding_date DATE);CREATE TABLE funds (id INT,company_id INT,amount INT,funding_round TEXT); | SELECT companies.name FROM companies INNER JOIN funds ON companies.id = funds.company_id WHERE funds.amount > 10000000 AND companies.founding_date < '2010-01-01'; |
What is the distribution of audience demographics by gender in the 'audience_stats' table? | CREATE TABLE audience_stats (id INT,user_id INT,age INT,gender VARCHAR(50),location VARCHAR(255)); | SELECT gender, COUNT(*) as audience_count FROM audience_stats GROUP BY gender; |
What was the total revenue of organic products sold in the USA in Q1 2022? | CREATE TABLE OrganicProductSales (product_id INT,sale_date DATE,revenue DECIMAL(10,2)); | SELECT SUM(revenue) FROM OrganicProductSales WHERE sale_date BETWEEN '2022-01-01' AND '2022-03-31' AND country = 'USA'; |
What is the total billing amount for cases in the state of California? | CREATE TABLE Cases (CaseID INT,State VARCHAR(255),BillingAmount DECIMAL(10,2)); INSERT INTO Cases (CaseID,State,BillingAmount) VALUES (1,'California',2000.00); INSERT INTO Cases (CaseID,State,BillingAmount) VALUES (2,'Texas',3000.00); INSERT INTO Cases (CaseID,State,BillingAmount) VALUES (3,'California',1500.00); | SELECT SUM(BillingAmount) FROM Cases WHERE State = 'California'; |
What is the total revenue for each category in the last month? | CREATE TABLE dishes (dish_id INT,dish VARCHAR(50),category VARCHAR(50),created_at TIMESTAMP);CREATE TABLE orders (order_id INT,dish_id INT,price DECIMAL(5,2)); | SELECT c.category, SUM(o.price) as total_revenue FROM dishes d JOIN orders o ON d.dish_id = o.dish_id WHERE d.created_at >= NOW() - INTERVAL '1 month' GROUP BY c.category; |
What is the total weight of seafood sourced from MSC-certified suppliers? | CREATE TABLE suppliers (supplier_id INT,name VARCHAR(50),msc_certified BOOLEAN); CREATE TABLE seafood_purchases (purchase_id INT,supplier_id INT,weight DECIMAL(10,2)); INSERT INTO suppliers (supplier_id,name,msc_certified) VALUES (1,'Sea Fresh',true),(2,'Ocean Bounty',false),(3,'Fish Direct',false); INSERT INTO seafood_purchases (purchase_id,supplier_id,weight) VALUES (1,1,120.50),(2,1,150.25),(3,3,85.75); | SELECT SUM(weight) FROM seafood_purchases JOIN suppliers ON seafood_purchases.supplier_id = suppliers.supplier_id WHERE suppliers.msc_certified = true; |
Which companies have manufactured spacecraft for ESA? | CREATE TABLE ESA_Spacecraft (SpacecraftID INT,Name VARCHAR(50),Manufacturer VARCHAR(30)); INSERT INTO ESA_Spacecraft (SpacecraftID,Name,Manufacturer) VALUES (1,'ATV-1 Jules Verne','EADS Astrium'),(2,'ATV-2 Johannes Kepler','Airbus Defence and Space'),(3,'ATV-3 Edoardo Amaldi','Airbus Safran Launchers'),(4,'ATV-4 Albert Einstein','Airbus Defence and Space'); | SELECT DISTINCT Manufacturer FROM ESA_Spacecraft; |
How many marine species are impacted by climate change in the Arctic region? | CREATE TABLE marine_species (name TEXT,region TEXT,impacted_by TEXT); INSERT INTO marine_species (name,region,impacted_by) VALUES ('Polar Bear','Arctic','climate_change'),('Narwhal','Arctic','climate_change'),('Greenland Shark','Arctic','ocean_acidification'),('Harp Seal','Arctic','climate_change'); | SELECT impacted_by, COUNT(*) AS count FROM marine_species WHERE region = 'Arctic' AND impacted_by = 'climate_change' GROUP BY impacted_by; |
How many climate adaptation projects are in Southeast Asia funded by the Global Environment Facility? | CREATE TABLE global_environment_facility (fund_id INT,project_name VARCHAR(100),country VARCHAR(50),sector VARCHAR(50),adaptation_flag BOOLEAN); INSERT INTO global_environment_facility (fund_id,project_name,country,sector,adaptation_flag) VALUES (1,'Mangrove Restoration','Indonesia','Forestry',TRUE); | SELECT COUNT(*) FROM global_environment_facility WHERE country LIKE '%%southeast%asia%%' AND adaptation_flag = TRUE; |
Delete the mining sites that have been inactive for the past six months | CREATE TABLE mining_sites (site_id INT,site_name VARCHAR(255)); INSERT INTO mining_sites (site_id,site_name) VALUES (1,'Site A'),(2,'Site B'); CREATE TABLE mining_activities (activity_id INT,site_id INT,activity_date DATE); INSERT INTO mining_activities (activity_id,site_id,activity_date) VALUES (1,1,'2022-01-01'),(2,1,'2022-01-02'),(3,2,'2022-01-01'); | DELETE s FROM mining_sites s LEFT JOIN mining_activities a ON s.site_id = a.site_id WHERE a.activity_date IS NULL OR a.activity_date < DATE_SUB(CURDATE(), INTERVAL 6 MONTH); |
How many articles were published in 'regional_newspapers' table and 'international_newswire' table for each month in 2020? | CREATE TABLE regional_newspapers (article_id INT,publication_date DATE,region VARCHAR(50));CREATE TABLE international_newswire (article_id INT,publication_date DATE,country VARCHAR(50)); | SELECT DATE_FORMAT(publication_date, '%Y-%m') AS month, COUNT(*) FROM regional_newspapers WHERE YEAR(publication_date) = 2020 GROUP BY month;SELECT DATE_FORMAT(publication_date, '%Y-%m') AS month, COUNT(*) FROM international_newswire WHERE YEAR(publication_date) = 2020 GROUP BY month; |
Find the top 2 countries with the highest number of users with visual impairments in the second quarter of 2021, and display the total number of users for each. | CREATE TABLE users (user_id INT,user_disability BOOLEAN,user_country VARCHAR(50)); INSERT INTO users (user_id,user_disability,user_country) VALUES (1,true,'Brazil'); | SELECT user_country, COUNT(*) as user_count FROM users WHERE EXTRACT(MONTH FROM user_last_login) BETWEEN 4 AND 6 AND user_disability = true GROUP BY user_country ORDER BY user_count DESC LIMIT 2; |
What is the maximum water consumption (in liters) in a single day for the city of Melbourne, Australia in 2020? | CREATE TABLE daily_water_usage (id INT,city VARCHAR(255),usage_liters INT,date DATE); INSERT INTO daily_water_usage (id,city,usage_liters,date) VALUES (1,'Melbourne',120000,'2020-01-01'),(2,'Melbourne',130000,'2020-01-02'),(3,'Melbourne',140000,'2020-01-03'); | SELECT MAX(usage_liters) FROM daily_water_usage WHERE city = 'Melbourne' AND date BETWEEN '2020-01-01' AND '2020-12-31'; |
What is the average size (in hectares) of all indigenous food system farms in the 'indigenous_food' schema? | CREATE SCHEMA if not exists indigenous_food; use indigenous_food; CREATE TABLE indigenous_farms (id INT,name TEXT,size_ha FLOAT,location TEXT); INSERT INTO indigenous_farms (id,name,size_ha,location) VALUES (1,'Farm 3',30.0,'City E'),(2,'Farm 4',45.0,'City F'); | SELECT AVG(size_ha) FROM indigenous_food.indigenous_farms; |
Which teams have the highest and lowest average ticket prices for VIP seats? | CREATE TABLE Teams (TeamID INT,TeamName VARCHAR(50),AvgVIPTicketPrice DECIMAL(5,2)); | SELECT TeamName FROM Teams WHERE AvgVIPTicketPrice = (SELECT MAX(AvgVIPTicketPrice) FROM Teams) OR AvgVIPTicketPrice = (SELECT MIN(AvgVIPTicketPrice) FROM Teams); |
Find the average production quantity of chemical 'C456' in each country | CREATE TABLE chemical_production (id INT PRIMARY KEY,chemical_id VARCHAR(10),quantity INT,country VARCHAR(50)); INSERT INTO chemical_production (id,chemical_id,quantity,country) VALUES (1,'C123',500,'USA'),(2,'C456',300,'Canada'),(3,'C123',100,'Germany'),(4,'C456',250,'USA'),(5,'C456',350,'Canada'); | SELECT country, AVG(quantity) FROM chemical_production WHERE chemical_id = 'C456' GROUP BY country; |
What is the distribution of visitor ages for the 'Modern Art' exhibition in Tokyo in 2021? | CREATE TABLE TokyoVisitorAge (id INT,exhibition_name VARCHAR(30),city VARCHAR(20),year INT,visitor_age INT); INSERT INTO TokyoVisitorAge (id,exhibition_name,city,year,visitor_age) VALUES (1,'Modern Art','Tokyo',2021,25),(2,'Modern Art','Tokyo',2021,35),(3,'Modern Art','Tokyo',2021,45); | SELECT visitor_age, COUNT(*) FROM TokyoVisitorAge WHERE exhibition_name = 'Modern Art' AND city = 'Tokyo' AND year = 2021 GROUP BY visitor_age; |
Which menu item in the 'Desserts' category has the highest price? | CREATE TABLE menu (menu_id INT,menu_name VARCHAR(50),category VARCHAR(50),quantity_sold INT,price DECIMAL(5,2),month_sold INT); INSERT INTO menu (menu_id,menu_name,category,quantity_sold,price,month_sold) VALUES (3,'New York Cheesecake','Desserts',25,7.99,1),(4,'Chocolate Lava Cake','Desserts',30,8.99,1); | SELECT menu_name, MAX(price) FROM menu WHERE category = 'Desserts'; |
Find the number of suppliers that have supplied at least one product in each of the following categories: fruits, vegetables, and grains. | CREATE TABLE suppliers (supplier_id INT,supplier_name TEXT);CREATE TABLE inventory (product_id INT,product_name TEXT,category TEXT);INSERT INTO suppliers VALUES (1,'Supplier A'),(2,'Supplier B'),(3,'Supplier C'),(4,'Supplier D'),(5,'Supplier E');INSERT INTO inventory VALUES (100,'Apples','Fruits'),(101,'Bananas','Fruits'),(102,'Oranges','Fruits'),(200,'Carrots','Vegetables'),(201,'Broccoli','Vegetables'),(202,'Spinach','Vegetables'),(300,'Rice','Grains'),(301,'Quinoa','Grains'),(302,'Oats','Grains'); | SELECT COUNT(DISTINCT supplier_id) FROM (SELECT supplier_id FROM inventory WHERE category = 'Fruits' INTERSECT SELECT supplier_id FROM inventory WHERE category = 'Vegetables' INTERSECT SELECT supplier_id FROM inventory WHERE category = 'Grains') AS intersection; |
Which restorative program in Florida has the highest number of successful completions? | CREATE TABLE restorative_completions (completion_id INT,program_id INT,state VARCHAR(20),completions INT); INSERT INTO restorative_completions (completion_id,program_id,state,completions) VALUES (1,1,'New York',35),(2,2,'Florida',42),(3,3,'Texas',21); | SELECT program_id, MAX(completions) FROM restorative_completions WHERE state = 'Florida' GROUP BY program_id; |
Update contract start date for mobile subscribers with data speed complaints | CREATE TABLE mobile_subscribers (id INT,name VARCHAR(255),data_allowance INT,contract_start DATE); INSERT INTO mobile_subscribers (id,name,data_allowance,contract_start) VALUES (1,'John Doe',5000,'2020-01-01'),(2,'Jane Doe',3000,'2019-01-01'); CREATE TABLE customer_complaints (id INT,subscriber_id INT,complaint_date DATE,complaint_type VARCHAR(255)); INSERT INTO customer_complaints (id,subscriber_id,complaint_date,complaint_type) VALUES (1,1,'2020-02-01','Data Speed'); | UPDATE mobile_subscribers SET contract_start = '2020-02-02' WHERE id IN (SELECT subscriber_id FROM customer_complaints WHERE complaint_type = 'Data Speed'); |
Count the number of packages shipped to each country in the 'EMEA' region | CREATE TABLE countries (id INT,name TEXT,region TEXT); INSERT INTO countries (id,name,region) VALUES (1,'USA','Americas'),(2,'China','APAC'),(3,'France','EMEA'),(4,'Canada','Americas'); | SELECT country, COUNT(*) FROM packages JOIN (SELECT id, name FROM countries WHERE region = 'EMEA') countries ON packages.country = countries.name GROUP BY country; |
Identify the unique treatments for PTSD and OCD | CREATE TABLE treatments (treatment_id INT,condition VARCHAR(20)); INSERT INTO treatments (treatment_id,condition) VALUES (1,'PTSD'),(2,'OCD'); | SELECT DISTINCT condition FROM treatments; |
Update the job title for the veteran with the SSN 123-45-6789 to 'Senior Software Engineer'. | CREATE TABLE employees (ssn VARCHAR(11),first_name VARCHAR(20),last_name VARCHAR(20),job_title VARCHAR(30)); | UPDATE employees SET job_title = 'Senior Software Engineer' WHERE ssn = '123-45-6789'; |
What is the number of accidents reported in '2021' in the 'SafetyIncidents' table? | CREATE TABLE SafetyIncidents (id INT,year INT,accident_reported INT); INSERT INTO SafetyIncidents (id,year,accident_reported) VALUES (1,2019,1),(2,2020,2),(3,2021,3); | SELECT SUM(accident_reported) FROM SafetyIncidents WHERE year = 2021; |
Present total mineral extraction in Indonesia by year. | CREATE TABLE mineral_extraction (id INT,mine_id INT,year INT,quantity INT);CREATE TABLE mine (id INT,name VARCHAR(255),location VARCHAR(255)); INSERT INTO mine (id,name,location) VALUES (1,'Indonesian Coal','Indonesia'); INSERT INTO mineral_extraction (id,mine_id,year,quantity) VALUES (1,1,2019,5000); | SELECT year, SUM(quantity) as total_mineral_extraction FROM mineral_extraction JOIN mine ON mineral_extraction.mine_id = mine.id WHERE mine.location = 'Indonesia' GROUP BY year; |
Who are the top 3 customers in terms of spending on vegan skincare products in the United States? | CREATE TABLE customers (customer_id INT,customer_name TEXT,country TEXT); INSERT INTO customers (customer_id,customer_name,country) VALUES (1,'Jessica Smith','US'),(2,'David Johnson','CA'),(3,'Sarah Thompson','US'),(4,'Michael Brown','UK'),(5,'Emily Davis','US'); CREATE TABLE sales (sale_id INT,customer_id INT,product_id INT,sale_quantity INT,is_vegan BOOLEAN); INSERT INTO sales (sale_id,customer_id,product_id,sale_quantity,is_vegan) VALUES (1,1,1,50,true),(2,2,2,75,false),(3,3,3,60,true),(4,4,4,80,false),(5,5,5,90,true); CREATE TABLE products (product_id INT,product_name TEXT,brand_id INT,is_vegan BOOLEAN); INSERT INTO products (product_id,product_name,brand_id,is_vegan) VALUES (1,'Facial Cleanser',1,true),(2,'Moisturizing Lotion',2,false),(3,'Vegan Serum',3,true),(4,'Shea Butter Cream',4,false),(5,'Jojoba Oil',5,true); | SELECT c.customer_name, SUM(s.sale_quantity * p.is_vegan) as total_spent_on_vegan_products FROM sales s JOIN customers c ON s.customer_id = c.customer_id JOIN products p ON s.product_id = p.product_id WHERE c.country = 'US' GROUP BY c.customer_name ORDER BY total_spent_on_vegan_products DESC LIMIT 3; |
List the chemical_ids and total production quantities for chemicals produced in the USA | CREATE TABLE chemical_production (id INT PRIMARY KEY,chemical_id VARCHAR(10),quantity INT,country VARCHAR(50)); INSERT INTO chemical_production (id,chemical_id,quantity,country) VALUES (1,'C123',500,'USA'),(2,'C456',300,'Canada'),(3,'C123',100,'Germany'),(4,'C456',250,'USA'),(5,'C456',350,'Canada'),(6,'C123',400,'Mexico'),(7,'C789',550,'Mexico'),(8,'C123',600,'USA'); | SELECT chemical_id, SUM(quantity) FROM chemical_production WHERE country = 'USA' GROUP BY chemical_id; |
How many hours did volunteers contribute to disaster relief programs in Japan in 2020? | CREATE TABLE Volunteers (id INT,volunteer_name VARCHAR(255),program VARCHAR(255),volunteer_hours INT,volunteer_date DATE); INSERT INTO Volunteers (id,volunteer_name,program,volunteer_hours,volunteer_date) VALUES (1,'Yamada Taro','Disaster Relief',25,'2020-03-14'),(2,'Tanaka Hanako','Disaster Relief',30,'2020-11-05'); | SELECT SUM(volunteer_hours) FROM Volunteers WHERE program = 'Disaster Relief' AND volunteer_date BETWEEN '2020-01-01' AND '2020-12-31'; |
Delete records with zero water conservation in Florida and Georgia. | CREATE TABLE conservation(state TEXT,savings INTEGER); INSERT INTO conservation(state,savings) VALUES ('Florida',50),('Georgia',0),('Florida',0),('Georgia',100); | DELETE FROM conservation WHERE state IN ('Florida', 'Georgia') AND savings = 0; |
Calculate the average price of all menu items | CREATE TABLE Menu (id INT PRIMARY KEY,name VARCHAR(255),category VARCHAR(255),price DECIMAL(5,2)); | SELECT AVG(price) FROM Menu; |
List the co-owners and their shared property addresses in Seattle, WA. | CREATE TABLE co_owners (id INT,name VARCHAR(30),property_id INT); CREATE TABLE properties (id INT,address VARCHAR(50),city VARCHAR(20)); INSERT INTO co_owners (id,name,property_id) VALUES (1,'Alex',101),(2,'Bella',101),(3,'Charlie',102); INSERT INTO properties (id,address,city) VALUES (101,'1234 SE Stark St','Seattle'),(102,'5678 NE 20th Ave','Seattle'); | SELECT co_owners.name, properties.address FROM co_owners INNER JOIN properties ON co_owners.property_id = properties.id WHERE properties.city = 'Seattle'; |
What is the total number of satellites owned by African countries? | CREATE TABLE countries (id INTEGER,name TEXT,region TEXT,num_satellites INTEGER); INSERT INTO countries (id,name,region,num_satellites) VALUES (1,'Algeria','Africa',2),(2,'Egypt','Africa',5),(3,'Nigeria','Africa',10),(4,'South Africa','Africa',12),(5,'Kenya','Africa',3),(6,'Ghana','Africa',1); CREATE TABLE space_programs (id INTEGER,country TEXT); INSERT INTO space_programs (id,country) VALUES (6,'Ghana'); | SELECT SUM(num_satellites) FROM countries WHERE region = 'Africa' AND country IN (SELECT country FROM space_programs); |
What is the average price of eco-friendly tour packages? | CREATE TABLE tour_packages (package_id INT,package_type VARCHAR(20),price DECIMAL(5,2),is_eco_friendly BOOLEAN); INSERT INTO tour_packages (package_id,package_type,price,is_eco_friendly) VALUES (1,'City Tour',50,FALSE),(2,'Nature Hike',75,TRUE),(3,'Historical Tour',60,FALSE),(4,'Eco-friendly City Tour',65,TRUE); | SELECT AVG(price) FROM tour_packages WHERE is_eco_friendly = TRUE; |
What are the names of patients who have not received any treatment? | CREATE TABLE patient_treatments (patient_id INT,treatment VARCHAR(10)); INSERT INTO patient_treatments (patient_id,treatment) VALUES (1,'CBT'),(2,'DBT'),(3,'CBT'),(4,NULL); | SELECT patients.name FROM patients LEFT JOIN patient_treatments ON patients.patient_id = patient_treatments.patient_id WHERE patient_treatments.treatment IS NULL; |
What is the average income for each client, and what is the overall average income? | CREATE TABLE customer_analytics (client_id INT,income DECIMAL(10,2),education VARCHAR(50),marital_status VARCHAR(20)); INSERT INTO customer_analytics (client_id,income,education,marital_status) VALUES (3,80000,'PhD','Married'); INSERT INTO customer_analytics (client_id,income,education,marital_status) VALUES (4,90000,'High School','Single'); | SELECT client_id, income, AVG(income) OVER () as overall_average_income FROM customer_analytics; |
What is the average salary of full-time workers who are union members in the 'finance' industry? | CREATE TABLE fulltime_workers (id INT,industry VARCHAR(20),salary FLOAT,union_member BOOLEAN); INSERT INTO fulltime_workers (id,industry,salary,union_member) VALUES (1,'manufacturing',50000.0,true),(2,'technology',70000.0,true),(3,'finance',80000.0,true),(4,'finance',85000.0,true),(5,'finance',90000.0,true); | SELECT AVG(salary) FROM fulltime_workers WHERE industry = 'finance' AND union_member = true; |
What are the total budgets for evidence-based policy making initiatives for each department in the current fiscal year? | CREATE TABLE dept_budgets (dept_name TEXT,fiscal_year INT,budget INT); CREATE TABLE evidence_based_policy_making (initiative_id INT,dept_name TEXT,initiative_budget INT); | SELECT dept_budgets.dept_name, SUM(evidence_based_policy_making.initiative_budget) AS total_budget FROM dept_budgets INNER JOIN evidence_based_policy_making ON dept_budgets.dept_name = evidence_based_policy_making.dept_name WHERE dept_budgets.fiscal_year = EXTRACT(YEAR FROM CURRENT_DATE) GROUP BY dept_budgets.dept_name; |
List the top 3 donors by the amount donated to 'Health Services' in '2021' | 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,service_area VARCHAR(255)); INSERT INTO Donors (donor_id,donor_name) VALUES (1,'Jane Doe'); INSERT INTO Donations (donation_id,donor_id,donation_amount,donation_date,service_area) VALUES (1,1,1000,'2021-01-01','Health Services'); | SELECT Donors.donor_name, SUM(Donations.donation_amount) as total_donation FROM Donors INNER JOIN Donations ON Donors.donor_id = Donations.donor_id WHERE Donations.service_area = 'Health Services' AND YEAR(Donations.donation_date) = 2021 GROUP BY Donors.donor_name ORDER BY total_donation DESC LIMIT 3; |
What is the average budget allocated per service category in the Parks and Recreation department? | CREATE TABLE Parks_And_Rec (ID INT,Service VARCHAR(255),Budget FLOAT); INSERT INTO Parks_And_Rec (ID,Service,Budget) VALUES (1,'Parks Maintenance',400000),(2,'Sports Programs',500000),(3,'Community Events',600000); | SELECT AVG(Budget) FROM Parks_And_Rec GROUP BY Service; |
What is the total revenue generated from digital music sales by each artist? | CREATE TABLE MusicSales (SaleID INT,ArtistName VARCHAR(20),Genre VARCHAR(10),SalesAmount DECIMAL(10,2)); INSERT INTO MusicSales (SaleID,ArtistName,Genre,SalesAmount) VALUES (1,'Ella Fitzgerald','Jazz',12.99),(2,'The Beatles','Rock',15.00),(3,'Ariana Grande','Pop',19.45),(4,'Billie Eilish','Pop',11.99); | SELECT ArtistName, SUM(SalesAmount) as TotalRevenue FROM MusicSales GROUP BY ArtistName; |
What is the maximum number of veterans hired per month by each company? | CREATE TABLE veteran_employment (employment_id INT,hire_date DATE,company_name TEXT,veteran_status TEXT,num_hired INT); INSERT INTO veteran_employment (employment_id,hire_date,company_name,veteran_status,num_hired) VALUES (1,'2022-01-05','XYZ Manufacturing','Veteran',15); INSERT INTO veteran_employment (employment_id,hire_date,company_name,veteran_status,num_hired) VALUES (2,'2022-01-12','LMN Services','Veteran Spouse',8); | SELECT company_name, MAX(num_hired) as max_veterans_hired_per_month FROM veteran_employment WHERE hire_date >= DATEADD(month, DATEDIFF(month, 0, GETDATE()), 0) GROUP BY company_name; |
What is the average price of garments made with recycled materials? | CREATE TABLE RecycledGarments (id INT,garment VARCHAR(50),price DECIMAL(5,2)); INSERT INTO RecycledGarments (id,garment,price) VALUES (1,'Recycled Polyester Shirt',25.99),(2,'Reclaimed Wood Tote',39.99),(3,'Regenerated Leather Jacket',75.00); | SELECT AVG(price) FROM RecycledGarments; |
List the number of cybersecurity incidents reported by the defense industry in each country for the last 12 months. | CREATE TABLE cybersecurity_incidents(id INT,industry VARCHAR(30),country VARCHAR(30),incident_date DATE); | SELECT country, COUNT(*) AS incidents FROM cybersecurity_incidents WHERE industry = 'defense' AND incident_date >= DATE(NOW()) - INTERVAL 12 MONTH GROUP BY country; |
What are the total cybersecurity budgets by country for the last 3 years? | CREATE TABLE cyber_budgets (id INT,country VARCHAR(255),year INT,budget DECIMAL(10,2)); INSERT INTO cyber_budgets (id,country,year,budget) VALUES (1,'United States',2019,5000000),(2,'China',2019,4000000),(3,'Russia',2019,3000000),(4,'United States',2020,6000000),(5,'China',2020,5000000),(6,'Russia',2020,4000000); | SELECT country, SUM(budget) as total_budget FROM cyber_budgets WHERE year IN (2019, 2020, 2021) GROUP BY country; |
How many hours did each volunteer contribute to the healthcare programs in H2 2021? | CREATE TABLE VolunteerHours (Volunteer VARCHAR(50),Program VARCHAR(50),Hours INT,VolunteerDate DATE); INSERT INTO VolunteerHours (Volunteer,Program,Hours,VolunteerDate) VALUES ('Sophia Chen','Healthcare Outreach',8,'2021-07-02'),('Daniel Kim','Medical Research',12,'2021-11-05'); | SELECT Volunteer, SUM(Hours) as TotalHours FROM VolunteerHours WHERE VolunteerDate BETWEEN '2021-07-01' AND '2021-12-31' AND Program LIKE '%Healthcare%' GROUP BY Volunteer; |
Which vegetarian menu items have the highest and lowest sales? | CREATE TABLE SalesData (id INT,item VARCHAR(30),sales INT); INSERT INTO SalesData (id,item,sales) VALUES (1,'Vegetable Curry',70),(2,'Vegetable Stir Fry',50); | SELECT item, sales FROM SalesData WHERE item LIKE '%Vegetarian%' ORDER BY sales DESC, sales ASC LIMIT 1; |
What is the average rating of movies produced in the US and released between 2010 and 2020? | CREATE TABLE Movies (id INT,title VARCHAR(255),country VARCHAR(50),release_year INT,rating DECIMAL(3,2)); INSERT INTO Movies (id,title,country,release_year,rating) VALUES (1,'Movie1','USA',2010,7.5),(2,'Movie2','USA',2015,8.2),(3,'Movie3','Canada',2018,6.8); | SELECT AVG(rating) FROM Movies WHERE country = 'USA' AND release_year BETWEEN 2010 AND 2020; |
Which ethical labor certifications are present in the Manufacturing table? | CREATE TABLE Manufacturing (manufacturer_id INT,manufacturer_name TEXT,certification TEXT); INSERT INTO Manufacturing (manufacturer_id,manufacturer_name,certification) VALUES (101,'Textile Co','SA8000'); INSERT INTO Manufacturing (manufacturer_id,manufacturer_name,certification) VALUES (102,'Gadgets Inc','Fair Labor'); INSERT INTO Manufacturing (manufacturer_id,manufacturer_name,certification) VALUES (103,'Eco Parts Ltd','ISO 14001'); | SELECT DISTINCT certification FROM Manufacturing; |
Insert a new record in the trending_fashions table for style 'T-shirt', region 'Africa' and popularity 70 | CREATE TABLE trending_fashions (style VARCHAR(255) PRIMARY KEY,region VARCHAR(255),popularity INT); INSERT INTO trending_fashions (style,region,popularity) VALUES ('Tunic','MiddleEast',60),('Pants','Asia',90); | INSERT INTO trending_fashions (style, region, popularity) VALUES ('T-shirt', 'Africa', 70); |
How many customers have a subscription that includes both mobile and broadband services? | CREATE TABLE subscriptions (id INT,customer_id INT,mobile_service BOOLEAN,broadband_service BOOLEAN); INSERT INTO subscriptions (id,customer_id,mobile_service,broadband_service) VALUES (1,1,true,true),(2,2,false,true),(3,3,true,false); | SELECT COUNT(*) FROM subscriptions WHERE mobile_service = true AND broadband_service = true; |
What is the average height of basketball players in the 'nba_players' table? | CREATE TABLE nba_players (player_id INT,name VARCHAR(50),height DECIMAL(3,1),position VARCHAR(50)); INSERT INTO nba_players (player_id,name,height,position) VALUES (1,'LeBron James',6.8,'Forward'); INSERT INTO nba_players (player_id,name,height,position) VALUES (2,'Stephen Curry',6.3,'Guard'); | SELECT AVG(height) FROM nba_players; |
Find dishes with more than 2 allergens and their average calorie count | CREATE TABLE dishes (dish_id INT PRIMARY KEY,dish_name VARCHAR(255),calories INT);CREATE TABLE allergens (allergen_id INT PRIMARY KEY,dish_id INT,FOREIGN KEY (dish_id) REFERENCES dishes(dish_id)); | SELECT d.dish_name, AVG(d.calories) FROM dishes d JOIN allergens a ON d.dish_id = a.dish_id GROUP BY d.dish_id HAVING COUNT(DISTINCT a.allergen_id) > 2; |
What is the total revenue generated from concert ticket sales and music streaming in the country of 'India'? | CREATE TABLE concert_sales (id INT,artist VARCHAR(255),country VARCHAR(255),date DATE,tickets_sold INT,revenue FLOAT); INSERT INTO concert_sales (id,artist,country,date,tickets_sold,revenue) VALUES (1,'AR Rahman','India','2022-04-01',7500,225000.00); CREATE TABLE music_streaming (id INT,artist VARCHAR(255),country VARCHAR(255),date DATE,streams INT,revenue FLOAT); INSERT INTO music_streaming (id,artist,country,date,streams,revenue) VALUES (1,'AR Rahman','India','2022-04-01',150000,15000.00); | SELECT SUM(concert_sales.revenue + music_streaming.revenue) FROM concert_sales INNER JOIN music_streaming ON concert_sales.country = music_streaming.country WHERE concert_sales.country = 'India'; |
Show biosensor technology companies in Europe that have over 10 million in funding after 2019. | CREATE TABLE company_eu (id INT PRIMARY KEY,name VARCHAR(255),location VARCHAR(255),industry VARCHAR(255)); INSERT INTO company_eu (id,name,location,industry) VALUES (1,'BioSense','London,UK','Biosensor Technology'); CREATE TABLE funding_eu (id INT PRIMARY KEY,company_id INT,fund_type VARCHAR(255),amount INT,funding_date DATE); INSERT INTO funding_eu (id,company_id,fund_type,amount,funding_date) VALUES (1,1,'Venture Capital',12000000,'2021-06-30'); | SELECT c.name, f.fund_type, f.amount FROM company_eu c JOIN funding_eu f ON c.id = f.company_id WHERE c.industry = 'Biosensor Technology' AND c.location LIKE '%Europe%' AND f.funding_date >= '2020-01-01' AND f.amount > 10000000; |
What is the number of open positions by department? | CREATE TABLE jobs (id INT,department VARCHAR(50),position_name VARCHAR(50),open_position BOOLEAN); INSERT INTO jobs (id,department,position_name,open_position) VALUES (1,'HR','HR Manager',true),(2,'IT','Software Engineer',true),(3,'Marketing','Marketing Coordinator',false); | SELECT department, COUNT(*) FROM jobs WHERE open_position = true GROUP BY department; |
What is the minimum volume of timber produced in the last 10 years in the United States? | CREATE TABLE timber_production (id INT,volume REAL,year INT,country TEXT); INSERT INTO timber_production (id,volume,year,country) VALUES (1,12345.0,2012,'United States'),(2,67890.0,2015,'United States'); | SELECT MIN(volume) FROM timber_production WHERE country = 'United States' AND year BETWEEN 2012 AND 2021; |
What is the average number of doctor visits per year by age group? | CREATE TABLE doctor_visits (id INT,age_group VARCHAR(255),year INT,visits INT); INSERT INTO doctor_visits VALUES (1,'0-10',2020,3),(2,'11-20',2020,2),(3,'21-30',2020,1); | SELECT age_group, AVG(visits) AS avg_visits FROM doctor_visits GROUP BY age_group; |
What was the total number of volunteers and staff members in each department as of December 31, 2019? | CREATE TABLE OrganizationMembers (employee_id INT,department VARCHAR(20),role VARCHAR(20),date DATE); INSERT INTO OrganizationMembers (employee_id,department,role,date) VALUES (1,'Animal Care','Volunteer','2019-12-31'),(2,'Animal Care','Staff','2019-12-31'),(3,'Education','Volunteer','2019-12-31'),(4,'Education','Staff','2019-12-31'),(5,'Fundraising','Volunteer','2019-12-31'),(6,'Fundraising','Staff','2019-12-31'); | SELECT department, COUNT(*) FROM OrganizationMembers WHERE date = '2019-12-31' AND role = 'Volunteer' GROUP BY department; SELECT department, COUNT(*) FROM OrganizationMembers WHERE date = '2019-12-31' AND role = 'Staff' GROUP BY department; |
What is the average length (in seconds) of songs released in 2020 in the pop genre? | CREATE TABLE songs (song_id INT,title VARCHAR(255),release_year INT,genre VARCHAR(50),length FLOAT); INSERT INTO songs (song_id,title,release_year,genre,length) VALUES (1,'Song1',2020,'pop',180.5),(2,'Song2',2019,'rock',210.3),(3,'Song3',2020,'pop',205.7); | SELECT AVG(length) FROM songs WHERE release_year = 2020 AND genre = 'pop'; |
What is the total number of volunteers in the Volunteers table, excluding those who have not provided their age? | CREATE TABLE Volunteers (id INT,name VARCHAR(50),age INT,country VARCHAR(50)); INSERT INTO Volunteers (id,name,age,country) VALUES (1,'Alice',25,'USA'),(2,'Bob',NULL,'Canada'),(3,'Charlie',30,'Mexico'); | SELECT COUNT(*) FROM Volunteers WHERE age IS NOT NULL; |
List all deep-sea species discovered in the Southern Ocean since 2010. | CREATE TABLE deep_sea_species (species VARCHAR(255),ocean VARCHAR(255),year INT); INSERT INTO deep_sea_species (species,ocean,year) VALUES ('Foraminifera sp.','Southern Ocean',2012),('Hadal Snailfish','Southern Ocean',2014); | SELECT species FROM deep_sea_species WHERE ocean = 'Southern Ocean' AND year >= 2010; |
List the names of all owners who co-own a property in Brooklyn with a SustainabilityRating of at least 3. | CREATE TABLE CoOwnedProperties (PropertyID int,Price int,Borough varchar(255),SustainabilityRating int); CREATE TABLE Owners (PropertyID int,OwnerName varchar(255)); INSERT INTO CoOwnedProperties (PropertyID,Price,Borough,SustainabilityRating) VALUES (1,400000,'Brooklyn',3); INSERT INTO Owners (PropertyID,OwnerName) VALUES (1,'Jane Doe'); | SELECT o.OwnerName FROM CoOwnedProperties c INNER JOIN Owners o ON c.PropertyID = o.PropertyID WHERE c.Borough = 'Brooklyn' AND c.SustainabilityRating >= 3; |
Which South American countries have the highest number of eco-tourists? | CREATE TABLE south_american_countries (country VARCHAR(50),eco_tourists INT); INSERT INTO south_american_countries (country,eco_tourists) VALUES ('Brazil',500000),('Argentina',400000),('Colombia',350000),('Peru',450000),('Chile',300000); | SELECT country FROM south_american_countries ORDER BY eco_tourists DESC LIMIT 2; |
What is the maximum R&D expenditure for each drug in 2021? | CREATE TABLE rd_expenditure (drug varchar(255),year int,expenditure int); INSERT INTO rd_expenditure (drug,year,expenditure) VALUES ('DrugA',2021,8000000),('DrugB',2021,9000000); | SELECT drug, MAX(expenditure) FROM rd_expenditure WHERE year = 2021 GROUP BY drug; |
What are the total sales for each drug in the 'drugs' table, grouped by drug name, including drugs with no sales? | CREATE TABLE drugs (drug_id INT,drug_name TEXT,sales INT); INSERT INTO drugs (drug_id,drug_name,sales) VALUES (1,'DrugA',500),(2,'DrugB',750),(3,'DrugC',0); | SELECT d.drug_name, COALESCE(SUM(s.sales), 0) AS total_sales FROM drugs d LEFT JOIN sales s ON d.drug_id = s.drug_id GROUP BY d.drug_name; |
What is the number of patients who improved after therapy and medication, separated by gender? | CREATE TABLE patients (patient_id INT,name VARCHAR(50),gender VARCHAR(10),therapy_completed BOOLEAN,medication_completed BOOLEAN,therapy_outcome INT,medication_outcome INT); | SELECT gender, SUM(CASE WHEN therapy_outcome > 0 THEN 1 ELSE 0 END) AS improved_therapy, SUM(CASE WHEN medication_outcome > 0 THEN 1 ELSE 0 END) AS improved_medication FROM patients WHERE therapy_completed = TRUE AND medication_completed = TRUE GROUP BY gender; |
What is the average water temperature for tropical fish farms? | CREATE TABLE tropical_fish (id INT,name VARCHAR(50),water_temperature FLOAT); INSERT INTO tropical_fish (id,name,water_temperature) VALUES (1,'Clownfish',28.5),(2,'Angelfish',26.7),(3,'Surgeonfish',29.2); | SELECT AVG(water_temperature) FROM tropical_fish; |
What is the maximum donation amount per country, for countries that have received donations? | CREATE TABLE donations (id INT,country TEXT,amount DECIMAL(10,2)); INSERT INTO donations (id,country,amount) VALUES (1,'Country A',500.00),(2,'Country A',750.00),(3,'Country B',300.00),(4,'Country C',1000.00); | SELECT country, MAX(amount) FROM donations GROUP BY country; |
What is the average deep-sea pressure at 6000 meters in the Pacific Ocean? | CREATE TABLE deep_sea_pressure (depth INT,region VARCHAR(20),pressure INT); INSERT INTO deep_sea_pressure (depth,region,pressure) VALUES (6000,'Pacific Ocean',600); INSERT INTO deep_sea_pressure (depth,region,pressure) VALUES (6000,'Pacific Ocean',610); INSERT INTO deep_sea_pressure (depth,region,pressure) VALUES (6000,'Pacific Ocean',590); | SELECT AVG(pressure) FROM deep_sea_pressure WHERE depth = 6000 AND region = 'Pacific Ocean'; |
Delete the record for event_id 5001 | CREATE TABLE events (event_id INT PRIMARY KEY,event_name VARCHAR(100),event_location VARCHAR(100),start_time DATETIME,end_time DATETIME,attendance INT); | DELETE FROM events WHERE event_id = 5001; |
What is the highest scoring game in the 2022 FIFA World Cup? | CREATE TABLE fifa_scores (team_a TEXT,team_b TEXT,goals_a INT,goals_b INT); INSERT INTO fifa_scores (team_a,team_b,goals_a,goals_b) VALUES ('Brazil','Germany',1,7),('Spain','Netherlands',1,5),('Argentina','France',3,3); | SELECT team_a, team_b, MAX(goals_a + goals_b) as highest_score FROM fifa_scores; |
What are the names and fares of all the train routes that intersect with Route C in the NYC subway system? | CREATE TABLE train_routes (id INT,route_name VARCHAR(255),fare DECIMAL(5,2)); INSERT INTO train_routes (id,route_name,fare) VALUES (1,'Route A',2.75),(2,'Route B',3.50),(3,'Route C',2.25); CREATE TABLE route_intersections (id INT,route1 VARCHAR(255),route2 VARCHAR(255)); INSERT INTO route_intersections (id,route1,route2) VALUES (1,'Route A','Route C'),(2,'Route B','Route C'); | SELECT route_name, fare FROM train_routes TR JOIN route_intersections RI ON TR.route_name = RI.route1 WHERE RI.route2 = 'Route C'; |
How many electric vehicles were sold in China between 2018 and 2020? | CREATE TABLE sales (id INT,vehicle_id INT,sale_date DATE,quantity INT,vehicle_type VARCHAR(50)); INSERT INTO sales (id,vehicle_id,sale_date,quantity,vehicle_type) VALUES (1,1,'2018-01-01',5,'electric'); INSERT INTO sales (id,vehicle_id,sale_date,quantity,vehicle_type) VALUES (2,2,'2019-03-15',8,'hybrid'); INSERT INTO sales (id,vehicle_id,sale_date,quantity,vehicle_type) VALUES (3,3,'2020-08-22',12,'electric'); | SELECT SUM(quantity) FROM sales WHERE vehicle_type = 'electric' AND sale_date BETWEEN '2018-01-01' AND '2020-12-31'; |
Add a new record to the "CommunityProjects" table for a new project called 'Solar Street Lights' in the village of 'Koraro' | CREATE TABLE CommunityProjects (id INT PRIMARY KEY,project_name VARCHAR(255),location VARCHAR(255),status VARCHAR(255)); | INSERT INTO CommunityProjects (project_name, location, status) VALUES ('Solar Street Lights', 'Koraro', 'planning'); |
What is the total revenue for each game in the "Racing" category? | CREATE TABLE GameRevenue (GameID int,GameName varchar(50),Category varchar(50),Revenue decimal(10,2)); | SELECT Category, SUM(Revenue) OVER(PARTITION BY Category) as TotalRevenue FROM GameRevenue; |
What is the total waste generated in India in the year 2020? | CREATE TABLE WasteGeneration (country VARCHAR(50),year INT,waste_generated_kg FLOAT); | SELECT SUM(waste_generated_kg) FROM WasteGeneration WHERE country = 'India' AND year = 2020; |
What is the maximum number of blocks in a season by players from Europe who have played more than 50 games in a season? | CREATE TABLE season_stats (season_id INT,player_id INT,blocks INT); | SELECT MAX(blocks) FROM season_stats JOIN players ON season_stats.player_id = players.player_id WHERE players.country = 'Europe' GROUP BY players.country HAVING games_played > 50; |
What are the decentralized applications with their corresponding regulatory frameworks, ranked by framework ID in ascending order? | CREATE TABLE decentralized_applications (app_id INT,app_name VARCHAR(50)); INSERT INTO decentralized_applications (app_id,app_name) VALUES (1,'Ethereum'); INSERT INTO decentralized_applications (app_id,app_name) VALUES (2,'Cardano'); CREATE TABLE regulatory_frameworks (framework_id INT,framework_name VARCHAR(50),app_id INT); INSERT INTO regulatory_frameworks (framework_id,framework_name,app_id) VALUES (1,'MiCA',1); INSERT INTO regulatory_frameworks (framework_id,framework_name,app_id) VALUES (2,'TFR',2); INSERT INTO regulatory_frameworks (framework_id,framework_name,app_id) VALUES (3,'DAR',2); | SELECT da.app_name, rf.framework_name, rf.framework_id, ROW_NUMBER() OVER (PARTITION BY da.app_name ORDER BY rf.framework_id ASC) as rank FROM regulatory_frameworks rf JOIN decentralized_applications da ON rf.app_id = da.app_id ORDER BY da.app_name; |
What is the number of students enrolled in each district, grouped by district and ordered by the number of students in descending order? | CREATE TABLE school_districts (district_id INT,district_name TEXT); CREATE TABLE students (student_id INT,district_id INT,num_courses INT); | SELECT sd.district_name, COUNT(s.student_id) as num_students FROM students s JOIN school_districts sd ON s.district_id = sd.district_id GROUP BY sd.district_name ORDER BY num_students DESC; |
What is the average yield of crops for each farm type, ranked by the highest average yield? | CREATE TABLE Farm (FarmID int,FarmType varchar(20),Yield int); INSERT INTO Farm (FarmID,FarmType,Yield) VALUES (1,'Organic',150),(2,'Conventional',200),(3,'Urban',100); | SELECT FarmType, AVG(Yield) as AvgYield FROM Farm GROUP BY FarmType ORDER BY AvgYield DESC; |
List all cybersecurity strategies and their implementation dates in the Middle East, ordered by the implementation date in descending order. | CREATE TABLE cybersecurity_strategies (id INT,strategy_name VARCHAR(255),implementation_date DATE,region VARCHAR(255)); INSERT INTO cybersecurity_strategies (id,strategy_name,implementation_date,region) VALUES (1,'Strategy 1','2019-01-01','Middle East'),(2,'Strategy 2','2018-05-15','Middle East'); | SELECT * FROM cybersecurity_strategies WHERE region = 'Middle East' ORDER BY implementation_date DESC; |
What is the total cargo capacity (in weight) for each port, including the types of ships docked at that port? | CREATE TABLE port (id INT PRIMARY KEY,name VARCHAR(50),location VARCHAR(50),capacity INT); INSERT INTO port VALUES (1,'New York','USA',5000); INSERT INTO port VALUES (2,'Los Angeles','USA',4000); CREATE TABLE ship (id INT PRIMARY KEY,name VARCHAR(50),type VARCHAR(50),length INT,port_id INT,FOREIGN KEY (port_id) REFERENCES port(id)); INSERT INTO ship VALUES (1,'Sea Giant','Container',300,1); INSERT INTO ship VALUES (2,'Ocean Titan','Tanker',400,2); CREATE TABLE cargo (id INT PRIMARY KEY,ship_id INT,weight INT,FOREIGN KEY (ship_id) REFERENCES ship(id)); INSERT INTO cargo VALUES (1,1,1000); INSERT INTO cargo VALUES (2,2,2000); | SELECT p.name as port_name, s.type as ship_type, SUM(c.weight) as total_weight FROM cargo c JOIN ship s ON c.ship_id = s.id JOIN port p ON s.port_id = p.id GROUP BY p.name, s.type; |
How many cruelty-free skincare products were sold in Italy between 2017 and 2020? | CREATE TABLE SkincareProducts(productId INT,productName VARCHAR(100),isCrueltyFree BOOLEAN,saleYear INT,country VARCHAR(50)); INSERT INTO SkincareProducts(productId,productName,isCrueltyFree,saleYear,country) VALUES (1,'Green Tea Toner',true,2017,'Italy'),(2,'Cocoa Butter Moisturizer',false,2018,'Italy'); | SELECT COUNT(*) FROM SkincareProducts WHERE isCrueltyFree = true AND saleYear BETWEEN 2017 AND 2020 AND country = 'Italy'; |
What are the top 5 electric vehicles by battery range in the Auto_Sales table? | CREATE TABLE Auto_Sales (Vehicle_Type VARCHAR(20),Model VARCHAR(20),Battery_Range INT); | SELECT Vehicle_Type, Model, Battery_Range FROM Auto_Sales WHERE Vehicle_Type = 'Electric' ORDER BY Battery_Range DESC LIMIT 5; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.