instruction
stringlengths
0
1.06k
input
stringlengths
11
5.3k
response
stringlengths
2
4.44k
Insert new records for 5 fans who signed up for the soccer team newsletter
CREATE TABLE fans (fan_id INT,first_name VARCHAR(50),last_name VARCHAR(50),dob DATE,signed_up_for_newsletter BOOLEAN); INSERT INTO fans (fan_id,first_name,last_name,dob,signed_up_for_newsletter) VALUES (1,'John','Doe','1990-05-01',false),(2,'Jane','Smith','1985-08-12',false);
INSERT INTO fans (fan_id, first_name, last_name, dob, signed_up_for_newsletter) VALUES (3, 'Michael', 'Lee', '1995-03-25', true), (4, 'Sophia', 'Park', '2000-06-18', true), (5, 'William', 'Johnson', '2005-11-10', true), (6, 'Olivia', 'Kim', '2007-09-22', true), (7, 'Ethan', 'Lee', '2010-02-03', true);
Display support programs in alphabetical order by name
CREATE TABLE support_programs (program_id INT PRIMARY KEY,name VARCHAR(255),description TEXT,category VARCHAR(255),budget DECIMAL(10,2));
SELECT * FROM support_programs ORDER BY name ASC;
Which threat actors have targeted systems with a CVE score greater than 7 in the last year?
CREATE TABLE threat_actors (threat_actor_id INT,threat_actor_name VARCHAR(255));CREATE TABLE targeted_systems (system_id INT,system_name VARCHAR(255),sector VARCHAR(255),threat_actor_id INT);CREATE TABLE cve_scores (system_id INT,score INT,scan_date DATE);CREATE TABLE scan_dates (scan_date DATE,system_id INT);
SELECT ta.threat_actor_name FROM threat_actors ta INNER JOIN targeted_systems ts ON ta.threat_actor_id = ts.threat_actor_id INNER JOIN cve_scores c ON ts.system_id = c.system_id INNER JOIN scan_dates sd ON ts.system_id = sd.system_id WHERE c.score > 7 AND sd.scan_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR);
What is the total number of workouts performed by users from the USA?
CREATE TABLE workouts (id INT,user_id INT,workout_date DATE,calories INT,country VARCHAR(50)); INSERT INTO workouts (id,user_id,workout_date,calories,country) VALUES (1,123,'2022-01-01',300,'USA'); INSERT INTO workouts (id,user_id,workout_date,calories,country) VALUES (2,456,'2022-01-02',400,'Canada');
SELECT SUM(calories) FROM workouts WHERE country = 'USA';
What are the distinct spacecraft types in the 'spacecraft_types' table, ordered by their launch date?
CREATE TABLE spacecraft_types (id INT,spacecraft_type VARCHAR(50),launch_date DATE); INSERT INTO spacecraft_types (id,spacecraft_type,launch_date) VALUES (1,'Space Shuttle','1981-04-12'),(2,'Soyuz','1967-11-29'),(3,'Delta IV','2002-11-20');
SELECT DISTINCT spacecraft_type FROM spacecraft_types ORDER BY launch_date;
What is the total number of games played by players who have used virtual reality technology, and what is the average age of those players?
CREATE TABLE Players (PlayerID INT,Age INT,Gender VARCHAR(10),GamesPlayed INT,VR INT);
SELECT AVG(Age), SUM(GamesPlayed) FROM Players WHERE VR = 1;
Which menu items have the lowest food cost for gluten-free dishes?
CREATE TABLE gluten_free_menu_items (menu_item_id INT,dish_type VARCHAR(255),food_cost DECIMAL(5,2)); INSERT INTO gluten_free_menu_items (menu_item_id,dish_type,food_cost) VALUES (1,'Gluten-free',3.50),(2,'Vegetarian',2.50),(3,'Gluten-free',1.50);
SELECT dish_type, MIN(food_cost) FROM gluten_free_menu_items WHERE dish_type = 'Gluten-free';
What is the number of community health workers who identify as non-binary, by state, ordered by the number of non-binary workers in descending order?
CREATE TABLE CommunityHealthWorkers (WorkerID INT,Age INT,Gender VARCHAR(10),State VARCHAR(20)); INSERT INTO CommunityHealthWorkers (WorkerID,Age,Gender,State) VALUES (1,34,'Female','California'),(2,42,'Male','Texas'),(3,50,'Female','California'),(4,48,'Non-binary','New York'),(5,30,'Non-binary','California'),(6,45,'Ma...
SELECT State, COUNT(CASE WHEN Gender = 'Non-binary' THEN 1 END) as NumNonbinary FROM CommunityHealthWorkers GROUP BY State ORDER BY NumNonbinary DESC;
What is the total number of tickets sold for events in the 'music' and 'theater' categories?
CREATE TABLE events (id INT,name TEXT,category TEXT,tickets_sold INT); INSERT INTO events (id,name,category,tickets_sold) VALUES (1,'Concert','music',200),(2,'Play','theater',150),(3,'Festival','music',300);
SELECT SUM(tickets_sold) FROM events WHERE category IN ('music', 'theater');
What is the total length of all public transportation projects in New York City that have been completed since 2015, and the average completion time for these projects, ordered by the completion time?
CREATE TABLE transport_projects (id INT,project_name VARCHAR(255),location VARCHAR(255),length FLOAT,completion_time INT); INSERT INTO transport_projects (id,project_name,location,length,completion_time) VALUES (1,'Subway Extension','New York City',5.6,48),(2,'Bus Rapid Transit','New York City',12.4,36),(3,'Light Rail'...
SELECT SUM(length), AVG(completion_time) FROM transport_projects WHERE location = 'New York City' AND completion_time >= 2015 GROUP BY completion_time ORDER BY completion_time;
How many countries have registered deep-sea expeditions in the last decade?
CREATE TABLE deep_sea_expeditions (expedition_id INTEGER,country TEXT,year INTEGER); INSERT INTO deep_sea_expeditions (expedition_id,country,year) VALUES (1,'France',2015),(2,'Japan',2018),(3,'Canada',2019),(4,'New Zealand',2020),(5,'United States',2017),(6,'Indonesia',2016);
SELECT COUNT(DISTINCT country) FROM deep_sea_expeditions WHERE year BETWEEN 2011 AND 2020;
What is the average capacity of cargo ships owned by Global Shipping?
CREATE TABLE ships (id INT,name VARCHAR(255),capacity INT); INSERT INTO ships (id,name,capacity) VALUES (1,'Global1',5000),(2,'Global2',7000),(3,'Local1',3000);
SELECT AVG(capacity) FROM ships WHERE name LIKE 'Global%';
Update the 'practice_description' field to 'Implemented greywater recycling system' in the 'sustainable_practices' table where 'contractor_name' is 'EcoBuilders' and 'practice_date' is '2023-01-10'
CREATE TABLE sustainable_practices (contractor_name VARCHAR(50),practice_date DATE,practice_description VARCHAR(100)); INSERT INTO sustainable_practices (contractor_name,practice_date,practice_description) VALUES ('EcoBuilders','2023-01-10','Used recycled materials for wall construction.'),('SolarCo Inc.','2023-01-15',...
UPDATE sustainable_practices SET practice_description = 'Implemented greywater recycling system' WHERE contractor_name = 'EcoBuilders' AND practice_date = '2023-01-10';
What is the total number of containers handled by each vessel in the Port of Singapore?
CREATE TABLE ports (id INT,name TEXT); INSERT INTO ports (id,name) VALUES (1,'Port of Singapore'); CREATE TABLE vessel_arrivals (id INT,port_id INT,vessel_id INT,arrival_date DATE); INSERT INTO vessel_arrivals (id,port_id,vessel_id,arrival_date) VALUES (1,1,1,'2022-01-01'),(2,1,2,'2022-01-05'),(3,1,1,'2022-01-15'); CRE...
SELECT v.name, SUM(ce.quantity) FROM vessels v JOIN vessel_arrivals va ON v.id = va.vessel_id JOIN container_events ce ON v.id = ce.vessel_id WHERE va.port_id = (SELECT id FROM ports WHERE name = 'Port of Singapore') GROUP BY v.name;
What is the maximum fare for each route type in the 'route' table?
CREATE TABLE route (id INT,name TEXT,type TEXT,fare FLOAT); INSERT INTO route (id,name,type,fare) VALUES (1,'Central Line','Underground',3.5),(2,'Circle Line','Underground',4.2),(3,'Jubilee Line','Underground',5.0),(4,'Bus Route 123','Bus',2.5),(5,'Bus Route 456','Bus',3.0);
SELECT type, MAX(fare) as max_fare FROM route GROUP BY type;
What is the landfill capacity for the country of South Africa for the year 2030?
CREATE TABLE country_landfill_capacity (country VARCHAR(20),year INT,capacity INT); INSERT INTO country_landfill_capacity (country,year,capacity) VALUES ('South Africa',2030,8000000);
SELECT capacity FROM country_landfill_capacity WHERE country = 'South Africa' AND year = 2030;
Display the names of teachers and topics of professional development for those teachers in '2019'
CREATE TABLE teachers (teacher_id INT,teacher_name VARCHAR(50)); CREATE TABLE teacher_pd (teacher_id INT,pd_year INT,pd_topic VARCHAR(50)); INSERT INTO teachers (teacher_id,teacher_name) VALUES (100,'Ms. Smith'),(200,'Mr. Johnson'),(300,'Mx. Garcia'); INSERT INTO teacher_pd (teacher_id,pd_year,pd_topic) VALUES (100,201...
SELECT teachers.teacher_name, teacher_pd.pd_topic FROM teachers INNER JOIN teacher_pd ON teachers.teacher_id = teacher_pd.teacher_id WHERE teacher_pd.pd_year = 2019;
Who is the coach of the team with the lowest average score in the 'nba_teams' table?
CREATE TABLE nba_teams (team_id INT,team_name VARCHAR(100),avg_score DECIMAL(5,2),coach VARCHAR(100));
SELECT coach FROM nba_teams WHERE avg_score = (SELECT MIN(avg_score) FROM nba_teams);
What is the total revenue for museum shop sales in the month of January?
CREATE TABLE sales (id INT,date DATE,item VARCHAR(255),revenue DECIMAL(10,2)); INSERT INTO sales (id,date,item,revenue) VALUES (1,'2021-01-01','Postcard',1.50),(2,'2022-02-01','Mug',10.00);
SELECT SUM(revenue) FROM sales WHERE MONTH(date) = 1;
What is the total number of bytes transferred by a specific server?
CREATE TABLE network_traffic (id INT,server VARCHAR(255),bytes INT); INSERT INTO network_traffic (id,server,bytes) VALUES (1,'ServerA',1000),(2,'ServerB',2000),(3,'ServerA',1500),(4,'ServerC',500),(5,'ServerB',2500);
SELECT server, SUM(bytes) as total_bytes FROM network_traffic WHERE server = 'ServerA' GROUP BY server;
What is the average water consumption per capita in the state of New South Wales, Australia in 2018?
CREATE TABLE StateWaterUsage_NSW (id INT,state VARCHAR,year INT,population INT,consumption FLOAT); INSERT INTO StateWaterUsage_NSW (id,state,year,population,consumption) VALUES (1,'New South Wales',2018,7958748,54121.5),(2,'New South Wales',2019,8007345,55003.2),(3,'Victoria',2018,6231777,38450.6);
SELECT consumption / population AS consumption_per_capita FROM StateWaterUsage_NSW WHERE state = 'New South Wales' AND year = 2018;
List all cybersecurity policies that have not been reviewed in the last year, in alphabetical order.
CREATE TABLE cybersecurity_policies (id INT,policy_name VARCHAR(255),last_reviewed DATE); INSERT INTO cybersecurity_policies (id,policy_name,last_reviewed) VALUES (1,'Policy Alpha','2021-01-01'),(2,'Policy Bravo','2020-12-01'),(3,'Policy Charlie','2021-05-01');
SELECT policy_name FROM cybersecurity_policies WHERE last_reviewed < DATEADD(year, -1, GETDATE()) ORDER BY policy_name;
What is the minimum landfill capacity in the state of California in 2020?
CREATE TABLE landfill_capacity (state VARCHAR(255),year INT,capacity INT); INSERT INTO landfill_capacity (state,year,capacity) VALUES ('California',2020,70000),('California',2020,80000),('California',2020,60000);
SELECT MIN(capacity) FROM landfill_capacity WHERE state = 'California' AND year = 2020;
Which countries have the most female film directors?
CREATE TABLE country (country_id INT,country_name VARCHAR(50)); INSERT INTO country (country_id,country_name) VALUES (1,'United States'),(2,'Canada'),(3,'France'); CREATE TABLE film_director (director_id INT,director_name VARCHAR(50),country_id INT); INSERT INTO film_director (director_id,director_name,country_id) VALU...
SELECT country_name, COUNT(*) as num_female_directors FROM film_director fd JOIN country c ON fd.country_id = c.country_id WHERE director_name = 'Ava DuVernay' OR director_name = 'Celine Sciamma' GROUP BY country_name ORDER BY num_female_directors DESC;
What is the average water consumption by agricultural customers in the month of June?
CREATE TABLE water_usage(customer_id INT,usage FLOAT,customer_type TEXT,month DATE); INSERT INTO water_usage(customer_id,usage,customer_type,month) VALUES (1,500,'agricultural','2022-06-01'),(2,350,'agricultural','2022-06-01'),(3,700,'agricultural','2022-06-01'),(4,600,'residential','2022-06-01');
SELECT AVG(usage) FROM water_usage WHERE customer_type = 'agricultural' AND month = '2022-06-01';
What is the average environmental impact per mine located in Mexico?
CREATE TABLE mines (mine_id INT,name TEXT,location TEXT,environmental_impact FLOAT); INSERT INTO mines (mine_id,name,location,environmental_impact) VALUES (1,'ABC Mine','USA',200),(2,'DEF Mine','Mexico',300);
SELECT location, AVG(environmental_impact) FROM mines GROUP BY location;
What are the details of space missions that encountered asteroids?
CREATE TABLE SpaceMissions (id INT,mission VARCHAR(255),year INT,organization VARCHAR(255)); CREATE TABLE AsteroidEncounters (id INT,mission_id INT,asteroid VARCHAR(255));
SELECT SpaceMissions.mission, SpaceMissions.year, SpaceMissions.organization, AsteroidEncounters.asteroid FROM SpaceMissions INNER JOIN AsteroidEncounters ON SpaceMissions.id = AsteroidEncounters.mission_id;
Delete menu items with a price greater than $15 from the menu_items table
CREATE TABLE menu_items (menu_item_id INT,name VARCHAR(255),description TEXT,price DECIMAL(5,2),category VARCHAR(255),sustainability_rating INT);
DELETE FROM menu_items WHERE price > 15.00;
What is the average wellbeing score for athletes in each sport?
CREATE TABLE athletes (id INT,sport_id INT,wellbeing_score INT); INSERT INTO athletes (id,sport_id,wellbeing_score) VALUES (1,1,80),(2,2,85),(3,1,75),(4,3,90); CREATE TABLE sports (id INT,name VARCHAR(255)); INSERT INTO sports (id,name) VALUES (1,'Basketball'),(2,'Soccer'),(3,'Football');
SELECT s.name, AVG(a.wellbeing_score) as avg_wellbeing_score FROM athletes a JOIN sports s ON a.sport_id = s.id GROUP BY s.name;
What is the average amount of fines issued per officer in the City of Austin's Police Department?
CREATE TABLE police_department(officer_id INT,fine_amount FLOAT); INSERT INTO police_department(officer_id,fine_amount) VALUES (1,100.0),(2,200.0),(3,300.0);
SELECT AVG(fine_amount) FROM police_department;
What is the total CO2 emissions for fish feed production in India in 2021?
CREATE TABLE fish_feed_production (country VARCHAR(50),year INT,co2_emissions FLOAT);
SELECT SUM(co2_emissions) FROM fish_feed_production WHERE country = 'India' AND year = 2021;
What is the 5-year moving average of annual energy consumption in Oceania?
CREATE TABLE energy_oceania (country VARCHAR(20),year INT,energy_consumption DECIMAL(5,2)); INSERT INTO energy_oceania VALUES ('OC',2010,10.1),('OC',2011,10.3),('OC',2012,10.5),('OC',2013,10.7),('OC',2014,10.9),('OC',2015,11.1),('OC',2016,11.3),('OC',2017,11.5),('OC',2018,11.7),('OC',2019,11.9);
SELECT year, AVG(energy_consumption) OVER (ORDER BY year ROWS BETWEEN 4 PRECEDING AND CURRENT ROW) AS moving_avg FROM energy_oceania WHERE country = 'OC';
How many Indica strains were produced in Colorado in 2021?
CREATE TABLE production (id INT,strain_id INT,year INT,quantity INT); CREATE TABLE strains (id INT,name VARCHAR(255),type VARCHAR(255)); INSERT INTO strains (id,name,type) VALUES (1,'Northern Lights','Indica'); INSERT INTO production (id,strain_id,year,quantity) VALUES (1,1,2021,5000);
SELECT SUM(production.quantity) FROM production JOIN strains ON production.strain_id = strains.id WHERE strains.type = 'Indica' AND production.year = 2021;
What is the daily count and average number of malware threats from Asian threat intelligence sources?
CREATE TABLE threat_intel(id INT,date DATE,source VARCHAR(50),category VARCHAR(50),description VARCHAR(255)); INSERT INTO threat_intel(id,date,source,category,description) VALUES (1,'2021-01-01','Asian Threat Intelligence','malware','A new malware variant has been discovered'),(2,'2021-01-02','Asian Threat Intelligence...
SELECT date, COUNT(*) as total_threats, AVG(category = 'malware'::int) as avg_malware FROM threat_intel WHERE source = 'Asian Threat Intelligence' GROUP BY date ORDER BY date;
Add a new record for ash tree in the 'East' region with a carbon sequestration rate of 4.5 tons per hectare for the year 2021
CREATE TABLE carbon_sequestration (year INT,tree_type VARCHAR(255),region VARCHAR(255),sequestration_rate FLOAT);
INSERT INTO carbon_sequestration (year, tree_type, region, sequestration_rate) VALUES (2021, 'Ash', 'East', 4.5);
List all wells with production rates higher than the average well in California?
CREATE TABLE wells (well_id INT,well_name TEXT,location TEXT,production_rate FLOAT); INSERT INTO wells (well_id,well_name,location,production_rate) VALUES (1,'Well A','Texas',500),(2,'Well B','California',700),(3,'Well C','California',600);
SELECT * FROM wells WHERE production_rate > (SELECT AVG(production_rate) FROM wells WHERE location = 'California')
Show the top 5 most popular workout types and the number of times they were performed
CREATE TABLE workout_type_counts (workout_type VARCHAR(255),num_times INT);
SELECT workout_type, SUM(num_times) as total_times FROM workout_type_counts GROUP BY workout_type ORDER BY total_times DESC LIMIT 5;
Delete a record from the 'Donations' table
CREATE TABLE Donations (DonationID INT PRIMARY KEY,DonorID INT,Amount DECIMAL(10,2),DonationDate DATE);
DELETE FROM Donations WHERE DonationID = 301;
What are the names of all ingredients that are used in both cruelty-free certified products and products not certified as cruelty-free, but are not sourced from 'Organic Farms'?
CREATE TABLE ingredients (ingredient_name VARCHAR(50)); INSERT INTO ingredients (ingredient_name) VALUES ('Water'),('Mineral Powder'),('Chemical X'),('Chemical Y');
SELECT ingredients.ingredient_name FROM ingredients JOIN product_ingredients ON ingredients.ingredient_name = product_ingredients.ingredient WHERE product_ingredients.ingredient_source IN (SELECT ingredient_source FROM product_ingredients WHERE product_ingredients.product_name IN (SELECT products.product_name FROM prod...
What is the total number of articles published on topics related to disinformation detection?
CREATE TABLE articles (title VARCHAR(255),topic VARCHAR(255));
SELECT COUNT(*) FROM articles WHERE topic LIKE '%disinformation detection%';
Insert new records of renewable energy projects for 2023 in the 'renewable_energy' schema, if there are none.
CREATE TABLE renewable_energy.projects (id INT,project_name VARCHAR(255),start_date DATE);
INSERT INTO renewable_energy.projects (id, project_name, start_date) SELECT seq as id, 'Wind Farm Texas' as project_name, '2023-01-01' as start_date FROM generate_series(1, 5) as seq WHERE NOT EXISTS ( SELECT 1 FROM renewable_energy.projects WHERE start_date = '2023-01-01' );
How many employees were hired before 2021?
CREATE TABLE Employees (EmployeeID INT,HireDate DATE); INSERT INTO Employees (EmployeeID,HireDate) VALUES (1,'2021-01-01'),(2,'2020-01-01'),(3,'2019-01-01'),(4,'2021-03-01'),(5,'2021-12-31');
SELECT COUNT(*) FROM Employees WHERE YEAR(HireDate) < 2021;
Show autonomous vehicles with the highest safety scores
CREATE TABLE AutonomousDriving (Vehicle VARCHAR(50),Manufacturer VARCHAR(50),Year INT,AutonomousLevel FLOAT); INSERT INTO AutonomousDriving (Vehicle,Manufacturer,Year,AutonomousLevel) VALUES ('Tesla Model S','Tesla',2020,2.5); CREATE TABLE SafetyTesting (Vehicle VARCHAR(50),Manufacturer VARCHAR(50),Year INT,Score INT);
SELECT ST.Vehicle, ST.Manufacturer, ST.Year, ST.Score, AD.AutonomousLevel FROM SafetyTesting ST INNER JOIN AutonomousDriving AD ON ST.Vehicle = AD.Vehicle WHERE ST.Score = (SELECT MAX(Score) FROM SafetyTesting);
How many digital assets are registered in the 'crypto_assets' table, grouped by their 'asset_type'?
CREATE TABLE crypto_assets (asset_id INT,asset_name VARCHAR(100),asset_type VARCHAR(50)); INSERT INTO crypto_assets (asset_id,asset_name,asset_type) VALUES (1,'Bitcoin','Cryptocurrency'),(2,'Ethereum','Cryptocurrency'),(3,'Chainlink','Token');
SELECT asset_type, COUNT(*) FROM crypto_assets GROUP BY asset_type;
What is the earliest delivery time for each courier in the 'courier_performances' view?
CREATE VIEW courier_performances AS SELECT courier_id,MIN(delivery_time) as earliest_delivery_time FROM orders GROUP BY courier_id;
SELECT courier_id, MIN(earliest_delivery_time) as earliest_delivery_time FROM courier_performances GROUP BY courier_id;
List the names and total costs of all projects that started before 2018 and were completed after 2016.
CREATE TABLE Projects (ProjectID INT,Name VARCHAR(255),StartDate DATE,EndDate DATE,TotalCost DECIMAL(10,2));
SELECT Name, SUM(TotalCost) as TotalCost FROM Projects WHERE StartDate < '2018-01-01' AND EndDate > '2016-12-31' GROUP BY Name;
Which programs had the most volunteer hours in 2022?
CREATE TABLE volunteer_hours (volunteer_id INT,program_id INT,hours DECIMAL(10,2),hour_date DATE); INSERT INTO volunteer_hours VALUES (14,101,3.00,'2022-01-01'),(15,101,2.50,'2022-02-01'),(16,102,4.00,'2022-01-10');
SELECT program_id, SUM(hours) FROM volunteer_hours GROUP BY program_id ORDER BY SUM(hours) DESC LIMIT 1;
What is the total production quantity (in metric tons) of Neodymium and Praseodymium for each year?
CREATE TABLE production (element VARCHAR(10),year INT,quantity INT); INSERT INTO production (element,year,quantity) VALUES ('Neodymium',2015,12000),('Neodymium',2016,15000),('Praseodymium',2015,7000),('Praseodymium',2016,8000);
SELECT SUM(quantity) as total_production, year FROM production WHERE element IN ('Neodymium', 'Praseodymium') GROUP BY year;
How many hotels have adopted AI in South America?
CREATE TABLE ai_adoption (hotel_id INT,country VARCHAR(255),ai_adoption BOOLEAN); INSERT INTO ai_adoption (hotel_id,country,ai_adoption) VALUES (1,'South America',true),(2,'South America',false),(3,'Africa',true);
SELECT COUNT(*) FROM ai_adoption WHERE country = 'South America' AND ai_adoption = true;
Update the 'funding_amount' for the 'Climate Change Impact Study' to $650000 in the 'research_projects' table
CREATE TABLE research_projects (id INT PRIMARY KEY,project_name VARCHAR(255),funding_source VARCHAR(255),funding_amount DECIMAL(10,2)); INSERT INTO research_projects (id,project_name,funding_source,funding_amount) VALUES (1,'Climate Change Impact Study','National Science Foundation',750000.00),(2,'Biodiversity Loss in ...
UPDATE research_projects SET funding_amount = 650000.00 WHERE project_name = 'Climate Change Impact Study';
What was the total revenue for each bus route in the month of January 2022?
CREATE TABLE route (route_id INT,route_name TEXT);CREATE TABLE fare (fare_id INT,route_id INT,fare_amount DECIMAL,collection_date DATE); INSERT INTO route (route_id,route_name) VALUES (1,'RouteA'),(2,'RouteB'),(3,'RouteC'); INSERT INTO fare (fare_id,route_id,fare_amount,collection_date) VALUES (1,1,5.00,'2022-01-01'),(...
SELECT r.route_name, SUM(f.fare_amount) as total_revenue FROM route r JOIN fare f ON r.route_id = f.route_id WHERE f.collection_date BETWEEN '2022-01-01' AND '2022-01-31' GROUP BY r.route_name;
Which technology for social good projects received funding in Q3 2019?
CREATE TABLE social_good_projects (id INT,project_name VARCHAR(255),funding_quarter VARCHAR(10)); INSERT INTO social_good_projects (id,project_name,funding_quarter) VALUES (1,'E-learning for Refugees','Q3 2019'),(2,'Accessible Health Tech','Q1 2020');
SELECT project_name FROM social_good_projects WHERE funding_quarter = 'Q3 2019';
Delete records of clients who are not part of any financial wellbeing program from the clients table.
CREATE TABLE clients (client_id INT,name VARCHAR(50),program VARCHAR(50)); CREATE TABLE financial_wellbeing_programs (program VARCHAR(50));
DELETE FROM clients WHERE client_id IN (SELECT client_id FROM clients c1 WHERE program NOT IN (SELECT program FROM financial_wellbeing_programs) GROUP BY client_id HAVING COUNT(*) = (SELECT COUNT(*) FROM clients c2 WHERE c1.client_id = c2.client_id));
List the number of graduate students enrolled in each department, grouped by gender and ethnicity.
CREATE TABLE Department (id INT,name VARCHAR(255),college VARCHAR(255)); INSERT INTO Department (id,name,college) VALUES (1,'Biology','College of Science'),(2,'Chemistry','College of Science'),(3,'Physics','College of Science'); CREATE TABLE GraduateStudents (id INT,department_id INT,gender VARCHAR(50),ethnicity VARCHA...
SELECT d.name AS Department, g.gender, g.ethnicity, COUNT(g.id) AS Enrollment FROM GraduateStudents g JOIN Department d ON g.department_id = d.id GROUP BY d.name, g.gender, g.ethnicity;
What is the total number of cultural events in each city?
CREATE TABLE cultural_events (id INT,city TEXT,event_type TEXT); INSERT INTO cultural_events (id,city,event_type) VALUES (1,'Tokyo','Concert'),(2,'Tokyo','Theater'),(3,'Tokyo','Exhibition'),(4,'Paris','Concert'),(5,'Paris','Theater');
SELECT city, COUNT(*) FROM cultural_events GROUP BY city;
What is the total installed capacity (MW) of wind energy in Australia?
CREATE TABLE aus_renewable_energy (id INT,source TEXT,capacity_mw FLOAT); INSERT INTO aus_renewable_energy (id,source,capacity_mw) VALUES (1,'Wind',4000.0),(2,'Solar',8000.0),(3,'Hydro',6000.0);
SELECT SUM(capacity_mw) FROM aus_renewable_energy WHERE source = 'Wind';
Add new record to defense_spending table, including '2022' as year, 'USA' as country, and '70000000000' as amount
CREATE TABLE defense_spending (id INT PRIMARY KEY,year INT,country VARCHAR(100),amount FLOAT);
INSERT INTO defense_spending (year, country, amount) VALUES (2022, 'USA', 70000000000);
Who are the top 3 players with the highest scores in Europe?
CREATE TABLE PlayerScores (PlayerID int,PlayerName varchar(50),Score int,Country varchar(50)); INSERT INTO PlayerScores (PlayerID,PlayerName,Score,Country) VALUES (1,'John Doe',90,'USA'),(2,'Jane Smith',100,'Europe'),(3,'Bob Johnson',80,'Europe'),(4,'Alice Davis',70,'Europe');
SELECT PlayerName, Score FROM PlayerScores WHERE Country = 'Europe' ORDER BY Score DESC LIMIT 3;
What is the count of water treatment plants in the Africa region constructed before 2015?
CREATE TABLE InfrastructureProjects (id INT,name VARCHAR(100),region VARCHAR(50),project_type VARCHAR(50),completion_date DATE); INSERT INTO InfrastructureProjects (id,name,region,project_type,completion_date) VALUES (1,'Nairobi Water Treatment Plant','Africa','water treatment plant','2012-01-01');
SELECT COUNT(*) FROM InfrastructureProjects WHERE region = 'Africa' AND project_type = 'water treatment plant' AND completion_date < '2015-01-01';
What is the average temperature (in Kelvin) per spacecraft per week, ranked in descending order?
CREATE TABLE spacecraft_temperatures (spacecraft_name TEXT,temperature FLOAT,mission_date DATE);
SELECT spacecraft_name, DATE_TRUNC('week', mission_date) as mission_week, AVG(temperature) as avg_temperature, RANK() OVER (PARTITION BY spacecraft_name ORDER BY AVG(temperature) DESC) as temp_rank FROM spacecraft_temperatures GROUP BY spacecraft_name, mission_week ORDER BY spacecraft_name, temp_rank;
What is the average speed of all vessels in the 'vessels' table?
CREATE TABLE vessels (id INT,name TEXT,type TEXT,max_speed REAL); INSERT INTO vessels (id,name,type,max_speed) VALUES (1,'Fishing Vessel 1','Fishing',20.5),(2,'Cargo Ship 1','Cargo',35.2);
SELECT AVG(max_speed) FROM vessels;
What is the total revenue generated from all games?
CREATE TABLE TotalRevenue (GameID INT,GameType VARCHAR(20),Revenue INT); INSERT INTO TotalRevenue (GameID,GameType,Revenue) VALUES (1,'Action',5000),(2,'Adventure',6000),(3,'Simulation',8000),(4,'Action',7000),(5,'Simulation',9000),(6,'Adventure',10000),(7,'Action',8000),(8,'Simulation',6000);
SELECT SUM(Revenue) FROM TotalRevenue;
Which building permits were issued in California in Q1 2021?
CREATE TABLE building_permits (state VARCHAR(20),year INT,quarter INT,permits INT); INSERT INTO building_permits VALUES ('California',2021,1,3000),('California',2021,2,3500),('California',2020,4,2500);
SELECT permits FROM building_permits WHERE state = 'California' AND year = 2021 AND quarter BETWEEN 1 AND 1;
What is the minimum number of marine species in a marine protected area?
CREATE TABLE marine_protected_areas (area_name TEXT,num_species INTEGER); INSERT INTO marine_protected_areas (area_name,num_species) VALUES ('Galapagos Islands',5000),('Great Barrier Reef',1500);
SELECT MIN(num_species) FROM marine_protected_areas;
What are the names of fishing vessels with invalid registration numbers?
CREATE TABLE fishing_vessels (name VARCHAR(255),registration_number VARCHAR(255)); INSERT INTO fishing_vessels (name,registration_number) VALUES ('Vessel1','AA12345'),('Vessel2','ZZ99999');
SELECT name FROM fishing_vessels WHERE NOT REGEXP_LIKE(registration_number, '^[A-Z]{2}[0-9]{5}$')
List all Mars rovers and their respective first and last successful landing dates.
CREATE TABLE mars_rovers (id INT,rover VARCHAR(255),launch_date DATE,landing_date DATE); INSERT INTO mars_rovers (id,rover,launch_date,landing_date) VALUES (1,'Spirit','2003-06-10','2004-01-04'),(2,'Opportunity','2003-07-07','2004-01-25'),(3,'Curiosity','2011-11-26','2012-08-06');
SELECT rover, MIN(launch_date) AS first_successful_launch, MAX(landing_date) AS last_successful_landing FROM mars_rovers WHERE landing_date IS NOT NULL GROUP BY rover;
What is the total number of heritage sites by type?
CREATE TABLE heritage_sites (id INT,type VARCHAR(50),name VARCHAR(100)); INSERT INTO heritage_sites (id,type,name) VALUES (1,'Historic Site','Anasazi Ruins'),(2,'Museum','Metropolitan Museum of Art'),(3,'Historic Site','Alamo');
SELECT type, COUNT(*) FROM heritage_sites GROUP BY type;
Get vessel details with vessel_id 4 and their corresponding safety inspection status from the vessel_details and safety_records tables
CREATE TABLE vessel_details (vessel_id INT,vessel_name VARCHAR(50)); CREATE TABLE safety_records (vessel_id INT,inspection_status VARCHAR(10));
SELECT vd.vessel_id, vd.vessel_name, sr.inspection_status FROM vessel_details vd INNER JOIN safety_records sr ON vd.vessel_id = sr.vessel_id WHERE vd.vessel_id = 4;
Identify the textile sourcing countries with the highest sustainability scores for cotton and hemp.
CREATE TABLE fabric_sourcing (id INT PRIMARY KEY,fabric_type VARCHAR(255),country VARCHAR(255),sustainability_score FLOAT); INSERT INTO fabric_sourcing (id,fabric_type,country,sustainability_score) VALUES (1,'Cotton','India',0.75),(2,'Polyester','China',0.5),(3,'Hemp','France',0.9),(4,'Rayon','Indonesia',0.6),(5,'Cotto...
SELECT fabric_type, country, sustainability_score, ROW_NUMBER() OVER (PARTITION BY fabric_type ORDER BY sustainability_score DESC) AS rank FROM fabric_sourcing WHERE fabric_type IN ('Cotton', 'Hemp') AND sustainability_score = (SELECT MAX(sustainability_score) FROM fabric_sourcing WHERE fabric_type = f.fabric_type);
Insert a record into 'volunteer_events' table
CREATE TABLE volunteer_events (id INT PRIMARY KEY,name VARCHAR(255),location VARCHAR(255),description TEXT,start_date DATETIME,end_date DATETIME);
INSERT INTO volunteer_events (id, name, location, description, start_date, end_date) VALUES (1, 'AI for Social Good', 'New York, NY', 'Discuss ethical AI applications', '2023-04-01 10:00:00', '2023-04-01 12:00:00');
What is the average number of healthcare workers per hospital and clinic in each region?
CREATE TABLE hospitals (id INT,name TEXT,region TEXT,workers INT); INSERT INTO hospitals (id,name,region,workers) VALUES (1,'Hospital A','Northeast',50),(2,'Hospital B','Northeast',75),(3,'Clinic C','Northeast',10),(4,'Hospital D','South',60),(5,'Clinic E','South',15),(6,'Hospital F','West',65),(7,'Clinic G','West',20)...
SELECT region, AVG(workers) FROM hospitals GROUP BY region;
Create a new table named "construction_labor" with columns: project_name (text), worker_name (text), hours_worked (integer), and hourly_rate (float)
CREATE TABLE construction_labor (project_name TEXT,worker_name TEXT,hours_worked INTEGER,hourly_rate FLOAT);
CREATE TABLE construction_labor (project_name TEXT, worker_name TEXT, hours_worked INTEGER, hourly_rate FLOAT);
What is the total number of properties in sustainable communities that are not in affordable housing schemes?
CREATE TABLE sustainable_communities (community_id INT,property_id INT); INSERT INTO sustainable_communities (community_id,property_id) VALUES (1,101),(1,102),(2,103),(2,104),(3,105); CREATE TABLE affordable_housing (property_id INT,price FLOAT); INSERT INTO affordable_housing (property_id,price) VALUES (101,500000.00)...
SELECT COUNT(*) FROM sustainable_communities EXCEPT SELECT COUNT(*) FROM sustainable_communities JOIN affordable_housing ON sustainable_communities.property_id = affordable_housing.property_id;
Find the sales and profits for ethical material types in the USA.
CREATE TABLE materials (id INT,country VARCHAR(255),type VARCHAR(255),sales FLOAT,profits FLOAT); INSERT INTO materials (id,country,type,sales,profits) VALUES (1,'USA','Organic Cotton',5000,2500),(2,'Canada','Hemp',3000,1800),(3,'USA','Recycled Polyester',4000,2000);
SELECT type, SUM(sales) as total_sales, SUM(profits) as total_profits FROM materials WHERE country = 'USA' GROUP BY type;
Retrieve all employees who joined after January 1st, 2021 from the "finance" schema
CREATE TABLE finance.employees (id INT,name VARCHAR(50),hire_date DATE); INSERT INTO finance.employees (id,name,hire_date) VALUES (1,'Alice Johnson','2021-02-01'); INSERT INTO finance.employees (id,name,hire_date) VALUES (2,'Bob Brown','2021-03-15'); INSERT INTO finance.employees (id,name,hire_date) VALUES (3,'Jessica ...
SELECT * FROM finance.employees WHERE hire_date > '2021-01-01';
Update the 'rural_development' database's 'agricultural_innovation' table to include a new 'innovation' column with values 'Automated Irrigation' and 'Precision Agriculture' for 'United States' records
CREATE TABLE agricultural_innovation (innovation_id INT PRIMARY KEY,innovation_name VARCHAR(100),country VARCHAR(50),region VARCHAR(50),year_introduced INT);
ALTER TABLE agricultural_innovation ADD innovation VARCHAR(50); UPDATE agricultural_innovation SET innovation = 'Automated Irrigation' WHERE country = 'United States'; UPDATE agricultural_innovation SET innovation = 'Precision Agriculture' WHERE country = 'United States';
What is the total production output for each chemical compound produced at production sites located in Australia?
CREATE TABLE chemical_compounds(id INT,compound_name TEXT,production_output INT); CREATE TABLE production_sites(id INT,site_name TEXT,location TEXT); INSERT INTO chemical_compounds (id,compound_name,production_output) VALUES (1,'Compound X',100),(2,'Compound Y',150); INSERT INTO production_sites (id,site_name,location)...
SELECT chemical_compounds.compound_name, SUM(chemical_compounds.production_output) FROM chemical_compounds INNER JOIN production_sites ON chemical_compounds.id = production_sites.id WHERE production_sites.location = 'Australia' GROUP BY chemical_compounds.compound_name;
What is the change in recycling rate between consecutive quarters for 'CityB'?
CREATE TABLE CityB (Quarter INT,RecyclingRate DECIMAL(5,2)); INSERT INTO CityB (Quarter,RecyclingRate) VALUES (1,0.25),(2,0.3),(3,0.35),(4,0.4);
SELECT LAG(RecyclingRate, 1) OVER (ORDER BY Quarter) as prev_rate, RecyclingRate, (RecyclingRate - LAG(RecyclingRate, 1) OVER (ORDER BY Quarter)) as change_rate FROM CityB;
Find the cerium production difference between 2017 and 2018 for each miner.
CREATE TABLE CeriumProduction (Miner VARCHAR(50),Year INT,Production FLOAT); INSERT INTO CeriumProduction(Miner,Year,Production) VALUES ('MinerA',2017,321.5),('MinerA',2018,345.7),('MinerA',2019,362.1),('MinerB',2017,289.1),('MinerB',2018,303.5),('MinerB',2019,319.8);
SELECT Miner, Production - LAG(Production) OVER (PARTITION BY Miner ORDER BY Year) as Difference FROM CeriumProduction WHERE Miner IN ('MinerA', 'MinerB');
What was the maximum glass recycling rate in 2019 for North America, Canada, and Mexico?
CREATE TABLE RecyclingRates (year INT,country VARCHAR(50),material VARCHAR(50),recycling_rate FLOAT); INSERT INTO RecyclingRates (year,country,material,recycling_rate) VALUES (2019,'United States','Glass',0.3),(2019,'Canada','Glass',0.35),(2019,'Mexico','Glass',0.25),(2019,'Brazil','Glass',0.4),(2019,'Argentina','Glass...
SELECT MAX(recycling_rate) FROM RecyclingRates WHERE year = 2019 AND material = 'Glass' AND country IN ('United States', 'Canada', 'Mexico');
How many members does each union have that is involved in labor rights advocacy?
CREATE TABLE unions (id INT,name VARCHAR(50),location VARCHAR(50),type VARCHAR(50)); CREATE TABLE members (id INT,union_id INT,gender VARCHAR(50)); INSERT INTO unions (id,name,location,type) VALUES (1,'United Steelworkers','USA','Labor Rights'); INSERT INTO unions (id,name,location,type) VALUES (2,'UNI Global Union','S...
SELECT unions.name, COUNT(members.id) AS member_count FROM unions JOIN members ON unions.id = members.union_id WHERE unions.type = 'Labor Rights' GROUP BY unions.name;
What's the total amount donated by new donors who made their first donation in the year 2021?
CREATE TABLE Donors (DonorID INT,DonorName VARCHAR(100),DonationAmount DECIMAL(10,2),DonationDate DATE,FirstDonationYear INT);
SELECT SUM(DonationAmount) FROM Donors WHERE FirstDonationYear = 2021;
How many matches did each team play in the 2021-2022 UEFA Champions League?
CREATE TABLE ucl_teams (team_id INT,team_name TEXT,league TEXT,matches_played INT,wins INT); INSERT INTO ucl_teams (team_id,team_name,league,matches_played,wins) VALUES (1,'Manchester City','EPL',13,11),(2,'Liverpool','EPL',13,6);
SELECT team_name, matches_played FROM ucl_teams;
List all the unique regions where humanitarian assistance has been provided, according to the 'Assistance' table, excluding the 'Americas' region.
CREATE TABLE Assistance (id INT,region VARCHAR(255),type VARCHAR(255));
SELECT DISTINCT region FROM Assistance WHERE region != 'Americas';
What is the total budget allocated for disaster response in each region?
CREATE TABLE disaster_budget (region TEXT,disaster_type TEXT,budget INTEGER); INSERT INTO disaster_budget (region,disaster_type,budget) VALUES ('Asia','Flood',50000),('Americas','Earthquake',75000),('Africa','Fire',30000);
SELECT d.region, SUM(d.budget) FROM disaster_budget d GROUP BY d.region;
What are the contractor names for projects in California?
CREATE TABLE project (id INT,name VARCHAR(255),location VARCHAR(255),start_date DATE,end_date DATE); INSERT INTO project (id,name,location,start_date,end_date) VALUES (2,'Eco Renovate','California','2021-05-01','2021-09-30');
SELECT contractor.name FROM contractor JOIN project_contractor ON contractor.id = project_contractor.contractor_id JOIN project ON project_contractor.project_id = project.id WHERE project.location = 'California';
What is the total cost of construction projects that started in the second half of 2022?
CREATE TABLE construction_projects (project_name TEXT,start_date DATE,end_date DATE,total_cost FLOAT); INSERT INTO construction_projects (project_name,start_date,end_date,total_cost) VALUES ('Solar Panel Installation','2022-02-15','2022-03-31',12000.0),('Green Building Demo','2022-07-01','2022-09-15',150000.0);
SELECT SUM(total_cost) FROM construction_projects WHERE start_date >= '2022-07-01';
Which golfers have won the most major championships?
CREATE TABLE players (id INT,name VARCHAR(50),sport VARCHAR(20),majors INT); INSERT INTO players (id,name,sport,majors) VALUES (1,'Tiger Woods','Golf',15); INSERT INTO players (id,name,sport,majors) VALUES (2,'Jack Nicklaus','Golf',18);
SELECT name, majors FROM players WHERE sport = 'Golf' ORDER BY majors DESC;
What are the researchers who have worked on both deep-sea exploration and marine conservation?
CREATE TABLE Researchers (id INT PRIMARY KEY,name VARCHAR(50),specialization VARCHAR(50),affiliation VARCHAR(50)); CREATE TABLE Publications (id INT PRIMARY KEY,title VARCHAR(50),year INT,researchers_id INT,publication_type VARCHAR(50)); CREATE TABLE Projects (id INT PRIMARY KEY,name VARCHAR(50),start_date DATE,end_dat...
SELECT Researchers.name FROM Researchers INNER JOIN Projects ON Researchers.id = Projects.researchers_id WHERE Projects.name IN ('Deep-Sea Exploration', 'Marine Conservation') GROUP BY Researchers.name HAVING COUNT(DISTINCT Projects.name) = 2;
Insert a new record into the "Vessels" table
CREATE TABLE Vessels (Id INT PRIMARY KEY,Name VARCHAR(100),Type VARCHAR(50),Year INT);
INSERT INTO Vessels (Id, Name, Type, Year) VALUES (123, 'Manta Ray', 'Research Vessel', 2015);
What is the total duration of Yoga workouts done by members from India, grouped by gender?
CREATE TABLE Members (Id INT,Name VARCHAR(50),Age INT,Nationality VARCHAR(50),Gender VARCHAR(10)); INSERT INTO Members (Id,Name,Age,Nationality,Gender) VALUES (3,'Ravi Kumar',35,'India','Male'),(4,'Priya Gupta',28,'India','Female'); CREATE TABLE Workouts (Id INT,MemberId INT,WorkoutType VARCHAR(50),Duration INT,Date DA...
SELECT w.WorkoutType, m.Gender, SUM(w.Duration) as TotalDuration FROM Members m JOIN Workouts w ON m.Id = w.MemberId WHERE m.Nationality = 'India' AND w.WorkoutType = 'Yoga' GROUP BY w.WorkoutType, m.Gender;
How many military innovation projects have been completed by each country in the last 3 years?
CREATE TABLE Military_Innovation (id INT,country VARCHAR(50),year INT,project VARCHAR(50));
SELECT country, COUNT(project) as total_projects FROM Military_Innovation WHERE year BETWEEN (YEAR(CURRENT_DATE) - 3) AND YEAR(CURRENT_DATE) GROUP BY country;
Identify the users who have streamed both pop and country songs, excluding any streams from Australia.
CREATE TABLE genres (id INT,name VARCHAR(255),type VARCHAR(255)); CREATE TABLE users (id INT,name VARCHAR(255),location VARCHAR(255)); CREATE TABLE streams (id INT,user_id INT,song_id INT,timestamp TIMESTAMP); INSERT INTO genres (id,name,type) VALUES (1,'Pop','Music'),(2,'Country','Music'); INSERT INTO users (id,name,l...
SELECT DISTINCT streams.user_id FROM streams JOIN users ON streams.user_id = users.id JOIN (SELECT song_id FROM pop_songs) AS pop_ids ON streams.song_id = pop_ids.song_id JOIN (SELECT song_id FROM country_songs) AS country_ids ON streams.song_id = country_ids.song_id WHERE users.location != 'Australia';
What is the total population of animals in the "animal_population" view that are older than 10?
CREATE VIEW animal_population AS SELECT 'Penguin' AS species,COUNT(*) AS num_animals FROM penguins WHERE age > 10 UNION ALL SELECT 'Turtle' AS species,COUNT(*) AS num_animals FROM turtles WHERE age > 10;
SELECT SUM(num_animals) FROM animal_population;
What is the total number of hours spent on incident response for the last month?
CREATE TABLE incident_response (id INT,incident_id INT,responders INT,start_time TIMESTAMP,end_time TIMESTAMP); INSERT INTO incident_response (id,incident_id,responders,start_time,end_time) VALUES (1,1,2,'2022-02-01 10:00:00','2022-02-01 12:00:00'),(2,1,3,'2022-02-01 12:00:00','2022-02-01 14:00:00'),(3,2,1,'2022-02-02 ...
SELECT SUM(TIMESTAMPDIFF(HOUR, start_time, end_time)) FROM incident_response WHERE incident_response.incident_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH);
What is the average number of artists associated with each traditional art, ordered by the average number in ascending order?
CREATE TABLE traditional_arts (art_id INT,art_name TEXT,art_type TEXT,artist TEXT,years_practiced INT); INSERT INTO traditional_arts (art_id,art_name,art_type,artist,years_practiced) VALUES (1,'Thangka Painting','Painting','Sonam',55),(2,'Talavera Pottery','Pottery','Rafael',60);
SELECT art_type, AVG(artist) as avg_artists FROM traditional_arts GROUP BY art_type ORDER BY avg_artists;
What is the average elevation of all tunnels in the 'Rocky Mountains' with a length over 5 miles?
CREATE TABLE Tunnels (id INT,name TEXT,mountainRange TEXT,elevation DECIMAL(5,2),length DECIMAL(10,2));
SELECT mountainRange, AVG(elevation) FROM Tunnels WHERE mountainRange = 'Rocky Mountains' AND length > 5 GROUP BY mountainRange;
Delete space debris records older than 20 years from the "space_debris" table.
CREATE TABLE space_debris (id INT,name VARCHAR(50),launch_date DATE,latitude FLOAT,longitude FLOAT); INSERT INTO space_debris (id,name,launch_date,latitude,longitude) VALUES (1,'DEbris 1','2000-01-01',10.123456,20.123456); INSERT INTO space_debris (id,name,launch_date,latitude,longitude) VALUES (2,'DEbris 2','2005-05-0...
DELETE FROM space_debris WHERE launch_date < DATE_SUB(CURRENT_DATE, INTERVAL 20 YEAR);
What is the total salary cost for workers in the 'workforce development' department?
CREATE TABLE salaries_ext (id INT,worker_id INT,department VARCHAR(50),salary FLOAT,is_development BOOLEAN); INSERT INTO salaries_ext (id,worker_id,department,salary,is_development) VALUES (1,1,'manufacturing',50000.00,FALSE),(2,2,'workforce development',60000.00,TRUE);
SELECT SUM(salary) FROM salaries_ext WHERE department = 'workforce development' AND is_development = TRUE;
Insert a new record of a virtual tourism center in Tokyo with 15 rooms.
CREATE TABLE tourism_centers (id INT,name TEXT,city TEXT,type TEXT,num_rooms INT);
INSERT INTO tourism_centers (name, city, type, num_rooms) VALUES ('Virtual Tourism Center', 'Tokyo', 'virtual', 15);