instruction
stringlengths
0
1.06k
input
stringlengths
11
5.3k
response
stringlengths
2
4.44k
List all unique locations from the 'Waste_Management' table.
CREATE TABLE Waste_Management (project_id INT,project_name VARCHAR(50),location VARCHAR(50)); INSERT INTO Waste_Management (project_id,project_name,location) VALUES (1,'Landfill Expansion','Rural Area'),(2,'Recycling Center Construction','Industrial Area'),(3,'Composting Facility','Suburbs'),(4,'Hazardous Waste Disposal','Urban Area');
SELECT DISTINCT location FROM Waste_Management;
How many genetic research projects were completed in 2021?
CREATE SCHEMA if not exists genetics;CREATE TABLE genetics.project_timeline (id INT,project_name VARCHAR(50),start_date DATE,end_date DATE);INSERT INTO genetics.project_timeline (id,project_name,start_date,end_date) VALUES (1,'ProjectX','2020-01-01','2021-12-31'),(2,'ProjectY','2022-01-01','2023-12-31'),(3,'ProjectZ','2019-01-01','2020-12-31');
SELECT COUNT(*) FROM genetics.project_timeline WHERE YEAR(start_date) = 2021 AND YEAR(end_date) = 2021;
List all the distinct workouts and their average duration for members aged 50 or older, grouped by the workout type and gender.
CREATE TABLE Members (MemberID INT,Age INT,Gender VARCHAR(10)); INSERT INTO Members (MemberID,Age,Gender) VALUES (7,55,'Female'); CREATE TABLE Workouts (WorkoutID INT,WorkoutType VARCHAR(20),Duration INT,MemberID INT); INSERT INTO Workouts (WorkoutID,WorkoutType,Duration,MemberID) VALUES (70,'Zumba',45,7);
SELECT Workouts.WorkoutType, Members.Gender, AVG(Workouts.Duration) FROM Members INNER JOIN Workouts ON Members.MemberID = Workouts.MemberID WHERE Members.Age >= 50 GROUP BY Workouts.WorkoutType, Members.Gender;
What is the total energy stored in batteries in California for the month of May 2021?
CREATE TABLE state (id INT PRIMARY KEY,name VARCHAR(50));CREATE TABLE energy_storage (id INT PRIMARY KEY,name VARCHAR(50),state_id INT,FOREIGN KEY (state_id) REFERENCES state(id));CREATE TABLE battery_storage (id INT PRIMARY KEY,date DATE,energy_stored DECIMAL(10,2));
SELECT s.name AS state_name, es.name AS energy_storage_name, SUM(bs.energy_stored) AS total_energy_stored FROM battery_storage bs JOIN energy_storage es ON bs.energy_storage_id = es.id JOIN state s ON es.state_id = s.id WHERE s.name = 'California' AND bs.date BETWEEN '2021-05-01' AND '2021-05-31' GROUP BY s.name, es.name;
What is the maximum and minimum number of art forms practiced at each heritage site, and the average number?
CREATE TABLE HeritageSites (id INT,name VARCHAR(255),num_art_forms INT,UNIQUE(id)); CREATE TABLE ArtFormsPracticed (id INT,heritage_site_id INT,form_id INT,UNIQUE(id)); CREATE TABLE ArtForms (id INT,name VARCHAR(255),UNIQUE(id));
SELECT HeritageSites.name, MAX(ArtFormsPracticed.num_art_forms) as max_art_forms, MIN(ArtFormsPracticed.num_art_forms) as min_art_forms, AVG(ArtFormsPracticed.num_art_forms) as avg_art_forms FROM HeritageSites INNER JOIN (SELECT heritage_site_id, COUNT(DISTINCT form_id) as num_art_forms FROM ArtFormsPracticed GROUP BY heritage_site_id) as ArtFormsPracticed ON HeritageSites.id = ArtFormsPracticed.heritage_site_id;
What is the average distance covered by each athlete in the 2022 decathlon event?
CREATE TABLE decathlon_results (athlete_id INT,athlete_name VARCHAR(50),distance_covered INT); INSERT INTO decathlon_results (athlete_id,athlete_name,distance_covered) VALUES (1,'Kevin Mayer',8750),(2,'Damian Warner',8800),(3,'Ashley Moloney',8600),(4,'Garrett Scantling',8400),(5,'Pierce Lepage',8500);
SELECT athlete_name, AVG(distance_covered) as avg_distance_covered FROM decathlon_results GROUP BY athlete_name;
Show the total quantity of sustainable fabric types used in the last two years.
CREATE TABLE Fabrics_History (id INT PRIMARY KEY,type VARCHAR(20),year INT,quantity INT); INSERT INTO Fabrics_History (id,type,year,quantity) VALUES (1,'Organic_Cotton',2021,6000),(2,'Recycled_Polyester',2020,7000),(3,'Organic_Cotton',2020,4000);
SELECT SUM(quantity) FROM Fabrics_History WHERE type IN ('Organic_Cotton', 'Recycled_Polyester') AND year BETWEEN 2020 AND 2021;
What is the most common type of cybersecurity incident in each region in the year 2020?
CREATE TABLE cybersecurity_incidents (id INT,incident_type VARCHAR(255),year INT,affected_systems VARCHAR(255),region VARCHAR(255)); INSERT INTO cybersecurity_incidents (id,incident_type,year,affected_systems,region) VALUES (1,'Data Breach',2020,'Web Servers','Asia'),(2,'Phishing',2019,'Email Accounts','Asia'),(3,'Malware',2020,'Workstations','Europe'),(4,'Ransomware',2019,'Databases','North America'),(5,'Data Breach',2020,'Web Servers','North America'),(6,'Phishing',2020,'Email Accounts','Europe');
SELECT region, MAX(incident_type) as most_common_incident FROM cybersecurity_incidents WHERE year = 2020 GROUP BY region;
Find the product name and rating for the product with the highest rating in each product category.
CREATE TABLE products (product_id INT,product_name TEXT,rating FLOAT,product_category TEXT); INSERT INTO products (product_id,product_name,rating,product_category) VALUES (1,'Product A',4.5,'Category 1'),(2,'Product B',4.2,'Category 2'),(3,'Product C',4.8,'Category 1'),(4,'Product D',4.6,'Category 3'),(5,'Product E',4.7,'Category 2');
SELECT product_name, rating FROM (SELECT product_name, rating, product_category, DENSE_RANK() OVER (PARTITION BY product_category ORDER BY rating DESC) as rnk FROM products) t WHERE rnk = 1;
Identify virtual reality (VR) game designers who have designed games for more than one genre.
CREATE TABLE Designers (DesignerID INT,DesignerName VARCHAR(50),VR_Designer BOOLEAN);CREATE TABLE Games (GameID INT,GameName VARCHAR(50),DesignerID INT,GameGenre VARCHAR(20));
SELECT d.DesignerName FROM Designers d INNER JOIN Games g1 ON d.DesignerID = g1.DesignerID INNER JOIN Games g2 ON d.DesignerID = g2.DesignerID AND g1.GameGenre != g2.GameGenre WHERE d.VR_Designer = TRUE;
Top 3 most popular workout types by gender.
CREATE TABLE workout_sessions (id INT,user_id INT,session_date DATE,workout_type VARCHAR(20));
SELECT s.gender, w.workout_type, COUNT(*) as session_count FROM workout_sessions s JOIN user_profile u ON s.user_id = u.user_id GROUP BY s.workout_type, s.gender ORDER BY session_count DESC LIMIT 3;
What is the total amount donated by each donor in the 'donors' table, ordered by the total amount donated in descending order?
CREATE TABLE donors (donor_id INT,donor_name TEXT,total_donations DECIMAL(10,2));
SELECT donor_name, SUM(total_donations) as total_donated FROM donors GROUP BY donor_name ORDER BY total_donated DESC;
What is the total number of multimodal trips taken in Los Angeles, California using electric vehicles?
CREATE TABLE multimodal_trips (trip_id INT,trip_duration INT,start_time TIMESTAMP,end_time TIMESTAMP,start_station TEXT,end_station TEXT,city TEXT,mode TEXT,electric BOOLEAN);
SELECT COUNT(*) FROM multimodal_trips WHERE city = 'Los Angeles' AND electric = TRUE;
What is the total number of criminal cases heard by each judge in the state of California in 2021?
CREATE TABLE judges (id INT,name TEXT,state TEXT); INSERT INTO judges (id,name,state) VALUES (1,'Judge A','California'),(2,'Judge B','California'),(3,'Judge C','California'); CREATE TABLE cases (id INT,judge_id INT,year INT,case_type TEXT); INSERT INTO cases (id,judge_id,year,case_type) VALUES (1,1,2021,'Criminal'),(2,1,2020,'Civil'),(3,2,2021,'Criminal'),(4,2,2021,'Criminal');
SELECT j.name, COUNT(*) as cases_heard FROM cases JOIN judges j ON cases.judge_id = j.id WHERE cases.year = 2021 AND cases.case_type = 'Criminal' GROUP BY j.name;
Which renewable energy projects started before 2015?
CREATE TABLE projects (id INT PRIMARY KEY,name VARCHAR(255),location VARCHAR(255),type VARCHAR(255),capacity FLOAT,start_date DATE,end_date DATE); INSERT INTO projects (id,name,location,type,capacity,start_date,end_date) VALUES (4,'Solar Farm 2','Arizona','Solar',75.0,'2014-01-01','2024-12-31');
SELECT * FROM projects WHERE start_date < '2015-01-01';
What is the average number of disaster preparedness drills conducted per state in the past year?
CREATE TABLE DisasterPreparedness (id INT,state VARCHAR(20),date DATE,drill_type VARCHAR(20),quantity INT);
SELECT AVG(SUM(quantity)) FROM DisasterPreparedness GROUP BY state HAVING date >= DATEADD(year, -1, GETDATE());
How many donors are there in 'NY' and 'MA'?
CREATE TABLE donors_4 (id INT PRIMARY KEY,name VARCHAR(50),age INT,city VARCHAR(50),state VARCHAR(50)); INSERT INTO donors_4 (id,name,age,city,state) VALUES (1,'John Doe',35,'New York','NY'),(2,'Jane Smith',40,'Buffalo','NY'),(3,'Mike Johnson',50,'Boston','MA'),(4,'Emily Davis',30,'Chicago','IL');
SELECT state, COUNT(DISTINCT donors_4.id) as num_donors FROM donors_4 WHERE state IN ('NY', 'MA') GROUP BY state;
What is the average income of families without health insurance coverage in California?
CREATE TABLE Income (ID INT,FamilySize INT,Income INT,HealthInsurance BOOLEAN); INSERT INTO Income (ID,FamilySize,Income,HealthInsurance) VALUES (1,4,80000,TRUE); INSERT INTO Income (ID,FamilySize,Income,HealthInsurance) VALUES (2,2,50000,FALSE);
SELECT AVG(Income) FROM Income WHERE HealthInsurance = FALSE;
Which sustainable fabric types are most frequently used in our products, and how many units of each are available?
CREATE TABLE fabrics (id INT,fabric_type VARCHAR(50),is_sustainable BOOLEAN); INSERT INTO fabrics (id,fabric_type,is_sustainable) VALUES (1,'Organic Cotton',TRUE),(2,'Recycled Polyester',TRUE),(3,'Conventional Cotton',FALSE); CREATE TABLE products (id INT,fabric_id INT,quantity INT); INSERT INTO products (id,fabric_id,quantity) VALUES (1,1,1000),(2,2,1500),(3,3,750);
SELECT f.fabric_type, SUM(p.quantity) AS total_quantity FROM fabrics f INNER JOIN products p ON f.id = p.fabric_id WHERE f.is_sustainable = TRUE GROUP BY f.fabric_type;
What is the name of the deepest part of the South China Sea?
CREATE TABLE sea_depths (id INT,sea TEXT,deepest_part TEXT,depth INT); INSERT INTO sea_depths (id,sea,deepest_part,depth) VALUES (1,'South China Sea','Sulu Sea Trench',8040),(2,'Indian Ocean','Java Trench',8075);
SELECT deepest_part FROM sea_depths WHERE sea = 'South China Sea';
What is the maximum collective bargaining agreement length in the transportation industry?
CREATE TABLE transportation (id INT,agreement_length INT); INSERT INTO transportation (id,agreement_length) VALUES (1,36),(2,48),(3,60);
SELECT MAX(agreement_length) FROM transportation;
What is the maximum transaction value for 'SmartContractD'?
CREATE TABLE Transactions (tx_id INT,contract_name VARCHAR(255),tx_value DECIMAL(10,2)); INSERT INTO Transactions (tx_id,contract_name,tx_value) VALUES (1,'SmartContractD',100.50); INSERT INTO Transactions (tx_id,contract_name,tx_value) VALUES (2,'SmartContractD',200.75);
SELECT MAX(tx_value) FROM Transactions WHERE contract_name = 'SmartContractD';
Which sustainable fashion brand sources the most recycled polyester?
CREATE TABLE MaterialSourcing (Brand VARCHAR(255),Material VARCHAR(255),Quantity INT); INSERT INTO MaterialSourcing (Brand,Material,Quantity) VALUES ('BrandP','Recycled Polyester',30000),('BrandQ','Organic Cotton',25000),('BrandR','Recycled Polyester',35000);
SELECT Brand, MAX(Quantity) FROM MaterialSourcing WHERE Material = 'Recycled Polyester';
What is the maximum number of military personnel in each branch?
CREATE TABLE Military_Personnel (ID INT,Branch VARCHAR(50),Personnel INT); INSERT INTO Military_Personnel (ID,Branch,Personnel) VALUES (1,'Army',500000),(2,'Navy',400000),(3,'Air_Force',350000);
SELECT Branch, MAX(Personnel) FROM Military_Personnel GROUP BY Branch;
What is the number of employees in each department in the 'mining_operations' table, for employees with a salary greater than $70,000?
CREATE TABLE mining_operations (id INT,first_name VARCHAR(50),last_name VARCHAR(50),job_title VARCHAR(50),department VARCHAR(50),PRIMARY KEY (id)); INSERT INTO mining_operations (id,first_name,last_name,job_title,department,salary) VALUES (1,'John','Doe','Engineer','Mining',80000.00),(2,'Jane','Doe','Operator','Mining',60000.00),(3,'Mike','Johnson','Manager','Environment',90000.00),(4,'Sara','Smith','Technician','Environment',70000.00),(5,'David','Williams','Engineer','Mining',75000.00);
SELECT department, COUNT(*) FROM mining_operations WHERE salary > 70000 GROUP BY department;
What is the total CO2 emissions reduction achieved by sustainable tourism practices in South America in 2021?
CREATE TABLE emissions (emission_id INT,activity_type TEXT,country TEXT,CO2_emissions FLOAT,reduction_percentage FLOAT,year INT); INSERT INTO emissions (emission_id,activity_type,country,CO2_emissions,reduction_percentage,year) VALUES (1,'Eco-tours','Brazil',1000,0.2,2021),(2,'Wildlife sanctuaries','Argentina',2000,0.3,2021),(3,'Bicycle tours','Colombia',500,0.1,2021),(4,'Sustainable transportation','Peru',1500,0.2,2021);
SELECT SUM(CO2_emissions * reduction_percentage) FROM emissions WHERE country LIKE 'South%' AND year = 2021;
What is the average temperature recorded in the 'arctic_weather' table for January?
CREATE TABLE arctic_weather (date DATE,temperature FLOAT); INSERT INTO arctic_weather (date,temperature) VALUES ('2020-01-01',-10.0),('2020-01-02',-15.0),('2020-01-03',-8.0);
SELECT AVG(temperature) FROM arctic_weather WHERE EXTRACT(MONTH FROM date) = 1;
Delete all events with attendance below 50 in the 'Music' category.
CREATE TABLE Events (event_id INT PRIMARY KEY,event_name TEXT,category TEXT,attendees INT);
DELETE FROM Events WHERE category = 'Music' AND attendees < 50;
What was the total REE production in 2018?
CREATE TABLE production (year INT,element TEXT,quantity INT); INSERT INTO production (year,element,quantity) VALUES (2015,'Dysprosium',100),(2016,'Dysprosium',150),(2017,'Dysprosium',200),(2018,'Dysprosium',250),(2019,'Dysprosium',300),(2020,'Dysprosium',350),(2015,'Neodymium',500),(2016,'Neodymium',600),(2017,'Neodymium',700),(2018,'Neodymium',800),(2019,'Neodymium',900),(2020,'Neodymium',1000);
SELECT SUM(quantity) FROM production WHERE year = 2018 AND element IN ('Dysprosium', 'Neodymium');
Update the data limit for a mobile plan in the mobile_plans table
CREATE TABLE mobile_plans (plan_id INT,plan_name VARCHAR(50),data_limit INT,price DECIMAL(5,2),contract_length INT,created_at TIMESTAMP);
UPDATE mobile_plans SET data_limit = 75000 WHERE plan_id = 2001;
What is the earliest founding date for a startup with a diverse founding team (at least one founder identifies as female and one founder identifies as a person of color)?
CREATE TABLE startups (id INT,name TEXT,founder_gender TEXT,founder_ethnicity TEXT,founding_date DATE);
SELECT MIN(founding_date) FROM startups WHERE (founder_gender = 'Female' OR founder_ethnicity IN ('African American', 'Asian', 'Hispanic', 'Latinx')) AND EXISTS (SELECT 1 FROM startups s2 WHERE s2.id = startups.id AND (s2.founder_gender <> 'Female' OR s2.founder_ethnicity NOT IN ('African American', 'Asian', 'Hispanic', 'Latinx')));
List all disability support programs and their start dates in descending order.
CREATE TABLE Programs (ProgramID INT,ProgramName VARCHAR(50),StartDate DATE); INSERT INTO Programs (ProgramID,ProgramName,StartDate) VALUES (1,'Accessible Tech','2020-01-01'),(2,'Sign Language Interpretation','2019-06-15'),(3,'Mobility Assistance','2018-02-20'),(4,'Assistive Listening','2021-03-25'),(5,'Adaptive Equipment','2020-07-01');
SELECT ProgramName, StartDate FROM Programs ORDER BY StartDate DESC;
Find the number of farmers who cultivate more than one crop.
CREATE VIEW multi_crop_farmers AS SELECT farmer_id,COUNT(crop_name) AS num_crops FROM crops GROUP BY farmer_id HAVING num_crops > 1; INSERT INTO crops (id,farmer_id,crop_name,acres) VALUES (1,1,'maize',50),(2,2,'maize',75),(3,3,'soybean',100),(4,1,'carrot',25);
SELECT COUNT(*) FROM multi_crop_farmers;
Delete all records from the 'employees' table where the department is 'Sustainability' and the employee's age is less than 30.
CREATE TABLE employees (id INT,first_name VARCHAR(50),last_name VARCHAR(50),job_title VARCHAR(50),department VARCHAR(50),age INT,PRIMARY KEY (id)); INSERT INTO employees (id,first_name,last_name,job_title,department,age) VALUES (1,'John','Doe','Engineer','Mining',35),(2,'Jane','Doe','Operator','Mining',28),(3,'Mike','Johnson','Manager','Environment',45),(4,'Sara','Smith','Technician','Environment',30),(5,'David','Williams','Engineer','Sustainability',25),(6,'Grace','Lee','Operator','Sustainability',22);
DELETE FROM employees WHERE department = 'Sustainability' AND age < 30;
What is the average temperature recorded for each species in the species_measurements table?
CREATE TABLE species_measurements (species_id INT,measurement_date DATE,temperature DECIMAL(5,2));
SELECT species_id, AVG(temperature) OVER (PARTITION BY species_id) FROM species_measurements;
Who are the graduate students who have published the most papers in the Mathematics department?
CREATE TABLE students (student_id INT,name VARCHAR(50),department VARCHAR(50)); CREATE TABLE publications (publication_id INT,student_id INT,title VARCHAR(50),department VARCHAR(50));
SELECT students.name, COUNT(publications.publication_id) AS num_publications FROM students JOIN publications ON students.student_id = publications.student_id WHERE students.department = 'Mathematics' GROUP BY students.name ORDER BY num_publications DESC LIMIT 1;
How many labor rights violations have been reported in Brazil in the last 2 years?
CREATE TABLE Country (id INT,name TEXT,continent TEXT); INSERT INTO Country (id,name,continent) VALUES (1,'Brazil','South America'); CREATE TABLE Violations (id INT,country_id INT,year INT,type TEXT); INSERT INTO Violations (id,country_id,year,type) VALUES (1,1,2020,'Wage Theft'),(2,1,2021,'Child Labor'),(3,1,2020,'Harassment'),(4,1,2021,'Discrimination'),(5,1,2020,'Forced Labor'),(6,1,2021,'Retaliation'),(7,1,2020,'Unfair Termination'),(8,1,2021,'Health and Safety');
SELECT COUNT(*) FROM Violations WHERE year BETWEEN (SELECT YEAR(CURRENT_DATE) - 2) AND YEAR(CURRENT_DATE) AND country_id = 1;
What is the total number of consumers who prefer cruelty-free cosmetics in the database?
CREATE TABLE Consumer_Preference (id INT,consumer_id INT,product VARCHAR(255),preference BOOLEAN); INSERT INTO Consumer_Preference (id,consumer_id,product,preference) VALUES (1,1001,'Lush Soak Stimulant Bath Bomb',true),(2,1002,'The Body Shop Born Lippy Strawberry Lip Balm',true),(3,1003,'Estee Lauder Advanced Night Repair',false),(4,1004,'Lush Soak Stimulant Bath Bomb',true),(5,1005,'The Body Shop Born Lippy Strawberry Lip Balm',false);
SELECT COUNT(DISTINCT consumer_id) as total_consumers FROM Consumer_Preference WHERE preference = true;
How many indigenous communities are in each Arctic region?
CREATE TABLE indigenous_communities (community_name VARCHAR(50),region VARCHAR(50)); INSERT INTO indigenous_communities (community_name,region) VALUES ('Inuit','Arctic North America'),('Sami','Arctic Europe');
SELECT i.region, COUNT(i.community_name) as community_count FROM indigenous_communities i GROUP BY i.region;
What is the average donation amount for first-time donors in 'CountryY'?
CREATE TABLE Donors (donor_id INT,name VARCHAR(255),country VARCHAR(255),first_time BOOLEAN); CREATE TABLE Donations (donation_id INT,donor_id INT,event_id INT,amount DECIMAL(10,2));
SELECT AVG(amount) FROM Donations D JOIN Donors DD ON D.donor_id = DD.donor_id WHERE DD.first_time = TRUE AND DD.country = 'CountryY';
Who are the property owners in the 'prop_owners' table that have a 'property_id' matching with any record in the 'property2' table?
CREATE TABLE prop_owners (id INT,owner VARCHAR(20),property_id INT); INSERT INTO prop_owners (id,owner,property_id) VALUES (1,'Oliver',201),(2,'Sophia',202),(3,'Jacob',203); CREATE TABLE property2 (id INT,city VARCHAR(20),price INT); INSERT INTO property2 (id,city,price) VALUES (201,'Phoenix',700000),(202,'Denver',500000);
SELECT prop_owners.owner FROM prop_owners INNER JOIN property2 ON prop_owners.property_id = property2.id;
What is the maximum temperature recorded in the 'arctic_weather' table for each month in the year 2020, broken down by region ('region' column in the 'arctic_weather' table)?
CREATE TABLE arctic_weather (id INT,date DATE,temperature FLOAT,region VARCHAR(50));
SELECT MONTH(date) AS month, region, MAX(temperature) AS max_temp FROM arctic_weather WHERE YEAR(date) = 2020 GROUP BY month, region;
What is the total number of hotels in Mexico that offer virtual tours and AI-powered guest communication?
CREATE TABLE hotel_features_data (hotel_id INT,country TEXT,virtual_tours INT,ai_guest_comm INT); INSERT INTO hotel_features_data (hotel_id,country,virtual_tours,ai_guest_comm) VALUES (1,'Mexico',1,1),(2,'Mexico',0,1),(3,'Mexico',1,0),(4,'Brazil',1,1);
SELECT COUNT(*) FROM hotel_features_data WHERE country = 'Mexico' AND virtual_tours = 1 AND ai_guest_comm = 1;
What is the minimum size of a food justice organization in hectares, grouped by country, and only considering organizations with more than 20 organizations?
CREATE TABLE food_justice_organizations (id INT,name VARCHAR(255),size FLOAT,country VARCHAR(255)); INSERT INTO food_justice_organizations (id,name,size,country) VALUES (1,'Organization A',12.5,'USA'),(2,'Organization B',20.0,'Canada'),(3,'Organization C',5.5,'Mexico');
SELECT country, MIN(size) as min_size FROM food_justice_organizations GROUP BY country HAVING COUNT(*) > 20;
Find the percentage of records in the explainable_ai table with a fairness score greater than 0.8.
CREATE TABLE explainable_ai (record_id INT,algorithm_name TEXT,fairness_score REAL); INSERT INTO explainable_ai VALUES (1,'SHAP',0.8),(2,'LIME',0.6),(3,'Anchors',0.9);
SELECT (COUNT(*) FILTER (WHERE fairness_score > 0.8)) * 100.0 / COUNT(*) as fairness_percentage FROM explainable_ai;
What is the total amount of coal produced by each mine?
CREATE TABLE mines (id INT,name TEXT,location TEXT,total_coal_production INT); INSERT INTO mines (id,name,location,total_coal_production) VALUES (1,'Golden Mine','Colorado,USA',10000),(2,'Silver Ridge','Nevada,USA',12000),(3,'Bronze Basin','Utah,USA',14000);
SELECT name, SUM(total_coal_production) FROM mines GROUP BY name
List the initiatives, cities, and capacities for renewable energy projects related to wind energy in countries with LEED certified buildings.
CREATE TABLE green_buildings (id INT,name VARCHAR(50),city VARCHAR(50),country VARCHAR(50),certification VARCHAR(50)); INSERT INTO green_buildings (id,name,city,country,certification) VALUES (1,'GreenHeights','San Francisco','USA','LEED Platinum'); CREATE TABLE renewable_energy (id INT,project_name VARCHAR(50),city VARCHAR(50),country VARCHAR(50),energy_type VARCHAR(50),capacity FLOAT); INSERT INTO renewable_energy (id,project_name,city,country,energy_type,capacity) VALUES (1,'WindFarm1','San Francisco','USA','Wind',2000);
SELECT r.project_name, r.city, r.capacity FROM green_buildings g INNER JOIN renewable_energy r ON g.country = r.country WHERE g.certification = 'LEED' AND r.energy_type = 'Wind';
What is the average data usage in GB for postpaid mobile customers in the Midwest region?
CREATE TABLE customers (id INT,type VARCHAR(10),region VARCHAR(10)); INSERT INTO customers (id,type,region) VALUES (1,'postpaid','Midwest'),(2,'prepaid','Midwest'); CREATE TABLE usage (customer_id INT,data_usage FLOAT); INSERT INTO usage (customer_id,data_usage) VALUES (1,3.5),(2,2.2);
SELECT AVG(data_usage) FROM usage JOIN customers ON usage.customer_id = customers.id WHERE customers.type = 'postpaid' AND customers.region = 'Midwest';
Find the top 3 countries with the most autonomous driving research publications in the past 2 years.
CREATE TABLE Countries (Id INT,Name VARCHAR(50)); CREATE TABLE Publications (Id INT,Title VARCHAR(50),Publication_Date DATE,Country_Id INT);
SELECT C.Name, COUNT(P.Id) FROM Countries C INNER JOIN Publications P ON C.Id = P.Country_Id WHERE P.Publication_Date >= DATE(NOW()) - INTERVAL 2 YEAR GROUP BY C.Id ORDER BY COUNT(P.Id) DESC LIMIT 3;
What is the maximum number of security incidents handled by each response team in the EMEA region for the current year?
CREATE TABLE security_incidents (incident_id INT,incident_date DATE,mitigation_team VARCHAR(255),region VARCHAR(255),response_time INT); INSERT INTO security_incidents (incident_id,incident_date,mitigation_team,region,response_time) VALUES (1,'2022-02-14','Team Alpha','EMEA',300),(2,'2022-03-05','Team Bravo','APAC',420),(3,'2022-04-18','Team Alpha','EMEA',560),(4,'2022-06-11','Team Charlie','AMER',240),(5,'2022-07-23','Team Alpha','EMEA',700),(6,'2022-08-09','Team Bravo','APAC',380),(7,'2022-09-15','Team Charlie','AMER',520);
SELECT mitigation_team, MAX(response_time) AS max_response_time FROM security_incidents WHERE region = 'EMEA' AND incident_date >= DATE_SUB(NOW(), INTERVAL 1 YEAR) GROUP BY mitigation_team;
What is the distribution of articles published by day of the week in the 'news_reports' table?
CREATE TABLE news_reports (id INT,title VARCHAR(255),author VARCHAR(255),published_date DATE,topic VARCHAR(255));
SELECT DAYNAME(published_date) as day_of_week, COUNT(*) as articles_published FROM news_reports GROUP BY day_of_week;
How many marine research projects are conducted in the Indian Ocean?
CREATE TABLE research_projects (id INT,project_name VARCHAR(50),location_latitude FLOAT,location_longitude FLOAT,ocean VARCHAR(50)); INSERT INTO research_projects (id,project_name,location_latitude,location_longitude,ocean) VALUES (1,'Deep-Sea Coral Study',12.9716,77.5946,'Indian Ocean'),(2,'Marine Mammal Research',-26.8406,28.1774,'Indian Ocean');
SELECT COUNT(*) FROM research_projects WHERE ocean = 'Indian Ocean';
Which company has the most satellite deployments since 2015?
CREATE TABLE company_deployments (id INT,company VARCHAR(50),launch_year INT,deployments INT);
SELECT company, SUM(deployments) FROM company_deployments WHERE launch_year >= 2015 GROUP BY company ORDER BY SUM(deployments) DESC LIMIT 1;
How many new products were introduced in the last quarter?
CREATE TABLE ProductInnovation (id INT,product VARCHAR(255),introduction_date DATE); INSERT INTO ProductInnovation (id,product,introduction_date) VALUES (1,'product A','2023-01-01'),(2,'product B','2023-04-15');
SELECT COUNT(*) FROM ProductInnovation WHERE introduction_date >= DATE_SUB(CURRENT_DATE, INTERVAL 3 MONTH);
Delete all games that have not been played in the last month
CREATE TABLE games (id INT PRIMARY KEY,name VARCHAR(50),release_date DATE); CREATE TABLE games_played (game_id INT,play_date DATE,FOREIGN KEY (game_id) REFERENCES games(id)); INSERT INTO games (id,name,release_date) VALUES (1,'Game A','2022-01-01'),(2,'Game B','2022-06-01'),(3,'Game C','2022-12-01'); INSERT INTO games_played (game_id,play_date) VALUES (1,'2022-12-15'),(2,'2023-01-10'),(3,'2023-01-01');
DELETE FROM games WHERE id NOT IN (SELECT game_id FROM games_played WHERE play_date >= DATEADD(month, -1, GETDATE()));
Delete 'Trial001' from 'ClinicalTrials' table.
CREATE TABLE ClinicalTrials (clinical_trial_id TEXT,medicine_name TEXT); INSERT INTO ClinicalTrials (clinical_trial_id,medicine_name) VALUES ('Trial001','DrugX');
DELETE FROM ClinicalTrials WHERE clinical_trial_id = 'Trial001';
What are the average carbon emissions of flights from Sydney to various Asian destinations?
CREATE TABLE flight_data (id INT,flight_number TEXT,origin TEXT,destination TEXT,distance INT,carbon_emissions FLOAT); INSERT INTO flight_data (id,flight_number,origin,destination,distance,carbon_emissions) VALUES (1,'QF1','Sydney','Tokyo',7000,550),(2,'QF2','Sydney','Seoul',6500,520),(3,'QF3','Sydney','Hong Kong',7500,600);
SELECT destination, AVG(carbon_emissions) AS avg_carbon_emissions FROM flight_data WHERE origin = 'Sydney' AND destination LIKE 'Asia%' GROUP BY destination;
What is the total value of defense contracts awarded to companies located in California in the year 2020?
CREATE TABLE defense_contracts (contract_id INT,company_name VARCHAR(255),company_state VARCHAR(255),award_date DATE,contract_value DECIMAL(10,2)); INSERT INTO defense_contracts (contract_id,company_name,company_state,award_date,contract_value) VALUES (1,'ABC Corp','California','2020-01-01',1000000.00),(2,'XYZ Inc','California','2020-02-03',2000000.00);
SELECT SUM(contract_value) FROM defense_contracts WHERE company_state = 'California' AND EXTRACT(YEAR FROM award_date) = 2020;
Which military aircraft are used by both the United States and China?
CREATE TABLE us_aircraft (id INT,name VARCHAR(50),country VARCHAR(50)); INSERT INTO us_aircraft (id,name,country) VALUES (1,'F-15 Eagle','USA'),(2,'F-16 Fighting Falcon','USA'); CREATE TABLE china_aircraft (id INT,name VARCHAR(50),country VARCHAR(50)); INSERT INTO china_aircraft (id,name,country) VALUES (3,'J-10','China'),(4,'J-11','China');
SELECT name FROM us_aircraft WHERE country = 'USA' INTERSECT SELECT name FROM china_aircraft WHERE country = 'China';
What is the maximum number of military equipment items sold in a single transaction?
CREATE TABLE sales (id INT,quantity INT); INSERT INTO sales (id,quantity) VALUES (1,100),(2,50),(3,150);
SELECT MAX(quantity) as max_quantity FROM sales;
What are the names and descriptions of all military technologies in the technologies table that have a cost less than $10,000,000?
CREATE TABLE technologies (name TEXT,description TEXT,cost INT); INSERT INTO technologies (name,description,cost) VALUES ('Drones','Unmanned aerial vehicles.',5000000),('Stealth Technology','Invisible to radar.',100000000),('Smart Bombs','Precision-guided munitions.',500000);
SELECT name, description FROM technologies WHERE cost < 10000000;
List the names of the top five countries with the highest visitor counts at heritage sites in 'Asia'.
CREATE TABLE HeritageSitesAsia (SiteID INT PRIMARY KEY,SiteName VARCHAR(50),Country VARCHAR(50),VisitorCount INT); INSERT INTO HeritageSitesAsia (SiteID,SiteName,Country,VisitorCount) VALUES (1,'Angkor Wat','Cambodia',2500000),(2,'Taj Mahal','India',3000000);
SELECT Country, SUM(VisitorCount) as Total FROM HeritageSitesAsia GROUP BY Country ORDER BY Total DESC LIMIT 5;
What is the average age of users who liked articles about climate change?
CREATE TABLE articles (id INT,title TEXT,category TEXT); CREATE TABLE users (id INT,age INT,gender TEXT); CREATE TABLE user_likes (user_id INT,article_id INT); INSERT INTO articles (id,title,category) VALUES (1,'Climate Crisis 101','climate_change'); INSERT INTO users (id,age,gender) VALUES (1,25,'female'),(2,35,'male'),(3,30,'non-binary'); INSERT INTO user_likes (user_id,article_id) VALUES (1,1),(2,1),(3,1);
SELECT AVG(users.age) FROM users JOIN user_likes ON users.id = user_likes.user_id JOIN articles ON user_likes.article_id = articles.id WHERE articles.category = 'climate_change';
What is the average water pH level for aquatic farms in the 'Southern Ocean' region?
CREATE TABLE aquatic_farms (id INT,name TEXT,region TEXT); INSERT INTO aquatic_farms (id,name,region) VALUES (1,'Farm I','Southern Ocean'),(2,'Farm J','Arctic Ocean'); CREATE TABLE pH_readings (id INT,farm_id INT,pH FLOAT); INSERT INTO pH_readings (id,farm_id,pH) VALUES (1,1,7.9),(2,1,7.8),(3,2,8.1);
SELECT AVG(pH_readings.pH) FROM pH_readings INNER JOIN aquatic_farms ON pH_readings.farm_id = aquatic_farms.id WHERE aquatic_farms.region = 'Southern Ocean';
How many individuals received support in each country?
CREATE TABLE SupportRecipients (Id INT,Country VARCHAR(50),SupportType VARCHAR(50)); INSERT INTO SupportRecipients (Id,Country,SupportType) VALUES (1,'Syria','Food'),(2,'Bangladesh','Shelter'),(3,'Syria','Medical'),(4,'Brazil','Food');
SELECT Country, COUNT(*) FROM SupportRecipients GROUP BY Country;
Find the total fare collected from passengers using the 'Oyster' payment method
CREATE TABLE fare_payment (payment_method VARCHAR(50),fare FLOAT); INSERT INTO fare_payment (payment_method,fare) VALUES ('Oyster',2.00),('Cash',2.50),('Contactless',2.25);
SELECT SUM(fare) FROM fare_payment WHERE payment_method = 'Oyster';
Delete all sightings for a specific location
species_sightings (species_id,location_id,sighted_date,sighted_time,sighted_by)
DELETE FROM species_sightings WHERE location_id = 456
What mental health conditions were addressed in public awareness campaigns in 2021?
CREATE TABLE PublicAwarenessCampaigns (CampaignID INT PRIMARY KEY,Name VARCHAR(100),TargetConditionID INT,StartDate DATE,EndDate DATE); INSERT INTO PublicAwarenessCampaigns (CampaignID,Name,TargetConditionID,StartDate,EndDate) VALUES (1,'EndTheStigma',1,'2021-04-01','2021-04-30'),(2,'HopeForRecovery',2,'2021-06-01','2021-06-30');
SELECT PAC.Name, MHC.Name FROM PublicAwarenessCampaigns AS PAC INNER JOIN MentalHealthConditions AS MHC ON PAC.TargetConditionID = MHC.ConditionID WHERE YEAR(PAC.StartDate) = 2021;
Which regions have more than 50 animals in their sanctuaries?
CREATE TABLE regions_3 (region_id INT,region_name VARCHAR(50)); INSERT INTO regions_3 VALUES (1,'region_1'); INSERT INTO regions_3 VALUES (2,'region_2'); INSERT INTO regions_3 VALUES (3,'region_3'); CREATE TABLE sanctuary_h (sanctuary_id INT,sanctuary_name VARCHAR(50),region_id INT,population INT); INSERT INTO sanctuary_h VALUES (1,'sanctuary_1',1,100); INSERT INTO sanctuary_h VALUES (2,'sanctuary_2',2,60); INSERT INTO sanctuary_h VALUES (3,'sanctuary_3',3,75);
SELECT r.region_name FROM regions_3 r INNER JOIN sanctuary_h s ON r.region_id = s.region_id WHERE s.population > 50;
What is the average age of attendees for music-related events?
CREATE TABLE MusicEvents (id INT,title VARCHAR(50),artist_id INT); INSERT INTO MusicEvents (id,title,artist_id) VALUES (1,'Symphony Performance',1); INSERT INTO MusicEvents (id,title,artist_id) VALUES (2,'Jazz Concert',2); CREATE TABLE MusicAttendees (id INT,event_id INT,age INT,gender VARCHAR(10)); INSERT INTO MusicAttendees (id,event_id,age,gender) VALUES (1,1,40,'Female'); INSERT INTO MusicAttendees (id,event_id,age,gender) VALUES (2,2,50,'Male');
SELECT event_id, AVG(age) FROM MusicAttendees GROUP BY event_id;
Which artists have the highest-rated pieces?
CREATE TABLE Artists (ArtistID int,Name varchar(50),Nationality varchar(50)); CREATE TABLE ArtPieces (ArtPieceID int,Title varchar(50),YearCreated int,ArtistID int,AverageRating decimal(3,2));
SELECT Artists.Name, AVG(ArtPieces.AverageRating) AS AverageRating FROM Artists INNER JOIN ArtPieces ON Artists.ArtistID = ArtPieces.ArtistID GROUP BY Artists.Name ORDER BY AverageRating DESC;
Get the number of marine reserves that have been established between 2000 and 2010, including the year of establishment in the 'reserve_years' table.
CREATE TABLE reserve_years (reserve_id INT,year_established INT);
SELECT year_established, COUNT(*) FROM reserve_years WHERE year_established BETWEEN 2000 AND 2010 GROUP BY year_established;
What is the total amount of government funding for urban agriculture projects in Tokyo?
CREATE TABLE funding (city VARCHAR(255),type VARCHAR(255),amount FLOAT); INSERT INTO funding (city,type,amount) VALUES ('Tokyo','urban agriculture',20000.0),('Tokyo','urban agriculture',25000.0),('Tokyo','other',15000.0);
SELECT SUM(amount) FROM funding WHERE city = 'Tokyo' AND type = 'urban agriculture';
What is the earliest date a security incident was recorded in the 'security_incidents' table?
CREATE TABLE security_incidents (id INT,date DATE,department VARCHAR(50),description TEXT);
SELECT MIN(date) FROM security_incidents;
What are the top 5 countries with the highest number of security incidents in the last 6 months from the 'security_incidents' table?
CREATE TABLE security_incidents (id INT,country VARCHAR(50),incident_count INT,incident_date DATE);
SELECT country, SUM(incident_count) as total_incidents FROM security_incidents WHERE incident_date >= DATE_SUB(CURDATE(), INTERVAL 6 MONTH) GROUP BY country ORDER BY total_incidents DESC LIMIT 5;
What is the maximum number of wins for a player in multiplayer games?
CREATE TABLE Games (GameID INT,GameType VARCHAR(255),Multiplayer INT); INSERT INTO Games (GameID,GameType,Multiplayer) VALUES (1,'Racing',0); INSERT INTO Games (GameID,GameType,Multiplayer) VALUES (2,'Shooter',1); CREATE TABLE Wins (PlayerID INT,GameID INT); INSERT INTO Wins (PlayerID,GameID) VALUES (1,1); INSERT INTO Wins (PlayerID,GameID) VALUES (1,2); INSERT INTO Wins (PlayerID,GameID) VALUES (2,2); INSERT INTO Wins (PlayerID,GameID) VALUES (3,2);
SELECT MAX(CountWins) FROM (SELECT PlayerID, COUNT(GameID) AS CountWins FROM Wins INNER JOIN Games ON Wins.GameID = Games.GameID WHERE Games.Multiplayer = 1 GROUP BY PlayerID) AS Subquery;
What is the total budget for all community development initiatives in the 'community_development' table?
CREATE TABLE community_development (id INT,initiative_name VARCHAR(50),sector VARCHAR(50),start_date DATE,end_date DATE,budget FLOAT); INSERT INTO community_development (id,initiative_name,sector,start_date,end_date,budget) VALUES (1,'Youth Empowerment Program','Community Development','2019-01-01','2020-12-31',250000);
SELECT SUM(budget) FROM community_development;
Find the total amount of Terbium sold in Q3 and Q4 of 2020.
CREATE TABLE TerbiumSales(quarter INT,amount INT); INSERT INTO TerbiumSales(quarter,amount) VALUES (3,250),(3,275),(3,300),(4,325),(4,350),(4,375);
SELECT SUM(amount) FROM TerbiumSales WHERE quarter BETWEEN 3 AND 4;
What is the total amount of climate finance provided by development banks in the Pacific region for climate adaptation projects in the last 3 years?
CREATE TABLE climate_finance (bank VARCHAR(50),region VARCHAR(50),type VARCHAR(50),year INT,amount INT); INSERT INTO climate_finance (bank,region,type,year,amount) VALUES ('Asian Development Bank','Pacific','Adaptation',2019,5000000); INSERT INTO climate_finance (bank,region,type,year,amount) VALUES ('Asian Development Bank','Pacific','Adaptation',2020,6000000); INSERT INTO climate_finance (bank,region,type,year,amount) VALUES ('World Bank','Pacific','Adaptation',2019,7000000); INSERT INTO climate_finance (bank,region,type,year,amount) VALUES ('World Bank','Pacific','Adaptation',2020,8000000);
SELECT SUM(amount) FROM climate_finance WHERE region = 'Pacific' AND type = 'Adaptation' AND year BETWEEN 2019 AND 2021;
List the names and average depths of the oceanic trenches in the Atlantic Ocean deeper than 7000 meters.
CREATE TABLE atlantic_trenches (id INT,name VARCHAR(255),avg_depth FLOAT); INSERT INTO atlantic_trenches (id,name,avg_depth) VALUES (1,'Puerto Rico Trench',8605),(2,'South Sandwich Trench',8260);
SELECT name, avg_depth FROM atlantic_trenches WHERE avg_depth > 7000;
What is the total climate finance provided by Nordic countries to African countries in 2017?
CREATE TABLE climate_finance (year INT,donor_country TEXT,recipient_country TEXT,amount INT); INSERT INTO climate_finance (year,donor_country,recipient_country,amount) VALUES (2017,'Norway','Kenya',5000000),(2017,'Sweden','Ethiopia',7000000),(2017,'Denmark','Mali',3000000),(2017,'Finland','Uganda',8000000),(2017,'Iceland','Tanzania',4000000);
SELECT SUM(amount) FROM climate_finance WHERE year = 2017 AND donor_country IN ('Norway', 'Sweden', 'Denmark', 'Finland', 'Iceland') AND recipient_country NOT IN ('Norway', 'Sweden', 'Denmark', 'Finland', 'Iceland');
Create a table 'athlete_salaries' with athlete_id, name, team, base_salary, bonus columns
CREATE TABLE athlete_salaries (athlete_id INT,name VARCHAR(100),team VARCHAR(50),base_salary DECIMAL(10,2),bonus DECIMAL(10,2));
CREATE TABLE athlete_salaries AS SELECT a.athlete_id, a.name, t.team, s.base_salary, s.bonus FROM athlete_data a JOIN team_roster tr ON a.athlete_id = tr.athlete_id JOIN athlete_salary_info s ON a.athlete_id = s.athlete_id JOIN team_data t ON tr.team_id = t.team_id;
Which countries have experienced a decrease in travel advisories from 2018 to 2019?
CREATE TABLE Advisories (country_id INT,year INT,level INT); INSERT INTO Advisories (country_id,year,level) VALUES (1,2018,2); INSERT INTO Advisories (country_id,year,level) VALUES (1,2019,1); INSERT INTO Advisories (country_id,year,level) VALUES (2,2018,3); INSERT INTO Advisories (country_id,year,level) VALUES (2,2019,3); INSERT INTO Advisories (country_id,year,level) VALUES (3,2018,1); INSERT INTO Advisories (country_id,year,level) VALUES (3,2019,1); INSERT INTO Advisories (country_id,year,level) VALUES (4,2018,2); INSERT INTO Advisories (country_id,year,level) VALUES (4,2019,1);
SELECT country_id FROM Advisories WHERE level = (SELECT MIN(level) FROM Advisories a2 WHERE a2.country_id = Advisories.country_id) GROUP BY country_id HAVING MIN(year) = 2018 AND MAX(year) = 2019;
Update the fare for the 'Yellow' line's 'Station 1' from 1000 to 1200.
CREATE TABLE routes (line VARCHAR(10),station VARCHAR(20)); INSERT INTO routes (line,station) VALUES ('Yellow','Station 1'),('Yellow','Station 2'),('Yellow','Station 3'); CREATE TABLE fares (station VARCHAR(20),revenue DECIMAL(10,2)); INSERT INTO fares (station,revenue) VALUES ('Station 1',1000),('Station 2',1500),('Station 3',1800);
UPDATE fares SET revenue = 1200 WHERE station = (SELECT station FROM routes WHERE line = 'Yellow' AND station = 'Station 1' LIMIT 1);
List the number of fish caught and total revenue for each trawler in the North Atlantic during 2022.
CREATE TABLE trawlers (id INT,name VARCHAR(50)); CREATE TABLE catch (trawler_id INT,date DATE,species VARCHAR(50),quantity INT,price FLOAT); INSERT INTO trawlers VALUES (1,'North Atlantic Trawler 1'),(2,'North Atlantic Trawler 2'),(3,'North Atlantic Trawler 3'); INSERT INTO catch VALUES (1,'2022-01-01','Cod',1200,4.5),(1,'2022-01-02','Haddock',900,3.8),(2,'2022-01-01','Herring',1800,2.2);
SELECT t.name, COUNT(c.trawler_id) as catches, SUM(c.quantity * c.price) as revenue FROM trawlers t INNER JOIN catch c ON t.id = c.trawler_id WHERE YEAR(c.date) = 2022 AND t.name LIKE '%North Atlantic%' GROUP BY t.id;
What is the highest surface tide ever recorded in the Bay of Fundy?
CREATE TABLE tide_height (location VARCHAR(255),height FLOAT); INSERT INTO tide_height (location,height) VALUES ('Bay of Fundy',17.0);
SELECT MAX(height) FROM tide_height WHERE location = 'Bay of Fundy';
Which countries have landfill capacities below 20% as of 2025?
CREATE TABLE landfill_capacity (id INT,country VARCHAR(255),capacity DECIMAL(3,2),timestamp DATETIME); INSERT INTO landfill_capacity (id,country,capacity,timestamp) VALUES (1,'Canada',0.25,'2025-01-01'),(2,'USA',0.32,'2025-01-01'),(3,'Mexico',0.18,'2025-01-01');
SELECT country FROM landfill_capacity WHERE capacity < 0.2 AND YEAR(timestamp) = 2025;
What is the total number of students with speech impairments and their accommodation types?
CREATE TABLE Students (StudentID INT,Name VARCHAR(50),DisabilityType VARCHAR(50)); INSERT INTO Students VALUES (1,'Avery Davis','Speech Impairment'); CREATE TABLE Accommodations (AccommodationID INT,AccommodationType VARCHAR(50),StudentID INT); INSERT INTO Accommodations VALUES (1,'Speech-to-Text Software',1);
SELECT COUNT(DISTINCT s.StudentID), a.AccommodationType FROM Students s INNER JOIN Accommodations a ON s.StudentID = a.StudentID WHERE s.DisabilityType = 'Speech Impairment' GROUP BY a.AccommodationType;
What is the average number of containers handled per day by vessels in the Caribbean Sea in Q1 2021?
CREATE TABLE Vessel_Stats_3 (vessel_name TEXT,location TEXT,handling_date DATE,containers_handled INTEGER); INSERT INTO Vessel_Stats_3 (vessel_name,location,handling_date,containers_handled) VALUES ('VesselM','Caribbean Sea','2021-01-01',55),('VesselN','Caribbean Sea','2021-01-02',65),('VesselO','Caribbean Sea','2021-02-01',70),('VesselP','Caribbean Sea','2021-02-02',75);
SELECT AVG(containers_handled/31.0) FROM Vessel_Stats_3 WHERE location = 'Caribbean Sea' AND handling_date >= '2021-01-01' AND handling_date <= '2021-03-31';
How many farmers in Cambodia and Sri Lanka adopted innovative agricultural practices in 2020?
CREATE TABLE Farmers (Farmer_ID INT,Farmer_Name TEXT,Location TEXT,Innovations_Adopted INT,Year INT); INSERT INTO Farmers (Farmer_ID,Farmer_Name,Location,Innovations_Adopted,Year) VALUES (1,'Chan','Cambodia',1,2020),(2,'Kumar','Sri Lanka',1,2020);
SELECT SUM(Innovations_Adopted) FROM Farmers WHERE Year = 2020 AND Location IN ('Cambodia', 'Sri Lanka');
What is the average budget allocated for disability support programs per region?
CREATE TABLE Regions (RegionID INT,RegionName VARCHAR(50)); CREATE TABLE DisabilitySupportPrograms (ProgramID INT,ProgramName VARCHAR(50),Budget DECIMAL(10,2),RegionID INT); INSERT INTO Regions (RegionID,RegionName) VALUES (1,'Northeast'),(2,'Southeast'),(3,'Midwest'),(4,'South'),(5,'West'); INSERT INTO DisabilitySupportPrograms (ProgramID,ProgramName,Budget,RegionID) VALUES (1,'ASD Support',50000,1),(2,'Wheelchair Access',35000,1),(3,'Blind Assistance',42000,2),(4,'Deaf Interpretation',60000,2),(5,'PTSD Therapy',70000,3);
SELECT AVG(dsp.Budget) as AvgBudget, r.RegionName FROM DisabilitySupportPrograms dsp JOIN Regions r ON dsp.RegionID = r.RegionID GROUP BY r.RegionName;
Find the average age of players who have achieved a rank of Gold or higher in the game "Apex Legends".
CREATE TABLE Players (PlayerID INT,PlayerName VARCHAR(100),Age INT,Game VARCHAR(100),Rank VARCHAR(50)); INSERT INTO Players (PlayerID,PlayerName,Age,Game,Rank) VALUES (1,'John Doe',25,'Apex Legends','Gold'),(2,'Jane Smith',30,'Apex Legends','Platinum'),(3,'Mike Johnson',35,'Apex Legends','Diamond');
SELECT AVG(Age) FROM Players WHERE Game = 'Apex Legends' AND Rank IN ('Gold', 'Platinum', 'Diamond');
Find the total revenue and CO2 emissions for products that are made from a specific material
CREATE TABLE products (product_id INT,material VARCHAR(50),revenue FLOAT,co2_emissions FLOAT);
SELECT SUM(revenue) as total_revenue, SUM(co2_emissions) as total_co2_emissions FROM products WHERE material = 'cotton';
What is the average number of vessels registered per month in the Mediterranean region?
CREATE TABLE vessels (vessel_id INT,registration_date DATE,region TEXT); INSERT INTO vessels VALUES (1,'2020-01-15','Mediterranean'),(2,'2020-03-07','Mediterranean'),(3,'2019-12-28','Mediterranean'),(4,'2020-02-04','Mediterranean'),(5,'2019-11-10','Mediterranean'),(6,'2020-01-02','Mediterranean');
SELECT AVG(vessel_count_per_month) FROM (SELECT COUNT(*) AS vessel_count_per_month FROM vessels WHERE region = 'Mediterranean' GROUP BY YEAR(registration_date), MONTH(registration_date)) subquery;
Create a table named "satellites" with columns "name", "launch_date", "country", and "function".
CREATE TABLE satellites (name TEXT,launch_date DATE,country TEXT,function TEXT);
CREATE TABLE satellites (name TEXT, launch_date DATE, country TEXT, function TEXT);
What are the total installed solar panel capacities for power plants in Mexico?
CREATE TABLE Power_Plant (id INT,name VARCHAR(50),solar_panel_capacity FLOAT,country VARCHAR(50)); INSERT INTO Power_Plant (id,name,solar_panel_capacity,country) VALUES (1,'Agua Prieta Solar Park',290,'Mexico');
SELECT SUM(solar_panel_capacity) FROM Power_Plant WHERE country = 'Mexico' AND type = 'Solar Power Plant';
Show the intelligence operations in the Pacific region.
CREATE TABLE Intelligence_Operations (Name VARCHAR(255),Location VARCHAR(255)); INSERT INTO Intelligence_Operations (Name,Location) VALUES ('Operation Pacific Prowler','Pacific Ocean'),('Operation Pacific Haven','Pacific Ocean'),('Operation Pacific Repose','Pacific Ocean');
SELECT * FROM Intelligence_Operations WHERE Location = 'Pacific Ocean';
What was the most popular post in the "tech" community last month, based on the number of likes?
CREATE TABLE posts (post_id INT,post_text TEXT,post_date DATE,community_id INT,likes INT); INSERT INTO posts (post_id,post_text,post_date,community_id,likes) VALUES (1,'Check out this new gadget!','2022-01-05',3,500),(2,'AI is the future','2022-02-10',3,750),(3,'Gaming setup reveal','2022-01-15',3,900);
SELECT post_id, post_text, post_date, community_id, likes FROM posts WHERE community_id = 3 AND post_date >= DATE('2022-02-01') AND post_date < DATE('2022-03-01') ORDER BY likes DESC LIMIT 1;
Provide a list of countries that have flight safety records equal to or better than the United Kingdom.
CREATE TABLE FlightSafety (FlightSafetyID INT,Country VARCHAR(50),SafetyScore INT);
SELECT Country FROM FlightSafety WHERE SafetyScore >= (SELECT SafetyScore FROM FlightSafety WHERE Country = 'United Kingdom');
What are the top 3 most common genetic mutations in the 'BRCA1' gene?
CREATE TABLE genetic_mutations (id INT,gene VARCHAR(100),mutation VARCHAR(100));
SELECT mutation FROM genetic_mutations WHERE gene = 'BRCA1' GROUP BY mutation ORDER BY COUNT(*) DESC LIMIT 3;