instruction stringlengths 0 1.06k | input stringlengths 11 5.3k | response stringlengths 2 4.44k |
|---|---|---|
Update the win rate of teams in game B by dividing the number of wins by the sum of wins and losses. | CREATE TABLE Teams (TeamID INT,Game VARCHAR(50),Name VARCHAR(50),Wins INT,Losses INT); INSERT INTO Teams (TeamID,Game,Name,Wins,Losses) VALUES (1,'GameA','TeamA',10,5); INSERT INTO Teams (TeamID,Game,Name,Wins,Losses) VALUES (2,'GameB','TeamC',15,3); INSERT INTO Teams (TeamID,Game,Name,Wins,Losses) VALUES (3,'GameB','TeamD',5,8); | UPDATE Teams SET WinRate = (Wins / (Wins + Losses)) WHERE Game = 'GameB'; |
How many unique donors have donated to each organization? | CREATE TABLE donor_donation (donor_id INT,org_id INT,donation_id INT); INSERT INTO donor_donation (donor_id,org_id,donation_id) VALUES (1,1,1),(2,1,2),(3,2,3),(4,3,4),(5,4,5); | SELECT org_id, COUNT(DISTINCT donor_id) as unique_donors FROM donor_donation GROUP BY org_id; |
What is the total weight of items in the inventory that are both Kosher and vegan? | CREATE TABLE Inventory(item_id INT,item_name VARCHAR(50),is_kosher BOOLEAN,is_vegan BOOLEAN,weight DECIMAL(5,2)); INSERT INTO Inventory VALUES(1,'Tofu',TRUE,TRUE,0.5),(2,'Seitan',TRUE,TRUE,1.0),(3,'TV Dinner',FALSE,FALSE,0.3); | SELECT SUM(weight) FROM Inventory WHERE is_kosher = TRUE AND is_vegan = TRUE; |
Show veteran unemployment rates by state? | CREATE TABLE Veteran_Employment (id INT,state VARCHAR(50),unemployment_rate FLOAT); INSERT INTO Veteran_Employment (id,state,unemployment_rate) VALUES (1,'California',3.5),(2,'Texas',4.0); | SELECT Veteran_Employment.state, Veteran_Employment.unemployment_rate FROM Veteran_Employment ORDER BY Veteran_Employment.unemployment_rate; |
What is the total revenue generated from cosmetic products that are fair trade certified? | CREATE TABLE cosmetics (product_id INT,product_name VARCHAR(50),is_fair_trade BOOLEAN,revenue FLOAT); | SELECT SUM(revenue) FROM cosmetics WHERE is_fair_trade = TRUE; |
Delete a marine species from the 'marine_species' table | CREATE TABLE marine_species (id INT PRIMARY KEY,species_name VARCHAR(255),conservation_status VARCHAR(255)); INSERT INTO marine_species (id,species_name,conservation_status) VALUES (1001,'Oceanic Whitetip Shark','Vulnerable'),(1002,'Green Sea Turtle','Threatened'),(1003,'Leatherback Sea Turtle','Vulnerable'); | DELETE FROM marine_species WHERE species_name = 'Oceanic Whitetip Shark'; |
How many products does each supplier supply? | CREATE TABLE products (product_id INT,product_name VARCHAR(50),supplier_id INT); CREATE TABLE suppliers (supplier_id INT,supplier_name VARCHAR(50)); INSERT INTO products (product_id,product_name,supplier_id) VALUES (1,'T-Shirt',1),(2,'Jeans',2),(3,'Shoes',3),(4,'Dress',1),(5,'Bag',2); INSERT INTO suppliers (supplier_id,supplier_name) VALUES (1,'GreenEarth'),(2,'EcoBlue'),(3,'CircularWear'); | SELECT suppliers.supplier_name, COUNT(products.product_id) FROM suppliers LEFT JOIN products ON suppliers.supplier_id = products.supplier_id GROUP BY suppliers.supplier_name; |
What is the average age of visitors who attended exhibitions in 'Mumbai'? | CREATE TABLE Exhibitions (exhibition_id INT,city VARCHAR(20),country VARCHAR(20)); INSERT INTO Exhibitions (exhibition_id,city,country) VALUES (1,'Mumbai','India'),(2,'Delhi','India'),(3,'Bangalore','India'); CREATE TABLE Visitors (visitor_id INT,exhibition_id INT,age INT); INSERT INTO Visitors (visitor_id,exhibition_id,age) VALUES (1,1,25),(2,1,28),(3,2,15),(4,2,18),(5,3,35),(6,3,40); | SELECT AVG(age) FROM Visitors v JOIN Exhibitions e ON v.exhibition_id = e.exhibition_id WHERE e.city = 'Mumbai'; |
What is the average donation amount by new members in Q2 2022? | CREATE TABLE Members (MemberID INT,JoinDate DATE,Region VARCHAR(50)); INSERT INTO Members (MemberID,JoinDate,Region) VALUES (1,'2022-04-01','Northeast'),(2,'2022-05-14','Southeast'),(3,'2022-06-03','Northeast'); CREATE TABLE Donations (DonationID INT,MemberID INT,DonationDate DATE,Amount DECIMAL(10,2)); INSERT INTO Donations (DonationID,MemberID,DonationDate,Amount) VALUES (1,1,'2022-04-05',50.00),(2,2,'2022-05-15',100.00),(3,3,'2022-06-07',25.00); | SELECT AVG(Amount) FROM Donations INNER JOIN Members ON Donations.MemberID = Members.MemberID WHERE YEAR(DonationDate) = 2022 AND Members.MemberID NOT IN (SELECT Members.MemberID FROM Members GROUP BY Members.MemberID HAVING COUNT(Members.MemberID) < 2) AND QUARTER(DonationDate) = 2; |
What is the average number of community development initiatives in Africa, grouped by country? | CREATE TABLE Country (ID INT,Name VARCHAR(50),Continent VARCHAR(50)); INSERT INTO Country (ID,Name,Continent) VALUES (1,'Nigeria','Africa'),(2,'Kenya','Africa'); CREATE TABLE CommunityInitiatives (ID INT,CountryID INT,Initiative VARCHAR(50)); INSERT INTO CommunityInitiatives (ID,CountryID,Initiative) VALUES (1,1,'Library'),(2,1,'Playground'),(3,2,'Health Center'); | SELECT c.Name, AVG(CI.Initiative) as AvgInitiativesPerCountry FROM Country c JOIN CommunityInitiatives CI ON c.ID = CI.CountryID WHERE c.Continent = 'Africa' GROUP BY c.Name; |
How many sustainable tourism initiatives are in Canada? | CREATE TABLE initiatives (id INT,name TEXT,type TEXT,country TEXT); INSERT INTO initiatives (id,name,type,country) VALUES (1,'Sustainable Tourism in the Rockies','Sustainable Tourism','Canada'),(2,'Eco-Friendly Whale Watching in British Columbia','Sustainable Tourism','Canada'),(3,'Historic Sites of Quebec City','Cultural Heritage','Canada'); | SELECT COUNT(*) FROM initiatives WHERE type = 'Sustainable Tourism' AND country = 'Canada'; |
List all unique AI safety research topics addressed before 2018. | CREATE TABLE AI_Safety_Topics (id INT,topic TEXT,published_date DATE); INSERT INTO AI_Safety_Topics (id,topic,published_date) VALUES (1,'Topic1','2017-01-01'),(2,'Topic2','2018-05-15'),(3,'Topic3','2016-03-20'),(4,'Topic4','2018-12-31'); | SELECT DISTINCT topic FROM AI_Safety_Topics WHERE published_date < '2018-01-01'; |
What is the average investment in climate change mitigation projects in North America? | CREATE TABLE investments (id INT,country VARCHAR(50),sector VARCHAR(50),amount FLOAT); INSERT INTO investments (id,country,sector,amount) VALUES (1,'Canada','Climate Change',500000),(2,'Mexico','Renewable Energy',750000),(3,'Canada','Climate Change',600000); | SELECT AVG(amount) as avg_investment FROM investments WHERE sector = 'Climate Change' AND country IN (SELECT country FROM (SELECT * FROM countries WHERE region = 'North America') as north_america); |
How many male patients are in the 'rural_hospital' table? | CREATE TABLE rural_hospital (patient_id INT,age INT,gender VARCHAR(10)); INSERT INTO rural_hospital (patient_id,age,gender) VALUES (1,35,'Male'),(2,50,'Female'),(3,42,'Male'),(4,60,'Male'),(5,30,'Female'); | SELECT COUNT(*) FROM rural_hospital WHERE gender = 'Male'; |
Insert new 'Sativa' strain 'Green Crack' with price $15 per gram into 'Green Earth' dispensary. | CREATE TABLE strains (strain_id INT,name VARCHAR(255),type VARCHAR(255),price FLOAT); INSERT INTO strains (strain_id,name,type,price) VALUES (10,'Green Crack','Sativa',NULL); CREATE TABLE dispensaries (dispensary_id INT,name VARCHAR(255)); INSERT INTO dispensaries (dispensary_id,name) VALUES (2,'Green Earth'); CREATE TABLE inventory (inventory_id INT,strain_id INT,dispensary_id INT,price FLOAT,quantity INT); | INSERT INTO inventory (inventory_id, strain_id, dispensary_id, price, quantity) SELECT NULL, (SELECT strain_id FROM strains WHERE name = 'Green Crack' AND type = 'Sativa'), (SELECT dispensary_id FROM dispensaries WHERE name = 'Green Earth'), 15, 25; |
List all TV shows produced in Mexico or created by Mexican producers, along with their production budget and premiere date. | CREATE TABLE tv_shows (tv_show_id INT,title VARCHAR(50),production_country VARCHAR(50),premiere_date DATE,production_budget INT); INSERT INTO tv_shows (tv_show_id,title,production_country,premiere_date,production_budget) VALUES (1,'TV Show1','Mexico','2020-01-01',10000000),(2,'TV Show2','Brazil','2019-12-25',12000000),(3,'TV Show3','Mexico','2018-05-15',9000000); CREATE TABLE producers (producer_id INT,name VARCHAR(50),nationality VARCHAR(50)); INSERT INTO producers (producer_id,name,nationality) VALUES (1,'Producer1','Mexico'),(2,'Producer2','Brazil'),(3,'Producer3','Mexico'); | SELECT tv_shows.title, tv_shows.production_country, tv_shows.premiere_date, tv_shows.production_budget FROM tv_shows INNER JOIN producers ON (tv_shows.production_country = 'Mexico' OR producers.nationality = 'Mexico'); |
List all suppliers and their associated eco-labels in 'GreenGrocers'? | CREATE TABLE GreenGrocers (supplier_id INT,supplier_name VARCHAR(50)); CREATE TABLE SupplierEcoLabels (supplier_id INT,eco_label VARCHAR(50)); INSERT INTO GreenGrocers (supplier_id,supplier_name) VALUES (1,'EcoFarm'),(2,'GreenFields'),(3,'NatureVille'); INSERT INTO SupplierEcoLabels (supplier_id,eco_label) VALUES (1,'Certified Organic'),(1,'Non-GMO'),(2,'Fair Trade'),(3,'Regenerative Agriculture'); | SELECT g.supplier_name, e.eco_label FROM GreenGrocers g INNER JOIN SupplierEcoLabels e ON g.supplier_id = e.supplier_id; |
What is the maximum Shariah-compliant finance asset value in the Gulf Cooperation Council (GCC) countries? | CREATE TABLE shariah_compliant_finance (id INT,country VARCHAR(255),asset_value DECIMAL(10,2)); | SELECT MAX(asset_value) FROM shariah_compliant_finance WHERE country IN (SELECT country FROM (SELECT DISTINCT country FROM shariah_compliant_finance WHERE region = 'Gulf Cooperation Council') t); |
Insert new user with privacy settings | CREATE TABLE users (id INT,name VARCHAR(50),join_date DATE,total_likes INT); CREATE TABLE privacy_settings (id INT,user_id INT,allow_notifications BOOLEAN,allow_messages BOOLEAN,allow_location BOOLEAN); | INSERT INTO users (id, name, join_date, total_likes) VALUES (3, 'Charlie', '2021-03-03', 200); INSERT INTO privacy_settings (id, user_id, allow_notifications, allow_messages, allow_location) VALUES (3, 3, false, true, false); |
What is the average number of citizens' complaints received by each city council in the 'Urban' region? | CREATE SCHEMA Government;CREATE TABLE Government.Region (name VARCHAR(255),budget INT);CREATE TABLE Government.City (name VARCHAR(255),region VARCHAR(255),complaints INT); | SELECT region, AVG(complaints) FROM Government.City WHERE region = 'Urban' GROUP BY region; |
List the case types and the number of cases, excluding cases with a billing amount between $5000 and $10000. | CREATE TABLE cases (id INT,case_type VARCHAR(20),billing_amount INT); INSERT INTO cases (id,case_type,billing_amount) VALUES (1,'Civil',5000),(2,'Criminal',7000),(3,'Civil',6000),(4,'Civil',15000),(5,'Civil',3000),(6,'Criminal',8000); | SELECT case_type, COUNT(*) AS num_cases FROM cases WHERE billing_amount < 5000 OR billing_amount > 10000 GROUP BY case_type; |
How many 'youth' passengers traveled on 'monorail' routes in August 2022? | CREATE TABLE public.trips (trip_id SERIAL PRIMARY KEY,passenger_type VARCHAR(20),fare DECIMAL(5,2),route_type_id INTEGER,FOREIGN KEY (route_type_id) REFERENCES public.route_type(route_type_id)); INSERT INTO public.trips (passenger_type,fare,route_type_id) VALUES ('youth',2.00,5),('adult',3.00,1),('youth',2.00,2); | SELECT COUNT(*) FROM public.trips WHERE passenger_type = 'youth' AND route_type_id = (SELECT route_type_id FROM public.route_type WHERE route_type = 'monorail') AND fare_date >= '2022-08-01' AND fare_date <= '2022-08-31' |
Update the coverage amount to 100000 for policy number 1. | CREATE TABLE policy (policy_number INT,coverage_amount INT); INSERT INTO policy VALUES (1,50000); INSERT INTO policy VALUES (2,75000); | UPDATE policy SET coverage_amount = 100000 WHERE policy_number = 1; |
List the number of military equipment maintenance requests for each type of equipment in January 2020 | CREATE TABLE maintenance_requests (request_id INT,equipment_type VARCHAR(255),date DATE); INSERT INTO maintenance_requests (request_id,equipment_type,date) VALUES (1,'Tank','2020-01-05'),(2,'Helicopter','2020-01-10'),(3,'Tank','2020-01-15'); | SELECT equipment_type, COUNT(*) FROM maintenance_requests WHERE date BETWEEN '2020-01-01' AND '2020-01-31' GROUP BY equipment_type; |
What is the total timber production of all forests in the 'Asia-Pacific' region? | CREATE TABLE forests (id INT,name TEXT,area FLOAT,region TEXT,timber_production FLOAT); INSERT INTO forests (id,name,area,region,timber_production) VALUES (1,'Sundarbans',10000.0,'Asia-Pacific',12345.6),(2,'Great Barrier Reef',34000.0,'Asia-Pacific',67890.1); | SELECT SUM(timber_production) FROM forests WHERE region = 'Asia-Pacific'; |
What is the total production budget for movies released in 2010? | CREATE TABLE Movies (movie_id INT,title TEXT,release_year INT,production_budget FLOAT); INSERT INTO Movies (movie_id,title,release_year,production_budget) VALUES (1,'MovieA',2005,60.0),(2,'MovieB',2012,40.0),(3,'MovieC',2018,70.0),(4,'MovieD',2008,55.0),(5,'MovieE',2010,80.0),(6,'MovieF',2015,45.0); | SELECT SUM(production_budget) FROM Movies WHERE release_year = 2010; |
Display the number of workers in each country who have completed workforce development training in the circular economy, along with the names of those countries. | CREATE TABLE countries (id INT,country VARCHAR(50)); CREATE TABLE workers (id INT,name VARCHAR(50),country VARCHAR(50),training VARCHAR(50)); INSERT INTO countries (id,country) VALUES (1,'USA'),(2,'China'),(3,'Germany'),(4,'Mexico'); INSERT INTO workers (id,name,country,training) VALUES (1,'Tom','USA','Composting'),(2,'Jin','China','Recycling'),(3,'Heidi','Germany','Upcycling'),(4,'Pedro','Mexico','Waste Reduction'),(5,'Anna','USA','Recycling'),(6,'Li','China','Composting'),(7,'Karl','Germany','Waste Reduction'),(8,'Carlos','Mexico','Upcycling'); | SELECT w.country, COUNT(*) as count FROM workers w INNER JOIN countries c ON w.country = c.country INNER JOIN circular_economy ce ON w.training = ce.training GROUP BY w.country; |
What is the total budget allocated for the 'Transportation' department in the year 2022? | CREATE TABLE Department (id INT,name VARCHAR(255),budget FLOAT); INSERT INTO Department (id,name,budget) VALUES (1,'Education',5000000),(2,'Healthcare',7000000),(3,'Transportation',8000000); | SELECT SUM(budget) FROM Department WHERE name = 'Transportation' AND YEAR(datetime) = 2022; |
List the top 5 diseases by prevalence in rural areas of India and Pakistan. | CREATE TABLE diseases (name TEXT,location TEXT,prevalence INTEGER); INSERT INTO diseases (name,location,prevalence) VALUES ('Disease A','Rural India',50),('Disease B','Rural India',40),('Disease C','Rural India',30),('Disease D','Rural India',20),('Disease E','Rural India',10),('Disease A','Rural Pakistan',40),('Disease B','Rural Pakistan',30),('Disease C','Rural Pakistan',20),('Disease D','Rural Pakistan',10); | SELECT name, SUM(prevalence) AS total_prevalence FROM diseases WHERE location IN ('Rural India', 'Rural Pakistan') GROUP BY name ORDER BY total_prevalence DESC LIMIT 5; |
What is the total amount of funding received by each literary arts program in Canada in 2021? | CREATE TABLE funding (id INT,program VARCHAR(50),country VARCHAR(50),year INT,amount INT); INSERT INTO funding (id,program,country,year,amount) VALUES (1,'Literary Arts Program 1','Canada',2021,15000),(2,'Literary Arts Program 2','Canada',2021,20000); | SELECT program, SUM(amount) AS total_amount FROM funding WHERE country = 'Canada' AND year = 2021 GROUP BY program; |
List all support programs with their respective budgets, in alphabetical order. | CREATE TABLE SupportPrograms (ProgramID INT,ProgramName VARCHAR(50),Budget DECIMAL(10,2)); INSERT INTO SupportPrograms (ProgramID,ProgramName,Budget) VALUES (1,'Art Therapy',15000),(2,'Braille Literacy',18000),(3,'Communication Assistance',22000),(4,'Dietary Accommodations',14000),(5,'Hearing Loops',20000),(6,'Inclusive Fitness',25000),(7,'Low Vision Services',19000); | SELECT ProgramName, Budget FROM SupportPrograms ORDER BY ProgramName ASC; |
What is the maximum flight time of a SpaceX mission? | CREATE TABLE SpaceX_Missions (Id INT,Name VARCHAR(50),FlightTime INT); INSERT INTO SpaceX_Missions (Id,Name,FlightTime) VALUES (1,'Falcon1',280),(2,'Falcon9',540),(3,'FalconHeavy',1000); | SELECT MAX(FlightTime) FROM SpaceX_Missions WHERE Name = 'Falcon9'; |
What is the number of solar power plants in the state of New York? | CREATE TABLE power_plants (plant_id INT,state VARCHAR(255),power_source VARCHAR(255)); INSERT INTO power_plants (plant_id,state,power_source) VALUES (1,'CA','Hydro'),(2,'CA','Wind'),(3,'CA','Solar'),(4,'TX','Hydro'),(5,'TX','Wind'),(6,'TX','Solar'),(7,'NY','Hydro'),(8,'NY','Wind'),(9,'NY','Solar'),(10,'NY','Hydro'),(11,'NY','Wind'),(12,'NY','Solar'); | SELECT COUNT(*) FROM power_plants WHERE state = 'NY' AND power_source = 'Solar'; |
What is the most common type of violation, in the last month? | CREATE TABLE violations (violation_id INT,violation_type VARCHAR(20),violation_date DATE); INSERT INTO violations (violation_id,violation_type,violation_date) VALUES (1,'Speeding','2022-01-15'),(2,'Parking','2022-01-17'),(3,'Speeding','2022-01-18'); | SELECT violation_type, COUNT(*) as num_occurrences FROM (SELECT violation_type, ROW_NUMBER() OVER (PARTITION BY violation_type ORDER BY violation_date DESC) as rn FROM violations WHERE violation_date >= DATEADD(month, -1, GETDATE())) x WHERE rn = 1 GROUP BY violation_type; |
Update the age of archaeologist 'John Doe' in the 'archaeologists' table to 35. | CREATE TABLE archaeologists (id INT,name VARCHAR(50),age INT,gender VARCHAR(10),country VARCHAR(50)); | UPDATE archaeologists SET age = 35 WHERE name = 'John Doe'; |
Delete all records with a calorie count greater than 500 from the FoodSafetyRecords.HealthyMeals table. | CREATE TABLE FoodSafetyRecords.HealthyMeals (mealName TEXT,calorieCount INTEGER); | DELETE FROM FoodSafetyRecords.HealthyMeals WHERE calorieCount > 500; |
What is the average shipping cost for all shipments that were sent by rail from France to Germany? | CREATE TABLE Shipments(id INT,mode VARCHAR(50),source VARCHAR(50),destination VARCHAR(50),shipping_cost FLOAT); INSERT INTO Shipments(id,mode,source,destination,shipping_cost) VALUES (1,'rail','France','Germany',500); | SELECT AVG(Shipments.shipping_cost) FROM Shipments WHERE Shipments.mode = 'rail' AND Shipments.source = 'France' AND Shipments.destination = 'Germany'; |
How many traditional dances from Asia have been documented and preserved since 2010? | CREATE TABLE DancePreservation (id INT,dance VARCHAR(50),continent VARCHAR(50),year INT); INSERT INTO DancePreservation (id,dance,continent,year) VALUES (1,'Bharatanatyam','Asia',2012),(2,'Odissi','Asia',2011),(3,'Kathak','Asia',2013),(4,'Mohiniyattam','Asia',2010),(5,'Kuchipudi','Asia',2011); | SELECT COUNT(*) FROM DancePreservation WHERE continent = 'Asia' AND year >= 2010; |
List all graduate students from India who have received research grants. | CREATE TABLE graduate_students (id INT,name VARCHAR(50),country VARCHAR(50)); INSERT INTO graduate_students (id,name,country) VALUES (1,'John Doe','USA'),(2,'Jane Smith','Canada'),(3,'Ravi Patel','India'),(4,'Sana Khan','Pakistan'); CREATE TABLE research_grants (id INT,student_id INT,amount DECIMAL(10,2)); INSERT INTO research_grants (id,student_id,amount) VALUES (1,1,5000),(2,3,7000),(3,2,3000),(5,3,4000); | SELECT gs.* FROM graduate_students gs INNER JOIN research_grants rg ON gs.id = rg.student_id WHERE gs.country = 'India'; |
How many energy efficiency programs were initiated in South America in 2019? | CREATE TABLE if not exists energy_efficiency_programs (program_id integer,program_start_date date,program_location varchar(255)); INSERT INTO energy_efficiency_programs (program_id,program_start_date,program_location) VALUES (1,'2019-01-01','Brazil'),(2,'2019-06-01','Argentina'),(3,'2019-12-31','Colombia'); | SELECT program_location, COUNT(*) as num_programs FROM energy_efficiency_programs WHERE program_start_date BETWEEN '2019-01-01' AND '2019-12-31' AND program_location LIKE 'South America%' GROUP BY program_location; |
What is the average age of all trees in the 'young_trees' table? | CREATE TABLE young_trees (id INT,species VARCHAR(255),age INT); INSERT INTO young_trees (id,species,age) VALUES (1,'Oak',10),(2,'Maple',8),(3,'Pine',12); | SELECT AVG(age) FROM young_trees; |
What is the total number of cultural heritage tours in France that were added to the database in the last month? | CREATE TABLE cult_tours (tour_id INT,tour_name TEXT,country TEXT,added_date DATE); INSERT INTO cult_tours (tour_id,tour_name,country,added_date) VALUES (1,'Eiffel Tower Tour','France','2022-06-15'); INSERT INTO cult_tours (tour_id,tour_name,country,added_date) VALUES (2,'Louvre Tour','France','2022-07-20'); INSERT INTO cult_tours (tour_id,tour_name,country,added_date) VALUES (3,'Mont Saint-Michel Tour','France','2022-08-02'); | SELECT COUNT(*) FROM cult_tours WHERE country = 'France' AND added_date >= '2022-07-01'; |
What is the total number of maintenance tasks performed on each vehicle, by vehicle type? | CREATE TABLE vehicles (vehicle_id INT,vehicle_type TEXT); CREATE TABLE maintenance (maintenance_id INT,vehicle_id INT,maintenance_date DATE,maintenance_type TEXT); | SELECT v.vehicle_type, v.vehicle_id, COUNT(m.maintenance_id) as total_maintenance_tasks FROM vehicles v INNER JOIN maintenance m ON v.vehicle_id = m.vehicle_id GROUP BY v.vehicle_type, v.vehicle_id; |
Which renewable energy sources have been installed in Africa with a capacity greater than 150 MW? | CREATE TABLE africa_renewable (id INT,source VARCHAR(50),capacity FLOAT); INSERT INTO africa_renewable (id,source,capacity) VALUES (1,'Wind',200.5),(2,'Solar',300.2),(3,'Hydro',150.1),(4,'Geothermal',100.3); | SELECT DISTINCT source FROM africa_renewable WHERE capacity > 150; |
What is the total donation for each program in the 'ProgramDonations' table? | CREATE TABLE Programs (ProgramID int,ProgramName varchar(50)); CREATE TABLE Donations (DonationID int,Donation decimal(10,2)); CREATE TABLE ProgramDonations (ProgramID int,DonationID int,ProgramName varchar(50),Donation decimal(10,2)); INSERT INTO Programs (ProgramID,ProgramName) VALUES (1,'Education'),(2,'Health'),(3,'Environment'); INSERT INTO Donations (DonationID,Donation) VALUES (1,1000.00),(2,1500.00),(3,750.00); INSERT INTO ProgramDonations (ProgramID,DonationID,ProgramName,Donation) VALUES (1,1,'Education',1000.00),(2,2,'Health',1500.00),(3,3,'Environment',750.00); | SELECT ProgramName, SUM(Donation) as TotalDonated FROM ProgramDonations GROUP BY ProgramName; |
Count the number of dishes in each category | CREATE TABLE menu (dish_name TEXT,category TEXT,price DECIMAL); INSERT INTO menu VALUES ('Cheese Quesadilla','Mexican',6.99),('Beef Burrito','Mexican',8.99),('Chicken Shawarma','Middle Eastern',9.99); | SELECT category, COUNT(*) FROM menu GROUP BY category; |
Get the total salary paid to employees in each department, ordered by the total salary. | CREATE TABLE Employees (EmployeeID INT,Salary DECIMAL(10,2),Department VARCHAR(50)); INSERT INTO Employees (EmployeeID,Salary,Department) VALUES (1,50000,'HR'),(2,55000,'IT'),(3,60000,'IT'),(4,45000,'HR'),(5,70000,'HR'); | SELECT Department, SUM(Salary) FROM Employees GROUP BY Department ORDER BY SUM(Salary) DESC; |
Delete fare information for rider 'Aaliyah Brown' | CREATE TABLE riders (rider_id INT,name VARCHAR(255)); INSERT INTO riders (rider_id,name) VALUES (1,'John Smith'),(2,'Jane Doe'),(3,'Aaliyah Brown'); CREATE TABLE fares (fare_id INT,rider_id INT,fare_amount DECIMAL(5,2)); | DELETE FROM fares WHERE rider_id = (SELECT rider_id FROM riders WHERE name = 'Aaliyah Brown'); |
What is the total number of digital assets owned by companies based in Africa as of 2022-01-01? | CREATE TABLE Companies (id INT,name VARCHAR(255),region VARCHAR(255)); CREATE TABLE DigitalAssets (id INT,company_id INT,value DECIMAL(10,2),asset_date DATE); INSERT INTO Companies (id,name,region) VALUES (1,'CompanyA','Africa'),(2,'CompanyB','Europe'),(3,'CompanyC','Africa'); INSERT INTO DigitalAssets (id,company_id,value,asset_date) VALUES (1,1,100,'2022-01-01'),(2,1,200,'2022-01-02'),(3,2,50,'2022-01-01'),(4,3,250,'2022-01-01'); | SELECT SUM(value) FROM DigitalAssets JOIN Companies ON DigitalAssets.company_id = Companies.id WHERE Companies.region = 'Africa' AND DigitalAssets.asset_date <= '2022-01-01'; |
Show the total revenue generated from sales of recycled products in Australia. | CREATE TABLE products (product_id INT,name VARCHAR(100),price DECIMAL(5,2),is_recycled BOOLEAN); INSERT INTO products (product_id,name,price,is_recycled) VALUES (1,'Recycled Notebook',9.99,true); INSERT INTO products (product_id,name,price,is_recycled) VALUES (2,'Eco-Friendly Pen',3.99,true); CREATE TABLE sales (sale_id INT,product_id INT,quantity INT); CREATE TABLE stores (store_id INT,location VARCHAR(50)); INSERT INTO stores (store_id,location) VALUES (1,'Sydney Store'); INSERT INTO stores (store_id,location) VALUES (2,'Melbourne Store'); CREATE TABLE store_sales (store_id INT,sale_id INT); | SELECT SUM(p.price * s.quantity) FROM products p JOIN sales s ON p.product_id = s.product_id JOIN store_sales ss ON s.sale_id = ss.sale_id JOIN stores st ON ss.store_id = st.store_id WHERE p.is_recycled = true AND st.location = 'Australia'; |
How many indigenous communities are there in each country? | CREATE TABLE communities (community_id INT,country VARCHAR(255)); | SELECT country, COUNT(*) FROM communities GROUP BY country; |
Add a new column 'payment_method' to table 'hotel_reservations' | CREATE TABLE hotel_reservations (reservation_id INT,hotel_id INT,guest_name TEXT,arrival_date DATE,departure_date DATE,num_guests INT,payment_amount FLOAT,is_cancelled BOOLEAN); | ALTER TABLE hotel_reservations ADD COLUMN payment_method TEXT; |
Identify the top 3 countries with the highest total investment amounts. | CREATE TABLE investments (id INT,investor_id INT,country TEXT,amount FLOAT); INSERT INTO investments (id,investor_id,country,amount) VALUES (1,1,'USA',10000),(2,1,'Canada',5000),(3,2,'Mexico',8000),(4,2,'USA',12000),(5,3,'Canada',7000),(6,3,'USA',15000); | SELECT country, SUM(amount) as total_investment FROM investments GROUP BY country ORDER BY total_investment DESC LIMIT 3; |
What is the total revenue generated by each OTA (Online Travel Agency) for a given hotel? | CREATE TABLE hotels (hotel_id INT,hotel_name TEXT,country TEXT);CREATE TABLE ota_bookings (booking_id INT,hotel_id INT,ota_name TEXT,revenue FLOAT); INSERT INTO hotels (hotel_id,hotel_name,country) VALUES (1,'Hotel X','USA'); INSERT INTO ota_bookings (booking_id,hotel_id,ota_name,revenue) VALUES (1,1,'OTA1',500),(2,1,'OTA2',700),(3,1,'OTA3',300); | SELECT ota.ota_name, SUM(ob.revenue) as total_revenue FROM hotels h INNER JOIN ota_bookings ob ON h.hotel_id = ob.hotel_id INNER JOIN (SELECT DISTINCT hotel_id, ota_name FROM ota_bookings) ota ON h.hotel_id = ota.hotel_id WHERE h.hotel_id = 1 GROUP BY ota.ota_name; |
Insert new record into ai_ethics table for 'Tegnbit' with 'Machine Learning' method in 2021 | CREATE TABLE ai_ethics (tool VARCHAR(255),method VARCHAR(255),year INT,ethical_rating FLOAT); | INSERT INTO ai_ethics (tool, method, year, ethical_rating) VALUES ('Tegnbit', 'Machine Learning', 2021, NULL); |
What are the energy efficiency stats for buildings in France and Germany? | CREATE TABLE building_energy (country TEXT,building_type TEXT,energy_efficiency NUMERIC); INSERT INTO building_energy (country,building_type,energy_efficiency) VALUES ('France','Residential',80),('France','Commercial',90),('Germany','Residential',85),('Germany','Commercial',95); | SELECT country, building_type, energy_efficiency FROM building_energy WHERE country IN ('France', 'Germany'); |
Find the total billing amount for cases in the labor law category that were opened after 2020-01-01. | CREATE TABLE cases (case_id INT,category VARCHAR(20),billing_amount DECIMAL(10,2),opened_date DATE); | SELECT SUM(billing_amount) FROM cases WHERE category = 'labor' AND opened_date >= '2020-01-01'; |
Insert new artist with multiple albums and tracks | CREATE TABLE artists (id INT PRIMARY KEY,name VARCHAR(255),genre VARCHAR(255)); CREATE TABLE albums (id INT PRIMARY KEY,title VARCHAR(255),release_year INT,artist_id INT,FOREIGN KEY (artist_id) REFERENCES artists(id)); CREATE TABLE tracks (id INT PRIMARY KEY,title VARCHAR(255),duration FLOAT,album_id INT,FOREIGN KEY (album_id) REFERENCES albums(id)); | INSERT INTO artists (id, name, genre) VALUES (1, 'Natasha Bedingfield', 'Pop'); INSERT INTO albums (id, title, release_year, artist_id) VALUES (1, 'Unwritten', 2004, 1), (2, 'Pocketful of Sunshine', 2008, 1); INSERT INTO tracks (id, title, duration, album_id) VALUES (1, 'These Words', 3.21, 1), (2, 'Unwritten', 4.18, 1), (3, 'Soulmate', 3.29, 2), (4, 'Pocketful of Sunshine', 3.12, 2); |
Create a view 'top_cities_v' that shows the top 3 cities with the most fans in 'fan_data' table | CREATE TABLE fan_data (fan_id INT,age INT,gender VARCHAR(10),city VARCHAR(50),state VARCHAR(20),country VARCHAR(50)); INSERT INTO fan_data (fan_id,age,gender,city,state,country) VALUES (1,22,'Male','New York','NY','USA'); INSERT INTO fan_data (fan_id,age,gender,city,state,country) VALUES (2,28,'Female','Los Angeles','CA','USA'); | CREATE VIEW top_cities_v AS SELECT city, COUNT(*) AS fan_count FROM fan_data GROUP BY city ORDER BY fan_count DESC LIMIT 3; |
What is the total number of military bases and their types for each country? | CREATE TABLE military_bases (id INT,country VARCHAR(50),base_name VARCHAR(50),base_type VARCHAR(50)); INSERT INTO military_bases (id,country,base_name,base_type) VALUES (1,'USA','Fort Bragg','Army'),(2,'USA','Pearl Harbor','Navy'),(3,'Russia','Moscow Garrison','Army'); | SELECT COUNT(*) as total_bases, base_type FROM military_bases GROUP BY base_type, country; |
Which virtual reality headsets have the highest adoption rate among users in the 'vr_users' table of the 'virtual_reality' database? | CREATE TABLE vr_users (user_id INT,headset_id INT); INSERT INTO vr_users (user_id,headset_id) VALUES (1,1),(2,1),(3,2),(4,2),(5,3),(6,1),(6,2),(6,3); | SELECT headset_id, COUNT(DISTINCT user_id) as adoption_count FROM vr_users GROUP BY headset_id ORDER BY adoption_count DESC; |
Delete all records from the conservation_efforts table where the project status is 'completed' | CREATE TABLE conservation_efforts (id INT,species_id INT,project_status VARCHAR(20)); | DELETE FROM conservation_efforts WHERE project_status = 'completed'; |
What is the minimum listing price for co-owned properties in Denver? | CREATE TABLE properties (id INT,city VARCHAR(20),listing_price INT,co_owned BOOLEAN); INSERT INTO properties (id,city,listing_price,co_owned) VALUES (1,'Denver',550000,true); INSERT INTO properties (id,city,listing_price,co_owned) VALUES (2,'Denver',450000,false); | SELECT MIN(listing_price) FROM properties WHERE city = 'Denver' AND co_owned = true; |
What is the maximum number of practitioners for a traditional art in each country? | CREATE TABLE max_practitioners (id INT,country VARCHAR(50),art VARCHAR(50),practitioners INT); INSERT INTO max_practitioners (id,country,art,practitioners) VALUES (1,'Canada','Inuit carving',700); INSERT INTO max_practitioners (id,country,art,practitioners) VALUES (2,'New Zealand','Māori tattooing',300); | SELECT country, MAX(practitioners) FROM max_practitioners GROUP BY country; |
How many public libraries are there in the Northeast region? | CREATE TABLE Library (Name VARCHAR(255),Region VARCHAR(255),Type VARCHAR(255)); INSERT INTO Library (Name,Region,Type) VALUES ('Northeast Public Library','Northeast','Public'),('Southeast Public Library','Southeast','Public'),('Southwest Public Library','Southwest','Public'),('Northwest Public Library','Northwest','Public'); | SELECT COUNT(*) FROM Library WHERE Region = 'Northeast' AND Type = 'Public'; |
Which cities have 'Smart Lighting' or 'Smart Transportation' features? | CREATE TABLE smart_city_features (city VARCHAR(50),feature VARCHAR(50)); INSERT INTO smart_city_features (city,feature) VALUES ('CityA','Smart Lighting'),('CityB','Smart Waste Management'),('CityC','Smart Transportation'); | SELECT city FROM smart_city_features WHERE feature IN ('Smart Lighting', 'Smart Transportation'); |
What is the average grant amount awarded to faculty members in the Engineering department? | CREATE TABLE departments (department_id INT,department VARCHAR(50)); INSERT INTO departments VALUES (1,'Computer Science'); INSERT INTO departments VALUES (2,'Engineering'); INSERT INTO departments VALUES (3,'Mathematics'); CREATE TABLE faculty_departments (faculty_id INT,department_id INT); INSERT INTO faculty_departments VALUES (1,1); INSERT INTO faculty_departments VALUES (2,2); INSERT INTO faculty_departments VALUES (3,2); INSERT INTO faculty_departments VALUES (4,3); CREATE TABLE grants_faculty (grant_id INT,faculty_id INT,amount DECIMAL(10,2)); INSERT INTO grants_faculty VALUES (1,1,50000); INSERT INTO grants_faculty VALUES (2,2,75000); INSERT INTO grants_faculty VALUES (3,2,60000); INSERT INTO grants_faculty VALUES (4,1,65000); | SELECT AVG(g.amount) FROM grants_faculty g INNER JOIN faculty_departments fd ON g.faculty_id = fd.faculty_id INNER JOIN departments d ON fd.department_id = d.department_id WHERE d.department = 'Engineering'; |
List all news stories from the 'news_stories' table that have a word length greater than 50 and were published after 2015. | CREATE TABLE news_stories (story_id INT,title VARCHAR(100),description TEXT,reporter_id INT,publish_date DATE); | SELECT title FROM news_stories WHERE LENGTH(title) > 50 AND publish_date > '2015-01-01'; |
Update the species column for all entries in the trees table where the diameter is between 30 and 60 inches to 'Large Tree' | CREATE TABLE trees (id INT PRIMARY KEY,species VARCHAR(255),diameter FLOAT); | UPDATE trees SET species = 'Large Tree' WHERE diameter BETWEEN 30 AND 60; |
What is the minimum age of community health workers in the health_equity schema? | CREATE TABLE community_health_workers (worker_id INT,age INT,name VARCHAR(50)); INSERT INTO community_health_workers (worker_id,age,name) VALUES (1,35,'John Doe'); INSERT INTO community_health_workers (worker_id,age,name) VALUES (2,45,'Jane Smith'); | SELECT MIN(age) FROM health_equity.community_health_workers; |
What is the total cost of all Hubble Space Telescope servicing missions? | CREATE TABLE missions (id INT,name VARCHAR(255),type VARCHAR(255),cost FLOAT); INSERT INTO missions (id,name,type,cost) VALUES (1,'Hubble Servicing Mission 1','Servicing',250000000.0),(2,'Hubble Servicing Mission 2','Servicing',400000000.0); | SELECT SUM(cost) FROM missions WHERE type = 'Servicing' AND name LIKE '%Hubble%'; |
What is the average severity of vulnerabilities for web applications in the last month? | CREATE TABLE vulnerabilities (id INT,application VARCHAR(255),severity FLOAT,discovered_at TIMESTAMP); INSERT INTO vulnerabilities (id,application,severity,discovered_at) VALUES (1,'webapp1',7.5,'2021-01-01 12:00:00'),(2,'webapp2',5.0,'2021-01-05 14:30:00'); | SELECT AVG(severity) FROM vulnerabilities WHERE discovered_at >= DATE_SUB(NOW(), INTERVAL 1 MONTH) AND application LIKE '%webapp%'; |
What is the total number of garments produced using fair labor practices in South America? | CREATE TABLE FairLaborGarments (garment_id INT,factory_id INT); INSERT INTO FairLaborGarments (garment_id,factory_id) VALUES (1,1),(2,1),(3,2),(4,3),(5,4); CREATE TABLE FairLaborFactories (factory_id INT,region VARCHAR(20)); INSERT INTO FairLaborFactories (factory_id,region) VALUES (1,'South America'),(2,'Europe'),(3,'Asia'),(4,'Africa'); | SELECT COUNT(*) FROM FairLaborGarments INNER JOIN FairLaborFactories ON FairLaborGarments.factory_id = FairLaborFactories.factory_id WHERE FairLaborFactories.region = 'South America'; |
What is the total score of players from the UK in VR games? | CREATE TABLE Players (PlayerID INT PRIMARY KEY,Name VARCHAR(50),Age INT,Country VARCHAR(50)); INSERT INTO Players (PlayerID,Name,Age,Country) VALUES (1,'James Smith',25,'UK'); INSERT INTO Players (PlayerID,Name,Age,Country) VALUES (2,'Emily Johnson',30,'Canada'); INSERT INTO Players (PlayerID,Name,Age,Country) VALUES (3,'Oliver Brown',22,'UK'); CREATE TABLE VR_Games (GameID INT PRIMARY KEY,Name VARCHAR(50),Genre VARCHAR(50),Platform VARCHAR(50),PlayerID INT,Score INT); INSERT INTO VR_Games (GameID,Name,Genre,Platform,PlayerID,Score) VALUES (1,'VR Game A','Action','Oculus',1,100); INSERT INTO VR_Games (GameID,Name,Genre,Platform,PlayerID,Score) VALUES (2,'VR Game B','Adventure','HTC Vive',2,200); INSERT INTO VR_Games (GameID,Name,Genre,Platform,PlayerID,Score) VALUES (3,'VR Game C','Simulation','Oculus',3,150); | SELECT SUM(Score) FROM Players JOIN VR_Games ON Players.PlayerID = VR_Games.PlayerID WHERE Players.Country = 'UK' AND Platform = 'Oculus'; |
What is the total quantity of gold mined in Canada by year? | CREATE TABLE mines (id INT,country VARCHAR(255),mineral VARCHAR(255),quantity INT,year INT); INSERT INTO mines (id,country,mineral,quantity,year) VALUES (1,'Canada','Gold',500,2000),(2,'Canada','Gold',750,2001),(3,'Canada','Gold',800,2002); | SELECT year, SUM(quantity) FROM mines WHERE country = 'Canada' AND mineral = 'Gold' GROUP BY year; |
Delete a record for a given mammal in the Mammals table | CREATE TABLE Mammals (species VARCHAR(255),region VARCHAR(255),biomass FLOAT); INSERT INTO Mammals (species,region,biomass) VALUES ('Polar Bear','Arctic Ocean',500),('Reindeer','Greenland',200),('Polar Fox','Norway',10),('Musk Ox','Canada',300),('Walrus','Russia',2000); | DELETE FROM Mammals WHERE species = 'Polar Fox'; |
What is the distribution of employees by job title? | CREATE TABLE employees (employee_id INT,name TEXT,job_title TEXT); INSERT INTO employees (employee_id,name,job_title) VALUES (1,'Alice','HR Manager'),(2,'Bob','Software Engineer'),(3,'Charlie','Software Engineer'),(4,'Dave','Sales Manager'),(5,'Eve','Software Engineer'); | SELECT job_title, COUNT(*) AS num_employees FROM employees GROUP BY job_title; |
What is the total amount donated by female donors aged 50 or above? | CREATE TABLE DonorDemographics (DonorID INT,Age INT,Gender VARCHAR(10),Income DECIMAL(10,2),Education VARCHAR(50)); INSERT INTO DonorDemographics (DonorID,Age,Gender,Income,Education) VALUES (1,35,'Female',80000.00,'Master''s'); INSERT INTO DonorDemographics (DonorID,Age,Gender,Income,Education) VALUES (2,42,'Male',100000.00,'Doctorate'); INSERT INTO DonorDemographics (DonorID,Age,Gender,Income,Education) VALUES (3,55,'Female',120000.00,'Doctorate'); | SELECT SUM(Income) FROM DonorDemographics WHERE Gender = 'Female' AND Age >= 50; |
What is the total cargo tonnage exported from Japan to the Port of Long Beach in Q1 2021? | CREATE TABLE vessels (vessel_id INT,vessel_name TEXT); INSERT INTO vessels VALUES (1,'Vessel X'),(2,'Vessel Y'),(3,'Vessel Z'); CREATE TABLE ports (port_id INT,port_name TEXT,country TEXT); INSERT INTO ports VALUES (7,'Port of Long Beach','USA'),(8,'Port of Tokyo','Japan'); CREATE TABLE shipments (shipment_id INT,vessel_id INT,port_id INT,cargo_tonnage INT,ship_date DATE); INSERT INTO shipments VALUES (1,1,8,5000,'2021-01-01'),(2,1,7,3000,'2021-02-01'),(3,2,8,4000,'2021-03-01'),(4,3,8,6000,'2021-04-01'); | SELECT SUM(shipments.cargo_tonnage) FROM vessels JOIN shipments ON vessels.vessel_id = shipments.vessel_id JOIN ports ON shipments.port_id = ports.port_id WHERE ports.port_name = 'Port of Long Beach' AND ports.country = 'Japan' AND YEAR(shipments.ship_date) = 2021 AND QUARTER(shipments.ship_date) = 1; |
What is the average price of naval vessels sold by UnitedDefense to the German government? | CREATE TABLE UnitedDefense.NavalVesselSales (id INT,manufacturer VARCHAR(255),model VARCHAR(255),quantity INT,price DECIMAL(10,2),buyer_country VARCHAR(255),sale_date DATE); | SELECT AVG(price) FROM UnitedDefense.NavalVesselSales WHERE buyer_country = 'Germany' AND manufacturer = 'UnitedDefense'; |
Delete all records of non-organic cotton items from the inventory. | CREATE TABLE inventory (id INT,item_name VARCHAR(255),category VARCHAR(255),is_organic BOOLEAN); INSERT INTO inventory (id,item_name,category,is_organic) VALUES (1,'Cotton Shirt','Tops',true),(2,'Polyester Pants','Bottoms',false); | DELETE FROM inventory WHERE is_organic = false; |
How many police officers are employed in the city of Chicago? | CREATE TABLE public.police_department (id SERIAL PRIMARY KEY,city VARCHAR(255),num_officers INTEGER); INSERT INTO public.police_department (city,num_officers) VALUES ('Chicago',12000),('New York',35000),('Los Angeles',10000); | SELECT num_officers FROM public.police_department WHERE city = 'Chicago'; |
What is the total cost of 'Organic Chicken' and 'Tofu Stir Fry' dishes? | CREATE TABLE Items (id INT,item_name VARCHAR(50),cost DECIMAL(5,2)); INSERT INTO Items VALUES (1,'Organic Chicken',3.50),(2,'Tofu Stir Fry',4.25),(3,'Sweet Potato Fries',1.75); | SELECT SUM(cost) FROM Items WHERE item_name IN ('Organic Chicken', 'Tofu Stir Fry'); |
What is the average game purchase price for each game category? | CREATE TABLE games (game_id INT,game_name TEXT,game_category TEXT,game_purchase_price FLOAT); INSERT INTO games (game_id,game_name,game_category,game_purchase_price) VALUES (1,'Game A','Role-playing',49.99),(2,'Game B','Action',59.99),(3,'Game C','Role-playing',54.99),(4,'Game D','Strategy',39.99); | SELECT game_category, AVG(game_purchase_price) as avg_price FROM games GROUP BY game_category; |
How many mobile customers in the West region are in compliance with data privacy regulations? | CREATE TABLE customers(id INT,region VARCHAR(10),compliant BOOLEAN); | SELECT COUNT(*) FROM customers WHERE customers.region = 'West' AND customers.compliant = TRUE; |
What is the number of unique IP addresses that have attempted to exploit each software product's vulnerabilities, ordered by the count of unique IP addresses in descending order? | CREATE TABLE exploit_attempts (id INT,product VARCHAR(50),ip VARCHAR(50)); | SELECT product, COUNT(DISTINCT ip) as num_unique_ips FROM exploit_attempts GROUP BY product ORDER BY num_unique_ips DESC; |
What is the maximum quantity of silver extracted in a single day for mining sites in Australia, for sites having more than 30 employees? | CREATE TABLE silver_mine (site_id INT,country VARCHAR(50),num_employees INT,extraction_date DATE,quantity INT); INSERT INTO silver_mine (site_id,country,num_employees,extraction_date,quantity) VALUES (1,'Australia',40,'2015-01-02',1000),(2,'Australia',35,'2014-12-31',1500),(3,'Australia',60,'2016-03-04',2000),(4,'Australia',50,'2015-06-10',500); | SELECT country, MAX(quantity) as max_daily_silver FROM silver_mine WHERE num_employees > 30 AND country = 'Australia' GROUP BY country; |
What is the minimum salary of part-time workers who are not union members in the 'manufacturing' industry? | CREATE TABLE parttime_workers (id INT,industry VARCHAR(20),salary FLOAT,union_member BOOLEAN); INSERT INTO parttime_workers (id,industry,salary,union_member) VALUES (1,'healthcare',30000.0,false),(2,'healthcare',32000.0,false),(3,'manufacturing',25000.0,false),(4,'retail',20000.0,false),(5,'retail',22000.0,true); | SELECT MIN(salary) FROM parttime_workers WHERE industry = 'manufacturing' AND union_member = false; |
Create a table named 'philanthropic_orgs' | CREATE TABLE philanthropic_orgs (id INT PRIMARY KEY,name VARCHAR(100),focus_area VARCHAR(100),headquarters VARCHAR(100),website VARCHAR(100)); | CREATE TABLE philanthropic_orgs ( id INT PRIMARY KEY, name VARCHAR(100), focus_area VARCHAR(100), headquarters VARCHAR(100), website VARCHAR(100)); |
How many AI safety incidents were reported by the underrepresented communities in Q4 2021? | CREATE TABLE SafetyIncidents (incident_id INT,reported_by VARCHAR(255),incident_date DATE); INSERT INTO SafetyIncidents (incident_id,reported_by,incident_date) VALUES (1,'Minority Group','2021-10-01'),(2,'LGBTQ+','2021-11-01'),(3,'Women in Tech','2021-12-01'); | SELECT COUNT(*) FROM SafetyIncidents WHERE reported_by IN ('Minority Group', 'LGBTQ+', 'Women in Tech') AND incident_date BETWEEN '2021-10-01' AND '2021-12-31'; |
What is the minimum cargo weight for vessels in the Caribbean? | CREATE TABLE Vessels (VesselID varchar(10),CargoWeight int,Region varchar(10)); INSERT INTO Vessels (VesselID,CargoWeight,Region) VALUES ('VesselA',1000,'Asia-Pacific'),('VesselB',1500,'Caribbean'),('VesselC',1200,'Atlantic'); | SELECT MIN(CargoWeight) FROM Vessels WHERE Region = 'Caribbean'; |
How many esports events were held for each game in 2018, ranked by the number of events? | CREATE TABLE EsportsEvents (EventID INT,EventName VARCHAR(50),GameID INT,EventDate DATE,PrizePool NUMERIC(18,2)); INSERT INTO EsportsEvents (EventID,EventName,GameID,EventDate,PrizePool) VALUES (1,'Fortnite World Cup',1,'2019-07-26',30000000); INSERT INTO EsportsEvents (EventID,EventName,GameID,EventDate,PrizePool) VALUES (2,'Overwatch League Grand Finals',2,'2018-07-28',1500000); INSERT INTO EsportsEvents (EventID,EventName,GameID,EventDate,PrizePool) VALUES (3,'League of Legends World Championship',3,'2018-11-03',24000000); INSERT INTO EsportsEvents (EventID,EventName,GameID,EventDate,PrizePool) VALUES (4,'Dota 2 International',4,'2018-08-20',25500000); | SELECT GameID, COUNT(*) as EventsIn2018, ROW_NUMBER() OVER (ORDER BY COUNT(*) DESC) as Rank FROM EsportsEvents WHERE EventDate BETWEEN '2018-01-01' AND '2018-12-31' GROUP BY GameID; |
How many unique IP addresses have been blacklisted in the last week? | CREATE TABLE blacklist (id INT,ip_address VARCHAR(50),blacklist_date DATE); | SELECT COUNT(DISTINCT ip_address) FROM blacklist WHERE blacklist_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 WEEK); |
Identify the number of unique countries represented by founders | CREATE TABLE company_founding (company_name VARCHAR(255),founder_country VARCHAR(50)); INSERT INTO company_founding (company_name,founder_country) VALUES ('Acme Inc','USA'),('Beta Corp','Canada'),('Charlie LLC','USA'); | SELECT COUNT(DISTINCT founder_country) FROM company_founding; |
What is the average salary of developers who have contributed to open-source projects focused on technology accessibility in the EU? | CREATE TABLE developers (developer_id INT,name VARCHAR(50),salary FLOAT,country VARCHAR(50),contribution_accessibility BOOLEAN); INSERT INTO developers (developer_id,name,salary,country,contribution_accessibility) VALUES (1,'Alice',75000.0,'EU',true),(2,'Bob',80000.0,'USA',false),(3,'Charlie',85000.0,'EU',true); | SELECT AVG(salary) FROM developers WHERE country = 'EU' AND contribution_accessibility = true; |
Insert a new record for a program with ProgramID of 4 and ProgramName of 'Education and Literacy', and give it a ProgramBudget of $50,000. | CREATE TABLE Programs (ProgramID INT,ProgramName VARCHAR(50),ProgramBudget DECIMAL(10,2)); INSERT INTO Programs (ProgramID,ProgramName,ProgramBudget) VALUES (1,'Healthcare',75000.00),(2,'Housing',60000.00),(3,'Food Security',45000.00); | INSERT INTO Programs (ProgramID, ProgramName, ProgramBudget) VALUES (4, 'Education and Literacy', 50000.00); |
List the names of all dispensaries that have never sold a strain containing 'Kush' in its name. | CREATE TABLE dispensaries (id INT,name TEXT,state TEXT); CREATE TABLE strains (id INT,name TEXT,dispensary_id INT); INSERT INTO dispensaries (id,name,state) VALUES (1,'The Healing Center','Massachusetts'),(2,'Remedy','Texas'); INSERT INTO strains (id,name,dispensary_id) VALUES (1,'Jack Herer',1),(2,'Purple Kush',1),(3,'Green Crack',2); | SELECT d.name FROM dispensaries d WHERE d.id NOT IN (SELECT s.dispensary_id FROM strains s WHERE s.name LIKE '%Kush%'); |
What is the name and age of the youngest donor from each country? | CREATE TABLE Donors (DonorID int,Name varchar(50),Age int,Country varchar(50)); INSERT INTO Donors (DonorID,Name,Age,Country) VALUES (1,'John Doe',30,'USA'),(2,'Jane Smith',45,'Canada'),(3,'Pedro Martinez',25,'Mexico'); | SELECT d1.Name, d1.Age, d1.Country FROM Donors d1 INNER JOIN (SELECT Country, MIN(Age) AS MinAge FROM Donors GROUP BY Country) d2 ON d1.Country = d2.Country AND d1.Age = d2.MinAge; |
Find the total assets managed by each fund manager in the Western region, excluding those who manage less than $10 million. | CREATE TABLE fund_managers (manager_id INT,name VARCHAR(50),region VARCHAR(20),total_assets DECIMAL(10,2)); CREATE TABLE managed_funds (fund_id INT,manager_id INT,total_assets DECIMAL(10,2)); | SELECT fm.name, SUM(mf.total_assets) as total_assets_managed FROM fund_managers fm JOIN managed_funds mf ON fm.manager_id = mf.manager_id WHERE fm.region = 'Western' GROUP BY fm.name HAVING SUM(mf.total_assets) >= 10000000 ORDER BY total_assets_managed DESC; |
Find cross-table correlation between Europium production and market trends. | CREATE TABLE europium_production (country VARCHAR(50),year INT,quantity INT); CREATE TABLE europium_market_trends (country VARCHAR(50),year INT,trend VARCHAR(50),value INT); | SELECT e.country, e.year, e.quantity, m.trend, m.value, CORR(e.quantity, m.value) AS correlation FROM europium_production e INNER JOIN europium_market_trends m ON e.country = m.country AND e.year = m.year GROUP BY e.country, e.year; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.