instruction
stringlengths
0
1.06k
input
stringlengths
11
5.3k
response
stringlengths
2
4.44k
What is the minimum and maximum number of rural hospitals per province in Asia and how many of these hospitals are located in provinces with more than 50 rural hospitals?
CREATE TABLE rural_hospitals (hospital_id INT,hospital_name VARCHAR(100),province VARCHAR(50),num_staff INT); INSERT INTO rural_hospitals (hospital_id,hospital_name,province,num_staff) VALUES (1,'Hospital A','Jiangsu',55),(2,'Hospital B','Jiangsu',65),(3,'Hospital C','Shandong',45),(4,'Hospital D','Shandong',75);
SELECT MIN(num_staff) AS min_staff, MAX(num_staff) AS max_staff, COUNT(*) FILTER (WHERE num_staff > 50) AS hospitals_in_provinces_with_more_than_50_hospitals FROM ( SELECT province, COUNT(*) AS num_staff FROM rural_hospitals GROUP BY province ) subquery;
Which strain had the highest sales in the month of July 2021 in the state of Colorado?
CREATE TABLE sales (id INT,strain VARCHAR(50),state VARCHAR(50),month INT,year INT,revenue INT); INSERT INTO sales (id,strain,state,month,year,revenue) VALUES (1,'Blue Dream','Colorado',7,2021,150000);
SELECT strain, MAX(revenue) FROM sales WHERE state = 'Colorado' AND month = 7 GROUP BY strain;
Update rider 'Liam Johnson's' address to '789 Oak St'
CREATE TABLE riders (rider_id INT,name VARCHAR(255),address VARCHAR(255)); INSERT INTO riders (rider_id,name,address) VALUES (1,'John Smith','456 Elm St'),(2,'Jane Doe','742 Pine St'),(3,'Liam Johnson','321 Maple St');
UPDATE riders SET address = '789 Oak St' WHERE name = 'Liam Johnson';
What is the total installed renewable energy capacity in India, and how does it break down by technology?
CREATE TABLE renewable_capacity (id INT,country VARCHAR(255),technology VARCHAR(255),capacity FLOAT);
SELECT technology, SUM(capacity) FROM renewable_capacity WHERE country = 'India' GROUP BY technology;
Find the number of companies founded by underrepresented minorities in the energy sector with funding records higher than $10 million.
CREATE TABLE companies (id INT,name TEXT,industry TEXT,founding_year INT,founder_gender TEXT,underrepresented_minority BOOLEAN); INSERT INTO companies (id,name,industry,founding_year,founder_gender,underrepresented_minority) VALUES (1,'GreenTech','Energy',2017,'Male',TRUE); INSERT INTO companies (id,name,industry,found...
SELECT COUNT(*) FROM companies JOIN funding_records ON companies.id = funding_records.company_id WHERE companies.industry = 'Energy' AND companies.underrepresented_minority = TRUE AND funding_records.funding_amount > 10000000;
What is the average age of clients in India with a financial wellbeing score greater than 70?
CREATE TABLE clients (client_id INT,name VARCHAR(100),age INT,country VARCHAR(50),financial_wellbeing_score INT); INSERT INTO clients (client_id,name,age,country,financial_wellbeing_score) VALUES (13,'Ravi Patel',32,'India',80);
SELECT AVG(age) FROM clients c WHERE country = 'India' AND (SELECT COUNT(*) FROM financial_assessments fa WHERE fa.client_id = c.client_id AND fa.score > 70) > 0;
What is the total revenue by event category for events before 2022?
CREATE TABLE events (id INT,name VARCHAR(255),category VARCHAR(255),date DATE,revenue DECIMAL(10,2));
SELECT category, SUM(revenue) FROM events WHERE date < '2022-01-01' GROUP BY category;
List all mining operations in Peru and Chile with their environmental impact stats?
CREATE TABLE peruvian_departments (id INT,name VARCHAR(50)); CREATE TABLE chilean_regions (id INT,name VARCHAR(50)); CREATE TABLE mining_operations (id INT,country_id INT,region VARCHAR(20),annual_co2_emissions INT); INSERT INTO peruvian_departments (id,name) VALUES (1,'Piura'),(2,'Arequipa'); INSERT INTO chilean_regio...
SELECT m.id, m.region, m.annual_co2_emissions FROM mining_operations m INNER JOIN (SELECT * FROM peruvian_departments WHERE name IN ('Piura', 'Arequipa') UNION ALL SELECT * FROM chilean_regions WHERE name IN ('Antofagasta', 'Atacama')) c ON m.country_id = c.id;
List all socially responsible lending initiatives with a budget greater than $10 million
CREATE TABLE lending_initiatives (initiative_id INT,initiative_name VARCHAR(50),budget DECIMAL(18,2));
SELECT initiative_name FROM lending_initiatives WHERE budget > 10000000;
What is the average budget allocated for disability support programs in the APAC region?
CREATE TABLE SupportPrograms (Id INT,Program VARCHAR(50),Region VARCHAR(30),Budget DECIMAL(10,2)); INSERT INTO SupportPrograms (Id,Program,Region,Budget) VALUES (1,'Sign Language Interpreters','APAC',50000),(2,'Assistive Technology','APAC',80000),(3,'Adaptive Furniture','APAC',30000),(4,'Mobility Equipment','APAC',7000...
SELECT AVG(Budget) FROM SupportPrograms WHERE Region = 'APAC';
What is the total energy production by energy type and city?
CREATE TABLE EnergyProduction (City VARCHAR(50),EnergyType VARCHAR(50),Production FLOAT); INSERT INTO EnergyProduction (City,EnergyType,Production) VALUES ('New York','Solar',50.0),('New York','Wind',75.0),('London','Solar',80.0),('London','Wind',100.0);
SELECT City, EnergyType, SUM(Production) AS TotalProduction FROM EnergyProduction GROUP BY City, EnergyType;
What is the maximum production of Terbium in a single year?
CREATE TABLE production_data (year INT,element VARCHAR(10),quantity INT); INSERT INTO production_data (year,element,quantity) VALUES (2018,'Terbium',100),(2019,'Terbium',120),(2020,'Terbium',150),(2021,'Terbium',180);
SELECT MAX(quantity) FROM production_data WHERE element = 'Terbium';
Update the latitude and longitude for stations in the city of Tokyo, Japan in the stations table.
stations (id,name,city,country,latitude,longitude)
UPDATE stations SET latitude = 35.6895, longitude = 139.6917 WHERE stations.city = 'Tokyo';
How many electric vehicles are there in Tokyo compared to Osaka?
CREATE TABLE electric_vehicles (vehicle_id INT,type VARCHAR(20),city VARCHAR(20)); INSERT INTO electric_vehicles (vehicle_id,type,city) VALUES (1,'Car','Tokyo'),(2,'Car','Tokyo'),(3,'Bike','Tokyo'),(4,'Car','Osaka'),(5,'Bike','Osaka');
SELECT city, COUNT(*) AS total_evs FROM electric_vehicles WHERE type IN ('Car', 'Bike') GROUP BY city;
What is the average number of beds in hospitals by state?
CREATE TABLE hospitals (id INT,name TEXT,city TEXT,state TEXT,beds INT); INSERT INTO hospitals (id,name,city,state,beds) VALUES (1,'General Hospital','Miami','Florida',500); INSERT INTO hospitals (id,name,city,state,beds) VALUES (2,'Memorial Hospital','Boston','Massachusetts',600);
SELECT state, AVG(beds) as avg_beds FROM hospitals GROUP BY state;
What is the average sale price for sculptures from the 20th century?
CREATE TABLE Artworks (ArtworkID INT,Type TEXT,SalePrice INT,CreationYear INT); INSERT INTO Artworks (ArtworkID,Type,SalePrice,CreationYear) VALUES (1,'Sculpture',100000,1901);
SELECT AVG(SalePrice) FROM Artworks WHERE Type = 'Sculpture' AND CreationYear BETWEEN 1901 AND 2000;
What is the total number of cultural heritage sites in India?
CREATE TABLE cultural_sites (site_id INT,name TEXT,country TEXT); INSERT INTO cultural_sites (site_id,name,country) VALUES (1,'Taj Mahal','India'),(2,'Hawa Mahal','India'),(3,'Qutub Minar','India');
SELECT COUNT(*) FROM cultural_sites WHERE country = 'India';
Find the average budget for education services in each state, excluding states with a population under 500,000
CREATE TABLE states (state_id INT,state_name TEXT,population INT,budget FLOAT);
SELECT state_name, AVG(budget) FROM states WHERE population > 500000 GROUP BY state_name;
What is the average price of properties in neighborhoods with a co-ownership density above 0.5, that are higher than the overall average price for co-owned properties?
CREATE TABLE Neighborhood (id INT,name VARCHAR(255),city VARCHAR(255),country VARCHAR(255),co_ownership_density FLOAT); CREATE TABLE Property (id INT,neighborhood VARCHAR(255),price FLOAT,co_ownership BOOLEAN);
SELECT Neighborhood.name, AVG(Property.price) as avg_price FROM Neighborhood INNER JOIN Property ON Neighborhood.name = Property.neighborhood WHERE Neighborhood.co_ownership_density > 0.5 GROUP BY Neighborhood.name HAVING AVG(Property.price) > (SELECT AVG(Property.price) FROM Property WHERE Property.co_ownership = TRUE...
What is the maximum number of units in a single property in the 'inclusive_housing' table?
CREATE TABLE inclusive_housing (id INT,property_id INT,number_of_units INT); INSERT INTO inclusive_housing (id,property_id,number_of_units) VALUES (1,101,12),(2,102,8),(3,103,15);
SELECT MAX(number_of_units) FROM inclusive_housing;
What is the total number of heritage sites in Asia and Europe?
CREATE TABLE heritage_sites (id INT,name VARCHAR(255),country VARCHAR(255)); INSERT INTO heritage_sites (id,name,country) VALUES (1,'Historic Site','Japan'),(2,'Landmark','France'),(3,'Monument','Italy'),(4,'Archaeological Site','India'),(5,'Natural Reserve','Germany');
SELECT COUNT(*) FROM heritage_sites WHERE country = 'Japan' OR country = 'France' OR country = 'Italy' OR country = 'India' OR country = 'Germany';
Insert a new record for 'Climate Finance Australia' with '5000000' funding
CREATE TABLE climate_finance (region VARCHAR(255),funding FLOAT);
INSERT INTO climate_finance (region, funding) VALUES ('Climate Finance Australia', 5000000);
What is the total number of safety incidents for each cosmetic product type?
CREATE TABLE cosmetics (product_id INT,product_name VARCHAR(100),product_type VARCHAR(50),is_cruelty_free BOOLEAN,consumer_preference_score INT); INSERT INTO cosmetics (product_id,product_name,product_type,is_cruelty_free,consumer_preference_score) VALUES (1,'Lipstick A','Lipstick',TRUE,80),(2,'Foundation B','Foundatio...
SELECT product_type, COUNT(*) AS safety_incidents_count FROM cosmetics INNER JOIN safety_incidents ON cosmetics.product_id = safety_incidents.product_id GROUP BY product_type;
Which countries have players who play 'FPS' games?
CREATE TABLE Players (player_id INT,name VARCHAR(255),age INT,game_genre VARCHAR(255),country VARCHAR(255)); INSERT INTO Players (player_id,name,age,game_genre,country) VALUES (1,'John',27,'FPS','USA'),(2,'Sarah',30,'RPG','Canada'),(3,'Alex',22,'FPS','USA'),(4,'Max',25,'FPS','Canada'),(5,'Zoe',28,'FPS','Mexico');
SELECT DISTINCT country FROM Players WHERE game_genre = 'FPS';
What is the production output of the plant with the highest capacity?
CREATE TABLE plants (plant_id INT,plant_name VARCHAR(50),city VARCHAR(50),capacity INT,production_output INT); INSERT INTO plants (plant_id,plant_name,city,capacity,production_output) VALUES (1,'PlantA','CityX',1000,500),(2,'PlantB','CityY',700,700),(3,'PlantC','CityX',1500,600),(4,'PlantD','CityZ',800,800);
SELECT production_output FROM plants WHERE capacity = (SELECT MAX(capacity) FROM plants);
Find the maximum and minimum conservation scores for marine species.
CREATE TABLE species (id INT,name VARCHAR(255),conservation_score INT);
SELECT MAX(conservation_score) AS max_score, MIN(conservation_score) AS min_score FROM species;
Rank the construction labor statistics in Texas by the number of employees, in descending order, with a tiebreaker based on the average salary.
CREATE TABLE labor_statistics (labor_id INT,state VARCHAR(10),employees INT,salary DECIMAL(10,2)); INSERT INTO labor_statistics VALUES (1,'Texas',50,45000.00),(2,'Texas',60,42000.00);
SELECT labor_id, state, employees, salary, RANK() OVER (PARTITION BY state ORDER BY employees DESC, salary DESC) AS labor_rank FROM labor_statistics WHERE state = 'Texas';
How many agricultural innovation projects were implemented in the 'ruraldev' schema in 2017 and 2019?
CREATE TABLE ruraldev.innovation_projects (id INT,project_name VARCHAR(50),start_year INT); INSERT INTO ruraldev.innovation_projects (id,project_name,start_year) VALUES (1,'Precision Farming',2015),(2,'Drip Irrigation',2017),(3,'Vertical Farming',2020);
SELECT COUNT(*) FROM ruraldev.innovation_projects WHERE start_year IN (2017, 2019);
List the menu categories and their total inventory quantity, from the menu_item_dim and inventory_fact tables, grouped by menu_category.
CREATE TABLE customer_fact (customer_id INT,sale_id INT,customer_age INT,customer_gender VARCHAR,customer_country VARCHAR);
SELECT m.menu_category, SUM(i.inventory_quantity) as total_inventory_quantity FROM menu_item_dim m JOIN inventory_fact i ON m.menu_item_id = i.menu_item_id GROUP BY m.menu_category;
Display the total number of organic and non-organic produce suppliers in the produce_suppliers table.
CREATE TABLE produce_suppliers (supplier_id INT,supplier_name VARCHAR(255),is_organic BOOLEAN);
SELECT SUM(CASE WHEN is_organic THEN 1 ELSE 0 END) as organic_count, SUM(CASE WHEN NOT is_organic THEN 1 ELSE 0 END) as non_organic_count FROM produce_suppliers;
How many satellites were launched in a given year?
CREATE TABLE satellites (id INT,name VARCHAR(255),country VARCHAR(255),launch_date DATE); INSERT INTO satellites (id,name,country,launch_date) VALUES (1,'Satellite1','USA','2010-01-01'); INSERT INTO satellites (id,name,country,launch_date) VALUES (2,'Satellite2','Russia','2015-05-12');
SELECT COUNT(*) FROM satellites WHERE YEAR(launch_date) = 2010;
What is the prevalence of heart disease in rural Oregon compared to urban Oregon?
CREATE TABLE health_stats (id INT,location VARCHAR(20),disease VARCHAR(20),prevalence FLOAT); INSERT INTO health_stats (id,location,disease,prevalence) VALUES (1,'rural Oregon','heart disease',0.08);
SELECT location, disease, prevalence FROM health_stats WHERE disease = 'heart disease' AND location IN ('rural Oregon', 'urban Oregon');
How many economic diversification projects were completed before their scheduled end date in the rural region of 'Puno', Peru between 2015 and 2018?
CREATE TABLE economic_diversification (id INT,project_name VARCHAR(100),project_location VARCHAR(100),project_status VARCHAR(50),start_date DATE,end_date DATE);
SELECT COUNT(*) FROM economic_diversification WHERE project_location = 'Puno' AND project_status = 'completed' AND start_date <= '2018-12-31' AND end_date >= '2015-01-01';
Identify countries that source both organic and non-organic ingredients.
CREATE TABLE ingredient_sourcing (product_id INT,ingredient_id INT,is_organic BOOLEAN,source_country TEXT); INSERT INTO ingredient_sourcing VALUES (1,1,true,'Mexico'),(2,2,false,'Brazil'),(3,3,true,'Indonesia'),(4,4,false,'Peru'),(5,1,true,'Nigeria'),(6,5,false,'Mexico');
SELECT source_country FROM ingredient_sourcing WHERE is_organic = true INTERSECT SELECT source_country FROM ingredient_sourcing WHERE is_organic = false
Calculate the average daily transaction value for each customer in the last month.
CREATE TABLE customer_transactions (transaction_id INT,customer_id INT,transaction_date DATE,transaction_value DECIMAL(10,2)); INSERT INTO customer_transactions (transaction_id,customer_id,transaction_date,transaction_value) VALUES (1,1,'2022-01-01',100.00),(2,1,'2022-02-01',200.00),(3,2,'2022-03-01',150.00),(4,1,'2022...
SELECT customer_id, AVG(transaction_value) FROM customer_transactions WHERE transaction_date >= DATE_SUB(NOW(), INTERVAL 1 MONTH) GROUP BY customer_id;
List the top 5 species with the highest number of protection programs in place.
CREATE TABLE Species (id INT PRIMARY KEY,name VARCHAR(50),family VARCHAR(50),conservation_status VARCHAR(50)); CREATE TABLE Threats (id INT PRIMARY KEY,species_id INT,threat_type VARCHAR(50),severity VARCHAR(50)); CREATE TABLE Protection_Programs (id INT PRIMARY KEY,species_id INT,program_name VARCHAR(50),start_year IN...
SELECT Species.name, COUNT(Protection_Programs.id) AS program_count FROM Species LEFT JOIN Protection_Programs ON Species.id = Protection_Programs.species_id GROUP BY Species.name ORDER BY program_count DESC LIMIT 5;
How many people attended the 'Film Festival' event by age group?
CREATE TABLE Events (event_id INT,event_name VARCHAR(50)); CREATE TABLE Attendees (attendee_id INT,event_id INT,age INT); INSERT INTO Events (event_id,event_name) VALUES (7,'Film Festival'); INSERT INTO Attendees (attendee_id,event_id,age) VALUES (10,7,22),(11,7,32),(12,7,42);
SELECT e.event_name, a.age, COUNT(a.attendee_id) FROM Events e JOIN Attendees a ON e.event_id = a.event_id WHERE e.event_name = 'Film Festival' GROUP BY e.event_name, a.age;
What is the maximum depth of all stations in the Mariana Trench Mapping Project?
CREATE TABLE MarianaTrench (id INT,name TEXT,latitude REAL,longitude REAL,depth REAL); INSERT INTO MarianaTrench (id,name,latitude,longitude,depth) VALUES (1,'Challenger Deep',11.2161,142.7913,10972); INSERT INTO MarianaTrench (id,name,latitude,longitude,depth) VALUES (2,'Sirena Deep',11.2121,142.7876,10594);
SELECT MAX(depth) FROM MarianaTrench;
Delete the record of the cybersecurity incident with ID 2.
CREATE TABLE cybersecurity_incidents (id INT,title VARCHAR(255),description TEXT,region VARCHAR(255),countermeasure TEXT);INSERT INTO cybersecurity_incidents (id,title,description,region,countermeasure) VALUES (1,'Incident A','Details about Incident A','Asia-Pacific','Countermeasure A'),(2,'Incident B','Details about I...
DELETE FROM cybersecurity_incidents WHERE id = 2;
What is the number of mental health parity violations in each state?
CREATE TABLE mental_health_parity (state VARCHAR(2),violations INT); INSERT INTO mental_health_parity (state,violations) VALUES ('CA',25),('NY',30),('TX',15);
SELECT state, violations FROM mental_health_parity;
What is the total number of hours spent on professional development by teachers in the last quarter?
CREATE TABLE hours (id INT,teacher_id INT,date DATE,hours_spent DECIMAL(5,2)); INSERT INTO hours (id,teacher_id,date,hours_spent) VALUES (1,1001,'2022-01-01',2.5),(2,1001,'2022-02-15',3.0),(3,1002,'2022-03-10',2.0),(4,1003,'2022-04-01',4.0);
SELECT SUM(hours_spent) as total_hours FROM hours WHERE date >= DATEADD(quarter, -1, GETDATE());
How much did the company spend on R&D in 2020?
CREATE TABLE company_financials (financial_year INT,rd_expenses FLOAT); INSERT INTO company_financials (financial_year,rd_expenses) VALUES (2018,5000000),(2019,6000000),(2020,8000000),(2021,9000000);
SELECT SUM(rd_expenses) FROM company_financials WHERE financial_year = 2020;
Get the number of energy efficiency projects in each continent
CREATE TABLE energy_efficiency_projects (project_name VARCHAR(50),location VARCHAR(50)); INSERT INTO energy_efficiency_projects (project_name,location) VALUES ('Project A','Asia-Pacific'),('Project B','Europe'),('Project C','Asia-Pacific'),('Project D','Americas'),('Project E','Africa');
SELECT location, COUNT(project_name) FROM energy_efficiency_projects GROUP BY location;
What is the average time to complete a production cycle for each machine?
CREATE TABLE machines(id INT,name TEXT,location TEXT);CREATE TABLE cycles(id INT,machine_id INT,start_time TIMESTAMP,end_time TIMESTAMP);INSERT INTO machines(id,name,location) VALUES (1,'Machine A','Location A'),(2,'Machine B','Location B'); INSERT INTO cycles(id,machine_id,start_time,end_time) VALUES (1,1,'2021-02-01 ...
SELECT machine_id, AVG(TIMESTAMPDIFF(MINUTE, start_time, end_time)) as avg_time FROM cycles GROUP BY machine_id;
Add a new row to the 'digital_divide_stats' table with the following data: 'Rural India', 'Limited internet access', '2022-01-01'
CREATE TABLE digital_divide_stats (region VARCHAR(50),issue VARCHAR(50),last_update DATETIME);
INSERT INTO digital_divide_stats (region, issue, last_update) VALUES ('Rural India', 'Limited internet access', '2022-01-01');
How many people in the vaccinations table have received their first dose, but not their second dose?
CREATE TABLE vaccinations (person_id INT,first_dose DATE,second_dose DATE);
SELECT COUNT(*) FROM vaccinations WHERE first_dose IS NOT NULL AND second_dose IS NULL;
Identify the number of virtual tours in Asia with over 1000 users.
CREATE TABLE virtual_tours (tour_id INT,tour_name TEXT,region TEXT,user_count INT); INSERT INTO virtual_tours (tour_id,tour_name,region,user_count) VALUES (1,'Virtual Tokyo Tour','Asia',1200),(2,'Paris Cultural Tour','Europe',800);
SELECT COUNT(*) FROM virtual_tours WHERE region = 'Asia' AND user_count > 1000;
Get the smart city project names and costs in the CityOfFuture schema
CREATE SCHEMA CityOfFuture; USE CityOfFuture; CREATE TABLE SmartCityProjects (id INT,project_name VARCHAR(100),cost DECIMAL(10,2)); INSERT INTO SmartCityProjects (id,project_name,cost) VALUES (1,'Smart Lighting',50000.00),(2,'Smart Waste Management',25000.00);
SELECT project_name, cost FROM CityOfFuture.SmartCityProjects;
What is the maximum CO2 emission of buildings in New York?
CREATE TABLE BuildingCO2Emissions (id INT,city VARCHAR(20),co2_emission FLOAT); INSERT INTO BuildingCO2Emissions (id,city,co2_emission) VALUES (1,'New York',1200.5),(2,'New York',1300.2),(3,'Los Angeles',1100.3);
SELECT MAX(co2_emission) FROM BuildingCO2Emissions WHERE city = 'New York';
What is the total revenue generated by each investment type in the last year?
CREATE TABLE investment_type (investment_id INT,investment_type VARCHAR(50),monthly_rate DECIMAL(5,2),start_date DATE,end_date DATE); INSERT INTO investment_type (investment_id,investment_type,monthly_rate,start_date,end_date) VALUES (1,'Network Upgrade',10000.00,'2022-01-01','2022-12-31'),(2,'Marketing Campaign',5000....
SELECT investment_type, EXTRACT(YEAR FROM start_date) as year, SUM(monthly_rate * DATEDIFF('month', start_date, end_date)) as total_revenue FROM investment_type GROUP BY investment_type, EXTRACT(YEAR FROM start_date);
What is the total number of art pieces and historical artifacts in the database, excluding any duplicate entries?
CREATE TABLE ArtCollection(id INT,type VARCHAR(20),artist VARCHAR(30)); INSERT INTO ArtCollection(id,type,artist) VALUES (1,'Painting','Braque'),(2,'Sculpture','Arp'),(3,'Painting','Braque'),(4,'Installation','Serra');
SELECT COUNT(DISTINCT type, artist) FROM ArtCollection;
What is the total number of digital assets launched by country in descending order?
CREATE TABLE DigitalAssets (AssetID int,AssetName varchar(50),Country varchar(50)); INSERT INTO DigitalAssets (AssetID,AssetName,Country) VALUES (1,'Asset1','USA'),(2,'Asset2','Canada'),(3,'Asset3','USA');
SELECT Country, COUNT(*) as TotalAssets FROM DigitalAssets GROUP BY Country ORDER BY TotalAssets DESC;
Insert a new language preservation record for 'Papua New Guinea', 'Tok Pisin', 'Endangered'.
CREATE TABLE LanguagePreservation (id INT,country VARCHAR(50),language VARCHAR(50),status VARCHAR(50));
INSERT INTO LanguagePreservation (id, country, language, status) VALUES (1, 'Papua New Guinea', 'Tok Pisin', 'Endangered');
What is the average recycling rate (%) for urban areas in 2019?
CREATE TABLE recycling_rates(region VARCHAR(255),year INT,recycling_rate FLOAT);
SELECT AVG(recycling_rate) FROM recycling_rates WHERE region LIKE '%urban%' AND year = 2019;
List the total number of cultural competency training sessions and the average sessions per community health worker by state in 2020.
CREATE TABLE cultural_competency_training_sessions (id INT,state VARCHAR(50),year INT,worker_id INT,sessions INT); INSERT INTO cultural_competency_training_sessions (id,state,year,worker_id,sessions) VALUES (1,'California',2020,1,12),(2,'California',2020,2,15),(3,'California',2020,3,18),(4,'Texas',2020,1,10),(5,'Texas'...
SELECT state, SUM(sessions) as total_sessions, AVG(sessions) as avg_sessions_per_worker FROM cultural_competency_training_sessions WHERE year = 2020 GROUP BY state;
How many wind farms have been completed in the state of Texas since 2010?
CREATE TABLE wind_farms (id INT,name VARCHAR(50),state VARCHAR(50),capacity FLOAT,operational_year INT);
SELECT COUNT(*) FROM wind_farms WHERE state = 'Texas' AND operational_year >= 2010;
Add a new record into the "exhibits" table for an exhibit named "Impressionist Masterpieces" with a start date of 2022-06-01 and end date of 2023-05-31
CREATE TABLE exhibits (exhibit_id INT PRIMARY KEY,name VARCHAR(100),start_date DATE,end_date DATE,venue_id INT,FOREIGN KEY (venue_id) REFERENCES venue(venue_id));
INSERT INTO exhibits (exhibit_id, name, start_date, end_date, venue_id) VALUES ((SELECT MAX(exhibit_id) FROM exhibits) + 1, 'Impressionist Masterpieces', '2022-06-01', '2023-05-31', (SELECT venue_id FROM venue WHERE name = 'Metropolitan Museum'));
Update records in recycling_rates table where location is 'London' and recycling rate is 28%
CREATE TABLE recycling_rates (location VARCHAR(50),rate DECIMAL(5,2));
UPDATE recycling_rates SET rate = 0.28 WHERE location = 'London';
How many players are registered in each region?
CREATE TABLE player_registration (player_id INT,region VARCHAR(255)); INSERT INTO player_registration (player_id,region) VALUES (1,'North America'),(2,'Europe'),(3,'Asia');
SELECT region, COUNT(player_id) as num_players FROM player_registration GROUP BY region;
What is the maximum funding received in a single round by startups founded by individuals who identify as LGBTQ+ in the fintech industry?
CREATE TABLE startups(id INT,name TEXT,founders TEXT,founding_year INT,industry TEXT); INSERT INTO startups VALUES (1,'StartupA','Alex,Bob',2010,'Fintech'); INSERT INTO startups VALUES (2,'StartupB','Eve',2015,'Healthcare'); INSERT INTO startups VALUES (3,'StartupC','Carlos',2018,'Tech'); CREATE TABLE investments(start...
SELECT MAX(funding) FROM (SELECT startup_id, funding FROM investments JOIN startups ON investments.startup_id = startups.id WHERE startups.industry = 'Fintech' AND founders LIKE '%Alex%' GROUP BY startup_id, round) subquery;
Add new compliance data for 'Oregon'
CREATE TABLE compliance (id INT,state TEXT,violation TEXT,date DATE); INSERT INTO compliance (id,state,violation,date) VALUES (1,'California','Pesticide Use','2021-02-01');
INSERT INTO compliance (id, state, violation, date) VALUES (2, 'Oregon', 'Improper Labeling', '2021-03-15');
List all clinical trials with a status of 'Completed' or 'Terminated' in the USA.
CREATE TABLE clinical_trials(trial_id INT,country VARCHAR(255),status VARCHAR(255)); INSERT INTO clinical_trials(trial_id,country,status) VALUES (1,'USA','Completed'),(2,'Canada','Recruiting'),(3,'USA','Terminated');
SELECT * FROM clinical_trials WHERE country = 'USA' AND status IN ('Completed', 'Terminated');
What is the earliest launch date of any satellite?
CREATE TABLE SatelliteTimeline (Id INT,Name VARCHAR(50),LaunchDate DATE); INSERT INTO SatelliteTimeline (Id,Name,LaunchDate) VALUES (1,'Sputnik 1','1957-10-04'),(2,'Explorer 1','1958-01-31');
SELECT MIN(LaunchDate) FROM SatelliteTimeline;
How many eco-friendly materials are sourced by region?
CREATE TABLE sourcing (region VARCHAR(255),material VARCHAR(255),eco_friendly BOOLEAN);
SELECT region, COUNT(*) as eco_friendly_materials_count FROM sourcing WHERE eco_friendly = TRUE GROUP BY region;
What's the average like count of posts by 'UserA'?
CREATE TABLE social_posts (id INT,post TEXT,user TEXT,like_count INT); INSERT INTO social_posts (id,post,user,like_count) VALUES (1,'Post1','UserA',10),(2,'Post2','UserB',5);
SELECT AVG(like_count) FROM social_posts WHERE user = 'UserA';
What is the total installed capacity of solar farms in India and China?
CREATE TABLE solar_farms (id INT,country VARCHAR(255),name VARCHAR(255),capacity FLOAT); INSERT INTO solar_farms (id,country,name,capacity) VALUES (1,'India','Solarfarm A',100.2),(2,'China','Solarfarm B',200.5),(3,'India','Solarfarm C',150.8);
SELECT SUM(capacity) FROM solar_farms WHERE country IN ('India', 'China');
Count the number of transactions for socially responsible lending initiatives in the United Kingdom over the past year.
CREATE TABLE transactions (id INT,initiative_type VARCHAR(255),transaction_date DATE,country VARCHAR(255));
SELECT COUNT(*) FROM transactions WHERE initiative_type = 'socially responsible lending' AND country = 'United Kingdom' AND transaction_date >= DATEADD(year, -1, GETDATE());
What is the minimum investment amount in startups founded by BIPOC entrepreneurs in the gaming industry since 2017?
CREATE TABLE StartupInvestments(id INT,name TEXT,industry TEXT,investment_amount INT,racial_ethnicity TEXT,founding_year INT); INSERT INTO StartupInvestments VALUES (1,'GameChanger','Gaming',7000000,'BIPOC',2018),(2,'GreenTech','CleanTech',8000000,'White',2016),(3,'AIStudio','AI',12000000,'Asian',2020),(4,'RenewableE...
SELECT MIN(investment_amount) FROM StartupInvestments WHERE racial_ethnicity = 'BIPOC' AND industry = 'Gaming' AND founding_year >= 2017;
Who are the top 3 investors by total investment amount in the renewable energy sector since 2019?
CREATE TABLE companies (id INT,name VARCHAR(30)); INSERT INTO companies (id,name) VALUES (1,'ABC Corp'),(2,'XYZ Inc'),(3,'DEF Investments'),(4,'GHI Fund'); CREATE TABLE investments (id INT,company_id INT,sector_id INT,investment_amount DECIMAL,investment_date DATE); INSERT INTO investments (id,company_id,sector_id,inve...
SELECT companies.name, SUM(investments.investment_amount) as total_investment FROM companies INNER JOIN investments ON companies.id = investments.company_id WHERE investments.sector_id IN (SELECT id FROM sectors WHERE sector = 'renewable energy') AND investments.investment_date >= '2019-01-01' GROUP BY companies.name O...
Insert a new artifact 'Ancient Coin' from the 'EuropeExcavation' site, type 'Coin', quantity 1.
CREATE TABLE ExcavationSite (SiteID INT PRIMARY KEY,SiteName VARCHAR(100),Location VARCHAR(100),StartDate DATE,EndDate DATE);CREATE TABLE Artifact (ArtifactID INT PRIMARY KEY,SiteID INT,ArtifactName VARCHAR(100),Description TEXT,FOREIGN KEY (SiteID) REFERENCES ExcavationSite(SiteID));CREATE TABLE ArtifactType (Artifact...
INSERT INTO Artifact (ArtifactID, SiteID, ArtifactName, Description) VALUES (1415, (SELECT SiteID FROM ExcavationSite WHERE SiteName = 'EuropeExcavation'), 'Ancient Coin', 'An ancient coin from the EuropeExcavation site.');INSERT INTO ArtifactDetail (ArtifactID, ArtifactTypeID, Quantity) VALUES (1415, (SELECT ArtifactT...
Find the average salary of healthcare workers in hospitals, excluding doctors.
CREATE TABLE healthcare_workers (name VARCHAR(255),title VARCHAR(255),city VARCHAR(255),salary DECIMAL(10,2),workplace VARCHAR(255)); INSERT INTO healthcare_workers (name,title,city,salary,workplace) VALUES ('John Doe','Doctor','Miami',200000.00,'Hospital'); INSERT INTO healthcare_workers (name,title,city,salary,workpl...
SELECT AVG(salary) FROM healthcare_workers WHERE workplace = 'Hospital' AND title != 'Doctor';
How many job offers were made to candidates who identify as veterans in the past quarter, by hiring manager?
CREATE TABLE JobOffers (OfferID INT,FirstName VARCHAR(50),LastName VARCHAR(50),HiringManager VARCHAR(50),DateOffered DATE,Veteran VARCHAR(10));
SELECT HiringManager, COUNT(*) as Num_Offers FROM JobOffers WHERE Veteran = 'Yes' AND DateOffered >= DATEADD(quarter, -1, GETDATE()) GROUP BY HiringManager;
Find the number of threat intelligence reports created per day in the last month, excluding weekends.
CREATE TABLE threat_intelligence (report_id INT,creation_date DATE); INSERT INTO threat_intelligence VALUES (1,'2022-02-01'),(2,'2022-02-02'),(3,'2022-02-05');
SELECT creation_date, COUNT(*) OVER (PARTITION BY creation_date) FROM threat_intelligence WHERE creation_date >= CURRENT_DATE - INTERVAL '1 month' AND EXTRACT(DOW FROM creation_date) < 5;
What is the total number of games played by each team in the FIFA World Cup?
CREATE TABLE teams (team_id INT,team_name VARCHAR(100)); CREATE TABLE games (game_id INT,home_team INT,away_team INT);
SELECT teams.team_name, COUNT(games.game_id) as total_games FROM teams INNER JOIN games ON teams.team_id IN (games.home_team, games.away_team) GROUP BY teams.team_name;
What is the maximum number of security incidents recorded in a single day?
CREATE TABLE security_incidents (id INT,incident_date DATE,incident_count INT); INSERT INTO security_incidents (id,incident_date,incident_count) VALUES (1,'2022-01-01',5),(2,'2022-01-02',3),(3,'2022-01-03',7);
SELECT MAX(incident_count) FROM security_incidents;
Calculate the number of traditional art pieces in each UNESCO World Heritage site, ranked by their total value.
CREATE TABLE HeritageSites (SiteID INT,Name VARCHAR(50),Location VARCHAR(50),ArtPieceID INT); INSERT INTO HeritageSites VALUES (1,'Taj Mahal','India',101),(2,'Machu Picchu','Peru',201),(3,'Angkor Wat','Cambodia',301); CREATE TABLE ArtPieces (ArtPieceID INT,Name VARCHAR(50),Type VARCHAR(50),Value INT); INSERT INTO ArtPi...
SELECT hs.Name AS HeritageSite, COUNT(ap.ArtPieceID) AS ArtPieces, SUM(ap.Value) AS TotalValue FROM HeritageSites hs JOIN ArtPieces ap ON hs.ArtPieceID = ap.ArtPieceID GROUP BY hs.Name ORDER BY TotalValue DESC;
What is the minimum amount of funds raised for disaster relief efforts in the Philippines in the year 2019?
CREATE TABLE disaster_funds(id INT,disaster_name TEXT,country TEXT,amount FLOAT,year INT); INSERT INTO disaster_funds(id,disaster_name,country,amount,year) VALUES (1,'Typhoon','Philippines',300000.00,2019),(2,'Volcano','Philippines',500000.00,2020),(3,'Earthquake','Philippines',400000.00,2018);
SELECT MIN(amount) FROM disaster_funds WHERE country = 'Philippines' AND year = 2019;
Who are the top 3 suppliers of recycled materials in the US?
CREATE TABLE recycled_material_suppliers (supplier_id INT,supplier_name VARCHAR(50),material VARCHAR(50),country VARCHAR(50)); INSERT INTO recycled_material_suppliers (supplier_id,supplier_name,material,country) VALUES (1,'Green Supplies','Recycled Plastic','USA'),(2,'EcoTech','Recycled Metal','Canada'),(3,'Sustainable...
SELECT supplier_name, material FROM recycled_material_suppliers WHERE country = 'USA' LIMIT 3;
How many community development initiatives were implemented in Mexico in 2020, with at least 500 participants?
CREATE TABLE community_development (country TEXT,year INT,participants INT); INSERT INTO community_development (country,year,participants) VALUES ('Mexico',2018,300),('Mexico',2018,600),('Mexico',2019,400),('Mexico',2019,700),('Mexico',2020,500),('Mexico',2020,550),('Mexico',2020,600),('Mexico',2021,450),('Mexico',2021...
SELECT COUNT(*) FROM community_development WHERE country = 'Mexico' AND year = 2020 AND participants >= 500;
How many mental health campaigns were launched in New York and Texas?
CREATE TABLE campaigns (id INT,name TEXT,state TEXT); INSERT INTO campaigns (id,name,state) VALUES (1,'Campaign A','New York'); INSERT INTO campaigns (id,name,state) VALUES (2,'Campaign B','Texas'); INSERT INTO campaigns (id,name,state) VALUES (3,'Campaign C','New York');
SELECT COUNT(*) FROM campaigns WHERE campaigns.state IN ('New York', 'Texas');
How many volunteers are needed on average per event for the Arts and Culture programs in 2023?
CREATE TABLE Volunteers (VolunteerID INT,Program VARCHAR(50),EventDate DATE); INSERT INTO Volunteers (VolunteerID,Program,EventDate) VALUES (1,'Arts and Culture','2023-01-01'),(2,'Arts and Culture','2023-02-01'); CREATE TABLE Events (EventID INT,Program VARCHAR(50),EventDate DATE,NumberOfVolunteers INT); INSERT INTO Ev...
SELECT Program, AVG(NumberOfVolunteers) as AvgVolunteers FROM Events INNER JOIN Volunteers ON Events.Program = Volunteers.Program AND Events.EventDate = Volunteers.EventDate WHERE Program = 'Arts and Culture' AND Year(EventDate) = 2023 GROUP BY Program;
What is the name and location of the rural clinic with the fewest medical professionals in the state of California?
CREATE TABLE medical_professionals (id INT,name VARCHAR(50),clinic_id INT); CREATE TABLE clinics (id INT,name VARCHAR(50),location VARCHAR(50)); INSERT INTO medical_professionals (id,name,clinic_id) VALUES (1,'Dr. Smith',1),(2,'Dr. Johnson',1),(3,'Dr. Lee',2); INSERT INTO clinics (id,name,location) VALUES (1,'Clinic A'...
SELECT clinics.name, clinics.location FROM clinics JOIN (SELECT clinic_id, COUNT(*) as num_of_professionals FROM medical_professionals GROUP BY clinic_id ORDER BY num_of_professionals LIMIT 1) AS subquery ON clinics.id = subquery.clinic_id;
What is the average media literacy score for each region?
CREATE TABLE countries (id INT,name TEXT,region TEXT,media_literacy_score INT); INSERT INTO countries VALUES (1,'USA','North America',75),(2,'Canada','North America',85),(3,'Mexico','North America',65),(4,'Brazil','South America',55),(5,'Argentina','South America',60),(6,'France','Europe',80),(7,'Germany','Europe',85),...
SELECT region, AVG(media_literacy_score) as avg_score FROM countries GROUP BY region;
What is the total production cost for fair trade products in the 'Clothing' category?
CREATE TABLE products (product_id INT,product_name VARCHAR(255),production_cost DECIMAL(5,2),category VARCHAR(255),fair_trade BOOLEAN); INSERT INTO products (product_id,product_name,production_cost,category,fair_trade) VALUES (1,'Fair Trade Dress',19.99,'Clothing',true); INSERT INTO products (product_id,product_name,pr...
SELECT SUM(production_cost) FROM products WHERE fair_trade = true AND category = 'Clothing';
How many space missions were launched by each space agency, according to the Space_Agencies and Space_Missions tables?
CREATE TABLE Space_Agencies (ID INT,Agency_Name VARCHAR(255),Num_Missions INT); INSERT INTO Space_Agencies (ID,Agency_Name,Num_Missions) VALUES (1,'NASA',100); CREATE TABLE Space_Missions (ID INT,Mission_Name VARCHAR(255),Agency_ID INT); INSERT INTO Space_Missions (ID,Mission_Name,Agency_ID) VALUES (1,'Apollo 11',1); C...
SELECT Agency_Name, Num_Missions FROM Agency_Mission_Counts;
What is the total grant amount awarded to faculty members in the Computer Science department in 2020?
CREATE TABLE Grants (GrantID INT,AwardYear INT,Department VARCHAR(50),Amount DECIMAL(10,2)); INSERT INTO Grants (GrantID,AwardYear,Department,Amount) VALUES (1,2020,'Mathematics',50000),(2,2021,'Physics',60000),(3,2020,'Mathematics',55000),(4,2021,'Computer Science',70000),(5,2020,'Computer Science',80000);
SELECT SUM(Amount) FROM Grants WHERE Department = 'Computer Science' AND AwardYear = 2020;
Which causes received donations in both 2021 and 2022?
CREATE TABLE donations (id INT,donor VARCHAR(50),cause VARCHAR(50),amount DECIMAL(10,2),donation_date DATE); INSERT INTO donations (id,donor,cause,amount,donation_date) VALUES (1,'John Doe','Education',500,'2022-01-05'); INSERT INTO donations (id,donor,cause,amount,donation_date) VALUES (2,'Jane Smith','Health',300,'20...
SELECT cause FROM donations WHERE YEAR(donation_date) IN (2021, 2022) GROUP BY cause HAVING COUNT(DISTINCT YEAR(donation_date)) = 2;
What is the number of menu items that are both vegan and gluten-free?
CREATE TABLE MenuItems (MenuItemID int,MenuItemName varchar(255),MenuItemType varchar(255),DietaryRestrictions varchar(255)); INSERT INTO MenuItems (MenuItemID,MenuItemName,MenuItemType,DietaryRestrictions) VALUES (1,'Margherita Pizza','Entree','None'),(2,'Spaghetti Bolognese','Entree','None'),(3,'Caprese Salad','Appet...
SELECT COUNT(*) FROM MenuItems WHERE DietaryRestrictions = 'Vegan, Gluten-free';
What is the percentage of events with an attendance of over 200 that were held in the Americas in 2021?
CREATE TABLE Events (EventID int,EventDate date,EventAttendance int,EventLocation varchar(50));
SELECT (COUNT(*) / (SELECT COUNT(*) FROM Events WHERE EventDate BETWEEN '2021-01-01' AND '2021-12-31' AND EventAttendance > 200)) * 100.0 AS Percentage FROM Events WHERE EventDate BETWEEN '2021-01-01' AND '2021-12-31' AND EventLocation LIKE '%Americas%' AND EventAttendance > 200;
Show machines produced by companies with a strong commitment to ethical manufacturing.
CREATE TABLE machines (id INT PRIMARY KEY,model TEXT,year INT,manufacturer TEXT,ethical_manufacturing BOOLEAN); CREATE TABLE maintenance (id INT PRIMARY KEY,machine_id INT,date DATE,FOREIGN KEY (machine_id) REFERENCES machines(id));
SELECT machines.model, machines.year, machines.manufacturer FROM machines WHERE machines.ethical_manufacturing = TRUE;
What is the average daily waste generation for each municipality?
CREATE TABLE municipalities (id INT,name VARCHAR(255),population INT); INSERT INTO municipalities (id,name,population) VALUES (1,'CityA',50000),(2,'CityB',75000),(3,'CityC',100000); CREATE TABLE waste_generation (municipality_id INT,date DATE,generation FLOAT); INSERT INTO waste_generation (municipality_id,date,generat...
SELECT municipality_id, AVG(generation) OVER (PARTITION BY municipality_id) as avg_daily_generation FROM waste_generation;
What is the average gas price for transactions on the Solana network, grouped by week?
CREATE TABLE solana_transactions (transaction_id INT,tx_time TIMESTAMP,gas_price DECIMAL(10,2)); INSERT INTO solana_transactions (transaction_id,tx_time,gas_price) VALUES (1,'2022-01-01 10:00:00',0.01),(2,'2022-01-02 11:00:00',0.02),(3,'2022-01-03 12:00:00',0.03),(4,'2022-01-04 13:00:00',0.04),(5,'2022-01-05 14:00:00',...
SELECT DATE_FORMAT(tx_time, '%Y-%u') AS week, AVG(gas_price) AS avg_gas_price FROM solana_transactions GROUP BY week;
What is the total number of cyber threats detected by the military in the Middle East in the last 6 months?
CREATE TABLE CyberThreats (id INT,country VARCHAR(50),threat_type VARCHAR(50),threat_date DATE); INSERT INTO CyberThreats (id,country,threat_type,threat_date) VALUES (1,'Iraq','Phishing','2021-01-12'),(2,'Saudi Arabia','Ransomware','2021-03-25'),(3,'Israel','Malware','2021-05-08');
SELECT SUM(frequency) FROM (SELECT COUNT(*) AS frequency FROM CyberThreats WHERE country LIKE '%Middle East%' AND threat_date >= DATE_SUB(CURDATE(), INTERVAL 6 MONTH) GROUP BY threat_type) AS subquery;
What is the total production output for all factories in France?
CREATE TABLE factory (id INT,name TEXT,sector TEXT,country TEXT); INSERT INTO factory (id,name,sector,country) VALUES (1,'FactoryA','automotive','France'),(2,'FactoryB','aerospace','France'),(3,'FactoryC','electronics','Germany'); CREATE TABLE production (factory_id INT,output REAL); INSERT INTO production (factory_id,...
SELECT SUM(production.output) FROM production INNER JOIN factory ON production.factory_id = factory.id WHERE factory.country = 'France';
Local economic impact of sustainable tourism in each state?
CREATE TABLE local_economy_extended (state TEXT,impact FLOAT,year INT); INSERT INTO local_economy_extended (state,impact,year) VALUES ('New York',50000.0,2021),('California',75000.0,2021),('Texas',60000.0,2021);
SELECT state, impact FROM local_economy_extended WHERE year = 2021 GROUP BY state;
What was the total playing time for Team E?
CREATE TABLE Team_E (match_id INT,playing_time INT); INSERT INTO Team_E (match_id,playing_time) VALUES (1,180),(2,190),(3,200);
SELECT SUM(playing_time) FROM Team_E;
What was the average cost of rural community development initiatives in Colombia in 2017?
CREATE TABLE Community_Development_Colombia (id INT,country VARCHAR(50),year INT,cost FLOAT); INSERT INTO Community_Development_Colombia (id,country,year,cost) VALUES (1,'Colombia',2017,15000.0),(2,'Colombia',2018,18000.0),(3,'Colombia',2019,20000.0);
SELECT AVG(cost) FROM Community_Development_Colombia WHERE country = 'Colombia' AND year = 2017;
What is the maximum price of linen garments sold in the UK?
CREATE TABLE sales (id INT,price DECIMAL(5,2),material VARCHAR(20),country VARCHAR(20)); INSERT INTO sales (id,price,material,country) VALUES (1,75.00,'linen','UK'); -- additional rows removed for brevity;
SELECT MAX(price) FROM sales WHERE material = 'linen' AND country = 'UK';
What is the total quantity of items stored in each warehouse for each category of products?
CREATE TABLE warehouse (id INT,name VARCHAR(50),location VARCHAR(50)); INSERT INTO warehouse (id,name,location) VALUES (1,'Warehouse A','City A'),(2,'Warehouse B','City B'); CREATE TABLE inventory (id INT,warehouse_id INT,product VARCHAR(50),quantity INT); INSERT INTO inventory (id,warehouse_id,product,quantity) VALUES...
SELECT w.name, p.category, SUM(i.quantity) as total_quantity FROM inventory i JOIN warehouse w ON i.warehouse_id = w.id JOIN product p ON i.product = p.name GROUP BY w.name, p.category WITH ROLLUP;
What is the total CO2 emissions reduction achieved by wind energy projects in Germany, grouped by project type and year of implementation?
CREATE TABLE wind_energy_projects (id INT,project_type VARCHAR(100),country VARCHAR(50),co2_emissions_reduction FLOAT,implementation_date DATE); INSERT INTO wind_energy_projects (id,project_type,country,co2_emissions_reduction,implementation_date) VALUES (1,'Onshore Wind Project A','Germany',2000,'2015-01-01'); INSERT ...
SELECT project_type, YEAR(implementation_date) AS implementation_year, SUM(co2_emissions_reduction) AS total_reduction FROM wind_energy_projects WHERE country = 'Germany' GROUP BY project_type, YEAR(implementation_date);