instruction
stringlengths
0
1.06k
input
stringlengths
11
5.3k
response
stringlengths
2
4.44k
What is the maximum project duration for sustainable building projects in 'Oregon'?
CREATE TABLE sustainable_projects (id INT,project_name TEXT,duration INT,state TEXT,sustainable BOOLEAN); INSERT INTO sustainable_projects (id,project_name,duration,state,sustainable) VALUES (1,'GreenVille',120,'Oregon',true),(2,'Eco-Town',180,'Texas',true);
SELECT MAX(duration) FROM sustainable_projects WHERE state = 'Oregon' AND sustainable = true;
How many marine fish farms in Indonesia use recirculating aquaculture systems (RAS)?
CREATE TABLE marinefarms (country VARCHAR(20),uses_ras BOOLEAN); INSERT INTO marinefarms (country,uses_ras) VALUES ('Indonesia',true),('Indonesia',false),('Philippines',true);
SELECT COUNT(*) FROM marinefarms WHERE country = 'Indonesia' AND uses_ras = true;
Which vendors have the highest percentage of sustainable materials?
CREATE TABLE vendors (vendor_id INT,name TEXT,sustainable_materials_percentage DECIMAL(3,2)); INSERT INTO vendors (vendor_id,name,sustainable_materials_percentage) VALUES (1,'Vendor A',0.75),(2,'Vendor B',0.85),(3,'Vendor C',0.65);
SELECT name, sustainable_materials_percentage FROM vendors ORDER BY sustainable_materials_percentage DESC LIMIT 1;
What is the total number of disability support programs offered by each region?
CREATE TABLE regions (id INT,name VARCHAR(255)); INSERT INTO regions (id,name) VALUES (1,'Northeast'),(2,'Southeast'),(3,'Midwest'),(4,'South'),(5,'West'); CREATE TABLE support_programs (id INT,region_id INT,name VARCHAR(255),type VARCHAR(255)); INSERT INTO support_programs (id,region_id,name,type) VALUES (1,1,'Assisti...
SELECT regions.name AS region, COUNT(support_programs.id) AS total_programs FROM regions LEFT JOIN support_programs ON regions.id = support_programs.region_id GROUP BY regions.name;
What is the total number of vaccination centers and testing sites in the public health database?
CREATE TABLE vaccination_centers (id INT,name VARCHAR(50),location VARCHAR(50)); INSERT INTO vaccination_centers (id,name,location) VALUES (1,'Vaccination Center A','City A'); INSERT INTO vaccination_centers (id,name,location) VALUES (2,'Vaccination Center B','City B'); CREATE TABLE testing_sites (id INT,name VARCHAR(5...
SELECT COUNT(*) FROM vaccination_centers UNION SELECT COUNT(*) FROM testing_sites;
Get the top 3 legal aid request categories by total requests and total costs
CREATE TABLE LegalAidRequests (Category TEXT,Request INT,Cost FLOAT); INSERT INTO LegalAidRequests (Category,Request,Cost) VALUES ('Domestic Violence',500,25000),('Public Defender',300,15000),('Immigration',200,10000),('Housing',150,7500),('Debt',100,5000);
SELECT Category, SUM(Request) AS TotalRequests, SUM(Cost) AS TotalCosts FROM LegalAidRequests GROUP BY Category ORDER BY TotalRequests DESC, TotalCosts DESC LIMIT 3;
Find the total number of aquatic species that have been introduced to a new habitat in the last 5 years.
CREATE TABLE species_introductions (id INT,species VARCHAR(255),date DATE); INSERT INTO species_introductions (id,species,date) VALUES (1,'Trout','2018-01-01'),(2,'Catfish','2019-05-15'),(3,'Bass','2020-12-31'),(4,'Perch','2021-03-14');
SELECT COUNT(*) FROM species_introductions WHERE date >= DATE_SUB(CURDATE(), INTERVAL 5 YEAR);
get tv shows with rating greater than 7 in the tv_shows table
CREATE TABLE tv_shows(id INT PRIMARY KEY,name VARCHAR(255),rating INT);
SELECT name FROM tv_shows WHERE rating > 7;
Update the 'data_usage' value to 40 for the record with 'subscriber_id' 10 in the 'subscribers' table.
CREATE TABLE subscribers (subscriber_id INT,name VARCHAR(50),data_usage FLOAT);
UPDATE subscribers SET data_usage = 40 WHERE subscriber_id = 10;
Identify any machines in the manufacturing process that have not been inspected in the past month.
CREATE TABLE machines (machine_id INT,last_inspection DATE); INSERT INTO machines VALUES (1,'2022-01-01'),(2,'2022-02-15'),(3,'2022-03-05'),(4,'2022-04-10'),(5,'2022-05-02');
SELECT machine_id FROM machines WHERE last_inspection < DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH);
What is the minimum salary for employees in the Engineering department who identify as women of color?
CREATE TABLE Employees (EmployeeID INT,Department VARCHAR(20),Gender VARCHAR(20),IdentifiesAsWomenOfColor BOOLEAN,Salary DECIMAL(10,2)); INSERT INTO Employees (EmployeeID,Department,Gender,IdentifiesAsWomenOfColor,Salary) VALUES (1,'Engineering','Female',true,80000.00),(2,'Finance','Male',false,90000.00),(3,'Engineerin...
SELECT MIN(Salary) FROM Employees WHERE Department = 'Engineering' AND IdentifiesAsWomenOfColor = true;
What is the average diversity score of startups that have received funding in the last 3 years, grouped by industry?
CREATE TABLE company (id INT,name TEXT,industry TEXT,founding_year INT,diversity_score INT); INSERT INTO company (id,name,industry,founding_year,diversity_score) VALUES (1,'InnoTech','Tech',2018,80); INSERT INTO company (id,name,industry,founding_year,diversity_score) VALUES (2,'GreenEnergy','Energy',2019,90); INSERT I...
SELECT industry, AVG(diversity_score) FROM company INNER JOIN funding ON company.id = funding.company_id WHERE funding.funding_date >= DATEADD(year, -3, GETDATE()) GROUP BY industry;
List the volunteers who have volunteered for more than one program, in alphabetical order by volunteer name.
CREATE TABLE Volunteers (VolunteerID INT,VolunteerName TEXT,Program TEXT); INSERT INTO Volunteers (VolunteerID,VolunteerName,Program) VALUES (1,'John Doe','Feeding Program'),(2,'Jane Smith','Education Program'),(3,'Bob Johnson','Feeding Program'),(4,'Alice Davis','Education Program'),(5,'Charlie Brown','Feeding Program...
SELECT VolunteerName, Program FROM (SELECT VolunteerName, Program, COUNT(*) OVER (PARTITION BY VolunteerName) AS CountVolunteer FROM Volunteers) AS SubQuery WHERE CountVolunteer > 1 ORDER BY VolunteerName;
Which renewable energy projects in Europe do not have any associated carbon offset initiatives?
CREATE TABLE renewable_energy (project_id INT,project_name TEXT,location TEXT); CREATE TABLE carbon_offsets (project_id INT,initiative_name TEXT,location TEXT); INSERT INTO renewable_energy (project_id,project_name,location) VALUES (1,'Solar Field One','Europe'),(2,'Wind Farm Two','North America'); INSERT INTO carbon_o...
SELECT project_name FROM renewable_energy WHERE project_id NOT IN (SELECT project_id FROM carbon_offsets WHERE renewable_energy.location = carbon_offsets.location);
Find the number of public schools in the state of California and Texas, excluding any schools with a rating below 7.
CREATE TABLE Schools (name VARCHAR(50),state VARCHAR(20),rating INT); INSERT INTO Schools (name,state,rating) VALUES ('SchoolA','California',8),('SchoolB','California',7),('SchoolC','Texas',9);
SELECT COUNT(*) FROM Schools WHERE state IN ('California', 'Texas') AND rating >= 7;
Which members have a gym membership and a yoga membership?
CREATE TABLE gym_members(member_id INT,name VARCHAR(50),start_date DATE,end_date DATE); INSERT INTO gym_members(member_id,name,start_date,end_date) VALUES (1,'John Doe','2021-01-01','2022-12-31'); INSERT INTO gym_members(member_id,name,start_date,end_date) VALUES (2,'Jane Smith','2021-05-15','2023-05-14'); CREATE TABLE...
SELECT gm.member_id, gm.name FROM gym_members gm INNER JOIN yoga_members ym ON gm.member_id = ym.member_id;
What is the total revenue generated by sustainable tourism initiatives in Tokyo?
CREATE TABLE revenue (initiative_id INT,city TEXT,country TEXT,revenue FLOAT); INSERT INTO revenue (initiative_id,city,country,revenue) VALUES (5,'Tokyo Sustainable Tour','Tokyo',500000);
SELECT SUM(revenue) FROM revenue WHERE city = 'Tokyo' AND country = 'Japan';
What is the total revenue and player count for each game genre?
CREATE TABLE games (game_id INT,genre VARCHAR(50),player_count INT,revenue DECIMAL(10,2)); INSERT INTO games VALUES (1,'Action',10000,50000.00),(2,'Adventure',8000,45000.00),(3,'Simulation',12000,60000.00);
SELECT genre, SUM(player_count) as total_players, SUM(revenue) as total_revenue FROM games GROUP BY genre;
What is the average depth of marine species in the Southern Ocean that are affected by ocean acidification?
CREATE TABLE marine_species (name TEXT,affected_by_acidification BOOLEAN,ocean TEXT,min_depth FLOAT); CREATE TABLE ocean_regions (name TEXT,area FLOAT);
SELECT AVG(min_depth) FROM marine_species WHERE affected_by_acidification = TRUE AND ocean = (SELECT name FROM ocean_regions WHERE area = 'Southern Ocean');
find the percentage of forest area in each state in the year 2020
CREATE TABLE forests (id INT,state VARCHAR(255),area_ha INT,year INT);
SELECT state, ROUND(100.0 * area_ha / (SELECT SUM(area_ha) FROM forests WHERE year = 2020 AND state = forests.state), 2) as percentage FROM forests WHERE year = 2020 GROUP BY state;
What is the total number of disaster preparedness drills conducted in the state of Florida in 2019?
CREATE TABLE disaster_preparedness (id INT,state VARCHAR(50),year INT,drills INT); INSERT INTO disaster_preparedness (id,state,year,drills) VALUES (1,'Florida',2019,50); INSERT INTO disaster_preparedness (id,state,year,drills) VALUES (2,'Florida',2018,40);
SELECT SUM(drills) FROM disaster_preparedness WHERE state = 'Florida' AND year = 2019;
How many fish were added to or removed from each aquafarm daily?
CREATE TABLE aquafarms (id INT,name TEXT); INSERT INTO aquafarms (id,name) VALUES (1,'Farm A'),(2,'Farm B'),(3,'Farm C'); CREATE TABLE fish_movement (aquafarm_id INT,timestamp TIMESTAMP,movement_type TEXT,quantity INT);
SELECT aquafarm_id, DATE(timestamp) AS date, SUM(quantity) AS daily_movement FROM fish_movement JOIN aquafarms ON fish_movement.aquafarm_id = aquafarms.id GROUP BY aquafarm_id, date;
What is the most attended cultural event in each state, along with the event's name and the number of attendees?
CREATE TABLE cultural_events (id INT,name VARCHAR(255),state VARCHAR(255),attendance INT); CREATE VIEW state_events AS SELECT * FROM cultural_events WHERE attendance = (SELECT MAX(attendance) FROM cultural_events e WHERE e.state = cultural_events.state);
SELECT state, name, attendance FROM state_events;
What is the number of properties co-owned by two or more people in the city of Los Angeles?
CREATE TABLE properties (id INT,city VARCHAR(255),coowners INT); INSERT INTO properties (id,city,coowners) VALUES (1,'Los Angeles',2),(2,'Los Angeles',1),(3,'Los Angeles',3),(4,'San Diego',1);
SELECT COUNT(*) FROM properties WHERE city = 'Los Angeles' AND coowners > 1;
What is the average age of patients who have been treated with CBT for depression in New York?
CREATE TABLE patients (patient_id INT,patient_age INT,patient_name TEXT,condition TEXT,therapist_id INT,treatment TEXT); INSERT INTO patients (patient_id,patient_age,patient_name,condition,therapist_id,treatment) VALUES (1,35,'John Smith','Depression',1,'CBT'); INSERT INTO patients (patient_id,patient_age,patient_name,...
SELECT AVG(patients.patient_age) FROM patients JOIN therapists ON patients.therapist_id = therapists.therapist_id WHERE patients.condition = 'Depression' AND patients.treatment = 'CBT' AND therapists.state = 'New York';
What is the total defense spending for each region?
CREATE TABLE defense_spending (region VARCHAR(50),spending NUMERIC(10,2)); INSERT INTO defense_spending (region,spending) VALUES ('Africa',4000000000),('Asia',10000000000),('Europe',8000000000),('North America',12000000000),('South America',5000000000);
SELECT region, spending FROM defense_spending;
Create a view named 'recent_claims' that shows claims from the last 30 days
CREATE TABLE if not exists claims (claim_id INT PRIMARY KEY,policyholder_id INT,claim_amount DECIMAL(10,2),claim_date DATE);
CREATE VIEW recent_claims AS SELECT * FROM claims WHERE claim_date >= CURDATE() - INTERVAL 30 DAY;
What is the maximum temperature recorded by any spacecraft during a space mission?
CREATE TABLE Spacecraft (SpacecraftID INT,MaximumTemperature FLOAT);
SELECT MAX(MaximumTemperature) FROM Spacecraft;
What is the total number of donations in 'Russia' for the year 2021?
CREATE TABLE Donations (DonationID int,DonorID int,DonationDate date,DonationAmount decimal(10,2)); INSERT INTO Donations (DonationID,DonorID,DonationDate,DonationAmount) VALUES (1,1,'2021-01-01',50.00);
SELECT COUNT(*) FROM Donations WHERE Country = 'Russia' AND YEAR(DonationDate) = 2021;
What is the total plastic waste generation (in tonnes) by province in Canada in 2020?
CREATE TABLE waste_generation (province VARCHAR(20),year INT,material VARCHAR(20),weight FLOAT); INSERT INTO waste_generation (province,year,material,weight) VALUES ('Ontario',2020,'Plastic',15000),('Quebec',2020,'Plastic',12000),('British Columbia',2020,'Plastic',9000),('Alberta',2020,'Plastic',18000),('Manitoba',2020...
SELECT province, SUM(weight) as total_plastic_waste FROM waste_generation WHERE year = 2020 AND material = 'Plastic' GROUP BY province;
Update the 'ConservationStatus' of the 'Dugong' species in the 'MarineLife' table
CREATE TABLE MarineLife (LifeID INT,LifeName VARCHAR(255),Species VARCHAR(255),Habitat VARCHAR(255),ConservationStatus VARCHAR(255));
UPDATE MarineLife SET ConservationStatus = 'Vulnerable' WHERE Species = 'Dugong';
What is the average number of packages shipped daily from each warehouse?
CREATE TABLE Shipments (id INT,warehouse_id INT,shipped_date DATE,packages INT); INSERT INTO Shipments (id,warehouse_id,shipped_date,packages) VALUES (1,1,'2022-01-01',50),(2,1,'2022-01-02',75),(3,2,'2022-01-03',100); CREATE TABLE Warehouses (id INT,name VARCHAR(50),city VARCHAR(50),country VARCHAR(50)); INSERT INTO Wa...
SELECT w.name, AVG(s.packages) FROM Shipments s JOIN Warehouses w ON s.warehouse_id = w.id GROUP BY w.id;
What is the average budget for support programs in the Pacific region?
CREATE TABLE support_programs (id INT,name TEXT,region TEXT,budget FLOAT); INSERT INTO support_programs (id,name,region,budget) VALUES (1,'Accessible Tech','Pacific',50000.00),(2,'Mobility Training','Atlantic',75000.00);
SELECT AVG(budget) FROM support_programs WHERE region = 'Pacific';
What is the recycling rate for each material type for the year 2019?
CREATE TABLE WasteGeneration (region VARCHAR(255),waste_type VARCHAR(255),year INT,amount INT); CREATE TABLE RecyclingRates (waste_type VARCHAR(255),material_type VARCHAR(255),year INT,recycling_rate DECIMAL(5,4)); INSERT INTO WasteGeneration (region,waste_type,year,amount) VALUES ('North','Recyclables',2019,15000),('N...
SELECT wg.waste_type, AVG(rr.recycling_rate) as AvgRecyclingRate FROM WasteGeneration wg INNER JOIN RecyclingRates rr ON wg.waste_type = rr.waste_type WHERE wg.year = 2019 GROUP BY wg.waste_type;
What is the average communication budget for climate change initiatives in Europe between 2017 and 2020?
CREATE TABLE communication_budget (country VARCHAR(50),year INT,budget FLOAT); INSERT INTO communication_budget (country,year,budget) VALUES ('Germany',2017,1000000),('France',2018,1200000),('Spain',2019,1500000),('Italy',2020,1100000);
SELECT AVG(budget) FROM communication_budget WHERE country IN (SELECT name FROM countries WHERE region = 'Europe') AND year BETWEEN 2017 AND 2020;
Which community health worker programs have the highest health equity metrics?
CREATE TABLE community_health_worker_programs (id INT,program_name VARCHAR(50),location VARCHAR(20),health_equity_score INT); INSERT INTO community_health_worker_programs (id,program_name,location,health_equity_score) VALUES (1,'CHW Program 1','New York',90),(2,'CHW Program 2','California',95),(3,'CHW Program 3','Texas...
SELECT program_name, location, health_equity_score FROM community_health_worker_programs ORDER BY health_equity_score DESC;
What is the minimum fine amount for criminal cases in Florida?
CREATE TABLE criminal_cases (id INT,case_id INT,fine_amount INT); INSERT INTO criminal_cases (id,case_id,fine_amount) VALUES (1,1001,500),(2,1002,1000),(3,1003,1500);
SELECT MIN(fine_amount) FROM criminal_cases WHERE case_id = 1001;
What is the average number of esports events held in the NA region each year?
CREATE TABLE EsportsEventsYearly (EventYear INT,Region VARCHAR(10),EventCount INT); INSERT INTO EsportsEventsYearly (EventYear,Region,EventCount) VALUES (2022,'NA',5); INSERT INTO EsportsEventsYearly (EventYear,Region,EventCount) VALUES (2021,'EU',7);
SELECT AVG(EventCount) FROM EsportsEventsYearly WHERE Region = 'NA';
How many people voted in the presidential election of 2020 in the state of New York?
CREATE TABLE elections (year INT,state VARCHAR(20),voters INT); INSERT INTO elections (year,state,voters) VALUES (2020,'New York',8000000);
SELECT voters FROM elections WHERE year = 2020 AND state = 'New York';
How many genetic research projects are there in the UK?
CREATE SCHEMA if not exists genetics;CREATE TABLE if not exists genetics.research_projects(id INT,name TEXT,location TEXT,type TEXT);INSERT INTO genetics.research_projects (id,name,location,type) VALUES (1,'ProjectX','UK','Genetic'),(2,'ProjectY','USA','Genetic'),(3,'ProjectZ','Canada','Genomic');
SELECT COUNT(*) FROM genetics.research_projects WHERE location = 'UK';
What drugs have been approved in both the USA and UK?
CREATE TABLE drugs (id INT PRIMARY KEY,name VARCHAR(255),manufacturer VARCHAR(255),category VARCHAR(255)); INSERT INTO drugs (id,name,manufacturer,category) VALUES (1,'DrugA','Manufacturer1','Cardiovascular'); CREATE TABLE market_access (id INT PRIMARY KEY,drug_id INT,country VARCHAR(255),approval_date DATE,FOREIGN KEY...
SELECT drugs.name FROM drugs INNER JOIN market_access ON drugs.id = market_access.drug_id WHERE market_access.country IN ('USA', 'UK') GROUP BY drugs.name HAVING COUNT(DISTINCT market_access.country) = 2;
What is the maximum age of players who play non-VR games and are from Japan?
CREATE TABLE Players (PlayerID INT,Age INT,Country VARCHAR(50)); INSERT INTO Players (PlayerID,Age,Country) VALUES (1,25,'USA'),(2,30,'Canada'),(3,22,'Germany'),(4,35,'Japan'); CREATE TABLE GameLibrary (GameID INT,GameName VARCHAR(50),GameType VARCHAR(50)); INSERT INTO GameLibrary (GameID,GameName,GameType) VALUES (1,'...
SELECT MAX(Players.Age) FROM Players JOIN PlayerGameLibrary ON Players.PlayerID = PlayerGameLibrary.PlayerID JOIN GameLibrary ON PlayerGameLibrary.GameID = GameLibrary.GameID WHERE Players.Country = 'Japan' AND GameLibrary.GameType = 'Non-VR';
What is the total carbon sequestration of all the trees in the Trees table, if each tree sequesters 48.19 pounds of carbon per year on average?
CREATE TABLE Trees (id INT,species VARCHAR(255),age INT); INSERT INTO Trees (id,species,age) VALUES (1,'Oak',50),(2,'Pine',30),(3,'Maple',40);
SELECT SUM(48.19 * age) FROM Trees;
What are the top 5 countries with the most security incidents in the past month?
CREATE TABLE security_incidents (id INT,timestamp TIMESTAMP,country VARCHAR(255),incident_type VARCHAR(255)); INSERT INTO security_incidents (id,timestamp,country,incident_type) VALUES (1,'2022-01-01 10:00:00','USA','malware'),(2,'2022-01-02 15:00:00','Canada','phishing'),(3,'2022-01-03 08:00:00','USA','DDoS');
SELECT country, COUNT(*) as incident_count FROM security_incidents WHERE timestamp >= DATE_SUB(CURRENT_TIMESTAMP(), INTERVAL 1 MONTH) GROUP BY country ORDER BY incident_count DESC LIMIT 5;
What is the maximum order value for purchases made using a desktop device?
CREATE TABLE orders (id INT,order_value DECIMAL(10,2),device VARCHAR(20)); INSERT INTO orders (id,order_value,device) VALUES (1,150.50,'mobile'),(2,75.20,'desktop'),(3,225.00,'desktop');
SELECT MAX(order_value) FROM orders WHERE device = 'desktop';
What is the name and launch date of all spacecraft that have launched satellites with the type 'Communication'?
CREATE TABLE Spacecraft (id INT,name VARCHAR(50),country VARCHAR(50),launch_date DATE); INSERT INTO Spacecraft (id,name,country,launch_date) VALUES (1,'Falcon 9','USA','2010-06-04'); INSERT INTO Spacecraft (id,name,country,launch_date) VALUES (2,'Soyuz-FG','Russia','2001-11-02'); INSERT INTO Spacecraft (id,name,country...
SELECT sp.name, sp.launch_date FROM Spacecraft sp JOIN Satellites s ON sp.id = s.spacecraft_id WHERE s.type = 'Communication';
Show me the AI safety papers that were published in 2021 or 2022 and have the word 'ethics' in the title.
CREATE TABLE Papers (id INT,title VARCHAR(255),year INT,conference VARCHAR(255)); INSERT INTO Papers (id,title,year,conference) VALUES (1,'Ethical considerations in AI safety',2021,'NeurIPS'),(2,'Safe and fair AI algorithms',2022,'ICML'),(3,'Towards explainable AI systems',2022,'AAAI'),(4,'AI creativity and human value...
SELECT * FROM Papers WHERE year IN (2021, 2022) AND title LIKE '%ethics%';
Delete food safety inspection records with a score below 80 for location 201.
CREATE TABLE inspections (inspection_id INT,location_id INT,score INT,inspection_date DATE); INSERT INTO inspections (inspection_id,location_id,score,inspection_date) VALUES (1,201,95,'2021-01-01'),(2,201,78,'2021-02-01');
DELETE FROM inspections WHERE location_id = 201 AND score < 80;
How many cultivation licenses were issued in the state of Washington by the end of 2019?
CREATE TABLE CultivationLicenses (id INT,state VARCHAR(50),year INT,num_licenses INT); INSERT INTO CultivationLicenses (id,state,year,num_licenses) VALUES (1,'Washington',2019,1500),(2,'Washington',2018,1200),(3,'Oregon',2019,1800),(4,'Oregon',2018,1600);
SELECT SUM(num_licenses) FROM CultivationLicenses WHERE state = 'Washington' AND year = 2019;
What was the number of events and total attendees for each event type in Q1 and Q3 of 2023?
CREATE TABLE events (id INT,event_type VARCHAR(20),event_date DATE,num_attendees INT); INSERT INTO events (id,event_type,event_date,num_attendees) VALUES (1,'Fundraising','2023-02-01',50); INSERT INTO events (id,event_type,event_date,num_attendees) VALUES (2,'Awareness','2023-03-15',75);
SELECT event_type, COUNT(DISTINCT id) as total_events, SUM(num_attendees) as total_attendees FROM events WHERE EXTRACT(QUARTER FROM event_date) IN (1, 3) GROUP BY event_type;
What is the distribution of defense contract values by contracting agency since 2019?
CREATE TABLE IF NOT EXISTS defense_contracts (contract_id INT,contract_value FLOAT,contract_date DATE,contracting_agency VARCHAR(255));
SELECT contracting_agency, AVG(contract_value) as avg_contract_value, COUNT(*) as num_contracts, MIN(contract_value) as min_contract_value, MAX(contract_value) as max_contract_value FROM defense_contracts WHERE contract_date >= '2019-01-01' GROUP BY contracting_agency;
What is the total number of employees in the IT and Marketing departments?
CREATE TABLE Employees (EmployeeID INT,Department VARCHAR(20)); INSERT INTO Employees (EmployeeID,Department) VALUES (1,'IT'),(2,'IT'),(3,'HR'),(4,'IT'),(5,'Marketing'),(6,'Finance'),(7,'IT'),(8,'Marketing');
SELECT COUNT(*) FROM Employees WHERE Department IN ('IT', 'Marketing');
What is the minimum height for tunnels in the United Kingdom?
CREATE TABLE Tunnel (id INT,name TEXT,location TEXT,height FLOAT,length FLOAT); INSERT INTO Tunnel (id,name,location,height,length) VALUES (1,'Severn Tunnel','Wales,UK',50,7000);
SELECT MIN(height) FROM Tunnel WHERE location LIKE '%UK%';
What is the average number of penalty minutes served by a hockey player in a season?
CREATE TABLE season_penalties (id INT,player_name VARCHAR(50),team VARCHAR(50),season VARCHAR(10),penalty_minutes INT);
SELECT AVG(penalty_minutes) FROM season_penalties WHERE sport = 'Hockey' GROUP BY player_name, season;
List all ethical manufacturing certifications held by factories in the Asia-Pacific region.
CREATE TABLE certifications (certification_id INT,factory_id INT,certification TEXT); INSERT INTO certifications VALUES (1,1,'Fair Trade'),(2,1,'B Corp'),(3,2,'Fair Trade'),(4,3,'ISO 14001'),(5,3,'OHSAS 18001'); CREATE TABLE factories (factory_id INT,name TEXT,location TEXT); INSERT INTO factories VALUES (1,'ABC Factor...
SELECT factories.name, certifications.certification FROM certifications JOIN factories ON certifications.factory_id = factories.factory_id WHERE factories.location LIKE '%Asia%' OR factories.location LIKE '%Pacific%';
How many mining sites are located in each country?
CREATE TABLE mining_sites (site_id INT,site_name TEXT,location TEXT); INSERT INTO mining_sites (site_id,site_name,location) VALUES (1,'Site A','Country X'),(2,'Site B','Country Y'),(3,'Site C','Country X'),(4,'Site D','Country W');
SELECT location, COUNT(DISTINCT site_id) AS num_sites FROM mining_sites GROUP BY location;
What percentage of cosmetic products do not have 'fragrance' as an ingredient?
CREATE TABLE products (product_id INT,product_name TEXT,has_fragrance BOOLEAN); INSERT INTO products (product_id,product_name,has_fragrance) VALUES (1,'Soap',false),(2,'Lotion',true),(3,'Deodorant',false);
SELECT (COUNT(*) - SUM(has_fragrance)) * 100.0 / COUNT(*) as percentage FROM products;
Display the number of drilling rigs for each company, including companies without any rigs
CREATE TABLE Company (CompanyID int,CompanyName varchar(50)); CREATE TABLE OilRig (RigID int,CompanyID int,RigName varchar(50),DrillingType varchar(50),WaterDepth int);
SELECT Company.CompanyName, COUNT(OilRig.RigID) as Num_Rigs FROM Company LEFT JOIN OilRig ON Company.CompanyID = OilRig.CompanyID GROUP BY Company.CompanyName;
List all investors who have invested in companies with an ESG score greater than 85.0.
CREATE TABLE investments (investor_id INT,company_id INT,ESG_score FLOAT); INSERT INTO investments (investor_id,company_id,ESG_score) VALUES (1,1,86.0),(2,2,78.0),(3,3,82.5); CREATE TABLE companies (id INT,ESG_score FLOAT); INSERT INTO companies (id,ESG_score) VALUES (1,90.0),(2,60.0),(3,82.5);
SELECT DISTINCT i.name FROM investments AS i JOIN companies AS c ON i.company_id = c.id WHERE c.ESG_score > 85.0;
What is the total wastewater treated in California and Texas?
CREATE TABLE us_states (state VARCHAR(255),wastewater_treated INT); INSERT INTO us_states (state,wastewater_treated) VALUES ('California',2000000),('Texas',3000000);
SELECT SUM(wastewater_treated) FROM us_states WHERE state IN ('California', 'Texas');
What is the average time between failures for each vehicle type?
CREATE TABLE vehicle_types (type_id INT,type_name TEXT); CREATE TABLE fleet (vehicle_id INT,vehicle_type_id INT,license_plate TEXT); CREATE TABLE failures (failure_id INT,vehicle_id INT,failure_time TIMESTAMP); INSERT INTO vehicle_types VALUES (1,'Bus'),(2,'Tram'),(3,'Train'); INSERT INTO fleet VALUES (1,1,'ABC123'),(2...
SELECT vehicle_types.type_name, AVG(TIMESTAMPDIFF(MINUTE, failures, LEAD(failures) OVER (PARTITION BY vehicle_id ORDER BY failures.failure_time))) AS avg_time_between_failures FROM fleet INNER JOIN vehicle_types ON fleet.vehicle_type_id = vehicle_types.type_id INNER JOIN failures ON fleet.vehicle_id = failures.vehicle_...
How many visitors engaged with museums in Oceania in the last year?
CREATE TABLE Visitor_Engagement (id INT,visitor_id INT,museum_id INT,date DATE); CREATE TABLE Museums (id INT,name VARCHAR(255),region VARCHAR(255)); INSERT INTO Visitor_Engagement (id,visitor_id,museum_id,date) VALUES (1,1001,1,'2022-03-22'),(2,1002,2,'2022-02-15'),(3,1003,3,'2021-12-17'),(4,1004,4,'2022-01-03'); INSE...
SELECT COUNT(*) FROM Visitor_Engagement ve JOIN Museums m ON ve.museum_id = m.id WHERE m.region = 'Oceania' AND date >= '2021-01-01';
How many fans are over 30 years old in each city?
CREATE TABLE fans (fan_id INT,city VARCHAR(255),age INT,gender VARCHAR(10)); INSERT INTO fans (fan_id,city,age,gender) VALUES (1,'City A',25,'Male'),(2,'City A',35,'Female'),(3,'City B',20,'Male'),(4,'City B',40,'Female');
SELECT f.city, COUNT(*) as num_fans_over_30 FROM fans f WHERE f.age > 30 GROUP BY f.city;
Find the percentage of articles in the 'politics' category out of all articles.
CREATE TABLE articles (id INT,title TEXT,category TEXT,likes INT,created_at DATETIME); INSERT INTO articles (id,title,category,likes,created_at) VALUES (1,'Climate crisis: 12 years to save the planet','climate change',100,'2022-01-01 10:30:00');
SELECT 100.0 * COUNT(*) / (SELECT COUNT(*) FROM articles) as politics_percentage FROM articles WHERE category = 'politics'
What is the average cargo handling time for vessels in port 'Seattle'?
CREATE TABLE cargo_handling (id INT,vessel_name VARCHAR(50),port VARCHAR(50),handling_time INT); INSERT INTO cargo_handling (id,vessel_name,port,handling_time) VALUES (1,'Seattle Voyager','Seattle',8),(2,'Seattle Voyager','Seattle',10);
SELECT AVG(handling_time) FROM cargo_handling WHERE port = 'Seattle';
What is the maximum number of infectious disease tracking cases in a month for historically underrepresented communities, grouped by community?
CREATE TABLE infectious_disease_tracking_4 (id INT,community TEXT,cases_per_month INT,month TEXT); INSERT INTO infectious_disease_tracking_4 (id,community,cases_per_month,month) VALUES (1,'Community A',10,'January'),(2,'Community B',15,'February'),(3,'Underrepresented C',20,'March'),(4,'Underrepresented C',5,'April');
SELECT community, MAX(cases_per_month) FROM infectious_disease_tracking_4 WHERE community LIKE '%underrepresented%' GROUP BY community;
What are the names and dates of traditional festivals in Nigeria?
CREATE TABLE Festivals (FestivalID INT,Name TEXT,Date DATE); INSERT INTO Festivals (FestivalID,Name,Date) VALUES (1,'Durbar Festival','2022-02-26'); INSERT INTO Festivals (FestivalID,Name,Date) VALUES (2,'Argungu Fishing Festival','2022-03-04');
SELECT Name, Date FROM Festivals WHERE Country = 'Nigeria';
What is the maximum size (in square kilometers) of a habitat for birds in the 'habitats' table?
CREATE TABLE habitats (id INT,animal_type VARCHAR(50),size_km FLOAT); INSERT INTO habitats (id,animal_type,size_km) VALUES (1,'Bird',12.5);
SELECT MAX(size_km) FROM habitats WHERE animal_type = 'Bird';
What was the minimum number of followers for users who posted content related to 'art' in the last week?
CREATE SCHEMA usersdata; CREATE TABLE user_followers(user_id INT,followers INT,content_interests VARCHAR(255),post_date DATE); INSERT INTO usersdata.user_followers (user_id,followers,content_interests,post_date) VALUES (1,1200,'art','2022-01-01'); INSERT INTO usersdata.user_followers (user_id,followers,content_interest...
SELECT MIN(followers) FROM usersdata.user_followers WHERE post_date >= (SELECT CURDATE() - INTERVAL 7 DAY) AND content_interests LIKE '%art%';
What is the average age of visitors who attended exhibitions in Sydney and Melbourne?
CREATE TABLE Visitors (VisitorID INT,Age INT,Gender VARCHAR(10),City VARCHAR(50)); INSERT INTO Visitors (VisitorID,Age,Gender,City) VALUES (1,30,'Male','Sydney'); INSERT INTO Visitors (VisitorID,Age,Gender,City) VALUES (2,35,'Female','Melbourne'); INSERT INTO Visitors (VisitorID,Age,Gender,City) VALUES (3,40,'Male','Me...
SELECT AVG(Visitors.Age) FROM Visitors INNER JOIN Attendance ON Visitors.VisitorID = Attendance.VisitorID INNER JOIN Exhibitions ON Attendance.ExhibitionID = Exhibitions.ExhibitionID WHERE Visitors.City IN ('Sydney', 'Melbourne');
What is the number of public schools in each state and the percentage of those schools with free lunch programs?
CREATE TABLE states (state_name VARCHAR(255),state_abbreviation VARCHAR(255)); INSERT INTO states (state_name,state_abbreviation) VALUES ('Alabama','AL'),('Alaska','AK'),('Arizona','AZ'); CREATE TABLE schools (school_name VARCHAR(255),school_type VARCHAR(255),state_abbreviation VARCHAR(255)); INSERT INTO schools (schoo...
SELECT s.state_abbreviation, COUNT(*) AS num_schools, 100.0 * SUM(CASE WHEN fl.has_free_lunch THEN 1 ELSE 0 END) / COUNT(*) AS pct_free_lunch FROM schools s JOIN free_lunch fl ON s.school_name = fl.school_name GROUP BY s.state_abbreviation;
Delete a record for a technology accessibility project in the AccessibilityProjects table.
CREATE TABLE AccessibilityProjects (Project VARCHAR(50),Description TEXT,StartDate DATE,EndDate DATE); INSERT INTO AccessibilityProjects (Project,Description,StartDate,EndDate) VALUES ('Accessible Design','A project focused on accessible design for individuals with disabilities.','2022-04-01','2023-03-31');
DELETE FROM AccessibilityProjects WHERE Project = 'Accessible Design';
What is the breakdown of multimodal mobility usage by age group?
CREATE TABLE MultimodalMobility(AgeGroup VARCHAR(50),Mode VARCHAR(50),Usage FLOAT);
SELECT AgeGroup, Mode, SUM(Usage) FROM MultimodalMobility GROUP BY AgeGroup, Mode;
What is the average salinity (in ppt) in fish farms in the Arabian Sea?
CREATE TABLE arabian_sea_farms (id INT,name TEXT,salinity FLOAT);
SELECT AVG(salinity) FROM arabian_sea_farms;
Find the number of volunteers who joined in 2021 from the 'volunteer_registration' table.
CREATE TABLE volunteer_registration (id INT,name VARCHAR(50),city VARCHAR(50),state VARCHAR(50),country VARCHAR(50),registration_date DATE);
SELECT COUNT(*) FROM volunteer_registration WHERE YEAR(registration_date) = 2021;
What was the total revenue from children's tickets for the Classic Art exhibition?
CREATE TABLE exhibitions (name VARCHAR(50),tickets_sold INT,price DECIMAL(5,2)); INSERT INTO exhibitions (name,tickets_sold,price) VALUES ('Modern Art',300,20.00),('Classic Art',250,15.00);
SELECT SUM(price * tickets_sold) FROM exhibitions WHERE name = 'Classic Art' AND tickets_sold = (SELECT SUM(tickets_sold) FROM tickets WHERE age_group = 'Child');
What is the total amount of water consumed by each mining site in 2020?
CREATE TABLE mining_sites (site_id INT,site_name TEXT,location TEXT); INSERT INTO mining_sites (site_id,site_name,location) VALUES (1,'Gold Ridge','Melbourne,Australia'),(2,'Silver Peak','Nevada,USA'),(3,'Cerro Verde','Arequipa,Peru'); CREATE TABLE water_consumption (site_id INT,consumption_date DATE,amount_consumed FL...
SELECT site_name, SUM(amount_consumed) as total_water_consumption FROM water_consumption JOIN mining_sites ON water_consumption.site_id = mining_sites.site_id WHERE EXTRACT(YEAR FROM consumption_date) = 2020 GROUP BY site_name;
What is the total CO2 emission reduction for each carbon offset program in the past month?
CREATE TABLE Carbon_Offset_Programs (Program_ID INT,CO2_Emission_Reduction FLOAT,Program_Start_Date DATE); INSERT INTO Carbon_Offset_Programs (Program_ID,CO2_Emission_Reduction,Program_Start_Date) VALUES (1,5000.0,'2020-01-01'),(2,7000.0,'2020-01-15'),(3,3000.0,'2019-12-01');
SELECT Program_ID, CO2_Emission_Reduction FROM Carbon_Offset_Programs WHERE Program_Start_Date >= DATEADD(MONTH, -1, CURRENT_TIMESTAMP);
What was the mortality rate in Canada in 2017?
CREATE TABLE mortality_rates (id INT,country VARCHAR(50),year INT,rate DECIMAL(5,2)); INSERT INTO mortality_rates (id,country,year,rate) VALUES (1,'Canada',2017,8.2),(2,'Canada',2016,8.1);
SELECT rate FROM mortality_rates WHERE country = 'Canada' AND year = 2017;
Show the top 3 longest tourist trips in New Zealand.
CREATE TABLE tourism_stats (visitor_country VARCHAR(255),trip_duration INT); INSERT INTO tourism_stats (visitor_country,trip_duration) VALUES ('New Zealand',25),('New Zealand',30),('New Zealand',35);
SELECT * FROM (SELECT visitor_country, trip_duration, ROW_NUMBER() OVER (ORDER BY trip_duration DESC) as rn FROM tourism_stats WHERE visitor_country = 'New Zealand') t WHERE rn <= 3;
Increase the number of ambulances in Rural County by 10% in the transportation table.
CREATE TABLE transportation (location_id INT,location_type VARCHAR(255),num_ambulances INT); INSERT INTO transportation (location_id,location_type,num_ambulances) VALUES (1,'Rural County',20),(2,'Urban County',50),(3,'Suburban City',30);
UPDATE transportation SET num_ambulances = num_ambulances * 1.1 WHERE location_type = 'Rural County';
What are the carbon pricing for countries 'DE' and 'IT' in the 'carbon_pricing' schema?
CREATE TABLE carbon_pricing.carbon_prices (country varchar(2),year int,price decimal(5,2)); INSERT INTO carbon_pricing.carbon_prices (country,year,price) VALUES ('FR',2020,30.5),('FR',2021,32.0),('DE',2020,28.0),('DE',2021,30.2),('IT',2020,25.0),('IT',2021,27.5);
SELECT country, price FROM carbon_pricing.carbon_prices WHERE country IN ('DE', 'IT');
What is the minimum temperature recorded in Iceland during December across all years?
CREATE TABLE WeatherData (location TEXT,month INTEGER,year INTEGER,temperature REAL);
SELECT MIN(temperature) FROM WeatherData WHERE location = 'Iceland' AND month = 12;
Identify the number of marine species in the Pacific Ocean with a vulnerable conservation status.'
CREATE TABLE marine_species (name VARCHAR(255),conservation_status VARCHAR(50),ocean VARCHAR(50)); INSERT INTO marine_species (name,conservation_status,ocean) VALUES ('California Sea Lion','Vulnerable','Pacific'),('Green Sea Turtle','Endangered','Pacific');
SELECT COUNT(*) FROM marine_species WHERE conservation_status = 'Vulnerable' AND ocean = 'Pacific';
What is the minimum number of defense contracts signed by a single company in the United States?
CREATE TABLE defense_contracts (dc_id INT,dc_company VARCHAR(50),dc_country VARCHAR(50)); INSERT INTO defense_contracts (dc_id,dc_company,dc_country) VALUES (1,'Company A','United States'),(2,'Company B','United States'),(3,'Company C','Canada');
SELECT MIN(dc_count) FROM (SELECT COUNT(*) AS dc_count FROM defense_contracts WHERE dc_country = 'United States' GROUP BY dc_company) AS subquery;
What was the total cost of spacecraft manufactured by SpaceCorp with a launch date in 2019?
CREATE TABLE Spacecraft (id INT,name VARCHAR(255),manufacturer VARCHAR(255),launch_date DATE,cost INT); INSERT INTO Spacecraft (id,name,manufacturer,launch_date,cost) VALUES (1,'Starship','SpaceCorp','2019-01-01',10000000); INSERT INTO Spacecraft (id,name,manufacturer,launch_date,cost) VALUES (2,'FalconHeavy','SpaceX',...
SELECT SUM(cost) FROM Spacecraft WHERE manufacturer = 'SpaceCorp' AND YEAR(launch_date) = 2019;
find the number of indigenous communities in the arctic circle
CREATE TABLE indigenous_communities (community_id INT PRIMARY KEY,community_name TEXT,region TEXT); INSERT INTO indigenous_communities (community_id,community_name,region) VALUES (1,'Inuit Community A','Arctic Circle');
SELECT COUNT(*) FROM indigenous_communities WHERE region = 'Arctic Circle';
How many games were won by the Lakers in the current season?
CREATE TABLE teams (team_id INT,team_name VARCHAR(50)); INSERT INTO teams (team_id,team_name) VALUES (1,'Lakers'); CREATE TABLE games (game_id INT,season_id INT,home_team_id INT,away_team_id INT,home_team_score INT,away_team_score INT); INSERT INTO games (game_id,season_id,home_team_id,away_team_id,home_team_score,away...
SELECT COUNT(*) FROM games WHERE (home_team_id = (SELECT team_id FROM teams WHERE team_name = 'Lakers') AND home_team_score > away_team_score) OR (away_team_id = (SELECT team_id FROM teams WHERE team_name = 'Lakers') AND away_team_score > home_team_score);
What is the total number of research grants awarded to each college, broken down by year?
CREATE TABLE college (college_name TEXT); INSERT INTO college (college_name) VALUES ('College of Science'),('College of Arts'),('College of Business'); CREATE TABLE research_grants (grant_id INTEGER,college_name TEXT,grant_year INTEGER,grant_amount INTEGER); INSERT INTO research_grants (grant_id,college_name,grant_year...
SELECT college_name, grant_year, SUM(grant_amount) FROM research_grants GROUP BY college_name, grant_year;
What is the total value of artworks created by artists who lived in the 19th century?
CREATE TABLE Artists (id INT,name TEXT,nationality TEXT,birth_year INT,death_year INT); INSERT INTO Artists (id,name,nationality,birth_year,death_year) VALUES (1,'Claude Monet','French',1840,1926),(2,'Paul Cezanne','French',1839,1906); CREATE TABLE Artworks (id INT,title TEXT,artist_id INT,price INT); INSERT INTO Art...
SELECT SUM(Artworks.price) FROM Artworks INNER JOIN Artists ON Artworks.artist_id = Artists.id WHERE Artists.birth_year <= 1900 AND Artists.death_year >= 1800;
Delete the bus stop with bus_stop_id 5 from the city_bus_stops table
CREATE TABLE city_bus_stops (bus_stop_id INT,bus_stop_name VARCHAR(255),latitude DECIMAL,longitude DECIMAL); INSERT INTO city_bus_stops (bus_stop_id,bus_stop_name,latitude,longitude) VALUES (1,'Downtown',40.7128,-74.0060),(2,'Times Square',40.7590,-73.9844),(3,'Central Park',40.7829,-73.9654),(4,'Harlem',40.8097,-73.94...
DELETE FROM city_bus_stops WHERE bus_stop_id = 5;
How many students have enrolled in open pedagogy courses in the last 3 months?
CREATE TABLE students (student_id INT,enrollment_date DATE); INSERT INTO students (student_id,enrollment_date) VALUES (1,'2022-04-01'),(2,'2022-06-15'),(3,'2022-02-05'),(4,'2022-03-22'),(5,'2022-01-31'); CREATE TABLE courses (course_id INT,enrollment_date DATE); INSERT INTO courses (course_id,enrollment_date) VALUES (1...
SELECT COUNT(student_id) FROM students INNER JOIN courses ON students.enrollment_date = courses.enrollment_date WHERE students.enrollment_date > DATE_SUB(CURRENT_DATE, INTERVAL 3 MONTH);
What are the names of refineries and their inspectors, filtered based on the inspectors' certification date being later than January 1, 2021?
CREATE TABLE refineries (id INT PRIMARY KEY,name TEXT,location TEXT); CREATE TABLE refinery_inspections (id INT PRIMARY KEY,refinery_id INT,inspection_date DATE,inspector_id INT); CREATE TABLE inspectors (id INT PRIMARY KEY,name TEXT,certification_date DATE);
SELECT r.name, i.name as inspector_name FROM refineries r JOIN refinery_inspections ri ON r.id = ri.refinery_id JOIN inspectors i ON ri.inspector_id = i.id WHERE i.certification_date > '2021-01-01';
How many citizen feedback records were received in the last month for transportation services?
CREATE TABLE feedback (id INT,service VARCHAR(20),date DATE); INSERT INTO feedback (id,service,date) VALUES (1,'Transportation','2022-01-01'),(2,'Transportation','2022-02-01');
SELECT COUNT(*) FROM feedback WHERE service = 'Transportation' AND date >= DATE_SUB(CURDATE(), INTERVAL 1 MONTH);
What is the total distance driven in autonomous driving tests for each manufacturer in 2020?
CREATE TABLE AutonomousTests (Id INT,Manufacturer VARCHAR(100),TestDate DATE,Distance FLOAT); INSERT INTO AutonomousTests (Id,Manufacturer,TestDate,Distance) VALUES (1,'Tesla','2020-01-01',150.0); INSERT INTO AutonomousTests (Id,Manufacturer,TestDate,Distance) VALUES (2,'Waymo','2020-02-01',170.0); INSERT INTO Autonomo...
SELECT Manufacturer, SUM(Distance) FROM AutonomousTests WHERE EXTRACT(YEAR FROM TestDate) = 2020 GROUP BY Manufacturer;
Update the 'infrastructure_projects' table to set the 'project_start_date' to '2023-01-01' for all records where 'project_id' is 1
CREATE TABLE infrastructure_projects (project_id INT,project_name TEXT,project_start_date DATE,project_location TEXT);
UPDATE infrastructure_projects SET project_start_date = '2023-01-01' WHERE project_id = 1;
Find the number of male and female patients in the 'patients' table, separated by sex.
CREATE TABLE patients (id INT,name VARCHAR(50),sex VARCHAR(10),dob DATE);INSERT INTO patients (id,name,sex,dob) VALUES (1,'John Doe','Male','1980-01-01'); INSERT INTO patients (id,name,sex,dob) VALUES (2,'Jane Smith','Female','1990-02-02');
SELECT sex, COUNT(*) FROM patients GROUP BY sex;
List all records from the 'PlayerData' table where 'Age' is greater than 25
CREATE TABLE PlayerData (PlayerID INT,Name VARCHAR(50),Age INT,Country VARCHAR(50)); INSERT INTO PlayerData (PlayerID,Name,Age,Country) VALUES ('1','John Doe','25','USA'),('2','Jane Smith','30','Canada'),('3','Mike Johnson','22','USA'),('4','Sarah Lee','28','Canada'),('5','Lucas Martinez','35','Mexico');
SELECT * FROM PlayerData WHERE Age > 25;
Which beauty brands have a transparency score lower than 70 and are based in Asia?
CREATE TABLE brand_transparency (brand_id INT,brand_name VARCHAR(255),transparency_score INT); CREATE TABLE brands (brand_id INT,brand_name VARCHAR(255),country VARCHAR(255)); INSERT INTO brand_transparency (brand_id,brand_name,transparency_score) VALUES (1,'Seoul Beauty',65),(2,'Tokyo Glam',80),(3,'Mumbai Cosmetics',7...
SELECT brand_name FROM brand_transparency INNER JOIN brands ON brand_transparency.brand_id = brands.brand_id WHERE transparency_score < 70 AND country IN ('South Korea', 'Japan', 'India');
What is the total number of hours spent on cases in the last month, broken down by the responsible attorney?
CREATE TABLE Attorneys (ID INT,Name VARCHAR(255)); CREATE TABLE Cases (ID INT,AttorneyID INT,Date DATE,Hours INT); INSERT INTO Attorneys (ID,Name) VALUES (1,'John Smith'),(2,'Jane Doe'),(3,'Bob Johnson'); INSERT INTO Cases (ID,AttorneyID,Date,Hours) VALUES (1,1,'2022-01-01',10),(2,2,'2022-02-15',15),(3,1,'2022-03-28',2...
SELECT AttorneyID, SUM(Hours) as TotalHours FROM Cases WHERE Date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) GROUP BY AttorneyID;