instruction
stringlengths
0
1.06k
input
stringlengths
11
5.3k
response
stringlengths
2
4.44k
What is the average number of employees for startups with a female founder in the biotech industry?
CREATE TABLE company_data (id INT,company_id INT,num_employees INT); INSERT INTO company_data (id,company_id,num_employees) VALUES (1,1,100); INSERT INTO company_data (id,company_id,num_employees) VALUES (2,2,50);
SELECT AVG(num_employees) FROM company_data INNER JOIN company ON company_data.company_id = company.id WHERE company.founder_gender = 'female' AND company.industry = 'biotech';
Which members have not attended any workout in the past month?
CREATE TABLE member_registration (member_id INT,registration_date DATE); INSERT INTO member_registration VALUES (5,'2022-02-01'); INSERT INTO member_registration VALUES (6,'2022-02-03'); CREATE TABLE workouts (workout_id INT,member_id INT,date DATE); INSERT INTO workouts VALUES (3,5,'2022-02-05');
SELECT member_registration.member_id FROM member_registration LEFT JOIN workouts ON member_registration.member_id = workouts.member_id AND workouts.date >= DATEADD(month, -1, GETDATE()) WHERE workouts.workout_id IS NULL;
List the carbon sequestration rates for all forests in 'Region C'.
CREATE TABLE ForestCarbonSeq(forest_name TEXT,carbon_seq_rate REAL,region TEXT); INSERT INTO ForestCarbonSeq (forest_name,carbon_seq_rate,region) VALUES ('Forest 1',5.6,'Region C'),('Forest 2',6.3,'Region D'),('Forest 3',4.8,'Region C');
SELECT carbon_seq_rate FROM ForestCarbonSeq WHERE region = 'Region C';
What is the number of hotels in each city that have adopted AI technology?
CREATE TABLE hotels (hotel_id INT,city TEXT,ai_adoption BOOLEAN); INSERT INTO hotels (hotel_id,city,ai_adoption) VALUES (1,'Paris',TRUE),(2,'London',FALSE),(3,'Paris',TRUE);
SELECT city, COUNT(CASE WHEN ai_adoption = TRUE THEN 1 END) AS num_ai_hotels FROM hotels GROUP BY city;
Show the number of wells drilled in Alaska and Oklahoma
CREATE TABLE alaska_oklahoma_wells (state VARCHAR(2),num_wells INT); INSERT INTO alaska_oklahoma_wells (state,num_wells) VALUES ('AK',500),('OK',900);
SELECT state, num_wells FROM alaska_oklahoma_wells;
Identify the top 2 most productive departments in terms of research grants for LGBTQ+ and disabled faculty in the past 2 years.
CREATE TABLE faculty (faculty_id INT,faculty_name VARCHAR(255),faculty_gender VARCHAR(255),faculty_department VARCHAR(255),faculty_status VARCHAR(255)); CREATE TABLE research_grants (grant_id INT,faculty_id INT,grant_amount DECIMAL(10,2),grant_start_date DATE,grant_end_date DATE);
SELECT f.faculty_department, COUNT(*) AS cnt FROM faculty f INNER JOIN research_grants rg ON f.faculty_id = rg.faculty_id WHERE (f.faculty_gender = 'Transgender' OR f.faculty_status = 'Disabled') AND rg.grant_start_date >= DATE_SUB(CURRENT_DATE, INTERVAL 2 YEAR) GROUP BY f.faculty_department ORDER BY cnt DESC LIMIT 2;
What is the total funding received by female researchers in the Computer Science department since 2018?
CREATE TABLE researcher (id INT,name VARCHAR(50),gender VARCHAR(10),department VARCHAR(30),funding FLOAT); INSERT INTO researcher (id,name,gender,department,funding) VALUES (1,'Alice','Female','Computer Science',150000.00),(2,'Bob','Male','Computer Science',200000.00);
SELECT SUM(funding) FROM researcher WHERE gender = 'Female' AND department = 'Computer Science' AND YEAR(grant_date) >= 2018;
What is the maximum funding received by a biotech startup in Asia?
CREATE TABLE startups(id INT,name VARCHAR(50),sector VARCHAR(50),total_funding FLOAT,location VARCHAR(50));INSERT INTO startups (id,name,sector,total_funding,location) VALUES (1,'StartupC','Genetics',30000000,'Singapore');INSERT INTO startups (id,name,sector,total_funding,location) VALUES (2,'StartupD','Bioprocess',25000000,'Tokyo');
SELECT MAX(total_funding) FROM startups WHERE sector = 'Bioprocess' AND location LIKE 'Asia%';
Get the 'product_name' and 'recycled_content' for 'product_transparency' records with the highest 'recycled_content'.
CREATE TABLE product_transparency (product_id INT,product_name VARCHAR(50),circular_supply_chain BOOLEAN,recycled_content DECIMAL(4,2),COUNTRY VARCHAR(50));
SELECT product_name, recycled_content FROM product_transparency WHERE recycled_content = (SELECT MAX(recycled_content) FROM product_transparency);
What is the total waste generation rate in the circular economy initiatives?
CREATE TABLE CircularEconomy (id INT,initiative VARCHAR(20),waste_generation_rate FLOAT); INSERT INTO CircularEconomy (id,initiative,waste_generation_rate) VALUES (1,'Composting',0.5),(2,'Recycling',0.8);
SELECT SUM(waste_generation_rate) FROM CircularEconomy;
What is the average number of training hours per contractor in the Middle East region?
CREATE TABLE contractors (id INT,name VARCHAR(255),region VARCHAR(255),training_hours INT); INSERT INTO contractors (id,name,region,training_hours) VALUES (1,'John Doe','Middle East',40),(2,'Jane Smith','Europe',30),(3,'Alice Johnson','Middle East',50);
SELECT AVG(training_hours) as avg_training_hours FROM contractors WHERE region = 'Middle East';
How many marine mammal species are endangered in the Arctic Ocean?
CREATE TABLE Arctic_Ocean_Mammals (mammal_name TEXT,endangered BOOLEAN); INSERT INTO Arctic_Ocean_Mammals (mammal_name,endangered) VALUES ('Beluga Whale',TRUE),('Narwhal',FALSE),('Polar Bear',TRUE);
SELECT COUNT(*) FROM Arctic_Ocean_Mammals WHERE endangered = TRUE;
What is the average BMI of patients with diabetes in Illinois?
CREATE TABLE patients (patient_id INT,age INT,state VARCHAR(255),BMI DECIMAL(5,2),diabetes BOOLEAN); INSERT INTO patients VALUES (1,35,'Illinois',25.5,TRUE); INSERT INTO patients VALUES (2,42,'Illinois',22.2,FALSE);
SELECT AVG(patients.BMI) FROM patients WHERE patients.state = 'Illinois' AND patients.diabetes = TRUE;
Insert a new record in the "defendants" table with the name "John Smith" for the case with id 1
CREATE TABLE defendants (id INT,name VARCHAR(50),case_id INT); CREATE TABLE cases (id INT,case_number VARCHAR(20),case_type VARCHAR(20),court_id INT); INSERT INTO cases (id,case_number,case_type,court_id) VALUES (1,'123456','civil',1); INSERT INTO cases (id,case_number,case_type,court_id) VALUES (2,'654321','criminal',2);
INSERT INTO defendants (id, name, case_id) VALUES (1, 'John Smith', 1);
What is the difference in mental health scores between students in grade 5 and grade 7?
CREATE TABLE mental_health_scores (student_id INT,grade INT,mental_health_score INT); INSERT INTO mental_health_scores (student_id,grade,mental_health_score) VALUES (1,5,80),(2,5,85),(3,6,70),(4,6,75),(5,7,80),(6,7,85);
SELECT grade, mental_health_score, CASE WHEN grade = 5 THEN mental_health_score - LAG(mental_health_score, 2) OVER (ORDER BY grade) ELSE mental_health_score - LEAD(mental_health_score, -2) OVER (ORDER BY grade) END AS score_difference FROM mental_health_scores;
Which causes received donations from donors in a specific region?
CREATE TABLE Donors (DonorID INT,Region VARCHAR(50)); CREATE TABLE Donations (DonationID INT,DonorID INT,Cause VARCHAR(50),Amount DECIMAL(10,2)); INSERT INTO Donors (DonorID,Region) VALUES (1,'North America'),(2,'South America'),(3,'North America'),(4,'Europe'),(5,'Asia'); INSERT INTO Donations (DonationID,DonorID,Cause,Amount) VALUES (1,1,'Education',2000),(2,2,'Health',3000),(3,1,'Education',1000),(4,4,'Environment',4000);
SELECT Cause FROM Donations D JOIN Donors R ON D.DonorID = R.DonorID WHERE R.Region = 'North America';
What is the total research grant amount awarded to the 'Computer Science' department?
CREATE TABLE departments (id INT,name TEXT); INSERT INTO departments (id,name) VALUES (1,'Computer Science'); CREATE TABLE grants (id INT,department_id INT,amount INT); INSERT INTO grants (id,department_id,amount) VALUES (1,1,500000);
SELECT SUM(amount) FROM grants WHERE department_id = (SELECT id FROM departments WHERE name = 'Computer Science');
List the cybersecurity strategies and their corresponding risk levels, and determine the maximum risk level.
CREATE TABLE cyber_strategies_risk (id INT,strategy VARCHAR,risk VARCHAR); INSERT INTO cyber_strategies_risk (id,strategy,risk) VALUES (1,'Operation Iron Curtain','Medium'),(2,'Operation Glass Shield','High'),(3,'Operation Cyber Guardian','Low');
SELECT strategy, risk, MAX(CASE WHEN risk = 'High' THEN 1 ELSE 0 END) OVER () as max_risk FROM cyber_strategies_risk;
What is the landfill capacity in megatons for 2022?
CREATE TABLE LandfillCapacity (year INT,capacity INT); INSERT INTO LandfillCapacity (year,capacity) VALUES (2018,10000),(2019,11000),(2020,11500),(2021,12000),(2022,NULL);
SELECT capacity FROM LandfillCapacity WHERE year = 2022;
Delete all projects in the USA
CREATE TABLE infrastructure_projects (id INT,name TEXT,location TEXT); INSERT INTO infrastructure_projects (id,name,location) VALUES (1,'Brooklyn Bridge','USA'); INSERT INTO infrastructure_projects (id,name,location) VALUES (2,'Chunnel','UK'); INSERT INTO infrastructure_projects (id,name,location) VALUES (3,'Tokyo Tower','Japan');
DELETE FROM infrastructure_projects WHERE location = 'USA';
What is the maximum playtime for players who have played the game 'Racing' and are younger than 25?
CREATE TABLE PlayerGameData (PlayerID INT,Age INT,Game VARCHAR(20),Playtime INT); INSERT INTO PlayerGameData (PlayerID,Age,Game,Playtime) VALUES (1,22,'Shooter',30),(2,25,'Shooter',50),(3,28,'Racing',70),(4,20,'Racing',60);
SELECT MAX(Playtime) FROM PlayerGameData WHERE Game = 'Racing' AND Age < 25;
List the clinical trials with a status of 'Completed' and their respective start dates.
CREATE TABLE clinical_trials(trial_name TEXT,status TEXT,start_date DATE); INSERT INTO clinical_trials(trial_name,status,start_date) VALUES('Trial1','Completed','2018-05-01'),('Trial2','Recruiting','2019-07-15'),('Trial3','Completed','2020-12-20'),('Trial4','Planned','2021-04-05');
SELECT trial_name, start_date FROM clinical_trials WHERE status = 'Completed';
What is the total CO2 emission in the 'emissions' table?
CREATE TABLE emissions (id INT,site VARCHAR(50),year INT,co2_emission FLOAT);
SELECT SUM(co2_emission) FROM emissions;
Which exploratory methods were used the most in 2017?
CREATE TABLE exploration_data (well_name VARCHAR(255),exploratory_method VARCHAR(255),discovery_date DATE); INSERT INTO exploration_data (well_name,exploratory_method,discovery_date) VALUES ('Well A','2D Seismic','2017-02-14'); INSERT INTO exploration_data (well_name,exploratory_method,discovery_date) VALUES ('Well B','3D Seismic','2016-09-01'); INSERT INTO exploration_data (well_name,exploratory_method,discovery_date) VALUES ('Well C','2D Seismic','2017-06-27'); INSERT INTO exploration_data (well_name,exploratory_method,discovery_date) VALUES ('Well D','3D Seismic','2018-11-15');
SELECT exploratory_method, COUNT(*) as method_count FROM exploration_data WHERE EXTRACT(YEAR FROM discovery_date) = 2017 GROUP BY exploratory_method ORDER BY method_count DESC
What is the maximum R&D expenditure for trials in 'CountryZ' in 2022?
CREATE TABLE rd_expenditure(trial_id TEXT,country TEXT,year INT,amount FLOAT); INSERT INTO rd_expenditure (trial_id,country,year,amount) VALUES ('Trial1','CountryX',2021,2500000),('Trial2','CountryY',2022,3000000),('Trial3','CountryZ',2022,3500000);
SELECT MAX(amount) FROM rd_expenditure WHERE country = 'CountryZ' AND year = 2022;
How many female faculty members work in STEM fields?
CREATE TABLE faculty (id INT,faculty_name TEXT,faculty_gender TEXT,faculty_field TEXT); INSERT INTO faculty (id,faculty_name,faculty_gender,faculty_field) VALUES (1,'Eliot','M','Physics'); INSERT INTO faculty (id,faculty_name,faculty_gender,faculty_field) VALUES (2,'Fiona','F','Math'); INSERT INTO faculty (id,faculty_name,faculty_gender,faculty_field) VALUES (3,'Grace','F','Computer Science');
SELECT faculty_gender, COUNT(*) FROM faculty WHERE faculty_field IN ('Physics', 'Math', 'Computer Science', 'Engineering') GROUP BY faculty_gender HAVING faculty_gender = 'F'
How many water conservation initiatives were launched in the state of Texas in the past 6 months?
CREATE TABLE conservation_initiatives (initiative_id INT,state VARCHAR(20),launch_date DATE); INSERT INTO conservation_initiatives (initiative_id,state,launch_date) VALUES (1,'Texas','2021-05-01'),(2,'Texas','2021-06-01'),(3,'California','2021-04-01');
SELECT COUNT(*) FROM conservation_initiatives WHERE state = 'Texas' AND launch_date > DATE_SUB(CURDATE(), INTERVAL 6 MONTH);
What is the total budget allocated for education and healthcare services in 2020 across all regions?
CREATE TABLE Budget (Year INT,Service VARCHAR(20),Region VARCHAR(20),Amount DECIMAL(10,2)); INSERT INTO Budget (Year,Service,Region,Amount) VALUES (2020,'Healthcare','Northeast',50000.00),(2020,'Healthcare','Southeast',60000.00),(2020,'Education','Northeast',45000.00);
SELECT SUM(Amount) FROM Budget WHERE Year = 2020 AND (Service = 'Healthcare' OR Service = 'Education');
Delete a donor from the "funding" table based in Germany
CREATE TABLE funding (id INT PRIMARY KEY,name VARCHAR(100),donation_date DATE,amount DECIMAL(10,2),country VARCHAR(50));
DELETE FROM funding WHERE country = 'Germany';
How many events attracted over 100 attendees from the LGBTQ+ community in 2022?
CREATE TABLE Events (EventID INT,EventDate DATE,EventAttendance INT,Community VARCHAR(20)); INSERT INTO Events (EventID,EventDate,EventAttendance,Community) VALUES (1,'2022-03-12',120,'LGBTQ+'),(2,'2022-04-20',80,'Women'),(3,'2022-05-15',150,'LGBTQ+'),(4,'2022-01-01',30,'Men'),(5,'2022-06-10',45,'Non-binary');
SELECT COUNT(*) FROM Events WHERE EventAttendance > 100 AND Community = 'LGBTQ+';
What is the average temperature for each genetic research experiment?
CREATE SCHEMA if not exists genetics;CREATE TABLE if not exists genetics.experiments (id INT,experiment_name VARCHAR(255),temperature_delta INT); INSERT INTO genetics.experiments (id,experiment_name,temperature_delta) VALUES (1,'CRISPR-Cas9',15),(2,'Gene Editing',22),(3,'Genetic Fusion',18);
SELECT experiment_name, AVG(temperature_delta) avg_temperature FROM genetics.experiments GROUP BY experiment_name;
Update the phone number for clinics that provide mental health services in Montana.
CREATE TABLE clinic_info (clinic_id INT,state VARCHAR(2),phone_number VARCHAR(15)); INSERT INTO clinic_info (clinic_id,state,phone_number) VALUES (1,'Montana','123-456-7890'),(2,'Montana','987-654-3210'),(3,'Wyoming','555-555-5555'); CREATE TABLE mental_health_services (service_id INT,clinic_id INT); INSERT INTO mental_health_services (service_id,clinic_id) VALUES (101,1),(102,2);
UPDATE clinic_info SET phone_number = '000-000-0000' WHERE clinic_id IN (SELECT clinic_id FROM mental_health_services);
What is the average mental health score of students in 'Fall 2021' term?
CREATE TABLE student_mental_health (student_id INT,term VARCHAR(10),mental_health_score INT); INSERT INTO student_mental_health (student_id,term,mental_health_score) VALUES (1,'Fall 2021',75),(2,'Fall 2021',80);
SELECT AVG(mental_health_score) FROM student_mental_health WHERE term = 'Fall 2021';
What is the average total funding for startups founded by Latinx individuals in the fintech sector?
CREATE TABLE IF NOT EXISTS startups(id INT,name TEXT,founder_race TEXT,total_funding FLOAT); INSERT INTO startups (id,name,founder_race,total_funding) VALUES (1,'Cladwell','Latinx',5000000); INSERT INTO startups (id,name,founder_race,total_funding) VALUES (2,'Propel','African American',12000000); INSERT INTO startups (id,name,founder_race,total_funding) VALUES (3,'Stripe','Asian',20000000); INSERT INTO startups (id,name,founder_race,total_funding) VALUES (4,'Acorns','Latinx',3000000);
SELECT AVG(total_funding) FROM startups WHERE founder_race = 'Latinx' AND industry = 'Fintech';
What is the total number of hours played by all players for each game genre, excluding strategy games?
CREATE TABLE players (id INT,name VARCHAR(20),hours_played INT); INSERT INTO players (id,name,hours_played) VALUES (1,'David',100),(2,'Eve',50),(3,'Frank',150),(4,'Grace',120),(5,'Harrison',80); CREATE TABLE game_genres (id INT,genre VARCHAR(20)); INSERT INTO game_genres (id,genre) VALUES (1,'FPS'),(2,'RPG'),(3,'Strategy'); CREATE TABLE game_sessions (id INT,player_id INT,game_genre_id INT,start_time TIMESTAMP,end_time TIMESTAMP); INSERT INTO game_sessions (id,player_id,game_genre_id,start_time,end_time) VALUES (1,1,1,'2021-01-01 10:00:00','2021-01-01 12:00:00'),(2,2,2,'2021-01-02 09:00:00','2021-01-02 11:00:00'),(3,3,1,'2021-01-03 13:00:00','2021-01-03 16:00:00'),(4,1,2,'2021-01-04 14:00:00','2021-01-04 17:00:00'),(5,2,1,'2021-01-05 11:00:00','2021-01-05 13:00:00');
SELECT game_genres.genre, SUM(players.hours_played) AS total_hours FROM players INNER JOIN game_sessions ON players.id = game_sessions.player_id INNER JOIN game_genres ON game_sessions.game_genre_id = game_genres.id WHERE game_genres.genre NOT IN ('Strategy') GROUP BY game_genres.genre;
Calculate the average CO2 emissions reduction per carbon offset project in the carbon_offsets table.
CREATE SCHEMA IF NOT EXISTS carbon_offsets; CREATE TABLE IF NOT EXISTS carbon_offsets.carbon_offsets (offset_id INT NOT NULL,country_code VARCHAR(2) NOT NULL,co2_emissions_reduction FLOAT NOT NULL,PRIMARY KEY (offset_id));
SELECT AVG(co2_emissions_reduction) FROM carbon_offsets.carbon_offsets;
What is the average salary of engineers in the "tech_company" database by gender?
CREATE TABLE employees (id INT,name VARCHAR(50),department VARCHAR(50),salary DECIMAL(10,2),gender VARCHAR(10)); INSERT INTO employees (id,name,department,salary,gender) VALUES (1,'John Doe','Software Engineer',150000.00,'Male'),(2,'Jane Smith','Data Analyst',120000.00,'Female'),(3,'Bob Brown','Software Engineer',140000.00,'Male'),(4,'Amy Lee','Software Engineer',145000.00,'Female');
SELECT department, AVG(salary), gender FROM employees WHERE department = 'Software Engineer' GROUP BY gender;
How many green buildings in the 'green_buildings' table have a 'Silver' certification level?
CREATE TABLE green_buildings (building_id INT,location TEXT,certification_level TEXT); INSERT INTO green_buildings (building_id,location,certification_level) VALUES (1,'Los Angeles','Gold'),(2,'Chicago','Platinum'),(3,'Houston','Silver'),(4,'Dallas','Gold'),(5,'Miami','Silver');
SELECT COUNT(*) FROM green_buildings WHERE certification_level = 'Silver';
What are the names and locations of all factories that produce chemical A?
CREATE TABLE factories (factory_id INT,name TEXT,location TEXT); INSERT INTO factories (factory_id,name,location) VALUES (1,'Factory A','New York'),(2,'Factory B','Los Angeles'); CREATE TABLE productions (factory_id INT,chemical TEXT); INSERT INTO productions (factory_id,chemical) VALUES (1,'Chemical A'),(2,'Chemical B');
SELECT f.name, f.location FROM factories f JOIN productions p ON f.factory_id = p.factory_id WHERE p.chemical = 'Chemical A';
Which biosensor technology has the most patents filed in the last 5 years?
CREATE SCHEMA if not exists biosensors;CREATE TABLE if not exists biosensors.patents (id INT,technology VARCHAR(50),company VARCHAR(100),filing_date DATE);INSERT INTO biosensors.patents (id,technology,company,filing_date) VALUES (1,'Bioelectric','CompanyA','2018-03-15'),(2,'Optical','CompanyB','2019-08-01'),(3,'Mechanical','CompanyC','2020-02-20');
SELECT technology, COUNT(*) as patent_count FROM biosensors.patents WHERE filing_date >= DATE_SUB(CURRENT_DATE, INTERVAL 5 YEAR) GROUP BY technology ORDER BY patent_count DESC LIMIT 1;
Display the dishes in the order of their addition, with the dish type and total calorie count.
CREATE TABLE dishes (dish_id INT,dish_name VARCHAR(50),dish_type VARCHAR(20),calorie_count INT,added_date DATE); INSERT INTO dishes (dish_id,dish_name,dish_type,calorie_count,added_date) VALUES (1,'Veggie Delight','vegan',300,'2021-05-01'),(2,'Tofu Stir Fry','vegan',450,'2021-05-02'),(3,'Chickpea Curry','vegan',500,'2021-05-03'),(4,'Lamb Korma','non-veg',900,'2021-05-04');
SELECT dish_name, dish_type, added_date, SUM(calorie_count) OVER (PARTITION BY dish_type ORDER BY added_date) total_calorie_count FROM dishes;
What is the total population of animals in 'habitat_preservation' table that are part of a community education program?
CREATE TABLE habitat_preservation (id INT,animal_name VARCHAR(50),population INT,community_education VARCHAR(50));
SELECT SUM(population) FROM habitat_preservation WHERE community_education = 'Yes';
Calculate the percentage of water usage for each sector in the African region.
CREATE TABLE water_usage (region VARCHAR(20),sector VARCHAR(20),usage INT); INSERT INTO water_usage (region,sector,usage) VALUES ('Asia','Agriculture',800),('Asia','Domestic',500),('Asia','Industrial',1000),('Africa','Agriculture',600),('Africa','Domestic',300),('Africa','Industrial',700);
SELECT sector, (usage/total_usage*100) AS Percentage FROM water_usage INNER JOIN (SELECT SUM(usage) AS total_usage FROM water_usage WHERE region = 'Africa') AS total ON 1=1 WHERE region = 'Africa'
Which artists from the 'music_streaming' table also have concert data in the 'concert_ticket_sales' table?
CREATE TABLE music_streaming (artist_id INT,artist_name VARCHAR(100),genre VARCHAR(50)); CREATE TABLE concert_ticket_sales (artist_id INT,concert_date DATE,venue VARCHAR(100));
SELECT artist_id, artist_name FROM music_streaming WHERE artist_id IN (SELECT artist_id FROM concert_ticket_sales);
What is the maximum severity level of vulnerabilities in the 'web_applications' table?
CREATE TABLE web_applications (id INT,name VARCHAR(255),severity VARCHAR(255)); INSERT INTO web_applications (id,name,severity) VALUES (1,'App1','high'),(2,'App2','medium'),(3,'App3','low'),(4,'App4','medium');
SELECT MAX(severity) FROM web_applications;
How many drought impacts were reported for the Clear Water Plant in the month of January 2022?
CREATE TABLE WastewaterTreatmentFacilities (FacilityID INT,FacilityName VARCHAR(255),Address VARCHAR(255),City VARCHAR(255),State VARCHAR(255),ZipCode VARCHAR(10)); INSERT INTO WastewaterTreatmentFacilities (FacilityID,FacilityName,Address,City,State,ZipCode) VALUES (1,'Clear Water Plant','1234 5th St','Houston','TX','77002'),(2,'Greenville Wastewater Treatment Plant','450 Powerhouse Rd','Greenville','SC','29605'); CREATE TABLE DroughtImpact (ImpactID INT,FacilityID INT,ImpactDate DATE,ImpactDescription VARCHAR(255)); INSERT INTO DroughtImpact (ImpactID,FacilityID,ImpactDate,ImpactDescription) VALUES (1,1,'2022-01-01','Reduced flow due to drought conditions'),(2,1,'2022-01-05','Operational changes to conserve water'),(3,2,'2022-01-10','Water restriction measures in place');
SELECT COUNT(*) FROM DroughtImpact WHERE FacilityID = 1 AND ImpactDate BETWEEN '2022-01-01' AND '2022-01-31';
What is the status of operational equipment in Australian mining operations older than 10 years?
CREATE TABLE Equipment (EquipmentID INT,EquipmentName VARCHAR(255),Status VARCHAR(255),Department VARCHAR(255),PurchaseDate DATE,Country VARCHAR(255));
SELECT EquipmentName, Status FROM Equipment WHERE Department IN ('Mining Operations', 'Processing') AND PurchaseDate < '2011-01-01' AND Status = 'Operational' AND Country = 'Australia';
What is the total data usage, in GB, for each customer in the last 3 months, ordered by the most data usage?
CREATE TABLE customers (customer_id INT,name VARCHAR(50),data_usage FLOAT); INSERT INTO customers (customer_id,name,data_usage) VALUES (1,'John Doe',45.6),(2,'Jane Smith',30.9),(3,'Mike Johnson',60.7);
SELECT customer_id, SUM(data_usage) as total_data_usage FROM customers WHERE usage_date >= DATEADD(month, -3, GETDATE()) GROUP BY customer_id ORDER BY total_data_usage DESC;
Reveal the wells with daily production rate less than 150
CREATE TABLE wells (id INT,well_name VARCHAR(255),location VARCHAR(255),drill_year INT,company VARCHAR(255),daily_production_rate DECIMAL(5,2)); INSERT INTO wells (id,well_name,location,drill_year,company,daily_production_rate) VALUES (1,'Well001','Texas',2020,'CompanyA',100.50); INSERT INTO wells (id,well_name,location,drill_year,company,daily_production_rate) VALUES (2,'Well002','Colorado',2019,'CompanyB',150.25); INSERT INTO wells (id,well_name,location,drill_year,company,daily_production_rate) VALUES (3,'Well003','California',2019,'CompanyC',200.00); INSERT INTO wells (id,well_name,location,drill_year,company,daily_production_rate) VALUES (4,'Well004','Oklahoma',2018,'CompanyD',175.25);
SELECT * FROM wells WHERE daily_production_rate < 150;
List the clinics located in 'southwest' region from 'rural_clinics' table?
CREATE SCHEMA if not exists rural_clinics; use rural_clinics; CREATE TABLE clinics (id int,name varchar(255),location varchar(255));
SELECT name FROM clinics WHERE location = 'southwest';
Update the climate_monitoring_network table to include a new network
CREATE SCHEMA IF NOT EXISTS arctic_db; CREATE TABLE IF NOT EXISTS climate_monitoring_network (id INT PRIMARY KEY,network_name TEXT,stations_count INT);
INSERT INTO climate_monitoring_network (id, network_name, stations_count) VALUES (1, 'North Pole Network', 10);
What is the average battery range of electric vehicles manufactured by 'Green Motors'?
CREATE TABLE ElectricVehicleStats (ID INT,Manufacturer VARCHAR(255),AvgBatteryRange FLOAT); INSERT INTO ElectricVehicleStats (ID,Manufacturer,AvgBatteryRange) VALUES (1,'Green Motors',280.0),(2,'Blue Cars',220.0),(3,'FutureAutomobiles',380.0),(4,'Green Motors',320.0),(5,'Green Motors',350.0);
SELECT AVG(AvgBatteryRange) FROM ElectricVehicleStats WHERE Manufacturer = 'Green Motors';
Which electric vehicle model has the highest safety rating?
CREATE TABLE EVSafetyRatings (Model VARCHAR(255),Manufacturer VARCHAR(255),SafetyRating FLOAT); INSERT INTO EVSafetyRatings (Model,Manufacturer,SafetyRating) VALUES ('Model S','Tesla',5.1),('Model 3','Tesla',4.9),('Prius','Toyota',4.6),('Civic','Honda',4.4);
SELECT Model, SafetyRating FROM EVSafetyRatings ORDER BY SafetyRating DESC LIMIT 1;
What is the maximum price of organic cosmetics sourced from Italy?
CREATE TABLE products (product_id INT,name TEXT,is_organic BOOLEAN,price DECIMAL,source_country TEXT); INSERT INTO products (product_id,name,is_organic,price,source_country) VALUES (1,'Lipstick',TRUE,20.99,'Italy'); INSERT INTO products (product_id,name,is_organic,price,source_country) VALUES (2,'Eye Shadow',FALSE,18.49,'Spain');
SELECT MAX(price) FROM products WHERE is_organic = TRUE AND source_country = 'Italy';
Find the top 3 community development initiatives with the highest total funding, in the 'development' schema.
CREATE SCHEMA development; CREATE TABLE initiatives (initiative_id INT,name VARCHAR(50),region VARCHAR(50),total_funding INT); INSERT INTO initiatives (initiative_id,name,region,total_funding) VALUES (1,'Healthcare Center','Asia',50000),(2,'Education Building','Africa',75000),(3,'Water Supply System','Europe',60000),(4,'School Construction','Asia',80000),(5,'University Building','Africa',95000);
SELECT initiative_id, name, region, total_funding FROM development.initiatives ORDER BY total_funding DESC LIMIT 3;
Summarize restorative justice programs awarded per month
CREATE TABLE programs (id INT PRIMARY KEY,start_date DATE,type VARCHAR(255));
SELECT MONTH(start_date) AS month, COUNT(*) FROM programs WHERE type = 'Restorative Justice' GROUP BY month;
What is the average number of followers for users in the food industry, in France, who have posted in the past month?
CREATE TABLE users (id INT,country VARCHAR(255),industry VARCHAR(255),followers INT,last_post_time DATETIME);
SELECT AVG(followers) FROM users WHERE country = 'France' AND industry = 'food' AND last_post_time > DATE_SUB(NOW(), INTERVAL 1 MONTH);
Which sustainable materials have a higher CO2 emissions than cotton in the 'sustainable_materials' table?
CREATE TABLE sustainable_materials (material_id INT,material TEXT,co2_emissions FLOAT);
SELECT * FROM sustainable_materials WHERE co2_emissions > (SELECT co2_emissions FROM sustainable_materials WHERE material = 'cotton');
What is the average price of vegetarian dishes in each category?
CREATE TABLE Orders (OrderID INT,OrderDate DATE,DishID INT,Quantity INT); CREATE TABLE Dishes (DishID INT,DishName VARCHAR(50),Category VARCHAR(50),Price DECIMAL(5,2),IsVegetarian INT); INSERT INTO Dishes (DishID,DishName,Category,Price,IsVegetarian) VALUES (1,'Veggie Pizza','Pizza',12.99,1),(2,'Margherita Pizza','Pizza',10.99,1),(3,'Chicken Caesar Salad','Salad',15.49,0),(4,'Garden Salad','Salad',11.99,1); INSERT INTO Orders (OrderID,OrderDate,DishID,Quantity) VALUES (1,'2022-01-01',1,2),(2,'2022-01-02',2,1),(3,'2022-01-03',3,3),(4,'2022-01-04',1,1),(5,'2022-02-05',4,2);
SELECT Category, AVG(Price) as AvgPrice FROM Dishes WHERE IsVegetarian = 1 GROUP BY Category;
What is the total sales for 'Lipstick' and 'Eye Shadow'?
CREATE TABLE Sales (SaleID int,ProductID int,ProductName varchar(50),Category varchar(50),SalesNumber int); INSERT INTO Sales (SaleID,ProductID,ProductName,Category,SalesNumber) VALUES (1,1,'Eye Shadow A','Eye Shadow',100),(2,2,'Eye Shadow B','Eye Shadow',200),(3,3,'Lipstick C','Lipstick',300);
SELECT Category, SUM(SalesNumber) as TotalSales FROM Sales WHERE Category IN ('Lipstick', 'Eye Shadow') GROUP BY Category;
What is the average age of patients who have received treatment for depression?
CREATE TABLE patients (id INT PRIMARY KEY,age INT,gender TEXT); INSERT INTO patients (id,age,gender) VALUES (1,45,'Female'); INSERT INTO patients (id,age,gender) VALUES (2,50,'Male'); INSERT INTO patients (id,age,gender) VALUES (3,35,'Female'); INSERT INTO patients (id,age,gender) VALUES (4,60,'Male'); INSERT INTO patients (id,age,gender) VALUES (5,25,'Female'); CREATE TABLE treatments (id INT PRIMARY KEY,patient_id INT,condition TEXT); INSERT INTO treatments (id,patient_id,condition) VALUES (1,1,'Depression'); INSERT INTO treatments (id,patient_id,condition) VALUES (2,2,'Anxiety'); INSERT INTO treatments (id,patient_id,condition) VALUES (3,3,'PTSD'); INSERT INTO treatments (id,patient_id,condition) VALUES (4,4,'Depression'); INSERT INTO treatments (id,patient_id,condition) VALUES (5,5,'Depression');
SELECT AVG(patients.age) FROM patients INNER JOIN treatments ON patients.id = treatments.patient_id WHERE treatments.condition = 'Depression';
List all ships and their last recorded positions that entered the Mediterranean Sea in the last week.
CREATE TABLE ships (id INT,ship_name VARCHAR(50),last_position_lat DECIMAL(8,6),last_position_lon DECIMAL(8,6),last_position_timestamp TIMESTAMP); INSERT INTO ships (id,ship_name,last_position_lat,last_position_lon,last_position_timestamp) VALUES (1,'Ship A',37.7749,-122.4194,'2022-01-01 12:00:00'),(2,'Ship B',40.7128,-74.0060,'2022-01-07 10:30:00');
SELECT ship_name, last_position_lat, last_position_lon FROM ships WHERE last_position_timestamp >= NOW() - INTERVAL '7 days' AND ocean = 'Mediterranean Sea' ORDER BY last_position_timestamp DESC;
What is the maximum budget for AI projects in the healthcare sector?
CREATE TABLE ai_projects (sector VARCHAR(20),budget INT); INSERT INTO ai_projects (sector,budget) VALUES ('Education',200000),('Healthcare',500000),('Finance',1000000),('Technology',300000);
SELECT MAX(budget) FROM ai_projects WHERE sector = 'Healthcare';
Which countries have not implemented any maritime safety measures in the past decade?
CREATE TABLE maritime_safety_measures (country VARCHAR(255),year INT,measure_type VARCHAR(255));
SELECT country FROM maritime_safety_measures WHERE measure_type IS NULL AND year BETWEEN 2011 AND 2021 GROUP BY country;
What is the average age of players who identify as non-binary and play action games?
CREATE TABLE players (id INT,age INT,gender VARCHAR(20),game_genre VARCHAR(20)); INSERT INTO players (id,age,gender,game_genre) VALUES (1,25,'male','action'),(2,30,'non-binary','adventure'),(3,22,'male','racing'),(4,18,'female','action'),(5,28,'non-binary','action'),(6,35,'non-binary','rpg'),(7,40,'male','strategy');
SELECT ROUND(AVG(age), 2) FROM players WHERE gender = 'non-binary' AND game_genre = 'action';
Which indigenous languages are currently taught in 'School Y'?
CREATE TABLE Language_Preservation (id INT,school VARCHAR(50),language VARCHAR(50)); INSERT INTO Language_Preservation (id,school,language) VALUES (1,'School Y','Quechua');
SELECT language FROM Language_Preservation WHERE school = 'School Y';
What is the total amount of loans issued per community development initiative in North America?
CREATE TABLE CommunityDevelopment (ProjectID INT,ProjectName VARCHAR(50),Location VARCHAR(50),AmountOfLoans FLOAT); INSERT INTO CommunityDevelopment (ProjectID,ProjectName,Location,AmountOfLoans) VALUES (1,'Clean Water Project','USA',50000.00),(2,'Renewable Energy Initiative','Canada',75000.00);
SELECT ProjectName, SUM(AmountOfLoans) FROM CommunityDevelopment WHERE Location IN ('USA', 'Canada') GROUP BY ProjectName;
What is the minimum number of union members in workplaces that have successful collective bargaining?
CREATE TABLE workplaces (id INT,name TEXT,location TEXT,sector TEXT,total_employees INT,union_members INT,successful_cb BOOLEAN,cb_year INT);
SELECT MIN(union_members) FROM workplaces WHERE successful_cb = TRUE;
Get the number of marine protected areas created each year
CREATE TABLE marine_protected_areas_history (year INT,new_areas INT);
SELECT year, COUNT(*) FROM marine_protected_areas_history GROUP BY year ORDER BY year;
List the co-owned properties in Vancouver and their respective co-owners.
CREATE TABLE Vancouver_Properties (PropertyID INT,Owner1 VARCHAR(255),Owner2 VARCHAR(255)); INSERT INTO Vancouver_Properties (PropertyID,Owner1,Owner2) VALUES (1,'Alex','Jamie'),(2,'Taylor','Andrew'),(3,'Kelly','Steve'),(4,'Nicole','Ben');
SELECT Vancouver_Properties.PropertyID, Owner1, Owner2 FROM Vancouver_Properties;
Determine the number of ethical labor practice violations per supplier type, along with the last inspection date.
CREATE TABLE suppliers (supplier_id INT,supplier_type VARCHAR(255));CREATE TABLE violations (violation_id INT,violation_count INT,FK_supplier_id REFERENCES suppliers(supplier_id));CREATE TABLE inspections (inspection_id INT,last_inspection_date DATE,FK_supplier_id REFERENCES suppliers(supplier_id));
SELECT s.supplier_type, v.violation_count, i.last_inspection_date FROM suppliers s JOIN violations v ON s.supplier_id = v.supplier_id JOIN inspections i ON s.supplier_id = i.supplier_id GROUP BY s.supplier_type, v.violation_count, i.last_inspection_date;
What is the average ticket price for dance events in the cities of New York and Chicago?
CREATE TABLE events (name VARCHAR(255),location VARCHAR(255),category VARCHAR(255),price DECIMAL(5,2)); INSERT INTO events (name,location,category,price) VALUES ('Swan Lake','Chicago','Dance',95.00),('The Nutcracker','New York','Dance',125.00),('Hamilton','Chicago','Theatre',225.00);
SELECT AVG(price) FROM events WHERE location IN ('New York', 'Chicago') AND category = 'Dance';
How many food safety violations occurred per location?
CREATE TABLE Locations (Location_ID INT,Location_Name TEXT); INSERT INTO Locations (Location_ID,Location_Name) VALUES (1,'Location1'),(2,'Location2'); CREATE TABLE Inspections (Inspection_ID INT,Location_ID INT,Violation_Count INT); INSERT INTO Inspections (Inspection_ID,Location_ID,Violation_Count) VALUES (1,1,3),(2,1,2),(3,2,1),(4,2,0);
SELECT Location_Name, SUM(Violation_Count) as Total_Violations FROM Inspections I JOIN Locations L ON I.Location_ID = L.Location_ID GROUP BY Location_Name;
Update light intensity records for sensor 012 on 2023-03-06 to 10000 lux
CREATE TABLE LightIntensityData (date DATE,intensity INT,sensor_id INT,FOREIGN KEY (sensor_id) REFERENCES SensorData(sensor_id));
UPDATE LightIntensityData SET intensity = 10000 WHERE sensor_id = 12 AND date = '2023-03-06';
What is the maximum ocean acidification level ever recorded in the Pacific Ocean?
CREATE TABLE ocean_acidification (id INT,location TEXT,value FLOAT); INSERT INTO ocean_acidification (id,location,value) VALUES (1,'Pacific Ocean',8.2); INSERT INTO ocean_acidification (id,location,value) VALUES (2,'Atlantic Ocean',7.9);
SELECT MAX(value) FROM ocean_acidification WHERE location = 'Pacific Ocean';
Find the recycling rate for 'Africa' in 2020 and 2021 from the 'recycling_rates' table
CREATE TABLE recycling_rates (country VARCHAR(50),year INT,recycling_rate FLOAT);
SELECT year, AVG(recycling_rate) FROM recycling_rates WHERE year IN (2020, 2021) AND country = 'Africa' GROUP BY year;
What is the total number of accommodations provided in the Music department, and the total number of accommodations provided in the Mathematics department?
CREATE TABLE MusicAccommodations (AccommodationID INT,Department VARCHAR(20)); INSERT INTO MusicAccommodations (AccommodationID,Department) VALUES (1,'Music'),(2,'Music'),(3,'Music'); CREATE TABLE MathematicsAccommodations (AccommodationID INT,Department VARCHAR(20)); INSERT INTO MathematicsAccommodations (AccommodationID,Department) VALUES (4,'Mathematics'),(5,'Mathematics'),(6,'Mathematics');
SELECT COUNT(*) FROM MusicAccommodations WHERE Department = 'Music' UNION SELECT COUNT(*) FROM MathematicsAccommodations WHERE Department = 'Mathematics';
Find the number of artifacts from the pre-Columbian period and the earliest date of an excavation site in South America.
CREATE TABLE Sites (id INT,site_name VARCHAR(50),location VARCHAR(50),period VARCHAR(50),type VARCHAR(50)); INSERT INTO Sites (id,site_name,location,period,type) VALUES (1,'Site1','Location1','Pre-Columbian','Excavation'),(2,'Site2','South America','Medieval','Settlement'); CREATE TABLE Artifacts (id INT,site VARCHAR(50),artifact_name VARCHAR(50),date_found DATE,description TEXT); INSERT INTO Artifacts (id,site,artifact_name,date_found,description) VALUES (1,'Site1','Ancient Pottery','2000-01-01','Well-preserved pottery from the pre-Columbian era');
SELECT COUNT(a.id) as artifact_count, MIN(s.date_established) as earliest_date FROM Sites s JOIN Artifacts a ON s.site_name = a.site WHERE s.period = 'Pre-Columbian' AND s.location = 'South America';
Insert records for 3 arctic climate records into the "climate" table
CREATE TABLE climate (id INT PRIMARY KEY,year INT,temperature FLOAT,precipitation FLOAT,location VARCHAR(100));
WITH climate_data AS (VALUES (2010, -20.1, 50.0, 'North Pole'), (2011, -19.5, 52.3, 'North Pole'), (2012, -18.8, 54.2, 'North Pole')) INSERT INTO climate SELECT * FROM climate_data;
What is the total budget for all disability support programs?
CREATE TABLE support_programs (id INT,program_name VARCHAR(50),budget INT); INSERT INTO support_programs (id,program_name,budget) VALUES (1,'Mentorship Program',10000),(2,'Tutoring Program',15000),(3,'Accessibility Improvements',20000);
SELECT SUM(support_programs.budget) AS total_budget FROM support_programs;
List the top 2 countries with the most agricultural automation patents filed in the last 3 months in South America.
CREATE TABLE automation_patents (id INT,country VARCHAR(255),patent_date DATE); INSERT INTO automation_patents (id,country,patent_date) VALUES (5,'Brazil','2022-03-17'),(6,'Argentina','2022-04-01'),(7,'Brazil','2022-04-03'),(8,'Chile','2022-04-04'),(9,'Argentina','2022-04-02');
SELECT country, COUNT(*) as patent_count FROM automation_patents WHERE patent_date >= DATE_SUB(CURRENT_DATE, INTERVAL 3 MONTH) AND country LIKE '%South America%' GROUP BY country ORDER BY patent_count DESC LIMIT 2;
How many clients have an investment greater than $10,000 in any fund?
CREATE TABLE clients (client_id INT,name VARCHAR(50),investment FLOAT); CREATE TABLE fund_investments (client_id INT,fund_name VARCHAR(50),investment FLOAT);
SELECT COUNT(DISTINCT clients.client_id) FROM clients INNER JOIN fund_investments ON clients.client_id = fund_investments.client_id WHERE clients.investment > 10000;
What was the revenue from Music Streaming in India?
CREATE TABLE MusicStreaming (id INT,country VARCHAR(20),revenue FLOAT); INSERT INTO MusicStreaming (id,country,revenue) VALUES (1,'USA',1000000.0),(2,'India',500000.0);
SELECT SUM(revenue) FROM MusicStreaming WHERE country = 'India';
How many military technologies were developed in '2019' according to the 'Mil_Tech' table?
CREATE TABLE Mil_Tech (tech_id INT,tech_name VARCHAR(50),tech_year INT,tech_type VARCHAR(50)); INSERT INTO Mil_Tech (tech_id,tech_name,tech_year,tech_type) VALUES (1,'Stealth Fighter',2019,'Aircraft'); INSERT INTO Mil_Tech (tech_id,tech_name,tech_year,tech_type) VALUES (2,'Carrier Battlegroup',2017,'Naval');
SELECT COUNT(*) FROM Mil_Tech WHERE tech_year = 2019;
Update the "employee_training" table to reflect that employee E002 has completed the training for "Chemical Safety" on January 3, 2022.
CREATE TABLE employee_training (employee_id varchar(10),training_topic varchar(255),training_date date);
UPDATE employee_training SET training_date = '2022-01-03' WHERE employee_id = 'E002' AND training_topic = 'Chemical Safety';
What is the total population of endangered species in the 'endangered_species' table?
CREATE TABLE endangered_species (species_id INT,animal_name VARCHAR(50),population INT); INSERT INTO endangered_species (species_id,animal_name,population) VALUES (1,'Giant Panda',1800),(2,'Black Rhino',5000),(3,'Mountain Gorilla',1000);
SELECT SUM(population) FROM endangered_species;
List all autonomous driving research papers published in Europe in 2019 and 2020?
CREATE TABLE ResearchPapers(Id INT,Title VARCHAR(50),Author VARCHAR(50),Year INT,Domain VARCHAR(50)); INSERT INTO ResearchPapers(Id,Title,Author,Year,Domain) VALUES (1,'Autonomous Driving Algorithms','Li,X.',2019,'Europe'); INSERT INTO ResearchPapers(Id,Title,Author,Year,Domain) VALUES (2,'Deep Learning for Self-Driving Cars','Kim,Y.',2020,'Europe');
SELECT Title, Author FROM ResearchPapers WHERE Year IN (2019, 2020) AND Domain = 'Europe';
List all female researchers who led deep-sea expeditions?
CREATE TABLE deep_sea_expeditions (expedition_id INTEGER,leader_name TEXT); INSERT INTO deep_sea_expeditions (expedition_id,leader_name) VALUES (1,'John Doe'),(2,'Jane Smith'),(3,'Alice Johnson');
SELECT expedition_id, leader_name FROM deep_sea_expeditions WHERE leader_name LIKE '%%%';
How many patients with diabetes were treated in rural healthcare facilities, broken down by race and ethnicity?
CREATE TABLE treatments (treatment_id INT,patient_id INT,healthcare_id INT,date DATE); CREATE TABLE patients (patient_id INT,disease TEXT,age INT,gender TEXT,race TEXT,ethnicity TEXT); CREATE TABLE healthcare_facilities (healthcare_id INT,name TEXT,type TEXT,rural BOOLEAN); INSERT INTO treatments (treatment_id,patient_id,healthcare_id,date) VALUES (1,1,1,'2021-01-01'),(2,2,2,'2021-01-02'); INSERT INTO patients (patient_id,disease,age,gender,race,ethnicity) VALUES (1,'Diabetes',50,'Female','Asian','Non-Hispanic'),(2,'Diabetes',60,'Male','Black','Hispanic'); INSERT INTO healthcare_facilities (healthcare_id,name,type,rural) VALUES (1,'Rural General Hospital','Hospital',TRUE),(2,'Rural Clinic','Clinic',TRUE);
SELECT patients.race, patients.ethnicity, COUNT(treatments.treatment_id) as count FROM treatments INNER JOIN patients ON treatments.patient_id = patients.patient_id INNER JOIN healthcare_facilities ON treatments.healthcare_id = healthcare_facilities.healthcare_id WHERE patients.disease = 'Diabetes' AND healthcare_facilities.rural = TRUE GROUP BY patients.race, patients.ethnicity;
Insert a new record of Terbium production in South Africa for 2022 with 1200 tons.
CREATE TABLE production (country VARCHAR(255),REE VARCHAR(255),amount INT,year INT);
INSERT INTO production (country, REE, amount, year) VALUES ('South Africa', 'Terbium', 1200, 2022);
Delete records for volunteers who worked less than 10 hours on any program
CREATE TABLE Volunteers (VolunteerID INT,VolunteerName TEXT); INSERT INTO Volunteers (VolunteerID,VolunteerName) VALUES (1,'Aisha Ahmed'); INSERT INTO Volunteers (VolunteerID,VolunteerName) VALUES (2,'Bhavik Patel'); CREATE TABLE VolunteerHours (VolunteerID INT,Hours DECIMAL); INSERT INTO VolunteerHours (VolunteerID,Hours) VALUES (1,5); INSERT INTO VolunteerHours (VolunteerID,Hours) VALUES (2,20);
DELETE FROM Volunteers WHERE VolunteerID IN (SELECT VolunteerID FROM VolunteerHours WHERE Hours < 10);
What is the minimum age of candidates who ran for office in each election?
CREATE TABLE election (year INT,candidates INT); CREATE TABLE candidate (name VARCHAR(255),age INT,election_year INT); INSERT INTO election (year,candidates) VALUES (2016,10),(2018,15),(2020,20),(2022,25),(2024,30); INSERT INTO candidate (name,age,election_year) VALUES ('Candidate A',40,2016),('Candidate B',35,2016),('Candidate C',45,2018),('Candidate D',50,2018),('Candidate E',55,2020);
SELECT election_year, MIN(age) FROM candidate GROUP BY election_year;
Add new records to the "game_stats" table for the "RPG Quest" game
CREATE TABLE game_stats (game_name VARCHAR(255),players_online INT,peak_players INT,average_session_length TIME);
INSERT INTO game_stats (game_name, players_online, peak_players, average_session_length) VALUES ('RPG Quest', 5000, 7000, '01:30:00'), ('RPG Quest', 5500, 7500, '01:45:00');
How many active astronauts are there from African countries?
CREATE TABLE astronauts (id INT,name VARCHAR(50),status VARCHAR(50),country VARCHAR(50)); INSERT INTO astronauts (id,name,status,country) VALUES (1,'Mark Shuttleworth','active','South Africa'); INSERT INTO astronauts (id,name,status,country) VALUES (2,'Anousheh Ansari','active','Iran');
SELECT COUNT(*) FROM astronauts WHERE status = 'active' AND country IN ('Algeria', 'Angola', 'Benin', 'Botswana', 'Burkina Faso', '...');
What is the average horsepower of sports cars manufactured in Germany?
CREATE TABLE manufacturers (manufacturer_id INT,name VARCHAR(100),country VARCHAR(50)); INSERT INTO manufacturers (manufacturer_id,name,country) VALUES (1,'Audi','Germany'),(2,'BMW','Germany'),(3,'Porsche','Germany'); CREATE TABLE cars (car_id INT,model VARCHAR(100),manufacturer_id INT,horsepower INT); INSERT INTO cars (car_id,model,manufacturer_id,horsepower) VALUES (1,'R8',1,540),(2,'M3',2,473),(3,'911',3,443);
SELECT AVG(cars.horsepower) AS avg_horsepower FROM cars JOIN manufacturers ON cars.manufacturer_id = manufacturers.manufacturer_id WHERE manufacturers.country = 'Germany' AND manufacturers.name IN ('Audi', 'BMW', 'Porsche') AND cars.model LIKE '%sport%';
What is the adoption rate of electric vehicles per country in the electric_vehicle_adoption table?
CREATE TABLE electric_vehicle_adoption (country VARCHAR(50),adoption_rate FLOAT);
SELECT country, adoption_rate FROM electric_vehicle_adoption;
What is the average number of games won by player 'Amina'?
CREATE TABLE player_game_stats (player_name TEXT,week INT,games_won INT); INSERT INTO player_game_stats (player_name,week,games_won) VALUES ('Jamal',1,5); INSERT INTO player_game_stats (player_name,week,games_won) VALUES ('Jamal',2,6); INSERT INTO player_game_stats (player_name,week,games_won) VALUES ('Amina',1,4); INSERT INTO player_game_stats (player_name,week,games_won) VALUES ('Amina',2,7);
SELECT player_name, AVG(games_won) FROM player_game_stats WHERE player_name = 'Amina';
What is the total number of articles published in the 'Investigative Reports' category in the year 2020?
CREATE TABLE news (id INT,title TEXT,published DATE,category TEXT); INSERT INTO news (id,title,published,category) VALUES (1,'Investigation 1','2020-03-15','Investigative Reports');
SELECT COUNT(*) FROM news WHERE category = 'Investigative Reports' AND YEAR(published) = 2020;
What is the distribution of funding for research in Algorithmic Fairness by country?
CREATE TABLE funding_data (project_id INT,project_name VARCHAR(50),country VARCHAR(50),amount FLOAT);
SELECT country, SUM(amount) as total_funding FROM funding_data WHERE project_name LIKE '%Algorithmic Fairness%' GROUP BY country;
Create a table named 'military_equipment'
CREATE TABLE military_equipment (equipment_id INT,name VARCHAR(255),type VARCHAR(255),country_of_origin VARCHAR(255),year INT);
CREATE TABLE military_equipment (equipment_id INT, name VARCHAR(255), type VARCHAR(255), country_of_origin VARCHAR(255), year INT);