instruction
stringlengths
0
1.06k
input
stringlengths
11
5.3k
response
stringlengths
2
4.44k
What bridges were built using design standards from the Transportation Agency of Asia (TAA)?
CREATE TABLE DesignStandard (id INT,standard VARCHAR(50),description TEXT); INSERT INTO DesignStandard (id,standard,description) VALUES (1,'TAA','Transportation Agency of Asia');
INSERT INTO Infrastructure (id, name, location, type) SELECT 2, 'Bridge 2', 'Country D', 'Steel' FROM DesignStandard WHERE DesignStandard.standard = 'TAA';
What is the total number of tickets sold and the total revenue for teams in the 'Basketball' sport?
CREATE TABLE team_ticket_sales (team_name VARCHAR(50),sport VARCHAR(20),tickets_sold INT,revenue DECIMAL(10,2)); INSERT INTO team_ticket_sales (team_name,sport,tickets_sold,revenue) VALUES ('Team A','Basketball',1000,25000.00),('Team B','Soccer',800,20000.00),('Team C','Basketball',1200,32000.00),('Team D','Hockey',900,21000.00),('Team E','Basketball',700,18000.00);
SELECT SUM(tickets_sold) AS total_tickets_sold, SUM(revenue) AS total_revenue FROM team_ticket_sales WHERE sport = 'Basketball';
List all Shariah-compliant financing transactions over $10,000 for clients in the LGBTQ+ community in Q3 2021.
CREATE TABLE shariah_compliant_finance (id INT,value DECIMAL(10,2),client_id INT,client_community VARCHAR(50),date DATE);
SELECT shariah_compliant_finance.* FROM shariah_compliant_finance WHERE client_community = 'LGBTQ+' AND value > 10000 AND date BETWEEN '2021-07-01' AND '2021-09-30';
What is the total count of dishes that are both vegetarian and gluten-free?
CREATE TABLE Dishes (id INT,dish VARCHAR(255),vegetarian BOOLEAN,gluten_free BOOLEAN); INSERT INTO Dishes (id,dish,vegetarian,gluten_free) VALUES (1,'Quinoa Salad',TRUE,TRUE),(2,'Beef Stew',FALSE,FALSE),(3,'Vegetable Curry',TRUE,TRUE),(4,'Chicken Fried Rice',FALSE,FALSE),(5,'Lentil Soup',TRUE,TRUE);
SELECT COUNT(*) FROM Dishes WHERE vegetarian = TRUE AND gluten_free = TRUE;
What is the average training program duration by employee's job category?
CREATE TABLE job_categories (id INT,name VARCHAR(255)); INSERT INTO job_categories (id,name) VALUES (1,'Manager'),(2,'Engineer'),(3,'Sales'); CREATE TABLE employees (id INT,name VARCHAR(255),job_category_id INT); CREATE TABLE training_programs (id INT,employee_id INT,duration INT); INSERT INTO training_programs (id,employee_id,duration) VALUES (1,1,20),(2,2,30),(3,3,15),(4,1,25);
SELECT job_categories.name, AVG(training_programs.duration) as avg_duration FROM job_categories JOIN employees ON job_categories.id = employees.job_category_id JOIN training_programs ON employees.id = training_programs.employee_id GROUP BY job_categories.name;
Insert a new record of an accessibility audit for a university with a score of 90, conducted on January 1, 2022.
CREATE TABLE accessibility_audits (id INT PRIMARY KEY,university VARCHAR(255),score INT,audit_date DATE);
INSERT INTO accessibility_audits (university, score, audit_date) VALUES ('University of California, Berkeley', 90, '2022-01-01');
Which countries in Africa were certified for sustainable practices in 2019 or earlier?
CREATE TABLE Sustainable_Practices (id INT PRIMARY KEY,country_id INT,certification_date DATE,FOREIGN KEY (country_id) REFERENCES Countries(id)); INSERT INTO Sustainable_Practices (id,country_id,certification_date) VALUES (1,5,'2019-06-01'); INSERT INTO Sustainable_Practices (id,country_id,certification_date) VALUES (2,6,'2018-12-31'); INSERT INTO Sustainable_Practices (id,country_id,certification_date) VALUES (3,13,'2017-03-01');
SELECT c.name FROM Countries c INNER JOIN Sustainable_Practices sp ON c.id = sp.country_id WHERE c.continent = 'Africa' AND sp.certification_date <= '2019-12-31';
What was the total amount of funding given by UNHCR to shelter projects in Syria in 2017?
CREATE TABLE unhcr_funding (funding_agency VARCHAR(255),project_type VARCHAR(255),country VARCHAR(255),amount DECIMAL(10,2),year INT);
SELECT SUM(amount) FROM unhcr_funding WHERE funding_agency = 'UNHCR' AND project_type = 'shelter' AND country = 'Syria' AND year = 2017;
How many mental health facilities exist in each state that offer services in Spanish?
CREATE TABLE mental_health_facilities (facility_id INT,state TEXT,languages TEXT); INSERT INTO mental_health_facilities (facility_id,state,languages) VALUES (1,'California','English,Spanish'),(2,'Texas','Spanish,French'),(3,'New York','English,Mandarin');
SELECT state, COUNT(*) FROM mental_health_facilities WHERE languages LIKE '%Spanish%' GROUP BY state;
What is the ratio of shared to private electric vehicles in New York City?
CREATE TABLE vehicle_ownership (id INT,vehicle_type TEXT,owner_type TEXT);
SELECT (COUNT(*) FILTER (WHERE owner_type = 'shared')) * 100.0 / COUNT(*) AS shared_ratio FROM vehicle_ownership WHERE vehicle_type = 'electric vehicle' AND owner_type IS NOT NULL;
What was the average donation amount by donors from the city of "Seattle"?
CREATE TABLE Donors (DonorID INT,DonorName TEXT,City TEXT,AmountDonated DECIMAL); INSERT INTO Donors (DonorID,DonorName,City,AmountDonated) VALUES (1,'John Doe','Seattle',500.00),(2,'Jane Smith','New York',300.00);
SELECT AVG(AmountDonated) FROM Donors WHERE City = 'Seattle';
What is the average price of upcycled furniture items sold in Canada?
CREATE TABLE furniture_inventory (id INT,item_name VARCHAR(50),price DECIMAL(10,2),country_of_sale VARCHAR(50),sale_date DATE); INSERT INTO furniture_inventory (id,item_name,price,country_of_sale,sale_date) VALUES (1,'Wooden Table',500.00,'Canada','2021-09-25'),(2,'Vintage Chair',250.00,'Canada','2021-11-12'),(3,'Reclaimed Desk',700.00,'USA','2021-12-18');
SELECT AVG(price) FROM furniture_inventory WHERE country_of_sale = 'Canada' AND item_name LIKE '%upcycled%';
How many chemical manufacturing facilities are there in each region (North, South, Central, East, West) in Africa?
CREATE TABLE african_facilities (facility_id INT,facility_name TEXT,region TEXT); INSERT INTO african_facilities (facility_id,facility_name,region) VALUES (1,'Facility X','West'),(2,'Facility Y','North'),(3,'Facility Z','Central'),(4,'Facility W','East'),(5,'Facility V','South');
SELECT region, COUNT(*) as facility_count FROM african_facilities GROUP BY region;
What is the number of articles written by independent journalists in Europe?
CREATE TABLE journalists (journalist_id INT,journalist_type VARCHAR(20),country VARCHAR(50)); CREATE TABLE articles (article_id INT,journalist_id INT,content_type VARCHAR(20)); INSERT INTO journalists VALUES (1,'independent','France'); INSERT INTO articles VALUES (1,1,'opinion');
SELECT COUNT(*) FROM journalists INNER JOIN articles ON journalists.journalist_id = articles.journalist_id WHERE journalists.journalist_type = 'independent' AND country IN ('France', 'Germany', 'Italy');
Show the unique states for each policy type in the underwriting database
CREATE TABLE underwriting (policy_type VARCHAR(10),policy_number INT,state VARCHAR(2)); INSERT INTO underwriting (policy_type,policy_number,state) VALUES ('auto',12345,'NY'),('home',67890,'CA'),('life',111,'NY');
SELECT DISTINCT policy_type, state FROM underwriting;
What is the maximum duration of satellite missions for each country?
CREATE TABLE satellite_missions (id INT,mission_name VARCHAR(255),country VARCHAR(255),duration FLOAT); INSERT INTO satellite_missions (id,mission_name,country,duration) VALUES (1,'Sentinel-1A','Europe',780),(2,'Sentinel-1B','Europe',780),(3,'Landsat 8','USA',1639),(4,'ResourceSat-2','India',1500),(5,'Terra','USA',20185);
SELECT country, MAX(duration) as max_duration FROM satellite_missions GROUP BY country;
What is the name and subscription type of the broadband subscriber with the highest revenue?
CREATE TABLE broadband_subscribers (subscriber_id INT,subscription_type VARCHAR(50),revenue DECIMAL(10,2)); INSERT INTO broadband_subscribers (subscriber_id,subscription_type,revenue) VALUES (1,'Residential',100.00),(2,'Business',150.00);
SELECT name, subscription_type FROM broadband_subscribers WHERE revenue = (SELECT MAX(revenue) FROM broadband_subscribers);
What is the total quantity of dish A served in all branches last month?
CREATE TABLE Branches (branch_id INT,branch_name VARCHAR(255));CREATE TABLE Menu (dish_name VARCHAR(255),branch_id INT);CREATE TABLE Sales (sale_date DATE,dish_name VARCHAR(255),quantity INT);
SELECT SUM(quantity) FROM Sales JOIN Menu ON Sales.dish_name = Menu.dish_name WHERE dish_name = 'Dish A' AND sale_date BETWEEN DATE_SUB(CURRENT_DATE, INTERVAL 2 MONTH) AND DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH);
Delete all contracts in the contracts table associated with the contractor with ID 2
CREATE TABLE contracts (id INT,project_id INT,contractor_id INT);
WITH cte AS (DELETE FROM contracts WHERE contractor_id = 2) SELECT * FROM cte;
What is the number of employees by mine, gender, and role?
CREATE TABLE mine (id INT,name VARCHAR(50),location VARCHAR(50)); CREATE TABLE employee (id INT,mine_id INT,gender VARCHAR(10),role VARCHAR(20),salary INT);
SELECT mine.name, employee.gender, employee.role, COUNT(employee.id) FROM employee JOIN mine ON employee.mine_id = mine.id GROUP BY mine.name, employee.gender, employee.role;
Identify top 3 investment strategies by ROI for Q3 2022 in the technology sector.
CREATE TABLE investment_strategies (strategy_id INT,strategy_name TEXT,investment_date DATE,sector TEXT,amount FLOAT); CREATE TABLE returns (return_id INT,strategy_id INT,return_date DATE,return_amount FLOAT);
SELECT strategy_name, 100.0 * SUM(return_amount) / SUM(amount) AS roi FROM investment_strategies s JOIN returns r ON s.strategy_id = r.strategy_id WHERE investment_date BETWEEN '2022-07-01' AND '2022-09-30' AND sector = 'technology' GROUP BY strategy_id, strategy_name ORDER BY roi DESC LIMIT 3;
Show members who joined in Q1 2022 and have not attended a workout
CREATE TABLE member_data (member_id INT,join_date DATE); CREATE TABLE member_workouts (member_id INT,workout_date DATE);
SELECT mdata.member_id FROM member_data mdata LEFT JOIN member_workouts mworkouts ON mdata.member_id = mworkouts.member_id WHERE mdata.join_date BETWEEN '2022-01-01' AND '2022-03-31' AND mworkouts.member_id IS NULL;
What is the total number of bookings for each hotel in the popular_hotels view?
CREATE VIEW popular_hotels AS SELECT * FROM hotels WHERE region IN ('New York','Los Angeles'); CREATE TABLE bookings (id INT,hotel_id INT,bookings INT);
SELECT h.hotel_name, SUM(b.bookings) FROM popular_hotels h JOIN bookings b ON h.id = b.hotel_id GROUP BY h.hotel_name;
Insert new marine species records for 'Australia' in 2022.
CREATE TABLE Species_6 (id INT,name VARCHAR(255),region VARCHAR(255),year INT); INSERT INTO Species_6 (id,name,region,year) VALUES (1,'Kangaroo','Australia',2021); INSERT INTO Species_6 (id,name,region,year) VALUES (2,'Platypus','Australia',2022); INSERT INTO Species_6 (id,name,region,year) VALUES (3,'Wombat','Australia',2023);
INSERT INTO Species_6 (id, name, region, year) VALUES (4, 'Echidna', 'Australia', 2022);
What is the percentage of total community engagement in cultural preservation in Oceania, grouped by country?
CREATE TABLE CommunityEngagement (EngagementID INT,Country VARCHAR(255),EngagementScore INT,PRIMARY KEY (EngagementID));
SELECT Country, 100.0 * COUNT(*) OVER (PARTITION BY Country) * 1.0 / SUM(COUNT(*)) OVER () AS PercentageOfTotal FROM CommunityEngagement WHERE Country = 'Oceania' GROUP BY Country;
Display the name of the rural infrastructure project and the expenditure, sorted by the expenditure in descending order
CREATE TABLE rural_infrastructure_projects (id INT,name TEXT,expenditure DECIMAL(10,2)); INSERT INTO rural_infrastructure_projects (id,name,expenditure) VALUES (1,'RoadA',5000.00),(2,'SchoolB',6000.00),(3,'HospitalC',7000.00),(4,'BridgeD',8000.00),(5,'ParkE',9000.00);
SELECT name, expenditure FROM rural_infrastructure_projects ORDER BY expenditure DESC;
What is the average altitude of satellites in Low Earth Orbit (LEO)?
CREATE TABLE Satellite (Id INT,Name VARCHAR(100),LaunchDate DATETIME,Country VARCHAR(50),Function VARCHAR(50),OrbitType VARCHAR(50),Altitude INT); INSERT INTO Satellite (Id,Name,LaunchDate,Country,Function,OrbitType,Altitude) VALUES (4,'GRACE-FO','2018-05-22','United States','Scientific Research','LEO',499);
SELECT AVG(Altitude) FROM Satellite WHERE OrbitType = 'LEO';
What is the maximum labor productivity score for mines in Colorado?
CREATE TABLE mines (id INT PRIMARY KEY,name VARCHAR(255),location VARCHAR(255),year_opened INT,total_employees INT); INSERT INTO mines (id,name,location,year_opened,total_employees) VALUES (1,'Golden Ridge Mine','California',1992,250); INSERT INTO mines (id,name,location,year_opened,total_employees) VALUES (2,'Emerald Paradise','Colorado',2005,180); CREATE TABLE labor_productivity (id INT PRIMARY KEY,mine_id INT,productivity_score INT,year INT); INSERT INTO labor_productivity (id,mine_id,productivity_score,year) VALUES (1,1,8,2010); INSERT INTO labor_productivity (id,mine_id,productivity_score,year) VALUES (2,2,9,2015);
SELECT MAX(labor_productivity.productivity_score) as max_productivity FROM labor_productivity JOIN mines ON labor_productivity.mine_id = mines.id WHERE mines.location = 'Colorado';
What is the total number of community health workers in each region and the percentage of female community health workers in each region?
CREATE TABLE Community_Health_Workers (Worker_ID INT,Gender VARCHAR(10),Region VARCHAR(255)); INSERT INTO Community_Health_Workers (Worker_ID,Gender,Region) VALUES (1,'Male','Northeast'),(2,'Female','Northeast'),(3,'Male','South'),(4,'Female','South');
SELECT Region, COUNT(*) AS Total_Workers, COUNT(*) FILTER (WHERE Gender = 'Female') * 100.0 / COUNT(*) AS Percentage_Female_Workers FROM Community_Health_Workers GROUP BY Region;
What is the total fare collected on each route?
CREATE TABLE routes (route_id INT,route_name TEXT);CREATE TABLE fares (fare_id INT,route_id INT,fare DECIMAL); INSERT INTO routes VALUES (123,'Route 123'); INSERT INTO routes VALUES (456,'Route 456'); INSERT INTO fares VALUES (1,123,2.5); INSERT INTO fares VALUES (2,123,2.5); INSERT INTO fares VALUES (3,456,3.0); INSERT INTO fares VALUES (4,456,3.0); INSERT INTO fares VALUES (5,456,3.0);
SELECT routes.route_name, SUM(fares.fare) FROM routes INNER JOIN fares ON routes.route_id = fares.route_id GROUP BY routes.route_name;
What is the maximum number of research grants awarded to a single faculty member?
CREATE TABLE faculty (id INT,name TEXT);CREATE TABLE research_grant (id INT,faculty_id INT,amount INT);
SELECT MAX(rg.count) FROM (SELECT faculty_id, COUNT(*) AS count FROM research_grant rg GROUP BY faculty_id) rg;
What is the minimum water temperature recorded for marine shrimp farms in Thailand?
CREATE TABLE marineshrimp (country VARCHAR(20),temperature DECIMAL(5,2)); INSERT INTO marineshrimp (country,temperature) VALUES ('Thailand',29.2),('Thailand',28.9),('Thailand',29.0),('Thailand',28.8);
SELECT MIN(temperature) FROM marineshrimp WHERE country = 'Thailand';
What is the average ethical AI certifications per capita by country?
CREATE TABLE CountryPopulation (CountryID INT PRIMARY KEY,CountryName VARCHAR(100),Population INT); INSERT INTO CountryPopulation (CountryID,CountryName,Population) VALUES (1,'USA',331002651),(2,'Canada',37410003),(3,'Mexico',128932753);
SELECT CountryName, AVG(CertificationCount/Population) as AvgCertificationsPerCapita FROM (SELECT CountryName, COUNT(CertificationID) as CertificationCount FROM EthicalAICertifications GROUP BY CountryName) AS CertificationsPerCountry JOIN CountryPopulation ON CertificationsPerCountry.CountryName = CountryPopulation.CountryName GROUP BY CountryName;
What is the total number of items delivered to 'country_deliveries' table for 'South America' in the year 2022?
CREATE TABLE country_deliveries (delivery_id INT,item_count INT,delivery_date DATE,country VARCHAR(50)); INSERT INTO country_deliveries (delivery_id,item_count,delivery_date,country) VALUES (1,10,'2022-01-01','Brazil'),(2,20,'2022-01-02','Argentina');
SELECT SUM(item_count) FROM country_deliveries WHERE EXTRACT(YEAR FROM delivery_date) = 2022 AND country = 'South America';
List all underwater volcanoes near the Mariana Trench.
CREATE TABLE underwater_volcanoes (id INT,name TEXT,lat FLOAT,lon FLOAT,depth INT); INSERT INTO underwater_volcanoes (id,name,lat,lon,depth) VALUES (1,'NW Rota-1',14.05,145.75,5367),(2,'Ferdinand De Lesseps',11.87,142.33,4000); CREATE TABLE mariana_trench (id INT,point TEXT,lat FLOAT,lon FLOAT); INSERT INTO mariana_trench (id,point,lat,lon) VALUES (1,'Challenger Deep',11.23,142.19),(2,'Sirena Deep',11.20,142.15);
SELECT uv.name FROM underwater_volcanoes uv INNER JOIN mariana_trench mt ON uv.lat BETWEEN mt.lat - 1 AND mt.lat + 1 AND uv.lon BETWEEN mt.lon - 1 AND mt.lon + 1;
What is the maximum depth in the Atlantic Ocean?
CREATE TABLE ocean_depths (ocean TEXT,depth FLOAT); INSERT INTO ocean_depths (ocean,depth) VALUES ('Atlantic Ocean',8605.0);
SELECT MAX(depth) FROM ocean_depths WHERE ocean = 'Atlantic Ocean';
What is the average assets value for clients in the 'Low-Risk' category?
CREATE TABLE clients (id INT,name TEXT,category TEXT,assets FLOAT); INSERT INTO clients (id,name,category,assets) VALUES (1,'John Doe','Medium-Risk',50000.00),(2,'Jane Smith','Low-Risk',75000.00),(3,'Alice Johnson','High-Risk',100000.00),(4,'Bob Brown','Low-Risk',120000.00);
SELECT AVG(assets) FROM clients WHERE category = 'Low-Risk';
What is the average age of fans who attended home games for the basketball team in New York?
CREATE TABLE fans (fan_id INT,age INT,gender VARCHAR(10),city VARCHAR(20)); INSERT INTO fans VALUES (1,25,'Male','New York'); INSERT INTO fans VALUES (2,35,'Female','Los Angeles'); CREATE TABLE games (game_id INT,team VARCHAR(20),location VARCHAR(20)); INSERT INTO games VALUES (1,'Knicks','New York'); INSERT INTO games VALUES (2,'Lakers','Los Angeles');
SELECT AVG(fans.age) FROM fans INNER JOIN games ON fans.city = games.location WHERE games.team = 'Knicks';
Update the capacity of the warehouse in Miami to 1200
CREATE TABLE warehouse (id INT,city VARCHAR(20),capacity INT); INSERT INTO warehouse (id,city,capacity) VALUES (1,'Chicago',1000),(2,'Houston',1500),(3,'Miami',800);
UPDATE warehouse SET capacity = 1200 WHERE city = 'Miami';
What are the most common mental health conditions in rural areas of the US?
CREATE TABLE mental_health_conditions (id INT PRIMARY KEY,location VARCHAR(50),condition VARCHAR(50),prevalence FLOAT);
SELECT condition FROM mental_health_conditions WHERE location = 'rural areas' GROUP BY condition ORDER BY SUM(prevalence) DESC;
What is the maximum and minimum duration of peacekeeping operations?
CREATE TABLE Peacekeeping_Operations (Operation_ID INT,Country_Name VARCHAR(50),Start_Date DATE,End_Date DATE); INSERT INTO Peacekeeping_Operations (Operation_ID,Country_Name,Start_Date,End_Date) VALUES (1,'Bangladesh','2005-01-01','2007-12-31');
SELECT MIN(DATEDIFF(End_Date, Start_Date)) as Min_Duration, MAX(DATEDIFF(End_Date, Start_Date)) as Max_Duration FROM Peacekeeping_Operations;
What is the number of protected areas in each country?
CREATE TABLE ProtectedAreas (country VARCHAR(255),area INT); INSERT INTO ProtectedAreas (country,area) VALUES ('Canada',1000000),('US',800000),('Brazil',1500000),('Mexico',500000);
SELECT country, COUNT(*) as num_protected_areas FROM ProtectedAreas GROUP BY country;
What is the earliest launch year for military satellites in the Oceanic region?
CREATE TABLE MilitarySatellites (Id INT,Country VARCHAR(50),SatelliteName VARCHAR(50),LaunchYear INT,Function VARCHAR(50));INSERT INTO MilitarySatellites (Id,Country,SatelliteName,LaunchYear,Function) VALUES (1,'Australia','AustraliaSat-1',2017,'Communication');
SELECT MIN(LaunchYear) AS EarliestLaunchYear FROM MilitarySatellites WHERE Country = 'Australia';
Which organizations provided support in 'refugee_support' table, and what sectors did they support?
CREATE TABLE refugee_support (id INT,organization VARCHAR(50),sector VARCHAR(50)); INSERT INTO refugee_support (id,organization,sector) VALUES (1,'UNHCR','Refugee Agency'),(2,'WFP','Food Assistance');
SELECT organization, sector FROM refugee_support;
What is the average program impact score for the 'Women' demographic in the 'Visual Arts' category?
CREATE SCHEMA if not exists arts_culture; CREATE TABLE if not exists arts_culture.programs(program_id INT,program_name VARCHAR(50),demographic VARCHAR(10),category VARCHAR(20),impact_score INT);
SELECT AVG(programs.impact_score) FROM arts_culture.programs WHERE programs.demographic = 'Women' AND programs.category = 'Visual Arts';
Update the "description" to "Discover the ancient Mayan civilization" for all records in the "cultural_heritage" table where the "region" is "Central America"
CREATE TABLE cultural_heritage (id INT,name VARCHAR(50),region VARCHAR(50),description VARCHAR(100));
UPDATE cultural_heritage SET description = 'Discover the ancient Mayan civilization' WHERE region = 'Central America';
What is the total transaction volume for each digital asset in the Cardano network?
CREATE TABLE if not exists cardano_assets (asset_id INT,asset_name VARCHAR(255),total_txn_volume DECIMAL(18,2)); INSERT INTO cardano_assets (asset_id,asset_name,total_txn_volume) VALUES (1,'ADA',150000000),(2,'USDt',120000000),(3,'wADA',90000000),(4,'USDC',80000000),(5,'BSV',70000000),(6,'DOT',60000000),(7,'LINK',50000000),(8,'BCH',40000000),(9,'EOS',30000000),(10,'XLM',20000000);
SELECT asset_name, SUM(total_txn_volume) as total_volume FROM cardano_assets GROUP BY asset_name;
Delete records of volunteers who have not volunteered in the last year?
CREATE TABLE volunteer_hours (volunteer_id INT,hours INT,volunteer_date DATE); INSERT INTO volunteer_hours (volunteer_id,hours,volunteer_date) VALUES (1,5,'2021-10-10'),(2,3,'2022-01-15');
DELETE FROM volunteers WHERE volunteer_id NOT IN (SELECT volunteer_id FROM volunteer_hours WHERE volunteer_date >= (CURRENT_DATE - INTERVAL '1 year'));
Who are the developers that have created digital assets on the Binance Smart Chain?
CREATE TABLE developers (developer_id INT,name VARCHAR(50),country VARCHAR(50)); CREATE TABLE digital_assets (asset_id INT,name VARCHAR(50),developer_id INT,network VARCHAR(50)); INSERT INTO digital_assets (asset_id,name,developer_id,network) VALUES (1,'Asset1',1,'Ethereum'),(2,'BSCDApp',2,'Binance Smart Chain'); INSERT INTO developers (developer_id,name,country) VALUES (1,'Alice','USA'),(2,'Bob','China');
SELECT developers.name FROM developers INNER JOIN digital_assets ON developers.developer_id = digital_assets.developer_id WHERE digital_assets.network = 'Binance Smart Chain';
How many customers have a savings balance greater than $5000?
CREATE TABLE customers (id INT,name TEXT,region TEXT,savings REAL);
SELECT COUNT(*) FROM customers WHERE savings > 5000;
What is the earliest event at each heritage site, grouped by site location?
CREATE TABLE HeritageSites (id INT,name VARCHAR(255),location VARCHAR(255),type VARCHAR(255),year_established INT,UNIQUE(id)); CREATE TABLE Events (id INT,name VARCHAR(255),date DATE,HeritageSite_id INT,PRIMARY KEY(id),FOREIGN KEY(HeritageSite_id) REFERENCES HeritageSites(id)); CREATE VIEW EventsPerSite AS SELECT HeritageSites.location AS heritage_site,MIN(Events.date) as min_date FROM Events INNER JOIN HeritageSites ON Events.HeritageSite_id = HeritageSites.id GROUP BY HeritageSites.location;
SELECT EventsPerSite.heritage_site, MIN(EventsPerSite.min_date) as earliest_event FROM EventsPerSite;
Insert a new record for the single 'Stairway to Heaven' with 500,000 sales in 2022-03-25
CREATE TABLE if not exists sales (sale_id serial PRIMARY KEY,sale_date date,title varchar(255),revenue decimal(10,2));
insert into sales (sale_date, title, revenue) values ('2022-03-25', 'Stairway to Heaven', 500000 * 0.01);
How many defense projects were completed in the North American region in 2019?
CREATE TABLE defense_projects (id INT,year INT,region VARCHAR(20),project_name VARCHAR(30),completed BOOLEAN); INSERT INTO defense_projects (id,year,region,project_name,completed) VALUES (1,2019,'North America','Project A',true); INSERT INTO defense_projects (id,year,region,project_name,completed) VALUES (2,2019,'North America','Project B',false);
SELECT COUNT(*) FROM defense_projects WHERE year = 2019 AND region = 'North America' AND completed = true;
How many parcels were shipped to 'DEL' from each airport?
CREATE TABLE shipments (id INT,source_airport VARCHAR(5),destination_airport VARCHAR(5),shipped_date DATE); INSERT INTO shipments (id,source_airport,destination_airport,shipped_date) VALUES (1,'SYD','DEL','2022-04-02'),(2,'SYD','DEL','2022-04-10'),(3,'PEK','DEL','2022-04-15'),(4,'NRT','DEL','2022-04-20'),(5,'CDG','DEL','2022-04-25');
SELECT source_airport, COUNT(*) FROM shipments WHERE destination_airport = 'DEL' GROUP BY source_airport;
What is the maximum budget for all completed projects in the 'Water Supply' category?
CREATE TABLE projects (id INT,name VARCHAR(255),category VARCHAR(255),budget FLOAT,status VARCHAR(255)); INSERT INTO projects (id,name,category,budget,status) VALUES (6,'Dam Rehabilitation','Water Supply',3000000.00,'Completed');
SELECT MAX(budget) FROM projects WHERE category = 'Water Supply' AND status = 'Completed';
What are the names of all freight forwarders who have handled shipments from the United States to Canada?
CREATE TABLE freight_forwarders (id INT,name VARCHAR(255));CREATE TABLE shipments (id INT,forwarder_id INT,origin_country VARCHAR(255),destination_country VARCHAR(255));INSERT INTO freight_forwarders (id,name) VALUES (1,'ABC Freight'),(2,'XYZ Logistics');INSERT INTO shipments (id,forwarder_id,origin_country,destination_country) VALUES (1,1,'USA','Canada'),(2,2,'USA','Mexico');
SELECT f.name FROM freight_forwarders f INNER JOIN shipments s ON f.id = s.forwarder_id WHERE s.origin_country = 'USA' AND s.destination_country = 'Canada';
Get total budget for projects in 'adaptation_projects' table
CREATE TABLE adaptation_projects (id INT PRIMARY KEY,name VARCHAR(255),location VARCHAR(255),budget FLOAT,start_date DATE,end_date DATE); INSERT INTO adaptation_projects (id,name,location,budget,start_date,end_date) VALUES (1,'Seawall Construction','New York City,USA',2000000,'2022-01-01','2023-12-31'),(2,'Drought Resistant Crops','Cape Town,South Africa',800000,'2022-05-15','2024-04-30');
SELECT SUM(budget) FROM adaptation_projects;
What is the R&D expenditure for each drug in the 'drugs' table, grouped by drug name, including drugs with no expenditure in Africa?
CREATE TABLE drugs (drug_id INT,drug_name TEXT,rd_expenditure INT,region TEXT); INSERT INTO drugs (drug_id,drug_name,rd_expenditure,region) VALUES (1,'DrugA',20000,'Africa'),(2,'DrugB',30000,'Europe');
SELECT d.drug_name, COALESCE(SUM(d.rd_expenditure), 0) AS total_expenditure FROM drugs d WHERE d.region = 'Africa' GROUP BY d.drug_name;
What is the total attendance by program type?
CREATE TABLE Attendance (id INT,program_type VARCHAR(50),attendees INT); INSERT INTO Attendance (id,program_type,attendees) VALUES (1,'Concert',100),(2,'Theater',150),(3,'Workshop',50),(4,'Concert',120);
SELECT program_type, SUM(attendees) as total_attendance FROM Attendance GROUP BY program_type;
Insert a new record into the "MarinePollution" table with values (1, 'Asia', 'Oil Spill')
CREATE TABLE MarinePollution (Id INT,Region VARCHAR(20),Type VARCHAR(10));
INSERT INTO MarinePollution (Id, Region, Type) VALUES (1, 'Asia', 'Oil Spill');
What is the average age of mining engineers and geologists in the workforce?
CREATE TABLE workforce (id INT,name VARCHAR(50),position VARCHAR(50),age INT); INSERT INTO workforce (id,name,position,age) VALUES (1,'John Doe','Mining Engineer',35),(2,'Jane Smith','Geologist',32),(3,'Alice Johnson','Mining Engineer',38);
SELECT AVG(age) AS avg_age FROM workforce WHERE position IN ('Mining Engineer', 'Geologist');
What is the total amount of Shariah-compliant investments made by customers in the year 2020?
CREATE TABLE customers (customer_id INT,investments_amount INT,registration_date DATE);
SELECT SUM(investments_amount) FROM customers WHERE EXTRACT(YEAR FROM registration_date) = 2020 AND investments_amount >= 0;
What is the percentage of restaurants with a food safety score above 90 in each city?
CREATE TABLE restaurants (restaurant_id INT,name VARCHAR(255),city VARCHAR(255),food_safety_score INT); INSERT INTO restaurants (restaurant_id,name,city,food_safety_score) VALUES (1,'Restaurant A','City A',95),(2,'Restaurant B','City A',85),(3,'Restaurant C','City B',98),(4,'Restaurant D','City B',88);
SELECT city, AVG(CASE WHEN food_safety_score > 90 THEN 1 ELSE 0 END) * 100 as passing_percentage FROM restaurants GROUP BY city;
What was the maximum freight cost for a single shipment to China in May 2021?
CREATE TABLE china_shipments (id INT,freight_cost DECIMAL(10,2),shipment_date DATE); INSERT INTO china_shipments (id,freight_cost,shipment_date) VALUES (1,2500.00,'2021-05-01'); INSERT INTO china_shipments (id,freight_cost,shipment_date) VALUES (2,3000.00,'2021-05-10');
SELECT MAX(freight_cost) FROM china_shipments WHERE shipment_date >= '2021-05-01' AND shipment_date < '2021-06-01' AND country = 'China';
What's the average donation amount for donors who made more than one donation?
CREATE TABLE Donors (DonorID INT,DonorName VARCHAR(50)); INSERT INTO Donors (DonorID,DonorName) VALUES (1001,'John Doe'),(1002,'Jane Doe'),(2001,'Mike Johnson'),(3001,'Emma Smith'); CREATE TABLE Donations (DonationID INT,DonorID INT,DonationAmount DECIMAL(10,2)); INSERT INTO Donations (DonationID,DonorID,DonationAmount) VALUES (1,1001,50.00),(2,1001,100.00),(3,1002,200.00),(4,2001,300.00);
SELECT AVG(d.DonationAmount) AS AverageDonationAmount FROM (SELECT DonorID, COUNT(*) AS DonationCount FROM Donations GROUP BY DonorID) dc JOIN Donations d ON dc.DonorID = d.DonorID WHERE dc.DonationCount > 1;
What is the average age of NHL players in the 2021-2022 season?
CREATE TABLE nhl_players (player VARCHAR(50),age INT); INSERT INTO nhl_players (player,age) VALUES ('Alex Ovechkin',37),('Sidney Crosby',34),('Connor McDavid',25);
SELECT AVG(age) AS avg_age FROM nhl_players;
What is the number of students who have ever enrolled in lifelong learning programs in 'Charter' school type?
CREATE TABLE SchoolTypes (id INT,name VARCHAR(20)); INSERT INTO SchoolTypes (id,name) VALUES (1,'Public'),(2,'Private'),(3,'Charter'); CREATE TABLE StudentEnrollment (student_id INT,school_type_id INT); INSERT INTO StudentEnrollment (student_id,school_type_id) VALUES (1,1),(2,1),(3,2),(4,3),(5,3);
SELECT s.name, COUNT(DISTINCT se.student_id) FROM SchoolTypes s JOIN StudentEnrollment se ON s.id = se.school_type_id WHERE s.name = 'Charter' GROUP BY s.name;
What are the average gas fees for Ethereum smart contracts involved in NFTs?
CREATE TABLE ethereum_smart_contracts (id INT,gas_fees DECIMAL(10,2),nft_involvement BOOLEAN); INSERT INTO ethereum_smart_contracts (id,gas_fees,nft_involvement) VALUES (1,50,TRUE);
SELECT AVG(gas_fees) FROM ethereum_smart_contracts WHERE nft_involvement = TRUE;
Delete records in the labor_practices table where the company is 'Green Manufacturing' and compliance_score is less than 7
CREATE TABLE labor_practices (id INT PRIMARY KEY,company VARCHAR(255),compliance_score INT); INSERT INTO labor_practices (id,company,compliance_score) VALUES (1,'Green Manufacturing',8),(2,'Ethical Apparel',9),(3,'Sustainable Fabrics',7),(4,'Green Manufacturing',6);
DELETE FROM labor_practices WHERE company = 'Green Manufacturing' AND compliance_score < 7;
Calculate the total area (in hectares) under cultivation for each crop type in 'Northeast' India.
CREATE TABLE crop_data (crop_type VARCHAR(20),area FLOAT,region VARCHAR(20)); INSERT INTO crop_data (crop_type,area,region) VALUES ('Rice',150.0,'Northeast India');
SELECT crop_type, SUM(area) / 10000 as total_area_ha FROM crop_data WHERE region = 'Northeast India' GROUP BY crop_type
What are the names of community development initiatives that started in 2019?
CREATE TABLE community_dev (id INT,initiative_name VARCHAR(255),start_date DATE); INSERT INTO community_dev (id,initiative_name,start_date) VALUES (1,'Education Program','2020-01-01'),(2,'Health Care Center','2019-07-01');
SELECT initiative_name FROM community_dev WHERE start_date LIKE '2019-%';
What is the maximum number of intelligence operations conducted in a single region last year?
CREATE TABLE IntelligenceOperations (region TEXT,year INTEGER,num_operations INTEGER); INSERT INTO IntelligenceOperations (region,year,num_operations) VALUES ('Asia-Pacific',2021,15),('Europe',2021,10),('Asia-Pacific',2020,12),('Europe',2020,14);
SELECT MAX(num_operations) FROM IntelligenceOperations WHERE year = 2021;
What is the maximum number of visitors in a single day for the 'Impressionist' exhibition?
CREATE TABLE Exhibition_Attendance (exhibition_id INT,visit_date DATE,visitor_count INT); CREATE TABLE Exhibitions (id INT,name VARCHAR(50)); INSERT INTO Exhibitions (id,name) VALUES (1,'Impressionist'); ALTER TABLE Exhibition_Attendance ADD FOREIGN KEY (exhibition_id) REFERENCES Exhibitions(id);
SELECT MAX(visitor_count) FROM Exhibition_Attendance WHERE exhibition_id = 1;
What is the average transaction amount for clients in California?
CREATE TABLE clients (id INT,name TEXT,age INT,state TEXT,transaction_amount DECIMAL(10,2)); INSERT INTO clients (id,name,age,state,transaction_amount) VALUES (1,'Maria Garcia',45,'California',500.00); INSERT INTO clients (id,name,age,state,transaction_amount) VALUES (2,'Roberto Rodriguez',50,'California',350.50);
SELECT AVG(transaction_amount) FROM clients WHERE state = 'California';
What is the maximum number of words in an article title in the 'articles' table?
CREATE TABLE articles (title VARCHAR(255));
SELECT MAX(LENGTH(title) - LENGTH(REPLACE(title, ' ', '')) + 1) AS max_words FROM articles;
How many landfills are there in North America with a capacity greater than 10000 tons as of 2022?'
CREATE TABLE landfills (country VARCHAR(50),capacity INT,year INT); INSERT INTO landfills (country,capacity,year) VALUES ('Mexico',15000,2022),('Canada',13000,2022),('USA',11000,2022);
SELECT COUNT(*) as num_landfills FROM landfills WHERE capacity > 10000 AND year = 2022 AND country IN ('Mexico', 'Canada', 'USA');
How many climate adaptation projects were implemented in Asia between 2015 and 2018?
CREATE TABLE climate_adaptation (project_name VARCHAR(255),location VARCHAR(255),year INT,type VARCHAR(255)); INSERT INTO climate_adaptation (project_name,location,year,type) VALUES ('GreenTech Education','Nepal',2015,'Adaptation'),('Solar for Agriculture','Bangladesh',2016,'Adaptation'),('Climate Resilient Infrastructure','Pakistan',2017,'Adaptation'),('Community Based Adaptation','Sri Lanka',2018,'Adaptation');
SELECT COUNT(*) FROM climate_adaptation WHERE location LIKE 'Asia%' AND year BETWEEN 2015 AND 2018 AND type = 'Adaptation';
What is the average hotel rating in France?
CREATE TABLE Hotels (id INT,country VARCHAR(50),rating INT); INSERT INTO Hotels (id,country,rating) VALUES (1,'France',4),(2,'France',5),(3,'France',3),(4,'France',4),(5,'France',5);
SELECT AVG(h.rating) as avg_rating FROM Hotels h WHERE h.country = 'France';
Calculate the total revenue for restaurants in the "suburban" area with a food safety score above 90.
CREATE TABLE revenue (restaurant_id INT,revenue INT,score INT,area VARCHAR(255));INSERT INTO revenue (restaurant_id,revenue,score,area) VALUES (1,5000,95,'urban'),(2,4000,85,'urban'),(3,8000,90,'suburban'),(4,3000,80,'rural'),(5,6000,92,'urban');
SELECT SUM(revenue.revenue) FROM revenue WHERE revenue.area = 'suburban' AND revenue.score > 90;
How many healthcare workers are there in total in the rural health clinics and hospitals?
CREATE TABLE rural_health_facilities (id INT,name TEXT,facility_type TEXT,num_workers INT); INSERT INTO rural_health_facilities (id,name,facility_type,num_workers) VALUES (1,'Rural Clinic A','clinic',10),(2,'Rural Clinic B','clinic',15),(3,'Rural Hospital A','hospital',60),(4,'Rural Hospital B','hospital',45);
SELECT SUM(num_workers) FROM rural_health_facilities WHERE facility_type IN ('clinic', 'hospital');
What is the percentage of military equipment sales by type, in the European Union?
CREATE TABLE Equipment_Types (equipment_id INT,equipment_type VARCHAR(50),equipment_region VARCHAR(50),sale_value FLOAT);
SELECT equipment_type, equipment_region, SUM(sale_value) as total_sales, 100.0 * SUM(sale_value) / (SELECT SUM(sale_value) FROM Equipment_Types WHERE equipment_region = 'European Union') as sales_percentage FROM Equipment_Types WHERE equipment_region = 'European Union' GROUP BY equipment_type, equipment_region;
What is the total revenue generated by hotels in the 'EMEA' region for the year 2022?
CREATE TABLE hotel_revenue (id INT,hotel_id INT,region TEXT,year INT,revenue FLOAT);
SELECT region, SUM(revenue) FROM hotel_revenue WHERE region = 'EMEA' AND YEAR(calendar) = 2022 GROUP BY region;
What is the total number of hotels in Africa that have adopted virtual tour technology?
CREATE TABLE hotels (hotel_id INT,hotel_name TEXT,country TEXT,virtual_tour BOOLEAN); INSERT INTO hotels (hotel_id,hotel_name,country,virtual_tour) VALUES (1,'The Nile River','Egypt',true),(2,'The Sahara Desert','Tunisia',false),(3,'The African Safari','South Africa',true);
SELECT COUNT(*) FROM hotels WHERE virtual_tour = true AND country = 'Africa';
What is the total number of electric vehicles sold in cities with a population greater than 5 million?
CREATE TABLE Cities (id INT,name VARCHAR(255),population INT); INSERT INTO Cities (id,name,population) VALUES (1,'San Francisco',884000); INSERT INTO Cities (id,name,population) VALUES (2,'New York',8500000); CREATE TABLE EV_Sales (id INT,city_id INT,year INT,sales INT); INSERT INTO EV_Sales (id,city_id,year,sales) VALUES (1,1,2020,15000); INSERT INTO EV_Sales (id,city_id,year,sales) VALUES (2,2,2020,50000); INSERT INTO EV_Sales (id,city_id,year,sales) VALUES (3,1,2021,20000); INSERT INTO EV_Sales (id,city_id,year,sales) VALUES (4,2,2021,70000);
SELECT SUM(EV_Sales.sales) FROM EV_Sales JOIN Cities ON EV_Sales.city_id = Cities.id WHERE Cities.population > 5000000;
What is the average mental health score of students in each district with more than 500 students?
CREATE TABLE districts (id INT,district_name TEXT,num_students INT,avg_mental_health_score FLOAT); INSERT INTO districts (id,district_name,num_students,avg_mental_health_score) VALUES (1,'Downtown',600,75.3),(2,'Uptown',400,78.1),(3,'Midtown',700,72.5);
SELECT district_name, AVG(avg_mental_health_score) as avg_score FROM districts GROUP BY district_name HAVING num_students > 500;
What is the total budget for programs in the 'Environment' category?
CREATE TABLE Program (id INT,name VARCHAR(50),budget DECIMAL(10,2)); INSERT INTO Program (id,name,budget) VALUES (1,'Arts',125000.00),(2,'Education',550000.00),(3,'Environment',375000.00);
SELECT SUM(budget) FROM Program WHERE name = 'Environment';
Identify the top 3 rural areas with the highest number of diabetes cases.
CREATE TABLE diabetes_cases (id INT,area VARCHAR(10),cases INT); INSERT INTO diabetes_cases (id,area,cases) VALUES (1,'Area 1',50),(2,'Area 2',30),(3,'Area 3',70),(4,'Area 4',40),(5,'Area 5',60);
SELECT area, cases FROM diabetes_cases WHERE area = 'Rural' ORDER BY cases DESC LIMIT 3;
Which country has the highest solar energy capacity?
CREATE TABLE energy_sources (country VARCHAR(255),source_type VARCHAR(255),capacity INT); INSERT INTO energy_sources (country,source_type,capacity) VALUES ('Germany','Solar',53000),('Spain','Solar',9500),('USA','Solar',97000);
SELECT country, MAX(capacity) FROM energy_sources WHERE source_type = 'Solar' GROUP BY country;
What is the total revenue from concert ticket sales for artists from a specific genre?
CREATE TABLE Concerts (ConcertID INT,ConcertName VARCHAR(100),ArtistID INT,Genre VARCHAR(50),Year INT,Revenue INT); INSERT INTO Concerts VALUES (1,'Concert1',1,'Rock',2020,10000); INSERT INTO Concerts VALUES (2,'Concert2',2,'Pop',2021,15000); INSERT INTO Concerts VALUES (3,'Concert3',3,'Jazz',2019,12000);
SELECT Genre, SUM(Revenue) FROM Concerts WHERE Genre = 'Rock' GROUP BY Genre;
Which maritime law violations occurred in the last 6 months, ordered by date?
CREATE TABLE violations (id INT,law_code TEXT,description TEXT,violation_date DATE); INSERT INTO violations (id,law_code,description,violation_date) VALUES (1,'LAW123','Speeding','2021-07-01'),(2,'LAW456','Illegal fishing','2021-08-15');
SELECT * FROM violations WHERE violation_date >= DATE(NOW()) - INTERVAL 6 MONTH ORDER BY violation_date;
Find the maximum quantity of 'Quinoa' in the 'Warehouse' table
CREATE TABLE Warehouse (id INT PRIMARY KEY,product VARCHAR(255),quantity INT); INSERT INTO Warehouse (id,product,quantity) VALUES (1,'Quinoa',100),(2,'Rice',75),(3,'Quinoa',125);
SELECT MAX(quantity) FROM Warehouse WHERE product = 'Quinoa';
What is the average funding received by biotech startups in India and USA?
CREATE SCHEMA if not exists biotech;USE biotech;CREATE TABLE if not exists startups (name VARCHAR(255),country VARCHAR(255),funding FLOAT);INSERT INTO startups (name,country,funding) VALUES ('Startup1','India',5000000),('Startup2','USA',8000000),('Startup3','India',3000000),('Startup4','USA',6000000);
SELECT AVG(funding) FROM startups WHERE country IN ('India', 'USA');
Calculate the total quantity of items in inventory for each warehouse, sorted by warehouse name.
CREATE TABLE Inventory (id INT,item VARCHAR(255),quantity INT,warehouse VARCHAR(255)); INSERT INTO Inventory (id,item,quantity,warehouse) VALUES (1,'apples',100,'Seattle'),(2,'bananas',200,'Miami');
SELECT warehouse, SUM(quantity) as total_quantity FROM Inventory GROUP BY warehouse ORDER BY warehouse;
What is the number of units manufactured for each garment type by month in 2021?
CREATE TABLE garment_manufacturing (garment_id INT,garment_type VARCHAR(50),production_date DATE,units_manufactured INT); CREATE TABLE garments (garment_id INT,garment_name VARCHAR(50));
SELECT garment_type, EXTRACT(MONTH FROM production_date) AS month, SUM(units_manufactured) FROM garment_manufacturing JOIN garments ON garment_manufacturing.garment_id = garments.garment_id WHERE EXTRACT(YEAR FROM production_date) = 2021 GROUP BY garment_type, month;
Update the average depth of the 'Arctic Ocean' in the 'oceanography' table
CREATE TABLE oceanography (id INT PRIMARY KEY,name VARCHAR(255),average_depth FLOAT,area FLOAT,volume FLOAT);
WITH updated_arctic AS (UPDATE oceanography SET average_depth = 1205 WHERE name = 'Arctic Ocean') SELECT * FROM updated_arctic;
What is the percentage of donors who have donated to each cause category?
CREATE TABLE donor_causes (donor_id INT,cause_category VARCHAR(255)); INSERT INTO donor_causes (donor_id,cause_category) VALUES (1,'Education'),(2,'Health'),(3,'Environment'),(1,'Health'),(4,'Education');
SELECT cause_category, COUNT(donor_id) * 100.0 / (SELECT COUNT(DISTINCT donor_id) FROM donor_causes) AS donor_percentage FROM donor_causes GROUP BY cause_category;
What is the total quantity of gold produced by the company in 2021?
CREATE TABLE Production (ProductionID INT PRIMARY KEY,EquipmentID INT,ResourceType VARCHAR(50),Quantity INT,ProductionDate DATE); INSERT INTO Production (ProductionID,EquipmentID,ResourceType,Quantity,ProductionDate) VALUES (1,1,'Gold',500,'2021-01-01'),(2,2,'Gold',750,'2021-05-10'),(3,3,'Iron',1200,'2021-12-31');
SELECT SUM(Quantity) FROM Production WHERE ResourceType = 'Gold' AND YEAR(ProductionDate) = 2021;
What is the total number of concerts for the Hip Hop genre in Asia in the last 2 years?
CREATE TABLE concerts (concert_id INT,artist_id INT,genre VARCHAR(50),country VARCHAR(50),timestamp TIMESTAMP); INSERT INTO concerts (concert_id,artist_id,genre,country,timestamp) VALUES (1,2001,'Hip Hop','Japan','2022-01-01 00:00:00'),(2,2002,'Hip Hop','China','2022-01-02 12:30:00'); CREATE TABLE artists (artist_id INT,name VARCHAR(100)); INSERT INTO artists (artist_id,name) VALUES (2001,'Kendrick Lamar'),(2002,'Drake');
SELECT COUNT(*) FROM concerts JOIN artists ON concerts.artist_id = artists.artist_id WHERE artists.genre = 'Hip Hop' AND concerts.country IN ('Japan', 'China', 'India', 'South Korea', 'Indonesia') AND concerts.timestamp >= '2020-01-01' AND concerts.timestamp < '2022-01-01';
List AI models with explainability scores above 85.
CREATE TABLE AIModels (model_id INT,model_name VARCHAR(50),explainability_score DECIMAL(3,2)); INSERT INTO AIModels (model_id,model_name,explainability_score) VALUES (1,'ModelA',82.00),(2,'ModelB',88.50),(3,'ModelC',76.75),(4,'ModelD',91.00),(5,'ModelE',87.00);
SELECT model_name FROM AIModels WHERE explainability_score > 85;
What is the average sea surface temperature in the Arctic Ocean by month?
CREATE TABLE SeaSurfaceTemperature (location varchar(50),date DATE,temperature float);
SELECT MONTH(date) AS month, AVG(temperature) AS avg_temperature FROM SeaSurfaceTemperature WHERE location = 'Arctic Ocean' GROUP BY month;