instruction stringlengths 0 1.06k | input stringlengths 11 5.3k | response stringlengths 2 4.44k |
|---|---|---|
Create a view to display all unique legal precedents | CREATE TABLE case_outcomes (case_id INT,outcome TEXT,precedent TEXT); | CREATE VIEW unique_precedents AS SELECT DISTINCT precedent FROM case_outcomes; |
List all volunteers who have worked in program A or B, along with their total hours. | CREATE TABLE Volunteers (VolunteerID INT,Name TEXT); INSERT INTO Volunteers VALUES (1,'Mike Johnson'),(2,'Sara Jones'); CREATE TABLE VolunteerPrograms (VolunteerID INT,Program TEXT,Hours DECIMAL); INSERT INTO VolunteerPrograms VALUES (1,'Program A',20.00),(1,'Program B',15.00),(2,'Program A',25.00); | SELECT v.Name, SUM(vp.Hours) as TotalHours FROM Volunteers v INNER JOIN VolunteerPrograms vp ON v.VolunteerID = vp.VolunteerID WHERE vp.Program IN ('Program A', 'Program B') GROUP BY v.Name; |
What is the number of community policing events in the city of Miami, broken down by the day of the week? | CREATE TABLE miami_community_policing (id INT,city VARCHAR(20),neighborhood VARCHAR(20),event_type VARCHAR(20),date DATE); INSERT INTO miami_community_policing (id,city,neighborhood,event_type,date) VALUES (1,'Miami','Downtown','meeting','2021-01-01'); INSERT INTO miami_community_policing (id,city,neighborhood,event_ty... | SELECT DATEPART(dw, date) AS day_of_week, COUNT(*) AS event_count FROM miami_community_policing WHERE city = 'Miami' GROUP BY DATEPART(dw, date) ORDER BY day_of_week |
What is the minimum heart rate variability for users who have achieved a specific recovery milestone? | CREATE TABLE Recovery (id INT,user_id INT,milestone TEXT,variability FLOAT); INSERT INTO Recovery (id,user_id,milestone,variability) VALUES (1,1,'full recovery',60.5),(2,2,'partial recovery',55.3); | SELECT MIN(variability) FROM Recovery WHERE milestone = 'full recovery'; |
What is the average rating of hotels in 'Paris'? | CREATE TABLE hotels (id INT,name TEXT,city TEXT,rating FLOAT); INSERT INTO hotels (id,name,city,rating) VALUES (1,'Hotel Ritz','Paris',4.8),(2,'Hotel George V','Paris',4.9); | SELECT AVG(rating) FROM hotels WHERE city = 'Paris'; |
List the names and types of renewable energy projects with their corresponding carbon offset values from the projects and carbon_offsets tables. | CREATE TABLE projects(id INT,project_name VARCHAR(50),project_type VARCHAR(50));CREATE TABLE carbon_offsets(project_id INT,carbon_offset_value INT); | SELECT p.project_name, p.project_type, co.carbon_offset_value FROM projects p INNER JOIN carbon_offsets co ON p.id = co.project_id; |
How many doctors are there in Asia? | CREATE TABLE Country (name VARCHAR(50),doctor_count INT); INSERT INTO Country (name,doctor_count) VALUES ('China',2831000),('India',1194700); | SELECT SUM(doctor_count) FROM Country WHERE name IN ('China', 'India'); |
What is the total investment in economic diversification projects in Indonesia and Malaysia? | CREATE TABLE eco_diversification (id INT,name TEXT,location TEXT,investment FLOAT); INSERT INTO eco_diversification (id,name,location,investment) VALUES (1,'Renewable Energy','Indonesia',750000.00),(2,'Tourism Infrastructure','Malaysia',600000.00); | SELECT SUM(investment) FROM eco_diversification WHERE location IN ('Indonesia', 'Malaysia'); |
List the top 2 countries with the most agricultural automation patents filed in the last 6 months. | CREATE TABLE automation_patents (id INT,country VARCHAR(255),patent_date DATE); INSERT INTO automation_patents (id,country,patent_date) VALUES (1,'Germany','2021-12-17'),(2,'Australia','2022-01-01'),(3,'Germany','2022-01-03'),(4,'Japan','2022-01-04'),(5,'Australia','2022-01-02'); | SELECT country, COUNT(*) as patent_count FROM automation_patents WHERE patent_date >= DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH) GROUP BY country ORDER BY patent_count DESC LIMIT 2; |
What is the total revenue for 'Organic Cafe' in January 2021?' | CREATE TABLE Restaurants (restaurant_id INT,name VARCHAR(50),revenue INT); INSERT INTO Restaurants (restaurant_id,name,revenue) VALUES (1,'Organic Cafe',5000); | SELECT SUM(revenue) FROM Restaurants WHERE name = 'Organic Cafe' AND EXTRACT(MONTH FROM timestamp) = 1 AND EXTRACT(YEAR FROM timestamp) = 2021; |
List all the unique sizes available in the 'Customer_Sizes' table, excluding 'One Size' entries. | CREATE TABLE Customer_Sizes (size VARCHAR(10)); INSERT INTO Customer_Sizes (size) VALUES ('Small'),('Medium'),('Large'),('One Size'); | SELECT DISTINCT size FROM Customer_Sizes WHERE size != 'One Size'; |
What is the maximum number of absences for a student in the mental health program in the past month? | CREATE TABLE students (id INT,name VARCHAR(50),program VARCHAR(50),absences INT,last_visit DATE); | SELECT MAX(absences) FROM students WHERE program = 'mental health' AND last_visit >= DATE_SUB(CURDATE(), INTERVAL 1 MONTH); |
Delete all records from the 'public_transit' table where the 'route_type' is 'Tram' | CREATE TABLE public_transit (route_id INT,num_passengers INT,route_type VARCHAR(255),route_length FLOAT); | DELETE FROM public_transit WHERE route_type = 'Tram'; |
What is the average height of bridges in Japan and Indonesia? | CREATE TABLE bridges (id INT,country VARCHAR(255),bridge_name VARCHAR(255),height INT); INSERT INTO bridges (id,country,bridge_name,height) VALUES (1,'Japan','Akashi Kaikyō',298),(2,'Japan','Kobe Port Tower',108),(3,'Indonesia','Suramadu',120),(4,'Indonesia','Semenanjung',65); | SELECT country, AVG(height) FROM bridges GROUP BY country; |
Insert new defense contract records for contracts awarded in Q3 2022 | CREATE TABLE DefenseContracts (ID INT,Vendor TEXT,Amount DECIMAL(10,2),Quarter INT); INSERT INTO DefenseContracts (ID,Vendor,Amount,Quarter) VALUES (1,'Vendor X',200000.00,3),(2,'Vendor Y',300000.00,3); | INSERT INTO DefenseContracts (ID, Vendor, Amount, Quarter) VALUES (3, 'Vendor Z', 150000.00, 3), (4, 'Vendor W', 400000.00, 3); |
List the types of community engagement events, their total attendance, and the number of unique visitors for each museum in the past 6 months, sorted by museum. | CREATE TABLE Museum (Id INT,Name VARCHAR(100)); CREATE TABLE CommunityEvent (Id INT,MuseumId INT,EventType VARCHAR(50),Attendance INT,EventDate DATE); | SELECT MuseumId, m.Name, EventType, SUM(Attendance) as TotalAttendance, COUNT(DISTINCT v.VisitorId) as UniqueVisitors FROM Museum m JOIN CommunityEvent ce ON m.Id = ce.MuseumId JOIN (SELECT VisitorId, ROW_NUMBER() OVER (ORDER BY EventDate DESC) as RowNum FROM CommunityEvent WHERE EventDate >= DATEADD(MONTH, -6, CURRENT... |
What is the sum of construction material costs for sustainable projects in Florida? | CREATE TABLE construction_projects (id INT,project_name TEXT,state TEXT,material_cost FLOAT,is_sustainable BOOLEAN); INSERT INTO construction_projects (id,project_name,state,material_cost,is_sustainable) VALUES (1,'Park Plaza','Texas',50000.00,false),(2,'Downtown Tower','California',150000.00,true),(3,'Galleria Mall','... | SELECT SUM(material_cost) FROM construction_projects WHERE state = 'Florida' AND is_sustainable = true; |
What is the total quantity of cotton textiles sourced from the USA and Canada? | CREATE TABLE sourcing (country VARCHAR(10),material VARCHAR(10),quantity INT); INSERT INTO sourcing (country,material,quantity) VALUES ('USA','cotton',3000),('Canada','cotton',2500),('Mexico','polyester',1500); | SELECT SUM(quantity) FROM sourcing WHERE country IN ('USA', 'Canada') AND material = 'cotton'; |
Show the number of property owners for each property | CREATE TABLE property_owners (property_id INT,owner_id INT); INSERT INTO property_owners (property_id,owner_id) VALUES (1,10),(1,11),(2,12),(3,13),(3,14); | SELECT properties.property_id, COUNT(DISTINCT property_owners.owner_id) FROM properties JOIN property_owners ON properties.property_id = property_owners.property_id GROUP BY properties.property_id; |
What is the maximum power output in watts for renewable energy sources in India and Brazil? | CREATE TABLE renewable_power (country VARCHAR(50),power_watts INT); INSERT INTO renewable_power (country,power_watts) VALUES ('India',428000),('Brazil',340000); | SELECT MAX(power_watts) FROM renewable_power WHERE country IN ('India', 'Brazil'); |
What is the average response time for fire incidents in each neighborhood in district 1? | CREATE TABLE districts (id INT,name VARCHAR(255)); INSERT INTO districts (id,name) VALUES (1,'Eastside'); CREATE TABLE neighborhoods (id INT,district_id INT,name VARCHAR(255)); INSERT INTO neighborhoods (id,district_id,name) VALUES (10,1,'Downtown'); INSERT INTO neighborhoods (id,district_id,name) VALUES (11,1,'Harbors... | SELECT neighborhoods.name, AVG(emergency_incidents.response_time) AS avg_response_time FROM neighborhoods JOIN emergency_incidents ON neighborhoods.id = emergency_incidents.neighborhood_id WHERE emergency_incidents.incident_type = 'fire' GROUP BY neighborhoods.name; |
Which AI safety research topics intersect with creative AI application topics? | CREATE TABLE if not exists safety_research (research_id INT PRIMARY KEY,topic TEXT); INSERT INTO safety_research (research_id,topic) VALUES (1,'Robustness'),(2,'Fairness'),(3,'Interpretability'); CREATE TABLE if not exists creative_ai_topics (topic_id INT PRIMARY KEY,topic TEXT); INSERT INTO creative_ai_topics (topic_i... | SELECT DISTINCT safety_research.topic FROM safety_research JOIN creative_ai_topics ON safety_research.topic = creative_ai_topics.topic; |
How many eco-friendly hotels are there in each city? | CREATE TABLE eco_hotels (hotel_id INT,name TEXT,city TEXT); INSERT INTO eco_hotels (hotel_id,name,city) VALUES (1,'Green Hotel','Paris'),(2,'Eco Lodge','Paris'),(3,'Eco Retreat','Rome'); | SELECT city, COUNT(*) FROM eco_hotels GROUP BY city; |
What is the percentage of climate communication projects in North America? | CREATE TABLE climate_projects_north_america (id INT,country VARCHAR(50),sector VARCHAR(50),funding FLOAT); INSERT INTO climate_projects_north_america (id,country,sector,funding) VALUES (1,'United States','Climate Mitigation',6000000); INSERT INTO climate_projects_north_america (id,country,sector,funding) VALUES (2,'Uni... | SELECT 100.0 * COUNT(*) / (SELECT COUNT(*) FROM climate_projects_north_america) AS percentage FROM climate_projects_north_america WHERE sector = 'Climate Communication'; |
Identify the top 3 genetic research projects by country with the highest R&D investment. | CREATE SCHEMA if not exists genetics;CREATE TABLE if not exists genetics.projects (id INT,name VARCHAR(50),country VARCHAR(50),rd_investment DECIMAL(10,2)); INSERT INTO genetics.projects (id,name,country,rd_investment) VALUES (1,'ProjectX','UK',3000000.00),(2,'ProjectY','Germany',2500000.00),(3,'ProjectZ','UK',2000000.... | SELECT country, name, rd_investment FROM genetics.projects ORDER BY rd_investment DESC LIMIT 3; |
What was the total cost of space missions led by astronauts from the United States? | CREATE TABLE Astronauts (AstronautID INT,Name VARCHAR(50),Nationality VARCHAR(50));CREATE TABLE SpaceMissions (MissionID INT,AstronautID INT,Name VARCHAR(50),Cost FLOAT); INSERT INTO Astronauts (AstronautID,Name,Nationality) VALUES (1,'Mark Watney','USA'),(2,'Melissa Lewis','USA'); INSERT INTO SpaceMissions (MissionID,... | SELECT SUM(sm.Cost) FROM SpaceMissions sm INNER JOIN Astronauts a ON sm.AstronautID = a.AstronautID WHERE a.Nationality = 'USA'; |
What is the total quantity of sustainable material used by each brand, ordered by the total quantity in descending order? | CREATE TABLE Brands(Brand_ID INT,Brand_Name TEXT,Sustainable_Material_ID INT,Quantity INT); INSERT INTO Brands(Brand_ID,Brand_Name,Sustainable_Material_ID,Quantity) VALUES (1,'H&M',1,500),(2,'Zara',2,600),(3,'Levi''s',1,400),(4,'Everlane',2,700); | SELECT Brand_Name, SUM(Quantity) as Total_Quantity FROM Brands GROUP BY Brand_Name ORDER BY Total_Quantity DESC; |
What is the total military equipment sales revenue for each country in Europe? | CREATE TABLE military_equipment_sales(id INT,country VARCHAR(20),equipment_type VARCHAR(20),quantity INT,sale_price FLOAT); | SELECT country, SUM(quantity * sale_price) FROM military_equipment_sales WHERE country IN ('United Kingdom', 'France', 'Germany', 'Italy', 'Spain') GROUP BY country; |
What is the minimum number of tracks for railways in New York? | CREATE TABLE Railways (id INT,name TEXT,location TEXT,state TEXT,tracks INT); INSERT INTO Railways (id,name,location,state,tracks) VALUES (1,'Railway A','Location A','New York',4),(2,'Railway B','Location B','New Jersey',2); | SELECT MIN(tracks) FROM Railways WHERE state = 'New York'; |
What is the PERCENT_RANK of each office capacity within their location? | CREATE TABLE offices (id INT PRIMARY KEY,name VARCHAR(50),capacity INT,location VARCHAR(50)); INSERT INTO offices (id,name,capacity,location) VALUES (1,'Headquarters',500,'Washington D.C.'); INSERT INTO offices (id,name,capacity,location) VALUES (2,'Branch',200,'Washington D.C.'); INSERT INTO offices (id,name,capacity,... | SELECT name, capacity, PERCENT_RANK() OVER (PARTITION BY location ORDER BY capacity DESC) AS percent_rank FROM offices; |
What is the average monthly data usage for 'ABC Internet' customers? | CREATE TABLE customers (id INT,name TEXT,isp TEXT,data_usage FLOAT); INSERT INTO customers (id,name,isp,data_usage) VALUES (1,'John Doe','ABC Internet',12.5),(2,'Jane Smith','XYZ Internet',4.0),(3,'Mike Johnson','ABC Internet',7.5); | SELECT AVG(data_usage) FROM customers WHERE isp = 'ABC Internet'; |
What is the maximum calorie burn for each user in the last month? | CREATE TABLE calories (id INT,user_id INT,calories INT,workout_date DATE); INSERT INTO calories (id,user_id,calories,workout_date) VALUES (1,1,500,'2022-01-01'),(2,2,600,'2022-01-15'); | SELECT user_id, MAX(calories) FROM calories WHERE workout_date BETWEEN DATE_SUB(CURRENT_DATE(), INTERVAL 1 MONTH) AND CURRENT_DATE() GROUP BY user_id; |
What is the average monthly rainfall in each region, ranked in descending order? | CREATE TABLE WeatherData (region VARCHAR(50),rainfall FLOAT,measurement_date DATE); INSERT INTO WeatherData (region,rainfall,measurement_date) VALUES ('North',80,'2022-01-01'),('South',60,'2022-01-01'),('East',90,'2022-01-01'),('West',70,'2022-01-01'); | SELECT region, AVG(rainfall) AS avg_rainfall FROM WeatherData GROUP BY region ORDER BY avg_rainfall DESC; |
List all the Solar Power projects in New York, USA | CREATE TABLE solar_projects_2 (project_id INT,name VARCHAR(50),location VARCHAR(50),capacity_mw FLOAT); INSERT INTO solar_projects_2 (project_id,name,location,capacity_mw) VALUES (1,'Solar Farm 2','New York',30.0); | SELECT * FROM solar_projects_2 WHERE location = 'New York'; |
Find the number of distinct animal species in each habitat | CREATE TABLE species (id INT,name VARCHAR(255));CREATE TABLE animals (id INT,species_id INT,habitat_id INT); INSERT INTO species (id,name) VALUES (1,'Lion'),(2,'Elephant'),(3,'Giraffe'); INSERT INTO animals (id,species_id,habitat_id) VALUES (1,1,2),(2,2,1),(3,3,2); | SELECT h.name AS habitat_name, COUNT(DISTINCT a.species_id) AS distinct_species FROM animals a INNER JOIN habitats h ON a.habitat_id = h.id GROUP BY h.name; |
Calculate the average horsepower of electric vehicles in the 'green_vehicles' table | CREATE TABLE green_vehicles (id INT PRIMARY KEY,make VARCHAR(50),model VARCHAR(50),year INT,type VARCHAR(50),horsepower INT); | SELECT AVG(horsepower) FROM green_vehicles WHERE type = 'Electric'; |
What is the earliest and latest appointment date for each healthcare provider in the "rural_clinics" table, partitioned by clinic location? | CREATE TABLE rural_clinics (clinic_location VARCHAR(255),healthcare_provider_name VARCHAR(255),appointment_date DATE); INSERT INTO rural_clinics (clinic_location,healthcare_provider_name,appointment_date) VALUES ('Location1','Provider1','2021-01-01'),('Location1','Provider1','2021-01-05'),('Location2','Provider2','2021... | SELECT clinic_location, healthcare_provider_name, MIN(appointment_date) OVER (PARTITION BY clinic_location, healthcare_provider_name) AS earliest_appointment_date, MAX(appointment_date) OVER (PARTITION BY clinic_location, healthcare_provider_name) AS latest_appointment_date FROM rural_clinics; |
What is the average length of songs (in seconds) by female artists in the Pop genre released between 2010 and 2020? | CREATE TABLE Artists (ArtistID INT,Name TEXT,Gender TEXT); INSERT INTO Artists (ArtistID,Name,Gender) VALUES (1,'Taylor Swift','Female'),(2,'Ariana Grande','Female'); CREATE TABLE Songs (SongID INT,Title TEXT,Length FLOAT,ArtistID INT,Genre TEXT,ReleaseYear INT); INSERT INTO Songs (SongID,Title,Length,ArtistID,Genre,Re... | SELECT AVG(Length) FROM Songs WHERE Gender = 'Female' AND Genre = 'Pop' AND ReleaseYear BETWEEN 2010 AND 2020; |
Count the number of vessels in the 'Cargo' category with a loading capacity of more than 50000 tons | CREATE TABLE VesselCategories (VesselID INT,Category VARCHAR(50),LoadingCapacity FLOAT); INSERT INTO VesselCategories (VesselID,Category,LoadingCapacity) VALUES (1,'Cargo',60000),(2,'Passenger',3000),(3,'Cargo',45000); | SELECT COUNT(*) FROM VesselCategories WHERE Category = 'Cargo' AND LoadingCapacity > 50000; |
Show the number of policies in 'NY' state having a coverage type of 'Third Party'. | CREATE TABLE Policy (PolicyID INT,PolicyholderID INT,Coverage VARCHAR(20),SumInsured DECIMAL(10,2)); INSERT INTO Policy (PolicyID,PolicyholderID,Coverage,SumInsured) VALUES (1,1,'Comprehensive',5000); INSERT INTO Policy (PolicyID,PolicyholderID,Coverage,SumInsured) VALUES (2,2,'Third Party',3000); CREATE TABLE Policyho... | SELECT COUNT(*) FROM Policy p JOIN Policyholder ph ON p.PolicyholderID = ph.PolicyholderID WHERE ph.State = 'NY' AND p.Coverage = 'Third Party'; |
Which beauty products in the 'haircare' category have a preference count of over 150 and are sold by suppliers with a sustainability score of 90 or higher, and what is the total revenue for these products? | CREATE TABLE consumer_preferences (id INT PRIMARY KEY,customer_id INT,product VARCHAR(100),preference INT,FOREIGN KEY (customer_id) REFERENCES customers(id)); CREATE TABLE beauty_products (id INT PRIMARY KEY,product VARCHAR(100),category VARCHAR(100),price FLOAT); CREATE TABLE suppliers (id INT PRIMARY KEY,name VARCHAR... | SELECT cp.product, SUM(cs.revenue) as total_revenue FROM consumer_preferences cp JOIN beauty_products bp ON cp.product = bp.product JOIN cosmetics_sales cs ON cp.product = cs.product JOIN suppliers s ON cs.supplier_id = s.id WHERE bp.category = 'haircare' AND cp.preference > 150 AND s.sustainability_score >= 90 GROUP B... |
What is the maximum heart rate for each user, sorted by gender? | CREATE TABLE workout_data (id INT,user_id INT,heart_rate INT,date DATE); INSERT INTO workout_data (id,user_id,heart_rate,date) VALUES (1,1,120,'2022-01-01'),(2,1,125,'2022-01-02'),(3,2,130,'2022-01-01'),(4,2,135,'2022-01-02'); | SELECT user_id, gender, MAX(heart_rate) as max_heart_rate FROM workout_data JOIN user_data ON workout_data.user_id = user_data.id GROUP BY user_id, gender ORDER BY max_heart_rate DESC; |
What is the maximum range of Level 2 EV chargers? | CREATE TABLE Chargers (Id INT,Type VARCHAR(255),Manufacturer VARCHAR(255),Range INT); INSERT INTO Chargers (Id,Type,Manufacturer,Range) VALUES (1,'Level 2','Blink',25),(2,'Level 2','ChargePoint',30),(3,'Level 2','EVgo',28),(4,'Level 2','SemaConnect',32); | SELECT MAX(Range) FROM Chargers WHERE Type = 'Level 2' |
What is the 90-day trailing yield for a specific bond? | CREATE TABLE bonds (bond_id INT,bond_symbol VARCHAR(10)); CREATE TABLE bond_prices (price_id INT,bond_id INT,price_date DATE,price DECIMAL(10,2),yield DECIMAL(10,4)); INSERT INTO bonds (bond_id,bond_symbol) VALUES (1,'TLT'),(2,'IEF'),(3,'SHY'); INSERT INTO bond_prices (price_id,bond_id,price_date,price,yield) VALUES (1... | SELECT bond_id, AVG(yield) OVER (PARTITION BY bond_id ORDER BY price_date ROWS BETWEEN 89 PRECEDING AND CURRENT ROW) AS trailing_yield FROM bond_prices WHERE bond_id = 1; |
What is the most popular category of news articles in the "LA Times"? | CREATE TABLE ArticleCategories (id INT,category VARCHAR(20),newspaper VARCHAR(20)); INSERT INTO ArticleCategories (id,category,newspaper) VALUES (1,'technology','LA Times'),(2,'politics','LA Times'),(3,'technology','LA Times'); | SELECT category, COUNT(*) AS count FROM ArticleCategories WHERE newspaper = 'LA Times' GROUP BY category ORDER BY count DESC LIMIT 1; |
What is the total landfill capacity for regions with a population density above 5000 people per square kilometer? | CREATE TABLE region (name TEXT,population INT,area FLOAT,landfill_capacity FLOAT); INSERT INTO region (name,population,area,landfill_capacity) VALUES ('Region A',500000,100,600),('Region B',600000,120,800),('Region C',400000,80,500); | SELECT SUM(landfill_capacity) FROM region WHERE population/area > 5000; |
What is the average experience for farmers in the 'Andes' region who have more than 2 records? | CREATE TABLE Farmers (id INT,name VARCHAR(50),region VARCHAR(50),experience INT); INSERT INTO Farmers (id,name,region,experience) VALUES (1,'Juan Doe','Andes',15); INSERT INTO Farmers (id,name,region,experience) VALUES (2,'Maria Smith','Andes',8); INSERT INTO Farmers (id,name,region,experience) VALUES (3,'Pedro Lopez',... | SELECT region, AVG(experience) FROM Farmers WHERE region = 'Andes' GROUP BY region HAVING COUNT(*) > 2; |
Which species have been observed at the 'Great Barrier Reef' marine protected area? | CREATE TABLE marine_protected_areas (name VARCHAR(255),location VARCHAR(255)); CREATE TABLE marine_species_observations (species VARCHAR(255),marine_protected_area_name VARCHAR(255)); INSERT INTO marine_species_observations (species,marine_protected_area_name) VALUES ('Clownfish','Great Barrier Reef'); | SELECT species FROM marine_species_observations WHERE marine_protected_area_name = 'Great Barrier Reef'; |
How many unique endangered languages are spoken in Europe and have more than 10000 speakers? | CREATE TABLE EuroLanguages (id INT,language VARCHAR(50),continent VARCHAR(50),speakers INT); INSERT INTO EuroLanguages (id,language,continent,speakers) VALUES (1,'French','Europe',76000000),(2,'German','Europe',95000000),(3,'Italian','Europe',59000000),(4,'Romanian','Europe',24000000),(5,'Welsh','Europe',550000); | SELECT continent, COUNT(DISTINCT language) FROM EuroLanguages WHERE continent = 'Europe' AND speakers > 10000 GROUP BY continent; |
What is the total quantity of recycled polyester used by textile suppliers in Bangladesh and Vietnam? | CREATE TABLE TextileSuppliers (SupplierID INT,SupplierName TEXT,Country TEXT,RecycledPolyesterQty INT); INSERT INTO TextileSuppliers (SupplierID,SupplierName,Country,RecycledPolyesterQty) VALUES (1,'EcoFabrics','Bangladesh',4000),(2,'GreenWeaves','Vietnam',5000),(3,'SustainableTextiles','Italy',6000); | SELECT Country, SUM(RecycledPolyesterQty) FROM TextileSuppliers WHERE Country IN ('Bangladesh', 'Vietnam') GROUP BY Country; |
What is the total fare collected for the 'Red Line' metro route? | CREATE TABLE MetroRoutes (route_id INT,route_name VARCHAR(20),fare DECIMAL(5,2)); INSERT INTO MetroRoutes (route_id,route_name,fare) VALUES (1,'Red Line',3.00),(2,'Red Line',3.50),(3,'Red Line',4.00); | SELECT SUM(fare) FROM MetroRoutes WHERE route_name = 'Red Line'; |
How many professional development courses have been completed by teachers in each subject area, in total? | CREATE TABLE teacher_pd (teacher_id INT,course_id INT,completed_date DATE); CREATE TABLE courses (course_id INT,course_name VARCHAR(255),subject_area VARCHAR(255)); | SELECT c.subject_area, COUNT(t.course_id) FROM teacher_pd t INNER JOIN courses c ON t.course_id = c.course_id GROUP BY c.subject_area; |
List all clinical trials, including those without any reported adverse events, for a specific drug in the 'clinical_trials' and 'adverse_events' tables? | CREATE TABLE clinical_trials (clinical_trial_id INT,drug_id INT,trial_name TEXT); CREATE TABLE adverse_events (adverse_event_id INT,clinical_trial_id INT,event_description TEXT); INSERT INTO clinical_trials (clinical_trial_id,drug_id,trial_name) VALUES (1,1,'TrialX'),(2,2,'TrialY'); | SELECT ct.trial_name, COALESCE(COUNT(ae.adverse_event_id), 0) AS event_count FROM clinical_trials ct LEFT JOIN adverse_events ae ON ct.clinical_trial_id = ae.clinical_trial_id WHERE ct.drug_id = 1 GROUP BY ct.trial_name; |
What is the minimum sustainability rating for any destination in Oceania with at least 500 visitors? | CREATE TABLE OceaniaDestinations (destination_id INT,name VARCHAR(50),country VARCHAR(50),sustainability_rating INT,visitor_count INT); INSERT INTO OceaniaDestinations (destination_id,name,country,sustainability_rating,visitor_count) VALUES (1,'Eco Retreat','Australia',4,600); INSERT INTO OceaniaDestinations (destinati... | SELECT MIN(sustainability_rating) FROM OceaniaDestinations WHERE country IN ('Oceania') AND visitor_count >= 500; |
What is the total budget for all language preservation programs in Canada and the United States? | CREATE TABLE budgets (id INT,program_name TEXT,country TEXT,budget INT); INSERT INTO budgets (id,program_name,country,budget) VALUES (1,'Cree Language Preservation Fund','Canada',50000),(2,'Navajo Language Preservation Program','USA',75000); | SELECT SUM(budget) FROM budgets WHERE country IN ('Canada', 'USA') AND program_name LIKE '%%language preservation%%'; |
List the top 5 organizations by total donation amount? | CREATE TABLE Organizations (OrgID INT,OrgName VARCHAR(100)); CREATE TABLE DonationsOrgs (DonationID INT,OrgID INT,Amount DECIMAL(10,2)); INSERT INTO DonationsOrgs (DonationID,OrgID,Amount) VALUES (1,1,500),(2,1,1000),(3,2,750),(4,2,250),(5,3,150),(6,3,350),(7,4,800),(8,4,400),(9,5,600),(10,5,100); | SELECT o.OrgName, SUM(do.Amount) as TotalDonations FROM Organizations o JOIN DonationsOrgs do ON o.OrgID = do.OrgID GROUP BY o.OrgName ORDER BY TotalDonations DESC LIMIT 5; |
What is the minimum salary of workers in the steel industry who are male and have more than 3 years of experience? | CREATE TABLE steel_workers (id INT,gender VARCHAR(10),years_of_experience INT,salary DECIMAL(10,2)); INSERT INTO steel_workers (id,gender,years_of_experience,salary) VALUES (1,'Male',4,52000.00),(2,'Female',2,48000.00),(3,'Male',5,58000.00),(4,'Female',1,45000.00),(5,'Male',6,60000.00); | SELECT MIN(salary) FROM steel_workers WHERE gender = 'Male' AND years_of_experience > 3; |
Which genetic research projects in Africa have the most citations? | CREATE TABLE research_projects (project_id INT,project_name VARCHAR(20),citations INT,country VARCHAR(20)); INSERT INTO research_projects (project_id,project_name,citations,country) VALUES (1,'Genome sequencing',500,'Kenya'),(2,'CRISPR gene editing',800,'Nigeria'),(3,'Stem cell research',650,'South Africa'); | SELECT project_name, MAX(citations) FROM research_projects WHERE country = 'Africa' GROUP BY project_name; |
What is the total funding received by organizations focusing on technology for social good in Asia? | CREATE TABLE contributor (contributor_id INT,contributor_name VARCHAR(255),amount DECIMAL(10,2)); INSERT INTO contributor (contributor_id,contributor_name,amount) VALUES (1,'Tech for Good Foundation',600000),(2,'AI Ethics Alliance',450000),(3,'Digital Responsibility Fund',500000),(4,'Inclusive AI Coalition',300000),(5,... | SELECT SUM(amount) as total_funding FROM contributor JOIN contributor_project ON contributor.contributor_id = contributor_project.contributor_id JOIN project ON contributor_project.project_id = project.project_id WHERE project.location = 'Asia'; |
How many volunteers signed up for program A in 2020? | CREATE TABLE volunteers (volunteer_id INT,volunteer_name TEXT,program TEXT,volunteer_date DATE); INSERT INTO volunteers (volunteer_id,volunteer_name,program,volunteer_date) VALUES (1,'Alice','Program A','2020-01-01'),(2,'Bob','Program B','2019-12-31'); | SELECT COUNT(*) FROM volunteers WHERE program = 'Program A' AND EXTRACT(YEAR FROM volunteer_date) = 2020; |
What was the total budget for agricultural innovation projects in 2020? | CREATE TABLE agri_innovation (id INT,year INT,project VARCHAR(50),budget FLOAT); INSERT INTO agri_innovation (id,year,project,budget) VALUES (1,2018,'Precision Agriculture',500000.00),(2,2019,'Biotech Seeds',750000.00),(3,2020,'Farm Robotics',900000.00); | SELECT SUM(budget) FROM agri_innovation WHERE year = 2020 AND project LIKE 'Agricultural%'; |
What is the minimum distance between Earth and Mars during their closest approach? | CREATE TABLE PlanetaryDistances (id INT,planet1 VARCHAR(50),planet2 VARCHAR(50),distance FLOAT); INSERT INTO PlanetaryDistances (id,planet1,planet2,distance) VALUES (1,'Earth','Mars',54.6); | SELECT MIN(distance) FROM PlanetaryDistances WHERE planet1 = 'Earth' AND planet2 = 'Mars'; |
How many community policing meetings were held in each borough of New York City in 2020? | CREATE TABLE community_policing (id INT,borough VARCHAR(255),meeting_date DATE); | SELECT borough, COUNT(*) as total_meetings FROM community_policing WHERE meeting_date BETWEEN '2020-01-01' AND '2020-12-31' GROUP BY borough; |
Who are the top 3 block producers with the highest total stake that have produced at least 100 blocks? | CREATE TABLE block_producer_stakes (stake_id INT PRIMARY KEY,producer_address VARCHAR(100),stake_amount DECIMAL(20,2),stake_start_time TIMESTAMP,stake_end_time TIMESTAMP); CREATE TABLE block_production (block_id INT PRIMARY KEY,producer_address VARCHAR(100),block_time TIMESTAMP); | SELECT bp.producer_address, SUM(bp.stake_amount) AS total_stake FROM block_producer_stakes bp JOIN block_production bp2 ON bp.producer_address = bp2.producer_address WHERE bp.stake_end_time > bp2.block_time GROUP BY bp.producer_address HAVING COUNT(bp2.block_id) >= 100 ORDER BY total_stake DESC LIMIT 3; |
List all countries with deep-sea exploration programs and their budgets? | CREATE TABLE countries (country_id INT,name VARCHAR(255),deep_sea_program BOOLEAN); CREATE TABLE budgets (country_id INT,amount FLOAT); | SELECT countries.name, budgets.amount FROM countries INNER JOIN budgets ON countries.country_id = budgets.country_id WHERE countries.deep_sea_program = TRUE; |
Find the total revenue and average guest rating for each exhibition in New York, ordered by total revenue in descending order. | CREATE TABLE Exhibitions (id INT,city VARCHAR(20),revenue FLOAT,guest_rating FLOAT); INSERT INTO Exhibitions (id,city,revenue,guest_rating) VALUES (1,'New York',55000,4.3),(2,'Los Angeles',70000,4.6),(3,'New York',62000,4.8); | SELECT city, SUM(revenue) as total_revenue, AVG(guest_rating) as avg_guest_rating FROM Exhibitions WHERE city = 'New York' GROUP BY city ORDER BY total_revenue DESC; |
List all cultural heritage sites in New York with more than 500 reviews. | CREATE TABLE attractions (id INT,city VARCHAR(20),type VARCHAR(20),reviews INT); INSERT INTO attractions (id,city,type,reviews) VALUES (1,'New York','cultural heritage',550),(2,'New York','museum',300); | SELECT * FROM attractions WHERE city = 'New York' AND type = 'cultural heritage' AND reviews > 500; |
What is the maximum response time for 'advocacy' interventions? | CREATE TABLE advocacy (id INT,intervention VARCHAR(50),response_time INT); INSERT INTO advocacy (id,intervention,response_time) VALUES (1,'Letter Writing',120),(2,'Protest',240),(3,'Petition',180); | SELECT MAX(response_time) FROM advocacy; |
What is the standard deviation of the financial wellbeing score for customers aged 20-30 in Progressive Bank? | CREATE TABLE ProgressiveBank (id INT,customer_age INT,financial_wellbeing_score INT); INSERT INTO ProgressiveBank (id,customer_age,financial_wellbeing_score) VALUES (1,25,70),(2,30,65); | SELECT STDDEV(financial_wellbeing_score) FROM ProgressiveBank WHERE customer_age BETWEEN 20 AND 30; |
Which program had the highest total budget in 2020? | CREATE TABLE Budget (ProgramID INT,Year INT,Budget DECIMAL(10,2)); INSERT INTO Budget (ProgramID,Year,Budget) VALUES (1,2020,5000.00),(2,2020,7000.00),(3,2020,6000.00),(4,2020,8000.00); CREATE TABLE Programs (ProgramID INT,ProgramName VARCHAR(255)); INSERT INTO Programs (ProgramID,ProgramName) VALUES (1,'Feeding the Hu... | SELECT ProgramName, MAX(Budget) as HighestBudget FROM Budget b JOIN Programs p ON b.ProgramID = p.ProgramID WHERE b.Year = 2020 GROUP BY p.ProgramName; |
What is the most common mental health condition in Nigeria's youth? | CREATE TABLE conditions (id INT,patient_id INT,condition VARCHAR(255)); CREATE TABLE patients (id INT,age INT,country VARCHAR(255)); INSERT INTO conditions (id,patient_id,condition) VALUES (1,1,'depression'),(2,2,'anxiety'),(3,1,'anxiety'); INSERT INTO patients (id,age,country) VALUES (1,18,'Nigeria'),(2,25,'Nigeria'); | SELECT conditions.condition, COUNT(conditions.condition) AS count FROM conditions JOIN patients ON conditions.patient_id = patients.id WHERE patients.country = 'Nigeria' AND patients.age BETWEEN 13 AND 24 GROUP BY conditions.condition ORDER BY count DESC LIMIT 1; |
Calculate the total weight of each strain produced by cultivators in states with medical cannabis laws. | CREATE TABLE Cultivators (CultivatorID INT,CultivatorName TEXT,State TEXT); INSERT INTO Cultivators (CultivatorID,CultivatorName,State) VALUES (1,'Green Leaf Farms','Missouri'); CREATE TABLE Production (ProductionID INT,CultivatorID INT,Strain TEXT,Weight DECIMAL(10,2)); INSERT INTO Production (ProductionID,CultivatorI... | SELECT p.Strain, SUM(p.Weight) as TotalWeight FROM Production p INNER JOIN Cultivators c ON p.CultivatorID = c.CultivatorID INNER JOIN States s ON c.State = s.State WHERE s.Legalization = 'Medical' GROUP BY p.Strain; |
Get the total weight of fair trade coffee beans | CREATE TABLE products (id INT,name VARCHAR(50),is_fair_trade BOOLEAN,weight INT,category VARCHAR(50)); INSERT INTO products (id,name,is_fair_trade,weight,category) VALUES (1,'Coffee Beans',TRUE,1000,'Beverages'),(2,'Tea Leaves',FALSE,500,'Beverages'),(3,'Sugar',FALSE,2000,'Baking'); | SELECT SUM(weight) FROM products WHERE is_fair_trade = TRUE AND name = 'Coffee Beans'; |
What is the total fare collected from wheelchair-accessible vehicles in the last month? | CREATE TABLE vehicles (vehicle_id INT,vehicle_type VARCHAR(255)); INSERT INTO vehicles (vehicle_id,vehicle_type) VALUES (1,'Wheelchair Accessible'),(2,'Standard'); CREATE TABLE transactions (transaction_id INT,vehicle_id INT,fare_amount DECIMAL(5,2),transaction_date DATE); INSERT INTO transactions (transaction_id,vehic... | SELECT SUM(fare_amount) FROM transactions WHERE vehicle_id IN (SELECT vehicle_id FROM vehicles WHERE vehicle_type = 'Wheelchair Accessible') AND transaction_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH); |
What is the difference in carbon prices between the European Union Emissions Trading System and the California Cap-and-Trade Program? | CREATE TABLE eu_ets (year INTEGER,price DECIMAL); INSERT INTO eu_ets (year,price) VALUES (2016,5.84); INSERT INTO eu_ets (year,price) VALUES (2017,7.14); CREATE TABLE california_cap (year INTEGER,price DECIMAL); INSERT INTO california_cap (year,price) VALUES (2016,13.57); INSERT INTO california_cap (year,price) VALUES ... | SELECT eu_ets.year, eu_ets.price - california_cap.price FROM eu_ets, california_cap WHERE eu_ets.year = california_cap.year; |
Increase artist stipends by 15% for the 'Asian Art' event. | CREATE TABLE artists (id INT,name VARCHAR(50),event VARCHAR(50),stipend DECIMAL(5,2)); INSERT INTO artists (id,name,event,stipend) VALUES (1,'Pablo Picasso','Art of the Americas',3000),(2,'Frida Kahlo','Art of the Americas',2500),(3,'Yayoi Kusama','Women in Art',4000),(4,'Xu Bing','Asian Art',2000); | UPDATE artists SET stipend = stipend * 1.15 WHERE event = 'Asian Art'; |
How many water treatment plants in California were built after 2015? | CREATE TABLE water_treatment (plant_name TEXT,plant_year INT,plant_state TEXT); INSERT INTO water_treatment (plant_name,plant_year,plant_state) VALUES ('WTP1',2016,'California'),('WTP2',2018,'California'),('WTP3',2013,'California'),('WTP4',2019,'California'); | SELECT COUNT(*) FROM water_treatment WHERE plant_year > 2015 AND plant_state = 'California'; |
How many solar_panels were installed in Brazil in each year? | CREATE TABLE installation_date (id INT,solar_panel_id INT,installation_date DATE,country VARCHAR(50)); | SELECT YEAR(installation_date) AS installation_year, COUNT(*) AS panels_per_year FROM installation_date JOIN solar_panels ON installation_date.solar_panel_id = solar_panels.id WHERE country = 'Brazil' GROUP BY installation_year ORDER BY installation_year; |
What is the average time to complete accessible technology initiatives? | CREATE TABLE initiative (initiative_id INT,initiative_name VARCHAR(255),launch_date DATE,completion_date DATE); INSERT INTO initiative (initiative_id,initiative_name,launch_date,completion_date) VALUES (1,'Accessible Software Development','2018-04-01','2019-01-15'),(2,'Adaptive Hardware Prototyping','2019-12-15','2021-... | SELECT AVG(DATEDIFF(completion_date, launch_date)) as avg_time_to_complete FROM initiative; |
How many agricultural innovation projects were successfully implemented in Indonesia between 2015 and 2017, inclusive? | CREATE TABLE agricultural_innovation_projects (id INT,country VARCHAR(255),success BOOLEAN); INSERT INTO agricultural_innovation_projects (id,country,success) VALUES (1,'Indonesia',true),(2,'Indonesia',false),(3,'Vietnam',true); | SELECT COUNT(*) FROM agricultural_innovation_projects WHERE country = 'Indonesia' AND success = true AND completion_date BETWEEN '2015-01-01' AND '2017-12-31'; |
Find the top 3 crops with the highest water usage in the past year. | CREATE TABLE crop (id INT,type VARCHAR(255),water_usage FLOAT,timestamp DATETIME); | SELECT type, SUM(water_usage) as total_water_usage FROM crop WHERE timestamp >= DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 1 YEAR) GROUP BY type ORDER BY total_water_usage DESC LIMIT 3; |
Count the number of marine species discovered in the Arctic Circle in the last 5 years. | CREATE TABLE marine_species (id INTEGER,species TEXT,discovery_date DATE,location TEXT); INSERT INTO marine_species (id,species,discovery_date,location) VALUES (1,'Narwhal','2017-06-15','Arctic Circle'); INSERT INTO marine_species (id,species,discovery_date,location) VALUES (2,'Polar Cod','2021-12-31','Arctic Circle'); | SELECT COUNT(*) FROM marine_species WHERE discovery_date >= '2017-01-01' AND discovery_date < '2022-01-01' AND location = 'Arctic Circle'; |
What are the top 3 most common innovations for companies founded in 'New York'? | CREATE TABLE innovation_trends (id INT PRIMARY KEY,company_id INT,innovation TEXT,year INT,location TEXT); CREATE VIEW innovation_summary AS SELECT innovation,location,COUNT(*) as count,RANK() OVER (PARTITION BY location ORDER BY COUNT(*) DESC) as rank FROM innovation_trends GROUP BY innovation,location; | SELECT i.innovation, i.location, i.count FROM innovation_summary i JOIN company_founding c ON c.location = i.location WHERE i.location = 'New York' AND i.rank <= 3; |
What is the average capacity of wind power plants in 'India' and 'Germany' from the 'power_plants' table? | CREATE TABLE power_plants (id INT,name VARCHAR(255),type VARCHAR(255),capacity INT,location VARCHAR(255)); INSERT INTO power_plants (id,name,type,capacity,location) VALUES (1,'La Grande-1','Hydro',2730,'Canada'); INSERT INTO power_plants (id,name,type,capacity,location) VALUES (2,'Three Gorges','Hydro',22500,'China'); ... | SELECT location, AVG(capacity) FROM power_plants WHERE type = 'Wind' AND location IN ('India', 'Germany') GROUP BY location; |
How many drought-affected counties are there in California and what is the total population in these counties? | CREATE TABLE CountyDroughtImpact (county_name VARCHAR(20),state VARCHAR(20),drought_status VARCHAR(10),population INT); INSERT INTO CountyDroughtImpact (county_name,state,drought_status,population) VALUES ('Los Angeles','California','Drought',1000000),('San Diego','California','Drought',800000); | SELECT COUNT(*), SUM(population) FROM CountyDroughtImpact WHERE state = 'California' AND drought_status = 'Drought'; |
What is the minimum yield of all crops in 'region6'? | CREATE TABLE farm (id INT,region VARCHAR(20),crop VARCHAR(20),yield INT); INSERT INTO farm (id,region,crop,yield) VALUES (1,'region6','wheat',40),(2,'region6','rice',50),(3,'region6','corn',60),(4,'region6','soybean',70); | SELECT MIN(yield) FROM farm WHERE region = 'region6'; |
What is the average cultural competency training hours for community health workers in each state? | CREATE TABLE CommunityHealthWorkers (WorkerID INT,State VARCHAR(255),TrainingHours INT); INSERT INTO CommunityHealthWorkers (WorkerID,State,TrainingHours) VALUES (1,'California',20),(2,'Texas',25),(3,'New York',30),(4,'Florida',35),(5,'Illinois',40); | SELECT State, AVG(TrainingHours) as AvgTrainingHours FROM CommunityHealthWorkers GROUP BY State; |
List the menu items and their prices from 'Italian Trattoria' | CREATE TABLE menu_prices (menu_item VARCHAR(255),price DECIMAL(10,2),restaurant_name VARCHAR(255)); INSERT INTO menu_prices (menu_item,price,restaurant_name) VALUES ('Pasta',15.99,'Italian Trattoria'),('Pizza',13.99,'Italian Trattoria'),('Salad',11.99,'Italian Trattoria'); | SELECT menu_item, price FROM menu_prices WHERE restaurant_name = 'Italian Trattoria'; |
What is the maximum budget allocated for any digital divide initiative? | CREATE TABLE initiatives(id INT,name TEXT,budget FLOAT,year INT); INSERT INTO initiatives(id,name,budget,year) VALUES (1,'Broadband Access',50000.0,2021); INSERT INTO initiatives(id,name,budget,year) VALUES (2,'Computer Literacy',75000.0,2021); INSERT INTO initiatives(id,name,budget,year) VALUES (3,'Device Distribution... | SELECT MAX(budget) FROM initiatives WHERE name LIKE '%Digital Divide%'; |
List the names and average depths of marine species that exist in all three oceans. | CREATE TABLE oceans (ocean_id INT,name VARCHAR(50)); CREATE TABLE species (species_id INT,name VARCHAR(50),ocean_id INT,avg_depth DECIMAL(5,2)); INSERT INTO oceans VALUES (1,'Atlantic'),(2,'Pacific'),(3,'Indian'); INSERT INTO species VALUES (1,'Clownfish',2,10),(2,'Salmon',1,100),(3,'Clownfish',3,15),(4,'Dolphin',1,200... | SELECT s.name, AVG(s.avg_depth) FROM species s JOIN (SELECT species_id FROM species GROUP BY species_id HAVING COUNT(DISTINCT ocean_id) = (SELECT COUNT(DISTINCT ocean_id) FROM oceans)) sq ON s.species_id = sq.species_id GROUP BY s.name; |
Find the mining operations that have a low environmental impact score and also a low number of employees. | CREATE TABLE mining_operations (id INT,name VARCHAR(50),num_employees INT,environmental_impact_score INT); | SELECT name FROM mining_operations WHERE num_employees < (SELECT AVG(num_employees) FROM mining_operations) AND environmental_impact_score < (SELECT AVG(environmental_impact_score) FROM mining_operations); |
What is the total data usage in GB for each mobile network provider in the last quarter? | CREATE TABLE mobile_data_usage (provider VARCHAR(25),usage_gb FLOAT,quarter_year VARCHAR(7)); INSERT INTO mobile_data_usage (provider,usage_gb,quarter_year) VALUES ('Provider A',500000,'Q4 2021'),('Provider B',600000,'Q4 2021'); | SELECT provider, SUM(usage_gb) FROM mobile_data_usage GROUP BY provider, quarter_year HAVING quarter_year = 'Q4 2021'; |
What are the top 3 countries with the most excavation sites? | CREATE TABLE Country (CountryID INT,CountryName VARCHAR(50)); INSERT INTO Country (CountryID,CountryName) VALUES (1,'Egypt'),(2,'Mexico'),(3,'Italy'),(4,'Greece'),(5,'Peru'); CREATE TABLE ExcavationSite (SiteID INT,SiteName VARCHAR(50),CountryID INT); INSERT INTO ExcavationSite (SiteID,SiteName,CountryID) VALUES (1,'... | SELECT c.CountryName, COUNT(es.SiteID) AS SiteCount FROM Country c JOIN ExcavationSite es ON c.CountryID = es.CountryID GROUP BY c.CountryName ORDER BY SiteCount DESC LIMIT 3; |
What was the total production of Terbium in 2017 and 2018 combined? | CREATE TABLE production (element VARCHAR(10),year INT,quantity FLOAT); INSERT INTO production (element,year,quantity) VALUES ('Terbium',2015,200),('Terbium',2016,250),('Terbium',2017,300),('Terbium',2018,350),('Terbium',2019,400); | SELECT SUM(quantity) FROM production WHERE element = 'Terbium' AND (year = 2017 OR year = 2018); |
Which support programs have been attended by students with both learning disabilities and ADHD? | CREATE TABLE SupportPrograms (ProgramID INT,Name VARCHAR(50),Description TEXT,Coordinator VARCHAR(50)); CREATE TABLE StudentSupportPrograms (StudentID INT,ProgramID INT); CREATE TABLE Students (StudentID INT,Disability VARCHAR(50),Name VARCHAR(50)); | SELECT sp.Name FROM SupportPrograms sp JOIN StudentSupportPrograms ssp ON sp.ProgramID = ssp.ProgramID JOIN Students s ON ssp.StudentID = s.StudentID WHERE s.Disability IN ('learning disabilities', 'ADHD') GROUP BY sp.Name HAVING COUNT(DISTINCT s.StudentID) > 1; |
What is the maximum mass of space debris in different categories? | CREATE TABLE space_debris (category TEXT,mass FLOAT); INSERT INTO space_debris (category,mass) VALUES ('Aluminum',200.5),('Titanium',180.2),('Copper',120.3),('Steel',450.7),('Other',70.1); | SELECT category, MAX(mass) AS max_mass FROM space_debris GROUP BY category; |
What is the total playtime for each player in the last month? | CREATE TABLE Players (PlayerID INT,PlayerName TEXT); INSERT INTO Players (PlayerID,PlayerName) VALUES (1,'John Doe'),(2,'Jane Smith'),(3,'Alex Rodriguez'); CREATE TABLE GameSessions (SessionID INT,PlayerID INT,GameID INT,StartTime TIMESTAMP); INSERT INTO GameSessions (SessionID,PlayerID,GameID,StartTime) VALUES (1,1,1,... | SELECT Players.PlayerName, SUM(TIMESTAMPDIFF(MINUTE, GameSessions.StartTime, NOW())) as TotalPlaytime FROM Players JOIN GameSessions ON Players.PlayerID = GameSessions.PlayerID WHERE GameSessions.StartTime > DATE_SUB(NOW(), INTERVAL 1 MONTH) GROUP BY Players.PlayerName; |
What is the average age of astronauts who have been to the International Space Station? | CREATE TABLE astronaut_missions(astronaut_id INT,mission_id INT,mission_start DATE,mission_end DATE); CREATE TABLE astronauts(id INT,name VARCHAR(255),birth_date DATE,gender VARCHAR(10)); INSERT INTO astronauts(id,name,birth_date,gender) VALUES (1,'Jane Doe','1985-02-15','Female'); INSERT INTO astronaut_missions(astron... | SELECT AVG(YEAR(astronauts.birth_date) - YEAR(astronaut_missions.mission_start)) AS avg_age FROM astronauts INNER JOIN astronaut_missions ON astronauts.id = astronaut_missions.astronaut_id WHERE astronaut_missions.mission_id IN (SELECT id FROM missions WHERE name = 'ISS'); |
Identify counties in Montana with increasing healthcare costs over the past 5 years. | CREATE TABLE costs (county_id INT,year INT,cost INT); | SELECT county_id, COUNT(*) AS years FROM costs WHERE costs[ROW_NUMBER() OVER (PARTITION BY county_id ORDER BY year) - 1] < cost GROUP BY county_id HAVING COUNT(*) = 5 AND county_id IN (SELECT county_id FROM costs WHERE state = 'Montana'); |
What is the total population of sharks in the Mediterranean Sea? | CREATE TABLE MediterraneanSea (shark_species TEXT,population INT); INSERT INTO MediterraneanSea (shark_species,population) VALUES ('Great White Shark',250),('Blue Shark',1500); | SELECT SUM(population) FROM MediterraneanSea WHERE shark_species IS NOT NULL; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.