instruction stringlengths 0 1.06k | input stringlengths 11 5.3k | response stringlengths 2 4.44k |
|---|---|---|
Identify the top 3 eco-certified tour operators with the most international visitors in Europe in 2021. | CREATE TABLE operator_stats (operator_id INT,operator_name TEXT,eco_certified BOOLEAN,continent TEXT,year INT,visitors INT); INSERT INTO operator_stats (operator_id,operator_name,eco_certified,continent,year,visitors) VALUES (1,'Operator A',TRUE,'Europe',2021,1000),(2,'Operator B',FALSE,'Europe',2021,1200),(3,'Operator C',TRUE,'Europe',2021,1500),(4,'Operator D',FALSE,'Europe',2021,2000),(5,'Operator E',TRUE,'Europe',2021,800); | SELECT operator_name, ROW_NUMBER() OVER (PARTITION BY eco_certified ORDER BY visitors DESC) as ranking FROM operator_stats WHERE continent = 'Europe' AND year = 2021 AND eco_certified = TRUE; |
Find the average age of attendees for 'Artistic Explorers' and 'Dance Education' programs combined. | CREATE TABLE if not exists event_attendees (id INT,name VARCHAR(50),age INT,program VARCHAR(50)); INSERT INTO event_attendees (id,name,age,program) VALUES (1,'John Doe',35,'Artistic Explorers'),(2,'Jane Smith',42,'Artistic Explorers'),(3,'Mike Johnson',28,'Dance Education'); | SELECT AVG(age) FROM (SELECT age FROM event_attendees WHERE program = 'Artistic Explorers' UNION ALL SELECT age FROM event_attendees WHERE program = 'Dance Education') as attendees; |
What is the minimum age of all country artists in the database? | CREATE TABLE artists (artist_id INT,artist_name VARCHAR(100),artist_age INT,genre VARCHAR(50)); INSERT INTO artists VALUES (1,'Artist A',35,'Country'); INSERT INTO artists VALUES (2,'Artist B',28,'Country'); INSERT INTO artists VALUES (3,'Artist C',45,'Pop'); | SELECT MIN(artist_age) FROM artists WHERE genre = 'Country'; |
What are the names of all professors who have received grants in the past year? | CREATE TABLE professors (id INT,name VARCHAR(50)); INSERT INTO professors (id,name) VALUES (1,'John Smith'),(2,'Jane Doe'); CREATE TABLE grants (id INT,professor_id INT,year INT,amount FLOAT); INSERT INTO grants (id,professor_id,year,amount) VALUES (1,1,2021,5000.0),(2,2,2020,7000.0); | SELECT professors.name FROM professors INNER JOIN grants ON professors.id = grants.professor_id WHERE grants.year = YEAR(CURRENT_DATE()) - 1; |
Which programs had the most attendees for each type of program, excluding any programs with less than 10 attendees, in the city of Chicago? | CREATE TABLE Programs (city VARCHAR(50),program VARCHAR(50),attendees INT); INSERT INTO Programs (city,program,attendees) VALUES ('Chicago','Art',120),('Chicago','Music',15),('Chicago','Dance',180),('Chicago','Art',5),('Chicago','Music',150),('Chicago','Dance',20); | SELECT program, MAX(attendees) FROM Programs WHERE attendees >= 10 AND city = 'Chicago' GROUP BY program; |
How many pallets were moved in the East region for high-priority orders? | CREATE TABLE Warehouse (id INT,region VARCHAR(20),order_priority VARCHAR(20),pallets INT); INSERT INTO Warehouse (id,region,order_priority,pallets) VALUES (1,'East','High',20),(2,'East','Medium',15); | SELECT SUM(pallets) FROM Warehouse WHERE region = 'East' AND order_priority = 'High'; |
Delete all records related to the given sport | CREATE TABLE athletes (id INT,name VARCHAR(50),age INT,sport VARCHAR(50)); INSERT INTO athletes (id,name,age,sport) VALUES (1,'John Doe',30,'Basketball'),(2,'Jane Smith',28,'Soccer'); CREATE TABLE teams (id INT,name VARCHAR(50),sport VARCHAR(50)); INSERT INTO teams (id,name,sport) VALUES (1,'Warriors','Basketball'),(2,'Real Madrid','Soccer'); | DELETE FROM athletes, teams WHERE athletes.sport = teams.sport AND sport = 'Basketball'; |
Show the top 5 most common causes donated to, along with their respective total donation amounts. | CREATE TABLE DonationCauses (DonationCauseID int,DonationCause varchar(50),DonationAmount decimal(10,2)); INSERT INTO DonationCauses (DonationCauseID,DonationCause,DonationAmount) VALUES (1,'Education',5000.00),(2,'Healthcare',7000.00),(3,'Environment',3000.00),(4,'Education',2500.00),(5,'Healthcare',1000.00),(6,'Poverty Alleviation',6000.00),(7,'Education',4000.00),(8,'Healthcare',8000.00),(9,'Environment',1500.00); | SELECT DonationCause, SUM(DonationAmount) as TotalDonation, RANK() OVER (ORDER BY SUM(DonationAmount) DESC) as DonationRank FROM DonationCauses GROUP BY DonationCause ORDER BY DonationRank ASC; |
What was the total REE production in 2016? | CREATE TABLE production (year INT,element TEXT,quantity INT); INSERT INTO production (year,element,quantity) VALUES (2015,'Dysprosium',100),(2016,'Dysprosium',150),(2017,'Dysprosium',200),(2018,'Dysprosium',250),(2019,'Dysprosium',300),(2020,'Dysprosium',350),(2015,'Neodymium',500),(2016,'Neodymium',600),(2017,'Neodymium',700),(2018,'Neodymium',800),(2019,'Neodymium',900),(2020,'Neodymium',1000); | SELECT SUM(quantity) FROM production WHERE year = 2016 AND element IN ('Dysprosium', 'Neodymium'); |
What is the total amount spent on mining operations in the years 2019 and 2020? | CREATE TABLE Mining_Operations (id INT,operation_name VARCHAR(50),location VARCHAR(50),cost FLOAT,year INT); INSERT INTO Mining_Operations (id,operation_name,location,cost,year) VALUES (1,'Operation A','USA',100000.00,2020),(2,'Operation B','Canada',120000.00,2019),(3,'Operation C','Mexico',90000.00,2020),(4,'Operation D','USA',80000.00,2019); | SELECT SUM(cost) FROM Mining_Operations WHERE year IN (2019, 2020); |
What is the maximum billing amount for cases in the region with the highest average billing amount? | CREATE TABLE Regions (RegionID INT,Region VARCHAR(20)); INSERT INTO Regions (RegionID,Region) VALUES (1,'Northeast'),(2,'Southeast'),(3,'Midwest'),(4,'Southwest'),(5,'West'); CREATE TABLE Cases (CaseID INT,RegionID INT,BillingAmount DECIMAL(10,2)); INSERT INTO Cases (CaseID,RegionID,BillingAmount) VALUES (1,1,5000.00),(2,2,4000.00),(3,3,6000.00),(4,1,5500.00),(5,2,4500.00); | SELECT MAX(BillingAmount) FROM Cases INNER JOIN (SELECT RegionID, AVG(BillingAmount) AS AvgBillingAmount FROM Cases GROUP BY RegionID ORDER BY AvgBillingAmount DESC LIMIT 1) AS Subquery ON Cases.RegionID = Subquery.RegionID; |
What is the total waste generated by each ethical fashion brand in the past year? | CREATE TABLE EthicalBrands (id INT,brand VARCHAR,waste_kg INT); CREATE TABLE BrandWasteData (brand VARCHAR,year INT,waste_kg INT); | SELECT e.brand, SUM(bw.waste_kg) as total_waste FROM EthicalBrands e JOIN BrandWasteData bw ON e.brand = bw.brand WHERE bw.year = YEAR(CURRENT_DATE()) - 1 GROUP BY e.brand; |
Get the top 3 most popular hobbies among visitors. | CREATE TABLE hobbies (id INT,hobby VARCHAR(50),visitors INT); INSERT INTO hobbies (id,hobby,visitors) VALUES (1,'Art',1200),(2,'Music',800),(3,'Science',1000); | SELECT hobby, visitors FROM hobbies ORDER BY visitors DESC LIMIT 3; |
What is the total amount of water consumed by each mining site? | CREATE TABLE MiningSites (site_id INT,site_name VARCHAR(50),location VARCHAR(50),water_consumed DECIMAL(10,2)); INSERT INTO MiningSites (site_id,site_name,location,water_consumed) VALUES (1,'Site A','California',1000),(2,'Site B','Nevada',1500); | SELECT site_name, water_consumed FROM MiningSites; |
What is the maximum budget of a SIGINT agency? | CREATE SCHEMA if not exists sigint_max_budget AUTHORIZATION defsec;CREATE TABLE if not exists sigint_max_budget.info (id INT,name VARCHAR(100),budget INT);INSERT INTO sigint_max_budget.info (id,name,budget) VALUES (1,'NSA',15000000000);INSERT INTO sigint_max_budget.info (id,name,budget) VALUES (2,'GCHQ',8000000000);INSERT INTO sigint_max_budget.info (id,name,budget) VALUES (3,'DGSE',5000000000); | SELECT MAX(budget) as max_budget FROM sigint_max_budget.info WHERE name LIKE '%SIGINT%'; |
Find the maximum number of shares for posts with the hashtag #sustainability in the "green_network" schema. | CREATE TABLE posts (id INT,user_id INT,content TEXT,shares INT,hashtags TEXT); | SELECT MAX(shares) FROM posts WHERE hashtags LIKE '%#sustainability%'; |
Delete all records in the 'carbon_prices' table that are older than 2020 | CREATE TABLE carbon_prices (id INT PRIMARY KEY,year INT,price FLOAT); | DELETE FROM carbon_prices WHERE year < 2020; |
What is the total amount of rainfall recorded in millimeters for 'Field4' by the automatic weather station in the month of June in 2022? | CREATE TABLE Field4_Rainfall (station_id INT,measurement_time TIMESTAMP,rainfall DECIMAL(4,1)); INSERT INTO Field4_Rainfall (station_id,measurement_time,rainfall) VALUES (5,'2022-06-15 12:30:00',25.6),(5,'2022-06-30 18:45:00',30.1); | SELECT SUM(rainfall) FROM Field4_Rainfall WHERE EXTRACT(MONTH FROM measurement_time) = 6 AND EXTRACT(YEAR FROM measurement_time) = 2022 AND station_id = 5; |
Drop the salary column from the veteran_employment table | CREATE TABLE veteran_employment (id INT PRIMARY KEY,name VARCHAR(255),position VARCHAR(255),years_of_service INT,salary NUMERIC(10,2)); | ALTER TABLE veteran_employment DROP COLUMN salary; |
How many users have used public transportation in Sydney for more than 30 days? | CREATE TABLE public_transportation_users (user_id INT,start_date DATE,city VARCHAR(255)); | SELECT COUNT(DISTINCT user_id) FROM public_transportation_users WHERE city = 'Sydney' GROUP BY user_id HAVING DATEDIFF('2022-06-30', start_date) >= 30; |
What is the average safety rating for vehicles released in 2018? | CREATE TABLE SafetyTesting (Id INT,Name VARCHAR(50),Year INT,SafetyRating INT); INSERT INTO SafetyTesting (Id,Name,Year,SafetyRating) VALUES (1,'Corvette',2018,5),(2,'911 Turbo',2017,5),(3,'M4 GTS',2016,4); | SELECT AVG(SafetyRating) FROM SafetyTesting WHERE Year = 2018; |
What is the total salary expense for each department, and what is the average salary for each department? | CREATE TABLE Employees (EmployeeID int,Department varchar(50),Salary decimal(10,2)); INSERT INTO Employees (EmployeeID,Department,Salary) VALUES (1,'Engineering',80000.00),(2,'Marketing',70000.00),(3,'Sales',75000.00); | SELECT e.Department, SUM(e.Salary) as SalaryExpense, AVG(e.Salary) as AverageSalary FROM Employees e GROUP BY e.Department; |
What is the maximum landfill capacity (in cubic meters) for each region and the corresponding region name? | CREATE TABLE RegionLandfillData (RegionID INT,Region VARCHAR(255),LandfillID INT,Capacity DECIMAL(10,2)); INSERT INTO RegionLandfillData (RegionID,Region,LandfillID,Capacity) VALUES (1,'North',1,120000),(2,'South',2,80000),(3,'North',3,150000); | SELECT Region, MAX(Capacity) AS MaxCapacity FROM RegionLandfillData GROUP BY Region; |
How many coal power plants were operational in Australia as of 2019? | CREATE TABLE coal_plants (country VARCHAR(50),operational BOOLEAN,year INT); INSERT INTO coal_plants (country,operational,year) VALUES ('Australia',true,2019),('United States',true,2019),('China',true,2019),('India',true,2019); | SELECT COUNT(*) FROM coal_plants WHERE country = 'Australia' AND operational = true AND year = 2019; |
What is the maximum number of attendees at labor advocacy events in Ohio? | CREATE TABLE LaborAdvocacy (id INT,org_name VARCHAR,location VARCHAR,budget FLOAT); CREATE TABLE AdvocacyEvents (id INT,labor_advocacy_id INT,event_name VARCHAR,date DATE,attendees INT); | SELECT MAX(ae.attendees) as max_attendees FROM AdvocacyEvents ae JOIN LaborAdvocacy la ON ae.labor_advocacy_id = la.id WHERE la.location = 'Ohio'; |
What is the total donation amount? | CREATE TABLE Donations (id INT,region VARCHAR(20),amount FLOAT); INSERT INTO Donations (id,region,amount) VALUES (1,'Northeast',25000.00),(2,'Southeast',30000.00),(3,'Midwest',20000.00),(4,'Southwest',15000.00),(5,'Northwest',35000.00); | SELECT SUM(amount) as total_donations FROM Donations; |
What is the maximum environmental impact score for mining operations in the Russian Federation? | CREATE TABLE Operations (OperationID INT,MineID INT,Year INT,EnvironmentalImpactScore FLOAT); INSERT INTO Operations (OperationID,MineID,Year,EnvironmentalImpactScore) VALUES (1,1,2019,50); INSERT INTO Operations (OperationID,MineID,Year,EnvironmentalImpactScore) VALUES (2,1,2018,55); INSERT INTO Operations (OperationID,MineID,Year,EnvironmentalImpactScore) VALUES (3,2,2019,60); INSERT INTO Operations (OperationID,MineID,Year,EnvironmentalImpactScore) VALUES (4,2,2018,65); | SELECT MAX(o.EnvironmentalImpactScore) as MaxImpactScore FROM Operations o INNER JOIN Mines m ON o.MineID = m.MineID WHERE m.Country = 'Russian Federation'; |
How many theater performances were held in each month of the last year? | CREATE TABLE TheaterPerformances (performanceID INT,performanceDate DATE); INSERT INTO TheaterPerformances (performanceID,performanceDate) VALUES (1,'2022-03-01'),(2,'2022-02-15'),(3,'2021-12-20'); | SELECT YEAR(performanceDate) AS Year, MONTH(performanceDate) AS Month, COUNT(*) AS Count FROM TheaterPerformances WHERE performanceDate >= DATEADD(year, -1, GETDATE()) GROUP BY YEAR(performanceDate), MONTH(performanceDate); |
What is the total ad spend for company X in Q3 of 2022? | CREATE TABLE ads (ad_id INT,company VARCHAR(50),ad_spend DECIMAL(10,2),ad_date DATE); INSERT INTO ads (ad_id,company,ad_spend,ad_date) VALUES (1,'Company X',500,'2022-07-01'),(2,'Company Y',800,'2022-08-01'),(3,'Company X',700,'2022-09-01'); | SELECT SUM(ad_spend) FROM ads WHERE company = 'Company X' AND QUARTER(ad_date) = 3 AND YEAR(ad_date) = 2022; |
What is the total number of streams for each artist in Canada and Germany? | CREATE TABLE streams (id INT,artist VARCHAR(255),country VARCHAR(255),streams INT); INSERT INTO streams (id,artist,country,streams) VALUES (1,'Artist1','Canada',1000000),(2,'Artist2','Germany',800000),(3,'Artist1','Canada',1200000),(4,'Artist3','Germany',900000); | SELECT artist, SUM(streams) AS total_streams FROM streams WHERE country IN ('Canada', 'Germany') GROUP BY artist; |
What is the average amount of research grants received by female faculty members in the Computer Science department? | CREATE TABLE faculty (id INT,name VARCHAR(50),department VARCHAR(50),gender VARCHAR(50),grant_amount DECIMAL(10,2)); INSERT INTO faculty (id,name,department,gender,grant_amount) VALUES (1,'Alice','Computer Science','Female',15000.00),(2,'Bob','Computer Science','Male',20000.00),(3,'Charlie','Computer Science','Female',12000.00); | SELECT AVG(grant_amount) FROM faculty WHERE department = 'Computer Science' AND gender = 'Female'; |
How many infectious disease cases were reported in New York City in the past month? | CREATE TABLE infectious_diseases (id INT,case_number INT,report_date DATE); INSERT INTO infectious_diseases (id,case_number,report_date) VALUES (1,123,'2022-01-01'); INSERT INTO infectious_diseases (id,case_number,report_date) VALUES (2,456,'2022-01-10'); | SELECT COUNT(*) FROM infectious_diseases WHERE report_date >= DATEADD(day, -30, CURRENT_DATE) AND city = 'New York'; |
What is the total revenue for the 'Art Auction' event? | CREATE TABLE Sales (event TEXT,item TEXT,price NUMERIC); INSERT INTO Sales (event,item,price) VALUES ('Art Auction','Painting',10000); INSERT INTO Sales (event,item,price) VALUES ('Art Auction','Sculpture',8000); INSERT INTO Sales (event,item,price) VALUES ('Art Auction','Photograph',2000); CREATE TABLE Inventory (item TEXT,category TEXT); INSERT INTO Inventory (item,category) VALUES ('Painting','Art'); INSERT INTO Inventory (item,category) VALUES ('Sculpture','Art'); INSERT INTO Inventory (item,category) VALUES ('Photograph','Art'); | SELECT SUM(price) FROM Sales WHERE event = 'Art Auction'; |
What is the total number of public schools in the US and what is the average student-teacher ratio in those schools? | CREATE TABLE countries (id INT,name VARCHAR(255)); INSERT INTO countries (id,name) VALUES (1,'US'); CREATE TABLE schools (id INT,country_id INT,name VARCHAR(255),num_students INT,num_teachers INT); INSERT INTO schools (id,country_id,name,num_students,num_teachers) VALUES (1,1,'School 1',500,30),(2,1,'School 2',600,40); | SELECT COUNT(schools.id) AS total_schools, AVG(schools.num_students / schools.num_teachers) AS avg_student_teacher_ratio FROM schools WHERE schools.country_id = 1; |
Find the number of students who received accommodations in the psychology department during the spring 2022 semester, but did not receive any accommodations in any department during the fall 2022 semester. | CREATE TABLE psychology_accommodations (student_id INT,semester VARCHAR(10));CREATE TABLE social_work_accommodations (student_id INT,semester VARCHAR(10));CREATE TABLE counseling_accommodations (student_id INT,semester VARCHAR(10)); INSERT INTO psychology_accommodations VALUES (8,'spring 2022'),(9,'spring 2022'),(10,'spring 2022'); INSERT INTO social_work_accommodations VALUES (9,'fall 2022'),(10,'fall 2022'),(11,'fall 2022'); INSERT INTO counseling_accommodations VALUES (10,'fall 2022'),(11,'fall 2022'); | SELECT COUNT(*) FROM (SELECT student_id FROM psychology_accommodations WHERE semester = 'spring 2022' EXCEPT SELECT student_id FROM social_work_accommodations WHERE semester = 'fall 2022' EXCEPT SELECT student_id FROM counseling_accommodations WHERE semester = 'fall 2022') AS subquery; |
What is the average energy efficiency rating for residential buildings in the 'building_stats' table? | CREATE TABLE building_stats (building_id INT,building_type VARCHAR(50),energy_efficiency_rating FLOAT); INSERT INTO building_stats (building_id,building_type,energy_efficiency_rating) VALUES (1,'Residential',80.5),(2,'Commercial',65.3),(3,'Industrial',72.9); | SELECT AVG(energy_efficiency_rating) FROM building_stats WHERE building_type = 'Residential'; |
Update the diversity metric for "Acme Corp" to 0.7 in the "company_profiles" table | CREATE TABLE company_profiles (company_name VARCHAR(255),founding_year INT,diversity_metric FLOAT); | UPDATE company_profiles SET diversity_metric = 0.7 WHERE company_name = 'Acme Corp'; |
What is the average number of matches won by tennis players in the Grand Slam tournaments, by surface? | CREATE TABLE tennis_players (player_id INT,player_name VARCHAR(50),surface VARCHAR(10),matches_played INT,matches_won INT); INSERT INTO tennis_players (player_id,player_name,surface,matches_played,matches_won) VALUES (1,'Novak Djokovic','Hard',120,90),(2,'Roger Federer','Grass',100,80); | SELECT surface, AVG(matches_won) FROM tennis_players GROUP BY surface; |
What is the average daily transaction value for decentralized exchanges in Germany? | CREATE TABLE decentralized_exchanges (exchange_name TEXT,country TEXT,daily_transaction_value INTEGER); INSERT INTO decentralized_exchanges (exchange_name,country,daily_transaction_value) VALUES ('Uniswap','Germany',5000000),('Sushiswap','Germany',3000000); | SELECT AVG(daily_transaction_value) FROM decentralized_exchanges WHERE country = 'Germany'; |
What is the change in energy consumption for each smart city compared to the previous year? | CREATE TABLE city_energy_consumption (city_name TEXT,year INTEGER,energy_consumption FLOAT); INSERT INTO city_energy_consumption VALUES ('CityA',2020,500.0),('CityA',2021,550.0),('CityB',2020,700.0),('CityB',2021,730.0); | SELECT a.city_name, a.year, a.energy_consumption, b.energy_consumption, a.energy_consumption - b.energy_consumption AS difference FROM city_energy_consumption a INNER JOIN city_energy_consumption b ON a.city_name = b.city_name AND a.year - 1 = b.year; |
Which spacecraft were launched before '2000-01-01'? | CREATE TABLE spacecraft (id INT,name VARCHAR(255),launch_date DATE); INSERT INTO spacecraft (id,name,launch_date) VALUES (1,'Voyager 1','1977-09-05'),(2,'Voyager 2','1977-08-20'),(3,'Spirit','2004-01-04'); | SELECT name FROM spacecraft WHERE launch_date < '2000-01-01' ORDER BY launch_date; |
List all marine protected areas in the Indian Ocean. | CREATE TABLE marine_protected_areas (name VARCHAR(255),location VARCHAR(255)); INSERT INTO marine_protected_areas (name,location) VALUES ('Protected Area A','Indian Ocean'),('Protected Area B','Atlantic Ocean'); | SELECT name FROM marine_protected_areas WHERE location = 'Indian Ocean'; |
How many virtual events are there in total in Amsterdam and Barcelona? | CREATE TABLE events (id INT,name VARCHAR(255),city VARCHAR(255),is_virtual BOOLEAN); INSERT INTO events (id,name,city,is_virtual) VALUES (1,'Virtual Cultural Heritage','Amsterdam',TRUE),(2,'Sustainable Architecture Tour','Barcelona',FALSE); | SELECT COUNT(*) FROM events WHERE city IN ('Amsterdam', 'Barcelona') AND is_virtual = TRUE; |
How many donors made donations in each quarter of 2022? | CREATE TABLE Donations (DonorID INT,DonationDate DATE); INSERT INTO Donations (DonorID,DonationDate) VALUES (1,'2022-01-01'),(2,'2022-02-15'),(1,'2022-04-05'),(3,'2022-07-10'),(4,'2022-10-25'); | SELECT DATE_FORMAT(DonationDate, '%Y-%m') as Quarter, COUNT(DISTINCT DonorID) as DonorCount FROM Donations WHERE YEAR(DonationDate) = 2022 GROUP BY Quarter; |
Which waste types are not included in the circular economy initiatives? | CREATE TABLE waste_types (type TEXT,id INTEGER); INSERT INTO waste_types (type,id) VALUES ('Plastic',1),('Paper',2),('Glass',3),('Metal',4); CREATE TABLE circular_economy_initiatives (waste_type_id INTEGER); INSERT INTO circular_economy_initiatives (waste_type_id) VALUES (1),(2),(3); | SELECT wt.type FROM waste_types wt LEFT JOIN circular_economy_initiatives cei ON wt.id = cei.waste_type_id WHERE cei.waste_type_id IS NULL; |
List all suppliers and the total revenue generated from each | CREATE TABLE suppliers (supplier_id INT,supplier_name VARCHAR(50));CREATE TABLE sales (sale_id INT,product_id INT,sale_quantity INT,sale_price DECIMAL(10,2),supplier_id INT); | SELECT s.supplier_id, s.supplier_name, SUM(sales.sale_quantity * sales.sale_price) as total_revenue FROM sales JOIN suppliers ON sales.supplier_id = suppliers.supplier_id GROUP BY s.supplier_id, s.supplier_name; |
List all building permits issued for commercial buildings in the state of Washington. | CREATE TABLE permit (id INT,state VARCHAR(20),type VARCHAR(20),permit_number INT); INSERT INTO permit (id,state,type,permit_number) VALUES (1,'Washington','Commercial',100),(2,'Washington','Residential',150),(3,'California','Commercial',80); | SELECT permit_number FROM permit WHERE state = 'Washington' AND type = 'Commercial'; |
List all restorative justice programs introduced in New Zealand in 2020. | CREATE TABLE programs (program_id INT,program_type VARCHAR(20),introduction_date DATE); INSERT INTO programs (program_id,program_type,introduction_date) VALUES (1,'Restorative Justice','2020-01-01'); INSERT INTO programs (program_id,program_type,introduction_date) VALUES (2,'Traditional','2019-01-01'); | SELECT program_id, program_type FROM programs WHERE program_type = 'Restorative Justice' AND introduction_date BETWEEN '2020-01-01' AND '2020-12-31'; |
What is the total installed capacity of wind energy in Africa? | CREATE TABLE renewable_energy_sources (id INT,country VARCHAR(255),source VARCHAR(255),installed_capacity INT); INSERT INTO renewable_energy_sources (id,country,source,installed_capacity) VALUES (1,'Egypt','Wind',250),(2,'South Africa','Solar',300),(3,'Morocco','Wind',150); | SELECT SUM(installed_capacity) FROM renewable_energy_sources WHERE country IN ('Egypt', 'South Africa', 'Morocco') AND source = 'Wind'; |
Update the name of an excavation site | CREATE TABLE ExcavationSites (SiteID int,Name varchar(50),Country varchar(50),StartDate date); | UPDATE ExcavationSites SET Name = 'Site G' WHERE SiteID = 6; |
What is the average word count for articles about politics and sports in the last 3 months? | CREATE TABLE articles (id INT,title VARCHAR(50),category VARCHAR(20),author_id INT,publish_date DATE,word_count INT); INSERT INTO articles (id,title,category,author_id,publish_date,word_count) VALUES (1,'Oil Prices Rising','politics',1,'2021-04-15',1200),(2,'Government Corruption','politics',2,'2021-03-10',1500),(3,'Baseball Game','sports',3,'2021-02-01',800),(4,'Football Match','sports',1,'2021-01-01',1000); | SELECT AVG(word_count) FROM articles WHERE category IN ('politics', 'sports') AND publish_date >= DATE_SUB(CURRENT_DATE, INTERVAL 3 MONTH); |
Identify unique authors who have written for 'The Hindu' and 'NDTV' in May 2021. | CREATE TABLE hindu (author_id INT,author_name VARCHAR(50),article_date DATE); INSERT INTO hindu (author_id,author_name,article_date) VALUES (1,'Rajesh Patel','2021-05-01'),(2,'Priya Gupta','2021-05-02'); CREATE TABLE ndtv (author_id INT,author_name VARCHAR(50),article_date DATE); INSERT INTO ndtv (author_id,author_name,article_date) VALUES (3,'Meera Kapoor','2021-05-01'),(4,'Rajesh Patel','2021-05-03'); | SELECT author_name FROM hindu WHERE article_date BETWEEN '2021-05-01' AND '2021-05-31' INTERSECT SELECT author_name FROM ndtv WHERE article_date BETWEEN '2021-05-01' AND '2021-05-31'; |
How many papers on algorithmic fairness were published in the past year by authors from each country, in the AI Research database? | CREATE TABLE authors (id INT,name VARCHAR(255),country VARCHAR(255)); INSERT INTO authors (id,name,country) VALUES (1,'Alice','USA'),(2,'Bob','Canada'); CREATE TABLE papers (id INT,title VARCHAR(255),published_date DATE,author_id INT); INSERT INTO papers (id,title,published_date,author_id) VALUES (1,'Paper1','2021-06-01',1),(2,'Paper2','2020-12-25',2); CREATE TABLE topics (id INT,paper_id INT,title VARCHAR(255)); INSERT INTO topics (id,paper_id,title) VALUES (1,1,'Algorithmic Fairness'),(2,2,'AI Safety'); | SELECT authors.country, COUNT(*) FROM papers JOIN authors ON papers.author_id = authors.id JOIN topics ON papers.id = topics.paper_id WHERE topics.title = 'Algorithmic Fairness' AND YEAR(papers.published_date) = YEAR(CURRENT_DATE()) GROUP BY authors.country; |
Find the total number of marine species in the Arctic region. | CREATE TABLE marine_species (species_name TEXT,region TEXT); INSERT INTO marine_species (species_name,region) VALUES ('Narwhal','Arctic'),('Beluga Whale','Arctic'),('Walrus','Arctic'); | SELECT COUNT(*) FROM marine_species WHERE region = 'Arctic'; |
How many policies were issued in each state last year? | CREATE TABLE Policies (PolicyID INT,IssueDate DATE,State VARCHAR(20)); INSERT INTO Policies (PolicyID,IssueDate,State) VALUES (1,'2021-01-01','California'),(2,'2021-02-15','Texas'),(3,'2020-12-30','New York'); | SELECT State, COUNT(PolicyID) FROM Policies WHERE YEAR(IssueDate) = YEAR(CURRENT_DATE()) - 1 GROUP BY State; |
How many traffic violations were recorded in 2022 and 2023? | CREATE TABLE traffic_violations (violation_id INT,violation_date DATE,violation_type VARCHAR(255)); INSERT INTO traffic_violations (violation_id,violation_date,violation_type) VALUES (1,'2022-01-01','Speeding'),(2,'2023-02-03','Running Red Light'); | SELECT SUM(violation_id) FROM traffic_violations WHERE violation_date BETWEEN '2022-01-01' AND '2023-12-31'; |
Which countries have no space research facilities? | CREATE TABLE Countries (ID INT PRIMARY KEY,Name TEXT); CREATE TABLE Research_Facilities (ID INT PRIMARY KEY,Country_ID INT,Name TEXT,Type TEXT); | SELECT c.Name FROM Countries c LEFT JOIN Research_Facilities rf ON c.ID = rf.Country_ID WHERE rf.ID IS NULL; |
What is the total quantity of items sold in the EU that are made of sustainable materials? | CREATE TABLE sales (id INT,item_id INT,country TEXT,quantity INT); INSERT INTO sales (id,item_id,country,quantity) VALUES (1,1,'Germany',100),(2,2,'France',50); CREATE TABLE products (id INT,name TEXT,material TEXT,vegan BOOLEAN); INSERT INTO products (id,name,material,vegan) VALUES (1,'Dress','Organic Cotton',1),(2,'Skirt','Polyester',0); | SELECT SUM(quantity) FROM sales JOIN products ON sales.item_id = products.id WHERE (products.material IN ('Organic Cotton', 'Linen', 'Recycled Polyester') OR products.vegan = 1) AND country LIKE 'EU%'; |
Identify the number of mobile subscribers using 4G technology in each region, excluding subscribers with incomplete data. | CREATE TABLE mobile_subscribers (subscriber_id INT,technology VARCHAR(20),region VARCHAR(50),complete_data BOOLEAN); INSERT INTO mobile_subscribers (subscriber_id,technology,region,complete_data) VALUES (1,'4G','North',true),(2,'5G','North',false),(3,'3G','South',true),(4,'5G','East',true),(5,'5G','North',true),(6,'3G','South',true),(7,'4G','West',true); | SELECT technology, region, COUNT(*) AS subscribers FROM mobile_subscribers WHERE complete_data = true AND technology = '4G' GROUP BY technology, region; |
What is the total number of volunteers in the 'Volunteers' table who signed up before and after June 2022? | CREATE TABLE Volunteers (VolunteerID INT,SignUpDate DATE); | SELECT SUM(CASE WHEN SignUpDate < '2022-06-01' THEN 1 ELSE 0 END) AS BeforeJune, SUM(CASE WHEN SignUpDate >= '2022-06-01' THEN 1 ELSE 0 END) AS AfterJune FROM Volunteers; |
What is the maximum response time for emergency calls in the state of New York? | CREATE TABLE emergency_calls (id INT,state VARCHAR(20),response_time INT); | SELECT MAX(response_time) FROM emergency_calls WHERE state = 'New York'; |
Identify the number of renewable energy projects in Japan with a completion year greater than 2019. | CREATE TABLE japan_renewable_energy_projects (id INT,country VARCHAR(20),completion_year INT); INSERT INTO japan_renewable_energy_projects (id,country,completion_year) VALUES (1,'Japan',2018),(2,'Japan',2021); | SELECT COUNT(*) FROM japan_renewable_energy_projects WHERE country = 'Japan' AND completion_year > 2019; |
What is the total number of AI models developed by organizations based in the Asia-Pacific region, and what is the maximum safety rating among these models? | CREATE TABLE AIModels (id INT,model_name VARCHAR(50),organization VARCHAR(50),application_type VARCHAR(50),safety_rating INT); INSERT INTO AIModels (id,model_name,organization,application_type,safety_rating) VALUES (1,'AI4Welfare','Microsoft','Social Welfare',85),(2,'AI4Empowerment','Google','Social Welfare',90),(3,'AI4Assistance','IBM','Social Welfare',88),(4,'AI4Support','Alibaba','Social Welfare',92),(5,'AI4Access','Tencent','Social Welfare',80),(6,'AI4Education','Baidu','Education',95); | SELECT organization, COUNT(model_name) as model_count FROM AIModels WHERE organization IN (SELECT DISTINCT organization FROM AIModels WHERE country IN (SELECT country FROM AIContinents WHERE continent = 'Asia-Pacific')) GROUP BY organization ORDER BY model_count DESC LIMIT 1; SELECT MAX(safety_rating) as max_safety_rating FROM AIModels WHERE organization IN (SELECT DISTINCT organization FROM AIModels WHERE country IN (SELECT country FROM AIContinents WHERE continent = 'Asia-Pacific')); |
What is the total number of digital assets issued in the North American region? | CREATE TABLE digital_assets (asset_id INT,asset_name VARCHAR(50),region VARCHAR(50)); INSERT INTO digital_assets (asset_id,asset_name,region) VALUES (1,'Bitcoin','North America'),(2,'Ethereum','North America'); | SELECT COUNT(*) FROM digital_assets WHERE region = 'North America'; |
What is the total price of eyeshadows with matte finish? | CREATE TABLE Cosmetics (product_id INT,name VARCHAR(50),price DECIMAL(5,2),has_matte_finish BOOLEAN,type VARCHAR(50)); | SELECT SUM(price) FROM Cosmetics WHERE type = 'Eyeshadow' AND has_matte_finish = TRUE; |
What's the minimum donation amount for donors from India? | CREATE TABLE donations (id INT,donation_amount DECIMAL,country TEXT); INSERT INTO donations (id,donation_amount,country) VALUES (1,150.00,'Germany'),(2,250.00,'Germany'),(3,300.00,'Canada'),(4,50.00,'India'),(5,100.00,'India'); | SELECT MIN(donation_amount) FROM donations WHERE country = 'India'; |
What is the average Shariah-compliant loan amount in the Middle East, Africa, and South Asia? | CREATE TABLE shariah_compliant_loans (id INT,region VARCHAR(20),amount DECIMAL(10,2)); INSERT INTO shariah_compliant_loans (id,region,amount) VALUES (1,'Middle East',8000.00),(2,'Africa',9000.00),(3,'South Asia',7000.00); | SELECT AVG(amount) FROM shariah_compliant_loans WHERE region IN ('Middle East', 'Africa', 'South Asia'); |
What is the maximum amount donated by a donor in the super_donors view? | CREATE VIEW super_donors AS SELECT id,name,organization,SUM(amount) AS total_donation FROM donors GROUP BY id; | SELECT MAX(total_donation) FROM super_donors; |
What is the number of students who have improved their mental health score by more than 10 points in each district? | CREATE TABLE student_mental_health (student_id INT,district_id INT,mental_health_score INT,date DATE); CREATE TABLE enrollments (student_id INT,enrollment_date DATE,mental_health_score INT); | SELECT d.district_name, COUNT(smh.student_id) as num_improved FROM student_mental_health smh JOIN enrollments e ON smh.student_id = e.student_id JOIN districts d ON smh.district_id = d.district_id WHERE smh.mental_health_score > e.mental_health_score + 10 GROUP BY d.district_name; |
What is the average production output for each machine in the company's facility in Mexico? | CREATE TABLE production_output (output_id INT,machine_id INT,production_date DATE,output_quantity INT); INSERT INTO production_output (output_id,machine_id,production_date,output_quantity) VALUES (1,1,'2022-01-01',100),(2,1,'2022-01-02',120),(3,2,'2022-01-01',150),(4,2,'2022-01-02',160); CREATE TABLE facilities (facility_id INT,facility_name VARCHAR(255),country VARCHAR(255)); INSERT INTO facilities (facility_id,facility_name,country) VALUES (1,'Tijuana Plant','Mexico'),(2,'Monterrey Plant','Mexico'); | SELECT machine_id, AVG(output_quantity) as avg_output FROM production_output po JOIN facilities f ON f.facility_name = 'Tijuana Plant' WHERE po.production_date BETWEEN '2022-01-01' AND '2022-12-31' GROUP BY machine_id; |
Update records in the "battery_storage" table where the warranty is less than 10 years, setting the warranty to 10 years | CREATE TABLE battery_storage (id INT PRIMARY KEY,capacity FLOAT,warranty INT,manufacturer VARCHAR(255)); | UPDATE battery_storage SET warranty = 10 WHERE warranty < 10; |
What is the production rate of Compound Z in each factory? | CREATE TABLE factories (id INT,name VARCHAR(255)); CREATE TABLE production_rates (factory_id INT,compound_name VARCHAR(255),production_rate INT); INSERT INTO factories (id,name) VALUES (1,'Factory A'),(2,'Factory B'),(3,'Factory C'); INSERT INTO production_rates (factory_id,compound_name,production_rate) VALUES (1,'Compound X',200),(1,'Compound Y',180),(2,'Compound X',250),(2,'Compound Y',220),(3,'Compound Z',300); | SELECT factories.name, production_rates.production_rate FROM factories INNER JOIN production_rates ON factories.id = production_rates.factory_id WHERE production_rates.compound_name = 'Compound Z'; |
Which menu items are shared between Restaurant A and Restaurant B? | CREATE TABLE restaurants (id INT,name VARCHAR(255)); INSERT INTO restaurants (id,name) VALUES (1,'Restaurant A'),(2,'Restaurant B'),(3,'Restaurant C'); CREATE TABLE menu_items (id INT,name VARCHAR(255),restaurant_id INT); INSERT INTO menu_items (id,name,restaurant_id) VALUES (1,'Tacos',1),(2,'Pizza',2),(3,'Fried Rice',3),(4,'Burrito',1),(5,'Spaghetti',2); | SELECT mi1.name FROM menu_items mi1 JOIN menu_items mi2 ON mi1.name = mi2.name WHERE mi1.restaurant_id = 1 AND mi2.restaurant_id = 2; |
Which music genres have the most followers on social media? | CREATE TABLE artists (id INT,name TEXT,genre TEXT,followers INT); INSERT INTO artists (id,name,genre,followers) VALUES (1,'Artist1','Pop',5000000); INSERT INTO artists (id,name,genre,followers) VALUES (2,'Artist2','Rock',4000000); INSERT INTO artists (id,name,genre,followers) VALUES (3,'Artist3','Jazz',3000000); | SELECT genre, MAX(followers) as max_followers FROM artists GROUP BY genre; |
How many vulnerabilities were found in the last quarter for each product? | CREATE TABLE vulnerabilities (id INT,product VARCHAR(50),vulnerability_count INT,vulnerability_date DATE); INSERT INTO vulnerabilities (id,product,vulnerability_count,vulnerability_date) VALUES (1,'ProductA',25,'2022-01-01'),(2,'ProductB',35,'2022-01-02'),(3,'ProductA',30,'2022-02-01'); CREATE TABLE products (id INT,name VARCHAR(50)); INSERT INTO products (id,name) VALUES (1,'ProductA'),(2,'ProductB'),(3,'ProductC'),(4,'ProductD'); | SELECT p.name, SUM(v.vulnerability_count) as total_vulnerabilities FROM vulnerabilities v JOIN products p ON v.product = p.name WHERE v.vulnerability_date >= DATE_SUB(CURRENT_DATE, INTERVAL 3 MONTH) GROUP BY p.name; |
What is the total word count of articles that contain the word 'climate'? | CREATE TABLE Articles (id INT,title VARCHAR(255),content TEXT); INSERT INTO Articles (id,title,content) VALUES (1,'Climate Change Impact','Climate change is a global issue...'),(2,'Economic Impact','The economy is a significant...'),(3,'Climate Action','Climate action is necessary...'); | SELECT SUM(LENGTH(content) - LENGTH(REPLACE(content, 'climate', '')) + LENGTH(title)) as total_word_count FROM Articles WHERE content LIKE '%climate%' OR title LIKE '%climate%'; |
Add a new record for 'Feature Selection' in the 'algorithmic_fairness' table, with 'Disparate Impact' bias type and 'German Credit' dataset | CREATE TABLE algorithmic_fairness (id INT,algorithm VARCHAR(20),bias_type VARCHAR(30),dataset VARCHAR(20)); | INSERT INTO algorithmic_fairness (id, algorithm, bias_type, dataset) VALUES (4, 'Feature Selection', 'Disparate Impact', 'German Credit'); |
Which explainable AI models have the highest fairness scores in Asia? | CREATE TABLE explainable_ai_models (model_id INT,model_name TEXT,region TEXT,fairness_score FLOAT); INSERT INTO explainable_ai_models (model_id,model_name,region,fairness_score) VALUES (1,'Lime','Asia',0.87),(2,'Shap','Europe',0.85),(3,'Skater','Asia',0.90); | SELECT model_name, fairness_score FROM explainable_ai_models WHERE region = 'Asia' ORDER BY fairness_score DESC; |
What is the maximum number of crimes committed in a single day in each neighborhood in the last year? | CREATE TABLE neighborhoods (id INT,name TEXT);CREATE TABLE crimes (id INT,neighborhood_id INT,date DATE); | SELECT n.name, MAX(COUNT(c.id)) as max_crimes FROM neighborhoods n JOIN crimes c ON n.id = c.neighborhood_id WHERE c.date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR) GROUP BY n.id, c.date; |
Insert a new record into the "circular_economy" table with "company_name" as "OPQ Inc", "location" as "Rio de Janeiro, Brazil", and "waste_reuse_rate" as 0.28 | CREATE TABLE circular_economy (id INT PRIMARY KEY,company_name VARCHAR(255),location VARCHAR(255),waste_reuse_rate DECIMAL(5,2)); | INSERT INTO circular_economy (company_name, location, waste_reuse_rate) VALUES ('OPQ Inc', 'Rio de Janeiro, Brazil', 0.28); |
What is the total number of whales and dolphins in the Indian Ocean? | CREATE TABLE Indian_Ocean_Cetaceans (species_name TEXT,population INT); INSERT INTO Indian_Ocean_Cetaceans (species_name,population) VALUES ('Sperm Whale',15000),('Blue Whale',10000),('Dolphin',60000); | SELECT SUM(population) FROM Indian_Ocean_Cetaceans WHERE species_name = 'Sperm Whale' OR species_name = 'Blue Whale' OR species_name = 'Dolphin'; |
What is the total area of land in square kilometers used for food justice initiatives, broken down by continent? | CREATE TABLE food_justice_initiatives (id INT,name VARCHAR(255),area FLOAT,continent VARCHAR(255)); INSERT INTO food_justice_initiatives (id,name,area,continent) VALUES (1,'Initiative A',12345.6,'North America'),(2,'Initiative B',23456.7,'Europe'),(3,'Initiative C',34567.8,'Asia'); | SELECT continent, SUM(area * 0.0001) as total_area_sq_km FROM food_justice_initiatives GROUP BY continent; |
What is the total claim amount for policyholders in the 'Northeast' region? | CREATE TABLE policyholders (id INT,region VARCHAR(10));CREATE TABLE claims (id INT,policyholder_id INT,amount DECIMAL(10,2)); | SELECT region, SUM(claims.amount) as total_claim_amount FROM claims JOIN policyholders ON claims.policyholder_id = policyholders.id WHERE policyholders.region IN ('NE', 'NJ', 'NY', 'PA', 'CT', 'MA', 'VT', 'NH', 'ME') GROUP BY region; |
List the names of all visitors who attended events in 'Paris' and 'Berlin'. | CREATE TABLE Events (id INT,name TEXT,location TEXT); CREATE TABLE Visitors_Events (visitor_id INT,event_id INT); INSERT INTO Events (id,name,location) VALUES (1,'Dance Performance','Paris'),(2,'Film Festival','Berlin'); INSERT INTO Visitors_Events (visitor_id,event_id) VALUES (1,1),(1,2),(3,1); | SELECT Visitors_Events.visitor_id FROM Visitors_Events INNER JOIN Events ON Visitors_Events.event_id = Events.id WHERE Events.location IN ('Paris', 'Berlin') GROUP BY Visitors_Events.visitor_id; |
Delete the production record for well 'W004' on '2021-01-05' from the Oil_Production table? | CREATE TABLE Oil_Production (well text,production_date date,quantity real); INSERT INTO Oil_Production (well,production_date,quantity) VALUES ('W004','2021-01-01',150.5),('W004','2021-01-05',185.0); | DELETE FROM Oil_Production WHERE well = 'W004' AND production_date = '2021-01-05'; |
List all the departments in the 'government_spending' table along with the total amount spent in descending order. | CREATE TABLE government_spending (department TEXT,amount FLOAT); INSERT INTO government_spending (department,amount) VALUES ('Education',15000.0),('Defense',25000.0),('Healthcare',20000.0); | SELECT department, SUM(amount) as total_amount FROM government_spending GROUP BY department ORDER BY total_amount DESC; |
How many unique donors have contributed to environmental sustainability in Africa in the last 4 years? | CREATE TABLE donations (donor_id INT,donation_amount DECIMAL(10,2),cause TEXT,donation_date DATE); INSERT INTO donations (donor_id,donation_amount,cause,donation_date) VALUES (1,6000,'environmental sustainability','2022-09-28'); CREATE TABLE donors (donor_id INT,donor_country TEXT); INSERT INTO donors (donor_id,donor_country) VALUES (1,'Nigeria'); | SELECT COUNT(DISTINCT donors.donor_id) FROM donations JOIN donors ON donations.donor_id = donors.donor_id WHERE cause = 'environmental sustainability' AND donors.donor_country LIKE 'Africa%' AND donation_date BETWEEN DATE_SUB(NOW(), INTERVAL 4 YEAR) AND NOW(); |
Show the average soil moisture levels for each field in the past week. | CREATE TABLE soil_moisture (field TEXT,moisture INTEGER,timestamp TIMESTAMP); | SELECT field, AVG(moisture) as avg_moisture FROM soil_moisture WHERE timestamp BETWEEN DATEADD(day, -7, CURRENT_TIMESTAMP) AND CURRENT_TIMESTAMP GROUP BY field; |
List defense projects with end dates in 2023 that have a duration greater than 12 months. | CREATE TABLE defense_projects(id INT,project_name VARCHAR(50),start_date DATE,end_date DATE); INSERT INTO defense_projects(id,project_name,start_date,end_date) VALUES (1,'Project A','2021-01-01','2024-12-31'); INSERT INTO defense_projects(id,project_name,start_date,end_date) VALUES (2,'Project B','2022-01-01','2023-01-01'); | SELECT project_name FROM defense_projects WHERE YEAR(end_date) = 2023 AND DATEDIFF(end_date, start_date) > 365; |
Update the loyalty_points balance for the customer with ID 1 to 2000 | CREATE TABLE customers (customer_id INT,first_name VARCHAR(50),last_name VARCHAR(50),loyalty_points INT); INSERT INTO customers (customer_id,first_name,last_name,loyalty_points) VALUES (1,'John','Doe',1000),(2,'Jane','Doe',2000); | UPDATE customers SET loyalty_points = 2000 WHERE customer_id = 1; |
Delete all records in the 'Donors' table that are older than 5 years from the current date? | CREATE TABLE Donors (id INT,donor_name VARCHAR(255),donation_amount DECIMAL(10,2),donation_date DATE); INSERT INTO Donors (id,donor_name,donation_amount,donation_date) VALUES (1,'John Doe',500.00,'2016-01-01'),(2,'Jane Smith',300.00,'2021-02-01'),(3,'Alice Johnson',200.00,'2019-03-01'); | DELETE FROM Donors WHERE donation_date < DATE_SUB(CURDATE(), INTERVAL 5 YEAR); |
How many hydroelectric power plants were operational in Canada as of 2018? | CREATE TABLE hydro_plants (country VARCHAR(50),operational BOOLEAN,year INT); INSERT INTO hydro_plants (country,operational,year) VALUES ('Canada',true,2018),('United States',true,2018),('Brazil',true,2018),('Norway',true,2018); | SELECT COUNT(*) FROM hydro_plants WHERE country = 'Canada' AND operational = true AND year = 2018; |
What is the average carbon offset per project for carbon offset initiatives in the state of California? | CREATE TABLE carbon_offsets (project_name TEXT,state TEXT,carbon_offset INTEGER); INSERT INTO carbon_offsets (project_name,state,carbon_offset) VALUES ('Wind Farm 1','California',5000); | SELECT AVG(carbon_offset) FROM carbon_offsets WHERE state = 'California'; |
Show the number of safety tests performed by each brand, broken down by test location | CREATE TABLE safety_tests (id INT PRIMARY KEY,company VARCHAR(255),brand VARCHAR(255),test_location VARCHAR(255),test_date DATE,safety_rating INT); | SELECT brand, test_location, COUNT(*) as total_tests FROM safety_tests GROUP BY brand, test_location; |
Which countries had the highest number of security incidents related to phishing in the last year? | CREATE TABLE phishing_incidents (id INT,country VARCHAR(255),incidents INT); INSERT INTO phishing_incidents (id,country,incidents) VALUES (1,'USA',500); INSERT INTO phishing_incidents (id,country,incidents) VALUES (2,'Canada',300); INSERT INTO phishing_incidents (id,country,incidents) VALUES (3,'UK',400); | SELECT country, incidents FROM phishing_incidents WHERE date >= DATEADD(year, -1, GETDATE()) ORDER BY incidents DESC; |
Which resilience metrics have been measured for infrastructure projects in seismic zones? | CREATE TABLE infrastructure_projects (id INT,name VARCHAR(255),location VARCHAR(255),seismic_zone VARCHAR(10),resilience_metric1 FLOAT,resilience_metric2 FLOAT); | SELECT DISTINCT seismic_zone, resilience_metric1, resilience_metric2 FROM infrastructure_projects WHERE seismic_zone IS NOT NULL; |
List all community development initiatives in the Appalachian region that were funded by the federal government and non-profit organizations. | CREATE TABLE community_development (id INT,name TEXT,location TEXT,funder TEXT); INSERT INTO community_development (id,name,location,funder) VALUES (1,'Housing Renovation','Appalachian region','Federal Government'),(2,'Education Center','Appalachian region','Non-profit Organization'); | SELECT * FROM community_development WHERE location = 'Appalachian region' AND funder IN ('Federal Government', 'Non-profit Organization'); |
Which causes have more than 50% of their budget spent? | CREATE TABLE Programs (ProgramID INT,ProgramName TEXT,Cause TEXT,Budget FLOAT,Spent FLOAT); INSERT INTO Programs (ProgramID,ProgramName,Cause,Budget,Spent) VALUES (1,'Education','Children',15000.00,9000.00),(2,'Healthcare','Seniors',20000.00,15000.00); | SELECT Cause FROM Programs WHERE Spent > 0.5 * Budget; |
Find the total number of wildlife sightings in Svalbard in 2018. | CREATE TABLE WildlifeSightings (location TEXT,year INTEGER,sightings INTEGER); | SELECT SUM(sightings) FROM WildlifeSightings WHERE location = 'Svalbard' AND year = 2018; |
What is the distribution of decentralized applications by industry? | CREATE TABLE DecentralizedApps (AppID int,AppName varchar(50),Industry varchar(50)); INSERT INTO DecentralizedApps (AppID,AppName,Industry) VALUES (1,'App1','Finance'),(2,'App2','Healthcare'),(3,'App3','Finance'),(4,'App4','Entertainment'),(5,'App5','Finance'); | SELECT Industry, COUNT(*) as AppsPerIndustry, 100.0 * COUNT(*) / (SELECT COUNT(*) FROM DecentralizedApps) as Percentage FROM DecentralizedApps GROUP BY Industry; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.