instruction stringlengths 0 1.06k | input stringlengths 11 5.3k | response stringlengths 2 4.44k |
|---|---|---|
List cities with the lowest life expectancy, by gender. | CREATE TABLE life_expectancy (id INT,city VARCHAR,gender VARCHAR,life_expectancy DECIMAL); | SELECT l.city, l.gender, AVG(l.life_expectancy) AS avg_life_expectancy FROM life_expectancy l GROUP BY l.city, l.gender ORDER BY avg_life_expectancy ASC LIMIT 10; |
What is the total length of pollution control initiatives in the Indian Ocean? | CREATE TABLE pollution_control (initiative_name TEXT,length REAL,ocean TEXT); INSERT INTO pollution_control (initiative_name,length,ocean) VALUES ('Initiative_1',120.0,'Indian'),('Initiative_2',150.0,'Indian'),('Initiative_3',180.0,'Pacific'); | SELECT SUM(length) FROM pollution_control WHERE ocean = 'Indian'; |
Which sustainable tourism activities in Germany are rated 4 or higher? | CREATE TABLE activities (activity_id INT,activity_name VARCHAR(50),country VARCHAR(50),rating INT); INSERT INTO activities (activity_id,activity_name,country,rating) VALUES (1,'Bike Tour','Germany',5),(2,'Hiking Adventure','Germany',4),(3,'Bird Watching','Germany',3),(4,'Nature Photography','Germany',5); | SELECT activity_name, rating FROM activities WHERE country = 'Germany' AND rating >= 4; |
Find all dishes in the menu and dish_allergens tables that contain peanuts. | CREATE TABLE menu (menu_id INT,dish_name TEXT); CREATE TABLE dish_allergens (dish_id INT,allergen TEXT); | SELECT menu.dish_name FROM menu INNER JOIN dish_allergens ON menu.menu_id = dish_allergens.dish_id WHERE dish_allergens.allergen = 'peanuts'; |
How many professional development courses have been completed by teachers in each region? | CREATE TABLE teachers (teacher_id INT,teacher_name VARCHAR(50),region VARCHAR(20),courses_completed INT); INSERT INTO teachers (teacher_id,teacher_name,region,courses_completed) VALUES (1,'John Doe','North',3),(2,'Jane Smith','South',5),(3,'Alice Johnson','East',4),(4,'Bob Williams','West',2); | SELECT region, SUM(courses_completed) as total_courses FROM teachers GROUP BY region; |
List all salmon farms in Canada with water temperature above 15 degrees Celsius? | CREATE TABLE salmon_farms (id INT,name TEXT,country TEXT,water_temp FLOAT); INSERT INTO salmon_farms (id,name,country,water_temp) VALUES (1,'Farm J','Canada',14.8); INSERT INTO salmon_farms (id,name,country,water_temp) VALUES (2,'Farm K','Canada',16.2); INSERT INTO salmon_farms (id,name,country,water_temp) VALUES (3,'F... | SELECT * FROM salmon_farms WHERE country = 'Canada' AND water_temp > 15; |
What is the percentage of each animal type in each sanctuary? | CREATE TABLE sanctuary_data (sanctuary_id INT,sanctuary_name VARCHAR(255),animal_type VARCHAR(255),animal_count INT); INSERT INTO sanctuary_data (sanctuary_id,sanctuary_name,animal_type,animal_count) VALUES (1,'Sanctuary A','Tiger',25),(2,'Sanctuary A','Elephant',30),(3,'Sanctuary B','Tiger',35),(4,'Sanctuary B','Eleph... | SELECT sanctuary_name, animal_type, (animal_count::float/SUM(animal_count) OVER (PARTITION BY sanctuary_name))*100 AS animal_percentage FROM sanctuary_data; |
What is the total number of military equipment maintenance requests, by equipment type, for the Army and Navy in the past six months? | CREATE TABLE military_equipment_maintenance (request_id INT,request_date DATE,branch TEXT,equipment_type TEXT,maintenance_description TEXT,completion_date DATE); INSERT INTO military_equipment_maintenance (request_id,request_date,branch,equipment_type,maintenance_description,completion_date) VALUES (1,'2022-04-01','Arm... | SELECT equipment_type, COUNT(*) as num_requests FROM military_equipment_maintenance WHERE branch IN ('Army', 'Navy') AND request_date BETWEEN DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH) AND CURRENT_DATE GROUP BY equipment_type; |
Find the number of green buildings certified by each certification body, represented in the green_buildings table. | CREATE TABLE green_buildings (building_id INT,building_name VARCHAR(255),location VARCHAR(255),certification_id INT,certification_name VARCHAR(255)); | SELECT certification_name, COUNT(*) AS num_buildings FROM green_buildings GROUP BY certification_id; |
How many hospital beds are there in each region of the world? | CREATE TABLE hospital_beds (id INT,region TEXT,num_beds INT); INSERT INTO hospital_beds (id,region,num_beds) VALUES (1,'North America',1000000),(2,'South America',500000),(3,'Europe',2000000),(4,'Asia',3000000),(5,'Africa',500000),(6,'Australia',100000); | SELECT region, SUM(num_beds) FROM hospital_beds GROUP BY region; |
Which military technology has been developed in the last 5 years? | CREATE TABLE Military_Technology (Technology VARCHAR(255),Year INT); INSERT INTO Military_Technology (Technology,Year) VALUES ('Stealth Fighter',2018),('Laser Weapon',2019),('Hypersonic Missile',2020),('Artificial Intelligence',2021),('Quantum Computer',2022); | SELECT Technology FROM Military_Technology WHERE Year >= 2017; |
Which countries received the most humanitarian assistance from the US in the last 3 years? | CREATE TABLE humanitarian_assistance (donor VARCHAR(255),recipient VARCHAR(255),assistance_amount DECIMAL(10,2),assistance_date DATE); | SELECT recipient, SUM(assistance_amount) as total_assistance FROM humanitarian_assistance WHERE donor = 'US' AND assistance_date BETWEEN DATE_SUB(CURDATE(), INTERVAL 3 YEAR) AND CURDATE() GROUP BY recipient ORDER BY total_assistance DESC LIMIT 5; |
Find the top 3 artists with the highest number of streams in Germany. | CREATE TABLE artists (artist_id INT,artist_name VARCHAR(255),country VARCHAR(255)); CREATE TABLE streams (stream_id INT,artist_id INT,streams INT); INSERT INTO artists (artist_id,artist_name,country) VALUES (101,'Taylor Swift','USA'),(102,'BTS','South Korea'),(103,'Drake','Canada'); INSERT INTO streams (stream_id,artis... | SELECT artist_name, SUM(streams) as total_streams FROM streams JOIN artists ON streams.artist_id = artists.artist_id WHERE country = 'Germany' GROUP BY artist_name ORDER BY total_streams DESC LIMIT 3; |
Delete all products with a price above 300. | CREATE TABLE products (product_id INT,price DECIMAL(5,2)); INSERT INTO products (product_id,price) VALUES (1,19.99),(2,79.99),(3,49.99),(4,299.99); | DELETE FROM products WHERE price > 300; |
Delete all records from 'exploration_data' table where 'method' is 'Seismic Reflection' | CREATE TABLE exploration_data (id INT PRIMARY KEY,method VARCHAR(255),date DATE); | DELETE FROM exploration_data WHERE method = 'Seismic Reflection'; |
What is the total number of members in the 'Educators_Union' with a safety_rating above 8? | CREATE TABLE Educators_Union (union_member_id INT,member_id INT,safety_rating FLOAT); INSERT INTO Educators_Union (union_member_id,member_id,safety_rating) VALUES (1,101,8.25),(1,102,8.75),(1,103,9.25),(2,201,7.50),(2,202,8.75); | SELECT COUNT(union_member_id) FROM Educators_Union WHERE safety_rating > 8; |
What is the total donation amount per donor, sorted by the total donation amount in descending order, and display the top 5 donors? | CREATE TABLE Donors (DonorID INT,DonorName VARCHAR(50),TotalDonation DECIMAL(10,2)); INSERT INTO Donors (DonorID,DonorName,TotalDonation) VALUES (1,'John Doe',5000.00),(2,'Jane Smith',3000.00),(3,'Alice Johnson',2500.00),(4,'Bob Brown',1500.00),(5,'Charlie Davis',800.00); | SELECT * FROM (SELECT DonorName, TotalDonation, ROW_NUMBER() OVER (ORDER BY TotalDonation DESC) as rn FROM Donors) t WHERE rn <= 5; |
What is the average value of all artworks in the 'sculpture' category? | CREATE TABLE artworks (id INT,name TEXT,category TEXT,value DECIMAL); INSERT INTO artworks (id,name,category,value) VALUES (1,'Starry Night','painting',400.00),(2,'The Persistence of Memory','painting',500.00),(3,'David','sculpture',800.00); | SELECT AVG(value) FROM artworks WHERE category = 'sculpture'; |
What is the minimum rating of any hotel? | CREATE TABLE hotels (id INT,city VARCHAR(20),rating FLOAT); INSERT INTO hotels (id,city,rating) VALUES (1,'Paris',4.2),(2,'Paris',4.5),(3,'London',4.7); | SELECT MIN(rating) FROM hotels; |
Find the number of artists who have won the Aboriginal Art Prize and their respective countries, along with the name of the capital city. | CREATE TABLE artists_aap (id INT,name VARCHAR(50),country VARCHAR(30)); INSERT INTO artists_aap (id,name,country) VALUES (1,'Artist1','Australia'),(2,'Artist2','Canada'),(3,'Artist3','New Zealand'); CREATE TABLE countries (id INT,country VARCHAR(30),capital VARCHAR(30)); INSERT INTO countries (id,country,capital) VALUE... | SELECT c.capital, a.country, COUNT(a.id) as artist_count FROM artists_aap a JOIN countries c ON a.country = c.country GROUP BY a.country, c.capital; |
Identify the genres that are unique to movies produced in Spain and Portugal. | CREATE TABLE movies (id INT,title VARCHAR(255),genre VARCHAR(100),country VARCHAR(50)); INSERT INTO movies VALUES (1,'Movie A','Comedy','Spain'); INSERT INTO movies VALUES (2,'Movie B','Drama','Portugal'); INSERT INTO movies VALUES (3,'Movie C','Action','Spain'); INSERT INTO movies VALUES (4,'Movie D','Comedy','Portuga... | SELECT genre FROM movies WHERE country IN ('Spain', 'Portugal') GROUP BY genre HAVING COUNT(DISTINCT country) = 1; |
Find the number of clients with the first name 'John' | CREATE TABLE clients (client_id INT,first_name VARCHAR(50),last_name VARCHAR(50)); INSERT INTO clients (client_id,first_name,last_name) VALUES (1,'John','Doe'),(2,'Jane','Smith'); | SELECT COUNT(*) FROM clients WHERE first_name = 'John'; |
What is the minimum budget for all resilience projects in the infrastructure development database? | CREATE TABLE if not exists Projects (id INT,name VARCHAR(50),type VARCHAR(50),budget DECIMAL(10,2)); INSERT INTO Projects (id,name,type,budget) VALUES (1,'Seawall','Resilience',5000000.00),(2,'Floodgate','Resilience',3000000.00),(3,'Bridge','Transportation',8000000.00),(4,'Highway','Transportation',12000000.00),(5,'Lev... | SELECT MIN(budget) FROM Projects WHERE type = 'Resilience'; |
What is the maximum number of likes received by any article about political corruption? | CREATE TABLE articles (article_id INT,title TEXT,topic TEXT,likes INT); INSERT INTO articles (article_id,title,topic,likes) VALUES (1,'Political Corruption Scandal','political corruption',100),(2,'Corruption in Local Government','political corruption',150); | SELECT MAX(likes) FROM articles WHERE topic = 'political corruption'; |
Create a view to display the job titles and departments of applicants | CREATE TABLE TalentAcquisition (ApplicantID INT PRIMARY KEY,JobTitle VARCHAR(30),Department VARCHAR(20),ApplicationDate DATE); | CREATE VIEW JobTitlesDepartments AS SELECT JobTitle, Department FROM TalentAcquisition; |
What is the maximum safety score for models from the 'Algo Fairness' category in Q4 2021? | CREATE TABLE model_scores (id INT,model_id INT,safety_score FLOAT,category VARCHAR(255),quarter INT,year INT); INSERT INTO model_scores (id,model_id,safety_score,category,quarter,year) VALUES (1,1,9.1,'Algo Fairness',4,2021); | SELECT MAX(safety_score) FROM model_scores WHERE category = 'Algo Fairness' AND quarter = 4 AND year = 2021 |
Update the type of vessels with a max speed greater than 25 knots to 'High Speed Vessel' | CREATE TABLE Vessel (vessel_id INT,name VARCHAR(255),type VARCHAR(255),max_speed DECIMAL(5,2)); INSERT INTO Vessel (vessel_id,name,type,max_speed) VALUES (1,'Test Vessel 1','Cargo',22.3),(2,'Test Vessel 2','Tanker',15.2),(3,'Test Vessel 3','Passenger',31.1); | UPDATE Vessel SET type = 'High Speed Vessel' WHERE max_speed > 25; |
What was the total revenue for the "Premium" product line in Q1 2021? | CREATE TABLE sales (product_line VARCHAR(10),date DATE,revenue FLOAT); INSERT INTO sales (product_line,date,revenue) VALUES ('Premium','2021-01-01',5000),('Basic','2021-01-01',3000),('Premium','2021-01-02',6000),('Basic','2021-01-02',4000); | SELECT SUM(revenue) FROM sales WHERE product_line = 'Premium' AND date BETWEEN '2021-01-01' AND '2021-03-31'; |
List all construction projects that were started in the last 6 months, along with the project name, start date, and the company responsible for the project. | CREATE TABLE projects (id INT,project_name VARCHAR(100),start_date DATE,company_name VARCHAR(100)); INSERT INTO projects (id,project_name,start_date,company_name) VALUES (1,'Building A','2022-01-01','ABC Construction'),(2,'Construction B','2022-02-15','XYZ Construction'),(3,'Project C','2022-03-01','DEF Construction'); | SELECT p.project_name, p.start_date, p.company_name FROM projects p WHERE p.start_date >= DATEADD(month, -6, GETDATE()); |
How many employees were hired in 2021 from underrepresented racial or ethnic groups? | CREATE TABLE Employees (EmployeeID int,HireDate date,Ethnicity varchar(30)); INSERT INTO Employees (EmployeeID,HireDate,Ethnicity) VALUES (1,'2021-01-01','Latinx'),(2,'2021-02-15','African American'),(3,'2020-05-01','Asian'),(4,'2022-03-20','Caucasian'); | SELECT COUNT(*) FROM Employees WHERE YEAR(HireDate) = 2021 AND Ethnicity IN ('Latinx', 'African American', 'Native American', 'Pacific Islander'); |
What are the top 3 countries with the most satellites in orbit? | CREATE TABLE countries (id INTEGER,name TEXT,num_satellites INTEGER); INSERT INTO countries (id,name,num_satellites) VALUES (1,'USA',1500),(2,'Russia',1200),(3,'China',800),(4,'India',300),(5,'Japan',250),(6,'Germany',150),(7,'France',120),(8,'Italy',100); | SELECT name, num_satellites FROM countries ORDER BY num_satellites DESC LIMIT 3; |
What is the average precipitation in 'Station A' and 'Station B'? | CREATE TABLE climate_data (id INT,location VARCHAR(255),temperature FLOAT,precipitation FLOAT,measurement_date DATE); INSERT INTO climate_data (id,location,temperature,precipitation,measurement_date) VALUES (1,'Station A',-15.0,20.5,'2020-01-01'); INSERT INTO climate_data (id,location,temperature,precipitation,measurem... | SELECT location, AVG(precipitation) FROM climate_data WHERE location IN ('Station A', 'Station B') GROUP BY location; |
List all bioprocess engineering information for a specific bioreactor named 'Bioreactor2'? | CREATE TABLE bioprocess (id INT,bioreactor VARCHAR(50),parameter VARCHAR(50),value FLOAT); INSERT INTO bioprocess (id,bioreactor,parameter,value) VALUES (2,'Bioreactor2','Pressure',2); | SELECT * FROM bioprocess WHERE bioreactor = 'Bioreactor2'; |
Find the top 3 players with the highest number of goals scored in the 2022 FIFA World Cup group stage? | CREATE TABLE players (player_id INT,player_name VARCHAR(255)); CREATE TABLE matches (match_id INT,home_team_id INT,away_team_id INT,goals_home INT,goals_away INT); INSERT INTO players VALUES (1,'Player1'),(2,'Player2'),(3,'Player3'),(4,'Player4'); INSERT INTO matches VALUES (1,1,2,2,1),(2,1,3,0,3),(3,2,4,1,2); | SELECT p.player_name, SUM(m.goals_home) + SUM(m.goals_away) AS total_goals FROM players p JOIN matches m ON p.player_id IN (m.home_team_id, m.away_team_id) WHERE m.match_id IN (SELECT match_id FROM matches WHERE (home_team_id = 1 OR away_team_id = 1) AND (goals_home > 0 OR goals_away > 0) AND match_id <= 6) GROUP BY p.... |
Find total donations from each country in 'donations' table. | CREATE TABLE donations (id INT,name VARCHAR(50),amount FLOAT,country VARCHAR(50),date DATE); | SELECT country, SUM(amount) FROM donations GROUP BY country; |
What was the average humanitarian assistance budget for the top 3 contributors in 2019? | CREATE TABLE humanitarian_assistance (contributor VARCHAR(50),year INT,budget FLOAT); INSERT INTO humanitarian_assistance (contributor,year,budget) VALUES ('USA',2019,3200000000),('Germany',2019,2100000000),('UK',2019,1800000000),('Canada',2019,1200000000),('France',2019,900000000); | SELECT AVG(budget) FROM humanitarian_assistance WHERE year = 2019 AND contributor IN ('USA', 'Germany', 'UK'); |
What is the age of the oldest reader? | CREATE TABLE readers (id INT,name VARCHAR(50),age INT,gender VARCHAR(10),country VARCHAR(50)); | SELECT MAX(age) FROM readers; |
Which restaurants do not serve any vegetarian menu items? | CREATE TABLE restaurants (id INT,name VARCHAR(255),category VARCHAR(255)); INSERT INTO restaurants (id,name,category) VALUES (1,'Fast Food Frenzy','Quick Service'),(2,'Bistro Bites','Fine Dining'),(3,'Green Garden','Quick Service'); CREATE TABLE menu_items (id INT,name VARCHAR(255),vegetarian BOOLEAN,restaurant_id INT)... | SELECT r.name FROM restaurants r LEFT JOIN menu_items mi ON r.id = mi.restaurant_id WHERE mi.vegetarian IS NULL; |
Who are the archaeologists specializing in Mayan civilization? | CREATE TABLE Archaeologist (ArchaeologistID INT PRIMARY KEY,Name VARCHAR(255),Specialty VARCHAR(255)); INSERT INTO Archaeologist (ArchaeologistID,Name,Specialty) VALUES (3,'Dr. Maria Garcia','Mayan Civilization'); | SELECT Archaeologist.Name FROM Archaeologist WHERE Archaeologist.Specialty = 'Mayan Civilization'; |
Which sustainable food trends have the highest calorie count? | CREATE TABLE Trends (trend_id INT,trend_name VARCHAR(100),calorie_count INT); INSERT INTO Trends (trend_id,trend_name,calorie_count) VALUES (1,'Plant-based meats',250),(2,'Local produce',50),(3,'Organic grains',180); | SELECT trend_name, calorie_count FROM Trends ORDER BY calorie_count DESC LIMIT 1; |
Retrieve the total number of wells drilled in the past year by each operator | CREATE TABLE operators (operator_id INT,operator_name TEXT); INSERT INTO operators (operator_id,operator_name) VALUES (1,'Operator Z'),(2,'Operator W'); CREATE TABLE wells (well_id INT,operator_id INT,year INT,location TEXT); INSERT INTO wells (well_id,operator_id,year,location) VALUES (1,1,2022,'Alaska'),(2,1,2022,'Al... | SELECT o.operator_name, COUNT(w.well_id) AS num_wells_drilled FROM wells w JOIN operators o ON w.operator_id = o.operator_id WHERE w.year = (SELECT MAX(year) FROM wells) GROUP BY o.operator_id; |
What is the total number of charging stations in the "charging_stations" table? | CREATE TABLE charging_stations (id INT,location VARCHAR(255),is_active BOOLEAN); INSERT INTO charging_stations (id,location,is_active) VALUES (1,'City Park',true); | SELECT COUNT(*) FROM charging_stations WHERE is_active = true; |
Insert a new rural infrastructure project in Nepal for 'Bridge Construction' with a cost of 40000.00. | CREATE TABLE rural_infrastructure (id INT,country VARCHAR(20),project_name VARCHAR(50),project_cost FLOAT); | INSERT INTO rural_infrastructure (country, project_name, project_cost) VALUES ('Nepal', 'Bridge Construction', 40000.00); |
How many community development initiatives were launched in Brazil between 2015 and 2018? | CREATE TABLE community_development (id INT,initiative_name TEXT,sector TEXT,country TEXT,launch_date DATE); INSERT INTO community_development (id,initiative_name,sector,country,launch_date) VALUES (1,'Youth Empowerment Program','Community Development','Brazil','2016-03-20'),(2,'Rural Women Entrepreneurship','Community ... | SELECT COUNT(*) FROM community_development WHERE country = 'Brazil' AND launch_date BETWEEN '2015-01-01' AND '2018-12-31'; |
Get the number of virtual tours booked in Asia in the last month? | CREATE TABLE Bookings (id INT,tour_id INT,booked_date DATE); INSERT INTO Bookings (id,tour_id,booked_date) VALUES (1,1,'2022-02-01'); | SELECT COUNT(*) FROM Bookings WHERE booked_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) AND EXTRACT(CONTINENT FROM (SELECT country FROM Tours WHERE Tours.id = Bookings.tour_id)) = 'Asia'; |
What is the total landfill capacity in cubic meters for each region in descending order? | CREATE TABLE landfill_capacity (region VARCHAR(255),year INT,capacity FLOAT); INSERT INTO landfill_capacity (region,year,capacity) VALUES ('North America',2018,5000000.0),('South America',2018,3000000.0),('Europe',2018,4000000.0); | SELECT lc.region, SUM(lc.capacity) as total_capacity FROM landfill_capacity lc GROUP BY lc.region ORDER BY total_capacity DESC; |
What is the total number of volunteer hours in the region 'South East'? | CREATE TABLE Volunteers (id INT,name TEXT,region TEXT,hours FLOAT); INSERT INTO Volunteers (id,name,region,hours) VALUES (1,'Alice','South East',5.0),(2,'Bob','North West',3.5); | SELECT SUM(hours) FROM Volunteers WHERE region = 'South East'; |
Determine the market share of the 'HotelBot' AI assistant in '2022'? | CREATE TABLE ai_assistants (assistant_name TEXT,year INT,revenue INT); INSERT INTO ai_assistants (assistant_name,year,revenue) VALUES ('ReceptionBot',2022,150000),('HotelBot',2022,200000),('FrontDeskAI',2022,100000); | SELECT (HotelBot_revenue / TOTAL_revenue) * 100 as market_share FROM (SELECT SUM(revenue) as HotelBot_revenue FROM ai_assistants WHERE assistant_name = 'HotelBot' AND year = 2022) as HotelBot, (SELECT SUM(revenue) as TOTAL_revenue FROM ai_assistants WHERE year = 2022) as total; |
List the names of all teachers who have completed the least amount of professional development hours. | CREATE TABLE teachers (id INT,name VARCHAR(255),professional_development_hours INT); INSERT INTO teachers (id,name,professional_development_hours) VALUES (1,'James Smith',15),(2,'Jane Smith',25),(3,'Jim Smith',20); | SELECT name, professional_development_hours FROM teachers ORDER BY professional_development_hours ASC LIMIT 1; |
Delete all volunteer records who have not contributed in the last 6 months. | CREATE TABLE volunteers (id INT,name TEXT,last_activity DATE); | DELETE FROM volunteers WHERE volunteers.last_activity < DATE_SUB(CURDATE(), INTERVAL 6 MONTH); |
Delete the entry for wind turbine with id 4 in the 'renewable_energy' table | CREATE TABLE renewable_energy (id INT,type VARCHAR(50),capacity INT); | DELETE FROM renewable_energy WHERE id = 4 AND type = 'wind turbine'; |
What is the total number of infrastructure projects in the 'rural_infrastructure' table? | CREATE TABLE rural_infrastructure (project_id INT,project_name TEXT,start_date DATE,end_date DATE,budget INT); INSERT INTO rural_infrastructure (project_id,project_name,start_date,end_date,budget) VALUES (1,'Water Supply','2021-01-01','2021-12-31',100000),(2,'Road Construction','2020-04-01','2020-12-31',150000); | SELECT COUNT(*) FROM rural_infrastructure; |
List the wildlife species in descending order of their presence in the forest? | CREATE TABLE wildlife_sightings (id INT,species VARCHAR(255),sighting_date DATE); | SELECT species, COUNT(*) as sighting_count FROM wildlife_sightings GROUP BY species ORDER BY sighting_count DESC; |
List players who have played games in both the 'Action' and 'Puzzle' genres, with age over 25. | CREATE TABLE Action_Games (player_id INT,name VARCHAR(50),age INT,gender VARCHAR(10)); INSERT INTO Action_Games (player_id,name,age,gender) VALUES (1,'Alex Thompson',28,'Male'),(2,'Jessica Brown',30,'Female'),(3,'Samantha Johnson',26,'Female'); CREATE TABLE Puzzle_Games (player_id INT,name VARCHAR(50),age INT,gender VA... | SELECT age, gender FROM Action_Games WHERE player_id IN (SELECT player_id FROM Puzzle_Games) AND age > 25; |
What is the total value of investments in commodities for clients in Texas, excluding clients with a risk level of 'medium'? | CREATE TABLE ClientInvestments (ClientID INT,InvestmentType VARCHAR(20),Value FLOAT); INSERT INTO ClientInvestments (ClientID,InvestmentType,Value) VALUES (1,'Stock',10000),(1,'Commodity',20000),(2,'Stock',30000),(3,'Bond',15000),(4,'Commodity',35000),(5,'Stock',12000),(6,'Commodity',40000); CREATE TABLE Clients (Clien... | SELECT SUM(Value) FROM ClientInvestments CI JOIN Clients C ON CI.ClientID = C.ClientID WHERE C.State = 'TX' AND InvestmentType = 'Commodity' AND C.RiskLevel != 'medium'; |
How many satellites have been launched by countries in the Asia-Pacific region? | CREATE TABLE satellites (id INT,name VARCHAR(255),country VARCHAR(255),launch_date DATE); CREATE VIEW asia_pacific_countries AS SELECT * FROM countries WHERE region = 'Asia-Pacific'; | SELECT COUNT(*) FROM satellites JOIN asia_pacific_countries ON satellites.country = asia_pacific_countries.country; |
What is the total funding received by companies founded by African American individuals before 2010? | CREATE TABLE founders (id INT,name VARCHAR(50),ethnicity VARCHAR(20),company_id INT,founding_year INT); CREATE TABLE funding (id INT,company_id INT,amount INT); | SELECT SUM(funding.amount) FROM funding JOIN founders ON funding.company_id = founders.company_id WHERE founders.ethnicity = 'African American' AND founders.founding_year < 2010; |
What is the total revenue of products that are ethically sourced? | CREATE TABLE products (product_id INT,is_ethically_sourced BOOLEAN); INSERT INTO products (product_id,is_ethically_sourced) VALUES (1,true),(2,false),(3,true); CREATE TABLE sales (product_id INT,revenue INT); INSERT INTO sales (product_id,revenue) VALUES (1,100),(2,200),(3,300); | SELECT SUM(sales.revenue) FROM sales INNER JOIN products ON sales.product_id = products.product_id WHERE products.is_ethically_sourced = true; |
Identify the vessel names with a maximum speed over 40 knots, and their corresponding loading capacities | CREATE TABLE Vessels (VesselID INT,VesselName VARCHAR(100),MaxSpeed FLOAT,LoadingCapacity FLOAT); INSERT INTO Vessels (VesselID,VesselName,MaxSpeed,LoadingCapacity) VALUES (1,'Poseidon',42.3,95000),(2,'Neptune',38.1,70000),(3,'Triton',45.6,105000),(4,'Odyssey',29.9,60000); | SELECT VesselName, LoadingCapacity FROM Vessels WHERE MaxSpeed > 40; |
How many public transportation services are there in total? | CREATE TABLE Transportation (Name VARCHAR(255),Type VARCHAR(255)); INSERT INTO Transportation (Name,Type) VALUES ('Bus A','Public'),('Bus B','Public'),('Train C','Public'),('Train D','Public'),('Taxi E','Private'),('Taxi F','Private'); | SELECT COUNT(*) FROM Transportation WHERE Type = 'Public'; |
What is the average transaction amount for each customer in the past year? | CREATE TABLE customers (customer_id INT,name VARCHAR(50)); CREATE TABLE transactions (transaction_id INT,customer_id INT,transaction_amount DECIMAL(10,2)); INSERT INTO customers (customer_id,name) VALUES (1,'Alex Johnson'); INSERT INTO customers (customer_id,name) VALUES (2,'Bella Smith'); INSERT INTO transactions (tra... | SELECT customer_id, AVG(transaction_amount) as avg_transaction_amount FROM transactions WHERE transaction_date BETWEEN DATEADD(year, -1, GETDATE()) AND GETDATE() GROUP BY customer_id; |
What is the total claim amount for policies in the 'life_insurance' table for male policyholders? | CREATE TABLE life_insurance (policy_id INT,policyholder_gender VARCHAR(10),claim_amount DECIMAL(10,2)); INSERT INTO life_insurance (policy_id,policyholder_gender,claim_amount) VALUES (1,'Male',500.00),(2,'Female',750.00),(3,'Male',1000.00),(4,'Female',250.00); | SELECT SUM(claim_amount) FROM life_insurance WHERE policyholder_gender = 'Male'; |
What is the minimum donation amount in the "library_donors" table? | CREATE TABLE library_donors (donor_id INT,donation_amount FLOAT,donation_date DATE); INSERT INTO library_donors (donor_id,donation_amount,donation_date) VALUES (1,50.00,'2021-01-01'),(2,75.00,'2021-02-01'),(3,100.00,'2021-03-01'); | SELECT MIN(donation_amount) FROM library_donors; |
How many marine species have been impacted by ocean acidification, and what are their names? | CREATE TABLE ocean_acidification_impact (species_name TEXT,impact_level INTEGER); | SELECT COUNT(species_name), species_name FROM ocean_acidification_impact GROUP BY species_name; |
Delete all records of makeup products from Australia. | CREATE TABLE products (id INT,name TEXT,product_type TEXT,country TEXT); | DELETE FROM products WHERE product_type = 'makeup' AND country = 'Australia'; |
List all peacekeeping operations led by the African Union in 2019. | CREATE TABLE peacekeeping_operations (org_name VARCHAR(255),year INT,operation_name VARCHAR(255)); INSERT INTO peacekeeping_operations (org_name,year,operation_name) VALUES ('African Union',2019,'African Union Mission in Somalia'),('African Union',2019,'Multinational Joint Task Force'); | SELECT operation_name FROM peacekeeping_operations WHERE org_name = 'African Union' AND year = 2019; |
List the top 3 countries by the number of accessible technology initiatives. | CREATE TABLE countries (id INT,name VARCHAR(50),accessible_tech_initiatives INT); INSERT INTO countries (id,name,accessible_tech_initiatives) VALUES (1,'USA',50),(2,'Canada',30),(3,'Mexico',20),(4,'Brazil',40); | SELECT name, ROW_NUMBER() OVER (ORDER BY accessible_tech_initiatives DESC) as rank FROM countries; |
What was the total sales revenue for DrugA in Q1 2020? | CREATE TABLE sales (drug varchar(255),quarter varchar(255),revenue int); INSERT INTO sales (drug,quarter,revenue) VALUES ('DrugA','Q1 2020',500000),('DrugA','Q2 2020',600000); | SELECT revenue FROM sales WHERE drug = 'DrugA' AND quarter = 'Q1 2020'; |
What is the total energy storage capacity in each state in the US? | CREATE TABLE energy_storage (id INT,state VARCHAR(255),capacity INT); INSERT INTO energy_storage (id,state,capacity) VALUES (1,'California',60000),(2,'Texas',50000),(3,'California',65000),(4,'Texas',55000); | SELECT state, SUM(capacity) as total_capacity FROM energy_storage GROUP BY state; |
What is the average donation amount for recurring donors from the United Kingdom? | CREATE TABLE Donors (DonorID INT,DonorName TEXT,Country TEXT,IsRecurring BOOLEAN); INSERT INTO Donors (DonorID,DonorName,Country,IsRecurring) VALUES (1,'John Doe','UK',TRUE),(2,'Jane Smith','Canada',FALSE); | SELECT AVG(DonationAmount) FROM Donations INNER JOIN Donors ON Donations.DonorID = Donors.DonorID WHERE Donors.Country = 'UK' AND Donors.IsRecurring = TRUE; |
Add a new record to the "public_health_policies" table for a policy in "MN" regarding vaccination | CREATE TABLE public_health_policies (id INT PRIMARY KEY,name TEXT,state TEXT,policy_topic TEXT); INSERT INTO public_health_policies (id,name,state,policy_topic) VALUES (1,'Policy 1','AK','Healthcare Access'),(2,'Policy 2','HI','Infectious Disease'),(3,'Policy 3','GA','Community Health'); | INSERT INTO public_health_policies (name, state, policy_topic) VALUES ('Vaccination Policy', 'MN', 'Vaccination'); |
What is the total production of organic crops by region? | CREATE TABLE organic_crops (id INT,region VARCHAR(255),production INT); | SELECT region, SUM(production) as total_production FROM organic_crops GROUP BY region; |
List unique chemical types used in the bottom 2 facilities by production volume. | CREATE TABLE facility_production (name VARCHAR(50),product VARCHAR(20),quantity INT); INSERT INTO facility_production VALUES ('facility C','chemical F',150); INSERT INTO facility_production VALUES ('facility D','chemical G',180); | SELECT DISTINCT product FROM (SELECT facility, product, ROW_NUMBER() OVER (PARTITION BY facility ORDER BY quantity DESC) AS rn FROM facility_production) tmp WHERE rn > 2; |
What is the total number of fish farmed in each country? | CREATE TABLE FishFarmingCountries (CountryID INT,CountryName VARCHAR(50),Quantity INT); INSERT INTO FishFarmingCountries VALUES (1,'USA',3500),(2,'Canada',2000),(3,'Mexico',1800); | SELECT CountryName, SUM(Quantity) FROM FishFarmingCountries GROUP BY CountryName; |
What are the names of Indigenous artisans who specialize in weaving? | CREATE TABLE Artisans (ArtisanID INT PRIMARY KEY,Name VARCHAR(100),Specialty VARCHAR(50),Nation VARCHAR(50)); INSERT INTO Artisans (ArtisanID,Name,Specialty,Nation) VALUES (1,'Marie Smith','Weaving','Navajo'),(2,'Pedro Gonzales','Pottery','Maya'); | SELECT Name FROM Artisans WHERE Specialty = 'Weaving' AND Nation = 'Navajo'; |
Add a new female member 'Sophia Garcia' aged 29 to the members table | CREATE TABLE members (member_id INT,name TEXT,age INT,gender TEXT); | INSERT INTO members (member_id, name, age, gender) VALUES (4, 'Sophia Garcia', 29, 'Female'); |
What is the average income in the city of 'San Francisco'? | CREATE TABLE city (name VARCHAR(255),income FLOAT); INSERT INTO city (name,income) VALUES ('San Francisco',96000),('Oakland',72000); | SELECT AVG(income) FROM city WHERE name = 'San Francisco'; |
Who are the top 3 readers by age that prefer print newspapers in 'Canada'? | CREATE TABLE readers (id INT,name TEXT,age INT,country TEXT); INSERT INTO readers VALUES (1,'John Doe',30,'USA'); INSERT INTO readers VALUES (2,'Jane Smith',35,'Canada'); CREATE TABLE preferences (id INT,reader_id INT,newspaper_type TEXT); INSERT INTO preferences VALUES (1,1,'digital'); INSERT INTO preferences VALUES... | SELECT readers.name, readers.age FROM readers INNER JOIN preferences ON readers.id = preferences.reader_id WHERE readers.country = 'Canada' AND preferences.newspaper_type = 'print' ORDER BY readers.age DESC LIMIT 3; |
Who are the top 5 users with the most failed login attempts in the last week? | CREATE TABLE login_attempts (user_id INT,timestamp TIMESTAMP); INSERT INTO login_attempts (user_id,timestamp) VALUES (1,'2022-01-01 10:00:00'),(2,'2022-01-02 15:30:00'),(1,'2022-01-03 08:45:00'),(3,'2022-01-04 14:20:00'),(4,'2022-01-05 21:00:00'),(1,'2022-01-06 06:15:00'),(5,'2022-01-07 12:30:00'),(1,'2022-01-07 19:45:... | SELECT user_id, COUNT(*) as failed_login_attempts FROM login_attempts WHERE timestamp >= '2022-01-01 00:00:00' AND timestamp < '2022-01-08 00:00:00' GROUP BY user_id ORDER BY failed_login_attempts DESC LIMIT 5; |
Who are the top 2 contributors to explainable AI research? | CREATE TABLE explainable_ai_research (researcher_name TEXT,num_papers INTEGER); INSERT INTO explainable_ai_research (researcher_name,num_papers) VALUES ('Alice',12),('Bob',15),('Carol',8); | SELECT researcher_name FROM explainable_ai_research ORDER BY num_papers DESC LIMIT 2; |
What is the minimum number of workers employed on a single project in the 'project_employment' table, grouped by project type? | CREATE TABLE project_employment (project_name VARCHAR(255),project_type VARCHAR(255),num_workers INT); | select project_type, min(num_workers) as min_workers from project_employment group by project_type; |
What is the average temperature anomaly for each ocean basin? | CREATE TABLE temperature_anomalies (id INT,year INT,ocean_basin VARCHAR(50),temperature_anomaly FLOAT); INSERT INTO temperature_anomalies (id,year,ocean_basin,temperature_anomaly) VALUES (1,2020,'Pacific Ocean',1.2); INSERT INTO temperature_anomalies (id,year,ocean_basin,temperature_anomaly) VALUES (2,2020,'Atlantic Oc... | SELECT ocean_basin, AVG(temperature_anomaly) FROM temperature_anomalies GROUP BY ocean_basin; |
What is the total production of wheat in each country in the 'agriculture' database? | CREATE TABLE production (id INT,crop VARCHAR(255),country VARCHAR(255),quantity INT); INSERT INTO production (id,crop,country,quantity) VALUES (1,'wheat','USA',5000000),(2,'wheat','Canada',3000000),(3,'rice','China',8000000),(4,'wheat','Australia',2500000); | SELECT country, SUM(quantity) as total_production FROM production WHERE crop = 'wheat' GROUP BY country; |
What is the total funding allocated for climate adaptation initiatives in island nations in the Pacific region? | CREATE TABLE climate_adaptation_pacific (country VARCHAR(50),initiative VARCHAR(50),funding DECIMAL(10,2)); INSERT INTO climate_adaptation_pacific (country,initiative,funding) VALUES ('Palau','Coral Reef Protection',5000000),('Vanuatu','Coastal Erosion Control',6000000); | SELECT SUM(funding) FROM climate_adaptation_pacific WHERE country IN ('Fiji', 'Jamaica', 'Maldives', 'Philippines', 'Haiti', 'Palau', 'Vanuatu'); |
Insert a new record into the 'calibration_data' table with 'algorithm' = 'Deep Learning', 'precision' = 0.8, 'recall' = 0.7 | CREATE TABLE calibration_data (id INT,algorithm VARCHAR(20),precision DECIMAL(3,2),recall DECIMAL(3,2)); INSERT INTO calibration_data (id,algorithm,precision,recall) VALUES (1,'Deep Learning',0.8,0.7); | INSERT INTO calibration_data (algorithm, precision, recall) VALUES ('Deep Learning', 0.8, 0.7); |
Which community policing programs were implemented in Seattle in 2020? | CREATE TABLE community_policing (id INT,program VARCHAR(30),city VARCHAR(20),start_year INT); INSERT INTO community_policing (id,program,city,start_year) VALUES (1,'Coffee with a Cop','Seattle',2018),(2,'Block Watch','Seattle',2019),(3,'Community Police Academy','Seattle',2020); | SELECT program, city FROM community_policing WHERE city = 'Seattle' AND start_year = 2020; |
How many pallets are currently stored in each warehouse, categorized by warehouse location and environmental conditions? | CREATE TABLE warehouses (id INT,location VARCHAR(50),environmental_conditions VARCHAR(50),pallets INT); INSERT INTO warehouses (id,location,environmental_conditions,pallets) VALUES (1,'Urban','Temperature Controlled',200),(2,'Rural','Dry',300),(3,'Coastal','Humidity Controlled',150); | SELECT location, environmental_conditions, SUM(pallets) as total_pallets FROM warehouses GROUP BY location, environmental_conditions; |
How many accidents were reported for each vessel type in the Indian Ocean? | CREATE TABLE accidents (id INT,vessel_name VARCHAR(255),vessel_type VARCHAR(255),latitude DECIMAL(9,6),longitude DECIMAL(9,6),accident_date DATE); INSERT INTO accidents (id,vessel_name,vessel_type,latitude,longitude,accident_date) VALUES (1,'VesselA','Tanker',12.879444,77.567445,'2021-12-31'); | SELECT vessel_type, COUNT(*) as num_accidents FROM accidents WHERE latitude BETWEEN -35.0 AND -5.0 AND longitude BETWEEN 20.0 AND 120.0 GROUP BY vessel_type; |
Which devices have been installed in the last 6 months? | CREATE TABLE installations (id INT,installation_date DATE,device_id INT); | SELECT device_id FROM installations WHERE installation_date >= DATE(NOW()) - INTERVAL 6 MONTH; |
What is the total quantity of organic fruits and vegetables sold by suppliers in the Midwest? | CREATE TABLE suppliers (supplier_id INT,supplier_name TEXT,region TEXT);CREATE TABLE inventory (product_id INT,product_name TEXT,category TEXT,quantity INT);INSERT INTO suppliers VALUES (1,'Supplier A','Midwest'),(2,'Supplier B','Northeast');INSERT INTO inventory VALUES (100,'Apples','Organic Fruits',500),(101,'Bananas... | SELECT SUM(quantity) FROM inventory INNER JOIN suppliers ON TRUE WHERE category IN ('Organic Fruits', 'Organic Vegetables') AND suppliers.region = 'Midwest'; |
Who are the volunteers who have donated more than $1000 in the last 12 months? | CREATE TABLE donor_volunteers (id INT,volunteer_id INT,donation_amount DECIMAL(10,2)); | SELECT first_name, last_name FROM volunteers JOIN donor_volunteers ON volunteers.id = donor_volunteers.volunteer_id WHERE donation_amount > 1000 AND DATEDIFF(CURDATE(), volunteers.last_donation_date) <= 365; |
What is the name of the client with the lowest financial wellbeing score, and the rank of their score compared to other clients in the financial wellbeing database? | CREATE TABLE financial_wellbeing (client_id INT,name TEXT,score INT); INSERT INTO financial_wellbeing (client_id,name,score) VALUES (5,'Harry',60),(6,'Sally',65),(7,'George',50); | SELECT name, ROW_NUMBER() OVER (ORDER BY score) AS score_rank FROM financial_wellbeing WHERE score = (SELECT MIN(score) FROM financial_wellbeing); |
Which professional development courses were completed by the most teachers in the past year? | CREATE TABLE teachers (teacher_id INT,teacher_name TEXT); INSERT INTO teachers (teacher_id,teacher_name) VALUES (1,'Teacher A'),(2,'Teacher B'),(3,'Teacher C'); CREATE TABLE courses (course_id INT,course_name TEXT,year INT); INSERT INTO courses (course_id,course_name,year) VALUES (1,'Course X',2021),(2,'Course Y',2021)... | SELECT c.course_name, COUNT(tc.teacher_id) as num_teachers FROM teacher_courses tc JOIN courses c ON tc.course_id = c.course_id WHERE c.year = 2021 GROUP BY c.course_name ORDER BY num_teachers DESC LIMIT 1; |
What is the minimum number of safety incidents in the automotive industry in Brazil? | CREATE TABLE incidents (id INT,company VARCHAR(50),country VARCHAR(50),industry VARCHAR(50),number INT); | SELECT MIN(number) FROM incidents WHERE country = 'Brazil' AND industry = 'Automotive'; |
What is the maximum daily water consumption for a household in Miami? | CREATE TABLE Households (id INT,city VARCHAR(20),daily_consumption FLOAT); INSERT INTO Households (id,city,daily_consumption) VALUES (1,'Miami',450.5),(2,'Miami',478.9),(3,'Orlando',350.6); | SELECT MAX(daily_consumption) FROM Households WHERE city = 'Miami'; |
What is the name of the African country with the most international visitors in the last 6 months? | CREATE TABLE international_visitors (visitor_id INT,country TEXT,arrival_date DATE); INSERT INTO international_visitors (visitor_id,country,arrival_date) VALUES (1,'South Africa','2022-01-01'),(2,'Morocco','2022-02-01'),(3,'Egypt','2022-03-01'),(4,'Kenya','2022-04-01'),(5,'Tanzania','2022-05-01'),(6,'Nigeria','2022-06-... | SELECT country FROM international_visitors WHERE arrival_date >= DATE('now', '-6 month') GROUP BY country ORDER BY COUNT(*) DESC LIMIT 1; |
How many rare earth element mines in Canada have production rates above 5? | CREATE TABLE canada_ree_mines (id INT,name TEXT,location TEXT,production_rate FLOAT); INSERT INTO canada_ree_mines (id,name,location,production_rate) VALUES (1,'Strange Lake','Quebec,Canada',7.2),(2,'Kipawa','Quebec,Canada',6.3),(3,'Hoidas Lake','Saskatchewan,Canada',4.5); | SELECT COUNT(*) FROM canada_ree_mines WHERE location LIKE '%Canada%' AND production_rate > 5; |
What is the percentage of students utilizing assistive technology in each program? | CREATE TABLE TechPrograms (program_name VARCHAR(255),num_students INT); INSERT INTO TechPrograms (program_name,num_students) VALUES ('Program A',50); INSERT INTO TechPrograms (program_name,num_students) VALUES ('Program B',60); INSERT INTO TechPrograms (program_name,num_students) VALUES ('Program C',70); CREATE TABLE... | SELECT P.program_name, ROUND(COUNT(DISTINCT A.student_id) * 100.0 / P.num_students, 1) as tech_percentage FROM TechPrograms P LEFT JOIN AssistiveTech A ON P.program_name = A.program_name WHERE tech_type IS NOT NULL GROUP BY P.program_name; |
What is the total number of traditional art pieces donated by individuals and organizations in Africa? | CREATE TABLE Donations (id INT,donor VARCHAR(50),item VARCHAR(50),location VARCHAR(50),quantity INT); INSERT INTO Donations (id,donor,item,location,quantity) VALUES (1,'John Doe','Painting','Nigeria',3),(2,'Jane Smith','Sculpture','Kenya',5),(3,'ABC Corp','Ceramics','Egypt',7); | SELECT SUM(quantity) FROM Donations WHERE location LIKE 'Africa%'; |
List the names and locations of all rural infrastructure projects in 'rural_infrastructure' table with a budget over $100,000? | CREATE TABLE rural_infrastructure (id INT,name VARCHAR(50),budget INT,location VARCHAR(50)); INSERT INTO rural_infrastructure (id,name,budget,location) VALUES (1,'Water Treatment Plant',150000,'Urban Missouri'); INSERT INTO rural_infrastructure (id,name,budget,location) VALUES (2,'Road Construction',75000,'Rural Alabam... | SELECT name, location FROM rural_infrastructure WHERE budget > 100000; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.