instruction
stringlengths
0
1.06k
input
stringlengths
11
5.3k
response
stringlengths
2
4.44k
List the virtual tours in Spain with more than 1000 reviews.
CREATE TABLE virtual_tours(tour_id INT,name TEXT,country TEXT,num_reviews INT); INSERT INTO virtual_tours (tour_id,name,country,num_reviews) VALUES (1,'Museum Tour','Spain',1200),(2,'Historic City Tour','Italy',800);
SELECT name FROM virtual_tours WHERE country = 'Spain' AND num_reviews > 1000;
List all chemicals with environmental impact data
CREATE TABLE environmental_impact (chemical_name VARCHAR(255),impact_description TEXT);
SELECT chemical_name FROM environmental_impact;
Count the number of new styles launched in the Fall season.
CREATE TABLE Styles (id INT PRIMARY KEY,style VARCHAR(20),season VARCHAR(20)); INSERT INTO Styles (id,style,season) VALUES (1,'New_Style_1','Fall'),(2,'New_Style_2','Fall'),(3,'Existing_Style_1','Fall');
SELECT COUNT(*) FROM Styles WHERE season = 'Fall';
What is the average broadband speed in each country?
CREATE TABLE broadband_speeds (speed_id INT,country VARCHAR(255),speed DECIMAL(10,2)); INSERT INTO broadband_speeds (speed_id,country,speed) VALUES (1,'USA',100.00),(2,'Canada',150.00),(3,'Mexico',75.00);
SELECT country, AVG(speed) AS avg_speed FROM broadband_speeds GROUP BY country;
How many reverse logistics shipments were made to each country in the month of January 2021?
CREATE TABLE reverse_logistics (id INT,country VARCHAR(255),shipment_date DATE);INSERT INTO reverse_logistics (id,country,shipment_date) VALUES (1,'USA','2021-01-05'),(2,'Canada','2021-01-10'),(3,'Mexico','2021-02-01');
SELECT country, COUNT(id) as shipment_count FROM reverse_logistics WHERE shipment_date BETWEEN '2021-01-01' AND '2021-01-31' GROUP BY country;
Show the total spending on military innovation by each country for the year 2020
CREATE TABLE military_innovation (id INT,weapon_system VARCHAR(255),country VARCHAR(255),year INT);
SELECT country, SUM(year) FROM military_innovation WHERE year = 2020 GROUP BY country;
How many employees work in the 'technician' position in the 'sustainable_practices' table?
CREATE TABLE sustainable_practices (employee_id INT,first_name VARCHAR(50),last_name VARCHAR(50),gender VARCHAR(10),position VARCHAR(50),hours_worked INT); INSERT INTO sustainable_practices (employee_id,first_name,last_name,gender,position,hours_worked) VALUES (3,'Alice','Johnson','Female','Analyst',30); INSERT INTO su...
SELECT COUNT(*) FROM sustainable_practices WHERE position = 'Technician';
What is the average donation amount per volunteer by program category?
CREATE TABLE volunteers (volunteer_id INT,org_id INT);CREATE TABLE programs (program_id INT,program_category_id INT);CREATE TABLE donations (donation_id INT,donor_id INT,program_id INT,donation_amount DECIMAL(10,2)); INSERT INTO volunteers (volunteer_id,org_id) VALUES (1,1),(2,1),(3,2),(4,2),(5,3),(6,3),(7,3); INSERT I...
SELECT pc.program_category_name, AVG(d.donation_amount) as avg_donation_amount_per_volunteer FROM programs p JOIN donations d ON p.program_id = d.program_id JOIN volunteers v ON p.org_id = v.org_id JOIN program_categories pc ON p.program_category_id = pc.program_category_id GROUP BY pc.program_category_name;
What is the average time to resolve security incidents for each asset type?
CREATE TABLE incident_resolution (id INT,asset_type VARCHAR(50),resolution_time INT); INSERT INTO incident_resolution (id,asset_type,resolution_time) VALUES (1,'network',120),(2,'server',150),(3,'workstation',180);
SELECT asset_type, AVG(resolution_time) as avg_resolution_time FROM incident_resolution GROUP BY asset_type;
What is the average age of visitors who attended the Cubism exhibition on Saturday?
CREATE TABLE Exhibitions (exhibition_id INT,name VARCHAR(50),start_date DATE,end_date DATE,day VARCHAR(10)); INSERT INTO Exhibitions (exhibition_id,name,start_date,end_date,day) VALUES (1,'Impressionist','2020-05-01','2021-01-01','Saturday'),(2,'Cubism','2019-08-15','2020-03-30','Saturday'),(3,'Surrealism','2018-12-15'...
SELECT AVG(age) FROM Visitors INNER JOIN Exhibitions ON Visitors.exhibition_id = Exhibitions.exhibition_id WHERE Exhibitions.name = 'Cubism' AND day = 'Saturday';
How many electric buses are operating in Beijing?
CREATE TABLE electric_buses (bus_id INT,registration_date TIMESTAMP,bus_type VARCHAR(50),city VARCHAR(50));
SELECT COUNT(*) as num_buses FROM electric_buses WHERE city = 'Beijing';
What is the most common offense type in Texas?
CREATE TABLE offenses (offense_id INT,offense_type VARCHAR(255),state VARCHAR(2)); INSERT INTO offenses (offense_id,offense_type,state) VALUES (1,'Theft','TX'); INSERT INTO offenses (offense_id,offense_type,state) VALUES (2,'DWI','CA'); INSERT INTO offenses (offense_id,offense_type,state) VALUES (3,'Theft','TX');
SELECT offense_type, COUNT(*) AS count FROM offenses WHERE state = 'TX' GROUP BY offense_type ORDER BY count DESC LIMIT 1;
Update the rock type to 'schist' for the mine named 'Emerald Peaks' in the latest year.
CREATE TABLE Rock_Classification (Mine_Name VARCHAR(50),Rock_Type VARCHAR(50),Year INT); INSERT INTO Rock_Classification (Mine_Name,Rock_Type,Year) VALUES ('Emerald Peaks','Granite',2019),('Ruby Ridge','Basalt',2019),('Sapphire Summit','Gneiss',2019);
UPDATE Rock_Classification SET Rock_Type = 'Schist' WHERE Mine_Name = 'Emerald Peaks' AND Year = (SELECT MAX(Year) FROM Rock_Classification);
Find the number of distinct esports events that each console player has participated in.
CREATE TABLE Players (PlayerID INT,Age INT,Platform VARCHAR(10)); INSERT INTO Players (PlayerID,Age,Platform) VALUES (1,25,'PC'),(2,30,'Console'),(3,22,'Console'); CREATE TABLE EsportsEvents (EventID INT,PlayerID INT); INSERT INTO EsportsEvents (EventID,PlayerID) VALUES (1,1),(2,2),(3,3),(4,2),(5,3);
SELECT p1.PlayerID, COUNT(DISTINCT e.EventID) as NumEvents FROM Players p1 JOIN EsportsEvents e ON p1.PlayerID = e.PlayerID WHERE p1.Platform = 'Console' GROUP BY p1.PlayerID;
How many COVID-19 cases have been reported in each province of Canada?
CREATE TABLE canada_provinces (id INT,name VARCHAR(255)); CREATE TABLE covid_cases (id INT,province_id INT,cases INT); INSERT INTO canada_provinces (id,name) VALUES (1,'Ontario'),(2,'Quebec'),(3,'British Columbia'),(4,'Alberta'),(5,'Manitoba');
SELECT p.name, SUM(c.cases) FROM covid_cases c JOIN canada_provinces p ON c.province_id = p.id GROUP BY p.name;
Which country had the largest decrease in Yttrium production from 2020 to 2021?
CREATE TABLE YttriumProduction (country VARCHAR(50),year INT,production INT); INSERT INTO YttriumProduction (country,year,production) VALUES ('China',2020,1200),('China',2021,1100),('USA',2020,1000),('USA',2021,1100),('Australia',2020,800),('Australia',2021,700);
SELECT country, MIN(production_change) FROM (SELECT country, (production - LAG(production) OVER (PARTITION BY country ORDER BY year)) AS production_change FROM YttriumProduction) AS subquery WHERE production_change IS NOT NULL GROUP BY country;
Find the number of employees who are members of unions in the 'technology' industry
CREATE TABLE employees (id INT,industry VARCHAR(20),union_member BOOLEAN); INSERT INTO employees (id,industry,union_member) VALUES (1,'technology',TRUE),(2,'finance',FALSE),(3,'technology',FALSE);
SELECT COUNT(*) FROM employees WHERE industry = 'technology' AND union_member = TRUE;
What's the average donation for each cause?
CREATE TABLE cause (id INT PRIMARY KEY,name VARCHAR(255));CREATE TABLE donation (id INT PRIMARY KEY,cause_id INT,amount DECIMAL(10,2));
SELECT c.name, AVG(d.amount) AS avg_donations FROM cause c JOIN donation d ON c.id = d.cause_id GROUP BY c.id;
What is the maximum local economic impact of eco-friendly hotels in Brazil?
CREATE TABLE eco_hotels (hotel_id INT,hotel_name TEXT,country TEXT,local_impact INT); INSERT INTO eco_hotels (hotel_id,hotel_name,country,local_impact) VALUES (1,'Eco-Friendly Hotel A','Brazil',500000),(2,'Eco-Friendly Hotel B','Brazil',600000);
SELECT MAX(local_impact) FROM eco_hotels WHERE country = 'Brazil';
What are the names of all gas wells in the 'Gulf of Mexico'?
CREATE TABLE if not exists gas_wells (id INT PRIMARY KEY,well_name TEXT,location TEXT); INSERT INTO gas_wells (id,well_name,location) VALUES (1,'Well D','Gulf of Mexico'),(2,'Well E','South Atlantic'),(3,'Well F','Gulf of Mexico');
SELECT well_name FROM gas_wells WHERE location = 'Gulf of Mexico';
Find the number of unique artists per platform, for R&B and hip-hop genres.
CREATE TABLE artists (artist_id INT,genre VARCHAR(10),platform VARCHAR(10)); CREATE TABLE sales (sale_id INT,genre VARCHAR(10),platform VARCHAR(10),sales FLOAT);
SELECT platform, COUNT(DISTINCT artist_id) FROM artists WHERE genre IN ('R&B', 'hip-hop') GROUP BY platform;
When was the first approval date for 'DrugC'?
CREATE TABLE drug_approval (drug_name TEXT,approval_date DATE);
SELECT MIN(approval_date) FROM drug_approval WHERE drug_name = 'DrugC';
What is the average age of all animals in the 'endangered_animal_profiles' table?
CREATE TABLE endangered_animal_profiles (id INT,animal_name VARCHAR(50),age INT,species_id INT); INSERT INTO endangered_animal_profiles (id,animal_name,age,species_id) VALUES (1,'Amur Leopard',8,1001),(2,'Black Rhino',10,1002),(3,'Sumatran Elephant',12,1003);
SELECT AVG(age) FROM endangered_animal_profiles;
What is the average cost of satellites launched by SpaceX?
CREATE TABLE Satellites (id INT,name VARCHAR(100),company VARCHAR(100),cost FLOAT); INSERT INTO Satellites (id,name,company,cost) VALUES (1,'Starlink 1','SpaceX',1000000); INSERT INTO Satellites (id,name,company,cost) VALUES (2,'Starlink 2','SpaceX',1000000);
SELECT AVG(cost) FROM Satellites WHERE company = 'SpaceX';
Add a new record for a language preservation event.
CREATE TABLE language_preservation_events (id INT PRIMARY KEY,name VARCHAR(255),language_id INT,participants INT,date DATE,description TEXT);
INSERT INTO language_preservation_events (id, name, language_id, participants, date, description) VALUES (1, 'Gàidhlig Language Revitalization Workshop', 2, 30, '2024-04-01', 'A workshop aimed at revitalizing the Gàidhlig language with 30 participants on April 1st, 2024.');
What are the names of the ports where 'Vessel F' has transported cargo?
CREATE TABLE port (port_id INT,port_name VARCHAR(50)); CREATE TABLE vessel (vessel_id INT,vessel_name VARCHAR(50)); CREATE TABLE transport (transport_id INT,cargo_id INT,vessel_id INT,port_id INT); INSERT INTO port (port_id,port_name) VALUES (1,'Port of New York'),(2,'Port of Miami'),(3,'Port of Boston'); INSERT INTO v...
SELECT port_name FROM port WHERE port_id IN (SELECT port_id FROM transport WHERE vessel_id = (SELECT vessel_id FROM vessel WHERE vessel_name = 'Vessel F'))
Find the total number of artworks by each artist in the 'Artworks' table.
CREATE TABLE Artworks (id INT,artist VARCHAR(50),title VARCHAR(100),year INT,medium VARCHAR(50),width FLOAT,height FLOAT); INSERT INTO Artworks (id,artist,title,year,medium,width,height) VALUES (1,'Vincent van Gogh','Starry Night',1889,'Oil on canvas',73.7,59.8);
SELECT artist, COUNT(*) as total_artworks FROM Artworks GROUP BY artist;
What is the average funding amount for companies founded by Latinx individuals in the fintech sector?
CREATE TABLE company (id INT,name TEXT,industry TEXT,founding_date DATE,founder_ethnicity TEXT); INSERT INTO company (id,name,industry,founding_date,founder_ethnicity) VALUES (1,'FintechLatam','Fintech','2018-04-01','Latinx');
SELECT AVG(investment_rounds.funding_amount) FROM company JOIN investment_rounds ON company.id = investment_rounds.company_id WHERE company.founder_ethnicity = 'Latinx' AND company.industry = 'Fintech';
Delete records from the graduate_students table where the student is not part of any department
CREATE TABLE graduate_students (id INT,name TEXT,department TEXT); INSERT INTO graduate_students (id,name,department) VALUES (1,'Alice','CS'),(2,'Bob',NULL),(3,'Charlie','Math');
DELETE FROM graduate_students WHERE department IS NULL;
What is the total number of artworks in the artworks table, excluding those from the United States?
CREATE TABLE artworks (artwork_id INT,artwork_name TEXT,artist_name TEXT,country TEXT);
SELECT COUNT(artwork_id) FROM artworks WHERE country != 'United States';
What is the average usage time for mobile plans in each country?
CREATE TABLE usage (id INT,subscriber_id INT,plan_id INT,usage_time DECIMAL(10,2)); CREATE TABLE mobile_plans (id INT,name VARCHAR(255),type VARCHAR(255),price DECIMAL(10,2)); CREATE TABLE subscribers (id INT,name VARCHAR(255),plan_id INT,country VARCHAR(255)); CREATE TABLE countries (id INT,name VARCHAR(255));
SELECT countries.name AS country, AVG(usage_time) FROM usage JOIN mobile_plans ON usage.plan_id = mobile_plans.id JOIN subscribers ON usage.subscriber_id = subscribers.id JOIN countries ON subscribers.country = countries.id GROUP BY countries.name;
List all unique exit strategies for startups in the cybersecurity sector founded by AAPI entrepreneurs.
CREATE TABLE exit_strategy (id INT,company_id INT,strategy TEXT); INSERT INTO exit_strategy (id,company_id,strategy) VALUES (1,1,'Merger'); CREATE TABLE company (id INT,name TEXT,industry TEXT,founder_race TEXT); INSERT INTO company (id,name,industry,founder_race) VALUES (1,'SecureSphere','Cybersecurity','AAPI');
SELECT DISTINCT strategy FROM exit_strategy INNER JOIN company ON exit_strategy.company_id = company.id WHERE industry = 'Cybersecurity' AND founder_race = 'AAPI';
What is the average safety rating for the 'North' plant in H1 of 2022?
CREATE TABLE safety_ratings (plant varchar(10),half int,year int,rating int); INSERT INTO safety_ratings (plant,half,year,rating) VALUES ('North Plant',1,2022,85),('North Plant',2,2022,88),('South Plant',1,2022,80),('South Plant',2,2022,83);
SELECT AVG(rating) FROM safety_ratings WHERE plant = 'North Plant' AND half = 1 AND year = 2022;
How many wheelchair-accessible bus stops are there in San Francisco, grouped by neighborhood?
CREATE TABLE sf_bus_stops (stop_id INT,stop_name VARCHAR(100),wheelchair_accessible BOOLEAN,neighborhood VARCHAR(50));
SELECT neighborhood, COUNT(*) FROM sf_bus_stops WHERE wheelchair_accessible = TRUE GROUP BY neighborhood;
Delete subscribers who have made payments after the due date for the 'Broadband' service in Q2 of 2022.
CREATE TABLE Subscribers (subscriber_id INT,service VARCHAR(20),region VARCHAR(20),revenue FLOAT,payment_date DATE,due_date DATE); INSERT INTO Subscribers (subscriber_id,service,region,revenue,payment_date,due_date) VALUES (1,'Broadband','Metro',50.00,'2022-04-15','2022-04-10'),(2,'Mobile','Urban',35.00,NULL,NULL),(3,'...
DELETE FROM Subscribers WHERE service = 'Broadband' AND QUARTER(payment_date) = 2 AND YEAR(payment_date) = 2022 AND payment_date > due_date;
What is the total number of hours of strength and conditioning sessions for all athletes in the NFL in the last month?
CREATE TABLE IF NOT EXISTS athletes (id INT,name VARCHAR(50),team VARCHAR(50),league VARCHAR(50)); CREATE TABLE IF NOT EXISTS sessions (id INT,athlete_id INT,type VARCHAR(50),duration INT,date DATE);
SELECT SUM(duration) FROM sessions JOIN athletes ON sessions.athlete_id = athletes.id WHERE athletes.league = 'NFL' AND sessions.type IN ('Strength', 'Conditioning') AND sessions.date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH);
What are the average temperatures and humidity levels for the crops in field A and B in July?
CREATE TABLE Fields (FieldID varchar(5),FieldName varchar(10),AvgTemperature float,AvgHumidity float); INSERT INTO Fields (FieldID,FieldName,AvgTemperature,AvgHumidity) VALUES ('A','Field A',25.6,60.1),('B','Field B',26.3,61.5);
SELECT AvgTemperature, AvgHumidity FROM Fields WHERE FieldName IN ('Field A', 'Field B') AND EXTRACT(MONTH FROM DATE '2022-07-01') = 7;
What courses have been added in the last 6 months?
CREATE TABLE courses (course_id INT,course_name TEXT,added_date DATE); INSERT INTO courses (course_id,course_name,added_date) VALUES (1,'Intro to Psychology','2022-01-05'),(2,'English Composition','2022-03-10');
SELECT * FROM courses WHERE added_date >= DATEADD(month, -6, GETDATE());
What is the average salary for employees hired in 2021?
CREATE TABLE Employees (EmployeeID int,HireDate date,Salary decimal(10,2)); INSERT INTO Employees (EmployeeID,HireDate,Salary) VALUES (1,'2021-01-01',80000.00),(2,'2021-02-15',85000.00),(3,'2020-12-31',75000.00);
SELECT AVG(Salary) FROM Employees WHERE YEAR(HireDate) = 2021;
Show research engineers and their details.
CREATE TABLE Employees (Id INT,Name VARCHAR(50),Role VARCHAR(50),Department VARCHAR(50)); INSERT INTO Employees (Id,Name,Role,Department) VALUES (1,'Jane Smith','Safety Officer','Production'),(2,'Robert Johnson','Engineer','Research'),(3,'Alice Davis','Research Engineer','Research');
SELECT * FROM Employees WHERE Role = 'Engineer' AND Department = 'Research';
What is the total investment amount for each sector?
CREATE TABLE nonprofits (id INT PRIMARY KEY,name VARCHAR(255),location VARCHAR(255),sector VARCHAR(255)); CREATE TABLE investments (id INT PRIMARY KEY,investor_id INT,nonprofit_id INT,amount DECIMAL(10,2),investment_date DATE); INSERT INTO nonprofits (id,name,location,sector) VALUES (1,'Habitat for Humanity','USA','Hou...
SELECT n.sector, SUM(i.amount) FROM nonprofits n JOIN investments i ON n.id = nonprofit_id GROUP BY n.sector;
What is the total revenue for each product category?
CREATE TABLE revenue (product_id INT,category VARCHAR(255),revenue DECIMAL(10,2)); INSERT INTO revenue (product_id,category,revenue) VALUES (1,'CategoryA',1200.00),(2,'CategoryB',2500.00),(3,'CategoryA',750.00);
SELECT category, SUM(revenue) AS total_revenue FROM revenue GROUP BY category;
Find the number of active satellites in each orbit type
CREATE TABLE satellite_status (satellite_name VARCHAR(255),orbit_type VARCHAR(255),status VARCHAR(255)); INSERT INTO satellite_status (satellite_name,orbit_type,status) VALUES ('Sat-1','LEO','active'); INSERT INTO satellite_status (satellite_name,orbit_type,status) VALUES ('Sat-2','GEO','active');
SELECT orbit_type, COUNT(*) FROM satellite_status WHERE status = 'active' GROUP BY orbit_type;
Which product category had the highest total revenue in Oregon in 2021?
CREATE TABLE categories (product VARCHAR(20),revenue DECIMAL(10,2),state VARCHAR(20),year INT); INSERT INTO categories (product,revenue,state,year) VALUES ('Flower',80000,'Oregon',2021),('Concentrate',70000,'Oregon',2021),('Edibles',90000,'Oregon',2021);
SELECT product, MAX(revenue) as max_revenue FROM categories WHERE state = 'Oregon' AND year = 2021 GROUP BY product;
Delete records with 'algorithm' = 'Decision Tree' in the 'training_data3' table
CREATE TABLE training_data3 (id INT,algorithm VARCHAR(20),bias INT,fairness INT); INSERT INTO training_data3 (id,algorithm,bias,fairness) VALUES (1,'Decision Tree',3,7),(2,'Random Forest',5,6),(3,'Decision Tree',4,8);
DELETE FROM training_data3 WHERE algorithm = 'Decision Tree';
Identify companies with more than one patent and located in the Asia Pacific region.
CREATE TABLE patents (id INT,company_id INT,title VARCHAR(100),issued_date DATE); INSERT INTO patents (id,company_id,title,issued_date) VALUES (1,1,'Quantum computing','2015-01-01'); INSERT INTO patents (id,company_id,title,issued_date) VALUES (2,2,'AI-based medical diagnostics','2008-01-01'); CREATE TABLE company_info...
SELECT p.company_id FROM patents p JOIN company_info ci ON p.company_id = ci.company_id WHERE ci.region = 'Asia Pacific' GROUP BY p.company_id HAVING COUNT(*) > 1;
What is the number of FOIA requests submitted per month in the United States?
CREATE TABLE FoiaRequests (RequestId INT,RequestDate DATE,RequestCity VARCHAR(255)); INSERT INTO FoiaRequests (RequestId,RequestDate,RequestCity) VALUES (1,'2021-01-01','Washington DC'),(2,'2021-02-01','New York'),(3,'2021-03-01','Los Angeles');
SELECT EXTRACT(MONTH FROM RequestDate) as Month, COUNT(*) as NumRequests FROM FoiaRequests GROUP BY EXTRACT(MONTH FROM RequestDate);
How many water conservation initiatives were implemented in India in the year 2018?
CREATE TABLE water_conservation_initiatives (id INT,country VARCHAR(50),year INT,initiative_type VARCHAR(50));
SELECT COUNT(*) FROM water_conservation_initiatives WHERE country = 'India' AND year = 2018;
Insert a new record of 'Armored Vehicle' sale to 'North America' in the year '2023' with the quantity of 27 and value of 30000000
CREATE TABLE military_sales (id INT PRIMARY KEY,region VARCHAR(20),year INT,equipment_name VARCHAR(30),quantity INT,value FLOAT);
INSERT INTO military_sales (id, region, year, equipment_name, quantity, value) VALUES (5, 'North America', 2023, 'Armored Vehicle', 27, 30000000);
How many mobile customers have a data usage greater than 3 GB in the city of Tokyo?
CREATE TABLE mobile_customers (customer_id INT,data_usage FLOAT,city VARCHAR(20)); INSERT INTO mobile_customers (customer_id,data_usage,city) VALUES (1,3.5,'Tokyo'),(2,4.2,'NYC'),(3,3.1,'Tokyo');
SELECT COUNT(*) FROM mobile_customers WHERE data_usage > 3 AND city = 'Tokyo';
What is the total area of organic farming in 'Oceania' by smallholder farms?
CREATE TABLE organic_farms (id INT,country VARCHAR(50),region VARCHAR(50),farm_type VARCHAR(50),area_ha FLOAT); INSERT INTO organic_farms (id,country,region,farm_type,area_ha) VALUES (1,'Australia','Oceania','Smallholder',345.6); INSERT INTO organic_farms (id,country,region,farm_type,area_ha) VALUES (2,'Australia','Oce...
SELECT SUM(area_ha) FROM organic_farms WHERE region = 'Oceania' AND farm_type = 'Smallholder';
What is the average funding received by startups founded by indigenous people in the media sector?
CREATE TABLE startups(id INT,name TEXT,industry TEXT,founder_ethnicity TEXT,funding FLOAT); INSERT INTO startups (id,name,industry,founder_ethnicity,funding) VALUES (1,'MediaNative','Media','Indigenous',3000000);
SELECT AVG(funding) FROM startups WHERE industry = 'Media' AND founder_ethnicity = 'Indigenous';
What is the total number of yellow cards given in football matches?
CREATE TABLE football_matches (id INT,home_team VARCHAR(50),away_team VARCHAR(50),yellow_cards_home INT,yellow_cards_away INT);
SELECT SUM(yellow_cards_home + yellow_cards_away) FROM football_matches;
What is the number of military innovation events by the USA, Russia, and China from 2016 to 2018?
CREATE TABLE military_innovation (country VARCHAR(50),year INT,event VARCHAR(50)); INSERT INTO military_innovation (country,year,event) VALUES ('USA',2016,'DARPA Robotics Challenge'); INSERT INTO military_innovation (country,year,event) VALUES ('USA',2017,'Hypersonic Weapon Test'); INSERT INTO military_innovation (coun...
SELECT country, COUNT(event) as total_events FROM military_innovation WHERE (country = 'USA' OR country = 'Russia' OR country = 'China') AND (year BETWEEN 2016 AND 2018) GROUP BY country;
Which countries have the most volunteers?
CREATE TABLE Volunteers (VolunteerID INT,VolunteerName TEXT,Country TEXT); INSERT INTO Volunteers (VolunteerID,VolunteerName,Country) VALUES (1,'Ali','Pakistan'),(2,'Sophia','China'),(3,'James','USA');
SELECT Country, COUNT(*) AS VolunteerCount FROM Volunteers GROUP BY Country ORDER BY VolunteerCount DESC;
What is the total number of streams for each artist and song in the Streaming table?
CREATE TABLE Streaming (id INT,user_id INT,artist_name VARCHAR(255),song_name VARCHAR(255),streams INT); INSERT INTO Streaming (id,user_id,artist_name,song_name,streams) VALUES (1,123,'Ariana Grande','Thank U,Next',500),(2,456,'Billie Eilish','Bad Guy',700),(3,789,'Taylor Swift','Love Story',600);
SELECT artist_name, song_name, SUM(streams) as total_streams FROM Streaming GROUP BY artist_name, song_name;
What is the average number of three-point shots made per game by players in the BasketballPlayers and BasketballPlayerStats tables, for players with more than 500 total points scored?
CREATE TABLE BasketballPlayers (PlayerID INT,Name VARCHAR(50)); CREATE TABLE BasketballPlayerStats (PlayerID INT,GameID INT,Points INT,ThreePointShots INT);
SELECT AVG(ThreePointShots) FROM BasketballPlayerStats INNER JOIN BasketballPlayers ON BasketballPlayerStats.PlayerID = BasketballPlayers.PlayerID GROUP BY PlayerID HAVING SUM(Points) > 500;
What is the number of cases per month for each mediator?
CREATE TABLE mediators (mediator_id INT,name TEXT); INSERT INTO mediators (mediator_id,name) VALUES (1,'John'),(2,'Jane'),(3,'Mike'); CREATE TABLE cases (case_id INT,mediator_id INT,date TEXT); INSERT INTO cases (case_id,mediator_id,date) VALUES (1,1,'2022-01-01'),(2,1,'2022-02-01'),(3,2,'2022-03-01'),(4,3,'2022-04-01'...
SELECT mediators.name, EXTRACT(MONTH FROM cases.date) as month, COUNT(cases.case_id) as cases_per_month FROM mediators INNER JOIN cases ON mediators.mediator_id = cases.mediator_id GROUP BY mediators.name, month;
Who were the top 3 volunteers in terms of total volunteer hours in 2022?
CREATE TABLE Volunteers (VolunteerID INT,VolunteerName TEXT,VolunteerHours DECIMAL(5,2),VolunteerDate DATE); INSERT INTO Volunteers (VolunteerID,VolunteerName,VolunteerHours,VolunteerDate) VALUES (1,'Alice',5.50,'2022-01-05'); INSERT INTO Volunteers (VolunteerID,VolunteerName,VolunteerHours,VolunteerDate) VALUES (2,'Bo...
SELECT VolunteerName, SUM(VolunteerHours) as TotalVolunteerHours FROM Volunteers GROUP BY VolunteerName ORDER BY TotalVolunteerHours DESC LIMIT 3;
What is the earliest incident date and time in the 'incidents' table
CREATE TABLE incidents (incident_id INT,incident_type VARCHAR(50),date_time DATETIME);
SELECT MIN(date_time) FROM incidents;
Which organizations received donations from donors A and B in 2021?
CREATE TABLE Donors (DonorID INT,DonorName TEXT,DonationAmount INT,DonationYear INT); INSERT INTO Donors (DonorID,DonorName,DonationAmount,DonationYear) VALUES (1,'Donor A',4000,2021),(2,'Donor B',6000,2021),(1,'Donor A',3000,2021),(2,'Donor B',5000,2021); CREATE TABLE Organizations (OrganizationID INT,OrganizationName...
SELECT OrganizationName FROM Organizations INNER JOIN Donations ON Organizations.OrganizationID = Donations.OrganizationID WHERE DonorID IN (1, 2) AND DonationYear = 2021;
Insert a new record into the 'solar_panels' table for a 300 W panel manufactured by 'SunCraft' in 2020
CREATE TABLE solar_panels (id INT,manufacturer VARCHAR(255),installed_year INT,capacity FLOAT);
INSERT INTO solar_panels (id, manufacturer, installed_year, capacity) VALUES (1, 'SunCraft', 2020, 300);
What is the minimum water temperature in the SustainableFish table for March 2022?
CREATE TABLE SustainableFish (date DATE,temperature FLOAT); INSERT INTO SustainableFish (date,temperature) VALUES ('2022-03-01',21.0),('2022-03-02',22.0),('2022-03-03',23.0);
SELECT MIN(temperature) FROM SustainableFish WHERE MONTH(date) = 3 AND YEAR(date) = 2022;
What is the total revenue for each collection in the sales table?
CREATE TABLE sales (collection VARCHAR(20),revenue INT); INSERT INTO sales (collection,revenue) VALUES ('Spring 2021',500000),('Fall 2021',600000),('Winter 2021',700000),('Spring 2022',800000);
SELECT collection, SUM(revenue) FROM sales GROUP BY collection;
What is the maximum funding received by a biotech startup in each country?
CREATE TABLE startups (id INT,name TEXT,country TEXT,funding FLOAT); INSERT INTO startups (id,name,country,funding) VALUES (1,'Genetech','USA',50000000); INSERT INTO startups (id,name,country,funding) VALUES (2,'BioSteward','Canada',75000000);
SELECT country, MAX(funding) FROM startups GROUP BY country;
Show the top 3 autonomous driving research papers with the highest number of citations in the 'research_papers' table.
CREATE TABLE research_papers (paper_id INT,title VARCHAR(50),citations INT); INSERT INTO research_papers (paper_id,title,citations) VALUES (1,'Autonomous Driving Algorithms',120),(2,'Deep Learning for Self-Driving Cars',150),(3,'LiDAR Sensor Technology in AVs',85);
SELECT title, citations FROM (SELECT title, citations, RANK() OVER (ORDER BY citations DESC) rank FROM research_papers) sq WHERE rank <= 3;
How many students have enrolled in online courses in the last 6 months?
CREATE TABLE students (id INT,name TEXT,gender TEXT,enrollment_date DATE); INSERT INTO students (id,name,gender,enrollment_date) VALUES (1,'Alice','Female','2021-06-01'); INSERT INTO students (id,name,gender,enrollment_date) VALUES (2,'Bob','Male','2021-01-15'); INSERT INTO students (id,name,gender,enrollment_date) VAL...
SELECT COUNT(*) FROM students WHERE enrollment_date >= DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH) AND course_type = 'Online';
How many members does 'auto_workers_union' have?
CREATE TABLE auto_workers_union.auto_workers (id INT,name TEXT,union_member BOOLEAN);
SELECT COUNT(*) FROM auto_workers_union.auto_workers WHERE union_member = TRUE;
How many athletes have participated in a specific event?
CREATE TABLE events (event_id INT,event_name VARCHAR(50)); CREATE TABLE athlete_events (athlete_id INT,event_id INT);
SELECT e.event_name, COUNT(*) as athlete_count FROM events e JOIN athlete_events ae ON e.event_id = ae.event_id GROUP BY e.event_name;
What percentage of menu items in each restaurant are sustainable, excluding restaurants with less than 50 menu items?
CREATE TABLE menu_items (restaurant_id INT,is_sustainable BOOLEAN,number_of_items INT); INSERT INTO menu_items (restaurant_id,is_sustainable,number_of_items) VALUES (1,TRUE,70),(1,FALSE,30),(2,TRUE,40),(2,FALSE,60),(3,TRUE,80),(3,FALSE,20),(4,TRUE,50),(4,FALSE,50),(5,TRUE,30),(5,FALSE,70);
SELECT restaurant_id, (COUNT(*) FILTER (WHERE is_sustainable = TRUE) * 100.0 / COUNT(*)) AS percentage FROM menu_items WHERE number_of_items >= 50 GROUP BY restaurant_id;
Insert new records into the satellite_images table for images taken in the last week with cloud_coverage less than 30%
CREATE TABLE satellite_images (image_id INT PRIMARY KEY,image_url VARCHAR(255),cloud_coverage FLOAT,acquisition_date DATE);
INSERT INTO satellite_images (image_url, cloud_coverage, acquisition_date) SELECT 'image_url_1', 0.25, DATE(CURRENT_DATE - INTERVAL '3 days') UNION ALL SELECT 'image_url_2', 0.15, DATE(CURRENT_DATE - INTERVAL '1 day') UNION ALL SELECT 'image_url_3', 0.20, DATE(CURRENT_DATE);
List all financial products with a Shariah-compliant status.
CREATE TABLE financial_products (product_id INT,product_name TEXT,is_shariah_compliant BOOLEAN);
SELECT * FROM financial_products WHERE is_shariah_compliant = TRUE;
Which disasters in 2020 had the highest impact on the environment?
CREATE TABLE environmental_impact (id INT,disaster_name VARCHAR(50),year INT,environmental_impact_score INT); INSERT INTO environmental_impact (id,disaster_name,year,environmental_impact_score) VALUES (1,'Australian Wildfires',2020,90),(2,'Amazon Rainforest Fires',2020,80),(3,'California Wildfires',2020,75),(4,'Brazil ...
SELECT disaster_name FROM environmental_impact WHERE year = 2020 ORDER BY environmental_impact_score DESC LIMIT 3;
Find the names of volunteers who have donated more than $500 in total but never participated in the 'Animal Welfare' program category.
CREATE TABLE VolunteerDonations (VolunteerID int,DonationAmount decimal(10,2)); INSERT INTO VolunteerDonations (VolunteerID,DonationAmount) VALUES (1,600.00),(2,250.00),(3,800.00),(4,300.00);
SELECT v.VolunteerName FROM Volunteers v JOIN VolunteerPrograms vp ON v.VolunteerID = vp.VolunteerID JOIN Programs p ON vp.ProgramID = p.ProgramID JOIN VolunteerDonations vd ON v.VolunteerID = vd.VolunteerID WHERE vd.DonationAmount > 500 AND p.Category NOT IN ('Animal Welfare') GROUP BY v.VolunteerID HAVING SUM(vd.Dona...
Which of our suppliers in Asia have not supplied any products to us in the last year?
CREATE TABLE Suppliers (SupplierID INT,CompanyName VARCHAR(50),Country VARCHAR(20)); INSERT INTO Suppliers VALUES (1,'Supplier1','Asia'); INSERT INTO Suppliers VALUES (2,'Supplier2','USA'); CREATE TABLE SupplierOrders (OrderID INT,SupplierID INT,OrderDate DATE); INSERT INTO SupplierOrders VALUES (1,1); INSERT INTO Supp...
SELECT Suppliers.CompanyName FROM Suppliers LEFT JOIN SupplierOrders ON Suppliers.SupplierID = SupplierOrders.SupplierID WHERE Suppliers.Country = 'Asia' AND SupplierOrders.OrderDate < DATEADD(YEAR, -1, GETDATE()) AND SupplierOrders.OrderID IS NULL;
What are the names and types of organizations in 'Canada'?
CREATE TABLE organizations (id INT PRIMARY KEY,name VARCHAR(50),type VARCHAR(50),location VARCHAR(50)); INSERT INTO organizations (id,name,type,location) VALUES (1,'Greenpeace','Non-profit','Canada'); INSERT INTO organizations (id,name,type,location) VALUES (2,'The Climate Group','Non-profit','UK'); INSERT INTO organiz...
SELECT organizations.name, organizations.type FROM organizations WHERE organizations.location = 'Canada';
Delete all open pedagogy courses that were created before 2010 from the 'courses' table.
CREATE TABLE courses (course_id INT,course_name VARCHAR(50),creation_date DATE);
DELETE FROM courses WHERE course_name LIKE '%open pedagogy%' AND creation_date < '2010-01-01';
Which restorative program in California has the highest number of successful completions?
CREATE TABLE restorative_completions (completion_id INT,program_id INT,state VARCHAR(20),completions INT); INSERT INTO restorative_completions (completion_id,program_id,state,completions) VALUES (1,1,'California',35),(2,2,'California',42),(3,3,'Texas',21);
SELECT program_id, MAX(completions) FROM restorative_completions WHERE state = 'California' GROUP BY program_id;
What is the inventory level of 'Organic Spinach'?
CREATE TABLE inventory (id INT,item VARCHAR(255),quantity INT); INSERT INTO inventory (id,item,quantity) VALUES (1,'Organic Spinach',50),(2,'Tofu',30),(3,'Almond Milk',20);
SELECT quantity FROM inventory WHERE item = 'Organic Spinach';
What is the maximum depth of the deepest part of the Arctic, Atlantic, and Indian Oceans?
CREATE TABLE ocean_depths (id INT,name VARCHAR(255),location VARCHAR(255),depth FLOAT); INSERT INTO ocean_depths (id,name,location,depth) VALUES (1,'Challenger Deep','Pacific Ocean',10994); INSERT INTO ocean_depths (id,name,location,depth) VALUES (2,'Southern Ocean Trench','Antarctic Ocean',7235); INSERT INTO ocean_dep...
SELECT MAX(depth) FROM ocean_depths WHERE location IN ('Arctic Ocean', 'Atlantic Ocean', 'Indian Ocean');
Who are the top 5 athletes with the highest participation in wellbeing programs?
CREATE TABLE athletes (athlete_id INT,name VARCHAR(30),team VARCHAR(20)); INSERT INTO athletes VALUES (1,'James','Lakers'); INSERT INTO athletes VALUES (2,'Thomas','Celtics'); CREATE TABLE wellbeing_programs (program_id INT,athlete_id INT,program_name VARCHAR(30)); INSERT INTO wellbeing_programs VALUES (1,1,'Meditation...
SELECT athletes.name, COUNT(*) as program_count FROM athletes INNER JOIN wellbeing_programs ON athletes.athlete_id = wellbeing_programs.athlete_id GROUP BY athletes.name ORDER BY program_count DESC LIMIT 5;
Who are the top 3 athletes with the highest number of wellbeing program participations?
CREATE TABLE Athletes (athlete_id INT,name VARCHAR(255),participations INT); INSERT INTO Athletes (athlete_id,name,participations) VALUES (1,'John Doe',10),(2,'Jane Smith',12),(3,'Mary Johnson',8),(4,'James Brown',15);
SELECT name, participations FROM Athletes ORDER BY participations DESC LIMIT 3;
Which volunteers are not assigned to any project in North America?
CREATE TABLE if not exists countries (id INT PRIMARY KEY,name VARCHAR(50),continent VARCHAR(50)); INSERT INTO countries (id,name,continent) VALUES (1,'Haiti','North America'); INSERT INTO countries (id,name,continent) VALUES (2,'Mexico','North America'); CREATE TABLE if not exists projects (id INT PRIMARY KEY,name VARC...
SELECT v.name FROM volunteers v LEFT JOIN projects p ON v.project_id = p.id WHERE p.id IS NULL AND c.continent = 'North America';
Which rural infrastructure projects in Central America have a completion rate higher than the overall completion rate for all projects, and what is the average completion rate for these projects?
CREATE TABLE Infrastructure_CA (ProjectID INT,Country VARCHAR(20),Type VARCHAR(20),Completion FLOAT); INSERT INTO Infrastructure_CA (ProjectID,Country,Type,Completion) VALUES (1,'Guatemala','Transportation',0.8),(2,'Honduras','Energy',0.7),(3,'El Salvador','Irrigation',0.6),(4,'Nicaragua','Transportation',0.9),(5,'Cost...
SELECT AVG(Completion) as Avg_Completion_Rate FROM (SELECT Completion FROM Infrastructure_CA WHERE Country IN ('Guatemala', 'Honduras', 'El Salvador', 'Nicaragua', 'Costa Rica', 'Panama') HAVING Completion > (SELECT AVG(Completion) FROM Infrastructure_CA WHERE Country IN ('Guatemala', 'Honduras', 'El Salvador', 'Nicara...
Insert a new investment round into the "investment_rounds" table for 'Charlie Startup' with $10M raised on 2022-01-01
CREATE TABLE investment_rounds (id INT,company_name VARCHAR(100),round_type VARCHAR(50),raised_amount FLOAT,round_date DATE);
INSERT INTO investment_rounds (id, company_name, round_type, raised_amount, round_date) VALUES (3, 'Charlie Startup', 'Series B', 10000000, '2022-01-01');
Add a virtual reality game to the game design data
CREATE TABLE GameDesignData (GameID INT PRIMARY KEY,GameName VARCHAR(50),Genre VARCHAR(20),Platform VARCHAR(20),ReleaseDate DATE,Developer VARCHAR(50));
INSERT INTO GameDesignData (GameID, GameName, Genre, Platform, ReleaseDate, Developer) VALUES (1, 'VirtualReality Racer', 'Racing', 'VR', '2023-01-01', 'VR Game Studios');
What is the count of unique students who utilized assistive technology in each program?
CREATE TABLE AssistiveTech (student_id INT,program_name VARCHAR(255),tech_type VARCHAR(255)); INSERT INTO AssistiveTech (student_id,program_name,tech_type) VALUES (1,'Program A','Screen Reader'); INSERT INTO AssistiveTech (student_id,program_name,tech_type) VALUES (3,'Program A','Text-to-Speech'); INSERT INTO Assistive...
SELECT program_name, COUNT(DISTINCT CASE WHEN tech_type = 'Assistive Technology' THEN student_id END) as unique_students FROM AssistiveTech GROUP BY program_name;
What is the total installed solar PV capacity (MW) in Japan as of 2021?
CREATE TABLE solar_pv (id INT,country TEXT,year INT,capacity_mw FLOAT); INSERT INTO solar_pv (id,country,year,capacity_mw) VALUES (1,'Japan',2020,60.5),(2,'Japan',2021,65.6);
SELECT SUM(capacity_mw) FROM solar_pv WHERE country = 'Japan' AND year = 2021;
Update the restaurant_revenue table to set the total_revenue to 0 for revenue_date '2022-07-01'
CREATE TABLE restaurant_revenue (restaurant_id INT,revenue_date DATE,total_revenue DECIMAL(10,2));
UPDATE restaurant_revenue SET total_revenue = 0 WHERE revenue_date = '2022-07-01';
List all programs and their corresponding volunteer engagement metrics for 2022, ordered by the highest number of volunteers?
CREATE TABLE Programs (ProgramID INT,ProgramName TEXT,Budget FLOAT); CREATE TABLE VolunteerPrograms (VolunteerID INT,ProgramID INT,VolunteerDate DATE); INSERT INTO Programs (ProgramID,ProgramName,Budget) VALUES (1,'Education',10000.00),(2,'Health',15000.00); INSERT INTO VolunteerPrograms (VolunteerID,ProgramID,Voluntee...
SELECT Programs.ProgramName, COUNT(DISTINCT VolunteerPrograms.VolunteerID) as VolunteerCount FROM Programs INNER JOIN VolunteerPrograms ON Programs.ProgramID = VolunteerPrograms.ProgramID WHERE YEAR(VolunteerPrograms.VolunteerDate) = 2022 GROUP BY Programs.ProgramName ORDER BY VolunteerCount DESC;
What is the total budget for habitat preservation projects in the Amazon rainforest?
CREATE TABLE Habitat_Preservation (Id INT,Project_Name VARCHAR(50),Location VARCHAR(50),Budget DECIMAL(10,2)); INSERT INTO Habitat_Preservation (Id,Project_Name,Location,Budget) VALUES (1,'Amazon_Project_1','Amazon',50000); INSERT INTO Habitat_Preservation (Id,Project_Name,Location,Budget) VALUES (2,'Amazon_Project_2',...
SELECT SUM(Budget) FROM Habitat_Preservation WHERE Location = 'Amazon';
What is the minimum preparedness score for each city?
CREATE TABLE DisasterPreparedness (id INT,city VARCHAR(255),preparedness_score INT);
SELECT city, MIN(preparedness_score) FROM DisasterPreparedness GROUP BY city;
Which fair trade suppliers are based in South America?
CREATE TABLE suppliers (id INT PRIMARY KEY,name VARCHAR(50),country VARCHAR(50),fair_trade BOOLEAN);
SELECT name AS supplier_name FROM suppliers WHERE country IN ('Argentina', 'Bolivia', 'Brazil', 'Chile', 'Colombia', 'Ecuador', 'Guyana', 'Paraguay', 'Peru', 'Suriname', 'Uruguay', 'Venezuela') AND fair_trade = TRUE;
List all military equipment maintenance records for the Navy in Q3 2020
CREATE TABLE equipment_maintenance (equipment_id INT,branch VARCHAR(50),date DATE,status VARCHAR(50)); INSERT INTO equipment_maintenance (equipment_id,branch,date,status) VALUES (1002,'Navy','2020-07-18','Completed');
SELECT * FROM equipment_maintenance WHERE branch = 'Navy' AND QUARTER(date) = 3 AND YEAR(date) = 2020;
What's the total number of donations and unique donors for each month in 2021?
CREATE TABLE donations_2 (id INT,donation_date DATE,donation_amount DECIMAL,donor_id INT);
SELECT EXTRACT(MONTH FROM donation_date) AS month, COUNT(id) AS total_donations, COUNT(DISTINCT donor_id) AS unique_donors FROM donations_2 WHERE donation_date >= '2021-01-01' GROUP BY month;
What is the total revenue of vegan skincare products from the US?
CREATE TABLE Sales (id INT,product_id INT,sale_date DATE,sale_price DECIMAL(5,2),country TEXT); CREATE TABLE Products (id INT,category TEXT,is_vegan BOOLEAN,price DECIMAL(5,2)); INSERT INTO Sales (id,product_id,sale_date,sale_price,country) VALUES (1,1,'2022-02-01',29.99,'US'),(2,2,'2022-03-05',19.99,'CA'); INSERT INTO...
SELECT SUM(sale_price) FROM Sales JOIN Products ON Sales.product_id = Products.id WHERE is_vegan = true AND category = 'Skincare' AND country = 'US';
What is the total number of marine protected areas in Africa and Oceania?
CREATE TABLE marine_protected_areas(region VARCHAR(255),num_areas INT);INSERT INTO marine_protected_areas(region,num_areas) VALUES ('Africa',120),('Oceania',200);
SELECT SUM(num_areas) FROM marine_protected_areas WHERE region IN ('Africa', 'Oceania');
What is the total number of peacekeeping personnel who have received humanitarian assistance training from NATO since 2017?
CREATE TABLE peacekeeping(id INT,personnel_id INT,trained_in VARCHAR(255),training_year INT); INSERT INTO peacekeeping(id,personnel_id,trained_in,training_year) VALUES (1,123,'Humanitarian Assistance',2017),(2,456,'Mediation',2018),(3,789,'Humanitarian Assistance',2019); CREATE TABLE nato_trainers(id INT,trainer VARCHA...
SELECT COUNT(*) FROM peacekeeping p JOIN nato_trainers n ON p.trained_in = 'Humanitarian Assistance' AND trained_by = 'NATO';
Find the number of affordable housing units in each city.
CREATE TABLE cities (id INT,name VARCHAR(30)); CREATE TABLE affordable_housing (id INT,city_id INT,units INT); INSERT INTO cities (id,name) VALUES (1,'Seattle'),(2,'Portland'),(3,'Vancouver'); INSERT INTO affordable_housing (id,city_id,units) VALUES (101,1,200),(102,1,300),(103,2,150),(104,3,400);
SELECT cities.name, SUM(affordable_housing.units) FROM cities INNER JOIN affordable_housing ON cities.id = affordable_housing.city_id GROUP BY cities.name;
What is the total budget allocated for the Public Works department's services in each city district?
CREATE TABLE PublicWorks (Service VARCHAR(255),District VARCHAR(255),Budget INT); INSERT INTO PublicWorks (Service,District,Budget) VALUES ('Road Maintenance','Downtown',900000),('Waste Management','Uptown',1100000),('Street Lighting','Suburbs',700000);
SELECT SUM(Budget), District FROM PublicWorks GROUP BY District;