instruction
stringlengths
0
1.06k
input
stringlengths
11
5.3k
response
stringlengths
2
4.44k
How many deep-sea expeditions were conducted in the Mediterranean Sea between 2015 and 2020?
CREATE TABLE deep_sea_expeditions (year INT,region VARCHAR(255),number_of_expeditions INT);INSERT INTO deep_sea_expeditions (year,region,number_of_expeditions) VALUES (2015,'Mediterranean Sea',3),(2016,'Mediterranean Sea',4),(2017,'Mediterranean Sea',5),(2018,'Mediterranean Sea',6),(2019,'Mediterranean Sea',7),(2020,'M...
SELECT number_of_expeditions FROM deep_sea_expeditions WHERE region = 'Mediterranean Sea' AND year BETWEEN 2015 AND 2020;
Find the daily revenue for each store, ranked by revenue in descending order.
CREATE TABLE Stores (StoreID INT,StoreName VARCHAR(50));CREATE TABLE Menu (MenuID INT,MenuItem VARCHAR(50),Price DECIMAL(5,2));CREATE TABLE Sales (SaleID INT,StoreID INT,MenuID INT,QuantitySold INT,SaleDate DATE);
SELECT StoreName, SaleDate, SUM(Price * QuantitySold) AS DailyRevenue, RANK() OVER (PARTITION BY SaleDate ORDER BY SUM(Price * QuantitySold) DESC) AS RevenueRank FROM Sales JOIN Menu ON Sales.MenuID = Menu.MenuID JOIN Stores ON Sales.StoreID = Stores.StoreID GROUP BY StoreName, SaleDate ORDER BY SaleDate, RevenueRank;
List all the datasets used in AI safety research since 2015
CREATE TABLE datasets (dataset_name TEXT,year INTEGER,domain TEXT); INSERT INTO datasets (dataset_name,year,domain) VALUES ('Dataset X',2016,'AI Safety'),('Dataset Y',2017,'Algorithmic Fairness'),('Dataset Z',2015,'Explainable AI');
SELECT dataset_name FROM datasets WHERE domain = 'AI Safety' AND year >= 2015;
What is the average quantity of fish sold by each seller in the Midwest region, only considering those sellers who have sold more than 5000 units?
CREATE TABLE Sellers (SellerID INT,SellerName TEXT,Region TEXT); INSERT INTO Sellers (SellerID,SellerName,Region) VALUES (1,'John Doe','Midwest'),(2,'Jane Smith','Northeast'); CREATE TABLE Sales (SaleID INT,SellerID INT,Quantity INT); INSERT INTO Sales (SaleID,SellerID,Quantity) VALUES (1,1,6000),(2,1,500),(3,2,3000),(...
SELECT SellerName, AVG(Quantity) FROM Sellers INNER JOIN Sales ON Sellers.SellerID = Sales.SellerID WHERE Sellers.Region = 'Midwest' GROUP BY SellerName HAVING SUM(Quantity) > 5000;
What is the maximum lifelong learning score for each subject, grouped by student?
CREATE TABLE student_lifelong_learning (student_id INT,subject VARCHAR(255),lifelong_learning_score INT);
SELECT s.student_id, s.subject, MAX(s.lifelong_learning_score) as max_score FROM student_lifelong_learning s GROUP BY s.student_id, s.subject;
What is the total number of animals in 'Hope Wildlife Sanctuary' and 'Paws and Claws Rescue'?
CREATE TABLE Hope_Wildlife_Sanctuary (Animal_ID INT,Animal_Name VARCHAR(50),Species VARCHAR(50),Age INT); INSERT INTO Hope_Wildlife_Sanctuary VALUES (1,'Bambi','Deer',3); INSERT INTO Hope_Wildlife_Sanctuary VALUES (2,'Fiona','Turtle',10); CREATE TABLE Paws_and_Claws_Rescue (Animal_ID INT,Animal_Name VARCHAR(50),Species...
SELECT SUM(Number_of_Animals) FROM (SELECT COUNT(*) AS Number_of_Animals FROM Hope_Wildlife_Sanctuary UNION ALL SELECT COUNT(*) AS Number_of_Animals FROM Paws_and_Claws_Rescue) AS Total_Animals
Delete the records with a budget lower than 100000 for the 'Transportation' service in the 'CityData' schema's 'CityBudget' table for the year 2023.
CREATE SCHEMA CityData; CREATE TABLE CityBudget (Service varchar(255),Year int,Budget int); INSERT INTO CityBudget (Service,Year,Budget) VALUES ('Education',2023,500000),('Healthcare',2023,700000),('Transportation',2023,90000),('Transportation',2023,120000);
DELETE FROM CityData.CityBudget WHERE Service = 'Transportation' AND Year = 2023 AND Budget < 100000;
Show the annual CO2 emissions reduction achieved by renewable energy projects in the province of Ontario, Canada
CREATE TABLE co2_emissions_reduction (project_id INT,project_name VARCHAR(255),co2_reduction FLOAT,reduction_year INT,province VARCHAR(255));
SELECT reduction_year, SUM(co2_reduction) as annual_reduction FROM co2_emissions_reduction WHERE province = 'Ontario' GROUP BY reduction_year;
Add a new row to the 'Player_Demographics' table
Player_Demographics
INSERT INTO Player_Demographics (Player_ID, Age, Gender, Location) VALUES (6, 25, 'Female', 'Australia');
Which countries have the highest threat intelligence metrics in the last 6 months?
CREATE TABLE Threat_Intel (metric_id INT,country TEXT,metric_value INT,metric_date DATE); INSERT INTO Threat_Intel (metric_id,country,metric_value,metric_date) VALUES (1,'USA',85,'2022-01-01'),(2,'Russia',75,'2022-01-01');
SELECT country, AVG(metric_value) as avg_metric FROM Threat_Intel WHERE metric_date >= DATE_SUB(CURDATE(), INTERVAL 6 MONTH) GROUP BY country ORDER BY avg_metric DESC;
What is the total number of trips taken on public transportation in Seoul, South Korea?
CREATE TABLE public_transportation_trips_seoul (trip_id INT,transportation_id INT,city VARCHAR(50),date DATE);
CREATE TABLE public_transportation_trips_seoul (trip_id INT, transportation_id INT, city VARCHAR(50), date DATE);
Show the percentage of broadband subscribers by technology type, ordered from the highest to the lowest.
CREATE TABLE broadband_subscribers (subscriber_id INT,technology VARCHAR(255)); INSERT INTO broadband_subscribers (subscriber_id,technology) VALUES (1,'Fiber'),(2,'Cable'),(3,'DSL'),(4,'Fiber'),(5,'Cable'),(6,'Satellite');
SELECT technology, 100.0 * COUNT(*) OVER (PARTITION BY technology) / SUM(COUNT(*)) OVER () as pct_subscribers FROM broadband_subscribers GROUP BY technology ORDER BY pct_subscribers DESC;
What is the total water consumption (in cubic meters) for agriculture purposes in the state of California in 2019?
CREATE TABLE water_consumption (id INT,state VARCHAR(255),usage_category VARCHAR(255),consumption_cubic_meters INT,year INT); INSERT INTO water_consumption (id,state,usage_category,consumption_cubic_meters,year) VALUES (1,'California','agriculture',3000000,2019),(2,'California','municipal',2000000,2019),(3,'California'...
SELECT SUM(consumption_cubic_meters) FROM water_consumption WHERE state = 'California' AND usage_category = 'agriculture' AND year = 2019;
Identify REE market trends by year and price.
CREATE TABLE market_trends (year INT,ree_price FLOAT); INSERT INTO market_trends (year,ree_price) VALUES (2019,25.5),(2020,30.2),(2021,35.1),(2022,40.5),(2023,45.6),(2024,50.4);
SELECT market_trends.year, market_trends.ree_price, production.total_production FROM market_trends INNER JOIN (SELECT company_id, year, SUM(ree_production) as total_production FROM production GROUP BY company_id, year) as production ON market_trends.year = production.year;
What is the maximum ad spend for ads with the category 'clean_transportation' in the 'advertising_stats' table?
CREATE TABLE advertising_stats(ad_id INT,category TEXT,ad_spend DECIMAL(10,2));
SELECT MAX(ad_spend) FROM advertising_stats WHERE category = 'clean_transportation';
List the names of rural healthcare centers in the US that serve more than 200 patients.
CREATE TABLE healthcare_centers_us (name TEXT,location TEXT,patients_served INT); INSERT INTO healthcare_centers_us (name,location,patients_served) VALUES ('HC A','Rural Alabama',250),('HC B','Rural Alaska',150),('HC C','Rural California',225);
SELECT name FROM healthcare_centers_us WHERE location LIKE 'Rural%' AND patients_served > 200;
What is the total revenue generated by each company from ethical fashion products?
CREATE TABLE revenue(company VARCHAR(50),product VARCHAR(50),revenue DECIMAL(10,2));
SELECT company, SUM(revenue) FROM revenue WHERE product IN ('ethical_fashion') GROUP BY company;
Which product has the highest average environmental impact score?
CREATE TABLE products (product_id INT,environmental_impact_score FLOAT); INSERT INTO products (product_id,environmental_impact_score) VALUES (1,5.2),(2,6.1),(3,4.9);
SELECT product_id, MAX(environmental_impact_score) OVER () AS max_score FROM products;
What is the regulatory status of Ripple in Japan?
CREATE TABLE regulatory_frameworks (country TEXT,asset TEXT,status TEXT); INSERT INTO regulatory_frameworks (country,asset,status) VALUES ('Japan','Ripple','Under Review');
SELECT status FROM regulatory_frameworks WHERE country = 'Japan' AND asset = 'Ripple';
How many defense diplomacy events were conducted in each region?
CREATE TABLE defense_diplomacy (id INT,region VARCHAR(255),event VARCHAR(255));
SELECT region, COUNT(event) FROM defense_diplomacy GROUP BY region;
What are the green building certifications held by companies based in the Asia-Pacific region?
CREATE TABLE green_buildings (id INT,company_name TEXT,certification TEXT,region TEXT); INSERT INTO green_buildings (id,company_name,certification,region) VALUES (1,'EcoBuild Pte Ltd','LEED','Asia-Pacific'),(2,'GreenTech India','IGBC','Asia-Pacific');
SELECT DISTINCT certification FROM green_buildings WHERE region = 'Asia-Pacific';
Insert a new rural infrastructure project in Bangladesh that started on 2022-01-15 with a budget of 60000.00 USD.
CREATE TABLE infrastructure_projects (id INT,project_id INT,country VARCHAR(50),project VARCHAR(50),budget DECIMAL(10,2),start_date DATE,end_date DATE); INSERT INTO infrastructure_projects (id,project_id,country,project,budget,start_date,end_date) VALUES (1,8001,'Bangladesh','Electric Grid Expansion',60000.00,'2022-01-...
INSERT INTO infrastructure_projects (project_id, country, project, budget, start_date, end_date) VALUES (8002, 'Bangladesh', 'Solar Powered Irrigation', 70000.00, '2022-07-01', '2024-06-30');
What is the average coins earned per game by players from the United States?
CREATE TABLE Players (PlayerID INT,PlayerName TEXT,Country TEXT,CoinsEarned INT); INSERT INTO Players (PlayerID,PlayerName,Country,CoinsEarned) VALUES (1,'John Doe','USA',500),(2,'Jane Smith','Canada',600);
SELECT AVG(CoinsEarned) FROM Players WHERE Country = 'USA';
What is the total cost of labor for projects that started after January 1, 2020?
CREATE TABLE Projects (id INT,start_date DATE,labor_cost FLOAT); INSERT INTO Projects (id,start_date,labor_cost) VALUES (1,'2020-01-05',12000.0),(2,'2019-12-30',15000.0),(3,'2021-02-01',13000.0);
SELECT SUM(labor_cost) FROM Projects WHERE start_date > '2020-01-01';
Delete records of accommodations that cost more than $80000 in the Asian region.
CREATE TABLE accommodations_4 (id INT,name TEXT,region TEXT,cost FLOAT); INSERT INTO accommodations_4 (id,name,region,cost) VALUES (1,'Wheelchair Ramp','Asia',120000.00),(2,'Sign Language Interpreter','Asia',60000.00);
DELETE FROM accommodations_4 WHERE cost > 80000 AND region = 'Asia';
What is the total severity of vulnerabilities found in the North American region?
CREATE TABLE vulnerabilities (id INT,severity FLOAT,region VARCHAR(50)); INSERT INTO vulnerabilities (id,severity,region) VALUES (1,7.5,'North America');
SELECT SUM(severity) FROM vulnerabilities WHERE region = 'North America';
What is the maximum GPA of graduate students who have not received a research grant in the last year?
CREATE TABLE grad_students (id INT,name TEXT,gpa DECIMAL(3,2),research_grant_received DATE); INSERT INTO grad_students (id,name,gpa,research_grant_received) VALUES (1,'Kai',3.9,NULL); INSERT INTO grad_students (id,name,gpa,research_grant_received) VALUES (2,'Lena',3.7,'2020-08-01');
SELECT MAX(gpa) FROM grad_students WHERE research_grant_received IS NULL OR research_grant_received < DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR)
Update the capacity of 'Ontario' to 500000 in landfill_capacity table
CREATE TABLE landfill_capacity (id INT PRIMARY KEY,location VARCHAR(255),capacity INT,date DATE);
UPDATE landfill_capacity SET capacity = 500000 WHERE location = 'Ontario';
Update the landfill capacity of 'Africa' in 2021 to 7000000 m3
CREATE TABLE landfill_capacity (region VARCHAR(50),year INT,capacity_m3 FLOAT); INSERT INTO landfill_capacity (region,year,capacity_m3) VALUES ('Africa',2020,5000000),('Africa',2021,6000000);
UPDATE landfill_capacity SET capacity_m3 = 7000000 WHERE region = 'Africa' AND year = 2021;
What is the maximum donation amount made by a donor from Africa?
CREATE TABLE Donors (DonorID INT,DonorName TEXT,Continent TEXT); INSERT INTO Donors (DonorID,DonorName,Continent) VALUES (1,'John Doe','North America'),(2,'Jane Smith','Africa'); CREATE TABLE Donations (DonationID INT,DonorID INT,DonationAmount INT); INSERT INTO Donations (DonationID,DonorID,DonationAmount) VALUES (1,1...
SELECT MAX(DonationAmount) FROM Donations JOIN Donors ON Donations.DonorID = Donors.DonorID WHERE Donors.Continent = 'Africa';
What is the maximum quantity of military equipment sold in a single transaction by Raytheon to European countries in Q2 2019?
CREATE TABLE Military_Equipment_Sales(equipment_id INT,manufacturer VARCHAR(255),purchaser VARCHAR(255),sale_date DATE,quantity INT);INSERT INTO Military_Equipment_Sales(equipment_id,manufacturer,purchaser,sale_date,quantity) VALUES (1,'Raytheon','Germany','2019-04-01',20),(2,'Raytheon','France','2019-06-15',30);
SELECT MAX(quantity) FROM Military_Equipment_Sales WHERE manufacturer = 'Raytheon' AND purchaser LIKE 'Europe%' AND sale_date BETWEEN '2019-04-01' AND '2019-06-30';
What is the maximum population for each species in the Arctic region?
CREATE TABLE Species (id INT,name VARCHAR(50),population INT,region VARCHAR(50)); INSERT INTO Species (id,name,population,region) VALUES (1,'Polar Bear',25000,'Arctic'); INSERT INTO Species (id,name,population,region) VALUES (2,'Arctic Fox',5000,'Arctic');
SELECT region, MAX(population) FROM Species WHERE region = 'Arctic' GROUP BY region;
List the total area (in hectares) of each crop type under cultivation by farmers in the 'Southern' region for the year 2022.
CREATE TABLE Farmers (id INT,region VARCHAR(255),crop_type VARCHAR(255),area INT);
SELECT region, crop_type, SUM(area / 10000.0) FROM Farmers WHERE region = 'Southern' AND YEAR(timestamp) = 2022 GROUP BY region, crop_type;
What is the surface area of the Pacific Ocean?
CREATE TABLE oceans (name TEXT,depth FLOAT,surface_area FLOAT); INSERT INTO oceans (name,depth,surface_area) VALUES ('Pacific Ocean',4000,165200000); INSERT INTO oceans (name,depth,surface_area) VALUES ('Atlantic Ocean',3500,82300000); INSERT INTO oceans (name,depth,surface_area) VALUES ('Indian Ocean',3500,73400000); ...
SELECT surface_area FROM oceans WHERE name = 'Pacific Ocean';
What is the total number of cultural heritage tours booked in Italy in Q2 2022?
CREATE TABLE tours (tour_id INT,name VARCHAR(255),country VARCHAR(255),booked_date DATE,cultural_heritage BOOLEAN); INSERT INTO tours (tour_id,name,country,booked_date,cultural_heritage) VALUES (1,'Roman Colosseum Tour','Italy','2022-04-15',true),(2,'Venice Canals Tour','Italy','2022-05-20',false),(3,'Pompeii Tour','It...
SELECT COUNT(*) FROM tours WHERE country = 'Italy' AND YEAR(booked_date) = 2022 AND QUARTER(booked_date) = 2 AND cultural_heritage = true;
What is the total grant money received by organizations in the community development sector in South Africa?
CREATE TABLE community_development (id INT,organization_name TEXT,sector TEXT,country TEXT,grant_amount DECIMAL(10,2)); INSERT INTO community_development (id,organization_name,sector,country,grant_amount) VALUES (1,'Youth Empowerment Fund','Community Development','South Africa',30000.00),(2,'Rural Women Development','C...
SELECT SUM(grant_amount) FROM community_development WHERE country = 'South Africa' AND sector = 'Community Development';
What is the percentage of employees who identify as LGBTQ+ in the company?
CREATE TABLE Employees (EmployeeID INT,Gender VARCHAR(10),SexualOrientation VARCHAR(20)); INSERT INTO Employees (EmployeeID,Gender,SexualOrientation) VALUES (1,'Female','Heterosexual'),(2,'Male','Gay'),(3,'Non-binary','Queer'),(4,'Male','Bisexual'),(5,'Female','Heterosexual');
SELECT (COUNT(*) * 100.0 / (SELECT COUNT(*) FROM Employees WHERE SexualOrientation IS NOT NULL)) FROM Employees WHERE SexualOrientation LIKE '%LGBTQ%';
What is the average number of visitors for each continent in 2019?
CREATE TABLE ContinentVisitors (id INT,continent VARCHAR(50),year INT,visitors INT); INSERT INTO ContinentVisitors (id,continent,year,visitors) VALUES (1,'Africa',2018,45000000); INSERT INTO ContinentVisitors (id,continent,year,visitors) VALUES (2,'Africa',2019,47000000); INSERT INTO ContinentVisitors (id,continent,yea...
SELECT continent, AVG(visitors) as avg_visitors FROM ContinentVisitors WHERE year = 2019 GROUP BY continent;
What is the highest rank held by a female military personnel in the 'army' branch?
CREATE TABLE military_personnel (id INT,name VARCHAR(50),gender VARCHAR(50),branch VARCHAR(50),rank VARCHAR(50),experience INT); INSERT INTO military_personnel (id,name,gender,branch,rank,experience) VALUES (1,'John Doe','Male','army','Captain',10); INSERT INTO military_personnel (id,name,gender,branch,rank,experience)...
SELECT MAX(rank) FROM military_personnel WHERE gender = 'Female' AND branch = 'army';
Get the number of railways in Texas
CREATE TABLE Infrastructure (id INT,name VARCHAR(100),type VARCHAR(50),location VARCHAR(100),state VARCHAR(50)); INSERT INTO Infrastructure (id,name,type,location,state) VALUES (7,'Texas Central High-Speed Railway','Railway','Houston','Texas');
SELECT COUNT(*) FROM Infrastructure WHERE type = 'Railway' AND state = 'Texas';
What is the total donation amount for each cause area, for donors from India and China, in descending order?
CREATE TABLE donors (id INT,name TEXT,country TEXT); CREATE TABLE donations (id INT,donor_id INT,donation_amount FLOAT,organization_id INT); CREATE TABLE organizations (id INT,name TEXT,cause_area TEXT);
SELECT o.cause_area, SUM(donations.donation_amount) as total_donations FROM donations INNER JOIN organizations o ON donations.organization_id = o.id INNER JOIN donors d ON donations.donor_id = d.id WHERE d.country IN ('India', 'China') GROUP BY o.cause_area ORDER BY total_donations DESC;
What is the percentage of citizen feedback related to public safety in 2021?
CREATE TABLE CitizenFeedback (Year INT,Topic VARCHAR(20),Feedback VARCHAR(10)); INSERT INTO CitizenFeedback (Year,Topic,Feedback) VALUES (2021,'Public Safety','Positive'),(2021,'Public Safety','Negative'),(2021,'Public Safety','Neutral'),(2021,'Healthcare','Positive'),(2021,'Healthcare','Negative');
SELECT (COUNT(CASE WHEN Topic = 'Public Safety' AND Feedback IN ('Positive', 'Negative', 'Neutral') THEN 1 END) * 100.0 / COUNT(*)) as Pct_Public_Safety_Feedback FROM CitizenFeedback WHERE Year = 2021;
What was the total revenue for Raytheon's military equipment sales to Asia in Q1 2019?
CREATE TABLE MilitaryEquipmentSales (EquipmentID INT,Manufacturer VARCHAR(50),DestinationRegion VARCHAR(50),SaleDate DATE,Quantity INT,UnitPrice FLOAT); INSERT INTO MilitaryEquipmentSales (EquipmentID,Manufacturer,DestinationRegion,SaleDate,Quantity,UnitPrice) VALUES (1,'Raytheon','Asia','2019-01-10',5,2000000.00),(2,'...
SELECT SUM(Quantity * UnitPrice) FROM MilitaryEquipmentSales WHERE Manufacturer = 'Raytheon' AND DestinationRegion = 'Asia' AND SaleDate >= '2019-01-01' AND SaleDate < '2019-04-01';
What is the number of users registered in each country in the current month?
CREATE TABLE users (user_id INT,registration_date DATE,country VARCHAR(255)); INSERT INTO users (user_id,registration_date,country) VALUES (1,'2022-01-01','USA'),(2,'2022-01-02','Canada'),(3,'2022-01-03','Mexico');
SELECT u.country, COUNT(DISTINCT u.user_id) FROM users u WHERE MONTH(u.registration_date) = MONTH(GETDATE()) AND YEAR(u.registration_date) = YEAR(GETDATE()) GROUP BY u.country;
How many players are from underrepresented communities?
CREATE TABLE Players (PlayerID INT,Underrepresented BOOLEAN); INSERT INTO Players (PlayerID,Underrepresented) VALUES (1,TRUE),(2,FALSE),(3,TRUE),(4,TRUE);
SELECT COUNT(*) FROM Players WHERE Underrepresented = TRUE;
Update the profile picture of user with id 3 to 'new_profile_pic.jpg'
CREATE TABLE users (id INT,name VARCHAR(100),profile_picture VARCHAR(50)); INSERT INTO users (id,name,profile_picture) VALUES (1,'Aarav','old_profile_pic.jpg'),(2,'Benita','profile_pic_2.png'),(3,'Chanho','profile_pic_3.jpg');
UPDATE users SET profile_picture = 'new_profile_pic.jpg' WHERE id = 3;
Show all ad campaigns that target users in Brazil.
CREATE TABLE ad_campaigns (id INT,name VARCHAR(255),target_country VARCHAR(255)); INSERT INTO ad_campaigns (id,name,target_country) VALUES (1,'AI for All','Brazil'),(2,'Data Science','USA');
SELECT * FROM ad_campaigns WHERE target_country = 'Brazil';
What are the patient outcomes for those who received therapy and medication, separated by socioeconomic status?
CREATE TABLE patients (patient_id INT,socioeconomic_status VARCHAR(50),therapy_completed BOOLEAN,medication_completed BOOLEAN,therapy_outcome INT,medication_outcome INT);
SELECT socioeconomic_status, SUM(CASE WHEN therapy_outcome > 0 THEN 1 ELSE 0 END) AS improved_therapy, SUM(CASE WHEN medication_outcome > 0 THEN 1 ELSE 0 END) AS improved_medication FROM patients WHERE therapy_completed = TRUE AND medication_completed = TRUE GROUP BY socioeconomic_status;
Update the workout type "Spinning" to "Cycling" in the "WorkoutTypes" table
CREATE TABLE WorkoutTypes (Id INT PRIMARY KEY,WorkoutType VARCHAR(50));
UPDATE WorkoutTypes SET WorkoutType = 'Cycling' WHERE WorkoutType = 'Spinning';
Update the safety AI model 'Criticality Safety' with a new method
CREATE TABLE safety_models (id INT,name VARCHAR(255),type VARCHAR(255),method VARCHAR(255)); INSERT INTO safety_models (id,name,type,method) VALUES (1,'Criticality Safety','Safety AI','Sensitivity Analysis');
UPDATE safety_models SET method = 'Consequence Analysis' WHERE name = 'Criticality Safety';
What is the average temperature recorded for crop 'Corn'?
CREATE TABLE WeatherData (crop_type VARCHAR(20),temperature FLOAT,record_date DATE); INSERT INTO WeatherData (crop_type,temperature,record_date) VALUES ('Corn',22.5,'2022-01-01'); INSERT INTO WeatherData (crop_type,temperature,record_date) VALUES ('Corn',25.3,'2022-01-02');
SELECT AVG(temperature) FROM WeatherData WHERE crop_type = 'Corn';
What is the average budget for digital divide initiatives in Oceania?
CREATE TABLE digital_divide_initiatives (region VARCHAR(20),budget DECIMAL(10,2)); INSERT INTO digital_divide_initiatives (region,budget) VALUES ('Oceania',250000.00),('Africa',300000.00),('South America',320000.00);
SELECT AVG(budget) as avg_budget FROM digital_divide_initiatives WHERE region = 'Oceania';
What is the average budget for labor advocacy organizations in Michigan that have a budget?
CREATE TABLE LaborAdvocacy (id INT,org_name VARCHAR,location VARCHAR,budget FLOAT);
SELECT AVG(budget) as avg_budget FROM LaborAdvocacy WHERE location = 'Michigan' AND budget IS NOT NULL;
What is the total CO2 emissions for each garment manufacturer in 2021?
CREATE TABLE manufacturing (manufacturing_id INT,manufacturer VARCHAR(50),CO2_emissions DECIMAL(10,2),manufacture_date DATE);
SELECT manufacturer, SUM(CO2_emissions) as total_emissions FROM manufacturing WHERE manufacture_date BETWEEN '2021-01-01' AND '2021-12-31' GROUP BY manufacturer;
What are the top 3 most common incident types in the 'IncidentReports' table?
CREATE TABLE IncidentReports (id INT,incident_name VARCHAR(50),severity VARCHAR(10),incident_type VARCHAR(50)); INSERT INTO IncidentReports (id,incident_name,severity,incident_type) VALUES (1,'Incident1','High','Malware'),(2,'Incident2','Medium','Phishing'),(3,'Incident3','Low','Unpatched Software'),(4,'Incident4','Hig...
SELECT incident_type, COUNT(*) as frequency FROM IncidentReports GROUP BY incident_type ORDER BY frequency DESC LIMIT 3;
What is the average billing rate for attorneys in the legal services domain?
CREATE TABLE Attorneys (AttorneyID INT,Name TEXT,Domain TEXT,HourlyRate DECIMAL); INSERT INTO Attorneys VALUES (1,'Singh','Legal Services',300),(2,'Lee','Criminal Law',250),(3,'Flores','Legal Services',280),(4,'Gomez','Intellectual Property',350);
SELECT AVG(Attorneys.HourlyRate) FROM Attorneys WHERE Attorneys.Domain = 'Legal Services';
identify the heaviest spacecraft manufactured by each country
CREATE TABLE Spacecraft_Manufacturing(name VARCHAR(50),mass FLOAT,country VARCHAR(50));
SELECT country, MAX(mass) FROM Spacecraft_Manufacturing GROUP BY country;
Delete records from donors table where state is 'CA'
CREATE TABLE donors (id INT PRIMARY KEY,name VARCHAR(100),age INT,state VARCHAR(2),income FLOAT);
DELETE FROM donors WHERE state = 'CA';
List the top 2 policyholders with the highest claim amounts in the 'Medium Risk' underwriting group.
CREATE TABLE underwriting (id INT,group VARCHAR(10),name VARCHAR(20),claim_amount DECIMAL(10,2)); INSERT INTO underwriting (id,group,name,claim_amount) VALUES (1,'High Risk','John Doe',5000.00),(2,'Medium Risk','Sophia Gonzalez',6000.00),(3,'Medium Risk','Javier Rodriguez',7000.00),(4,'Low Risk','Emma White',3000.00);
SELECT name, claim_amount FROM (SELECT name, claim_amount, ROW_NUMBER() OVER (PARTITION BY group ORDER BY claim_amount DESC) rn FROM underwriting WHERE group = 'Medium Risk') sub WHERE rn <= 2;
What is the total billing amount for cases in the "family" department?
CREATE TABLE CaseTypes (id INT,case_type VARCHAR(50),billing_amount DECIMAL(10,2));
SELECT case_type, SUM(billing_amount) FROM CaseTypes WHERE case_type = 'family' GROUP BY case_type;
What is the total biomass (in tons) of all marine life in the Pacific Ocean?
CREATE TABLE marine_life (species_name TEXT,location TEXT,biomass FLOAT); INSERT INTO marine_life (species_name,location,biomass) VALUES ('Salmon','Pacific Ocean',5.0),('Blue Whale','Pacific Ocean',200.0);
SELECT SUM(biomass) FROM marine_life WHERE location = 'Pacific Ocean';
How many research grants were awarded in the last two years?
CREATE TABLE research_grants (id INT,grant_date DATE,amount DECIMAL(10,2)); INSERT INTO research_grants (id,grant_date,amount) VALUES (1,'2021-01-01',5000),(2,'2021-03-01',7000),(3,'2020-02-01',3000);
SELECT COUNT(*) FROM research_grants WHERE grant_date >= DATE_SUB(CURRENT_DATE, INTERVAL 2 YEAR);
What is the average time to graduation by department?
CREATE TABLE student (id INT,department_id INT,graduation_date DATE); INSERT INTO student (id,department_id,graduation_date) VALUES (1,1,'2022-05-01'),(2,1,'2021-05-01'),(3,2,'2020-05-01');
SELECT department.name, AVG(DATEDIFF(graduation_date, student.enrollment_date)) as avg_time_to_graduation FROM department LEFT JOIN student ON department.id = student.department_id GROUP BY department.name;
Determine the average energy consumption of buildings with solar panel installations in the 'SmartCities' schema.
CREATE TABLE SmartCities.Buildings (id INT,has_solar_panels BOOLEAN,energy_consumption FLOAT); INSERT INTO SmartCities.Buildings (id,has_solar_panels,energy_consumption) VALUES (1,true,1200.5),(2,false,800.2),(3,true,900.7),(4,false,700.3),(5,true,600.0);
SELECT AVG(energy_consumption) FROM SmartCities.Buildings WHERE has_solar_panels = true;
How many charging stations for electric vehicles are there in Jakarta?
CREATE TABLE charging_stations (station_id INT,type VARCHAR(20),city VARCHAR(20)); INSERT INTO charging_stations (station_id,type,city) VALUES (1,'Car','Jakarta'),(2,'Bike','Jakarta'),(3,'Car','Jakarta'),(4,'Bike','Jakarta');
SELECT city, COUNT(*) FROM charging_stations WHERE city = 'Jakarta' GROUP BY city;
List all the disasters that occurred between January 2015 and December 2016.
CREATE TABLE disasters (id INT,disaster_name VARCHAR(50),start_date DATE,end_date DATE); INSERT INTO disasters (id,disaster_name,start_date,end_date) VALUES (1,'Nepal Earthquake','2015-04-25','2015-05-03'),(2,'Ebola Outbreak','2014-12-29','2016-06-10'),(3,'Hurricane Matthew','2016-09-28','2016-10-09'),(4,'Syria Conflic...
SELECT disaster_name FROM disasters WHERE start_date BETWEEN '2015-01-01' AND '2016-12-31';
What are the details of the national security threats that originated from a specific country, say 'Russia', from the 'nat_sec_threats' table?
CREATE TABLE nat_sec_threats (id INT,threat_name VARCHAR(255),country VARCHAR(255),threat_date DATE);
SELECT * FROM nat_sec_threats WHERE country = 'Russia';
Which cultivators in California had the highest average potency for their Indica strains in 2022?
CREATE TABLE cultivators (id INT,name TEXT,state TEXT); INSERT INTO cultivators (id,name,state) VALUES (1,'Cultivator A','California'); INSERT INTO cultivators (id,name,state) VALUES (2,'Cultivator B','California'); CREATE TABLE strains (cultivator_id INT,name TEXT,type TEXT,year INT,potency INT); INSERT INTO strains (...
SELECT c.name as cultivator_name, AVG(s.potency) as average_potency FROM cultivators c INNER JOIN strains s ON c.id = s.cultivator_id WHERE c.state = 'California' AND s.type = 'Indica' AND s.year = 2022 GROUP BY c.name ORDER BY average_potency DESC LIMIT 1;
Which countries acquired military cyber warfare systems in 2019?
CREATE TABLE military_transactions (id INT,country VARCHAR(255),year INT,technology VARCHAR(255)); INSERT INTO military_transactions (id,country,year,technology) VALUES (4,'Russia',2019,'Military Cyber Warfare Systems'),(5,'Iran',2019,'Military Cyber Warfare Systems');
SELECT DISTINCT country FROM military_transactions WHERE technology = 'Military Cyber Warfare Systems' AND year = 2019;
What is the average daily fare collected by bus and tram routes?
CREATE TABLE bus_routes (id INT,name VARCHAR(50),type VARCHAR(10),length DECIMAL(5,2),fare DECIMAL(5,2)); INSERT INTO bus_routes (id,name,type,length,fare) VALUES (1,'Line 1A','Bus',12.3,2.5),(2,'Line 2B','Tram',15.8,3.2);
SELECT type, AVG(fare) FROM bus_routes WHERE type IN ('Bus', 'Tram') GROUP BY type;
What are the unique threat levels in the 'threat_intelligence_v2' table?
CREATE TABLE threat_intelligence_v2 (id INT,name VARCHAR(255),ip_address VARCHAR(50),threat_level VARCHAR(10)); INSERT INTO threat_intelligence_v2 (id,name,ip_address,threat_level) VALUES (4,'APT35','172.20.0.1','Low'),(5,'APT36','10.1.1.1','High'),(6,'APT37','192.168.2.1','Medium');
SELECT DISTINCT threat_level FROM threat_intelligence_v2;
How many security incidents were reported in the last 30 days, and what was the average severity level?
CREATE TABLE incidents (incident_id INT,incident_date DATE,severity INT);
SELECT COUNT(*) as incident_count, AVG(severity) as avg_severity FROM incidents WHERE incident_date >= NOW() - INTERVAL 30 DAY;
What is the total revenue from ticket sales for games with an attendance of more than 5000 people?
CREATE TABLE ticket_prices (ticket_id INT,game_id INT,price DECIMAL(5,2));
SELECT SUM(price * quantity) FROM ticket_sales JOIN ticket_prices ON ticket_sales.ticket_id = ticket_prices.ticket_id WHERE (SELECT COUNT(DISTINCT fan_id) FROM fans WHERE game_id = ticket_sales.game_id) > 5000;
What is the total number of streams for hip-hop tracks on Spotify, grouped by quarter?
CREATE TABLE Streams (StreamID INT,TrackID INT,PlatformID INT,Date DATE,Streams INT); INSERT INTO Streams (StreamID,TrackID,PlatformID,Date,Streams) VALUES (1,1,1,'2022-01-01',100);
SELECT EXTRACT(QUARTER FROM Date) as Quarter, SUM(Streams) as TotalStreams FROM Streams JOIN Tracks ON Streams.TrackID = Tracks.TrackID JOIN StreamingPlatforms ON Streams.PlatformID = StreamingPlatforms.PlatformID WHERE Genre = 'Hip-Hop' AND PlatformName = 'Spotify' GROUP BY Quarter;
Determine the total sales revenue for each month of the year
CREATE TABLE sales_data_2 (sale_id INT,product_id INT,sale_date DATE,price DECIMAL(5,2),quantity INT); INSERT INTO sales_data_2 (sale_id,product_id,sale_date,price,quantity) VALUES (6,1,'2021-02-01',12.50,10),(7,2,'2021-03-02',13.00,15),(8,3,'2021-04-03',12.75,12),(9,4,'2021-05-04',45.00,5),(10,5,'2021-06-05',35.00,3);
SELECT DATE_FORMAT(sale_date, '%Y-%m') AS month, SUM(price * quantity) AS total_sales_revenue FROM sales_data_2 GROUP BY month;
Calculate the total downtime (in hours) for 'VesselI' during its maintenance periods in Q3 of 2020.
CREATE TABLE Vessels (vessel_name VARCHAR(255)); INSERT INTO Vessels (vessel_name) VALUES ('VesselI'),('VesselJ'); CREATE TABLE Maintenance (vessel_name VARCHAR(255),maintenance_start_date DATE,maintenance_end_date DATE); INSERT INTO Maintenance (vessel_name,maintenance_start_date,maintenance_end_date) VALUES ('VesselI...
SELECT SUM(DATEDIFF(hour, maintenance_start_date, maintenance_end_date)) FROM Maintenance WHERE vessel_name = 'VesselI' AND maintenance_start_date BETWEEN '2020-07-01' AND '2020-09-30';
How many financial products have been created in the last year?
CREATE TABLE products_history (product_id INT,product_name TEXT,creation_date DATE);
SELECT COUNT(*) FROM products_history WHERE products_history.creation_date >= DATEADD(year, -1, CURRENT_DATE);
List all chemicals and their safety protocols that were last updated before 2020-01-01.
CREATE TABLE Chemicals (chemical_id INT,chemical_name VARCHAR(20),last_updated DATE); CREATE TABLE Safety_Protocols (protocol_id INT,chemical_id INT,protocol_description VARCHAR(100));
SELECT Chemicals.chemical_name, Safety_Protocols.protocol_description FROM Chemicals INNER JOIN Safety_Protocols ON Chemicals.chemical_id = Safety_Protocols.chemical_id WHERE Chemicals.last_updated < '2020-01-01';
Update a network usage record's usage type and duration in the network_usage table
CREATE TABLE network_usage (usage_id INT,subscriber_id INT,usage_date DATE,usage_type VARCHAR(50),usage_duration INT);
UPDATE network_usage SET usage_type = 'Broadband', usage_duration = 200 WHERE usage_id = 3001;
What is the maximum duration of space missions for astronauts from the UK?
CREATE TABLE SpaceMissions (mission_name VARCHAR(30),astronaut_nationality VARCHAR(20),duration INT); INSERT INTO SpaceMissions (mission_name,astronaut_nationality,duration) VALUES ('Mission3','UK',300);
SELECT MAX(duration) FROM SpaceMissions WHERE astronaut_nationality = 'UK';
What is the total number of followers for users in the 'content_creator' category who have posted more than 30 times and have a follower count greater than 50000?
CREATE TABLE users (user_id INT,username VARCHAR(255),category VARCHAR(255),follower_count INT,post_count INT); INSERT INTO users (user_id,username,category,follower_count,post_count) VALUES (1,'user1','content_creator',60000,35),(2,'user2','politician',20000,30),(3,'user3','content_creator',70000,15);
SELECT SUM(follower_count) FROM users WHERE category = 'content_creator' AND post_count > 30 AND follower_count > 50000;
What are the top 5 busiest charging station locations with more than 7 charging stations and power level greater than 60?
CREATE TABLE Charging_Stations (id INT,charging_station_id INT,operator VARCHAR(255),location VARCHAR(255),num_chargers INT,num_ports INT,power_level INT);
SELECT location, COUNT(*) as num_ports FROM Charging_Stations WHERE num_chargers > 7 AND power_level > 60 GROUP BY location ORDER BY num_ports DESC LIMIT 5;
What is the average mass (in kg) of all spacecraft that have been used in space missions, excluding any spacecraft that have not yet been launched?
CREATE TABLE spacecraft (id INT,name VARCHAR(50),manufacturer VARCHAR(50),mass FLOAT,launch_date DATE); INSERT INTO spacecraft (id,name,manufacturer,mass,launch_date) VALUES (1,'New Glenn','Blue Origin',720000.0,'2025-01-01'); INSERT INTO spacecraft (id,name,manufacturer,mass,launch_date) VALUES (2,'Shepard','Blue Orig...
SELECT AVG(mass) FROM spacecraft WHERE launch_date IS NOT NULL;
Display the number of unique artists who have performed at music festivals
CREATE TABLE festivals (id INT,artist_name VARCHAR(255)); INSERT INTO festivals (id,artist_name) VALUES (1,'Taylor Swift'),(2,'BTS'),(3,'Taylor Swift'),(4,'Ariana Grande');
SELECT COUNT(DISTINCT artist_name) as num_unique_artists FROM festivals;
What is the total energy consumption in Antarctica for the last 3 years?
CREATE TABLE energy_antarctica (year INT,energy_consumption INT); INSERT INTO energy_antarctica VALUES (2017,100),(2018,110),(2019,120);
SELECT SUM(energy_consumption) FROM energy_antarctica WHERE year BETWEEN 2017 AND 2019;
What is the minimum data usage for postpaid mobile customers in the West region in the past month?
CREATE TABLE usage(customer_id INT,data_usage INT,usage_date DATE); CREATE TABLE customers(id INT,type VARCHAR(10),region VARCHAR(10));
SELECT MIN(usage.data_usage) FROM usage JOIN customers ON usage.customer_id = customers.id WHERE customers.type = 'postpaid' AND customers.region = 'West' AND usage.usage_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH);
Add a new textile source 'Fair Trade Certified Organic Cotton' to the 'sources' table
CREATE TABLE sources (id INT PRIMARY KEY,source_name VARCHAR(50));
INSERT INTO sources (id, source_name) VALUES (1, 'Fair Trade Certified Organic Cotton');
What is the maximum installed capacity of wind projects in 'green_country'?
CREATE TABLE renewable_energy_projects (id INT,project_name TEXT,country TEXT,technology TEXT,installed_capacity FLOAT); INSERT INTO renewable_energy_projects (id,project_name,country,technology,installed_capacity) VALUES (1,'WindFarm1','green_country','wind',300.0),(2,'SolarPlant1','solar_country','solar',250.0);
SELECT MAX(installed_capacity) FROM renewable_energy_projects WHERE country = 'green_country' AND technology = 'wind';
What is the average donation amount per donor, partitioned by year and ordered by total donation amount?
CREATE TABLE donors (id INT,name VARCHAR(50),total_donations DECIMAL(10,2),donation_year INT); INSERT INTO donors (id,name,total_donations,donation_year) VALUES (1,'John Doe',500.00,2020),(2,'Jane Smith',750.00,2019),(3,'Mike Johnson',300.00,2021);
SELECT donation_year, AVG(total_donations) avg_donation, RANK() OVER (PARTITION BY donation_year ORDER BY avg_donation DESC) donor_rank FROM donors GROUP BY donation_year ORDER BY donation_year, avg_donation DESC;
Display the dishes and their calorie counts in the order they were added, for vegan dishes only.
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,'20...
SELECT dish_name, calorie_count FROM dishes WHERE dish_type = 'vegan' ORDER BY added_date;
What is the average budget for humanitarian assistance operations for each region?
CREATE TABLE humanitarian_assistance (id INT,operation VARCHAR(255),region VARCHAR(255),budget DECIMAL(10,2));
SELECT region, AVG(budget) FROM humanitarian_assistance GROUP BY region;
What is the total quantity of sustainable materials in Brazil?
CREATE TABLE materials (id INT,name VARCHAR(50),quantity INT,country VARCHAR(50)); INSERT INTO materials (id,name,quantity,country) VALUES (1,'organic cotton',1000,'India'),(2,'recycled polyester',1500,'China'),(3,'hemp',500,'Brazil');
SELECT SUM(quantity) FROM materials WHERE country = 'Brazil' AND name LIKE '%sustainable%';
What is the average CO2 emission of buildings in the renewable energy sector?
CREATE TABLE Buildings (id INT,sector VARCHAR(20),CO2_emission FLOAT); INSERT INTO Buildings (id,sector,CO2_emission) VALUES (1,'Renewable',50.5),(2,'Non-Renewable',80.0);
SELECT AVG(CO2_emission) FROM Buildings WHERE sector = 'Renewable';
What is the number of days between each student's exam date, ordered by district_id and then by the number of days between exams?
CREATE TABLE student_exams (student_id INT,district_id INT,exam_date DATE); INSERT INTO student_exams (student_id,district_id,exam_date) VALUES (1,101,'2022-01-01'),(2,101,'2022-01-05'),(3,102,'2022-01-03'),(4,102,'2022-01-07'),(5,103,'2022-01-02');
SELECT student_id, district_id, exam_date, exam_date - LAG(exam_date) OVER (PARTITION BY district_id ORDER BY student_id) as days_between_exams FROM student_exams ORDER BY district_id, days_between_exams;
What is the maximum number of visitors to Greece from Canada in a single month?
CREATE TABLE visitor_stats (id INT PRIMARY KEY,visitor_country VARCHAR(50),year INT,month INT,num_visitors INT); INSERT INTO visitor_stats (id,visitor_country,year,month,num_visitors) VALUES (1,'Canada',2019,6,15000); INSERT INTO visitor_stats (id,visitor_country,year,month,num_visitors) VALUES (2,'Canada',2019,9,18000...
SELECT MAX(num_visitors) FROM visitor_stats WHERE visitor_country = 'Canada' AND year = 2019 AND month IS NOT NULL;
What is the total number of accommodations provided for students with learning disabilities in each school?
CREATE TABLE Accommodations (SchoolName VARCHAR(255),Student VARCHAR(255),Accommodation VARCHAR(255)); INSERT INTO Accommodations (SchoolName,Student,Accommodation) VALUES ('SchoolA','Student1','Extra Time'),('SchoolA','Student2','Reader'),('SchoolB','Student3','Extra Time');
SELECT SchoolName, COUNT(*) as TotalAccommodations FROM Accommodations WHERE Accommodation LIKE '%Learning Disability%' GROUP BY SchoolName;
What is the market share of electric vehicles in the top 10 most populous cities in China?
CREATE TABLE vehicles (vehicle_id INT,make TEXT,model TEXT,year INT,type TEXT,city_name TEXT);
SELECT city_name, SUM(CASE WHEN type = 'Electric' THEN 1 ELSE 0 END) / COUNT(*) FROM vehicles GROUP BY city_name ORDER BY COUNT(*) DESC LIMIT 10;
What is the total transaction amount for each client?
CREATE TABLE transactions (id INT,client_id INT,transaction_amount DECIMAL(10,2),transaction_date DATE); INSERT INTO transactions (id,client_id,transaction_amount,transaction_date) VALUES (1,1,500.00,'2022-01-01'),(2,2,800.00,'2022-01-02'),(3,1,1200.00,'2022-01-03'); CREATE TABLE clients (id INT,name VARCHAR(255),state...
SELECT clients.id, clients.name, SUM(transactions.transaction_amount) FROM clients INNER JOIN transactions ON clients.id = transactions.client_id GROUP BY clients.id;
What are the structural materials used in the projects that have not started yet?
CREATE TABLE Projects (id INT,name VARCHAR(255),status VARCHAR(255),start_date DATE); INSERT INTO Projects (id,name,status,start_date) VALUES (1,'Bridge Construction','Not Started','2023-01-01'); INSERT INTO Projects (id,name,status,start_date) VALUES (2,'Road Widening','In Progress','2022-06-01'); CREATE TABLE Materia...
SELECT m.name FROM Materials m JOIN Projects p ON m.name = 'Steel' WHERE p.start_date > CURDATE() AND p.status = 'Not Started';
What is the total number of cruelty-free certified products?
CREATE TABLE products (product_id INT PRIMARY KEY,cruelty_free BOOLEAN); INSERT INTO products (product_id,cruelty_free) VALUES (1,true),(2,true),(3,false),(4,true);
SELECT COUNT(*) FROM products WHERE cruelty_free = true;