instruction
stringlengths
0
1.06k
input
stringlengths
11
5.3k
response
stringlengths
2
4.44k
What is the number of artworks created by artists from underrepresented communities and their average value, for each country in Asia?
CREATE TABLE Artists (ArtistID INT,ArtistName VARCHAR(50),Community VARCHAR(50),Country VARCHAR(50)); CREATE TABLE ArtPieces (ArtPieceID INT,ArtistID INT,Value INT); INSERT INTO Artists VALUES (1,'Artist 1','Underrepresented','China'),(2,'Artist 2','Underrepresented','Japan'),(3,'Artist 3','Not Underrepresented','India'); INSERT INTO ArtPieces VALUES (1,1,5000),(2,1,7000),(3,2,8000),(4,2,9000),(5,3,11000),(6,3,13000);
SELECT A.Country, COUNT(AP.ArtPieceID) AS ArtworkCount, AVG(AP.Value) AS AvgValue FROM Artists A INNER JOIN ArtPieces AP ON A.ArtistID = AP.ArtistID WHERE A.Community = 'Underrepresented' AND A.Country IN ('Asia') GROUP BY A.Country;
What are the total sales and number of orders for each cuisine type?
CREATE TABLE restaurants (id INT,name VARCHAR(50),cuisine VARCHAR(50),sales DECIMAL(10,2),orders INT);
SELECT cuisine, SUM(sales) as total_sales, SUM(orders) as total_orders FROM restaurants GROUP BY cuisine;
What is the maximum score achieved in a single game session?
CREATE TABLE game_sessions (session_id INT,player_id INT,score INT); INSERT INTO game_sessions (session_id,player_id,score) VALUES (1,1,300),(2,2,400),(3,3,250);
SELECT MAX(score) FROM game_sessions;
Calculate the average distance of freight routes in Germany.
CREATE TABLE routes (id INT,start_location VARCHAR(50),end_location VARCHAR(50),distance INT,country VARCHAR(50)); INSERT INTO routes VALUES (1,'Location A','Location B',100,'Germany'),(2,'Location A','Location C',200,'France'),(3,'Location B','Location C',150,'Germany');
SELECT AVG(distance) as avg_distance FROM routes WHERE country = 'Germany';
What is the transaction value trend for each customer in the last month?
CREATE TABLE customers (customer_id INT,transaction_date DATE,transaction_value FLOAT); INSERT INTO customers VALUES (1,'2021-01-01',100.0),(1,'2021-02-01',200.0),(2,'2021-03-01',150.0);
SELECT customer_id, transaction_date, transaction_value, AVG(transaction_value) OVER (PARTITION BY customer_id ORDER BY transaction_date ROWS BETWEEN 29 PRECEDING AND CURRENT ROW) AS avg_transaction_value FROM customers WHERE transaction_date >= DATEADD(month, -1, CURRENT_DATE);
What is the adoption rate of virtual reality technology in Europe?
CREATE TABLE VRAdoption (UserID INT,Location VARCHAR(20),Adoption DATE); INSERT INTO VRAdoption (UserID,Location,Adoption) VALUES (1,'Europe','2018-01-01'),(2,'Asia','2019-01-01'),(3,'North America','2020-01-01');
SELECT Location, COUNT(UserID) as NumUsers, COUNT(*) FILTER (WHERE Adoption IS NOT NULL) as NumAdopters, COUNT(*) FILTER (WHERE Adoption IS NOT NULL) * 100.0 / COUNT(UserID) as AdoptionRate FROM VRAdoption GROUP BY Location
What is the total billing amount for cases handled by attorneys in the 'Boston' region?
CREATE TABLE attorneys (id INT,name TEXT,region TEXT); INSERT INTO attorneys (id,name,region) VALUES (1,'John Smith','Boston'),(2,'Jane Doe','New York'); CREATE TABLE cases (id INT,attorney_id INT,billing_amount INT); INSERT INTO cases (id,attorney_id,billing_amount) VALUES (1,1,1000),(2,1,2000),(3,2,3000);
SELECT SUM(billing_amount) FROM cases INNER JOIN attorneys ON cases.attorney_id = attorneys.id WHERE attorneys.region = 'Boston';
What is the total number of inclusive housing policies in the city of Toronto that were implemented before 2015?
CREATE TABLE InclusivePolicies (id INT,city VARCHAR(20),year INT,policy TEXT);
SELECT COUNT(*) FROM InclusivePolicies WHERE city = 'Toronto' AND year < 2015;
How many local tours were booked virtually in Tokyo in the last month?
CREATE TABLE tours(id INT,city TEXT,booking_date DATE,booking_type TEXT); INSERT INTO tours (id,city,booking_date,booking_type) VALUES (1,'Tokyo','2022-03-05','virtual'),(2,'Tokyo','2022-03-10','in-person'),(3,'Tokyo','2022-03-20','virtual');
SELECT COUNT(*) FROM tours WHERE city = 'Tokyo' AND booking_date >= DATEADD(month, -1, GETDATE()) AND booking_type = 'virtual';
What is the number of animals of each species currently in rehabilitation centers, grouped by condition?
CREATE TABLE RehabilitationCenters (id INT,animal_id INT,species VARCHAR(255),condition VARCHAR(255)); INSERT INTO RehabilitationCenters (id,animal_id,species,condition) VALUES (1,1,'Lion','Critical'),(2,2,'Elephant','Stable'),(3,3,'Tiger','Critical');
SELECT species, condition, COUNT(*) FROM RehabilitationCenters GROUP BY species, condition;
Update the donation amount to 1200.00 for the donor with the donor_id 3.
CREATE TABLE donors (donor_id INT,first_name TEXT,last_name TEXT,donation_amount FLOAT); INSERT INTO donors (donor_id,first_name,last_name,donation_amount) VALUES (1,'John','Doe',500.00),(2,'Jane','Smith',350.00),(3,'Mike','Johnson',700.00); CREATE TABLE donations (donation_id INT,donor_id INT,organization_id INT,donation_amount FLOAT); INSERT INTO donations (donation_id,donor_id,organization_id,donation_amount) VALUES (1,2,101,350.00),(2,3,102,700.00);
UPDATE donors SET donation_amount = 1200.00 WHERE donor_id = 3;
Which startups founded by African American women have raised over $10 million?
CREATE TABLE IF NOT EXISTS startups(id INT,name TEXT,founder_gender TEXT,founder_race TEXT,total_funding FLOAT); INSERT INTO startups (id,name,founder_gender,founder_race,total_funding) VALUES (1,'Glow','Female','African American',15000000); INSERT INTO startups (id,name,founder_gender,founder_race,total_funding) VALUES (2,'Blavity','Female','African American',8000000); INSERT INTO startups (id,name,founder_gender,founder_race,total_funding) VALUES (3,'Zyah','Female','African American',3000000);
SELECT name FROM startups WHERE founder_gender = 'Female' AND founder_race = 'African American' AND total_funding > 10000000;
What is the sum of the populations of the animals in the 'habitat_preservation' table that are not endangered?
CREATE TABLE habitat_preservation (id INT,animal_name VARCHAR(50),population INT,endangered_status VARCHAR(50));
SELECT SUM(population) FROM habitat_preservation WHERE endangered_status != 'Endangered';
What is the minimum water consumption in the Water_Usage table for the year 2018?
CREATE TABLE Water_Usage (id INT,year INT,water_consumption FLOAT); INSERT INTO Water_Usage (id,year,water_consumption) VALUES (1,2018,12000.0),(2,2019,13000.0),(3,2020,14000.0),(4,2021,15000.0);
SELECT MIN(water_consumption) FROM Water_Usage WHERE year = 2018;
Display the total number of flights to each destination from the 'flights' table
CREATE TABLE flights (flight_id INT,flight_name VARCHAR(50),destination VARCHAR(50),passengers INT);
SELECT destination, SUM(passengers) as total_passengers FROM flights GROUP BY destination;
List all factories that have received a sustainability audit in the past year.
CREATE TABLE factories (id INT,name VARCHAR(255),last_audit_date DATE);
SELECT factories.name FROM factories WHERE factories.last_audit_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR);
What is the minimum price of products made from recycled materials in the North American market?
CREATE TABLE products (product_id INT,material VARCHAR(20),price DECIMAL(5,2),market VARCHAR(20)); INSERT INTO products (product_id,material,price,market) VALUES (1,'recycled polyester',50.00,'North America'),(2,'recycled cotton',60.00,'North America'),(3,'recycled nylon',70.00,'Europe'),(4,'recycled polyester',40.00,'North America');
SELECT MIN(price) FROM products WHERE market = 'North America' AND material LIKE '%recycled%';
How many autonomous driving research papers were published in 2021 in the Research_Papers table?
CREATE TABLE Research_Papers (Paper_Title VARCHAR(50),Publication_Year INT,Vehicle_Type VARCHAR(20));
SELECT COUNT(*) FROM Research_Papers WHERE Vehicle_Type = 'Autonomous' AND Publication_Year = 2021;
What is the rank of each economic diversification effort in the 'economic_diversification' table, ordered by the amount of investment and ranked in ascending order?;
CREATE TABLE economic_diversification (id INT,effort_name VARCHAR(50),amount_of_investment DECIMAL(10,2)); INSERT INTO economic_diversification VALUES (1,'Tourism Development',200000.00),(2,'Manufacturing Expansion',300000.00),(3,'Agricultural Modernization',150000.00),(4,'Technology Innovation',400000.00),(5,'Service Industry Growth',250000.00);
SELECT effort_name, ROW_NUMBER() OVER (ORDER BY amount_of_investment ASC) as rank FROM economic_diversification;
Identify creative AI applications with a low creativity score.
CREATE TABLE creative_ai_applications (id INT PRIMARY KEY,application_name VARCHAR(50),application_type VARCHAR(50),creativity_score FLOAT); INSERT INTO creative_ai_applications (id,application_name,application_type,creativity_score) VALUES (1,'AI-Generated Music','Music Generation',0.78); INSERT INTO creative_ai_applications (id,application_name,application_type,creativity_score) VALUES (2,'AI-Painted Art','Art Generation',0.91);
SELECT * FROM creative_ai_applications WHERE creativity_score < 0.8;
What is the maximum ocean floor height difference within the Indian Ocean?
CREATE TABLE indian_ocean_floor (id INT,location TEXT,height FLOAT);
SELECT MAX(height) - MIN(height) FROM indian_ocean_floor;
How many graduate students have completed a thesis in the field of Artificial Intelligence?
CREATE TABLE students (student_id INT,name VARCHAR(50),field VARCHAR(50),thesis BOOLEAN);
SELECT COUNT(s.student_id) FROM students s WHERE s.field = 'Artificial Intelligence' AND s.thesis = TRUE;
What is the total number of security incidents caused by outdated software in the EMEA region?
CREATE TABLE incidents (id INT,cause TEXT,region TEXT); INSERT INTO incidents (id,cause,region) VALUES (1,'outdated software','EMEA'),(2,'malware','APAC'),(3,'phishing','NA');
SELECT COUNT(*) FROM incidents WHERE cause = 'outdated software' AND region = 'EMEA';
Which communities have more than 2 co-owned properties?
CREATE TABLE community_data (community_id INT,property_id INT,co_owner_count INT); INSERT INTO community_data (community_id,property_id,co_owner_count) VALUES (1,1001,2),(1,1002,3),(2,2001,1),(3,3001,4),(3,3002,2);
SELECT community_id, COUNT(*) FROM community_data GROUP BY community_id HAVING COUNT(*) > 2;
Delete all records of sustainable materials from manufacturer 'GreenYarns'.
CREATE TABLE Manufacturers (ManufacturerID INT,ManufacturerName VARCHAR(50)); CREATE TABLE Materials (MaterialID INT,ManufacturerID INT,MaterialName VARCHAR(50),QuantityUsed INT,Sustainable VARCHAR(5)); INSERT INTO Manufacturers (ManufacturerID,ManufacturerName) VALUES (1,'EcoFriendlyFabrics'),(2,'GreenYarns'),(3,'SustainableTextiles'),(4,'EcoWeaves'); INSERT INTO Materials (MaterialID,ManufacturerID,MaterialName,QuantityUsed,Sustainable) VALUES (1,1,'organic cotton',2000,'Yes'),(2,1,'recycled polyester',1500,'Yes'),(3,2,'hemp fiber',1200,'Yes'),(4,3,'organic cotton',1800,'Yes'),(5,3,'recycled polyester',1000,'Yes'),(6,4,'organic cotton',2500,'Yes'),(7,4,'recycled polyester',1800,'Yes'),(8,4,'hemp fiber',1500,'Yes');
DELETE FROM Materials WHERE ManufacturerID = 2;
List the top 5 mental health conditions by number of patients treated in the past year in California?
CREATE TABLE Treatments (TreatmentID INT,Condition VARCHAR(50),TreatmentDate DATE,State VARCHAR(20));
SELECT Condition, COUNT(*) FROM Treatments WHERE TreatmentDate >= DATE_SUB(CURDATE(), INTERVAL 1 YEAR) AND State = 'California' GROUP BY Condition ORDER BY COUNT(*) DESC LIMIT 5;
What is the average calorie count for all dishes across all restaurants in the city of Portland, OR?
CREATE TABLE restaurants (restaurant_id INT,name TEXT,city TEXT); INSERT INTO restaurants (restaurant_id,name,city) VALUES (1,'Portland Pizza','Portland'),(2,'Burgers & Beyond','Portland'); CREATE TABLE dishes (dish_id INT,name TEXT,calories INT,restaurant_id INT); INSERT INTO dishes (dish_id,name,calories,restaurant_id) VALUES (1,'Margherita Pizza',1200,1),(2,'Veggie Burger',800,2);
SELECT AVG(calories) FROM dishes JOIN restaurants ON dishes.restaurant_id = restaurants.restaurant_id WHERE city = 'Portland';
What is the total revenue generated from clients in the healthcare industry?
CREATE TABLE clients (client_id INT,industry VARCHAR(255)); INSERT INTO clients (client_id,industry) VALUES (1,'healthcare'),(2,'technology'),(3,'finance');
SELECT SUM(revenue) FROM bills INNER JOIN clients ON bills.client_id = clients.client_id WHERE clients.industry = 'healthcare';
How many explainable AI projects were completed in 2021 and 2022?
CREATE TABLE projects (project_id INT,title VARCHAR(50),year INT,explainable BOOLEAN); INSERT INTO projects (project_id,title,year,explainable) VALUES (1,'ProjectX',2021,1),(2,'ProjectY',2022,0),(3,'ProjectZ',2021,1),(4,'ProjectW',2022,1);
SELECT COUNT(*) FROM projects WHERE year IN (2021, 2022) AND explainable = 1;
Insert a new sustainable tourism campaign in the 'campaigns' table
CREATE TABLE campaigns (id INT PRIMARY KEY,name VARCHAR(255),location VARCHAR(255),start_date DATE,end_date DATE);
INSERT INTO campaigns (id, name, location, start_date, end_date) VALUES (1, 'Eco-Friendly Adventure', 'Nepal', '2023-06-01', '2023-08-31');
List the climate communication campaigns that were conducted in Africa in 2017.
CREATE TABLE climate_communication (campaign VARCHAR(20),location VARCHAR(20),year INT); INSERT INTO climate_communication (campaign,location,year) VALUES ('Campaign G','Africa',2017),('Campaign H','Europe',2018),('Campaign I','Asia',2019);
SELECT campaign FROM climate_communication WHERE location = 'Africa' AND year = 2017;
What are the project costs for each category in the Northeast region?
CREATE TABLE Projects (region VARCHAR(20),category VARCHAR(20),project_cost INT); INSERT INTO Projects (region,category,project_cost) VALUES ('Northeast','Bridge',5000000),('Northeast','Road',3000000),('Northeast','Water Treatment',6500000),('Southwest','Dams Safety',7500000),('West','Transit System',9000000);
SELECT category, project_cost FROM Projects WHERE region = 'Northeast';
What is the total amount of resources extracted by each company?
CREATE TABLE ResourceExtraction(id INT,company VARCHAR(50),extraction_date DATE,amount INT);
SELECT company, SUM(amount) AS Total_Amount FROM ResourceExtraction GROUP BY company;
What are the names of all research vessels operating in the Arctic Ocean and Southern Ocean?
CREATE TABLE research_vessels (id INT,name TEXT,operation_area TEXT); INSERT INTO research_vessels (id,name,operation_area) VALUES (1,'RV Polarstern','Arctic Ocean'); INSERT INTO research_vessels (id,name,operation_area) VALUES (2,'RRS Sir David Attenborough','Southern Ocean');
SELECT name FROM research_vessels WHERE operation_area = 'Arctic Ocean' OR operation_area = 'Southern Ocean';
Find the number of sustainable seafood certifications by country.
CREATE TABLE seafood_certifications (id INT,country VARCHAR(50),certification VARCHAR(50)); INSERT INTO seafood_certifications (id,country,certification) VALUES (1,'Norway','MSC'),(2,'Norway','ASC'),(3,'Canada','MSC');
SELECT country, COUNT(DISTINCT certification) FROM seafood_certifications GROUP BY country;
What are the types of permits issued for projects between 2021 and 2022?
CREATE TABLE permit (id INT,project_id INT,type VARCHAR(50),issued_date DATE,expiration_date DATE); INSERT INTO permit (id,project_id,type,issued_date,expiration_date) VALUES (1,2,'Renovation','2021-03-15','2023-03-15');
SELECT type FROM permit WHERE issued_date BETWEEN '2021-01-01' AND '2022-12-31';
Calculate the percentage of sustainable ingredients for each menu item in a given restaurant.
CREATE TABLE menu_items (menu_item_id INT,restaurant_id INT,sustainable_ingredients_percentage DECIMAL(5,2)); INSERT INTO menu_items (menu_item_id,restaurant_id,sustainable_ingredients_percentage) VALUES (1,1,0.6),(2,1,0.7),(3,1,0.8),(4,2,0.5),(5,2,0.6),(6,2,0.7);
SELECT menu_item_id, restaurant_id, sustainable_ingredients_percentage, (sustainable_ingredients_percentage * 100.0) AS percentage_sustainable FROM menu_items WHERE restaurant_id = 1;
Find the number of unique games in the database
game_stats(game_id,player_id,score,date_played)
SELECT COUNT(DISTINCT game_id) as unique_games FROM game_stats;
How many biotech startups from Australia or New Zealand have received funding in the last 18 months?
CREATE TABLE biotech_startups (startup_name VARCHAR(255),funding_round DATE,country VARCHAR(255)); INSERT INTO biotech_startups (startup_name,funding_round,country) VALUES ('StartupC','2023-01-01','Australia');
SELECT COUNT(*) FROM biotech_startups WHERE funding_round BETWEEN DATEADD(MONTH, -18, GETDATE()) AND GETDATE() AND country IN ('Australia', 'New Zealand');
What is the total amount of resources extracted from each mining site?
CREATE TABLE MiningSites (site_id INT,site_name VARCHAR(50),location VARCHAR(50),resources_extracted DECIMAL(10,2)); INSERT INTO MiningSites (site_id,site_name,location,resources_extracted) VALUES (1,'Site A','California',10000),(2,'Site B','Nevada',15000);
SELECT site_name, resources_extracted FROM MiningSites;
How many unique research grants were awarded to each department in 2020?
CREATE TABLE ResearchGrants(GrantID INT,Department VARCHAR(50),Amount FLOAT,GrantDate DATE); INSERT INTO ResearchGrants (GrantID,Department,Amount,GrantDate) VALUES (1,'Physics',80000.00,'2020-01-01'),(2,'Physics',90000.00,'2020-01-05');
SELECT Department, COUNT(DISTINCT GrantID) FROM ResearchGrants WHERE YEAR(GrantDate) = 2020 GROUP BY Department;
Which employees have completed the most cultural competency training hours?
CREATE TABLE CulturalCompetencyTraining (ID INT PRIMARY KEY,EmployeeID INT,TrainingType VARCHAR(20),Hours INT,Date DATE);
SELECT EmployeeID, SUM(Hours) as TotalHours FROM CulturalCompetencyTraining GROUP BY EmployeeID ORDER BY TotalHours DESC LIMIT 5;
Delete records from the garment table that have a quantity of 0.
CREATE TABLE garment (id INT PRIMARY KEY,garment_name VARCHAR(255),quantity INT); INSERT INTO garment (id,garment_name,quantity) VALUES (1,'Rayon',100),(2,'Silk',0),(3,'Cotton',200);
DELETE FROM garment WHERE quantity = 0;
What's the total runtime for all music videos by a specific artist, such as 'Beyoncé'?
CREATE TABLE music_video (id INT,title VARCHAR(100),artist VARCHAR(50),runtime INT); INSERT INTO music_video (id,title,artist,runtime) VALUES (1,'MusicVideo1','Beyoncé',4); INSERT INTO music_video (id,title,artist,runtime) VALUES (2,'MusicVideo2','Beyoncé',3);
SELECT SUM(runtime) FROM music_video WHERE artist = 'Beyoncé';
List the types of rural infrastructure projects and their respective budgets, sorted by budget in descending order.
CREATE TABLE rural_infrastructure (project_type VARCHAR(255),budget INT); INSERT INTO rural_infrastructure (project_type,budget) VALUES ('Dams',800000),('Renewable Energy',500000),('Irrigation Systems',350000);
SELECT project_type, budget FROM rural_infrastructure ORDER BY budget DESC;
Delete all records from the 'incidents' table where the incident_type is 'habitat destruction'
CREATE TABLE incidents (id INT,animal_id INT,incident_type VARCHAR(20),timestamp TIMESTAMP);
DELETE FROM incidents WHERE incident_type = 'habitat destruction';
Find the number of unique marine species found in the Indian Ocean region.
CREATE TABLE marine_species (id INT,species TEXT,region TEXT); INSERT INTO marine_species (id,species,region) VALUES (1,'Clownfish','Indian',(2,'Dolphin','Indian'));
SELECT COUNT(DISTINCT species) FROM marine_species WHERE region = 'Indian';
What is the percentage of community health workers who are male?
CREATE TABLE community_health_workers (id INT,name VARCHAR(50),gender VARCHAR(50),race VARCHAR(50),ethnicity VARCHAR(50),years_of_experience INT); INSERT INTO community_health_workers (id,name,gender,race,ethnicity,years_of_experience) VALUES (1,'John Doe','Male','White','Not Hispanic or Latino',5),(2,'Jane Smith','Female','Black or African American','Not Hispanic or Latino',10);
SELECT gender, COUNT(*) OVER (PARTITION BY gender) as worker_count, PERCENTAGE(COUNT(*), (SELECT COUNT(*) FROM community_health_workers)) as percentage FROM community_health_workers;
Insert new trend for company_id 102: 'Blockchain'
CREATE TABLE companies (id INT PRIMARY KEY,name VARCHAR(255)); CREATE TABLE innovation_trends (id INT PRIMARY KEY,company_id INT,trend VARCHAR(255));
INSERT INTO innovation_trends (id, company_id, trend) VALUES (3, 102, 'Blockchain');
What is the total passenger count for public transportation in 2020?
CREATE TABLE PublicTransportation(Year INT,Mode VARCHAR(50),PassengerCount INT);
SELECT SUM(PassengerCount) FROM PublicTransportation WHERE Year = 2020;
Identify the renewable energy sources and their capacities (MW) in California
CREATE TABLE renewable_sources (id INT,state VARCHAR(50),source VARCHAR(50),capacity FLOAT); INSERT INTO renewable_sources (id,state,source,capacity) VALUES (1,'California','Solar',5000),(2,'California','Wind',3000),(3,'Texas','Solar',4000);
SELECT source, capacity FROM renewable_sources WHERE state = 'California';
What is the total capacity of all cargo ships that handled containers in the month of April 2022?
CREATE TABLE ships (id INT,name VARCHAR(255),capacity INT); INSERT INTO ships (id,name,capacity) VALUES (1,'Ship1',5000),(2,'Ship2',7000); CREATE TABLE containers (id INT,ship_name VARCHAR(255),handled_date DATE); INSERT INTO containers (id,ship_name,handled_date) VALUES (1,'Ship1','2022-04-02'),(2,'Ship2','2022-04-03'),(3,'Ship1','2022-04-04');
SELECT SUM(capacity) FROM ships INNER JOIN containers ON ships.name = containers.ship_name WHERE handled_date BETWEEN '2022-04-01' AND '2022-04-30';
What is the total value of digital assets per type?
CREATE TABLE asset_type (id INT,name VARCHAR(255)); INSERT INTO asset_type VALUES (1,'Cryptocurrency'),(2,'Security Token'),(3,'Utility Token'); CREATE TABLE digital_asset (id INT,name VARCHAR(255),asset_type_id INT,value DECIMAL(10,2)); INSERT INTO digital_asset VALUES (1,'AssetA',1,1000000),(2,'AssetB',2,2000000),(3,'AssetC',3,3000000);
SELECT asset_type.name AS asset_type, SUM(digital_asset.value) AS total_value FROM digital_asset JOIN asset_type ON digital_asset.asset_type_id = asset_type.id GROUP BY asset_type.name;
What was the total donation amount in each quarter of 2023?
CREATE TABLE donations (id INT,donation_date DATE,amount DECIMAL(10,2)); INSERT INTO donations (id,donation_date,amount) VALUES (1,'2023-01-01',200); INSERT INTO donations (id,donation_date,amount) VALUES (2,'2023-01-15',300);
SELECT DATE_TRUNC('quarter', donation_date) as quarter, SUM(amount) as total_donation FROM donations WHERE donation_date BETWEEN '2023-01-01' AND '2023-12-31' GROUP BY quarter;
What are the R&D projects in the 'Space' category and their end dates?
CREATE TABLE if not exists rnd_projects (id INT,project_name VARCHAR(100),category VARCHAR(50),cost INT,start_date DATE,end_date DATE); INSERT INTO rnd_projects (id,project_name,category,cost,start_date,end_date) VALUES (1,'Stealth Fighter','Aircraft',5000000,'2010-01-01','2015-12-31'); INSERT INTO rnd_projects (id,project_name,category,cost,start_date,end_date) VALUES (2,'AI-Powered Drone','UAV',1000000,'2018-01-01','2020-12-31');
SELECT project_name, category, end_date FROM rnd_projects WHERE category = 'Space';
Show the percentage of skincare products in Germany that are fragrance-free.
CREATE TABLE product_details(product_id INT,product_type VARCHAR(255),contains_fragrance BOOLEAN); CREATE TABLE cosmetics_sales(product_id INT,country VARCHAR(255),sales_quantity INT,sales_revenue DECIMAL(10,2));
SELECT 100.0 * COUNT(*) / (SELECT COUNT(*) FROM cosmetics_sales cs WHERE cs.country = 'Germany' AND cs.product_type = 'skincare') AS pct_fragrance_free FROM product_details pd WHERE pd.product_type = 'skincare' AND pd.contains_fragrance = FALSE;
List all the machines with an operational status of 'active' in the 'South' region
CREATE TABLE machines (id INT,name VARCHAR(50),operational_status VARCHAR(50),region VARCHAR(50)); INSERT INTO machines (id,name,operational_status,region) VALUES (1,'Machine1','active','South'),(2,'Machine2','inactive','North'),(3,'Machine3','active','South');
SELECT * FROM machines WHERE operational_status = 'active' AND region = 'South';
Identify the top 3 most used sustainable sourcing practices for seafood by total quantity.
CREATE TABLE sourcing (sourcing_id INT,restaurant_id INT,item_id INT,source VARCHAR(255),quantity INT); INSERT INTO sourcing (sourcing_id,restaurant_id,item_id,source,quantity) VALUES (1,1,1,'Local Fishery',100),(2,1,2,'Imported',200),(3,2,1,'Local Coop',150),(4,2,2,'Sustainable',250),(5,3,1,'Local Fishery',200),(6,3,2,'Imported',100); CREATE TABLE menu_items (item_id INT,name VARCHAR(255),category VARCHAR(255)); INSERT INTO menu_items (item_id,name,category) VALUES (1,'Tuna','Seafood'),(2,'Shrimp','Seafood'); CREATE TABLE restaurants (restaurant_id INT,name VARCHAR(255),location VARCHAR(255)); INSERT INTO restaurants (restaurant_id,name,location) VALUES (1,'Restaurant A','City A'),(2,'Restaurant B','City B'),(3,'Restaurant C','City C');
SELECT s.source, SUM(s.quantity) as total_quantity FROM sourcing s JOIN menu_items mi ON s.item_id = mi.item_id JOIN restaurants r ON s.restaurant_id = r.restaurant_id WHERE mi.category = 'Seafood' GROUP BY s.source ORDER BY total_quantity DESC LIMIT 3;
How many smart contracts were deployed in each month of 2021, broken down by their respective regulatory frameworks?
CREATE TABLE contract_deployments (deployment_date DATE,contract_id INT,framework VARCHAR(255)); INSERT INTO contract_deployments (deployment_date,contract_id,framework) VALUES ('2021-01-01',1,'EU'),('2021-01-15',2,'US'),('2021-02-03',3,'EU'),('2021-03-05',4,'Non-regulated'),('2021-04-01',5,'EU'),('2021-04-15',6,'US');
SELECT DATE_FORMAT(deployment_date, '%Y-%m') as month, framework, COUNT(contract_id) as count FROM contract_deployments GROUP BY month, framework;
Delete all concert records for the artist 'Billie Eilish' in the 'concerts' table.
CREATE TABLE concerts (id INT,artist VARCHAR(255),city VARCHAR(255),tickets_sold INT,price DECIMAL(10,2));
DELETE FROM concerts WHERE artist = 'Billie Eilish';
What is the maximum accommodation cost for students with visual impairments?
CREATE TABLE Accommodations (StudentID INT,DisabilityType TEXT,AccommodationCost DECIMAL); INSERT INTO Accommodations (StudentID,DisabilityType,AccommodationCost) VALUES (1,'VisualImpairment',500),(2,'HearingImpairment',700),(3,'MentalHealth',300);
SELECT MAX(AccommodationCost) as MaxCost FROM Accommodations WHERE DisabilityType = 'VisualImpairment';
Provide the details of all climate finance transactions for Least Developed Countries (LDCs) for the year 2020.
CREATE TABLE climate_finance (year INT,country_type VARCHAR(50),region VARCHAR(50),funding_type VARCHAR(50),amount INT);
SELECT * FROM climate_finance WHERE year = 2020 AND country_type = 'Least Developed Countries';
Avg. revenue of movies with a budget over $100M
CREATE TABLE Movies_Financials (movie VARCHAR(255),budget INT,revenue INT);
SELECT AVG(revenue) FROM Movies_Financials WHERE budget > 100000000;
List players who joined a game's community after a certain date
CREATE TABLE players (player_id INT,name VARCHAR(100),joined_date DATE); CREATE TABLE games (game_id INT,name VARCHAR(50)); CREATE TABLE player_games (player_id INT,game_id INT,joined_date DATE);
SELECT p.name, g.name AS game_name FROM players p JOIN player_games pg ON p.player_id = pg.player_id JOIN games g ON pg.game_id = g.game_id WHERE pg.joined_date > '2022-01-01' AND p.player_id = pg.player_id AND g.game_id = pg.game_id;
Identify the top 3 workout types with the longest duration for users aged 40 and above?
CREATE TABLE Workouts (WorkoutID INT,UserID INT,WorkoutType VARCHAR(50),Duration INT,Date DATE); INSERT INTO Workouts (WorkoutID,UserID,WorkoutType,Duration,Date) VALUES (1,1,'Running',60,'2022-01-01'),(2,1,'Swimming',45,'2022-01-02'),(3,2,'Cycling',90,'2022-01-01');
SELECT WorkoutType, AVG(Duration) as AvgDuration FROM Workouts WHERE Age >= 40 GROUP BY WorkoutType ORDER BY AvgDuration DESC LIMIT 3;
How many restorative justice programs were completed in each month of 2020?
CREATE TABLE programs (id INT,program_name VARCHAR(255),program_completion_date DATE); INSERT INTO programs (id,program_name,program_completion_date) VALUES (1,'Victim Offender Mediation','2020-02-01'),(2,'Restorative Justice Conference','2020-04-01');
SELECT DATE_FORMAT(program_completion_date, '%Y-%m') as Month, COUNT(*) as Programs FROM programs WHERE YEAR(program_completion_date) = 2020 GROUP BY Month;
What is the average heart rate of members during workouts in the summer season?
CREATE TABLE Workouts (WorkoutID INT,MemberID INT,HeartRate INT,WorkoutDate DATE); INSERT INTO Workouts (WorkoutID,MemberID,HeartRate,WorkoutDate) VALUES (1,1,120,'2022-06-01'),(2,2,130,'2022-07-01'),(3,3,100,'2022-05-01');
SELECT AVG(HeartRate) FROM Workouts WHERE MONTH(WorkoutDate) BETWEEN 6 AND 8;
Find the most common artifact type in 'Site E'?
CREATE TABLE Site_E (Artifact_ID INT,Artifact_Type VARCHAR(255)); INSERT INTO Site_E (Artifact_ID,Artifact_Type) VALUES (1,'Pottery'),(2,'Stone'),(3,'Pottery');
SELECT Artifact_Type, COUNT(*) FROM Site_E GROUP BY Artifact_Type ORDER BY COUNT(*) DESC LIMIT 1;
Count the number of unique donors who made a donation in the last month from each country.
CREATE TABLE donors (donor_id INT,donation_amount DECIMAL(10,2),donation_date DATE,country VARCHAR(50));
SELECT country, COUNT(DISTINCT donor_id) FROM donors WHERE donation_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) GROUP BY country;
What is the total number of ad impressions for users in Southeast Asia, broken down by platform?
CREATE TABLE ad_impressions (id INT,user_id INT,platform VARCHAR(50),impressions INT); INSERT INTO ad_impressions (id,user_id,platform,impressions) VALUES (1,1,'Facebook',200),(2,2,'Instagram',300),(3,3,'Twitter',150); CREATE TABLE users (id INT,region VARCHAR(50)); INSERT INTO users (id,region) VALUES (1,'Indonesia'),(2,'Malaysia'),(3,'Singapore');
SELECT users.region, SUM(CASE WHEN platform = 'Facebook' THEN impressions ELSE 0 END) as Facebook_impressions, SUM(CASE WHEN platform = 'Instagram' THEN impressions ELSE 0 END) as Instagram_impressions, SUM(CASE WHEN platform = 'Twitter' THEN impressions ELSE 0 END) as Twitter_impressions FROM ad_impressions JOIN users ON ad_impressions.user_id = users.id WHERE users.region IN ('Indonesia', 'Malaysia', 'Singapore') GROUP BY users.region;
Find the maximum billing rate for attorneys in 'billing' table
CREATE TABLE billing (attorney_id INT,client_id INT,hours_billed INT,billing_rate DECIMAL(5,2));
SELECT MAX(billing_rate) FROM billing;
What was the total quantity of recycled materials used by each manufacturer in H1 of 2022?
CREATE TABLE Manufacturers (id INT,name VARCHAR(255)); INSERT INTO Manufacturers (id,name) VALUES (1,'Manufacturer A'),(2,'Manufacturer B'),(3,'Manufacturer C'),(4,'Manufacturer D'); CREATE TABLE Recycled_Materials (id INT,manufacturer_id INT,year INT,H1 INT,H2 INT); INSERT INTO Recycled_Materials (id,manufacturer_id,year,H1,H2) VALUES (1,1,2022,800,900),(2,2,2022,1000,1100),(3,3,2022,1200,1300),(4,4,2022,1400,1500);
SELECT m.name, SUM(r.H1) FROM Recycled_Materials r JOIN Manufacturers m ON r.manufacturer_id = m.id WHERE r.year = 2022 GROUP BY m.name;
What is the annual waste generation for the state of New York?
CREATE TABLE state_waste (state VARCHAR(255),year INT,waste_generation INT); INSERT INTO state_waste (state,year,waste_generation) VALUES ('New York',2021,15000000);
SELECT waste_generation FROM state_waste WHERE state='New York' AND year=2021;
Delete records of workers who have worked more than 50 hours in the state of New York on non-sustainable projects.
CREATE TABLE construction_labor (id INT,worker_name VARCHAR(50),hours_worked INT,project_type VARCHAR(20),state VARCHAR(20)); INSERT INTO construction_labor (id,worker_name,hours_worked,project_type,state) VALUES (1,'Jane Doe',60,'Non-Sustainable','New York');
DELETE FROM construction_labor WHERE hours_worked > 50 AND project_type != 'Sustainable' AND state = 'New York';
Find the average amount donated by donors in the 'Educational' program.
CREATE TABLE Donations (donation_id INT PRIMARY KEY,donor_id INT,program TEXT,amount INT);
SELECT AVG(amount) FROM Donations WHERE program = 'Educational';
Find the number of players who achieved a high score in each game and the percentage of players who achieved that high score, ordered by the percentage in descending order.
CREATE TABLE player_scores (player_id INT,game_id INT,score INT); INSERT INTO player_scores (player_id,game_id,score) VALUES (1,1,1000),(2,1,1000),(3,1,500),(4,2,200),(5,2,200),(6,2,150); CREATE TABLE games (id INT,name VARCHAR(255)); INSERT INTO games (id,name) VALUES (1,'Game1'),(2,'Game2');
SELECT g.name, COUNT(DISTINCT player_id) as num_players, COUNT(DISTINCT player_id) * 100.0 / (SELECT COUNT(DISTINCT player_id) FROM player_scores) as percentage FROM player_scores ps JOIN games g ON ps.game_id = g.id GROUP BY ps.game_id HAVING ps.score = (SELECT MAX(score) FROM player_scores ps2 WHERE ps2.game_id = ps.game_id) ORDER BY percentage DESC;
Which crops have health scores over 90 in the South region?
CREATE TABLE crop_health (id INT,crop VARCHAR(255),health_score DECIMAL(3,2),region VARCHAR(255),PRIMARY KEY (id)); INSERT INTO crop_health (id,crop,health_score,region) VALUES (1,'cotton',72.5,'Southwest'),(2,'corn',81.9,'Midwest'),(3,'rice',91.2,'South'),(4,'wheat',64.2,'Northwest');
SELECT * FROM crop_health WHERE health_score > 90.0 AND region = 'South';
Display the names and total donation amounts for nonprofits that offer programs in either the Education or Health categories, excluding any duplicate records.
CREATE TABLE nonprofits (id INT,name TEXT,state TEXT,program TEXT,category TEXT,donation_amount FLOAT); INSERT INTO nonprofits (id,name,state,program,category,donation_amount) VALUES (1,'Nonprofit A','California','Math Education','Education',25000.00),(2,'Nonprofit B','California','Health Services','Health',50000.00),(3,'Nonprofit C','California','Environmental Conservation','Environment',35000.00),(4,'Nonprofit D','Texas','Arts Education','Education',60000.00),(5,'Nonprofit E','New York','Social Services','Other',15000.00),(6,'Nonprofit F','Florida','Disaster Relief','Other',70000.00),(7,'Nonprofit G','California','Science Education','Education',40000.00),(8,'Nonprofit H','California','Mental Health Services','Health',45000.00);
SELECT name, SUM(donation_amount) as total_donation FROM nonprofits WHERE category IN ('Education', 'Health') GROUP BY name;
Which country has the most garment factories?
CREATE TABLE factories(factory_id INT,country VARCHAR(255)); INSERT INTO factories(factory_id,country) VALUES (1,'India'),(2,'Pakistan'),(3,'Bangladesh'),(4,'India'),(5,'China');
SELECT country, COUNT(*) FROM factories GROUP BY country ORDER BY COUNT(*) DESC LIMIT 1;
What is the total number of emergency calls and crimes reported in all districts, excluding the Downtown district?
CREATE TABLE Districts (district_name TEXT,calls INTEGER,crimes INTEGER); INSERT INTO Districts (district_name,calls,crimes) VALUES ('Downtown',450,300),('Uptown',500,250),('Central',300,200),('Westside',250,150),('Park',100,50);
SELECT SUM(calls) + SUM(crimes) FROM Districts WHERE district_name != 'Downtown';
What is the total quantity of ingredients sourced from Asia?
CREATE TABLE ingredient_sources (id INT,product VARCHAR(50),ingredient VARCHAR(50),country VARCHAR(50),quantity INT); INSERT INTO ingredient_sources (id,product,ingredient,country,quantity) VALUES (3,'Cleanser','Extract','Japan',30); INSERT INTO ingredient_sources (id,product,ingredient,country,quantity) VALUES (4,'Moisturizer','Oil','India',20);
SELECT SUM(quantity) as total_quantity FROM ingredient_sources WHERE country IN (SELECT name FROM countries WHERE region = 'Asia');
How many species are there in each marine habitat type?
CREATE TABLE marine_species (name VARCHAR(255),habitat_type VARCHAR(50));
SELECT habitat_type, COUNT(*) FROM marine_species GROUP BY habitat_type;
How many species of birds are there in each Arctic habitat?
CREATE TABLE Birds (species VARCHAR(255),habitat VARCHAR(255)); INSERT INTO Birds (species,habitat) VALUES ('Snowy Owl','Tundra'),('Peregrine Falcon','Mountains'),('Rock Ptarmigan','Tundra'),('Gyrfalcon','Mountains');
SELECT habitat, COUNT(DISTINCT species) as num_species FROM Birds GROUP BY habitat;
How many sustainable investments were made in the Asia-Pacific region in Q1 2021?
CREATE TABLE sustainable_investments (id INT,region VARCHAR(255),investment_date DATE); INSERT INTO sustainable_investments (id,region,investment_date) VALUES (1,'Asia-Pacific','2021-01-15'),(2,'Europe','2021-03-28'),(3,'Asia-Pacific','2021-01-03');
SELECT COUNT(*) FROM sustainable_investments WHERE region = 'Asia-Pacific' AND investment_date BETWEEN '2021-01-01' AND '2021-03-31';
What is the adoption rate of virtual tours among OTAs in Europe?
CREATE TABLE ota_virtual_tour (ota_id INT,ota_name TEXT,region TEXT,virtual_tour TEXT); INSERT INTO ota_virtual_tour (ota_id,ota_name,region,virtual_tour) VALUES (1,'TravelEase','Europe','yes'),(2,'VoyagePlus','Europe','yes'),(3,'DiscoverWorld','Europe','no');
SELECT region, COUNT(ota_id) AS total_otas, SUM(CASE WHEN virtual_tour = 'yes' THEN 1 ELSE 0 END) AS virtual_tour_otas, ROUND((SUM(CASE WHEN virtual_tour = 'yes' THEN 1 ELSE 0 END) / COUNT(ota_id) * 100), 2) AS adoption_rate FROM ota_virtual_tour WHERE region = 'Europe' GROUP BY region
display unique genders in 'visitor_demographics'
CREATE TABLE visitor_demographics (age INT,gender VARCHAR(10)); INSERT INTO visitor_demographics (age,gender) VALUES (25,'Male'),(32,'Female'),(45,'Non-binary'),(25,'Female');
SELECT DISTINCT gender FROM visitor_demographics;
Find the maximum pollution level recorded in the Mediterranean sea.
CREATE TABLE pollution_records (location TEXT,pollution_level FLOAT); INSERT INTO pollution_records (location,pollution_level) VALUES ('Mediterranean Sea',3.5),('North Sea',2.9),('Baltic Sea',4.1);
SELECT MAX(pollution_level) FROM pollution_records WHERE location = 'Mediterranean Sea';
What is the average biomass of fish in Japanese farms that use recirculating aquaculture systems (RAS)?
CREATE TABLE japanese_farms (farmer_id INT,farm_location TEXT,farming_method TEXT,biomass FLOAT); INSERT INTO japanese_farms (farmer_id,farm_location,farming_method,biomass) VALUES (1,'Tokyo','RAS',150.8),(2,'Osaka','Flow-through',200.1),(3,'Kyoto','RAS',125.9);
SELECT AVG(biomass) FROM japanese_farms WHERE farming_method = 'RAS';
Update the location of the 'Jungle Explorers' program in the 'education_programs' table
CREATE TABLE education_programs (id INT PRIMARY KEY,name VARCHAR(50),location VARCHAR(50),attendance INT,target_audience VARCHAR(50));
UPDATE education_programs SET location = 'Brazil' WHERE name = 'Jungle Explorers';
What is the total fare collected for all trips on the NYC subway system in the past week, excluding trips with missing fare data?
CREATE TABLE nyc_subway (trip_id INT,route_id VARCHAR(10),fare FLOAT,trip_date DATE);
SELECT SUM(fare) FROM nyc_subway WHERE fare IS NOT NULL AND trip_date >= DATE_SUB(NOW(), INTERVAL 1 WEEK);
Delete co-living properties that are not located in sustainable cities.
CREATE TABLE SustainableCities(id INT,city VARCHAR(20));INSERT INTO SustainableCities(id,city) VALUES (1,'Portland'),(2,'SanFrancisco'),(3,'Austin');
DELETE FROM CoLivingProperties WHERE city NOT IN (SELECT city FROM SustainableCities);
What is the average population size for cities in the "city_data" table that have a population greater than 500,000?
CREATE TABLE city_data (city_name VARCHAR(50),state VARCHAR(50),country VARCHAR(50),population INT); INSERT INTO city_data (city_name,state,country,population) VALUES ('CityA','StateA','CountryA',600000),('CityB','StateB','CountryA',400000),('CityC','StateC','CountryB',700000),('CityD','StateD','CountryB',800000);
SELECT AVG(population) FROM city_data WHERE population > 500000;
Identify the environmental impact assessment (EIA) reports that have not been reviewed yet, and list the corresponding mine names and report_ids.
CREATE TABLE eia_reports (report_id INT,mine_id INT,report_status TEXT); INSERT INTO eia_reports (report_id,mine_id,report_status) VALUES (1,1,'In Progress'),(2,2,'Completed'),(3,3,'In Progress'); CREATE TABLE mines (mine_id INT,mine_name TEXT); INSERT INTO mines (mine_id,mine_name) VALUES (1,'MineA'),(2,'MineB'),(3,'MineC');
SELECT e.report_id, m.mine_name FROM eia_reports e JOIN mines m ON e.mine_id = m.mine_id WHERE e.report_status = 'In Progress';
What is the total number of tourists visiting sustainable tourism destinations in Africa?
CREATE TABLE tourism (destination VARCHAR(50),is_sustainable BOOLEAN,number_of_tourists INT); INSERT INTO tourism (destination,is_sustainable,number_of_tourists) VALUES ('Masai Mara',true,50000),('Masai Mara',false,40000),('Serengeti',true,60000);
SELECT SUM(number_of_tourists) FROM tourism WHERE is_sustainable = true AND destination IN ('Masai Mara', 'Serengeti', 'Victoria Falls');
What are the top 3 drugs by sales in 2023?
CREATE TABLE sales_data (drug VARCHAR(255),year INT,sales FLOAT); INSERT INTO sales_data (drug,year,sales) VALUES ('DrugA',2023,50000),('DrugB',2023,35000),('DrugC',2023,42000),('DrugD',2023,30000);
SELECT drug, SUM(sales) as total_sales FROM sales_data WHERE year = 2023 GROUP BY drug ORDER BY total_sales DESC LIMIT 3;
What is the total claim amount for policyholders in California with 'Life' policy_type?
CREATE TABLE policyholders (id INT,name VARCHAR(50),age INT,gender VARCHAR(10),policy_type VARCHAR(10),state VARCHAR(20)); INSERT INTO policyholders (id,name,age,gender,policy_type,state) VALUES (8,'James Johnson',55,'Male','Life','California'); INSERT INTO claims (id,policyholder_id,claim_amount,claim_date) VALUES (10,8,5000,'2021-07-09');
SELECT SUM(claim_amount) FROM claims JOIN policyholders ON claims.policyholder_id = policyholders.id WHERE policyholders.state = 'California' AND policyholders.policy_type = 'Life';
Who is the most prolific artist in the database?
CREATE TABLE Artworks (ArtworkID INT,Title VARCHAR(50),Gallery VARCHAR(50),ArtistID INT); INSERT INTO Artworks (ArtworkID,Title,Gallery,ArtistID) VALUES (1,'Starry Night','ImpressionistGallery',1); INSERT INTO Artworks (ArtworkID,Title,Gallery,ArtistID) VALUES (2,'Sunflowers','ImpressionistGallery',1); INSERT INTO Artworks (ArtworkID,Title,Gallery,ArtistID) VALUES (3,'Untitled','ContemporaryArt',2); INSERT INTO Artworks (ArtworkID,Title,Gallery,ArtistID) VALUES (4,'Untitled2','ContemporaryArt',2); INSERT INTO Artworks (ArtworkID,Title,Gallery,ArtistID) VALUES (5,'Untitled3','ContemporaryArt',3);
SELECT ArtistID, COUNT(*) as Count FROM Artworks GROUP BY ArtistID ORDER BY Count DESC LIMIT 1;
Calculate the average construction cost per project in the USA
CREATE TABLE infrastructure_projects (id INT,name TEXT,location TEXT,construction_cost FLOAT); INSERT INTO infrastructure_projects (id,name,location,construction_cost) VALUES (1,'Brooklyn Bridge','USA',15000000); INSERT INTO infrastructure_projects (id,name,location,construction_cost) VALUES (2,'Chunnel','UK',21000000); INSERT INTO infrastructure_projects (id,name,location,construction_cost) VALUES (3,'Tokyo Tower','Japan',33000000);
SELECT AVG(construction_cost) FROM infrastructure_projects WHERE location = 'USA';
What was the minimum landfill capacity in Africa in 2017?'
CREATE TABLE landfill_capacity (country VARCHAR(50),region VARCHAR(50),landfill_capacity FLOAT,year INT); INSERT INTO landfill_capacity (country,region,landfill_capacity,year) VALUES ('Nigeria','Africa',5.2,2017),('South Africa','Africa',7.1,2017),('Egypt','Africa',4.8,2017);
SELECT MIN(landfill_capacity) FROM landfill_capacity WHERE region = 'Africa' AND year = 2017;
What was the count of shipments from the Middle East to North America in September 2022?
CREATE TABLE Shipments (id INT,source VARCHAR(50),destination VARCHAR(50),weight FLOAT,ship_date DATE); INSERT INTO Shipments (id,source,destination,weight,ship_date) VALUES (24,'Saudi Arabia','USA',700,'2022-09-01'); INSERT INTO Shipments (id,source,destination,weight,ship_date) VALUES (25,'UAE','Canada',800,'2022-09-15'); INSERT INTO Shipments (id,source,destination,weight,ship_date) VALUES (26,'Iran','USA',900,'2022-09-30');
SELECT COUNT(*) FROM Shipments WHERE (source = 'Saudi Arabia' OR source = 'UAE' OR source = 'Iran') AND (destination = 'USA' OR destination = 'Canada') AND ship_date BETWEEN '2022-09-01' AND '2022-09-30';