instruction
stringlengths
0
1.06k
input
stringlengths
11
5.3k
response
stringlengths
2
4.44k
What were the top 3 countries with the most space missions launched between 2010 and 2020?
CREATE TABLE space_missions (mission_id INT,country VARCHAR(50),launch_year INT); INSERT INTO space_missions (mission_id,country,launch_year) VALUES (1,'USA',2010),(2,'China',2012),(3,'Russia',2015),(4,'India',2016),(5,'Japan',2017);
SELECT country, COUNT(*) as mission_count FROM space_missions WHERE launch_year BETWEEN 2010 AND 2020 GROUP BY country ORDER BY mission_count DESC LIMIT 3;
Find the top 3 water-consuming states in the agricultural sector.
CREATE TABLE water_usage (state TEXT,sector TEXT,consumption INTEGER); INSERT INTO water_usage (state,sector,consumption) VALUES ('California','Agriculture',12000),('Texas','Agriculture',18000),('Nebraska','Agriculture',9000),('Oklahoma','Agriculture',10000),('Florida','Agriculture',15000);
SELECT state, consumption FROM water_usage WHERE sector = 'Agriculture' ORDER BY consumption DESC LIMIT 3;
What is the average price of vegan cosmetics sold in the US?
CREATE TABLE cosmetics (id INT,name TEXT,price DECIMAL,is_vegan BOOLEAN,country TEXT); INSERT INTO cosmetics (id,name,price,is_vegan,country) VALUES (1,'Lipstick',15.99,true,'USA'); INSERT INTO cosmetics (id,name,price,is_vegan,country) VALUES (2,'Eyeshadow',25.99,false,'USA'); INSERT INTO cosmetics (id,name,price,is_v...
SELECT AVG(price) FROM cosmetics WHERE is_vegan = true AND country = 'USA';
Update the account balance of clients who have recently received financial support from charitable organizations.
CREATE TABLE clients (client_id INT,name VARCHAR(50),account_balance DECIMAL(10,2));
UPDATE clients SET account_balance = account_balance + 500 WHERE client_id IN (SELECT client_id FROM (SELECT client_id, ROW_NUMBER() OVER(ORDER BY client_id) AS rn FROM clients WHERE account_balance < 1000) AS sq WHERE rn <= 10);
Present the cybersecurity strategies implemented by each government agency, the strategy type, and the year it was adopted, along with the status of its implementation.
CREATE TABLE cybersecurity_strategies (agency_name VARCHAR(255),strategy_type VARCHAR(255),adoption_year INT,implementation_status VARCHAR(255));
SELECT agency_name, strategy_type, adoption_year, COUNT(*) as num_implemented FROM cybersecurity_strategies WHERE implementation_status = 'Implemented' GROUP BY agency_name, strategy_type, adoption_year;
Drop the 'gogh_artworks' view
CREATE TABLE artworks (id INT PRIMARY KEY,title VARCHAR(255),artist VARCHAR(255),year INT); CREATE VIEW gogh_artworks AS SELECT * FROM artworks WHERE artist = 'Vincent van Gogh';
DROP VIEW gogh_artworks;
What is the average monetary donation amount received from female donors for the 'Education for Girls' project?
CREATE TABLE donors(id INT,gender TEXT,donation FLOAT); INSERT INTO donors(id,gender,donation) VALUES (1,'Female',50.00),(2,'Male',100.00),(3,'Female',25.00);
SELECT AVG(donation) FROM donors WHERE gender = 'Female' AND project = 'Education for Girls';
Determine the number of unique artists and albums in the database
CREATE TABLE Artist (id INT,name VARCHAR(255)); CREATE TABLE Album (id INT,artist_id INT,title VARCHAR(255),year INT);
SELECT COUNT(DISTINCT A.id) as artist_count, COUNT(DISTINCT AL.id) as album_count FROM Artist A INNER JOIN Album AL ON A.id = AL.artist_id;
What are the top 3 digital assets by market capitalization in the Energy sector?
CREATE TABLE digital_assets (asset_id INT,name VARCHAR(255),sector VARCHAR(255),market_cap DECIMAL(18,2)); INSERT INTO digital_assets (asset_id,name,sector,market_cap) VALUES (1,'Bitcoin','Store of Value',1000000000),(2,'Ethereum','Energy',300000000),(3,'SolarCoin','Energy',50000);
SELECT asset_id, name, sector, market_cap, ROW_NUMBER() OVER (PARTITION BY sector ORDER BY market_cap DESC) AS sector_market_cap_rank FROM digital_assets WHERE sector = 'Energy' FETCH FIRST 3 ROWS ONLY;
What is the regulatory status (approved, pending, rejected) of the digital assets with the lowest market capitalization, and what is their market capitalization?
CREATE TABLE LowMarketCapitalization (asset_id INT,asset_name VARCHAR(255),regulatory_status VARCHAR(255),market_capitalization DECIMAL(18,2)); INSERT INTO LowMarketCapitalization (asset_id,asset_name,regulatory_status,market_capitalization) VALUES (1,'DOGE','approved',100.00),(2,'ADA','pending',200.00),(3,'LINK','reje...
SELECT regulatory_status, market_capitalization FROM (SELECT regulatory_status, market_capitalization, RANK() OVER (ORDER BY market_capitalization ASC) as rank FROM LowMarketCapitalization WHERE regulatory_status IN ('approved', 'pending', 'rejected')) AS ranked_assets WHERE rank <= 3;
What is the average CO2 emissions reduction (in metric tons) from green building projects in the residential sector, grouped by city and year, where the average reduction is greater than 50 metric tons?
CREATE TABLE green_buildings_residential (building_id INT,city VARCHAR(50),year INT,co2_reduction_tons INT);
SELECT city, year, AVG(co2_reduction_tons) FROM green_buildings_residential GROUP BY city, year HAVING AVG(co2_reduction_tons) > 50;
Delete records in the vessel_performance table where the vessel_id is 101
CREATE TABLE vessel_performance (id INT,vessel_id INT,timestamp DATETIME,speed FLOAT);
DELETE FROM vessel_performance WHERE vessel_id = 101;
Delete all players from Egypt who have played less than 100 games.
CREATE TABLE Players (PlayerID INT,PlayerName VARCHAR(50),Age INT,Country VARCHAR(50),GamesPlayed INT); INSERT INTO Players (PlayerID,PlayerName,Age,Country,GamesPlayed) VALUES (1,'John Doe',25,'USA',100); INSERT INTO Players (PlayerID,PlayerName,Age,Country,GamesPlayed) VALUES (2,'Jane Smith',30,'Canada',200); INSERT ...
DELETE FROM Players WHERE Country = 'Egypt' AND GamesPlayed < 100;
What is the average travel advisory level for each region in Asia?
CREATE TABLE if not exists regions (id INT,name VARCHAR(20)); INSERT INTO regions (id,name) VALUES (1,'South Asia'),(2,'East Asia'),(3,'Southeast Asia'); CREATE TABLE if not exists advisories (id INT,region_id INT,level INT);
SELECT r.name, AVG(a.level) FROM advisories a JOIN regions r ON a.region_id = r.id GROUP BY r.name;
List all marine life research grants awarded in the 'Grants' schema from 2020.
CREATE SCHEMA Grants; CREATE TABLE ResearchGrants (grant_id INT,grant_amount DECIMAL(10,2),grant_year INT); INSERT INTO ResearchGrants (grant_id,grant_amount,grant_year) VALUES (1,50000.00,2020),(2,75000.00,2019),(3,30000.00,2020);
SELECT * FROM Grants.ResearchGrants WHERE grant_year = 2020 AND grant_type = 'MarineLifeResearch';
List all the football teams and their respective stadium capacities.
CREATE TABLE teams (id INT,name VARCHAR(50),sport VARCHAR(20)); CREATE TABLE stadiums (id INT,name VARCHAR(50),capacity INT,team_id INT); INSERT INTO teams (id,name,sport) VALUES (1,'New York Giants','Football'); INSERT INTO teams (id,name,sport) VALUES (2,'New York Jets','Football'); INSERT INTO stadiums (id,name,capa...
SELECT teams.name, stadiums.capacity FROM teams INNER JOIN stadiums ON teams.id = stadiums.team_id WHERE teams.sport = 'Football';
Which rural infrastructure projects were completed between 2018 and 2020?
CREATE TABLE infrastructure_projects (project_id INT,project_name TEXT,location TEXT,completion_year INT); INSERT INTO infrastructure_projects (project_id,project_name,location,completion_year) VALUES (1,'Bridge Construction','Rural Area',2018); INSERT INTO infrastructure_projects (project_id,project_name,location,comp...
SELECT * FROM infrastructure_projects WHERE completion_year BETWEEN 2018 AND 2020 AND location LIKE 'rural%';
Identify the number of countries in the ocean_health_metrics table with a water_quality_index above 80.
CREATE TABLE ocean_health_metrics (country VARCHAR(255),water_quality_index INT); INSERT INTO ocean_health_metrics (country,water_quality_index) VALUES ('Canada',85),('USA',78),('Mexico',62),('Peru',82);
SELECT COUNT(*) FROM ocean_health_metrics WHERE water_quality_index > 80;
What is the average energy efficiency (in kWh/m2) of buildings in the city of Berlin, Germany?
CREATE TABLE buildings (building_id INT,city VARCHAR(255),energy_efficiency FLOAT); INSERT INTO buildings (building_id,city,energy_efficiency) VALUES (1,'Berlin',150),(2,'Berlin',160),(3,'Berlin',140),(4,'Berlin',170),(5,'Berlin',130),(6,'Paris',180),(7,'Paris',170),(8,'Paris',160),(9,'London',190),(10,'London',180),(1...
SELECT AVG(energy_efficiency) FROM buildings WHERE city = 'Berlin';
How many indigenous food systems exist in Australia and New Zealand?
CREATE TABLE indigenous_food_systems (id INT,name TEXT,country TEXT); INSERT INTO indigenous_food_systems (id,name,country) VALUES (1,'System 1','Australia'),(2,'System 2','New Zealand');
SELECT COUNT(*) as count FROM indigenous_food_systems WHERE country IN ('Australia', 'New Zealand');
List all factories that use water-efficient methods in Oceania.
CREATE TABLE FactoryWaterUsage (factory_id INT,uses_water_efficient_methods BOOLEAN); INSERT INTO FactoryWaterUsage (factory_id,uses_water_efficient_methods) VALUES (1,true),(2,false),(3,true); CREATE TABLE Factories (factory_id INT,region VARCHAR(50)); INSERT INTO Factories (factory_id,region) VALUES (1,'Oceania'),(2,...
SELECT factory_id, region FROM FactoryWaterUsage INNER JOIN Factories ON FactoryWaterUsage.factory_id = Factories.factory_id WHERE Factories.region = 'Oceania' AND FactoryWaterUsage.uses_water_efficient_methods = true;
What is the minimum and maximum loan amount for socially responsible lending in South America?
CREATE TABLE socially_responsible_lending_sa (id INT,country VARCHAR(255),loan_amount DECIMAL(10,2)); INSERT INTO socially_responsible_lending_sa (id,country,loan_amount) VALUES (1,'Brazil',6000.00),(2,'Argentina',8000.00),(3,'Colombia',5000.00);
SELECT MIN(loan_amount) as "Min Loan Amount", MAX(loan_amount) as "Max Loan Amount" FROM socially_responsible_lending_sa WHERE country IN ('Brazil', 'Argentina', 'Colombia');
What is the total number of crimes committed by type in 2021?
CREATE TABLE crimes (id INT PRIMARY KEY,incident_date DATE,location VARCHAR(50),crime_type VARCHAR(50),description TEXT,FOREIGN KEY (incident_date) REFERENCES dates(date));
SELECT crime_type, COUNT(*) as total_crimes FROM crimes JOIN dates ON crimes.incident_date = dates.date WHERE dates.date BETWEEN '2021-01-01' AND '2021-12-31' GROUP BY crime_type;
What is the number of cases in each state, grouped by region?
CREATE TABLE Cases (CaseID INT,State VARCHAR(20),Region VARCHAR(20),BillingAmount DECIMAL(10,2)); INSERT INTO Cases (CaseID,State,Region,BillingAmount) VALUES (1,'California','West',5000.00),(2,'Texas','South',3500.00),(3,'California','West',4000.00),(4,'New York','Northeast',6000.00);
SELECT Region, State, COUNT(*) AS NumberOfCases FROM Cases GROUP BY Region, State;
What is the maximum loan amount for clients in Indonesia?
CREATE TABLE loans (loan_id INT,client_id INT,country VARCHAR(50),loan_amount DECIMAL(10,2)); INSERT INTO loans (loan_id,client_id,country,loan_amount) VALUES (1,3,'Indonesia',25000);
SELECT MAX(loan_amount) FROM loans WHERE country = 'Indonesia';
What is the total number of solar panel installations in urban areas, grouped by city and state, where the installation count is greater than 500?
CREATE TABLE urban_solar_installations (installation_id INT,city VARCHAR(50),state VARCHAR(50),installation_type VARCHAR(50));
SELECT city, state, COUNT(installation_id) FROM urban_solar_installations GROUP BY city, state HAVING COUNT(installation_id) > 500;
What is the total number of workplace safety violations in the 'construction' schema for the months of 'July' and 'August' in '2022'?
CREATE TABLE safety_violations (id INT,date DATE,industry VARCHAR(255),violation_count INT); INSERT INTO safety_violations (id,date,industry,violation_count) VALUES (1,'2022-07-01','construction',10),(2,'2022-08-01','construction',15),(3,'2022-09-01','construction',12);
SELECT SUM(violation_count) FROM safety_violations WHERE industry = 'construction' AND date BETWEEN '2022-07-01' AND '2022-08-31';
List the conferences that have more than 100 attendees.
CREATE TABLE InternationalConferences (ConferenceID INT,ConferenceName VARCHAR(50),NumberOfAttendees INT);
SELECT ConferenceName FROM InternationalConferences WHERE NumberOfAttendees > 100;
What is the average donation amount for donors aged 18-24 who have donated to organizations focused on global health?
CREATE TABLE donors (id INT,age INT,name VARCHAR(255)); INSERT INTO donors (id,age,name) VALUES (1,19,'Global Health Donor'); CREATE TABLE donations (id INT,donor_id INT,organization_id INT,amount DECIMAL(10,2),donation_date DATE); INSERT INTO donations (id,donor_id,organization_id,amount,donation_date) VALUES (1,1,3,5...
SELECT AVG(amount) FROM donations JOIN donors ON donations.donor_id = donors.id JOIN organizations ON donations.organization_id = organizations.id WHERE donors.age BETWEEN 18 AND 24 AND organizations.focus = 'Global Health';
What is the total revenue earned by drivers driving Tesla or Nissan Leaf vehicles with more than 250 rides?
CREATE TABLE Drivers (id INT,name VARCHAR(255),vehicle_type VARCHAR(50),vehicle_year INT,total_rides INT,total_revenue FLOAT); INSERT INTO Drivers (id,name,vehicle_type,vehicle_year,total_rides,total_revenue) VALUES (1,'Hana','Nissan Leaf',2020,260,3800.00),(2,'Liam','Tesla',2021,300,5000.00);
SELECT SUM(total_revenue) FROM (SELECT total_revenue FROM Drivers WHERE vehicle_type = 'Tesla' AND total_rides > 250 UNION ALL SELECT total_revenue FROM Drivers WHERE vehicle_type = 'Nissan Leaf' AND total_rides > 250) AS subquery;
Display the total number of accidents in factories located in urban areas
CREATE TABLE factories_location (id INT,name VARCHAR(50),location VARCHAR(50),accidents INT); INSERT INTO factories_location (id,name,location,accidents) VALUES (1,'Factory A','urban',2),(2,'Factory B','rural',0),(3,'Factory C','urban',3),(4,'Factory D','rural',1);
SELECT SUM(accidents) FROM factories_location WHERE location = 'urban';
What is the total number of regulatory violations by the company with the id 2 up to and including 2021-09-30?
CREATE TABLE Companies (id INT,name VARCHAR(255)); CREATE TABLE RegulatoryViolations (id INT,company_id INT,violation_date DATE); INSERT INTO Companies (id,name) VALUES (1,'CompanyA'),(2,'CompanyB'),(3,'CompanyC'); INSERT INTO RegulatoryViolations (id,company_id,violation_date) VALUES (1,1,'2021-08-01'),(2,1,'2021-09-0...
SELECT COUNT(*) FROM RegulatoryViolations JOIN Companies ON RegulatoryViolations.company_id = Companies.id WHERE Companies.id = 2 AND RegulatoryViolations.violation_date <= '2021-09-30';
How many seals are in the Arctic Ocean?
CREATE TABLE Animals (name VARCHAR(50),species VARCHAR(50),location VARCHAR(50)); INSERT INTO Animals (name,species,location) VALUES ('Seal 1','Seal','Arctic Ocean'),('Seal 2','Seal','Arctic Ocean'),('Walrus 1','Walrus','Arctic Ocean');
SELECT COUNT(*) FROM Animals WHERE species = 'Seal' AND location = 'Arctic Ocean';
What is the total value of all sustainable building projects in California?
CREATE TABLE Projects (ProjectID INT,ProjectValue DECIMAL(10,2),IsSustainable BOOLEAN,State CHAR(2));
SELECT SUM(ProjectValue) FROM Projects WHERE State='CA' AND IsSustainable=TRUE;
List all marine species and their status under maritime law in the Polar Seas Conservation database.
CREATE TABLE PolarSeasConservation (id INT,species TEXT,status TEXT); INSERT INTO PolarSeasConservation (id,species,status) VALUES (1,'Polar Bear','Vulnerable'); INSERT INTO PolarSeasConservation (id,species,status) VALUES (2,'Walrus','Protected');
SELECT species, status FROM PolarSeasConservation;
What is the average salary by company and job role?
CREATE TABLE Salaries (id INT,company_id INT,job_role VARCHAR(50),salary INT); INSERT INTO Salaries (id,company_id,job_role,salary) VALUES (1,1,'Engineer',90000),(2,1,'Manager',120000),(3,2,'Engineer',95000);
SELECT company_id, job_role, AVG(salary) as avg_salary, RANK() OVER (PARTITION BY AVG(salary) ORDER BY AVG(salary) DESC) as salary_rank FROM Salaries GROUP BY company_id, job_role;
Identify the top 5 strains with the highest average retail price in Massachusetts dispensaries during Q3 2022.
CREATE TABLE strains (id INT,name TEXT,type TEXT); INSERT INTO strains (id,name,type) VALUES (12,'Blue Dream','Hybrid'),(13,'OG Kush','Indica'),(14,'Jack Herer','Sativa'); CREATE TABLE sales (id INT,strain_id INT,retail_price DECIMAL,sale_date DATE,state TEXT); INSERT INTO sales (id,strain_id,retail_price,sale_date,sta...
SELECT name, AVG(retail_price) FROM (SELECT name, retail_price, ROW_NUMBER() OVER (PARTITION BY name ORDER BY retail_price DESC) rn FROM sales WHERE state = 'Massachusetts' AND sale_date >= '2022-07-01' AND sale_date < '2022-10-01') tmp WHERE rn <= 5 GROUP BY name ORDER BY AVG(retail_price) DESC;
What is the total capacity of wind energy projects in Germany?
CREATE TABLE wind_projects (id INT,country VARCHAR(50),capacity FLOAT);
SELECT SUM(capacity) FROM wind_projects WHERE country = 'Germany';
Which mining methods were used in the US for Copper extraction in 2020?
CREATE TABLE mining_methods (method VARCHAR(50),location VARCHAR(50),mineral VARCHAR(50),year INT); INSERT INTO mining_methods (method,location,mineral,year) VALUES ('Open-pit','US','Copper',2020),('Underground','US','Copper',2020),('In-situ leaching','US','Uranium',2020);
SELECT DISTINCT method FROM mining_methods WHERE location = 'US' AND mineral = 'Copper' AND year = 2020;
What is the average donation amount per donor for each cause category?
CREATE TABLE donor_donations (donor_id INT,donation_amount DECIMAL(10,2),cause_category VARCHAR(255)); INSERT INTO donor_donations (donor_id,donation_amount,cause_category) VALUES (1,5000.00,'Education'),(2,3000.00,'Health'),(3,7000.00,'Environment'),(1,6000.00,'Health');
SELECT cause_category, AVG(donation_amount) AS avg_donation, MIN(donation_amount) AS min_donation, MAX(donation_amount) AS max_donation FROM donor_donations GROUP BY cause_category;
How many geopolitical risk assessments were conducted in 2021 for any country?
CREATE TABLE Geopolitical_Risk_Assessments (assessment_id INT,assessment_date DATE,country VARCHAR(50)); INSERT INTO Geopolitical_Risk_Assessments (assessment_id,assessment_date,country) VALUES (1,'2021-05-12','France'),(2,'2021-07-03','Germany'),(3,'2021-11-28','Italy');
SELECT COUNT(assessment_id) FROM Geopolitical_Risk_Assessments WHERE YEAR(assessment_date) = 2021;
How many permits were issued in Texas for residential construction projects between 2015 and 2017?
CREATE TABLE permit (permit_id INT,state VARCHAR(50),project_type VARCHAR(50),issue_date DATE); INSERT INTO permit (permit_id,state,project_type,issue_date) VALUES (1,'Texas','Residential','2015-01-01');
SELECT COUNT(*) FROM permit WHERE state = 'Texas' AND project_type = 'Residential' AND issue_date BETWEEN '2015-01-01' AND '2017-12-31';
How many broadband subscribers have been added monthly, by city, for the past year?
CREATE TABLE broadband_subscribers (subscriber_id INT,subscribe_date DATE,city VARCHAR(255)); INSERT INTO broadband_subscribers (subscriber_id,subscribe_date,city) VALUES (1,'2021-03-01','Los Angeles'),(2,'2021-05-15','Toronto'),(3,'2021-03-04','Mexico City'),(4,'2021-10-20','São Paulo'),(5,'2022-07-03','New York'),(6,...
SELECT YEAR(subscribe_date) AS year, MONTH(subscribe_date) AS month, city, COUNT(subscriber_id) AS new_subscribers FROM broadband_subscribers WHERE subscribe_date >= DATE_SUB(CURDATE(), INTERVAL 1 YEAR) GROUP BY year, month, city;
Which region has the highest waste generation in 2020?
CREATE TABLE waste_generation(region VARCHAR(10),year INT,amount INT); INSERT INTO waste_generation VALUES('urban',2019,1500),('urban',2020,1800),('rural',2019,800),('rural',2020,1000);
SELECT region, MAX(amount) FROM waste_generation WHERE year = 2020 GROUP BY region;
What is the average response time for emergency calls in the 'fire' category in each district over the last month?
CREATE TABLE districts (id INT,name TEXT);CREATE TABLE emergencies (id INT,district_id INT,category_id INT,response_time INT,date DATE);CREATE TABLE emergency_categories (id INT,name TEXT);
SELECT d.name, AVG(e.response_time) FROM districts d JOIN emergencies e ON d.id = e.district_id JOIN emergency_categories ec ON e.category_id = ec.id WHERE ec.name = 'fire' AND e.date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) GROUP BY d.id;
Insert a new security incident report for a phishing attack on the HR department from yesterday.
CREATE TABLE incident_reports (incident_id INT,department VARCHAR(255),incident_type VARCHAR(255),reported_date TIMESTAMP);
INSERT INTO incident_reports (incident_id, department, incident_type, reported_date) VALUES (1, 'HR', 'Phishing', NOW() - INTERVAL '1 day');
What is the total number of hours spent on open pedagogy projects by students in each grade level?
CREATE TABLE grades (id INT,level TEXT); CREATE TABLE projects (id INT,student_id INT,hours INT,open_pedagogy BOOLEAN);
SELECT g.level, SUM(p.hours) FROM projects p JOIN grades g ON p.student_id = g.id WHERE p.open_pedagogy = TRUE GROUP BY g.id;
Update the region of a traditional art in the 'traditional_arts' table
CREATE TABLE traditional_arts (id INT PRIMARY KEY,name VARCHAR(255),type VARCHAR(255),region VARCHAR(255));
UPDATE traditional_arts SET region = 'Central Asia' WHERE id = 1;
Update the country for Green Waves vendor in the sustainable_vendors table
CREATE TABLE sustainable_vendors (id INT PRIMARY KEY,name VARCHAR(255),country VARCHAR(255));
UPDATE sustainable_vendors SET country = 'USA' WHERE name = 'Green Waves';
What's the most popular cruelty-free skincare product?
CREATE TABLE sales (id INT,product_id INT,quantity INT,sale_date DATE); CREATE TABLE products (id INT,name TEXT,is_cruelty_free BOOLEAN,category TEXT);
SELECT products.name, SUM(sales.quantity) as total_sold FROM sales JOIN products ON sales.product_id = products.id WHERE products.is_cruelty_free = true GROUP BY products.name ORDER BY total_sold DESC LIMIT 1;
What was the total amount donated by each age group in Q3 2021?
CREATE TABLE Donors (DonorID int,AgeGroup varchar(50),AmountDonated numeric(10,2)); INSERT INTO Donors (DonorID,AgeGroup,AmountDonated) VALUES (1,'18-24',200.00),(2,'25-34',300.00);
SELECT AgeGroup, SUM(AmountDonated) as TotalDonated FROM Donors WHERE AmountDonated >= 0 AND AmountDonated < 9999.99 GROUP BY AgeGroup;
Show the total number of games played by each team in the hockey_games table
CREATE TABLE hockey_games (id INT,team_id INT,game_date DATE); INSERT INTO hockey_games (id,team_id,game_date) VALUES (1,1,'2021-10-01'),(2,2,'2021-10-05'),(3,1,'2021-11-03');
SELECT team_id, COUNT(*) as games_played FROM hockey_games GROUP BY team_id;
Display the name and region for pollution sources in the pollution_sources table, ordered by pollution amount in descending order.
CREATE TABLE pollution_sources (id INT,name VARCHAR(255),region VARCHAR(255),pollution_amount INT); INSERT INTO pollution_sources (id,name,region,pollution_amount) VALUES (1,'Oceanic Chemical Pollution','Atlantic Ocean',60000); INSERT INTO pollution_sources (id,name,region,pollution_amount) VALUES (2,'Marine Debris','I...
SELECT name, region FROM pollution_sources ORDER BY pollution_amount DESC;
How many community policing events were held in 'Uptown' in 2020 and 2021?
CREATE TABLE locations (id INT,name VARCHAR(255)); CREATE TABLE community_policing (id INT,location_id INT,year INT,events INT); INSERT INTO locations (id,name) VALUES (1,'Uptown'); INSERT INTO community_policing (id,location_id,year,events) VALUES (1,1,2020,3),(2,1,2021,5);
SELECT SUM(events) FROM (SELECT year, events FROM community_policing WHERE location_id = (SELECT id FROM locations WHERE name = 'Uptown') AND year IN (2020, 2021)) AS subquery;
How many users have used ride-hailing services in Paris more than 10 times?
CREATE TABLE ride_hailing (ride_id INT,user_id INT,start_time TIMESTAMP,end_time TIMESTAMP,city VARCHAR(255));
SELECT COUNT(DISTINCT user_id) FROM ride_hailing WHERE city = 'Paris' GROUP BY user_id HAVING COUNT(ride_id) > 10;
Insert a new game into the games table
CREATE TABLE games (game_id INT,name VARCHAR(50));
INSERT INTO games (game_id, name) VALUES (3, 'GameX');
What is the average donation amount in Q1 2023 from returning donors in Latin America?
CREATE TABLE Donors (DonorID int,DonorType varchar(50),Country varchar(50),AmountDonated numeric(18,2),DonationDate date,IsReturningDonor bit); INSERT INTO Donors (DonorID,DonorType,Country,AmountDonated,DonationDate,IsReturningDonor) VALUES (1,'Individual','Brazil',3000,'2023-01-02',1),(2,'Organization','Argentina',80...
SELECT AVG(AmountDonated) FROM Donors WHERE DonorType = 'Individual' AND Country LIKE 'Latin America%' AND IsReturningDonor = 1 AND QUARTER(DonationDate) = 1 AND YEAR(DonationDate) = 2023;
How many policies were issued to policyholders in 'Texas'?
CREATE TABLE policies (policy_id INT,policyholder_state VARCHAR(20)); INSERT INTO policies (policy_id,policyholder_state) VALUES (1,'Texas'),(2,'California'),(3,'Texas');
SELECT COUNT(*) FROM policies WHERE policyholder_state = 'Texas';
What is the total marketing spend for all romantic-comedy movies released between 2015 and 2020, and their respective IMDb ratings?
CREATE TABLE movie (id INT,title VARCHAR(100),genre VARCHAR(20),release_year INT,IMDb_rating DECIMAL(3,1),marketing_spend INT); INSERT INTO movie (id,title,genre,release_year,IMDb_rating,marketing_spend) VALUES (1,'Silver Linings Playbook','Romantic Comedy',2012,7.7,20000000);
SELECT SUM(marketing_spend), AVG(IMDb_rating) FROM movie WHERE genre = 'Romantic Comedy' AND release_year BETWEEN 2015 AND 2020;
What is the average mass (in kg) of all spacecraft that have been used in space missions, excluding any spacecraft that have been decommissioned?
CREATE TABLE spacecraft (id INT,name VARCHAR(50),manufacturer VARCHAR(50),mass FLOAT,status VARCHAR(50)); INSERT INTO spacecraft (id,name,manufacturer,mass,status) VALUES (5,'Atlas V','United Launch Alliance',587000.0,'Active'); INSERT INTO spacecraft (id,name,manufacturer,mass,status) VALUES (6,'Titan IV','Lockheed Ma...
SELECT AVG(mass) FROM spacecraft WHERE status = 'Active';
What is the total value of materials sourced from local suppliers for the construction industry in the last fiscal year?
CREATE TABLE materials_sourcing_2 (id INT,industry VARCHAR(50),supplier_location VARCHAR(50),value DECIMAL(10,2),fiscal_year INT); INSERT INTO materials_sourcing_2 (id,industry,supplier_location,value,fiscal_year) VALUES (1,'Construction','Local',120000.00,2022),(2,'Fashion','International',200000.00,2022),(3,'Construc...
SELECT SUM(value) FROM materials_sourcing_2 WHERE industry = 'Construction' AND supplier_location = 'Local' AND fiscal_year = 2022;
List all countries and their regions from the countries table
CREATE TABLE countries (id INT,name VARCHAR(50),region VARCHAR(50));
SELECT name, region FROM countries;
List suppliers with food safety violations in the last year, excluding those with corrective actions taken.
CREATE TABLE suppliers (id INT,name TEXT,food_safety_violations INT,corrective_actions INT); INSERT INTO suppliers (id,name,food_safety_violations,corrective_actions) VALUES (1,'Supplier A',2,1),(2,'Supplier B',3,0),(3,'Supplier C',0,0),(4,'Supplier D',1,1);
SELECT name FROM suppliers WHERE food_safety_violations > 0 AND corrective_actions = 0 AND date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR);
What is the maximum safety score achieved by a model developed in the EU?
CREATE TABLE ai_models (model_id INT,name TEXT,country TEXT,safety_score FLOAT); INSERT INTO ai_models (model_id,name,country,safety_score) VALUES (1,'ModelA','Germany',0.85),(2,'ModelB','France',0.90),(3,'ModelC','US',0.75),(4,'ModelD','Germany',0.95),(5,'ModelE','France',0.92);
SELECT MAX(safety_score) FROM ai_models WHERE country IN ('Germany', 'France');
What is the maximum amount of research grants awarded to graduate students from India?
CREATE TABLE graduate_students (student_id INT,name VARCHAR(50),country VARCHAR(50)); INSERT INTO graduate_students (student_id,name,country) VALUES (1,'Alice','India'),(2,'Bob','Canada'),(3,'Carlos','Mexico'); CREATE TABLE research_grants (grant_id INT,student_id INT,amount INT); INSERT INTO research_grants (grant_id,...
SELECT MAX(rg.amount) FROM research_grants rg JOIN graduate_students gs ON rg.student_id = gs.student_id WHERE gs.country = 'India';
What is the difference in water consumption between industrial and agricultural sectors from 2015 to 2018?
CREATE TABLE water_usage(sector VARCHAR(20),year INT,consumption INT); INSERT INTO water_usage VALUES ('Industrial',2015,3000),('Industrial',2016,3200),('Industrial',2017,3400),('Industrial',2018,3600),('Agricultural',2015,8000),('Agricultural',2016,8400),('Agricultural',2017,8800),('Agricultural',2018,9200);
SELECT a.sector, (a.consumption - b.consumption) AS difference FROM water_usage AS a, water_usage AS b WHERE a.sector = 'Industrial' AND b.sector = 'Agricultural' AND a.year = b.year AND a.year BETWEEN 2015 AND 2018;
How many visual art exhibitions were held in Paris and London in 2020?
CREATE TABLE exhibitions (id INT,city VARCHAR(20),year INT,type VARCHAR(10)); INSERT INTO exhibitions (id,city,year,type) VALUES (1,'Paris',2020,'visual art'),(2,'London',2019,'visual art'),(3,'Paris',2020,'performing art'),(4,'London',2020,'visual art'),(5,'New York',2020,'visual art');
SELECT COUNT(*) FROM exhibitions WHERE city IN ('Paris', 'London') AND year = 2020 AND type = 'visual art';
Add a new agency to the 'agencies' table
CREATE TABLE agencies (id INT PRIMARY KEY,name VARCHAR(255),type VARCHAR(255),budget DECIMAL(10,2));
INSERT INTO agencies (id, name, type, budget) VALUES (1, 'Parks Department', 'Public Works', 500000.00);
List military equipment types with no maintenance activities in the 'equipment_maintenance' table
CREATE TABLE equipment_maintenance (maintenance_id INT,equipment_type VARCHAR(50),maintenance_activity VARCHAR(100),maintenance_date DATE);
SELECT equipment_type FROM equipment_maintenance GROUP BY equipment_type HAVING COUNT(*) = 0;
What is the average number of likes on posts from users in the 'celebrity' category who have more than 100000 followers, for posts made in the last 30 days?
CREATE TABLE posts (post_id INT,user_id INT,like_count INT,post_date DATE); INSERT INTO posts (post_id,user_id,like_count,post_date) VALUES (1,1,6000,'2022-02-01'),(2,2,2000,'2022-02-03'),(3,3,8000,'2022-02-05');
SELECT AVG(like_count) FROM posts JOIN users ON posts.user_id = users.user_id WHERE users.category = 'celebrity' AND users.follower_count > 100000 AND posts.post_date >= DATE_SUB(CURDATE(), INTERVAL 30 DAY);
Show all records in digital_divide table with 'Non-binary' gender
CREATE TABLE digital_divide (region VARCHAR(255),year INT,gender VARCHAR(50),internet_accessibility FLOAT,mobile_accessibility FLOAT); INSERT INTO digital_divide (region,year,gender,internet_accessibility,mobile_accessibility) VALUES ('North America',2015,'Male',0.85,0.93),('South America',2016,'Female',0.68,0.82),('As...
SELECT * FROM digital_divide WHERE gender = 'Non-binary';
What is the total funding raised by startups with a female CEO?
CREATE TABLE company (id INT,name TEXT,CEO_gender TEXT); INSERT INTO company (id,name,CEO_gender) VALUES (1,'Acme Inc','female'); INSERT INTO company (id,name,CEO_gender) VALUES (2,'Beta Corp','male'); CREATE TABLE funding_round (company_id INT,round_amount INT); INSERT INTO funding_round (company_id,round_amount) VALU...
SELECT SUM(funding_round.round_amount) FROM company JOIN funding_round ON company.id = funding_round.company_id WHERE company.CEO_gender = 'female';
What is the total revenue for each mobile plan in the past month?
CREATE TABLE mobile_plans (plan_id INT,plan_name VARCHAR(50),monthly_cost DECIMAL(5,2)); INSERT INTO mobile_plans (plan_id,plan_name,monthly_cost) VALUES (1,'Basic',30.00),(2,'Premium',50.00),(3,'Family',70.00);
SELECT plan_name, SUM(monthly_cost) as total_revenue FROM mobile_plans WHERE MONTH(current_date) = MONTH(date_sub(current_date, INTERVAL 1 MONTH)) GROUP BY plan_name;
What is the average range of electric vehicles, partitioned by manufacturer, for vehicles with a range greater than 200 miles?
CREATE TABLE ElectricVehicleStats (id INT,make VARCHAR(20),model VARCHAR(20),range INT,autonomy_level INT); INSERT INTO ElectricVehicleStats (id,make,model,range,autonomy_level) VALUES (1,'Tesla','Model S',373,5),(2,'Tesla','Model 3',263,4),(3,'Rivian','R1T',314,4),(4,'Lucid','Air',517,5),(5,'Volvo','XC40 Recharge',208...
SELECT make, AVG(range) AS avg_range FROM ElectricVehicleStats WHERE range > 200 GROUP BY make;
How many trees have been planted for each carbon offset initiative in Canada?
CREATE TABLE carbon_offsets (id INT,initiative VARCHAR(255),country VARCHAR(255),offset_type VARCHAR(255),amount INT); INSERT INTO carbon_offsets (id,initiative,country,offset_type,amount) VALUES (1,'Tree Planting','Canada','Trees',5000);
SELECT initiative, SUM(amount) as total_trees FROM carbon_offsets WHERE country = 'Canada' AND offset_type = 'Trees' GROUP BY initiative;
List the number of satellites deployed by 'SatelliteCo' each year, sorted by the number of satellites deployed in descending order?
CREATE TABLE satellites (id INT,company VARCHAR(255),year INT,quantity INT); INSERT INTO satellites (id,company,year,quantity) VALUES (1,'SatelliteCo',2010,5),(2,'SatelliteCo',2011,8),(3,'SpaceComm',2010,3),(4,'SatelliteCo',2012,6);
SELECT year, SUM(quantity) as total_deployed FROM satellites WHERE company = 'SatelliteCo' GROUP BY year ORDER BY total_deployed DESC;
What is the maximum number of goals scored in a match by a single team in the 'football_matches' table?
CREATE TABLE football_matches (match_id INT,home_team VARCHAR(50),away_team VARCHAR(50),home_team_score INT,away_team_score INT);
SELECT MAX(GREATEST(home_team_score, away_team_score)) FROM football_matches;
Delete all safety incidents that occurred before 2020.
CREATE TABLE incidents (id INT,vessel_id INT,type VARCHAR(50),date DATE); INSERT INTO incidents (id,vessel_id,type,date) VALUES (1,1,'Collision','2019-03-15'); INSERT INTO incidents (id,vessel_id,type,date) VALUES (2,1,'Grounding','2021-08-22'); INSERT INTO incidents (id,vessel_id,type,date) VALUES (3,2,'Fire','2020-02...
DELETE FROM incidents WHERE date < '2020-01-01';
Count the number of autonomous taxis in 'Toronto' and 'Montreal' that were manufactured before 2018?
CREATE TABLE if not exists Manufacturers (id int,name text); INSERT INTO Manufacturers (id,name) VALUES (1,'Tesla'),(2,'Waymo'),(3,'Uber'),(4,'NVIDIA'); CREATE TABLE if not exists Vehicles (id int,type text,manufacturer_id int,is_autonomous boolean); INSERT INTO Vehicles (id,type,manufacturer_id,is_autonomous) VALUES (...
SELECT COUNT(*) FROM Vehicles JOIN ManufacturingDates ON Vehicles.id = ManufacturingDates.vehicle_id JOIN Cities ON Vehicles.id = Cities.id WHERE is_autonomous = true AND year < 2018 AND Cities.name IN ('Toronto', 'Montreal');
List the total cost and number of projects for each type of transportation infrastructure
CREATE VIEW Transportation_Types AS SELECT project_id,project_name,project_type FROM Transportation WHERE year >= 2015; CREATE TABLE Transportation_Type_Descriptions (project_type VARCHAR(255),type_description VARCHAR(255));
SELECT project_type, SUM(cost), COUNT(*) FROM (SELECT project_id, project_name, project_type, cost FROM Transportation_Types JOIN Transportation_Costs ON Transportation_Types.project_id = Transportation_Costs.project_id) AS transportation_data JOIN Transportation_Type_Descriptions ON transportation_data.project_type = ...
Delete all records in the 'inventory' table with a 'quantity_on_hand' value less than 10
CREATE TABLE inventory (product_id INT,product_name VARCHAR(255),quantity_on_hand INT,last_updated TIMESTAMP);
DELETE FROM inventory WHERE quantity_on_hand < 10;
Find the maximum number of species found in a single marine protected area
CREATE TABLE marine_protected_areas (area_name VARCHAR(255),species_count INT); INSERT INTO marine_protected_areas (area_name,species_count) VALUES ('Galapagos Islands',500),('Great Barrier Reef',1500),('Palau National Marine Sanctuary',1000);
SELECT MAX(species_count) FROM marine_protected_areas;
Delete all records of smart contracts with a creation date before 2018-01-01 from the smart_contracts table.
CREATE TABLE smart_contracts (id INT,name VARCHAR(100),code VARCHAR(1000),creation_date DATE); INSERT INTO smart_contracts (id,name,code,creation_date) VALUES (1,'SC_123','0x123...','2017-01-01'); INSERT INTO smart_contracts (id,name,code,creation_date) VALUES (2,'OtherSC','0x456...','2018-05-05');
DELETE FROM smart_contracts WHERE creation_date < '2018-01-01';
Find the ratio of community health workers to mental health professionals in urban areas.
CREATE TABLE HealthWorkers (Location VARCHAR(20),WorkerType VARCHAR(20),Count INT); INSERT INTO HealthWorkers (Location,WorkerType,Count) VALUES ('Urban','MentalHealthProfessional',1200),('Urban','CommunityHealthWorker',800),('Rural','MentalHealthProfessional',600),('Rural','CommunityHealthWorker',400);
SELECT AVG(CommunityHealthWorkerCount / MentalHealthProfessionalCount) AS Ratio FROM (SELECT SUM(CASE WHEN Location = 'Urban' AND WorkerType = 'MentalHealthProfessional' THEN Count ELSE 0 END) AS MentalHealthProfessionalCount, SUM(CASE WHEN Location = 'Urban' AND WorkerType = 'CommunityHealthWorker' THEN Count ELSE 0 E...
What is the minimum transaction value for the 'Education' industry sector in the 'LINK' digital asset in Q1 2022?
CREATE TABLE min_transaction_values (industry_sector VARCHAR(10),asset_name VARCHAR(10),quarter INT,min_transaction_value INT); INSERT INTO min_transaction_values (industry_sector,asset_name,quarter,min_transaction_value) VALUES ('Education','BTC',1,500),('Education','BTC',2,700),('Education','BTC',3,1000),('Education'...
SELECT min_transaction_value FROM min_transaction_values WHERE industry_sector = 'Education' AND asset_name = 'LINK' AND quarter = 1;
What is the total Dysprosium production in 2019 and 2020 from all mines?
CREATE TABLE mines (id INT,name TEXT,location TEXT,dysprosium_production FLOAT,timestamp DATE); INSERT INTO mines (id,name,location,dysprosium_production,timestamp) VALUES (1,'Mine A','Canada',120.5,'2019-01-01'),(2,'Mine B','Canada',150.7,'2020-01-01'),(3,'Mine C','USA',200.3,'2019-01-01');
SELECT SUM(dysprosium_production) FROM mines WHERE YEAR(timestamp) IN (2019, 2020);
Find the IDs of products that are both moisturizing and lightweight, and are sourced from the USA or Canada.
CREATE TABLE consumer_preferences (id INT,consumer_id INT,product_id INT,preference TEXT); INSERT INTO consumer_preferences (id,consumer_id,product_id,preference) VALUES (1,1,1,'moisturizing'),(2,1,2,'lightweight'),(3,2,1,'organic'),(4,2,3,'matte finish'); CREATE TABLE ingredient_sourcing (id INT,product_id INT,country...
SELECT product_id FROM consumer_preferences WHERE preference IN ('moisturizing', 'lightweight') INTERSECT SELECT product_id FROM ingredient_sourcing WHERE country IN ('USA', 'Canada');
What is the rank of France in terms of the number of tourists visiting from Asia?
CREATE TABLE tourism (visitor_continent VARCHAR(50),host_country VARCHAR(50),number_of_tourists INT); INSERT INTO tourism (visitor_continent,host_country,number_of_tourists) VALUES ('Asia','France',500000),('Asia','Spain',400000),('Asia','Italy',450000);
SELECT host_country, RANK() OVER (ORDER BY number_of_tourists DESC) as rank FROM tourism WHERE visitor_continent = 'Asia';
How many inclusive housing units are in Seattle?
CREATE TABLE inclusive_housing (property_id INT,city VARCHAR(20),units INT); INSERT INTO inclusive_housing (property_id,city,units) VALUES (1,'Oakland',20),(2,'Berkeley',15),(3,'Seattle',10);
SELECT SUM(units) FROM inclusive_housing WHERE city = 'Seattle';
What is the total revenue for the 'business' category in Q1 of 2022?
CREATE TABLE hotel_revenue (hotel_id INT,category TEXT,revenue FLOAT,quarter INT,year INT); INSERT INTO hotel_revenue (hotel_id,category,revenue,quarter,year) VALUES (1,'business',5000,1,2022),(2,'leisure',3000,1,2022),(3,'business',7000,2,2022);
SELECT SUM(revenue) FROM hotel_revenue WHERE category = 'business' AND quarter = 1 AND year = 2022;
Show veteran unemployment rates by state
CREATE TABLE veteran_population (state TEXT,veterans INT,total_population INT); INSERT INTO veteran_population (state,veterans,total_population) VALUES ('Texas',1500000,30000000),('California',2000000,40000000),('New York',1000000,20000000),('Florida',1200000,25000000); CREATE TABLE unemployment (state TEXT,rate FLOAT)...
SELECT v.state, u.rate FROM veteran_population v INNER JOIN unemployment u ON v.state = u.state;
Update the name of Habitat1 to 'New Habitat Name' in the wildlife habitat table.
CREATE TABLE wildlife_habitat (id INT,name VARCHAR(50),area FLOAT); INSERT INTO wildlife_habitat (id,name,area) VALUES (1,'Habitat1',150.3),(2,'Habitat2',250.8),(3,'Habitat3',175.5);
UPDATE wildlife_habitat SET name = 'New Habitat Name' WHERE id = 1;
List the unique AI chatbot models used by the hotels in the hotels table and the number of hotels using each model.
CREATE TABLE hotels (hotel_id INT,name VARCHAR(50),chatbot VARCHAR(50),rating FLOAT); INSERT INTO hotels (hotel_id,name,chatbot,rating) VALUES (1,'Hotel X','Model A',4.5),(2,'Hotel Y','Model B',4.2),(3,'Hotel Z','Model A',4.7);
SELECT chatbot, COUNT(DISTINCT hotel_id) as hotels_count FROM hotels GROUP BY chatbot;
List all companies that have received funding from investors in India
CREATE TABLE investment_rounds (company_id INT,investor_country TEXT); INSERT INTO investment_rounds (company_id,investor_country) VALUES (1,'India'); INSERT INTO investment_rounds (company_id,investor_country) VALUES (2,'USA'); INSERT INTO investment_rounds (company_id,investor_country) VALUES (3,'Canada'); INSERT INT...
SELECT c.id, c.name FROM company c INNER JOIN investment_rounds ir ON c.id = ir.company_id WHERE ir.investor_country = 'India';
What is the total capacity (in MW) of installed wind energy generators in Texas and California?
CREATE TABLE wind_energy (state VARCHAR(20),generator_type VARCHAR(20),capacity FLOAT); INSERT INTO wind_energy (state,generator_type,capacity) VALUES ('Texas','Wind',2000.0),('Texas','Wind',3000.0),('California','Wind',1500.0),('California','Wind',2500.0);
SELECT SUM(capacity) FROM wind_energy WHERE state IN ('Texas', 'California') AND generator_type = 'Wind';
List of military equipment and their maintenance schedules for the Marine Corps in California?
CREATE TABLE military_equipment (equipment_id INT,equipment_name VARCHAR(100),type VARCHAR(50)); CREATE TABLE marine_corps_equipment (equipment_id INT,base_location VARCHAR(100)); CREATE TABLE equipment_maintenance (equipment_id INT,maintenance_schedule DATE); INSERT INTO military_equipment (equipment_id,equipment_name...
SELECT me.equipment_name, em.maintenance_schedule FROM military_equipment me INNER JOIN marine_corps_equipment mce ON me.equipment_id = mce.equipment_id INNER JOIN equipment_maintenance em ON me.equipment_id = em.equipment_id WHERE mce.base_location LIKE '%CA%';
List all countries involved in climate adaptation projects in Africa, excluding those with a population under 10 million.
CREATE TABLE climate_adaptation (country VARCHAR(255),population INT); INSERT INTO climate_adaptation VALUES ('Nigeria',200000000); INSERT INTO climate_adaptation VALUES ('Kenya',53000000);
SELECT country FROM climate_adaptation WHERE population >= 10000000 AND continent = 'Africa'
Show the airports in Brazil
CREATE TABLE Infrastructure (id INT,name VARCHAR(100),type VARCHAR(50),country VARCHAR(50)); INSERT INTO Infrastructure (id,name,type,country) VALUES (21,'São Paulo-Guarulhos International Airport','Airport','Brazil'),(22,'Rio de Janeiro-Galeão International Airport','Airport','Brazil');
SELECT name FROM Infrastructure WHERE type = 'Airport' AND country = 'Brazil';
What is the total budget allocated for community engagement in Pacific heritage sites?
CREATE TABLE CommunityBudget (id INT,heritage_site VARCHAR(255),budget FLOAT); INSERT INTO CommunityBudget (id,heritage_site,budget) VALUES (1,'Uluru',100000),(2,'Te Papa',150000),(3,'Sydney Opera House',200000);
SELECT SUM(budget) FROM CommunityBudget WHERE heritage_site IN (SELECT name FROM Heritagesites WHERE continent = 'Pacific');
Which gender has the lowest average ESG rating in the finance sector?
CREATE TABLE employees (id INT,gender VARCHAR(6),sector VARCHAR(255),esg_rating FLOAT); INSERT INTO employees (id,gender,sector,esg_rating) VALUES (1,'male','finance',6.5),(2,'female','finance',7.1),(3,'non-binary','technology',8.0);
SELECT gender, AVG(esg_rating) FROM employees WHERE sector = 'finance' GROUP BY gender ORDER BY AVG(esg_rating) LIMIT 1;