instruction
stringlengths
0
1.06k
input
stringlengths
11
5.3k
response
stringlengths
2
4.44k
How many unique volunteers have contributed to the education program?
CREATE TABLE Volunteers (id INT,name VARCHAR(255),contact_info VARCHAR(255)); CREATE TABLE Volunteer_Hours (id INT,volunteer_id INT,program VARCHAR(255),hours INT); INSERT INTO Volunteers (id,name,contact_info) VALUES (1,'Alice Johnson','alicejohnson@example.com'),(2,'Brian Lee','brianlee@example.com'),(3,'Carlos Alvar...
SELECT COUNT(DISTINCT volunteer_id) as num_unique_volunteers FROM Volunteer_Hours WHERE program = 'Education';
How many virtual tours have been taken for hotels in France and Germany?
CREATE TABLE hotels (hotel_id INT,hotel_name TEXT,country TEXT); CREATE TABLE virtual_tours (tour_id INT,hotel_id INT,user_id INT,timestamp TIMESTAMP);
SELECT COUNT(*) FROM virtual_tours WHERE hotels.country IN ('France', 'Germany');
What is the total number of glaciers in the Arctic region?
CREATE TABLE Glaciers (location VARCHAR(50),num_glaciers INT); INSERT INTO Glaciers (location,num_glaciers) VALUES ('Svalbard',2100); INSERT INTO Glaciers (location,num_glaciers) VALUES ('Greenland',2500); INSERT INTO Glaciers (location,num_glaciers) VALUES ('Russian Arctic',4500);
SELECT SUM(num_glaciers) FROM Glaciers;
List all unique types of 'refugee_support' projects and their locations.
CREATE TABLE refugee_support (id INT,project VARCHAR(50),location VARCHAR(50)); INSERT INTO refugee_support (id,project,location) VALUES (1,'Food Distribution','Syria'),(2,'Medical Aid','Lebanon'),(3,'Clothing Donation','Jordan');
SELECT DISTINCT project, location FROM refugee_support;
What is the minimum timeline for completing construction projects in Chicago, categorized by project type?
CREATE TABLE Project_Timelines (ProjectID INT,City VARCHAR(50),ProjectType VARCHAR(50),Timeline INT);
SELECT ProjectType, MIN(Timeline) FROM Project_Timelines WHERE City = 'Chicago' GROUP BY ProjectType;
What are military innovation projects with budgets over 10 million?
CREATE TABLE IF NOT EXISTS military_innovations (id INT PRIMARY KEY,project_name VARCHAR(255),budget INT);
SELECT * FROM military_innovations WHERE budget > 10000000;
What is the minimum, maximum, and average training time for AI models using different hardware platforms?
CREATE TABLE training_times (id INT,model_name VARCHAR(50),hardware_platform VARCHAR(50),training_time FLOAT); INSERT INTO training_times (id,model_name,hardware_platform,training_time) VALUES (1,'ModelA','GPU',2.1),(2,'ModelB','CPU',1.5),(3,'ModelC','TPU',2.9);
SELECT hardware_platform, MIN(training_time) as min_training_time, MAX(training_time) as max_training_time, AVG(training_time) as avg_training_time FROM training_times GROUP BY hardware_platform;
What is the average salary for employees in the 'employees' table, grouped by their department, for employees with an age greater than 35?
CREATE TABLE employees (id INT,first_name VARCHAR(50),last_name VARCHAR(50),job_title VARCHAR(50),department VARCHAR(50),age INT,salary DECIMAL(10,2),PRIMARY KEY (id)); INSERT INTO employees (id,first_name,last_name,job_title,department,age,salary) VALUES (1,'John','Doe','Engineer','Mining',35,80000.00),(2,'Jane','Doe'...
SELECT department, AVG(salary) FROM employees WHERE age > 35 GROUP BY department;
What is the total number of evidence-based policies implemented in each category?
CREATE TABLE policy_data (policy_name VARCHAR(255),category VARCHAR(255)); INSERT INTO policy_data VALUES ('Policy A','Category 1'),('Policy B','Category 2'),('Policy C','Category 3'),('Policy D','Category 1'),('Policy E','Category 2');
SELECT category, COUNT(DISTINCT policy_name) FROM policy_data GROUP BY category;
How many users in the 'East Coast' region have a membership type of 'Basic'?
CREATE SCHEMA fitness; CREATE TABLE memberships (id INT,member_name VARCHAR(50),region VARCHAR(50),membership_type VARCHAR(50),price DECIMAL(5,2),start_date DATE,end_date DATE); INSERT INTO memberships (id,member_name,region,membership_type,price,start_date,end_date) VALUES (1,'Jane Doe','East Coast','Basic',39.99,'202...
SELECT COUNT(*) FROM fitness.memberships WHERE region = 'East Coast' AND membership_type = 'Basic';
What is the total number of transactions and their corresponding value for the digital asset 'Aave'?
CREATE TABLE digital_assets (asset_name TEXT,total_transactions INT,total_value FLOAT); INSERT INTO digital_assets (asset_name,total_transactions,total_value) VALUES ('Avalanche',15000,2000000),('Aave',12000,3000000);
SELECT total_transactions, total_value FROM digital_assets WHERE asset_name = 'Aave';
What are the names of the students who have enrolled in 'English Composition'?
CREATE TABLE students (student_id INT,student_name TEXT); INSERT INTO students (student_id,student_name) VALUES (123,'John Doe'),(456,'Jane Smith'),(789,'Alice Johnson'); CREATE TABLE enrollments (student_id INT,course_name TEXT); INSERT INTO enrollments (student_id,course_name) VALUES (123,'Intro to Psychology'),(123,...
SELECT student_name FROM students JOIN enrollments ON students.student_id = enrollments.student_id WHERE course_name = 'English Composition';
How many accessible technology initiatives were launched in 2021?
CREATE TABLE initiatives (id INT,name TEXT,launch_year INT,is_accessible BOOLEAN); INSERT INTO initiatives (id,name,launch_year,is_accessible) VALUES (1,'InitA',2021,true),(2,'InitB',2019,false),(3,'InitC',2021,true),(4,'InitD',2020,true);
SELECT COUNT(*) FROM initiatives WHERE launch_year = 2021 AND is_accessible = true;
What is the total installed capacity of geothermal energy projects in North America, implemented before 2018?
CREATE TABLE GeothermalEnergyProjects (id INT,region VARCHAR(20),installed_capacity INT,project_start_date DATE); INSERT INTO GeothermalEnergyProjects (id,region,installed_capacity,project_start_date) VALUES (1,'North America',1000,'2015-01-01'),(2,'North America',1500,'2017-05-05'),(3,'Asia-Pacific',2000,'2019-09-09')...
SELECT SUM(installed_capacity) FROM GeothermalEnergyProjects WHERE region = 'North America' AND project_start_date < '2018-01-01';
Insert a new professional development record into the 'ProfessionalDevelopment' table
CREATE TABLE ProfessionalDevelopment (TeacherID int,Date date,ProfessionalDevelopmentScore int);
INSERT INTO ProfessionalDevelopment (TeacherID, Date, ProfessionalDevelopmentScore) VALUES (5678, '2022-10-01', 90);
Delete records from sustainability table where score is less than 5
CREATE TABLE sustainability (id INT,brand VARCHAR(50),score INT,category VARCHAR(50));
DELETE FROM sustainability WHERE score < 5;
What is the minimum installed capacity of renewable energy projects in the 'RenewableEnergyProjects' table, grouped by project_status?
CREATE TABLE RenewableEnergyProjects (id INT,project_status VARCHAR(50),installed_capacity FLOAT); INSERT INTO RenewableEnergyProjects (id,project_status,installed_capacity) VALUES (1,'Completed',1000.0),(2,'In Progress',1500.0),(3,'Completed',1200.0);
SELECT project_status, MIN(installed_capacity) FROM RenewableEnergyProjects GROUP BY project_status;
Create a table named 'VolunteerEvents'
CREATE TABLE VolunteerEvents (EventID INT,EventName VARCHAR(255),Location VARCHAR(255),EventDate DATE);
CREATE TABLE VolunteerEvents (EventID INT, EventName VARCHAR(255), Location VARCHAR(255), EventDate DATE);
Which regions published the most articles in 'regional_newspapers' table in 2020?
CREATE TABLE regional_newspapers (article_id INT,publication_date DATE,region VARCHAR(50));
SELECT region, COUNT(*) FROM regional_newspapers WHERE YEAR(publication_date) = 2020 GROUP BY region ORDER BY COUNT(*) DESC LIMIT 1;
List renewable energy projects in Canada with a budget over $100 million.
CREATE TABLE renewable_project (id INT,name VARCHAR(50),country VARCHAR(20),budget FLOAT); INSERT INTO renewable_project (id,name,country,budget) VALUES (1,'Project 1','Canada',150.0),(2,'Project 2','Canada',75.5),(3,'Project 3','Canada',120.0);
SELECT name FROM renewable_project WHERE country = 'Canada' AND budget > 100.0;
Show the number of heritage sites in each country in Asia, ordered from the most to the least, along with their respective percentage in relation to the total number of heritage sites in Asia.
CREATE TABLE UNESCO_Heritage_Sites (id INT,country VARCHAR(50),site VARCHAR(100)); INSERT INTO UNESCO_Heritage_Sites (id,country,site) VALUES (1,'China','Great Wall'),(2,'India','Taj Mahal'),(3,'Japan','Mount Fuji');
SELECT country, COUNT(site) as num_sites, ROUND(COUNT(site) * 100.0 / (SELECT COUNT(*) FROM UNESCO_Heritage_Sites WHERE country = 'Asia'), 2) as percentage FROM UNESCO_Heritage_Sites WHERE country = 'Asia' GROUP BY country ORDER BY num_sites DESC;
What is the maximum budget allocated for a 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),('Asia','Tsunami',60000),('Americas','Hurricane',80000),('Africa','Drought',40000);
SELECT d.region, MAX(d.budget) FROM disaster_budget d GROUP BY d.region;
Which artists from Asia have their artwork displayed in galleries located in New York?
CREATE TABLE Artists (ArtistID INT,Name TEXT,Nationality TEXT);CREATE TABLE Artworks (ArtworkID INT,Title TEXT,ArtistID INT);CREATE TABLE GalleryLocations (GalleryID INT,Location TEXT);CREATE TABLE GalleryArtworks (GalleryID INT,ArtworkID INT);
SELECT Artists.Name FROM Artists INNER JOIN Artworks ON Artists.ArtistID = Artworks.ArtistID INNER JOIN GalleryArtworks ON Artworks.ArtworkID = GalleryArtworks.ArtworkID INNER JOIN GalleryLocations ON GalleryArtworks.GalleryID = GalleryLocations.GalleryID WHERE Artists.Nationality = 'Asia' AND GalleryLocations.Location...
Delete all records from the "ai_ethics_training" table where the "training_date" is before 2021-01-01
CREATE TABLE ai_ethics_training (id INT PRIMARY KEY,employee_name VARCHAR(50),training_date DATE); INSERT INTO ai_ethics_training (id,employee_name,training_date) VALUES (1,'Alice Johnson','2021-02-01'); INSERT INTO ai_ethics_training (id,employee_name,training_date) VALUES (2,'Bob Williams','2020-12-15');
DELETE FROM ai_ethics_training WHERE training_date < '2021-01-01';
What is the average age of attendees who have participated in 'Art in the Park' events across all regions?
CREATE TABLE ArtInThePark (event_id INT,region VARCHAR(20),attendee_age INT); INSERT INTO ArtInThePark (event_id,region,attendee_age) VALUES (1,'Northeast',34),(2,'Southeast',45),(3,'Midwest',30);
SELECT AVG(attendee_age) FROM ArtInThePark
What is the total revenue generated from products made from recycled materials in the ethical fashion industry?
CREATE TABLE product_sales (product_id INT,material VARCHAR(50),revenue DECIMAL(10,2)); INSERT INTO product_sales (product_id,material,revenue) VALUES (1,'recycled cotton',100.00),(2,'recycled polyester',150.00),(3,'recycled cotton',200.00);
SELECT SUM(revenue) FROM product_sales WHERE material LIKE '%recycled%';
What is the average cost of satellites launched by Blue Origin?
CREATE TABLE Satellites (id INT,name VARCHAR(100),company VARCHAR(100),cost FLOAT); INSERT INTO Satellites (id,name,company,cost) VALUES (1,'New Glenn','Blue Origin',100000000); INSERT INTO Satellites (id,name,company,cost) VALUES (2,'Blue Moon','Blue Origin',50000000);
SELECT AVG(cost) FROM Satellites WHERE company = 'Blue Origin';
Delete records of Shariah-compliant loans with an amount greater than 5000 from the 'shariah_compliant_loans' table.
CREATE TABLE shariah_compliant_loans (id INT,bank VARCHAR(20),amount DECIMAL(10,2),is_shariah_compliant BOOLEAN); INSERT INTO shariah_compliant_loans (id,bank,amount,is_shariah_compliant) VALUES (1,'IslamicBank',3000.00,true),(2,'IslamicBank',6000.00,true),(3,'IslamicBank',8000.00,true);
DELETE FROM shariah_compliant_loans WHERE is_shariah_compliant = true AND amount > 5000;
What is the maximum funding received by a startup founded by a person from an underrepresented community in the technology sector?
CREATE TABLE startups(id INT,name TEXT,industry TEXT,founder_community TEXT,funding FLOAT); INSERT INTO startups (id,name,industry,founder_community,funding) VALUES (1,'TechUnderrepresented','Technology','Underrepresented',12000000);
SELECT MAX(funding) FROM startups WHERE industry = 'Technology' AND founder_community = 'Underrepresented';
How many conservation events were held in the park habitat in the first half of the year?
CREATE TABLE conservation_events (id INT,event_name VARCHAR(50),location VARCHAR(50),date DATE,attendees INT); INSERT INTO conservation_events (id,event_name,location,date,attendees) VALUES (7,'Tree Planting','Park','2022-03-20',60); INSERT INTO conservation_events (id,event_name,location,date,attendees) VALUES (8,'But...
SELECT COUNT(*) FROM conservation_events WHERE location = 'Park' AND date BETWEEN '2022-01-01' AND '2022-06-30';
Show the top 3 'Apex Legends' players with the highest kill-death ratio in the current season.
CREATE TABLE matches (id INT,game VARCHAR(10),player VARCHAR(50),kills INT,deaths INT,season VARCHAR(10),match_date DATE); INSERT INTO matches (id,game,player,kills,deaths,season,match_date) VALUES (1,'Apex Legends','Mia',20,5,'Season 1','2022-06-15');
SELECT player, AVG(kills / NULLIF(deaths, 0)) AS kill_death_ratio FROM matches WHERE game = 'Apex Legends' AND season = (SELECT season FROM matches WHERE match_date = (SELECT MAX(match_date) FROM matches WHERE game = 'Apex Legends')) GROUP BY player ORDER BY kill_death_ratio DESC, player DESC LIMIT 3;
What is the number of patients who have not started treatment for each condition by region?
CREATE TABLE TreatmentRegions (TreatmentID int,ConditionID int,Region varchar(50)); INSERT INTO TreatmentRegions (TreatmentID,ConditionID,Region) VALUES (1,1,'Northeast'),(2,1,'South'),(3,2,'Northeast'),(4,3,'South');
SELECT TreatmentRegions.ConditionID, TreatmentRegions.Region, COUNT(TreatmentRegions.TreatmentID) FROM TreatmentRegions LEFT JOIN TreatmentOutcomes ON TreatmentRegions.TreatmentID = TreatmentOutcomes.TreatmentID WHERE TreatmentOutcomes.Completed IS NULL GROUP BY TreatmentRegions.ConditionID, TreatmentRegions.Region;
Which city received the highest budget allocation for education in 2021?
CREATE TABLE CityBudget (CityName VARCHAR(50),Service VARCHAR(50),Allocation INT,Year INT); INSERT INTO CityBudget (CityName,Service,Allocation,Year) VALUES ('CityA','Healthcare',1050000,2021),('CityA','Education',850000,2021),('CityB','Healthcare',1250000,2021),('CityB','Education',950000,2021),('CityC','Healthcare',1...
SELECT CityName, MAX(Allocation) FROM CityBudget WHERE Service = 'Education' AND Year = 2021 GROUP BY CityName;
What is the maximum number of train maintenance incidents reported in Tokyo in a single day in the past year?
CREATE TABLE tokyo_train_maintenance (incident_id INT,incident_date DATE);
SELECT DATE_FORMAT(incident_date, '%Y-%m-%d') AS date, COUNT(*) AS num_incidents FROM tokyo_train_maintenance WHERE incident_date >= DATE_SUB(NOW(), INTERVAL 1 YEAR) GROUP BY date ORDER BY num_incidents DESC LIMIT 1;
What is the average age of visitors who attended theater performances in Chicago last year?
CREATE TABLE Events (event_name TEXT,city TEXT,year INT); INSERT INTO Events (event_name,city,year) VALUES ('Theater Performance','Chicago',2021); CREATE TABLE Visitors (visitor_id INT,event_name TEXT,age INT); INSERT INTO Visitors (visitor_id,event_name,age) VALUES (1,'Theater Performance',30),(2,'Theater Performance'...
SELECT AVG(age) FROM Visitors v INNER JOIN Events e ON v.event_name = e.event_name WHERE city = 'Chicago' AND year = 2021 AND event_name = 'Theater Performance';
How many solar panels were installed in Germany between 2010 and 2015?
CREATE TABLE solar_panels (id INT,installation_year INT,panel_type VARCHAR(20)); INSERT INTO solar_panels (id,installation_year,panel_type) VALUES (1,2008,'monocrystalline'),(2,2011,'polycrystalline'),(3,2013,'thin-film'),(4,2016,'bifacial'); CREATE TABLE installations (id INT,solar_panel_id INT,country VARCHAR(50)); I...
SELECT COUNT(*) FROM solar_panels JOIN installations ON solar_panels.id = installations.solar_panel_id WHERE installations.country = 'Germany' AND solar_panels.installation_year BETWEEN 2010 AND 2015;
Who are the top 5 blockchain developers who have contributed the most code to the development of decentralized applications in the Ethereum blockchain, and what is their total number of contributions?
CREATE TABLE IF NOT EXISTS blockchain_developers (developer_id INT PRIMARY KEY,name VARCHAR(100),gender VARCHAR(10),age INT,country VARCHAR(100),language VARCHAR(50),blockchain VARCHAR(50),contributions INT); CREATE TABLE IF NOT EXISTS decentralized_application_code (code_id INT PRIMARY KEY,developer_id INT,FOREIGN KEY...
SELECT bd.name, SUM(bd.contributions) FROM blockchain_developers bd JOIN decentralized_application_code dac ON bd.developer_id = dac.developer_id WHERE bd.blockchain = 'Ethereum' GROUP BY bd.name ORDER BY SUM(bd.contributions) DESC LIMIT 5;
What is the total billing amount for cases in the 'First' quarter?
CREATE TABLE CaseDates (CaseID INT,Date DATE); INSERT INTO CaseDates (CaseID,Date) VALUES (1,'2021-01-01'),(2,'2021-02-01'),(3,'2021-03-01'),(4,'2021-04-01'),(5,'2021-05-01');
SELECT SUM(BillingAmount) FROM CaseBilling INNER JOIN CaseDates ON CaseBilling.CaseID = CaseDates.CaseID WHERE MONTH(Date) BETWEEN 1 AND 3;
Find the top 3 cities with the most events in Germany.
CREATE TABLE Events (id INT,city VARCHAR(20),country VARCHAR(20)); INSERT INTO Events (id,city,country) VALUES (1,'Berlin','Germany'),(2,'Munich','Germany'),(3,'Frankfurt','Germany');
SELECT city, COUNT(*) as event_count FROM Events WHERE country = 'Germany' GROUP BY city ORDER BY event_count DESC LIMIT 3;
Which crops were planted in 'Toronto' and their yields?
CREATE TABLE crops (id INT PRIMARY KEY,name VARCHAR(50),yield INT,year INT,farmer_id INT,FOREIGN KEY (farmer_id) REFERENCES farmers(id)); INSERT INTO crops (id,name,yield,year,farmer_id) VALUES (2,'Soybeans',150,2021,2);
SELECT c.name, c.yield FROM crops c JOIN farmers f ON c.farmer_id = f.id WHERE f.location = 'Toronto';
What was the total attendance for events with free admission in H1 2022?
CREATE TABLE EventAttendance (event_id INT,attendance INT,free_admission BOOLEAN); INSERT INTO EventAttendance (event_id,attendance,free_admission) VALUES (1,100,true),(2,150,false),(3,200,true),(4,250,false),(5,300,true),(6,350,false),(7,400,true),(8,450,false);
SELECT SUM(attendance) AS total_attendance FROM EventAttendance WHERE free_admission = true AND event_id IN (SELECT event_id FROM Events WHERE event_date BETWEEN '2022-01-01' AND '2022-06-30');
How many workers in the electronics industry are part of ethical manufacturing initiatives?
CREATE TABLE electronics_workers (id INT,name VARCHAR(50),industry VARCHAR(50),ethical_manufacturing VARCHAR(50)); INSERT INTO electronics_workers (id,name,industry,ethical_manufacturing) VALUES (1,'Alice Johnson','Electronics','Fair Trade'); INSERT INTO electronics_workers (id,name,industry,ethical_manufacturing) VALU...
SELECT COUNT(*) FROM electronics_workers WHERE industry = 'Electronics' AND ethical_manufacturing IS NOT NULL;
How many matches were won by teams from Asia in the FIFA World Cup, by year?
CREATE TABLE matches (match_id INT,year INT,home_team VARCHAR(255),away_team VARCHAR(255),home_team_score INT,away_team_score INT);CREATE TABLE teams (team_id INT,team_name VARCHAR(255),continent VARCHAR(255));
SELECT m.year, COUNT(*) as asian_wins FROM matches m JOIN teams t ON (m.home_team = t.team_name OR m.away_team = t.team_name) WHERE t.continent = 'Asia' AND (m.home_team_score > m.away_team_score OR m.home_team_score = m.away_team_score AND m.home_team = t.team_name) GROUP BY m.year;
How many defense contract negotiations occurred in Q3 and Q4 2021?
CREATE TABLE ContractNegotiations (negotiation_date DATE,parties TEXT); INSERT INTO ContractNegotiations (negotiation_date,parties) VALUES ('2021-07-01','PQR Corp - Military'),('2021-11-15','STU Inc - Government'),('2021-09-20','VWX Ltd - Defense Agency');
SELECT COUNT(*) FROM ContractNegotiations WHERE negotiation_date BETWEEN '2021-07-01' AND '2021-12-31';
Get records on workforce diversity initiatives in the automotive sector
CREATE TABLE diversity_initiatives (id INT PRIMARY KEY,name VARCHAR(255),sector VARCHAR(255),diversity_score DECIMAL(3,2)); INSERT INTO diversity_initiatives (id,name,sector,diversity_score) VALUES (8,'Automotive Diversity Network','Automotive',4.5);
SELECT * FROM diversity_initiatives WHERE sector = 'Automotive';
List the number of unique donors who have donated to at least two different programs in the last year.
CREATE TABLE Donors (DonorID INT,DonorName TEXT,Program TEXT,DonationDate DATE); INSERT INTO Donors (DonorID,DonorName,Program,DonationDate) VALUES (1,'John Doe','Education','2021-12-25'),(2,'Jane Smith','Healthcare','2022-01-05'),(3,'John Doe','Environment','2022-02-14');
SELECT COUNT(DISTINCT DonorID) FROM (SELECT DonorID, Program FROM Donors WHERE DonationDate >= DATEADD(year, -1, GETDATE()) GROUP BY DonorID, Program HAVING COUNT(DISTINCT Program) > 1);
Find the agricultural innovation metrics for farmers in the specified provinces.
CREATE TABLE Farmers (farmer_id INT,province VARCHAR(50),innovation_score INT);CREATE TABLE Provinces (province_id INT,name VARCHAR(50));INSERT INTO Farmers (farmer_id,province,innovation_score) VALUES (1,'Province A',75),(2,'Province B',85),(3,'Province C',90),(4,'Province A',70),(5,'Province B',80);INSERT INTO Provin...
SELECT Farmers.province, AVG(Farmers.innovation_score) FROM Farmers WHERE Farmers.province IN ('Province A', 'Province B') GROUP BY Farmers.province;
Count of drugs approved in 2020
CREATE TABLE drug_approval (approval_id INT,drug_name TEXT,approval_date DATE); INSERT INTO drug_approval (approval_id,drug_name,approval_date) VALUES (1,'DrugM','2020-01-01'),(2,'DrugN','2019-01-01');
SELECT COUNT(*) FROM drug_approval WHERE YEAR(approval_date) = 2020;
How many hotels have adopted cloud-based systems in 'EMEA' region?
CREATE TABLE hotel_tech_adoption (hotel_id INT,hotel_name TEXT,region TEXT,cloud_adoption BOOLEAN); INSERT INTO hotel_tech_adoption (hotel_id,hotel_name,region,cloud_adoption) VALUES (1,'Hotel A','EMEA',true),(2,'Hotel B','EMEA',true),(3,'Hotel C','APAC',false),(4,'Hotel D','APAC',true);
SELECT COUNT(*) FROM hotel_tech_adoption WHERE region = 'EMEA' AND cloud_adoption = true;
Calculate the average age of artists in the 'ArtistsDemographics' table, partitioned by gender.
CREATE TABLE ArtistsDemographics (ArtistID INT,Age INT,Gender VARCHAR(10),Nationality VARCHAR(50)); INSERT INTO ArtistsDemographics (ArtistID,Age,Gender,Nationality) VALUES (1,45,'Male','American'),(2,34,'Female','Canadian'),(3,50,'Male','British'),(4,35,'Female','Mexican'),(5,40,'Non-binary','Australian');
SELECT Gender, AVG(Age) AS AvgAge FROM ArtistsDemographics GROUP BY Gender;
What is the timber volume harvested in 'Central American Forests' in 2019?
CREATE TABLE CentralAmericanForests (region VARCHAR(20),year INT,timber_volume FLOAT); INSERT INTO CentralAmericanForests (region,year,timber_volume) VALUES ('Central American Forests',2015,123.45),('Central American Forests',2016,234.56),('Central American Forests',2017,345.67),('Central American Forests',2018,456.78)...
SELECT timber_volume FROM CentralAmericanForests WHERE region = 'Central American Forests' AND year = 2019;
What is the most common disease prevalence in rural areas of Mississippi?
CREATE TABLE disease_prevalence (disease_id INT,name VARCHAR(50),location VARCHAR(20),prevalence INT); INSERT INTO disease_prevalence (disease_id,name,location,prevalence) VALUES (1,'Diabetes','Rural Mississippi',1200); INSERT INTO disease_prevalence (disease_id,name,location,prevalence) VALUES (2,'Heart Disease','Rura...
SELECT name, MAX(prevalence) FROM disease_prevalence WHERE location = 'Rural Mississippi' GROUP BY name;
What is the maximum budget for policy advocacy in "West Coast" region in 2019?
CREATE TABLE Policy_Advocacy (advocacy_id INT,region VARCHAR(20),budget DECIMAL(10,2),year INT); INSERT INTO Policy_Advocacy (advocacy_id,region,budget,year) VALUES (1,'Southeast',5000,2020),(2,'Northwest',6000,2019),(3,'East Coast',7000,2020),(4,'East Coast',6000,2019),(5,'Northeast',8000,2019),(6,'Northeast',9000,201...
SELECT MAX(budget) FROM Policy_Advocacy WHERE region = 'West Coast' AND year = 2019;
What is the number of cybersecurity incidents per country in the last quarter?
CREATE TABLE country (id INT,name VARCHAR(255)); INSERT INTO country (id,name) VALUES (1,'USA'),(2,'Canada'),(3,'Mexico'); CREATE TABLE incident (id INT,country_id INT,timestamp TIMESTAMP); INSERT INTO incident (id,country_id) VALUES (1,1),(2,1),(3,2),(4,3),(5,1);
SELECT c.name, COUNT(i.id) as num_incidents FROM incident i JOIN country c ON i.country_id = c.id WHERE i.timestamp >= DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 3 MONTH) GROUP BY c.name;
What is the total billing amount for cases handled by attorneys who have been with their law firm for less than 3 years and have a win rate of at least 50%?
CREATE TABLE attorneys (attorney_id INT,name VARCHAR(50),law_firm VARCHAR(50),joined_date DATE,win_rate DECIMAL(5,2)); INSERT INTO attorneys (attorney_id,name,law_firm,joined_date,win_rate) VALUES (1,'Mohammad Khan','Khan & Associates','2020-01-01',0.75),(2,'Sophia Kim','Smith & Lee','2018-06-15',0.55),(3,'Carlos Rodri...
SELECT SUM(billing_amount) FROM cases JOIN attorneys ON cases.attorney_id = attorneys.attorney_id WHERE attorneys.joined_date > DATE_SUB(CURDATE(), INTERVAL 3 YEAR) AND attorneys.win_rate >= 0.5;
List unique chemical types used in the top 3 facilities by production volume.
CREATE TABLE facility_production (name VARCHAR(50),product VARCHAR(20),quantity INT); INSERT INTO facility_production VALUES ('facility A','chemical A',350); INSERT INTO facility_production VALUES ('facility B','chemical B',400);
SELECT DISTINCT product FROM (SELECT facility, product, ROW_NUMBER() OVER (PARTITION BY facility ORDER BY quantity DESC) AS rn FROM facility_production) tmp WHERE rn <= 3;
Calculate the total donation amount for each category, pivoted to display categories as columns
CREATE TABLE donations (donation_id INT,donation_amount DECIMAL(10,2),donation_category VARCHAR(255)); INSERT INTO donations (donation_id,donation_amount,donation_category) VALUES (1,50.00,'Food'),(2,100.00,'Clothing'),(3,250.00,'Education'),(4,300.00,'Food'),(5,800.00,'Health');
SELECT SUM(CASE WHEN donation_category = 'Food' THEN donation_amount ELSE 0 END) as food, SUM(CASE WHEN donation_category = 'Clothing' THEN donation_amount ELSE 0 END) as clothing, SUM(CASE WHEN donation_category = 'Education' THEN donation_amount ELSE 0 END) as education, SUM(CASE WHEN donation_category = 'Health' THE...
What is the average monthly revenue generated from mobile and broadband services in each state?
CREATE TABLE states (state_id INT,state_name VARCHAR(20)); INSERT INTO states (state_id,state_name) VALUES (1,'New York'),(2,'California'),(3,'Texas'); CREATE TABLE mobile_revenue (state_id INT,monthly_revenue DECIMAL(10,2)); INSERT INTO mobile_revenue (state_id,monthly_revenue) VALUES (1,50000.00),(2,75000.00),(3,6000...
SELECT s.state_name, AVG(m.monthly_revenue + b.monthly_revenue) as avg_monthly_revenue FROM states s JOIN mobile_revenue m ON s.state_id = m.state_id JOIN broadband_revenue b ON s.state_id = b.state_id GROUP BY s.state_name;
Rank the top 2 countries with the highest local economic impact?
CREATE TABLE local_economic (economic_id INT,country TEXT,impact FLOAT); INSERT INTO local_economic (economic_id,country,impact) VALUES (1,'Japan',2000),(2,'Germany',1500),(3,'Brazil',1000);
SELECT country, RANK() OVER (ORDER BY impact DESC) as rank FROM local_economic WHERE rank <= 2;
Who are the top 3 community police officers with the highest number of traffic stops?
CREATE TABLE police_officers (officer_id INT,name VARCHAR(255),rank VARCHAR(255)); INSERT INTO police_officers (officer_id,name,rank) VALUES (1,'John Doe','Sergeant'),(2,'Jane Smith','Officer'),(3,'Mike Johnson','Lieutenant'); CREATE TABLE traffic_stops (stop_id INT,officer_id INT,date DATE); INSERT INTO traffic_stops ...
SELECT officer_id, name, COUNT(*) as total_stops FROM traffic_stops ts JOIN police_officers po ON ts.officer_id = po.officer_id GROUP BY officer_id, name ORDER BY total_stops DESC LIMIT 3;
What is the average revenue generated per day?
CREATE TABLE daily_revenue (date date,revenue int); INSERT INTO daily_revenue (date,revenue) VALUES ('2022-01-01',10000),('2022-01-02',12000),('2022-01-03',11000);
SELECT AVG(revenue) FROM daily_revenue;
Insert new records of AI-related patents filed in 2021.
CREATE TABLE patents (id INT,inventor_id INT,patent_year INT,ai_related BOOLEAN);
INSERT INTO patents (id, inventor_id, patent_year, ai_related) SELECT p.next_id, i.id, 2021, true FROM (SELECT ROW_NUMBER() OVER (ORDER BY name) AS next_id, id FROM inventors i WHERE i.ai_contributions = true) p WHERE p.next_id <= 10;
Show the top 2 most frequently cited research papers 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),(4,'Neural Networks in AVs',130),(5,'Computer Vision fo...
SELECT title, citations FROM (SELECT title, citations, RANK() OVER (ORDER BY citations DESC) rank FROM research_papers) sq WHERE rank <= 2;
How many droughts have been reported in India in the last 5 years?
CREATE TABLE droughts (drought_id INT,location VARCHAR(255),start_date DATE,end_date DATE); INSERT INTO droughts (drought_id,location,start_date,end_date) VALUES (1,'Australia','2010-01-01','2010-12-31'),(2,'California','2011-01-01','2011-12-31'),(3,'Texas','2012-01-01','2012-12-31'),(4,'India','2016-01-01','2016-12-31...
SELECT COUNT(*) FROM droughts WHERE location = 'India' AND start_date >= '2016-01-01';
What are the total expenses for each team in the NBA, considering the 'team_expenses' table?
CREATE TABLE team_expenses (team_id INT,league VARCHAR(50),total_expenses DECIMAL(10,2));
SELECT b.team_name, SUM(e.total_expenses) AS total_expenses FROM sports_teams b INNER JOIN team_expenses e ON b.team_id = e.team_id WHERE b.league = 'NBA' GROUP BY b.team_name;
Number of modern art exhibitions held in New York since 2000 with more than 500 visitors?
CREATE TABLE Exhibitions (id INT,exhibition_name VARCHAR(50),location VARCHAR(30),visitors INT,art_period VARCHAR(20),start_date DATE); INSERT INTO Exhibitions (id,exhibition_name,location,visitors,art_period,start_date) VALUES (1,'Exhibition1','New York',600,'Modern','2005-01-01');
SELECT COUNT(*) FROM Exhibitions WHERE location = 'New York' AND art_period = 'Modern' AND visitors > 500 AND start_date >= '2000-01-01';
What is the average nitrogen level in soils of urban farms in New York?
CREATE TABLE urban_farms (id INT PRIMARY KEY,name VARCHAR(100),nitrogen FLOAT,potassium FLOAT,farm_id INT,FOREIGN KEY (farm_id) REFERENCES farmers(id)); INSERT INTO urban_farms (id,name,nitrogen,potassium,farm_id) VALUES (1,'Brooklyn Grange',0.35,0.55,1),(2,'Eagle Street Rooftop Farm',0.40,0.60,2),(3,'Gotham Greens',0....
SELECT AVG(u.nitrogen) FROM urban_farms u WHERE u.farm_id IN (SELECT f.id FROM farmers f WHERE f.location = 'New York');
What is the percentage of students in 'New York City' public schools who are English language learners?
CREATE TABLE student_data (city VARCHAR(255),school_type VARCHAR(255),enrollment INT,ell_enrollment INT); INSERT INTO student_data (city,school_type,enrollment,ell_enrollment) VALUES ('New York City','Public',1200000,150000);
SELECT (ell_enrollment * 100.0 / enrollment) AS percentage FROM student_data WHERE city = 'New York City' AND school_type = 'Public';
List the number of building permits issued in the industrial sector each year.
CREATE TABLE building_permits (permit_id INT,sector VARCHAR(50),year INT); INSERT INTO building_permits (permit_id,sector,year) VALUES (1,'Industrial',2018),(2,'Residential',2018),(3,'Industrial',2019),(4,'Commercial',2019),(5,'Industrial',2020);
SELECT year, COUNT(permit_id) FROM building_permits WHERE sector = 'Industrial' GROUP BY year;
What is the maximum wave height recorded in the North Sea?
CREATE TABLE wave_heights (id INT,sea TEXT,max_wave_height FLOAT); INSERT INTO wave_heights (id,sea,max_wave_height) VALUES (1,'North Sea',30.0),(2,'Southern Ocean',15.0);
SELECT MAX(max_wave_height) FROM wave_heights WHERE sea = 'North Sea';
What's the total revenue of Marvel movies released in 2019?
CREATE TABLE movies (id INT,title VARCHAR(255),release_year INT,production_budget INT,revenue INT); INSERT INTO movies (id,title,release_year,production_budget,revenue) VALUES (1,'Avengers: Endgame',2019,356000000,27978000000),(2,'Captain Marvel',2019,153000000,11285000000);
SELECT SUM(revenue) FROM movies WHERE release_year = 2019 AND title IN ('Avengers: Endgame', 'Captain Marvel');
List all microfinance loans provided by the Grameen Bank with their corresponding repayment periods.
CREATE TABLE microfinance_loans (bank VARCHAR(50),product VARCHAR(50),repayment_period INT); INSERT INTO microfinance_loans (bank,product,repayment_period) VALUES ('Grameen Bank','Microenterprise Loan',12),('Grameen Bank','Education Loan',24),('Grameen Bank','Housing Loan',36);
SELECT bank, product, repayment_period FROM microfinance_loans WHERE bank = 'Grameen Bank';
How many Carbon Pricing schemes are there in the EU?
CREATE TABLE CarbonPricing (SchemeID INT,Name VARCHAR(255),Country VARCHAR(255),StartDate DATE);
SELECT COUNT(*) FROM CarbonPricing WHERE Country = 'European Union';
How many solar energy projects were completed in the Asia-Pacific region in the last 5 years, with a capacity greater than 10 MW?
CREATE TABLE solar_energy (project_id INT,project_name VARCHAR(255),region VARCHAR(255),completion_date DATE,installed_capacity FLOAT);
SELECT COUNT(*) FROM solar_energy WHERE region = 'Asia-Pacific' AND completion_date >= DATE_SUB(CURRENT_DATE, INTERVAL 5 YEAR) AND installed_capacity > 10000000;
What is the average dissolved oxygen level in each farming system?
CREATE TABLE FarmingSystems (FarmingSystemID INT,FarmingSystemName VARCHAR(50),AvgDO DECIMAL(4,2)); INSERT INTO FarmingSystems VALUES (1,'Pond Systems',6.5),(2,'Cage Systems',7.2),(3,'Recirculating Systems',8.1);
SELECT FarmingSystemName, AvgDO FROM FarmingSystems;
What is the total number of games played by each team in the 'soccer_teams' table?
CREATE TABLE soccer_teams (team_id INT,team_name VARCHAR(100),num_games INT);
SELECT team_id, SUM(num_games) FROM soccer_teams GROUP BY team_id;
Who has attended the most 'Pilates' classes?
CREATE TABLE Attendance (AttendanceID INT,MemberID INT,ClassID INT); INSERT INTO Attendance (AttendanceID,MemberID,ClassID) VALUES (1,1,2),(2,2,2),(3,3,3); CREATE TABLE Members (MemberID INT,Name VARCHAR(20)); INSERT INTO Members (MemberID,Name) VALUES (1,'Alice'),(2,'Bob'),(3,'Carol');
SELECT Name, COUNT(*) FROM Attendance JOIN Members ON Attendance.MemberID = Members.MemberID JOIN Classes ON Attendance.ClassID = Classes.ClassID WHERE Classes.ClassType = 'Pilates' GROUP BY Name ORDER BY COUNT(*) DESC LIMIT 1;
How many research vessels are registered in the Mediterranean Sea?
CREATE TABLE research_vessels (id INT,name TEXT,registry TEXT); INSERT INTO research_vessels (id,name,registry) VALUES (1,'Oceanus','Mediterranean'),(2,'Nautilus','Caribbean');
SELECT COUNT(*) FROM research_vessels WHERE registry = 'Mediterranean';
What are the top three countries with the highest climate finance investments?
CREATE TABLE climate_finance_investments (id INT,country VARCHAR(50),investment FLOAT); INSERT INTO climate_finance_investments (id,country,investment) VALUES (1,'Brazil',12000000),(2,'India',15000000),(3,'South Africa',10000000);
SELECT country, investment FROM climate_finance_investments ORDER BY investment DESC LIMIT 3;
What is the average bioprocess engineering project budget?
CREATE TABLE projects (name TEXT,budget FLOAT); INSERT INTO projects (name,budget) VALUES ('ProjectA',4000000),('ProjectB',5000000),('ProjectC',6000000);
SELECT AVG(budget) FROM projects;
List the names and treatments of patients from California.
CREATE TABLE patients (id INT,name TEXT,age INT,treatment TEXT,state TEXT); INSERT INTO patients (id,name,age,treatment,state) VALUES (1,'John Doe',35,'CBT','CA'),(2,'Jane Smith',40,'DBT','NY');
SELECT name, treatment FROM patients WHERE state = 'CA';
How many AI safety incidents were reported in the 'autonomous vehicles' application area in 2022?
CREATE TABLE ai_safety_incidents (incident_id INT,incident_year INT,ai_application_area VARCHAR(50));
SELECT COUNT(*) FROM ai_safety_incidents WHERE ai_application_area = 'autonomous vehicles' AND incident_year = 2022;
What are the top 3 game genres with the highest sales?
CREATE TABLE GameSales (GameID INT,GameType VARCHAR(10),Sales INT); INSERT INTO GameSales (GameID,GameType,Sales) VALUES (1,'RPG',50000),(2,'FPS',70000),(3,'RPG',60000),(4,'Simulation',80000);
SELECT GameType, AVG(Sales) FROM GameSales GROUP BY GameType ORDER BY AVG(Sales) DESC LIMIT 3;
Show the total area of marine protected areas in the Atlantic region, excluding the Sargasso Sea.
CREATE TABLE marine_protected_areas (id INT,name VARCHAR(50),size FLOAT,region VARCHAR(20)); INSERT INTO marine_protected_areas (id,name,size,region) VALUES (1,'Sargasso Sea',6000000,'Atlantic'); INSERT INTO marine_protected_areas (id,name,size,region) VALUES (2,'Bermuda Rise',300000,'Atlantic');
SELECT SUM(size) FROM marine_protected_areas WHERE region = 'Atlantic' AND name != 'Sargasso Sea';
What was the total budget allocated to environmental services in 2019 and 2020, and which year had a lower allocation?
CREATE TABLE BudgetAllocations (Year INT,Service TEXT,Amount INT); INSERT INTO BudgetAllocations (Year,Service,Amount) VALUES (2019,'EnvironmentalServices',9000000),(2020,'EnvironmentalServices',8000000);
SELECT Year, SUM(Amount) FROM BudgetAllocations WHERE Service = 'EnvironmentalServices' GROUP BY Year HAVING Year IN (2019, 2020) ORDER BY SUM(Amount) LIMIT 1;
How many artworks were created each year in the 19th century?
CREATE TABLE ArtWorks (ArtworkID int,Title varchar(100),YearCreated int);
SELECT YearCreated, COUNT(ArtworkID) FROM ArtWorks
What is the total cost of all rural infrastructure projects, ordered by the project cost in ascending order?
CREATE TABLE rural_infrastructure_projects (id INT,project_name VARCHAR(255),location VARCHAR(255),sector VARCHAR(255),cost FLOAT); INSERT INTO rural_infrastructure_projects (id,project_name,location,sector,cost) VALUES (1,'Water Supply System','Village A','Infrastructure',50000.00),(2,'Electricity Grid Expansion','Vil...
SELECT SUM(cost) as total_cost FROM rural_infrastructure_projects ORDER BY total_cost ASC;
Delete all records from the "audience_demographics" table where the "age" is less than 18
CREATE TABLE audience_demographics (id INT PRIMARY KEY,age INT,country VARCHAR(255),gender VARCHAR(255));
DELETE FROM audience_demographics WHERE age < 18;
What is the maximum level of ocean acidification in the Southern Ocean?
CREATE TABLE ocean_acidification (id INT,location TEXT,level FLOAT); INSERT INTO ocean_acidification (id,location,level) VALUES (1,'Indian Ocean',8.2),(2,'Atlantic Ocean',8.1),(3,'Southern Ocean',8.4);
SELECT MAX(level) FROM ocean_acidification WHERE location = 'Southern Ocean';
Which vessels were involved in an accident in the South China Sea in 2018?
CREATE TABLE incident_reports (id INT PRIMARY KEY,incident_type VARCHAR(50),latitude DECIMAL(10,8),longitude DECIMAL(11,8),timestamp TIMESTAMP); CREATE TABLE vessels_extended (id INT PRIMARY KEY,vessel_name VARCHAR(50),previous_vessel_id INT,FOREIGN KEY (previous_vessel_id) REFERENCES vessels_extended(id));
SELECT DISTINCT vessels_extended.vessel_name FROM incident_reports INNER JOIN vessels_extended ON vessels_extended.id = (incident_reports.id + 1 OR incident_reports.id - 1) WHERE incident_type = 'accident' AND latitude BETWEEN 1.5 AND 22.5 AND longitude BETWEEN 99.5 AND 122.5 AND YEAR(timestamp) = 2018;
What is the minimum salary for workers in the 'textile' department at factory 1?
CREATE TABLE factories (factory_id INT,department VARCHAR(20));CREATE TABLE workers (worker_id INT,factory_id INT,salary DECIMAL(5,2),department VARCHAR(20)); INSERT INTO factories (factory_id,department) VALUES (1,'textile'),(2,'metal'),(3,'electronics'); INSERT INTO workers (worker_id,factory_id,salary,department) VA...
SELECT MIN(w.salary) FROM workers w JOIN factories f ON w.factory_id = f.factory_id WHERE f.department = 'textile' AND w.factory_id = 1;
What is the total revenue for each game genre in the gaming industry?
CREATE TABLE Games (GameID INT,GameGenre VARCHAR(10),Revenue INT); INSERT INTO Games (GameID,GameGenre,Revenue) VALUES (1,'Action',1000000),(2,'RPG',2000000),(3,'Strategy',1500000);
SELECT GameGenre, SUM(Revenue) as TotalRevenue FROM Games GROUP BY GameGenre;
What is the most common type of workplace safety incident in each state?
CREATE TABLE safety_reports (report_id INT,state VARCHAR(2),incident_type VARCHAR(15)); INSERT INTO safety_reports (report_id,state,incident_type) VALUES (1,'NY','Fall'),(2,'CA','Electrocution'),(3,'IL','Fall');
SELECT state, MAX(incident_type) as most_common_incident FROM safety_reports GROUP BY state;
List the names and locations of all seaports in Washington
CREATE TABLE Infrastructure (id INT,name VARCHAR(100),type VARCHAR(50),location VARCHAR(100),state VARCHAR(50)); INSERT INTO Infrastructure (id,name,type,location,state) VALUES (8,'Port of Seattle','Seaport','Seattle','Washington');
SELECT name, location FROM Infrastructure WHERE type = 'Seaport' AND state = 'Washington';
Delete biosensor technology patents filed before 2015
CREATE TABLE biosensor_technology_patents (patent_id INT,patent_name VARCHAR(255),patent_filing_date DATE);
DELETE FROM biosensor_technology_patents WHERE patent_filing_date < '2015-01-01';
What is the weight (in kg) of the heaviest spacecraft ever built?
CREATE TABLE spacecraft(id INT,name VARCHAR(255),weight_kg FLOAT); INSERT INTO spacecraft(id,name,weight_kg) VALUES (1,'Saturn V',303540.0),(2,'Space Shuttle',110000.0);
SELECT MAX(weight_kg) FROM spacecraft;
What is the total CO2 emission from all aquaculture farms in the year 2021?
CREATE TABLE co2_emission (farm_id INT,year INT,co2_emission INT); INSERT INTO co2_emission VALUES (1,2022,100),(2,2021,120),(3,2022,150),(4,2021,180);
SELECT SUM(co2_emission) FROM co2_emission WHERE year = 2021;
What is the minimum number of employees in each department in the 'Human Services' agency?
CREATE SCHEMA Government;CREATE TABLE Government.Agency (name VARCHAR(255),budget INT);CREATE TABLE Government.Department (name VARCHAR(255),agency VARCHAR(255),employees INT,budget INT);
SELECT agency, MIN(employees) FROM Government.Department WHERE agency IN (SELECT name FROM Government.Agency WHERE budget > 5000000) GROUP BY agency;
What is the average time it takes for agricultural innovation projects to be implemented, from start to finish, and how does it vary by country?
CREATE TABLE projects (id INT,name VARCHAR(50),country VARCHAR(50),start_date DATE,end_date DATE);
SELECT country, AVG(DATEDIFF(end_date, start_date)) as avg_duration FROM projects GROUP BY country;
What is the industry with the highest total funding?
CREATE TABLE funding (id INT,company_id INT,amount DECIMAL(10,2)); CREATE TABLE company (id INT,name VARCHAR(255),industry VARCHAR(255)); INSERT INTO company (id,name,industry) VALUES (1,'Fintech Inc','finance'),(2,'Startup Corp','tech'),(3,'Green Inc','green'); INSERT INTO funding (id,company_id,amount) VALUES (1,1,50...
SELECT industry, SUM(amount) AS total_funding FROM funding INNER JOIN company ON funding.company_id = company.id GROUP BY industry ORDER BY total_funding DESC LIMIT 1;