instruction
stringlengths
0
1.06k
input
stringlengths
11
5.3k
response
stringlengths
2
4.44k
List all desserts with a profit margin over 50%
CREATE TABLE menu_items(item_id INT,name TEXT,type TEXT,price DECIMAL,cost_price DECIMAL);
SELECT name FROM menu_items WHERE (price - cost_price) / price > 0.5 AND type = 'Dessert';
How many size 14 garments are in the 'inventory' table?
CREATE TABLE inventory (id INT,size INT,quantity INT); INSERT INTO inventory (id,size,quantity) VALUES (1,10,25),(2,12,30),(3,14,40);
SELECT SUM(quantity) FROM inventory WHERE size = 14;
What is the total quantity of stone artifacts at Site D?
CREATE TABLE artifact_catalog (artifact_id INT,site_id INT,artifact_type TEXT,artifact_description TEXT,quantity INT); INSERT INTO artifact_catalog (artifact_id,site_id,artifact_type,artifact_description,quantity) VALUES (1,1,'ceramic','small bowl',25),(2,1,'metal','copper pin',10),(3,1,'bone','animal figurine',15),(4,2,'ceramic','large jar',35),(5,2,'metal','bronze spearhead',20),(6,2,'bone','bird whistle',12),(7,3,'ceramic','intact vase',50),(8,3,'metal','iron sword',30),(9,3,'bone','human carving',40),(10,4,'stone','flint knife',10),(11,4,'stone','granite statue',30);
SELECT SUM(quantity) FROM artifact_catalog WHERE site_id = 4 AND artifact_type = 'stone';
What is the total amount of seafood imported from Canada in the seafood_imports table?
CREATE TABLE seafood_imports (import_id INT,import_date DATE,product VARCHAR(255),quantity INT,country VARCHAR(255));
SELECT SUM(quantity) FROM seafood_imports WHERE product LIKE '%seafood%' AND country = 'Canada';
List all rovers that landed on Mars.
CREATE TABLE mars_rovers (id INT,rover VARCHAR(50),landed_on_mars BOOLEAN);INSERT INTO mars_rovers (id,rover,landed_on_mars) VALUES (1,'Spirit',true);
SELECT rover FROM mars_rovers WHERE landed_on_mars = true;
Update the statuses of all space missions launched before 2010 to 'inactive'.
CREATE TABLE SpaceMissions (ID INT,Name VARCHAR(50),LaunchDate DATE,Status VARCHAR(20)); INSERT INTO SpaceMissions VALUES (1,'Mission A','2008-03-12',NULL),(2,'Mission B','2012-06-18','active'),(3,'Mission C','2005-02-03',NULL),(4,'Mission D','2017-11-14',NULL);
UPDATE SpaceMissions SET Status = 'inactive' WHERE LaunchDate < '2010-01-01';
What was the sum of ad revenue for users who joined in Q1?
CREATE TABLE users (id INT,registration_date DATE,ad_revenue DECIMAL(10,2)); INSERT INTO users (id,registration_date,ad_revenue) VALUES (1,'2022-01-01',500.00),(2,'2022-02-01',450.00),(3,'2022-01-15',600.00),(4,'2022-03-01',300.00);
SELECT SUM(ad_revenue) FROM users WHERE QUARTER(registration_date) = 1;
What is the total amount of funding received by the Red Cross for disaster relief in Nepal since 2015?
CREATE TABLE disaster_relief_funding (organization TEXT,funding_amount INTEGER,funding_date DATE); INSERT INTO disaster_relief_funding (organization,funding_amount,funding_date) VALUES ('Red Cross',500000,'2015-04-25'),('World Vision',300000,'2015-04-25'),('CARE',400000,'2017-08-24');
SELECT SUM(funding_amount) FROM disaster_relief_funding WHERE organization = 'Red Cross' AND funding_date >= '2015-01-01';
What is the average length of all roads in New York?
CREATE TABLE NY_Roads (id INT,length FLOAT); INSERT INTO NY_Roads (id,length) VALUES (1,100.0),(2,200.0);
SELECT AVG(length) FROM NY_Roads;
How many employees have completed training on diversity and inclusion, by manager?
CREATE TABLE EmployeeTraining (EmployeeID INT,Manager VARCHAR(50),Training VARCHAR(50),CompletionDate DATE);
SELECT Manager, COUNT(*) as Num_Employees FROM EmployeeTraining WHERE Training = 'Diversity and Inclusion' GROUP BY Manager;
Delete all records from the "travel_advisory" table where the "advisory" is older than 3 months
CREATE TABLE travel_advisory (id INT PRIMARY KEY,country TEXT,advisory TEXT,updated_date DATE);
DELETE FROM travel_advisory WHERE updated_date < DATE_SUB(CURRENT_DATE, INTERVAL 3 MONTH);
What is the average revenue per concert by country?
CREATE TABLE concerts (id INT,artist_id INT,city VARCHAR(50),country VARCHAR(50),revenue FLOAT); INSERT INTO concerts (id,artist_id,city,country,revenue) VALUES (1,1,'Los Angeles','USA',500000),(2,1,'New York','USA',700000),(3,2,'Seoul','South Korea',800000),(4,2,'Tokyo','Japan',900000),(5,3,'Paris','France',1000000),(6,4,'Osaka','Japan',850000),(7,1,'London','UK',600000);
SELECT country, AVG(revenue) as avg_revenue FROM concerts GROUP BY country;
Delete the union with the least number of members.
CREATE TABLE unions (id INT,name TEXT,member_count INT); CREATE TABLE members (id INT,union_id INT);
DELETE FROM unions WHERE id IN (SELECT id FROM (SELECT id, ROW_NUMBER() OVER (ORDER BY member_count ASC) AS rn FROM unions) AS seq_table WHERE rn = 1);
What is the average cargo weight transported by oil tankers in the last month?
CREATE TABLE vessel (id INT,type VARCHAR(50),name VARCHAR(50));CREATE TABLE cargo (id INT,vessel_id INT,weight INT,cargo_date DATE);
SELECT AVG(c.weight) as avg_weight FROM vessel v INNER JOIN cargo c ON v.id = c.vessel_id WHERE v.type = 'oil tanker' AND c.cargo_date >= DATE(NOW(), INTERVAL -1 MONTH);
List defense projects and their respective start and end dates, along with the contract negotiation status, that are in the Middle East region and have a geopolitical risk score above 5, ordered by the geopolitical risk score in descending order.
CREATE TABLE ProjectTimelines (project_id INT,project_name VARCHAR(50),start_date DATE,end_date DATE,negotiation_status VARCHAR(50),geopolitical_risk_score INT,project_region VARCHAR(50)); INSERT INTO ProjectTimelines (project_id,project_name,start_date,end_date,negotiation_status,geopolitical_risk_score,project_region) VALUES (5,'Project G','2022-03-01','2024-12-31','Negotiating',6,'Middle East'),(6,'Project H','2021-06-15','2023-05-01','Completed',5,'Middle East'),(7,'Project I','2022-07-22','2027-06-30','Planning',7,'Europe');
SELECT project_name, start_date, end_date, negotiation_status, geopolitical_risk_score FROM ProjectTimelines WHERE project_region = 'Middle East' AND geopolitical_risk_score > 5 ORDER BY geopolitical_risk_score DESC;
Update carbon footprint to 1 for product_id 3 in 'sustainability_metrics' table
CREATE TABLE sustainability_metrics (product_id INT PRIMARY KEY,carbon_footprint DECIMAL(10,2),water_usage DECIMAL(10,2),waste_generation DECIMAL(10,2));
UPDATE sustainability_metrics SET carbon_footprint = 1 WHERE product_id = 3;
How many events were organized in the last month?
CREATE TABLE events (id INT,event_date DATE); INSERT INTO events (id,event_date) VALUES (1,'2022-01-01'),(2,'2022-02-01'),(3,'2022-03-01');
SELECT COUNT(*) FROM events WHERE event_date >= '2022-02-01' AND event_date < '2022-03-01';
Show the union_name and safety record for unions with names starting with 'D' from the 'labor_unions' and 'safety_records' tables
CREATE TABLE labor_unions (id INT,union_name VARCHAR(50),members INT); CREATE TABLE safety_records (id INT,union_id INT,safety_score INT);
SELECT l.union_name, s.safety_score FROM labor_unions l JOIN safety_records s ON l.id = s.union_id WHERE l.union_name LIKE 'D%';
Update the price of all size 8 dresses to 79.99.
CREATE TABLE dresses (id INT PRIMARY KEY,size INT,price DECIMAL(5,2),sale_date DATE); INSERT INTO dresses (id,size,price,sale_date) VALUES (1,8,69.99,'2021-12-01'),(2,10,79.99,'2021-12-05'),(3,12,89.99,'2021-12-10');
UPDATE dresses SET price = 79.99 WHERE size = 8;
Which vessels had an incident in Q1 2022?
CREATE TABLE vessels(id INT,name TEXT); CREATE TABLE incidents(id INT,vessel_id INT,incident_date DATE); INSERT INTO vessels VALUES (1,'VesselA'),(2,'VesselB'),(3,'VesselC'),(4,'VesselD'),(5,'VesselE'); INSERT INTO incidents VALUES (1,2,'2022-02-15'),(2,3,'2022-04-01'),(3,5,'2022-01-20');
SELECT DISTINCT v.name FROM vessels v JOIN incidents i ON v.id = i.vessel_id WHERE incident_date BETWEEN '2022-01-01' AND '2022-03-31';
What is the total number of unique users who liked posts containing the hashtag #movies, by users from Russia, in the last week?
CREATE TABLE users (id INT,country VARCHAR(255)); CREATE TABLE posts (id INT,user_id INT,likes INT,hashtags TEXT,post_date DATE); CREATE TABLE likes (id INT,user_id INT,post_id INT,like_date DATE);
SELECT COUNT(DISTINCT user_id) FROM likes INNER JOIN posts ON likes.post_id = posts.id INNER JOIN users ON posts.user_id = users.id WHERE users.country = 'Russia' AND hashtags LIKE '%#movies%' AND post_date >= DATE(NOW()) - INTERVAL 1 WEEK;
What is the average billing amount for cases handled by attorneys with more than 5 years of experience?
CREATE TABLE Attorneys (AttorneyID INT,ExperienceYears INT,BillingAmount DECIMAL); INSERT INTO Attorneys (AttorneyID,ExperienceYears,BillingAmount) VALUES (1,6,2500.00),(2,3,1800.00),(3,8,3200.00);
SELECT AVG(BillingAmount) FROM Attorneys WHERE ExperienceYears > 5;
Get the number of pallets stored in 'Warehouse A' that were received between '2021-05-01' and '2021-05-15' and have not been shipped yet.
CREATE TABLE pallets (pallet_id INT,warehouse_id INT,received_date DATE,shipped_date DATE,num_pallets INT); INSERT INTO pallets (pallet_id,warehouse_id,received_date,shipped_date,num_pallets) VALUES (1,1,'2021-04-25','2021-04-28',10),(2,1,'2021-05-03',NULL,15),(3,2,'2021-05-05','2021-05-07',20);
SELECT COUNT(*) FROM pallets WHERE warehouse_id = 1 AND received_date BETWEEN '2021-05-01' AND '2021-05-15' AND shipped_date IS NULL;
What is the total amount of Shariah-compliant financing provided to small businesses in the last quarter?
CREATE TABLE shariah_financing (financing_id INT,financing_date DATE,financing_amount INT,business_size TEXT); CREATE TABLE shariah_small_businesses (business_id INT,financing_id INT);
SELECT SUM(sf.financing_amount) FROM shariah_financing sf JOIN shariah_small_businesses ssb ON sf.financing_id = ssb.financing_id WHERE sf.financing_date >= DATEADD(quarter, -1, CURRENT_DATE());
What is the average funding amount per company, per country, for companies founded by women?
CREATE TABLE companies (id INT,name TEXT,country TEXT,founding_year INT,total_funding FLOAT,women_founded INT); INSERT INTO companies (id,name,country,founding_year,total_funding,women_founded) VALUES (1,'Acme Corp','USA',2010,20000000.0,1);
SELECT country, AVG(total_funding) FROM companies WHERE women_founded = 1 GROUP BY country;
What are the top 5 tree species with the lowest carbon sequestration rate in the state_forests schema?
CREATE TABLE state_forests.carbon_sequestration (species VARCHAR(255),sequestration_rate DECIMAL(5,2));
SELECT species FROM state_forests.carbon_sequestration ORDER BY sequestration_rate ASC LIMIT 5;
What is the total budget allocated for education in the year 2020 across all regions?
CREATE TABLE Budget (Year INT,Region VARCHAR(50),Category VARCHAR(50),Amount INT); INSERT INTO Budget (Year,Region,Category,Amount) VALUES (2020,'North','Education',5000000),(2020,'South','Education',6000000),(2020,'East','Education',7000000),(2020,'West','Education',8000000);
SELECT SUM(Amount) FROM Budget WHERE Year = 2020 AND Category = 'Education';
What is the number of marine species, grouped by conservation status?
CREATE TABLE marine_species (id INT,species VARCHAR(255),conservation_status VARCHAR(255)); INSERT INTO marine_species (id,species,conservation_status) VALUES (1,'Blue Whale','Endangered'); INSERT INTO marine_species (id,species,conservation_status) VALUES (2,'Green Sea Turtle','Vulnerable'); INSERT INTO marine_species (id,species,conservation_status) VALUES (3,'Clownfish','Least Concern');
SELECT conservation_status, COUNT(*) FROM marine_species GROUP BY conservation_status;
What is the percentage of new hires who are from underrepresented communities in each department in the past year?
CREATE TABLE Employees (EmployeeID INT,HireDate DATE,Community VARCHAR(25),Department VARCHAR(25)); INSERT INTO Employees (EmployeeID,HireDate,Community,Department) VALUES (1,'2021-12-01','Underrepresented','Marketing'),(2,'2022-02-15','Represented','Marketing'),(3,'2022-02-15','Underrepresented','IT');
SELECT Department, COUNT(*) * 100.0 / (SELECT COUNT(*) FROM Employees WHERE HireDate >= DATEADD(year, -1, GETDATE())) AS Percentage FROM Employees WHERE Community = 'Underrepresented' AND HireDate >= DATEADD(year, -1, GETDATE()) GROUP BY Department;
What's the average age of patients who received CBT?
CREATE TABLE patients (id INT,name TEXT,age INT,treatment TEXT); INSERT INTO patients (id,name,age,treatment) VALUES (1,'Alice',30,'CBT'),(2,'Bob',45,'DBT'),(3,'Charlie',60,'CBT');
SELECT AVG(age) FROM patients WHERE treatment = 'CBT';
Update the country of the employee with id 2 from 'Canada' to 'Mexico'.
CREATE TABLE employees (id INT,name VARCHAR(255),country VARCHAR(255)); INSERT INTO employees (id,name,country) VALUES (1,'John Doe','USA'); INSERT INTO employees (id,name,country) VALUES (2,'Jane Smith','Canada');
UPDATE employees SET country = 'Mexico' WHERE id = 2;
What is the total budget for economic diversification efforts in 2019 and 2020?
CREATE TABLE economic_diversification (id INT,year INT,effort VARCHAR(50),budget FLOAT); INSERT INTO economic_diversification (id,year,effort,budget) VALUES (1,2018,'Tourism',200000.00),(2,2019,'Renewable Energy',800000.00),(3,2020,'Handicrafts',500000.00);
SELECT SUM(budget) FROM economic_diversification WHERE year IN (2019, 2020);
Create a table named 'workforce_development'
CREATE TABLE workforce_development (id INT PRIMARY KEY,name VARCHAR(50),position VARCHAR(50),training_hours INT);
CREATE TABLE workforce_development (id INT PRIMARY KEY, name VARCHAR(50), position VARCHAR(50), training_hours INT);
What is the average accuracy and training time for models in the 'Computer Vision' domain using the 'transfer_learning' technique?
CREATE TABLE cv_models (id INT,model VARCHAR(255),algorithm VARCHAR(255),technique VARCHAR(255),accuracy FLOAT,time FLOAT); INSERT INTO cv_models (id,model,algorithm,technique,accuracy,time) VALUES (1,'LeNet','convnet','transfer_learning',0.98,2.1),(2,'ResNet','convnet','transfer_learning',0.96,3.5),(3,'VGG16','convnet','scratch',0.94,4.7);
SELECT technique, AVG(accuracy) as avg_accuracy, AVG(time) as avg_time FROM cv_models WHERE domain = 'Computer Vision' AND technique = 'transfer_learning' GROUP BY technique;
Insert a new record into the market_trends table for 2022: price_per_kg = 70.00, total_kg = 22000
CREATE TABLE market_trends (id INT PRIMARY KEY,year INT,price_per_kg DECIMAL(10,2),total_kg INT);
INSERT INTO market_trends (id, year, price_per_kg, total_kg) VALUES (5, 2022, 70.00, 22000);
Delete all graduate students who have not published any papers.
CREATE TABLE graduate_students (student_id INT,name VARCHAR(50)); CREATE TABLE publications (publication_id INT,title VARCHAR(50),student_id INT); INSERT INTO graduate_students VALUES (1,'Alice Johnson'); INSERT INTO graduate_students VALUES (2,'Bob Smith'); INSERT INTO publications VALUES (1,'Paper 1',1); INSERT INTO publications VALUES (2,'Paper 2',2);
DELETE FROM graduate_students WHERE student_id NOT IN (SELECT student_id FROM publications);
Which decentralized exchanges were launched in the last month?
CREATE TABLE decentralized_exchanges (exchange_id INT PRIMARY KEY,exchange_name VARCHAR(100),exchange_address VARCHAR(100),swap_volume DECIMAL(20,2),swap_time TIMESTAMP); CREATE VIEW exchange_launch_dates AS SELECT exchange_address,MIN(swap_time) AS first_swap_time FROM decentralized_exchanges GROUP BY exchange_address;
SELECT dex.* FROM decentralized_exchanges dex JOIN exchange_launch_dates eld ON dex.exchange_address = eld.exchange_address WHERE dex.swap_time >= eld.first_swap_time + INTERVAL '1 month';
What is the minimum cost for accommodations in the South American region?
CREATE TABLE accommodations_3 (id INT,name TEXT,region TEXT,cost FLOAT); INSERT INTO accommodations_3 (id,name,region,cost) VALUES (1,'Wheelchair Ramp','South America',120000.00),(2,'Sign Language Interpreter','South America',60000.00);
SELECT MIN(cost) FROM accommodations_3 WHERE region = 'South America';
What is the market share of electric vehicles in Germany and France?
CREATE TABLE vehicle_sales (id INT,country VARCHAR(50),vehicle_type VARCHAR(50),sales INT);
SELECT country, 100.0 * SUM(CASE WHEN vehicle_type = 'electric' THEN sales ELSE 0 END) / SUM(sales) AS market_share FROM vehicle_sales WHERE country IN ('Germany', 'France') GROUP BY country;
Which countries have the highest military budgets in the Asia-Pacific region, excluding China?
CREATE TABLE military_budget (country VARCHAR(50),budget INT); INSERT INTO military_budget (country,budget) VALUES ('United States',7050000000),('China',22800000000),('Japan',4936000000),('India',5574000000),('South Korea',4370000000);
SELECT country, budget FROM military_budget WHERE country != 'China' AND country IN ('United States', 'Japan', 'India', 'South Korea') ORDER BY budget DESC;
What is the average age of female patients diagnosed with Tuberculosis in California?
CREATE TABLE Patients (ID INT,Gender VARCHAR(10),Age INT,Disease VARCHAR(20),State VARCHAR(20)); INSERT INTO Patients (ID,Gender,Age,Disease,State) VALUES (1,'Female',34,'Tuberculosis','California');
SELECT AVG(Age) FROM Patients WHERE Gender = 'Female' AND Disease = 'Tuberculosis' AND State = 'California';
What are the names of all agricultural innovation projects in the 'rural_innovations' table that were funded by organizations located in Africa?
CREATE TABLE rural_innovations (id INT,project_name VARCHAR(50),funding_org VARCHAR(50),org_location VARCHAR(50)); INSERT INTO rural_innovations (id,project_name,funding_org,org_location) VALUES (1,'Precision Agriculture','InnovateAfrica','Kenya');
SELECT project_name FROM rural_innovations WHERE org_location LIKE '%Africa%';
What was the total number of volunteers and total volunteer hours for each program in 2021?
CREATE TABLE volunteers (volunteer_id INT,volunteer_program TEXT,volunteer_hours INT,volunteer_date DATE); INSERT INTO volunteers (volunteer_id,volunteer_program,volunteer_hours,volunteer_date) VALUES (1,'Education',20,'2021-01-01'),(2,'Food Bank',30,'2021-02-01'),(3,'Education',10,'2021-03-01'),(4,'Healthcare',40,'2021-04-01');
SELECT volunteer_program, COUNT(DISTINCT volunteer_id) AS total_volunteers, SUM(volunteer_hours) AS total_hours FROM volunteers WHERE YEAR(volunteer_date) = 2021 GROUP BY volunteer_program;
Which drugs were approved by the FDA in 2018?
CREATE TABLE fda_approval (drug varchar(255),year int); INSERT INTO fda_approval (drug,year) VALUES ('DrugA',2018),('DrugB',2019);
SELECT drug FROM fda_approval WHERE year = 2018;
Delete risk assessments for policyholders with the last name 'Lee' from the risk_assessment_table
CREATE TABLE risk_assessment_table (assessment_id INT,policy_holder TEXT,risk_score INT); INSERT INTO risk_assessment_table (assessment_id,policy_holder,risk_score) VALUES (1,'John Smith',650),(2,'Jane Doe',500),(3,'Mike Johnson',800),(4,'Sarah Lee',700);
DELETE FROM risk_assessment_table WHERE policy_holder LIKE '%Lee%';
What is the percentage of articles in the 'investigation' category, and the average word count, for each gender?
CREATE TABLE articles (article_id INT,title VARCHAR(50),category VARCHAR(20),word_count INT,author_id INT); INSERT INTO articles (article_id,title,category,word_count,author_id) VALUES (1,'Investigation 1','investigation',500,1),(2,'News 2','news',300,2),(3,'Investigation 2','investigation',700,3); CREATE TABLE users (user_id INT,gender VARCHAR(10)); INSERT INTO users (user_id,gender) VALUES (1,'Female'),(2,'Male'),(3,'Female');
SELECT gender, 100.0 * COUNT(CASE WHEN category = 'investigation' THEN 1 END) / COUNT(*) as investigation_percentage, AVG(word_count) as avg_word_count FROM articles JOIN users ON articles.author_id = users.user_id GROUP BY gender;
How many emergency calls were made in each borough in January 2021?
CREATE TABLE emergency_calls_3 (id INT,borough_id INT,call_time TIMESTAMP); INSERT INTO emergency_calls_3 (id,borough_id,call_time) VALUES (1,1,'2021-01-01 01:00:00'),(2,1,'2021-01-02 02:00:00'),(3,2,'2021-01-03 23:00:00'),(4,2,'2021-01-04 04:00:00'),(5,3,'2021-01-05 05:00:00'),(6,3,'2021-01-06 06:00:00'),(7,4,'2021-01-07 07:00:00'),(8,4,'2021-01-08 08:00:00'),(9,5,'2021-01-09 09:00:00'),(10,5,'2021-01-10 10:00:00'),(11,1,'2021-01-11 11:00:00'),(12,1,'2021-01-12 12:00:00');
SELECT b.name, COUNT(ec.id) FROM borough b JOIN emergency_calls_3 ec ON b.id = ec.borough_id WHERE EXTRACT(MONTH FROM ec.call_time) = 1 GROUP BY b.id;
What is the minimum age of employees in each position in the 'mining_operations' table?
CREATE TABLE mining_operations (employee_id INT,first_name VARCHAR(50),last_name VARCHAR(50),position VARCHAR(50),age INT,country VARCHAR(50)); INSERT INTO mining_operations (employee_id,first_name,last_name,position,age,country) VALUES (1,'John','Doe','Engineer',35,'USA'); INSERT INTO mining_operations (employee_id,first_name,last_name,position,age,country) VALUES (2,'Jane','Smith','Supervisor',42,'Canada'); INSERT INTO mining_operations (employee_id,first_name,last_name,position,age,country) VALUES (7,'Eva','Green','Engineer',28,'France');
SELECT position, MIN(age) FROM mining_operations GROUP BY position;
What is the total quantity of mineral X extracted in Year 2010?
CREATE TABLE extraction (id INT,year INT,mineral TEXT,quantity INT); INSERT INTO extraction (id,year,mineral,quantity) VALUES (1,2009,'Mineral X',500); INSERT INTO extraction (id,year,mineral,quantity) VALUES (2,2010,'Mineral Y',700);
SELECT SUM(quantity) FROM extraction WHERE year = 2010 AND mineral = 'Mineral X';
What is the average number of successful cybersecurity incidents reported in Europe in the last 2 years?
CREATE TABLE cyber_incidents_europe (region VARCHAR(255),year INT,success BOOLEAN); INSERT INTO cyber_incidents_europe (region,year,success) VALUES ('Europe',2021,TRUE),('Europe',2021,FALSE),('Europe',2020,TRUE);
SELECT AVG(COUNT(CASE WHEN success THEN 1 END)) FROM cyber_incidents_europe WHERE region = 'Europe' GROUP BY year;
What is the total installed capacity (in MW) of wind power projects in the state of Texas, grouped by project type?
CREATE TABLE wind_projects (project_id INT,project_name VARCHAR(255),state VARCHAR(255),project_type VARCHAR(255),installed_capacity INT);
SELECT project_type, SUM(installed_capacity) FROM wind_projects WHERE state = 'Texas' GROUP BY project_type;
Delete all customer records with a loyalty_score below 60 from the Customers table.
CREATE TABLE Customers (customerID INT,customerName VARCHAR(50),loyalty_score INT); INSERT INTO Customers (customerID,customerName,loyalty_score) VALUES (1,'Alice Johnson',75),(2,'Bob Smith',85),(3,'Carla Jones',65),(4,'Daniel Kim',90);
DELETE FROM Customers WHERE loyalty_score < 60;
What is the total revenue generated from sales to customers in the United States?
CREATE TABLE CustomerOrders (id INT,customer VARCHAR(20),country VARCHAR(20),total DECIMAL(5,2)); INSERT INTO CustomerOrders (id,customer,country,total) VALUES (1,'Alice','United States',100.00),(2,'Bob','Canada',150.00),(3,'Charlie','United States',75.00);
SELECT SUM(total) FROM CustomerOrders WHERE country = 'United States';
What is the average transaction amount for smart contracts in the Finance category?
CREATE TABLE Transactions (id INT PRIMARY KEY,user_id INT,amount INT,tx_type VARCHAR(50),smart_contract_id INT,FOREIGN KEY (user_id) REFERENCES Users(id),FOREIGN KEY (smart_contract_id) REFERENCES Smart_Contracts(id)); INSERT INTO Transactions (id,user_id,amount,tx_type,smart_contract_id) VALUES (3,1,800,'transfer',1); INSERT INTO Transactions (id,user_id,amount,tx_type,smart_contract_id) VALUES (4,2,900,'deposit',2);
SELECT AVG(t.amount) FROM Transactions t INNER JOIN Smart_Contracts sc ON t.smart_contract_id = sc.id WHERE sc.category = 'Finance';
Find organizations with no volunteer activities but have received donations.
CREATE TABLE organization (org_id INT,org_name TEXT); INSERT INTO organization (org_id,org_name) VALUES (1,'Habitat for Humanity'),(2,'American Red Cross'),(3,'Doctors Without Borders'); CREATE TABLE donation (donation_id INT,donor_id INT,org_id INT); INSERT INTO donation (donation_id,donor_id,org_id) VALUES (1,101,1),(2,102,1),(3,103,2),(4,104,3); CREATE TABLE volunteer (vol_id INT,donor_id INT,org_id INT,volunteer_hours INT); INSERT INTO volunteer (vol_id,donor_id,org_id,volunteer_hours) VALUES (101,101,1,20),(102,102,1,30),(103,104,3,15);
SELECT org_name FROM organization WHERE org_id NOT IN (SELECT org_id FROM volunteer);
Which regions have more than 500 total broadband subscribers?
CREATE TABLE broadband_subscribers (region VARCHAR(50),subscriber_id INT); INSERT INTO broadband_subscribers VALUES ('Region A',100); INSERT INTO broadband_subscribers VALUES ('Region A',200); INSERT INTO broadband_subscribers VALUES ('Region B',300); INSERT INTO broadband_subscribers VALUES ('Region C',400); INSERT INTO broadband_subscribers VALUES ('Region D',50);
SELECT region FROM broadband_subscribers GROUP BY region HAVING COUNT(subscriber_id) > 500;
How many agricultural innovation projects are in the 'innovation_projects' table?
CREATE TABLE innovation_projects (id INT,project VARCHAR(50),status VARCHAR(50)); INSERT INTO innovation_projects (id,project,status) VALUES (1,'Precision Agriculture','Completed'); INSERT INTO innovation_projects (id,project,status) VALUES (2,'Drip Irrigation','In Progress');
SELECT COUNT(*) FROM innovation_projects;
What are the names of genetic research projects focusing on genome editing?
CREATE SCHEMA if not exists genetics;CREATE TABLE if not exists genetics.projects (id INT PRIMARY KEY,name VARCHAR(100),focus VARCHAR(100));
SELECT name FROM genetics.projects WHERE focus = 'genome editing';
What are the names and launch dates of all space missions launched by ISA?
CREATE TABLE space_missions (mission_id INT,name VARCHAR(100),launch_date DATE,launching_agency VARCHAR(50)); INSERT INTO space_missions (mission_id,name,launch_date,launching_agency) VALUES (1,'Luna 1','1959-01-02','ISA');
SELECT name, launch_date FROM space_missions WHERE launching_agency = 'ISA';
What is the total sales revenue for organic products in Q1 2021?
CREATE TABLE sales (product_type VARCHAR(10),sale_date DATE,revenue DECIMAL(10,2)); INSERT INTO sales (product_type,sale_date,revenue) VALUES ('organic','2021-01-01',150.00),('non_organic','2021-01-01',200.00),('organic','2021-01-02',120.00),('non_organic','2021-01-02',250.00),('organic','2021-02-01',175.00),('non_organic','2021-02-01',220.00);
SELECT SUM(revenue) FROM sales WHERE product_type = 'organic' AND sale_date BETWEEN '2021-01-01' AND '2021-03-31';
List all suppliers and their associated sustainable certifications from the 'SupplyChain' and 'Sustainability' tables.
CREATE TABLE SupplyChain (supplier_id INT,supplier_name TEXT); CREATE TABLE Sustainability (supplier_id INT,certification TEXT);
SELECT SupplyChain.supplier_name, Sustainability.certification FROM SupplyChain INNER JOIN Sustainability ON SupplyChain.supplier_id = Sustainability.supplier_id;
List Defense contracts that were active in 2020 and have a contract value greater than $60 million.
CREATE TABLE Contracts (Contract_Id INT,Contract_Name VARCHAR(50),Contract_Value FLOAT,Start_Year INT,End_Year INT); INSERT INTO Contracts (Contract_Id,Contract_Name,Contract_Value,Start_Year,End_Year) VALUES (1,'Contract X',75000000,2019,2023); INSERT INTO Contracts (Contract_Id,Contract_Name,Contract_Value,Start_Year,End_Year) VALUES (2,'Contract Y',50000000,2018,2022);
SELECT * FROM Contracts WHERE Contract_Value > 60000000 AND Start_Year <= 2020 AND End_Year >= 2020;
How many sustainable tourism certifications does each country in Africa have?
CREATE TABLE africa_sustainable_tourism (id INT,country VARCHAR(20),certifications INT); INSERT INTO africa_sustainable_tourism (id,country,certifications) VALUES (1,'Egypt',50),(2,'South Africa',100),(3,'Morocco',75);
SELECT country, certifications FROM africa_sustainable_tourism;
Show the carbon offset generated by each smart city initiative in the smart_cities and carbon_offsets tables.
CREATE TABLE smart_cities (city_id INT,city_name VARCHAR(255),location VARCHAR(255)); CREATE TABLE carbon_offsets (offset_id INT,city_id INT,offset_value FLOAT);
SELECT smart_cities.city_name, carbon_offsets.offset_value FROM smart_cities JOIN carbon_offsets ON smart_cities.city_id = carbon_offsets.city_id;
How many public parks are there in urban areas compared to rural areas?
CREATE TABLE Parks (Area TEXT,NumParks INTEGER); INSERT INTO Parks (Area,NumParks) VALUES ('Urban',15),('Rural',10);
SELECT Area, NumParks FROM Parks;
What is the most common type of crime committed in the city of Houston?
CREATE TABLE crime_stats (id INT,city VARCHAR(20),crime_type VARCHAR(20),frequency INT); INSERT INTO crime_stats (id,city,crime_type,frequency) VALUES (1,'Houston','Theft',1200),(2,'Houston','Assault',800),(3,'Houston','Vandalism',500);
SELECT crime_type, MAX(frequency) FROM crime_stats WHERE city = 'Houston' GROUP BY crime_type;
What is the average duration of 'Running' workouts in the 'workout_data' table?
CREATE TABLE workout_data (user_id INT,workout_type VARCHAR(20),duration INT); INSERT INTO workout_data (user_id,workout_type,duration) VALUES (1,'Running',30),(1,'Cycling',60),(2,'Yoga',45),(3,'Pilates',50);
SELECT AVG(duration) as avg_duration FROM workout_data WHERE workout_type = 'Running';
What is the minimum and maximum age of players who have participated in esports events?
CREATE TABLE EsportsPlayers (PlayerID INT,Age INT,EventID INT); INSERT INTO EsportsPlayers (PlayerID,Age,EventID) VALUES (1,22,1),(2,25,2),(3,28,3),(4,30,4);
SELECT MIN(Age), MAX(Age) FROM EsportsPlayers;
What is the name and email of all staff members involved in disability services?
CREATE TABLE Staff (StaffID INT,FirstName VARCHAR(50),LastName VARCHAR(50),Email VARCHAR(50)); INSERT INTO Staff (StaffID,FirstName,LastName,Email) VALUES (1,'Jane','Doe','[[email protected]](mailto:[email protected])'); INSERT INTO Staff (StaffID,FirstName,LastName,Email) VALUES (2,'John','Doe','[[email protected]](mailto:[email protected])');
SELECT Staff.FirstName, Staff.LastName, Staff.Email FROM Staff;
Insert a new music album 'Sour' by Olivia Rodrigo with a release year of 2021 into the 'Music_Albums' table.
CREATE TABLE Music_Albums (album_id INT PRIMARY KEY,artist VARCHAR(100),title VARCHAR(100),release_year INT);
INSERT INTO Music_Albums (artist, title, release_year) VALUES ('Olivia Rodrigo', 'Sour', 2021);
What is the minimum water temperature in 'Salmon_farms'?
CREATE TABLE Salmon_farms (id INT,name TEXT,country TEXT,water_temp FLOAT); INSERT INTO Salmon_farms (id,name,country,water_temp) VALUES (1,'Farm A','Norway',8.5),(2,'Farm B','Canada',2.0);
SELECT MIN(water_temp) FROM Salmon_farms;
What is the local economic impact in 'Bangkok' for the year 2021?
CREATE TABLE local_economy (id INT,location VARCHAR(50),year INT,local_impact DECIMAL(10,2)); INSERT INTO local_economy (id,location,year,local_impact) VALUES (1,'Bangkok',2018,15000.00),(2,'Paris',2019,22000.00);
SELECT year, local_impact FROM local_economy WHERE location = 'Bangkok';
Delete all records in the 'PoliceStations' table where the 'StationName' is 'Central Police Station'
CREATE TABLE PoliceStations (StationID INT PRIMARY KEY,StationName VARCHAR(50),Region VARCHAR(50));
DELETE FROM PoliceStations WHERE StationName = 'Central Police Station';
Delete defense diplomacy activities that have been canceled
CREATE TABLE diplomacy (id INT PRIMARY KEY,activity_name VARCHAR(100),description TEXT,country VARCHAR(100),start_date DATE,end_date DATE,status VARCHAR(50));
DELETE FROM diplomacy WHERE status = 'Cancelled';
What is the earliest excavation date in each region?
CREATE TABLE ExcavationDates (SiteID INT,Region VARCHAR(50),ExcavationDate DATE); INSERT INTO ExcavationDates (SiteID,Region,ExcavationDate) VALUES (1,'africa','2020-01-01'),(2,'americas','2019-01-01'),(3,'africa','2018-01-01'),(4,'europe','2021-01-01');
SELECT Region, MIN(ExcavationDate) AS EarliestExcavationDate FROM ExcavationDates GROUP BY Region;
What is the total number of public libraries in Texas, excluding mobile libraries?
CREATE TABLE libraries (id INT,type TEXT,state TEXT); INSERT INTO libraries (id,type,state) VALUES (1,'public','TX'),(2,'mobile','TX'),(3,'school','TX');
SELECT COUNT(*) FROM libraries WHERE type = 'public' AND state = 'TX';
Delete the species 'Narwhal' from the species table.
CREATE TABLE species (id INT PRIMARY KEY,name VARCHAR(50),population INT);
DELETE FROM species WHERE name = 'Narwhal';
What is the total number of restorative justice programs in California and Texas?
CREATE TABLE restorative_justice_programs (id INT,state VARCHAR(50),program_name VARCHAR(50),type VARCHAR(50)); INSERT INTO restorative_justice_programs (id,state,program_name,type) VALUES (1,'California','Restorative Justice Circle','Victim-Offender'),(2,'Texas','Community Conferencing','Community'),(3,'California','Peacemaking Circle','Community');
SELECT COUNT(*) FROM restorative_justice_programs WHERE state IN ('California', 'Texas');
What is the average energy storage capacity in South Korea and Chile?
CREATE TABLE avg_energy_storage (country VARCHAR(20),capacity INT); INSERT INTO avg_energy_storage (country,capacity) VALUES ('South Korea',65),('South Korea',70),('South Korea',75),('Chile',80),('Chile',85),('Chile',90);
SELECT AVG(capacity) FROM avg_energy_storage WHERE country IN ('South Korea', 'Chile');
Create a table to track music distribution by genre
CREATE TABLE MusicDistribution (distribution_id INT PRIMARY KEY,genre VARCHAR(100),platform VARCHAR(100),distribution_count INT,FOREIGN KEY (genre) REFERENCES Genres(genre),FOREIGN KEY (platform) REFERENCES Platforms(platform)); CREATE TABLE Genres (genre_id INT PRIMARY KEY,genre VARCHAR(100),description VARCHAR(255)); CREATE TABLE Platforms (platform_id INT PRIMARY KEY,platform VARCHAR(100),description VARCHAR(255));
INSERT INTO MusicDistribution (distribution_id, genre, platform, distribution_count) SELECT ROW_NUMBER() OVER (ORDER BY g.genre_id, p.platform_id), g.genre, p.platform, COALESCE(d.distribution_count, 0) FROM Genres g, Platforms p LEFT JOIN (SELECT genre, platform, SUM(distribution_count) AS distribution_count FROM MusicDistribution GROUP BY genre, platform) d ON g.genre = d.genre AND p.platform = d.platform WHERE g.genre_id < 5 AND p.platform_id < 5;
Which graduate students are enrolled in the 'Data Structures' course?
CREATE TABLE GraduateStudents (StudentID int,Name varchar(50),Department varchar(50)); CREATE TABLE Enrollment (StudentID int,Course varchar(50),Semester varchar(50)); INSERT INTO GraduateStudents (StudentID,Name,Department) VALUES (1,'Sana Ahmed','Computer Science'); INSERT INTO GraduateStudents (StudentID,Name,Department) VALUES (2,'Pedro Gomez','Computer Science'); INSERT INTO Enrollment (StudentID,Course,Semester) VALUES (1,'Database Systems','Fall'); INSERT INTO Enrollment (StudentID,Course,Semester) VALUES (1,'Artificial Intelligence','Spring'); INSERT INTO Enrollment (StudentID,Course,Semester) VALUES (2,'Data Structures','Fall'); INSERT INTO Enrollment (StudentID,Course,Semester) VALUES (3,'Operating Systems','Fall'); INSERT INTO Enrollment (StudentID,Course,Semester) VALUES (3,'Data Structures','Fall');
SELECT DISTINCT Name FROM GraduateStudents g INNER JOIN Enrollment e ON g.StudentID = e.StudentID WHERE e.Course = 'Data Structures';
What is the minimum number of shares for posts in Turkish?
CREATE TABLE posts (id INT,language VARCHAR(255),shares INT); INSERT INTO posts (id,language,shares) VALUES (1,'English',10),(2,'Turkish',200),(3,'French',30),(4,'Turkish',50);
SELECT MIN(shares) FROM posts WHERE language = 'Turkish';
Delete defense contract records with a value higher than $100 million for a specific contractor?
CREATE TABLE DefenseContracts (ContractID INT,Contractor VARCHAR(50),Value DECIMAL(10,2)); INSERT INTO DefenseContracts (ContractID,Contractor,Value) VALUES (1,'Northrop Grumman',120000000),(2,'Raytheon',80000000),(3,'Northrop Grumman',75000000);
DELETE FROM DefenseContracts WHERE Contractor = 'Northrop Grumman' AND Value > 100000000;
What is the youngest player who plays VR games?
CREATE TABLE Players (PlayerID INT,Age INT,GameType VARCHAR(10)); INSERT INTO Players (PlayerID,Age,GameType) VALUES (1,25,'VR'),(2,30,'Non-VR'),(3,22,'VR'),(4,19,'VR');
SELECT MIN(Age) FROM Players WHERE GameType = 'VR';
How many health equity metric violations occurred in each region?
CREATE TABLE HealthEquityMetrics (ViolationID INT,Region VARCHAR(255),ViolationDate DATE); INSERT INTO HealthEquityMetrics (ViolationID,Region,ViolationDate) VALUES (1,'Northeast','2021-02-14'),(2,'Southeast','2021-05-03'),(3,'Midwest','2021-07-17'),(4,'Southwest','2021-10-02'),(5,'West','2021-12-18');
SELECT Region, COUNT(*) as ViolationCount FROM HealthEquityMetrics WHERE ViolationDate BETWEEN '2021-01-01' AND '2021-12-31' GROUP BY Region;
Which chemicals have a safety rating lower than 7 and are produced in the Europe region?
CREATE TABLE chemical_production (region VARCHAR(20),chemical VARCHAR(30),quantity INT); INSERT INTO chemical_production (region,chemical,quantity) VALUES ('Europe','Ethanol',3000),('Europe','Propanol',4000); CREATE TABLE chemical_safety (chemical VARCHAR(30),safety_rating INT); INSERT INTO chemical_safety (chemical,safety_rating) VALUES ('Ethanol',8),('Propanol',6);
SELECT chemical FROM chemical_production WHERE region = 'Europe' INTERSECT SELECT chemical FROM chemical_safety WHERE safety_rating < 7;
What is the total biomass of fish in each aquatic farm?
CREATE TABLE farm_biomass (farm_id INT,biomass FLOAT); INSERT INTO farm_biomass (farm_id,biomass) VALUES (1,25000),(2,30000),(3,20000);
SELECT farm_id, SUM(biomass) FROM farm_biomass GROUP BY farm_id;
Find the number of providers who have served more than 100 patients in the 'providers' table, ordered by the number of patients served in descending order.
CREATE TABLE providers (provider_id INT PRIMARY KEY AUTO_INCREMENT,first_name VARCHAR(50),last_name VARCHAR(50),gender VARCHAR(10),ethnicity VARCHAR(50),state VARCHAR(20),patients_served INT);
SELECT provider_id, first_name, last_name, patients_served FROM providers WHERE patients_served > 100 ORDER BY patients_served DESC;
Identify the top three mining operations with the highest waste water production in the last month.
CREATE TABLE WasteWater (MineID INT,Date DATE,Production INT); INSERT INTO WasteWater (MineID,Date,Production) VALUES (1,'2022-01-01',500),(1,'2022-01-02',550),(1,'2022-01-03',600),(2,'2022-01-01',700),(2,'2022-01-02',750),(2,'2022-01-03',800),(3,'2022-01-01',900),(3,'2022-01-02',950),(3,'2022-01-03',1000),(4,'2022-01-01',400),(4,'2022-01-02',450),(4,'2022-01-03',500);
SELECT MineID, SUM(Production) as Total_Production FROM WasteWater WHERE Date >= DATEADD(MONTH, -1, GETDATE()) GROUP BY MineID ORDER BY Total_Production DESC;
What is the maximum length of stay in prison for individuals who have been released in the past year, grouped by their offense type?
CREATE TABLE prison_releases (id INT,offense_type TEXT,release_date DATE,length_of_stay INT);
SELECT offense_type, MAX(length_of_stay) FROM prison_releases WHERE release_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR) GROUP BY offense_type;
What is the average property size for co-owned properties in the US?
CREATE TABLE properties (id INT,size INT,country VARCHAR(255),is_co_owned BOOLEAN); INSERT INTO properties (id,size,country,is_co_owned) VALUES (1,1500,'USA',true),(2,2000,'Canada',false);
SELECT AVG(size) FROM properties WHERE is_co_owned = true AND country = 'USA';
How many carbon offset programs were implemented in India, China, and Brazil between 2015 and 2020?
CREATE TABLE carbon_offsets (program_id INT,country VARCHAR(50),start_year INT,end_year INT); INSERT INTO carbon_offsets (program_id,country,start_year,end_year) VALUES (1,'India',2016,2020),(2,'China',2017,2019),(3,'Brazil',2015,2018),(4,'India',2018,2021),(5,'China',2016,2020),(6,'Brazil',2017,2020),(7,'India',2015,2017);
SELECT COUNT(*) FROM carbon_offsets WHERE country IN ('India', 'China', 'Brazil') AND start_year BETWEEN 2015 AND 2020 AND end_year BETWEEN 2015 AND 2020;
What is the average age of users who liked investigative articles, and how many unique sources are there in this category?
CREATE TABLE users (user_id INT,age INT,gender VARCHAR(10)); INSERT INTO users (user_id,age,gender) VALUES (1,30,'Female'),(2,40,'Male'); CREATE TABLE articles (article_id INT,title VARCHAR(50),category VARCHAR(20),source VARCHAR(20)); INSERT INTO articles (article_id,title,category,source) VALUES (1,'Investigative Article 1','investigative_journalism','Source A'),(2,'Investigative Article 2','investigative_journalism','Source B'),(3,'News Article 1','news','Source A'); CREATE TABLE likes (user_id INT,article_id INT); INSERT INTO likes (user_id,article_id) VALUES (1,1),(2,1);
SELECT AVG(users.age) as avg_age, COUNT(DISTINCT articles.source) as unique_sources FROM users JOIN likes ON users.user_id = likes.user_id JOIN articles ON likes.article_id = articles.article_id WHERE articles.category = 'investigative_journalism';
What is the average annual budget for education programs focused on indigenous languages?
CREATE TABLE education_budget (year INT,program VARCHAR(255),budget INT); INSERT INTO education_budget (year,program,budget) VALUES (2018,'Language Revitalization',500000),(2018,'Bilingual Education',750000),(2019,'Language Revitalization',550000),(2019,'Bilingual Education',800000),(2020,'Language Revitalization',600000),(2020,'Bilingual Education',850000),(2021,'Language Revitalization',650000),(2021,'Bilingual Education',900000);
SELECT AVG(budget) FROM education_budget WHERE program = 'Language Revitalization'
What is the average price of cosmetic products with a halal label?
CREATE TABLE Products (ProductID INT,ProductName VARCHAR(50),Price DECIMAL(5,2),Halal BIT); INSERT INTO Products (ProductID,ProductName,Price,Halal) VALUES (301,'Lipstick',15.99,1),(302,'Mascara',12.99,1),(303,'Foundation',25.99,1),(304,'Eyeshadow',18.99,0),(305,'Blush',14.99,1);
SELECT AVG(Price) FROM Products WHERE Halal = 1;
Find the top 5 highest paying departments in the company.
CREATE TABLE departments (id INT,name VARCHAR(255),manager_id INT,avg_salary DECIMAL(10,2));
SELECT departments.name FROM departments ORDER BY departments.avg_salary DESC LIMIT 5;
Update the genre of track_id 1001 to 'Soul' in the 'tracks' table.
CREATE TABLE tracks (id INT,title VARCHAR(255),artist VARCHAR(255),genre VARCHAR(255));
UPDATE tracks SET genre = 'Soul' WHERE id = 1001;
What is the minimum donation amount for impact investments in education?
CREATE TABLE impact_investments (id INT,area VARCHAR(50),amount DECIMAL(10,2)); INSERT INTO impact_investments (id,area,amount) VALUES (1,'Education',15000.00);
SELECT MIN(amount) FROM impact_investments WHERE area = 'Education';
Create a table named 'space_debris'
CREATE TABLE space_debris (id INT PRIMARY KEY,debris_name VARCHAR(100),launch_date DATE,type VARCHAR(50));
CREATE TABLE space_debris (id INT PRIMARY KEY, debris_name VARCHAR(100), launch_date DATE, type VARCHAR(50));
What are the top 5 countries with the highest number of virtual tours in 2022?
CREATE TABLE Countries (id INT,name VARCHAR(255)); INSERT INTO Countries (id,name) VALUES (1,'USA'),(2,'Canada'),(3,'Mexico'),(4,'Brazil'),(5,'Argentina'); CREATE TABLE VirtualTours (id INT,country_id INT,year INT,views INT); INSERT INTO VirtualTours (id,country_id,year,views) VALUES (1,1,2022,5000),(2,2,2022,3000),(3,3,2022,4000),(4,4,2022,6000),(5,5,2022,2500),(6,1,2022,5500),(7,2,2022,3300),(8,3,2022,4500),(9,4,2022,6200),(10,5,2022,2800);
SELECT c.name, SUM(vt.views) as total_views FROM Countries c JOIN VirtualTours vt ON c.id = vt.country_id WHERE vt.year = 2022 GROUP BY c.name ORDER BY total_views DESC LIMIT 5;