instruction
stringlengths
0
1.06k
input
stringlengths
11
5.3k
response
stringlengths
2
4.44k
Which food supplier had the most safety violations in 2021?
CREATE TABLE SupplierSafetyRecords (SupplierName VARCHAR(50),Year INT,SafetyViolations INT); INSERT INTO SupplierSafetyRecords (SupplierName,Year,SafetyViolations) VALUES ('ABC Foods',2021,5),('XYZ Foods',2021,8),('123 Foods',2021,3),('FoodCo',2021,7),('EcoFoods',2021,4);
SELECT SupplierName, MAX(SafetyViolations) FROM SupplierSafetyRecords WHERE Year = 2021 GROUP BY SupplierName;
Display the PlayerName and VRAdopted date for players who adopted VR technology in 2021
CREATE TABLE Players (PlayerID INT,PlayerName VARCHAR(50),Country VARCHAR(50)); INSERT INTO Players (PlayerID,PlayerName,Country) VALUES (1,'John Smith','Canada'); INSERT INTO Players (PlayerID,PlayerName,Country) VALUES (2,'Jane Doe','USA'); CREATE TABLE VRAdoption (PlayerID INT,VRAdopted DATE); INSERT INTO VRAdoption (PlayerID,VRAdopted) VALUES (1,'2021-08-01'); INSERT INTO VRAdoption (PlayerID,VRAdopted) VALUES (2,'2020-08-01');
SELECT p.PlayerName, va.VRAdopted FROM Players p INNER JOIN VRAdoption va ON p.PlayerID = va.PlayerID WHERE YEAR(va.VRAdopted) = 2021;
Insert new temperature data for farm_id 345
CREATE TABLE temperature_data (id INT,farm_id INT,temperature FLOAT,measurement_date DATE);
INSERT INTO temperature_data (id, farm_id, temperature, measurement_date) VALUES (6, 345, 22.2, '2022-06-02');
Create a table named 'diplomacy_events'
CREATE TABLE diplomacy_events (event_id INT,name VARCHAR(255),country VARCHAR(255),date DATE,description TEXT);
CREATE TABLE diplomacy_events (event_id INT, name VARCHAR(255), country VARCHAR(255), date DATE, description TEXT);
Alter 'military_equipment' table to add a column 'country'
CREATE TABLE military_equipment (id INT PRIMARY KEY,name VARCHAR(255),type VARCHAR(255),manufacturer VARCHAR(255),year INT,country VARCHAR(255)); INSERT INTO military_equipment (id,name,type,manufacturer,year,country) VALUES (1,'M1 Abrams','Tank','General Dynamics',1980,'USA'),(2,'F-15 Eagle','Fighter','McDonnell Douglas',1976,'USA');
ALTER TABLE military_equipment ADD COLUMN country VARCHAR(255);
Identify the number of cultural heritage sites and virtual tours offered in France and Spain, and find the difference between the two numbers.
CREATE TABLE cultural_sites (site_id INT,country VARCHAR(20),type VARCHAR(20)); INSERT INTO cultural_sites (site_id,country,type) VALUES (1,'France','heritage'),(2,'Spain','heritage'),(3,'France','heritage'),(4,'France','virtual'),(5,'Spain','virtual');
SELECT COUNT(*) FROM cultural_sites WHERE country = 'France' AND type = 'heritage' UNION ALL SELECT COUNT(*) FROM cultural_sites WHERE country = 'Spain' AND type = 'heritage' UNION ALL SELECT COUNT(*) FROM cultural_sites WHERE country = 'France' AND type = 'virtual' UNION ALL SELECT COUNT(*) FROM cultural_sites WHERE country = 'Spain' AND type = 'virtual' EXCEPT (SELECT * FROM (SELECT COUNT(*) FROM cultural_sites WHERE country = 'France' AND type = 'heritage' UNION ALL SELECT COUNT(*) FROM cultural_sites WHERE country = 'Spain' AND type = 'heritage' UNION ALL SELECT COUNT(*) FROM cultural_sites WHERE country = 'France' AND type = 'virtual' UNION ALL SELECT COUNT(*) FROM cultural_sites WHERE country = 'Spain' AND type = 'virtual') AS subquery);
How many cultivation licenses have been issued in Washington in the past year?
CREATE TABLE Licenses (id INT,type TEXT,issue_date DATE,revoke_date DATE);
SELECT COUNT(*) FROM Licenses WHERE type = 'cultivation' AND issue_date >= DATE_SUB(CURDATE(), INTERVAL 1 YEAR) AND issue_date < DATE_SUB(CURDATE(), INTERVAL 0 DAY) AND revoke_date IS NULL;
Delete records of customers who have not paid their bills in the last 60 days from the billing table
CREATE TABLE billing (customer_id INT,bill_amount DECIMAL(5,2),payment_date DATE);
DELETE FROM billing WHERE payment_date < (CURRENT_DATE - INTERVAL '60' DAY);
Update the medical data of astronaut 'John Glenn' to include a new medical record with a medical issue of 'High Blood Pressure' and a medical date of '1999-01-01'.
CREATE TABLE AstronautMedicalData (AstronautName VARCHAR(255),MedicalIssue VARCHAR(255),MedicalDate DATE); INSERT INTO AstronautMedicalData (AstronautName,MedicalIssue,MedicalDate) VALUES ('Neil Armstrong','Allergies','1968-12-12'),('Buzz Aldrin','Anxiety','1968-11-11');
INSERT INTO AstronautMedicalData (AstronautName, MedicalIssue, MedicalDate) SELECT 'John Glenn', 'High Blood Pressure', '1999-01-01' FROM AstronautMedicalData WHERE AstronautName = 'John Glenn' LIMIT 1;
What is the average waste generation per capita in the Asian region?
CREATE TABLE WasteGeneration (country VARCHAR(255),waste_generation_kg_per_capita DECIMAL(5,2),region VARCHAR(255)); INSERT INTO WasteGeneration (country,waste_generation_kg_per_capita,region) VALUES ('Japan',3.2,'Asia'),('China',5.1,'Asia'),('India',1.7,'Asia');
SELECT AVG(waste_generation_kg_per_capita) FROM WasteGeneration WHERE region = 'Asia';
What is the difference in total points scored between the first and second halves of each NBA game?
CREATE TABLE games (game_id INT,first_half_points INT,second_half_points INT);
SELECT game_id, first_half_points - second_half_points AS point_difference FROM games;
For all clients with a last name starting with 'B', update the region to 'EU'.
CREATE TABLE clients (client_id INT,name VARCHAR(50),region VARCHAR(50));INSERT INTO clients (client_id,name,region) VALUES (1,'John Doe','North America'),(2,'Barbara Black','Asia');
UPDATE clients c SET c.region = 'EU' WHERE SUBSTRING(c.name, 1, 1) = 'B';
What is the funding amount for the 'Coral Reef Restoration' project?
CREATE TABLE marine_research_funding (id INT PRIMARY KEY,project_name VARCHAR(255),organization VARCHAR(255),start_date DATE,end_date DATE,budget FLOAT); INSERT INTO marine_research_funding (id,project_name,organization,start_date,end_date,budget) VALUES (2,'Coral Reef Restoration','National Marine Fisheries Service','2022-07-01','2025-06-30',8000000.00);
SELECT budget FROM marine_research_funding WHERE project_name = 'Coral Reef Restoration';
What are the top 3 rare earth element producers in terms of total production quantity?
CREATE TABLE producer (id INT,name TEXT,total_production FLOAT); INSERT INTO producer (id,name,total_production) VALUES (1,'China',140000),(2,'Australia',20000),(3,'United States',15000);
SELECT name, total_production FROM producer ORDER BY total_production DESC LIMIT 3;
What is the total cost of accommodations for students with mobility impairments in the last 3 months?
CREATE TABLE student_accommodations (student_id INT,disability_type VARCHAR(255),country VARCHAR(255),date DATE,cost INT); INSERT INTO student_accommodations (student_id,disability_type,country,date,cost) VALUES (1,'Mobility Impairment','USA','2021-03-22',500); INSERT INTO student_accommodations (student_id,disability_type,country,date,cost) VALUES (2,'Mobility Impairment','Canada','2021-04-01',700);
SELECT SUM(cost) as total_cost FROM student_accommodations WHERE disability_type = 'Mobility Impairment' AND date BETWEEN DATE_SUB(NOW(), INTERVAL 3 MONTH) AND NOW();
What's the total number of renewable energy projects in Sweden?
CREATE TABLE renewable_energy (country VARCHAR(255),project_name VARCHAR(255),type VARCHAR(255),count INT);
SELECT SUM(count) FROM renewable_energy WHERE country = 'Sweden' AND type = 'renewable';
What are the names of the programs that have more than 5 volunteers?
CREATE TABLE Programs (ProgramID INT,ProgramName VARCHAR(255)); INSERT INTO Programs (ProgramID,ProgramName) VALUES (1,'Education'),(2,'Health'),(3,'Environment'),(4,'Arts'),(5,'Sports'); CREATE TABLE Volunteers (VolunteerID INT,ProgramID INT); INSERT INTO Volunteers (VolunteerID,ProgramID) VALUES (1,1),(2,1),(3,2),(4,2),(5,2),(6,3),(7,4),(8,4),(9,4),(10,5);
SELECT Programs.ProgramName FROM Programs INNER JOIN Volunteers ON Programs.ProgramID = Volunteers.ProgramID GROUP BY Programs.ProgramName HAVING COUNT(DISTINCT Volunteers.VolunteerID) > 5;
What is the total amount of waste generated in the commercial sector in the year 2020?
CREATE TABLE waste_generation (id INT,sector VARCHAR(20),year INT,waste_generated FLOAT); INSERT INTO waste_generation (id,sector,year,waste_generated) VALUES (1,'commercial',2020,200.2),(2,'commercial',2019,190.1),(3,'residential',2020,150.5);
SELECT SUM(waste_generated) FROM waste_generation WHERE sector = 'commercial' AND year = 2020;
What is the average salary for employees in the IT department?
CREATE TABLE Employees (EmployeeID INT,Department VARCHAR(50),Salary DECIMAL(10,2)); INSERT INTO Employees (EmployeeID,Department,Salary) VALUES (1,'IT',75000.00); INSERT INTO Employees (EmployeeID,Department,Salary) VALUES (2,'IT',80000.00); INSERT INTO Employees (EmployeeID,Department,Salary) VALUES (3,'HR',65000.00);
SELECT AVG(Salary) FROM Employees WHERE Department = 'IT'
What is the average capacity of vessels in the 'fleet_management' table?
CREATE TABLE fleet_management (id INT,name VARCHAR(50),type VARCHAR(50),capacity INT);
SELECT AVG(capacity) FROM fleet_management;
List all collective bargaining agreements and their respective union names.
CREATE TABLE CollectiveBargaining (agreement_id INT,union_id INT,terms TEXT); CREATE TABLE Unions (union_id INT,name TEXT);
SELECT CollectiveBargaining.terms, Unions.name FROM CollectiveBargaining INNER JOIN Unions ON CollectiveBargaining.union_id = Unions.union_id;
Find the CO2 emissions for each store in the state of New York.
CREATE TABLE stores (store_id INT,store_name VARCHAR(255),store_state VARCHAR(255),co2_emissions INT);
SELECT store_name, co2_emissions FROM stores WHERE store_state = 'New York';
What is the total number of students who received accommodations in the arts department and the physical education department, for the fall 2021 semester?
CREATE TABLE arts_accommodations (student_id INT,semester VARCHAR(10));CREATE TABLE pe_accommodations (student_id INT,semester VARCHAR(10)); INSERT INTO arts_accommodations VALUES (4,'fall 2021'),(5,'fall 2021'),(6,'fall 2021'); INSERT INTO pe_accommodations VALUES (5,'fall 2021'),(6,'fall 2021'),(7,'fall 2021');
SELECT COUNT(*) FROM arts_accommodations WHERE semester = 'fall 2021' UNION ALL SELECT COUNT(*) FROM pe_accommodations WHERE semester = 'fall 2021';
Calculate the year-over-year change in visitor spending in Africa.
CREATE TABLE spending_stats (year INT,continent TEXT,spending DECIMAL(10,2)); INSERT INTO spending_stats (year,continent,spending) VALUES (2019,'Africa',800),(2020,'Africa',600),(2021,'Africa',900);
SELECT t1.year, t1.continent, (t1.spending - LAG(t1.spending) OVER (PARTITION BY t1.continent ORDER BY t1.year)) / ABS(LAG(t1.spending) OVER (PARTITION BY t1.continent ORDER BY t1.year)) as change_percentage FROM spending_stats t1;
Which sites have no recorded marine life observations?
CREATE TABLE marine_species (species_id INT,site_id INT,species_name TEXT); INSERT INTO marine_species (species_id,site_id,species_name) VALUES (1,1,'Anglerfish'),(2,3,'Giant Squid'),(3,1,'Oceanic Trench Snailfish');
SELECT site_id FROM marine_sites WHERE site_id NOT IN (SELECT site_id FROM marine_species);
How many vessels were registered in the first quarter of 2020 in the Caribbean region?
CREATE TABLE vessels (vessel_id INT,registration_date DATE,region TEXT); INSERT INTO vessels VALUES (1,'2020-01-15','Caribbean'),(2,'2020-03-07','Caribbean'),(3,'2019-12-28','Caribbean'),(4,'2020-02-04','Caribbean'),(5,'2019-11-10','Caribbean'),(6,'2020-01-02','Caribbean');
SELECT COUNT(*) FROM vessels WHERE registration_date BETWEEN '2020-01-01' AND '2020-03-31' AND region = 'Caribbean';
How many clinical trials were conducted for a specific therapeutic area, 'Oncology', between 2015 and 2020?
CREATE TABLE clinical_trials (trial_id INT,therapeutic_area VARCHAR(50),start_year INT,end_year INT); INSERT INTO clinical_trials (trial_id,therapeutic_area,start_year,end_year) VALUES (1,'Oncology',2015,2017),(2,'Oncology',2016,2018),(3,'Cardiology',2017,2019),(4,'Oncology',2018,2020);
SELECT COUNT(*) as total_trials FROM clinical_trials WHERE therapeutic_area = 'Oncology' AND start_year BETWEEN 2015 AND 2020;
What was the total funding received by each department in H1 2023?
CREATE TABLE funding_sources (funding_id INT,funding_amount INT,funding_date DATE,department_id INT); INSERT INTO funding_sources (funding_id,funding_amount,funding_date,department_id) VALUES (1,5000,'2023-01-01',101); INSERT INTO funding_sources (funding_id,funding_amount,funding_date,department_id) VALUES (2,7000,'2023-04-15',102);
SELECT department_id, SUM(funding_amount) as total_funding FROM funding_sources WHERE MONTH(funding_date) <= 6 AND YEAR(funding_date) = 2023 GROUP BY department_id;
What is the change in obesity rates for each community center between 2018 and 2020?
CREATE TABLE obesity_data (community_center TEXT,year INT,obesity_rate INT); INSERT INTO obesity_data (community_center,year,obesity_rate) VALUES ('Center A',2018,20),('Center A',2019,22),('Center A',2020,24),('Center B',2018,18),('Center B',2019,19),('Center B',2020,21);
SELECT community_center, (obesity_rate_2020 - obesity_rate_2018) AS obesity_change FROM (SELECT community_center, obesity_rate AS obesity_rate_2018, LEAD(obesity_rate, 2) OVER (PARTITION BY community_center ORDER BY year) AS obesity_rate_2020 FROM obesity_data) WHERE obesity_rate_2020 IS NOT NULL;
How many animals are there in each protected habitat?
CREATE TABLE Protected_Habitats (id INT,habitat_id INT,animal_count INT);
SELECT habitat_id, COUNT(*) FROM Protected_Habitats GROUP BY habitat_id;
List all employees who do not have a job title
CREATE TABLE employees (id INT,first_name VARCHAR(50),last_name VARCHAR(50),job_title VARCHAR(100)); INSERT INTO employees (id,first_name,last_name,job_title) VALUES (1,'John','Doe','Software Engineer'),(2,'Jane','Doe',NULL);
SELECT id, first_name, last_name FROM employees WHERE job_title IS NULL;
What is the average calorie intake for organic meals in Canada?
CREATE TABLE Meals(id INT,name TEXT,country TEXT,calories INT); INSERT INTO Meals(id,name,country,calories) VALUES (1,'Organic Salad','Canada',350),(2,'Vegan Burger','Canada',600);
SELECT AVG(calories) FROM Meals WHERE name LIKE '%Organic%' AND country = 'Canada';
What is the minimum and maximum property price in the inclusive housing program?
CREATE TABLE inclusive_housing_prices (property_id INT,price DECIMAL(10,2)); INSERT INTO inclusive_housing_prices (property_id,price) VALUES (1,300000.00),(2,350000.00),(3,400000.00);
SELECT MIN(price), MAX(price) FROM inclusive_housing_prices;
Calculate the total fare collected at each station on the Blue Line on 2022-07-01
CREATE TABLE stations (station_id INT,station_name VARCHAR(255),line VARCHAR(255));CREATE TABLE trips (trip_id INT,station_id INT,entry_time TIMESTAMP,fare FLOAT); INSERT INTO stations (station_id,station_name,line) VALUES (1,'Bowdoin','Blue Line'),(2,'Aquarium','Blue Line'),(3,'Maverick','Blue Line'); INSERT INTO trips (trip_id,station_id,entry_time,fare) VALUES (1,1,'2022-07-01 06:00:00',2.5),(2,1,'2022-07-01 18:00:00',3.0),(3,2,'2022-07-01 12:00:00',1.5),(4,3,'2022-07-01 10:00:00',4.0);
SELECT s.station_name, SUM(t.fare) as total_fare FROM trips t JOIN stations s ON t.station_id = s.station_id WHERE s.line = 'Blue Line' AND t.entry_time::date = '2022-07-01' GROUP BY s.station_name;
What was the total weight of cannabis sold in the state of Nevada in the year 2021?
CREATE TABLE sales (id INT,state VARCHAR(50),year INT,weight INT); INSERT INTO sales (id,state,year,weight) VALUES (1,'Nevada',2021,50000);
SELECT SUM(weight) FROM sales WHERE state = 'Nevada' AND year = 2021;
What is the maximum housing affordability index in Berlin?
CREATE TABLE housing_affordability (index FLOAT,city VARCHAR(20));
SELECT MAX(index) FROM housing_affordability WHERE city = 'Berlin';
What is the maximum production quantity (in metric tons) of Europium in 2021, grouped by mining company locations in Africa?
CREATE TABLE mining_companies_2 (company_name TEXT,location TEXT); INSERT INTO mining_companies_2 (company_name,location) VALUES ('VWX Mining','South Africa'),('YZA Mining','Morocco'),('BCD Mining','Egypt'); CREATE TABLE europium_production (year INT,company_name TEXT,quantity INT); INSERT INTO europium_production (year,company_name,quantity) VALUES (2021,'VWX Mining',1200),(2021,'YZA Mining',800),(2021,'BCD Mining',1500);
SELECT location, MAX(quantity) as max_quantity FROM europium_production JOIN mining_companies_2 ON europium_production.company_name = mining_companies_2.company_name WHERE year = 2021 AND location LIKE 'Africa%' GROUP BY location;
How many teachers have participated in professional development programs in the last 3 years, broken down by subject area?
CREATE TABLE teachers (teacher_id INT,teacher_name TEXT,subject_area TEXT,last_pd_program_date DATE); INSERT INTO teachers (teacher_id,teacher_name,subject_area,last_pd_program_date) VALUES (1,'John Doe','Math','2020-04-01'),(2,'Jane Smith','Science','2019-08-15'),(3,'Mary Johnson','English','2021-03-20');
SELECT subject_area, COUNT(*) FROM teachers WHERE last_pd_program_date >= DATE_SUB(CURRENT_DATE, INTERVAL 3 YEAR) GROUP BY subject_area;
Which regions have a higher industrial water usage compared to domestic water usage?
CREATE TABLE water_usage (sector VARCHAR(20),region VARCHAR(20),usage INT); INSERT INTO water_usage (sector,region,usage) VALUES ('Agriculture','North',300),('Domestic','North',200),('Industrial','North',500),('Agriculture','South',400),('Domestic','South',250),('Industrial','South',600);
SELECT region FROM water_usage WHERE industrial > domestic
How many visitors identified as non-binary attended each exhibition?
CREATE TABLE Exhibitions (exhibition_id INT,name VARCHAR(50),start_date DATE,end_date DATE); INSERT INTO Exhibitions (exhibition_id,name,start_date,end_date) VALUES (1,'Impressionist','2020-05-01','2021-01-01'),(2,'Cubism','2019-08-15','2020-03-30'); CREATE TABLE Visitors (visitor_id INT,exhibition_id INT,age INT,gender VARCHAR(50));
SELECT exhibition_id, COUNT(*) FROM Visitors WHERE gender = 'non-binary' GROUP BY exhibition_id;
Find excavation sites in France and Germany with more than 50 artifacts.
CREATE TABLE excavation_sites (id INT,country VARCHAR(255),artifacts_count INT);
SELECT country, COUNT(*) as artifacts_count FROM excavation_sites WHERE country IN ('France', 'Germany') GROUP BY country HAVING artifacts_count > 50;
Update temperature records for sensor 003 on 2023-03-02 to 30°C
CREATE TABLE TemperatureData (date DATE,temperature FLOAT,sensor_id INT,FOREIGN KEY (sensor_id) REFERENCES SensorData(sensor_id));
UPDATE TemperatureData SET temperature = 30 WHERE sensor_id = 3 AND date = '2023-03-02';
What is the average number of hours spent on mental health resources per student in each school?
CREATE TABLE schools (school_id INT,school_name TEXT); INSERT INTO schools VALUES (1,'Lincoln High'),(2,'Washington Middle'),(3,'Jefferson Elementary'); CREATE TABLE student_mental_health (student_id INT,school_id INT,hours_spent INT); INSERT INTO student_mental_health VALUES (1,1,10),(2,1,8),(3,2,5),(4,2,7),(5,3,12),(6,3,15);
SELECT s.school_name, AVG(smh.hours_spent) as avg_hours_spent FROM student_mental_health smh JOIN schools s ON smh.school_id = s.school_id GROUP BY smh.school_id;
Delete all records with disability_type 'learning' from student_accommodations
CREATE TABLE student_accommodations (student_id INT,disability_type VARCHAR(255),accommodation_year INT);
DELETE FROM student_accommodations WHERE disability_type = 'learning';
What are the names of traditional art forms from Japan with a description?
CREATE TABLE ArtForms (id INT,name VARCHAR(255),origin VARCHAR(255),description TEXT); INSERT INTO ArtForms (id,name,origin,description) VALUES (1,'Kabuki','Japan','A classical Japanese dance-drama known for its elaborate make-up and costumes.');
SELECT name FROM ArtForms WHERE origin = 'Japan' INTERSECT SELECT name FROM ArtForms WHERE description IS NOT NULL;
Find the total number of shares for posts containing the hashtag "#sustainableliving" in the past week.
CREATE TABLE posts (id INT,user VARCHAR(50),content TEXT,likes INT,shares INT,timestamp DATETIME);
SELECT SUM(shares) FROM posts WHERE content LIKE '%#sustainableliving%' AND timestamp BETWEEN DATE_SUB(NOW(), INTERVAL 1 WEEK) AND NOW();
List the names of vessels that have had an accident
CREATE TABLE Vessels (Id INT,Name VARCHAR(50)); CREATE TABLE Accidents (VesselId INT); INSERT INTO Vessels (Id,Name) VALUES (1,'Vessel1'),(2,'Vessel2'),(3,'Vessel3'); INSERT INTO Accidents (VesselId) VALUES (1),(3);
SELECT Vessels.Name FROM Vessels JOIN Accidents ON Vessels.Id = Accidents.VesselId;
What is the average number of labor rights violations per workplace in Spain?
CREATE TABLE violations (id INT,workplace TEXT,country TEXT,violation_count INT); INSERT INTO violations (id,workplace,country,violation_count) VALUES (1,'Workplace A','Spain',5),(2,'Workplace B','Spain',3),(3,'Workplace C','Spain',7);
SELECT AVG(violation_count) as avg_violations_per_workplace FROM violations WHERE country = 'Spain';
Insert new record '2022-06-01' for 'community_policing' table
CREATE TABLE community_policing (id INT,date DATE,outreach_hours INT,PRIMARY KEY(id));
INSERT INTO community_policing (id, date, outreach_hours) VALUES (4, '2022-06-01', 2);
List the top 3 destinations with the highest sustainable tourism scores in Africa.
CREATE TABLE IF NOT EXISTS destinations (id INT PRIMARY KEY,name TEXT,region TEXT,sustainability_score FLOAT); INSERT INTO destinations (id,name,region,sustainability_score) VALUES (1,'EcoPark','Africa',9.2),(2,'GreenVillage','Africa',8.8),(3,'SustainableCity','Asia',8.9);
SELECT name, sustainability_score FROM destinations WHERE region = 'Africa' ORDER BY sustainability_score DESC LIMIT 3;
How many auto shows took place in India in 2019?
CREATE TABLE Auto_Shows (year INT,country VARCHAR(50),quantity INT); INSERT INTO Auto_Shows (year,country,quantity) VALUES (2019,'India',10);
SELECT SUM(quantity) FROM Auto_Shows WHERE year = 2019 AND country = 'India';
How many startups were founded in the Bay Area each year?
CREATE TABLE company (id INT,name TEXT,founding_year INT,founding_location TEXT); INSERT INTO company (id,name,founding_year,founding_location) VALUES (1,'Acme Inc',2010,'San Francisco'); INSERT INTO company (id,name,founding_year,founding_location) VALUES (2,'Beta Corp',2015,'Mountain View');
SELECT founding_location, COUNT(*) FROM company GROUP BY founding_year, founding_location HAVING founding_location = 'Bay Area';
Rank the species in descending order based on total biomass in brackish water farms.
CREATE TABLE brackish_farms (farm_id INT,species VARCHAR(20),biomass FLOAT); INSERT INTO brackish_farms (farm_id,species,biomass) VALUES (1,'Tilapia',1200.5),(2,'Barramundi',800.3),(3,'Catfish',1500.2);
SELECT species, SUM(biomass) total_biomass, ROW_NUMBER() OVER (ORDER BY SUM(biomass) DESC) rank FROM brackish_farms GROUP BY species;
How many marine species were observed in each ocean?
CREATE TABLE marine_species (id INT,species_name VARCHAR(255),ocean VARCHAR(255),depth INT); INSERT INTO marine_species (id,species_name,ocean,depth) VALUES (1,'Mariana Snailfish','Pacific',8178); INSERT INTO marine_species (id,species_name,ocean,depth) VALUES (2,'Hadal Snailfish','Atlantic',7500); INSERT INTO marine_species (id,species_name,ocean,depth) VALUES (3,'Narwhal','Arctic',1500); INSERT INTO marine_species (id,species_name,ocean,depth) VALUES (4,'Beluga Whale','Arctic',500);
SELECT ocean, COUNT(*) FROM marine_species GROUP BY ocean;
Which libraries had the most and least visitors in the last month?
CREATE TABLE Visitors (Library text,Visitors int,VisitDate date); INSERT INTO Visitors (Library,Visitors,VisitDate) VALUES ('LibraryA',100,'2022-04-01'),('LibraryB',150,'2022-04-02');
SELECT Library, Visitors FROM (SELECT Library, Visitors, ROW_NUMBER() OVER (ORDER BY Visitors) as Rank FROM Visitors WHERE VisitDate >= DATEADD(month, -1, CURRENT_DATE)) as Subquery WHERE Rank IN (1, (SELECT COUNT(*) FROM Visitors WHERE VisitDate >= DATEADD(month, -1, CURRENT_DATE)) * 0.01);
How many agricultural innovation projects are currently active in each region?
CREATE TABLE innovation_projects (id INT,region VARCHAR(50),status VARCHAR(50)); INSERT INTO innovation_projects (id,region,status) VALUES (1,'Region A','Active');
SELECT region, COUNT(*) FROM rural_development.innovation_projects WHERE status = 'Active' GROUP BY region;
Which materials in the 'inventory' table have a quantity of at least 100 and are used in the production of at least one product in the 'products' table, but are not produced in 'China'?
CREATE TABLE inventory(id INT,material VARCHAR(255),quantity INT); CREATE TABLE products(id INT,material VARCHAR(255),quantity INT); CREATE TABLE production(id INT,country VARCHAR(255),material VARCHAR(255),usage INT); INSERT INTO inventory(id,material,quantity) VALUES (1,'organic cotton',75),(2,'conventional cotton',100),(3,'organic cotton',30),(4,'hemp',60); INSERT INTO products(id,material,quantity) VALUES (1,'organic cotton',150),(2,'conventional cotton',200),(3,'hemp',100); INSERT INTO production(id,country,material,usage) VALUES (1,'China','recycled polyester',800),(2,'India','recycled polyester',600),(3,'Bangladesh','viscose',400),(4,'Vietnam','recycled polyester',700),(5,'India','hemp',500);
SELECT i.material FROM inventory i INNER JOIN products p ON i.material = p.material WHERE i.quantity >= 100 AND NOT EXISTS (SELECT * FROM production WHERE production.material = i.material AND production.country = 'China');
What is the market share of a different drug compared to its competitors in a different region?
CREATE TABLE market_share (market_share_id INT,drug_id INT,region TEXT,market_share FLOAT); INSERT INTO market_share (market_share_id,drug_id,region,market_share) VALUES (1,1002,'Asia',0.30),(2,1003,'Asia',0.40),(3,1002,'Asia',0.50),(4,1001,'Asia',0.25),(5,1003,'Asia',0.35),(6,1001,'Asia',0.45);
SELECT drug_id, region, AVG(market_share) as average_market_share FROM market_share WHERE drug_id = 1003 GROUP BY drug_id, region;
List all bridges with their respective inspection dates.
CREATE TABLE Bridges (id INT,name VARCHAR(50),inspection_date DATE); INSERT INTO Bridges (id,name,inspection_date) VALUES (1,'Golden Gate','2020-05-01'),(2,'Brooklyn','2019-12-20');
SELECT * FROM Bridges;
Which hotel chains have the most OTA bookings in 'CountryA'?
CREATE TABLE Hotels (hotel_id INT,hotel_name VARCHAR(50),chain_name VARCHAR(50),country VARCHAR(50)); CREATE TABLE Bookings (booking_id INT,hotel_id INT,booking_amt FLOAT,ota_source BOOLEAN); INSERT INTO Hotels (hotel_id,hotel_name,chain_name,country) VALUES (1,'Hotel1','ChainX','CountryA'),(2,'Hotel2','ChainX','CountryB'),(3,'Hotel3','ChainY','CountryA'); INSERT INTO Bookings (booking_id,hotel_id,booking_amt,ota_source) VALUES (1,1,500,TRUE),(2,2,400,FALSE),(3,1,300,TRUE),(4,3,250,TRUE);
SELECT h.chain_name, SUM(b.booking_amt) as total_ota_bookings FROM Hotels h JOIN Bookings b ON h.hotel_id = b.hotel_id WHERE h.country = 'CountryA' AND b.ota_source = TRUE GROUP BY h.chain_name;
List the teams that have conceded less than 10 goals in their last 5 games.
CREATE TABLE games (game_id INT,team VARCHAR(50),position VARCHAR(50),goals_conceded INT,game_date DATE);
SELECT team FROM (SELECT team, SUM(goals_conceded) AS goals_conceded FROM games WHERE game_date > DATE_SUB(CURRENT_DATE, INTERVAL 5 DAY) GROUP BY team) AS subquery WHERE goals_conceded < 10;
Delete all records from the 'Programs' table where the program name is 'Education'
CREATE TABLE Programs (id INT PRIMARY KEY,program_name VARCHAR(255),budget DECIMAL(10,2)); INSERT INTO Programs (id,program_name,budget) VALUES (1,'Education',10000.00),(2,'Health',15000.00);
DELETE FROM Programs WHERE program_name = 'Education';
List all artists who have more than 50 works in the NY museum.
CREATE TABLE Artists (id INT,name VARCHAR(50),museum VARCHAR(20)); INSERT INTO Artists (id,name,museum) VALUES (1,'Van Gogh','NY'),(2,'Monet','NY'),(3,'Picasso','LA'); CREATE TABLE Artworks (id INT,artist_id INT,title VARCHAR(50)); INSERT INTO Artworks (id,artist_id,title) VALUES (1,1,'Starry Night'),(2,2,'Water Lilies'),(3,1,'Sunflowers'); CREATE TABLE Museums (id INT,name VARCHAR(20),location VARCHAR(20)); INSERT INTO Museums (id,name,location) VALUES (1,'NY','NY'),(2,'LA','LA');
SELECT Artists.name FROM Artists JOIN Artworks ON Artists.id = Artworks.artist_id WHERE Museums.name = 'NY' GROUP BY Artists.name HAVING COUNT(Artworks.id) > 50;
What is the total revenue generated by dance performances in the past three years?
CREATE TABLE Events (event_name TEXT,year INT,revenue INT); INSERT INTO Events (event_name,year,revenue) VALUES ('Dance Performance',2019,8000),('Dance Festival',2020,9000),('Dance Recital',2021,11000);
SELECT SUM(revenue) FROM Events WHERE event_name LIKE '%Dance%' AND year IN (2019, 2020, 2021);
How many unique strains were produced by each grower in Washington in 2021?
CREATE TABLE Growers (id INT,name TEXT,state TEXT); CREATE TABLE Strains (growerid INT,name TEXT); INSERT INTO Growers (id,name,state) VALUES (1,'Grower A','Washington'); INSERT INTO Strains (growerid,name) VALUES (1,'Strain X'); INSERT INTO Strains (growerid,name) VALUES (1,'Strain Y');
SELECT g.name, COUNT(DISTINCT s.name) as unique_strains FROM Growers g JOIN Strains s ON g.id = s.growerid WHERE g.state = 'Washington' AND YEAR(s.name) = 2021 GROUP BY g.name;
Which clean energy policies were implemented in the year 2020?
CREATE TABLE clean_energy_policies (policy_id INT,policy_name VARCHAR(255),policy_description TEXT,implementation_year INT); INSERT INTO clean_energy_policies (policy_id,policy_name,policy_description,implementation_year) VALUES (1,'Renewable Portfolio Standard','Requires electricity providers to generate a certain percentage of their electricity from renewable sources',2020); INSERT INTO clean_energy_policies (policy_id,policy_name,policy_description,implementation_year) VALUES (2,'Energy Efficiency Resource Standard','Requires electricity providers to achieve a certain level of energy efficiency savings',2018);
SELECT policy_name, policy_description FROM clean_energy_policies WHERE implementation_year = 2020;
Delete all articles published before 2010 from the 'news_articles' table
CREATE TABLE news_articles (article_id INT PRIMARY KEY,title VARCHAR(255),content TEXT,publish_date DATE);
DELETE FROM news_articles WHERE publish_date < '2010-01-01';
What was the total revenue for a specific artist in the music streaming data?
CREATE TABLE Streaming (song VARCHAR(50),artist VARCHAR(50),streams INT,revenue FLOAT); INSERT INTO Streaming (song,artist,streams,revenue) VALUES ('Heat Waves','Glass Animals',500,5000.0),('Drivers License','Olivia Rodrigo',700,7000.0),('Good 4 U','Olivia Rodrigo',600,6000.0);
SELECT SUM(revenue) FROM Streaming WHERE artist = 'Olivia Rodrigo';
Insert new community engagement records for 'Festival of Colors' and 'Pow Wow'
CREATE TABLE CommunityEngagements (Id INT,Event TEXT,Year INT,Location TEXT);
INSERT INTO CommunityEngagements (Id, Event, Year, Location) VALUES (1, 'Festival of Colors', 2022, 'India'), (2, 'Pow Wow', 2022, 'USA');
List the names of clients who have a total billing amount less than $30,000
CREATE TABLE clients (id INT,name VARCHAR(50),total_billing_amount DECIMAL(10,2)); INSERT INTO clients (id,name,total_billing_amount) VALUES (1,'Davi Silva',25000.00),(2,'Alexei Ivanov',45000.00),(3,'Aaliyah Patel',15000.00);
SELECT name FROM clients WHERE total_billing_amount < 30000.00;
What is the total value of military equipment sold to the Chinese government by Lockheed Martin from 2017 to 2020?
CREATE TABLE sales(id INT,equipment_name VARCHAR(50),sale_date DATE,country VARCHAR(50),government_agency VARCHAR(50),sale_value INT); CREATE TABLE manufacturer(id INT,name VARCHAR(50)); INSERT INTO sales VALUES (1,'Fighter Jet','2017-01-01','China','Ministry of Defense',50000000); INSERT INTO manufacturer VALUES (1,'Lockheed Martin');
SELECT SUM(sales.sale_value) FROM sales INNER JOIN manufacturer ON sales.id = manufacturer.id WHERE sales.country = 'China' AND sales.government_agency = 'Ministry of Defense' AND YEAR(sale_date) BETWEEN 2017 AND 2020 AND manufacturer.name = 'Lockheed Martin';
Which military innovation projects were completed before 2015?
CREATE TABLE military_innovation (project_id INT,country_id INT,completion_year INT,FOREIGN KEY (country_id) REFERENCES country(id));
SELECT project_id, country_id, completion_year FROM military_innovation WHERE completion_year < 2015;
What is the maximum retail price of eco-friendly winter coats sold in the United Kingdom?
CREATE TABLE garment_sales (id INT,garment_type VARCHAR(50),sustainability_rating INT,country VARCHAR(50),price DECIMAL(5,2)); INSERT INTO garment_sales (id,garment_type,sustainability_rating,country,price) VALUES (1,'winter coat',5,'UK',350.99),(2,'winter coat',3,'UK',299.99);
SELECT MAX(price) FROM garment_sales WHERE garment_type = 'winter coat' AND country = 'UK' AND sustainability_rating >= 3;
What is the maximum donation amount in the 'donors' table?
CREATE TABLE donors (id INT,name TEXT,age INT,donation FLOAT); INSERT INTO donors (id,name,age,donation) VALUES (1,'John Doe',35,500.00); INSERT INTO donors (id,name,age,donation) VALUES (2,'Jane Smith',45,750.00); INSERT INTO donors (id,name,age,donation) VALUES (3,'Bob Johnson',25,600.00);
SELECT MAX(donation) FROM donors;
What are the average construction costs for buildings in Australia, Japan, and the United States?
CREATE TABLE construction_costs (id INT,country VARCHAR(255),building_type VARCHAR(255),avg_construction_cost FLOAT); INSERT INTO construction_costs (id,country,building_type,avg_construction_cost) VALUES (1,'Australia','Residential',250000),(2,'Australia','Commercial',500000),(3,'Japan','Residential',300000),(4,'Japan','Commercial',700000),(5,'United States','Residential',400000),(6,'United States','Commercial',800000);
SELECT country, AVG(avg_construction_cost) FROM construction_costs WHERE country IN ('Australia', 'Japan', 'United States') GROUP BY country;
Which artists have the highest number of streams on Spotify, by genre?
CREATE TABLE artists (artist_id INT,artist VARCHAR(100),genre VARCHAR(50)); CREATE VIEW streams_view AS SELECT artist_id,SUM(streams) AS total_streams FROM stream_data GROUP BY artist_id;
SELECT g.genre, a.artist, s.total_streams FROM artists a JOIN genres g ON a.genre = g.genre JOIN streams_view s ON a.artist_id = s.artist_id ORDER BY total_streams DESC;
How many renewable energy farms (wind and solar) are there in total in the 'West' region?
CREATE TABLE wind_farms (id INT,name VARCHAR(50),region VARCHAR(50),capacity FLOAT,efficiency FLOAT); INSERT INTO wind_farms (id,name,region,capacity,efficiency) VALUES (1,'Windfarm C','West',160.3,0.31); CREATE TABLE solar_farms (id INT,name VARCHAR(50),region VARCHAR(50),capacity FLOAT,efficiency FLOAT); INSERT INTO solar_farms (id,name,region,capacity,efficiency) VALUES (1,'Solarfarm C','West',220.1,0.34);
SELECT COUNT(*) AS total_farms FROM wind_farms WHERE region = 'West' UNION SELECT COUNT(*) AS total_farms FROM solar_farms WHERE region = 'West';
Delete genetic data with no related bioprocess engineering data.
CREATE TABLE genetic_data (id INT,sample_id VARCHAR(20),gene_sequence TEXT); CREATE TABLE bioprocess_data (id INT,sample_id VARCHAR(20),pressure FLOAT); INSERT INTO genetic_data (id,sample_id,gene_sequence) VALUES (1,'GD001','ATGCGA...'),(2,'GD002','ATGCGC...'); INSERT INTO bioprocess_data (id,sample_id,pressure) VALUES (1,'GD001',1.5);
DELETE gd FROM genetic_data gd LEFT JOIN bioprocess_data bd ON gd.sample_id = bd.sample_id WHERE bd.sample_id IS NULL;
What is the average energy_efficiency of the solar_panels installed in the US, ordered by the id in descending order?
CREATE TABLE solar_panels (id INT,country VARCHAR(50),energy_efficiency FLOAT);
SELECT AVG(energy_efficiency) AS avg_efficiency FROM solar_panels WHERE country = 'US' GROUP BY country ORDER BY id DESC;
Find the number of concerts that took place in each month of the year 2020.
CREATE TABLE concerts (concert_id INT,concert_date DATE); INSERT INTO concerts (concert_id,concert_date) VALUES (1,'2020-01-01'); INSERT INTO concerts (concert_id,concert_date) VALUES (2,'2020-02-01'); INSERT INTO concerts (concert_id,concert_date) VALUES (3,'2020-03-01');
SELECT DATEPART(MONTH, concert_date) as month, COUNT(*) as concerts_per_month FROM concerts WHERE YEAR(concert_date) = 2020 GROUP BY DATEPART(MONTH, concert_date);
Which agencies have experienced the highest budget increase between 2019 and 2020?
CREATE TABLE AgencyYearBudget (AgencyId INT,Year INT,Budget INT,PRIMARY KEY (AgencyId,Year)); INSERT INTO AgencyYearBudget (AgencyId,Year,Budget) VALUES (1,2019,5000000); INSERT INTO AgencyYearBudget (AgencyId,Year,Budget) VALUES (1,2020,5600000); INSERT INTO AgencyYearBudget (AgencyId,Year,Budget) VALUES (2,2019,4000000); INSERT INTO AgencyYearBudget (AgencyId,Year,Budget) VALUES (2,2020,4600000);
SELECT AgencyId, MAX(BudgetChange) as HighestBudgetIncrease FROM (SELECT AgencyId, Year, (Budget - LAG(Budget, 1) OVER (PARTITION BY AgencyId ORDER BY Year)) as BudgetChange FROM AgencyYearBudget WHERE Year IN (2019, 2020)) AS BudgetChanges GROUP BY AgencyId;
How many IoT sensors were installed in each country in the past quarter?
CREATE TABLE country (id INTEGER,name TEXT);CREATE TABLE region (id INTEGER,country_id INTEGER,name TEXT);CREATE TABLE iot_sensor (id INTEGER,region_id INTEGER,installed_date DATE);
SELECT co.name as country, r.name as region, COUNT(s.id) as num_sensors FROM country co INNER JOIN region r ON co.id = r.country_id INNER JOIN iot_sensor s ON r.id = s.region_id WHERE s.installed_date >= DATEADD(quarter, -1, CURRENT_DATE) GROUP BY co.name, r.name;
How many public libraries were there in 2017 and 2018?
CREATE TABLE Library(Year INT,Number INT); INSERT INTO Library VALUES (2016,10),(2017,12),(2018,14);
SELECT SUM(Number) FROM Library WHERE Year IN (2017, 2018);
What is the total number of posts with the word 'friends' in the text?
CREATE TABLE posts (id INT,user_id INT,post_text VARCHAR(255)); INSERT INTO posts (id,user_id,post_text) VALUES (1,1,'I love my friends'),(2,2,'I met new people'),(3,3,'My best friend is awesome'),(4,4,'Nice to meet you');
SELECT COUNT(*) FROM posts WHERE post_text LIKE '%friends%';
List the total number of mental health conditions treated with medication in each state.
CREATE TABLE condition_treatment (patient_id INT,condition VARCHAR(50),treatment VARCHAR(50)); INSERT INTO condition_treatment (patient_id,condition,treatment) VALUES (1,'Anxiety','Medication'),(2,'Depression','Medication'),(3,'PTSD','Therapy'),(4,'Anxiety','Therapy'),(5,'Bipolar Disorder','Medication'); CREATE TABLE patient_state (patient_id INT,state VARCHAR(50)); INSERT INTO patient_state (patient_id,state) VALUES (1,'Texas'),(2,'Texas'),(3,'California'),(4,'Arizona'),(5,'Florida');
SELECT state, COUNT(DISTINCT patient_id) FROM condition_treatment JOIN patient_state ON condition_treatment.patient_id = patient_state.patient_id WHERE treatment = 'Medication' GROUP BY state;
Add data to 'habitat_preservation' table
CREATE TABLE habitat_preservation (id INT,project_name VARCHAR(50),location VARCHAR(50),size_acres DECIMAL(10,2),budget_USD DECIMAL(10,2),start_date DATE,end_date DATE);
INSERT INTO habitat_preservation (id, project_name, location, size_acres, budget_USD, start_date, end_date) VALUES (1, 'Wildlife Corridor', 'Borneo', 500.00, 250000.00, '2025-01-01', '2027-12-31');
What is the total waste generation by material type in the city of Seattle in 2021?'
CREATE TABLE waste_generation (city VARCHAR(20),material VARCHAR(20),year INT,quantity FLOAT); INSERT INTO waste_generation (city,material,year,quantity) VALUES ('Seattle','Plastic',2021,1500.5); INSERT INTO waste_generation (city,material,year,quantity) VALUES ('Seattle','Paper',2021,2000.3); INSERT INTO waste_generation (city,material,year,quantity) VALUES ('Seattle','Glass',2021,1750.2);
SELECT wg.material, SUM(wg.quantity) as total_quantity FROM waste_generation wg WHERE wg.city = 'Seattle' AND wg.year = 2021 GROUP BY wg.material;
How many total grants has the local theater received from government sources in the last year?
CREATE TABLE TheaterGrants (grantID INT,grantDate DATE,grantAmount DECIMAL(10,2),grantSource VARCHAR(20)); INSERT INTO TheaterGrants (grantID,grantDate,grantAmount,grantSource) VALUES (10,'2022-01-10',5000.00,'Government'),(11,'2022-02-12',7000.00,'Private'),(12,'2022-03-20',6000.00,'Government');
SELECT SUM(grantAmount) FROM TheaterGrants WHERE grantSource = 'Government' AND grantDate >= '2022-01-01' AND grantDate <= '2022-12-31';
How many sustainable construction projects were completed in Texas in 2019?
CREATE TABLE project_data (project_number INT,state VARCHAR(20),year INT,is_sustainable BOOLEAN); INSERT INTO project_data (project_number,state,year,is_sustainable) VALUES (1,'Texas',2019,TRUE); INSERT INTO project_data (project_number,state,year,is_sustainable) VALUES (2,'Texas',2018,FALSE);
SELECT COUNT(*) FROM project_data WHERE state = 'Texas' AND is_sustainable = TRUE AND year = 2019;
Insert new records for a public park named 'ParkF' with a 'Size' value of 50 and 'Location' value of 'North', in the 'CityData' schema's 'CityParks' table.
CREATE SCHEMA CityData; CREATE TABLE CityParks (Name varchar(255),Size int,Location varchar(255));
INSERT INTO CityData.CityParks (Name, Size, Location) VALUES ('ParkF', 50, 'North');
What is the average price of eco-friendly tours in each city?
CREATE TABLE eco_tour (id INT,name VARCHAR(255),type VARCHAR(255),city VARCHAR(255),price INT,is_eco_friendly BOOLEAN); INSERT INTO eco_tour (id,name,type,city,price,is_eco_friendly) VALUES (1,'Bike City Tour','Tour','Berlin',50,true);
SELECT city, AVG(price) FROM eco_tour WHERE is_eco_friendly = true GROUP BY city;
What is the total production quantity for indica strains in California?
CREATE TABLE production (strain_type VARCHAR(10),production_quantity INT,state VARCHAR(20)); INSERT INTO production (strain_type,production_quantity,state) VALUES ('indica',1200,'California'); INSERT INTO production (strain_type,production_quantity,state) VALUES ('sativa',800,'California');
SELECT SUM(production_quantity) FROM production WHERE strain_type = 'indica' AND state = 'California';
Who is the top performing fund manager in the 'ESG' category?
CREATE TABLE fund_managers (id INT,name VARCHAR(50),category VARCHAR(20),performance FLOAT); INSERT INTO fund_managers (id,name,category,performance) VALUES (1,'John Smith','ESG',92.5),(2,'Jane Doe','traditional',88.0),(3,'Mary Major','ESG',90.3),(4,'Mike Minor','traditional',85.2);
SELECT name FROM fund_managers WHERE category = 'ESG' ORDER BY performance DESC LIMIT 1;
Calculate the difference between the waste generation figures of urban and rural areas.
CREATE TABLE WasteGeneration (id INT,area VARCHAR(10),amount INT); INSERT INTO WasteGeneration (id,area,amount) VALUES (1,'urban',3500),(2,'rural',2000);
SELECT (SELECT SUM(amount) FROM WasteGeneration WHERE area = 'urban') - (SELECT SUM(amount) FROM WasteGeneration WHERE area = 'rural');
List all community education programs and their respective budgets
CREATE TABLE education_programs (id INT,program_name VARCHAR(255),budget INT); INSERT INTO education_programs (id,program_name,budget) VALUES (1,'Wildlife Awareness',15000),(2,'Conservation Workshops',20000),(3,'Nature Camps',10000);
SELECT program_name, budget FROM education_programs;
What is the total CO2 emissions for garments made of wool?
CREATE TABLE inventory (id INT,garment_id INT,material VARCHAR(50),CO2_emissions INT); INSERT INTO inventory (id,garment_id,material,CO2_emissions) VALUES (1,1011,'wool',12);
SELECT SUM(CO2_emissions) FROM inventory WHERE material = 'wool';
What is the minimum age of 'retail' union members who are female?
CREATE TABLE retail_union_members (member_id INT,union VARCHAR(20),gender VARCHAR(10),age INT); INSERT INTO retail_union_members (member_id,union,gender,age) VALUES (1,'Retail','Female',25); INSERT INTO retail_union_members (member_id,union,gender,age) VALUES (2,'Retail','Male',30);
SELECT MIN(age) FROM retail_union_members WHERE gender = 'Female';
What is the total number of marine species in the Arctic and Antarctic Oceans?
CREATE TABLE marine_species_by_ocean (species_name VARCHAR(50),ocean_name VARCHAR(50)); INSERT INTO marine_species_by_ocean (species_name,ocean_name) VALUES ('Polar Bear','Arctic'),('Krill','Antarctic'),('Walrus','Arctic');
SELECT COUNT(DISTINCT species_name) FROM marine_species_by_ocean WHERE ocean_name IN ('Arctic', 'Antarctic');
Who were the top 3 donors in 2020 and what was their total donation amount?
CREATE TABLE Donors (id INT,donor VARCHAR(50),city VARCHAR(50),amount FLOAT,donation_date DATE); INSERT INTO Donors (id,donor,city,amount,donation_date) VALUES (1,'John Doe','New York',500,'2020-01-01'); INSERT INTO Donors (id,donor,city,amount,donation_date) VALUES (2,'Jane Smith','Los Angeles',300,'2020-02-01');
SELECT donor, SUM(amount) as total_donation FROM Donors WHERE YEAR(donation_date) = 2020 GROUP BY donor ORDER BY total_donation DESC LIMIT 3;
How many pollution incidents were reported in the Atlantic Ocean in 2021?
CREATE TABLE pollution_reports (id INT,location TEXT,date DATE,type TEXT); INSERT INTO pollution_reports (id,location,date,type) VALUES (1,'Bermuda Triangle','2021-06-01','Oil Spill'),(2,'North Atlantic Garbage Patch','2021-07-15','Plastic Waste');
SELECT COUNT(*) FROM pollution_reports WHERE location LIKE '%Atlantic%' AND date BETWEEN '2021-01-01' AND '2021-12-31';