instruction stringlengths 0 1.06k | input stringlengths 11 5.3k | response stringlengths 2 4.44k |
|---|---|---|
What is the average mental health score of students in each school? | CREATE TABLE schools (school_id INT,school_name VARCHAR(255)); INSERT INTO schools (school_id,school_name) VALUES (1,'School A'),(2,'School B'); CREATE TABLE students (student_id INT,school_id INT,mental_health_score INT); INSERT INTO students (student_id,school_id,mental_health_score) VALUES (1,1,80),(2,1,85),(3,2,70),(4,2,75); | SELECT s.school_name, AVG(st.mental_health_score) as avg_mental_health_score FROM students st JOIN schools s ON st.school_id = s.school_id GROUP BY s.school_name; |
How many renewable energy sources are there in each country, listed in the 'renewable_energy' table? | CREATE TABLE renewable_energy (id INT,country VARCHAR(50),source VARCHAR(50)); INSERT INTO renewable_energy (id,country,source) VALUES (1,'Germany','Solar'),(2,'US','Wind'),(3,'Germany','Wind'),(4,'France','Hydro'),(5,'US','Solar'),(6,'Germany','Hydro'); | SELECT r.country, COUNT(DISTINCT r.source) as num_sources FROM renewable_energy r GROUP BY r.country; |
Identify the unique co-owners across all properties. | CREATE TABLE property_coowners (property_id INT,coowner VARCHAR(255)); INSERT INTO property_coowners (property_id,coowner) VALUES (1,'John Doe'),(1,'Jane Smith'),(2,'Jane Smith'),(2,'Mike Johnson'),(3,'John Doe'); | SELECT DISTINCT coowner FROM property_coowners; |
What was the average age of artists who performed at Coachella in 2022? | CREATE TABLE FestivalArtists (id INT,festival VARCHAR(20),year INT,artist VARCHAR(50),age INT); INSERT INTO FestivalArtists (id,festival,year,artist,age) VALUES (1,'Coachella',2022,'Billie Eilish',20),(2,'Coachella',2022,'Harry Styles',28); | SELECT AVG(age) FROM FestivalArtists WHERE festival = 'Coachella' AND year = 2022; |
What was the citizen feedback score for public service delivery in urban and rural areas in 2021? | CREATE TABLE Feedback (Area TEXT,Year INTEGER,Feedback_Score INTEGER); INSERT INTO Feedback (Area,Year,Feedback_Score) VALUES ('Urban',2021,80),('Urban',2022,85),('Rural',2021,70),('Rural',2022,75); | SELECT Area, AVG(Feedback_Score) FROM Feedback WHERE Year = 2021 GROUP BY Area; |
Which languages are preserved by the most programs and what is their total funding? | CREATE TABLE LanguagePrograms (id INT,language VARCHAR(255),program VARCHAR(255),funding FLOAT); INSERT INTO LanguagePrograms (id,language,program,funding) VALUES (1,'Spanish','Language Immersion',20000),(2,'French','Bilingual Education',15000),(3,'Mandarin','Community Workshops',12000); | SELECT language, COUNT(*), SUM(funding) FROM LanguagePrograms GROUP BY language; |
How many matches has the Indian women's cricket team played in the last 5 years? | CREATE TABLE matches (id INT,team1 TEXT,team2 TEXT,match_date DATE); INSERT INTO matches (id,team1,team2,match_date) VALUES (1,'India','England','2021-07-01'),(2,'India','Australia','2022-02-12'); | SELECT COUNT(*) FROM matches WHERE (team1 = 'India' OR team2 = 'India') AND match_date >= DATE_SUB(CURRENT_DATE, INTERVAL 5 YEAR); |
List the bioprocess engineering projects for a specific duration, and show the average funding for biotech startups in the same duration range. | CREATE SCHEMA if not exists bioprocess_biotech; CREATE TABLE if not exists bioprocess_biotech.projects (id INT,name VARCHAR(100),duration INT); INSERT INTO bioprocess_biotech.projects (id,name,duration) VALUES (1,'Protein Production',18),(2,'Cell Culture',15),(3,'Fermentation',9),(4,'Bioprocess Optimization',24); CREATE TABLE if not exists bioprocess_biotech.startups (id INT,name VARCHAR(100),location VARCHAR(50),funding DECIMAL(10,2),project_duration INT); INSERT INTO bioprocess_biotech.startups (id,name,location,funding,project_duration) VALUES (1,'Genetech','San Francisco',2500000.00,18),(2,'IncellDX','New York',1500000.00,15),(3,'BiotechNY','New York',5000000.00,24); | SELECT p.duration_range, AVG(startups.funding) as avg_funding FROM (SELECT projects.duration as duration_range FROM bioprocess_biotech.projects WHERE projects.duration BETWEEN 10 AND 20) p JOIN bioprocess_biotech.startups ON p.duration_range = startups.project_duration GROUP BY p.duration_range; |
Determine the total number of volunteers for each gender, from the 'Volunteer_Info' table, grouped by Gender. | CREATE TABLE Volunteer_Info (VolunteerID INT,First_Name VARCHAR(50),Last_Name VARCHAR(50),Gender VARCHAR(10)); | SELECT Gender, COUNT(*) AS Number_Of_Volunteers FROM Volunteer_Info GROUP BY Gender; |
Identify the total number of financial wellbeing programs offered by each financial institution, along with the name of the institution. | CREATE TABLE programs (id INT,name VARCHAR(50),institution_id INT,category VARCHAR(20)); INSERT INTO programs (id,name,institution_id,category) VALUES (1,'Budgeting Workshop',1,'Financial Wellbeing'); CREATE TABLE financial_institutions (id INT,name VARCHAR(50)); INSERT INTO financial_institutions (id,name) VALUES (1,'Bank of America'); | SELECT financial_institutions.name, COUNT(programs.id) FROM programs INNER JOIN financial_institutions ON programs.institution_id = financial_institutions.id GROUP BY financial_institutions.name; |
Find the lowest revenue day for each menu category in February 2022. | CREATE TABLE menu_sales_6 (menu_category VARCHAR(255),sale_date DATE,revenue INT); INSERT INTO menu_sales_6 (menu_category,sale_date,revenue) VALUES ('Appetizers','2022-02-23',1200),('Appetizers','2022-02-24',1500),('Entrees','2022-02-23',3000),('Entrees','2022-02-24',3500); | SELECT menu_category, MIN(revenue) FROM menu_sales_6 WHERE sale_date BETWEEN '2022-02-01' AND '2022-02-28' GROUP BY menu_category; |
What is the total revenue generated by each art category in the museums in Paris? | CREATE TABLE paris_art(id INT,museum VARCHAR(30),category VARCHAR(30),revenue INT); INSERT INTO paris_art VALUES (1,'Louvre','Painting',500000); INSERT INTO paris_art VALUES (2,'d''Orsay','Sculpture',300000); | SELECT category, SUM(revenue) FROM paris_art GROUP BY category; |
How many accidents occurred at the 'Coal Mine' and 'Gold Mine' mining sites? | CREATE TABLE mining_sites(id INT,site VARCHAR(50),accidents INT); INSERT INTO mining_sites (id,site,accidents) VALUES (1,'Coal Mine',1),(2,'Gold Mine',0),(3,'Surface',5),(4,'Underground',3); | SELECT SUM(accidents) FROM mining_sites WHERE site IN ('Coal Mine', 'Gold Mine'); |
Determine the percentage change in monthly production of Lanthanum and Cerium from 2015 to 2016 | CREATE TABLE production (element VARCHAR(10),year INT,month INT,quantity INT); INSERT INTO production (element,year,month,quantity) VALUES ('Lanthanum',2015,1,100),('Lanthanum',2015,2,110),('Lanthanum',2016,1,120),('Lanthanum',2016,2,130),('Cerium',2015,1,140),('Cerium',2015,2,150),('Cerium',2016,1,160),('Cerium',2016,2,170); | SELECT element, (SUM(quantity * CASE WHEN year = 2016 THEN 1 ELSE -1 END) / SUM(quantity) * 100) AS percentage_change FROM production WHERE element IN ('Lanthanum', 'Cerium') GROUP BY element; |
What are the average safety scores for each chemical plant by region? | CREATE TABLE chemical_plants (id INT,name TEXT,region TEXT,safety_score INT); INSERT INTO chemical_plants (id,name,region,safety_score) VALUES (1,'Plant A','Northeast',92),(2,'Plant B','Midwest',88),(3,'Plant C','West',95); | SELECT region, AVG(safety_score) FROM chemical_plants GROUP BY region; |
What is the minimum altitude of Japanese satellites? | CREATE TABLE Satellites (satellite_id INT,name VARCHAR(255),country VARCHAR(255),altitude FLOAT,constellation VARCHAR(255)); INSERT INTO Satellites (satellite_id,name,country,altitude,constellation) VALUES (1,'Ibuki','Japan',600,'Earth Observation'),(2,'H-II Transfer Vehicle','Japan',400,'Supply Vehicle'),(3,'Kaguya','Japan',100,'Lunar Exploration'); | SELECT MIN(altitude) FROM Satellites WHERE country = 'Japan'; |
What is the average donation amount per month, for the last 12 months, excluding records with a donation amount of 0? | CREATE TABLE donations (donation_date DATE,donation_amount DECIMAL(10,2)); INSERT INTO donations (donation_date,donation_amount) VALUES ('2022-01-01',500.00),('2022-02-01',0.00),('2022-03-01',700.00),('2022-04-01',200.00); | SELECT AVG(donation_amount) as avg_donation_amount FROM (SELECT donation_amount FROM donations WHERE donation_date >= DATEADD(year, -1, GETDATE()) AND donation_amount > 0) t GROUP BY DATEPART(year, donation_date), DATEPART(month, donation_date); |
What is the total water consumption for industrial buildings in New York for each month? | CREATE TABLE new_york_water_usage (id INT,building_type VARCHAR(20),water_consumption FLOAT,month VARCHAR(10)); INSERT INTO new_york_water_usage (id,building_type,water_consumption,month) VALUES (1,'Industrial',20000,'January'),(2,'Industrial',25000,'February'); | SELECT month, SUM(water_consumption) FROM new_york_water_usage WHERE building_type = 'Industrial' GROUP BY month; |
Delete wastewater treatment records that are older than 5 years | CREATE TABLE wastewater_treatment (id INT PRIMARY KEY,location VARCHAR(255),treatment_date DATE,water_volume INT); | DELETE FROM wastewater_treatment WHERE treatment_date < DATE_SUB(CURDATE(), INTERVAL 5 YEAR); |
What is the maximum age of astronauts at their last space mission? | CREATE TABLE astronauts(id INT,name VARCHAR(50),age INT,last_mission_year INT); INSERT INTO astronauts VALUES(1,'John Glenn',77,1998),(2,'Peggy Whitson',62,2018); | SELECT MAX(age - last_mission_year) FROM astronauts; |
What is the number of trains that passed through a specific station in London? | CREATE TABLE train_lines (line_id INT,city VARCHAR(50)); INSERT INTO train_lines (line_id,city) VALUES (1,'London'),(2,'London'); CREATE TABLE trains (train_id INT,line_id INT,station VARCHAR(50)); INSERT INTO trains (train_id,line_id,station) VALUES (1,1,'Victoria'),(2,1,'Waterloo'),(3,2,'Paddington'); | SELECT COUNT(*) FROM trains WHERE station = 'Victoria'; |
How many satellites have been deployed by Aerospace Corp in the last 5 years? | CREATE TABLE Satellites (SatelliteID INT,Name VARCHAR(100),Manufacturer VARCHAR(50),LaunchDate DATE); | SELECT COUNT(*) FROM Satellites WHERE Manufacturer = 'Aerospace Corp' AND LaunchDate >= DATEADD(year, -5, GETDATE()); |
List the number of companies founded by people from underrepresented racial backgrounds in the retail sector that have had successful exit strategies. | CREATE TABLE company (id INT,name TEXT,industry TEXT,founding_year INT,founder_race TEXT,exit_strategy TEXT); | SELECT COUNT(id) FROM company WHERE industry = 'Retail' AND founder_race IN ('Black', 'Latinx', 'Indigenous') AND exit_strategy = 'Successful' |
What is the number of wildlife sightings in the Canadian Arctic Archipelago in 2022? | CREATE TABLE wildlife_sightings (species TEXT,location TEXT,date DATE); INSERT INTO wildlife_sightings (species,location,date) VALUES ('Polar Bear','Canadian Arctic Archipelago','2022-01-01'),('Narwhal','Canadian Arctic Archipelago','2022-01-02'); | SELECT COUNT(*) FROM wildlife_sightings WHERE location = 'Canadian Arctic Archipelago' AND date BETWEEN '2022-01-01' AND '2022-12-31'; |
What is the total energy production from solar power plants in Japan, and how does it break down by prefecture? | CREATE TABLE solar_plants (id INT,name VARCHAR(255),prefecture VARCHAR(255),power_output FLOAT,production DATE); | SELECT prefecture, SUM(power_output) FROM solar_plants WHERE country = 'Japan' GROUP BY prefecture; |
How many military drones were produced in the United States between 2018 and 2020? | CREATE TABLE drone_production (id INT,country VARCHAR(255),year INT,production_count INT); INSERT INTO drone_production (id,country,year,production_count) VALUES (1,'United States',2017,1234),(2,'United States',2018,2000),(3,'United States',2019,3000),(4,'United States',2020,4000); | SELECT SUM(production_count) FROM drone_production WHERE country = 'United States' AND year BETWEEN 2018 AND 2020; |
What is the maximum age of users who have used technology for social good? | CREATE TABLE Users (UserID INT,Age INT,UsedTech4Good BOOLEAN); INSERT INTO Users (UserID,Age,UsedTech4Good) VALUES (1,34,true),(2,45,false),(3,29,true); | SELECT MAX(Age) FROM Users WHERE UsedTech4Good = true; |
Who are the community health workers serving each region? | CREATE TABLE community_health_workers (worker_id INT,name VARCHAR(50),region VARCHAR(25)); INSERT INTO community_health_workers (worker_id,name,region) VALUES (1,'John Doe','Northeast'),(2,'Jane Smith','Southeast'),(3,'Maria Garcia','Midwest'); CREATE TABLE regions (region VARCHAR(25),community VARCHAR(50)); INSERT INTO regions (region,community) VALUES ('Northeast','Community A'),('Southeast','Community B'),('Midwest','Community C'); | SELECT c.name, r.community FROM community_health_workers c INNER JOIN regions r ON c.region = r.region; |
Which countries have participated in humanitarian assistance operations and what is their total spending? | CREATE TABLE humanitarian_operations (operation_id INT,country VARCHAR(50),spending INT); INSERT INTO humanitarian_operations (operation_id,country,spending) VALUES (1,'United States',5000000),(2,'Mexico',3000000),(3,'Chile',2000000); CREATE TABLE countries (country VARCHAR(50),population INT); INSERT INTO countries (country,population) VALUES ('United States',331002651),('Mexico',126577691),('Chile',19116209); | SELECT co.country, SUM(ho.spending) as total_spending FROM humanitarian_operations ho JOIN countries co ON ho.country = co.country GROUP BY co.country; |
What is the number of cases resolved using each type of resolution method in the last year? | CREATE TABLE Cases (ID INT,CaseNumber INT,Date DATE,Resolution VARCHAR(255)); INSERT INTO Cases (ID,CaseNumber,Date,Resolution) VALUES (1,12345,'2022-01-01','Restorative Justice'),(2,67890,'2022-02-15','Trial'),(3,111213,'2022-03-28','Mediation'); | SELECT Resolution, COUNT(*) as CasesResolved FROM Cases WHERE Date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR) GROUP BY Resolution; |
How many organizations are working on ethical AI in the technology industry? | CREATE TABLE organizations (id INT,industry VARCHAR(20),projects INT); INSERT INTO organizations (id,industry,projects) VALUES (1,'technology',15),(2,'finance',8),(3,'healthcare',12); | SELECT COUNT(*) FROM organizations WHERE industry = 'technology' AND projects > 10; |
What is the total installed capacity of renewable energy projects in the state of Texas, broken down by project type? | CREATE TABLE renewable_energy_projects (project_id INT,project_name VARCHAR(255),state VARCHAR(255),project_type VARCHAR(255),installed_capacity FLOAT); | SELECT project_type, SUM(installed_capacity) FROM renewable_energy_projects WHERE state = 'Texas' GROUP BY project_type; |
Find the number of models that were trained after 2019 and belong to the 'creative_ai' category. | CREATE TABLE model_categories (model_name TEXT,train_year INTEGER,category TEXT); INSERT INTO model_categories (model_name,train_year,category) VALUES ('model1',2018,'creative_ai'),('model2',2020,'explainable_ai'),('model3',2019,'creative_ai'),('model4',2021,'algorithmic_fairness'); | SELECT COUNT(*) FROM model_categories WHERE train_year > 2019 AND category = 'creative_ai'; |
Delete all records with the project_category 'Infrastructure Development' from the projects table. | CREATE TABLE projects (id INT PRIMARY KEY,project_name TEXT,project_category TEXT,cost FLOAT); INSERT INTO projects (id,project_name,project_category,cost) VALUES (1,'Building Schools','Infrastructure Development',500000); | DELETE FROM projects WHERE project_category = 'Infrastructure Development'; |
What is the total quantity of organic cotton textiles sourced from India and Bangladesh? | CREATE TABLE TextileSourcing (country VARCHAR(20),material VARCHAR(20),quantity INT,is_organic BOOLEAN); INSERT INTO TextileSourcing VALUES ('India','Cotton',4000,TRUE),('Bangladesh','Cotton',3000,TRUE),('China','Silk',5000,FALSE); | SELECT SUM(quantity) FROM TextileSourcing WHERE (country = 'India' OR country = 'Bangladesh') AND material = 'Cotton' AND is_organic = TRUE; |
How many donations were made to children's charities between '2021-04-01' and '2021-06-30'? | CREATE TABLE donors (donor_id INT,donor_name TEXT,donation_amount FLOAT,cause TEXT,donation_date DATE); | SELECT COUNT(*) FROM donors WHERE cause = 'Children''s Charities' AND donation_date BETWEEN '2021-04-01' AND '2021-06-30'; |
What is the percentage of financially capable individuals in each region, ordered by the percentage in descending order? | CREATE TABLE Individuals (ID INT,Name VARCHAR(255),Age INT,Region VARCHAR(255),FinanciallyCapable BOOLEAN); INSERT INTO Individuals (ID,Name,Age,Region,FinanciallyCapable) VALUES (1,'John',30,'Region1',true),(2,'Jane',25,'Region2',false),(3,'Mike',45,'Region1',true); | SELECT Region, COUNT(*) FILTER (WHERE FinanciallyCapable = true) * 100.0 / COUNT(*) as Percentage, RANK() OVER (ORDER BY Percentage DESC) as Rank FROM Individuals GROUP BY Region; |
What is the maximum maintenance cost for military vehicles in Europe? | CREATE TABLE Military_Vehicles (id INT,country VARCHAR(50),type VARCHAR(50),maintenance_cost FLOAT); | SELECT MAX(maintenance_cost) FROM Military_Vehicles WHERE country = 'Europe'; |
How many animals have been de-listed from the endangered species list in Australia? | CREATE TABLE DeListing (AnimalID INT,AnimalName VARCHAR(50),DeListed INT,Location VARCHAR(50)); INSERT INTO DeListing (AnimalID,AnimalName,DeListed,Location) VALUES (1,'Koala',300,'Australia'); INSERT INTO DeListing (AnimalID,AnimalName,DeListed,Location) VALUES (2,'Wallaby',250,'Australia'); | SELECT SUM(DeListed) FROM DeListing WHERE Location = 'Australia'; |
What is the total number of users by city? | CREATE TABLE users (id INT,name VARCHAR(50),age INT,city VARCHAR(50)); INSERT INTO users (id,name,age,city) VALUES (1,'Alice',30,'New York'); INSERT INTO users (id,name,age,city) VALUES (2,'Bob',25,'Los Angeles'); INSERT INTO users (id,name,age,city) VALUES (3,'Charlie',35,'New York'); | SELECT city, COUNT(*) as total_users FROM users GROUP BY city; |
What is the total revenue generated from baseball games in Chicago? | CREATE TABLE revenue (game_id INT,team VARCHAR(255),city VARCHAR(255),date DATE,revenue DECIMAL(10,2)); INSERT INTO revenue (game_id,team,city,date,revenue) VALUES (1,'Chicago Cubs','Chicago','2023-04-02',1200000),(2,'Chicago White Sox','Chicago','2023-04-03',1300000); | SELECT SUM(revenue) FROM revenue WHERE city = 'Chicago' AND sport = 'Baseball'; |
List the genetic research projects by disease category. | CREATE SCHEMA if not exists genetic_research;CREATE TABLE if not exists genetic_research.projects(id INT,name TEXT,lead_researcher TEXT,disease_category TEXT);INSERT INTO genetic_research.projects (id,name,lead_researcher,disease_category) VALUES (1,'ProjectX','Dr. Jane Smith','Cancer'),(2,'ProjectY','Dr. John Doe','Neurological Disorders'),(3,'ProjectZ','Dr. Maria Garcia','Cancer'); | SELECT disease_category, name FROM genetic_research.projects; |
Who are the top 5 users with the most security incidents in the past month? | CREATE TABLE security_incidents (id INT,incident_date DATE,user_id INT,threat_type VARCHAR(50)); INSERT INTO security_incidents (id,incident_date,user_id,threat_type) VALUES (1,'2022-01-01',1,'Malware'),(2,'2022-01-05',2,'Phishing'),(3,'2022-01-10',1,'Ransomware'); CREATE TABLE users (id INT,username VARCHAR(50)); INSERT INTO users (id,username) VALUES (1,'user1'),(2,'user2'),(3,'user3'); | SELECT u.username, COUNT(*) as incident_count FROM security_incidents s JOIN users u ON s.user_id = u.id WHERE incident_date >= DATEADD(month, -1, GETDATE()) GROUP BY u.username ORDER BY incident_count DESC LIMIT 5; |
What is the percentage of total cargo weight that each cargo item represents, per port, in descending order? | CREATE TABLE Port (PortID INT,PortName VARCHAR(100),City VARCHAR(100),Country VARCHAR(100)); INSERT INTO Port (PortID,PortName,City,Country) VALUES (1,'Port of Los Angeles','Los Angeles','USA'); INSERT INTO Port (PortID,PortName,City,Country) VALUES (2,'Port of Rotterdam','Rotterdam','Netherlands'); CREATE TABLE Cargo (CargoID INT,CargoName VARCHAR(100),PortID INT,Weight INT,Volume INT); INSERT INTO Cargo (CargoID,CargoName,PortID,Weight,Volume) VALUES (1,'Container 1',1,15000,5000); INSERT INTO Cargo (CargoID,CargoName,PortID,Weight,Volume) VALUES (2,'Container 2',2,18000,5500); CREATE TABLE PortCargo (PortID INT,CargoID INT,Weight INT,Volume INT); INSERT INTO PortCargo (PortID,CargoID,Weight,Volume) VALUES (1,1,15000,5000); INSERT INTO PortCargo (PortID,CargoID,Weight,Volume) VALUES (2,2,18000,5500); | SELECT PortID, CargoID, Weight, Volume, PERCENT_RANK() OVER(PARTITION BY PortID ORDER BY SUM(Weight) OVER(PARTITION BY PortID) DESC) AS WeightPercentage FROM PortCargo ORDER BY PortID, WeightPercentage DESC |
Determine the number of days since the last food safety inspection for each restaurant. | CREATE TABLE restaurant (restaurant_id INTEGER,last_inspection_date DATE); INSERT INTO restaurant (restaurant_id,last_inspection_date) VALUES (1,'2022-05-01'),(2,'2023-02-01'),(3,'2023-03-15'); | SELECT restaurant_id, DATEDIFF('day', last_inspection_date, CURRENT_DATE) AS days_since_last_inspection FROM restaurant; |
Calculate the total volume of wastewater treated in 'Lima' for each month of the year 2020 | CREATE TABLE wastewater_treatment (region VARCHAR(50),date DATE,volume FLOAT); INSERT INTO wastewater_treatment (region,date,volume) VALUES ('Lima','2020-01-01',500),('Lima','2020-02-01',550),('Lima','2020-03-01',600); | SELECT date, SUM(volume) FROM wastewater_treatment WHERE region = 'Lima' AND date BETWEEN '2020-01-01' AND '2020-12-31' GROUP BY date; |
What is the average funding amount for biotech startups in the USA? | CREATE TABLE startups (id INT,name VARCHAR(50),location VARCHAR(50),funding FLOAT); INSERT INTO startups (id,name,location,funding) VALUES (1,'StartupA','USA',15000000); INSERT INTO startups (id,name,location,funding) VALUES (2,'StartupB','USA',22000000); | SELECT AVG(funding) FROM startups WHERE location = 'USA'; |
What is the total CO2 emissions for each country where mining operations are present? | CREATE TABLE country_emissions (mine_id INT,co2_emissions INT,country TEXT); INSERT INTO country_emissions (mine_id,co2_emissions,country) VALUES (1,5000,'Canada'); INSERT INTO country_emissions (mine_id,co2_emissions,country) VALUES (2,7000,'Mexico'); | SELECT country, SUM(co2_emissions) FROM country_emissions GROUP BY country; |
What is the percentage of job offers made to candidates who identify as members of underrepresented racial or ethnic groups, by hiring manager? | CREATE TABLE JobOffers2 (OfferID INT,HiringManager VARCHAR(50),CandidateRaceEthnicity VARCHAR(50),DateOffered DATE); | SELECT HiringManager, COUNT(*) * 100.0 / (SELECT COUNT(*) FROM JobOffers2 WHERE CandidateRaceEthnicity NOT IN ('White', 'Asian')) as Percentage_Underrepresented FROM JobOffers2 WHERE CandidateRaceEthnicity NOT IN ('White', 'Asian') GROUP BY HiringManager; |
How many students from each country are enrolled in graduate programs? | CREATE TABLE graduate_students (student_id INT,name VARCHAR(50),country VARCHAR(50)); | SELECT gs.country, COUNT(*) AS num_students FROM graduate_students gs GROUP BY gs.country; |
List the top 10 restaurants with the highest food safety inspection scores, along with their average score. | CREATE TABLE inspections (inspection_id INT,restaurant_id INT,inspection_date DATE,score INT); INSERT INTO inspections (inspection_id,restaurant_id,inspection_date,score) VALUES (1,1,'2022-01-01',95); | SELECT restaurant_id, AVG(score) as avg_score FROM inspections GROUP BY restaurant_id ORDER BY avg_score DESC FETCH FIRST 10 ROWS ONLY; |
What is the average donation amount for environmental causes in Q1 2022? | CREATE TABLE donors (donor_id INT,donor_name TEXT,donation_amount FLOAT,cause TEXT,donation_date DATE); | SELECT AVG(donation_amount) FROM donors WHERE cause = 'Environment' AND donation_date BETWEEN '2022-01-01' AND '2022-03-31'; |
What is the average calorie count for vegetables in the ORGANIC_FOOD table? | CREATE TABLE ORGANIC_FOOD (id INT,name VARCHAR(50),category VARCHAR(50),avg_calories FLOAT); INSERT INTO ORGANIC_FOOD (id,name,category,avg_calories) VALUES (1,'Carrot','Vegetable',25),(2,'Lettuce','Vegetable',5); | SELECT AVG(avg_calories) FROM ORGANIC_FOOD WHERE category = 'Vegetable'; |
What is the total number of workshops organized for students in Japan during Q1 2022? | CREATE TABLE Workshops_For_Students (id INT,country VARCHAR(255),quarter INT,number_of_workshops INT); | SELECT SUM(number_of_workshops) FROM Workshops_For_Students WHERE country = 'Japan' AND quarter = 1; |
What is the average number of mobility assistive devices used per student? | CREATE TABLE MobilityAssistiveDevices (student_id INT,device_type VARCHAR(255),usage_frequency INT); | SELECT AVG(usage_frequency) FROM MobilityAssistiveDevices GROUP BY student_id; |
What is the total energy consumption of the top 3 most energy-intensive manufacturing industries in Africa? | CREATE TABLE energy_consumption (factory_id INT,industry VARCHAR(50),region VARCHAR(50),energy_consumption INT); | SELECT industry, SUM(energy_consumption) FROM energy_consumption e JOIN (SELECT factory_id, MIN(row_number) FROM (SELECT factory_id, ROW_NUMBER() OVER (PARTITION BY industry ORDER BY energy_consumption DESC) row_number FROM energy_consumption) t GROUP BY industry) x ON e.factory_id = x.factory_id GROUP BY industry HAVING COUNT(*) <= 3 AND region = 'Africa'; |
Identify the number of digital assets owned by each user and rank them by the number of assets they own. | CREATE TABLE user_assets(user_id INT,asset_id INT); INSERT INTO user_assets(user_id,asset_id) VALUES (1,101),(1,102),(2,103),(3,104),(3,105),(3,106),(4,107),(4,108),(5,109); CREATE TABLE assets(id INT,asset_name VARCHAR(255)); INSERT INTO assets(id,asset_name) VALUES (101,'AssetA'),(102,'AssetB'),(103,'AssetC'),(104,'AssetD'),(105,'AssetE'),(106,'AssetF'),(107,'AssetG'),(108,'AssetH'),(109,'AssetI'); | SELECT u.user_id, COUNT(ua.asset_id) as asset_count FROM users u JOIN user_assets ua ON u.user_id = ua.user_id JOIN assets a ON ua.asset_id = a.id GROUP BY u.user_id ORDER BY asset_count DESC; |
How many employees of each nationality work in the 'Mining Operations' department? | CREATE TABLE Employees (EmployeeID INT,Name VARCHAR(50),Department VARCHAR(50),Age INT,Nationality VARCHAR(50)); | SELECT Department, Nationality, COUNT(*) FROM Employees WHERE Department = 'Mining Operations' GROUP BY Department, Nationality; |
How many citizen feedback records are there for 'ServiceC' in 'RegionE'? | CREATE TABLE Feedback(service VARCHAR(20),region VARCHAR(20),feedback_id INT); INSERT INTO Feedback VALUES ('ServiceA','RegionC',1001),('ServiceA','RegionC',1002),('ServiceB','RegionD',2001),('ServiceB','RegionD',2002),('ServiceC','RegionE',3001),('ServiceC','RegionE',3002); | SELECT COUNT(*) FROM Feedback WHERE service = 'ServiceC' AND region = 'RegionE'; |
Update the sector for company with id 1 to 'green_technology'. | CREATE TABLE companies (id INT,sector TEXT,ESG_rating FLOAT); INSERT INTO companies (id,sector,ESG_rating) VALUES (1,'technology',78.2),(2,'finance',82.5),(3,'technology',84.6); | UPDATE companies SET sector = 'green_technology' WHERE id = 1; |
What are the top 5 customers by total spend in the past year from the 'customers' table? | CREATE TABLE customers (customer_id INT,name TEXT,total_spend DECIMAL(10,2)); | SELECT customer_id, name, total_spend FROM customers ORDER BY total_spend DESC LIMIT 5; |
What is the total local economic impact of eco-friendly hotels in Paris last year? | CREATE TABLE economic_impact (impact_id INT,hotel_id INT,city TEXT,amount DECIMAL(10,2)); INSERT INTO economic_impact (impact_id,hotel_id,city,amount) VALUES (1,1,'Paris',50000.00),(2,2,'Paris',75000.00); | SELECT SUM(amount) FROM economic_impact WHERE city = 'Paris' AND DATE_TRUNC('year', timestamp) = DATE_TRUNC('year', NOW() - INTERVAL '1 year') AND hotel_id IN (SELECT hotel_id FROM eco_hotels WHERE city = 'Paris'); |
What is the average number of games designed by all game designers? | CREATE TABLE GameDesigners (DesignerID INT,DesignerName VARCHAR(50),Gender VARCHAR(10),NumberOfGames INT); INSERT INTO GameDesigners (DesignerID,DesignerName,Gender,NumberOfGames) VALUES (1,'Alice','Female',3),(2,'Bob','Male',2),(3,'Charlie','Non-binary',1); | SELECT AVG(NumberOfGames) FROM GameDesigners; |
What is the total number of tourists visiting South America from 2015 to Q3 2021, grouped by year and quarter? | CREATE TABLE tourism_data (id INT,country VARCHAR(50),arrival_date DATE); INSERT INTO tourism_data (id,country,arrival_date) VALUES (1,'Brazil','2015-01-01'),(2,'Argentina','2016-03-15'),(3,'Colombia','2021-04-20'); | SELECT country, DATE_FORMAT(arrival_date, '%Y-%q') AS quarter, COUNT(*) AS total_tourists FROM tourism_data WHERE country IN ('Brazil', 'Argentina', 'Colombia') AND arrival_date BETWEEN '2015-01-01' AND '2021-09-30' GROUP BY quarter, country; |
What is the total amount spent on supplies by each organization in 2021? | CREATE TABLE Supplies (org_name TEXT,supply_cost INTEGER,supply_date DATE); INSERT INTO Supplies (org_name,supply_cost,supply_date) VALUES ('Organization A',3000,'2021-01-05'); INSERT INTO Supplies (org_name,supply_cost,supply_date) VALUES ('Organization B',4000,'2021-06-12'); | SELECT org_name, SUM(supply_cost) FROM Supplies WHERE supply_date BETWEEN '2021-01-01' AND '2021-12-31' GROUP BY org_name; |
Insert a new record for a female African American founder from Nigeria into the "company_diversity" table | CREATE TABLE company_diversity (id INT PRIMARY KEY,company_id INT,founder_gender VARCHAR(10),founder_ethnicity VARCHAR(20),country VARCHAR(20)); INSERT INTO company_diversity (id,company_id,founder_gender,founder_ethnicity,country) VALUES (1,1001,'male','white','US'),(2,1002,'male','asian','CA'); | INSERT INTO company_diversity (id, company_id, founder_gender, founder_ethnicity, country) VALUES (3, 1003, 'female', 'African American', 'NG'); |
What is the average quantity of sustainable fabric sourced from Europe? | CREATE TABLE TextileSourcing (id INT,location VARCHAR(50),fabric_type VARCHAR(50),quantity INT); INSERT INTO TextileSourcing (id,location,fabric_type,quantity) VALUES (1,'Italy','Organic Cotton',500),(2,'France','Tencel',350),(3,'Germany','Recycled Polyester',400); | SELECT AVG(quantity) FROM TextileSourcing WHERE fabric_type = 'Organic Cotton' AND location IN ('Italy', 'France', 'Germany'); |
Show the military spending of the top 3 countries in Africa and the Middle East. | CREATE TABLE military_spending (country TEXT,spending FLOAT); INSERT INTO military_spending (country,spending) VALUES ('Egypt',10.5),('Israel',9.2),('Algeria',11.7),('Saudi Arabia',8.8); | SELECT m.country, m.spending FROM military_spending m WHERE m.spending >= (SELECT AVG(m2.spending) FROM military_spending m2) ORDER BY m.spending DESC LIMIT 3; |
How many energy efficiency programs were implemented in 'Asia'? | CREATE TABLE energy_efficiency_programs (id INT,program_name VARCHAR(100),location VARCHAR(50)); | SELECT COUNT(*) FROM energy_efficiency_programs WHERE location = 'Asia'; |
Which country has the longest coastline? | CREATE TABLE countries (name VARCHAR(255),coastline FLOAT); | SELECT name FROM countries ORDER BY coastline DESC LIMIT 1; |
What is the average carbon price per metric ton for the European Union in 2021? | CREATE TABLE carbon_prices (region VARCHAR(20),price DECIMAL(5,2),year INT); INSERT INTO carbon_prices (region,price,year) VALUES ('European Union',25.50,2021),('European Union',26.30,2021),('European Union',24.80,2021); | SELECT AVG(price) FROM carbon_prices WHERE region = 'European Union' AND year = 2021; |
What is the total number of emergency incidents and corresponding response times for each community in Chicago? | CREATE TABLE chicago_communities (id INT,name TEXT); INSERT INTO chicago_communities (id,name) VALUES (1,'Downtown'),(2,'North Side'),(3,'South Side'); CREATE TABLE emergency_response (id INT,community_id INT,incident_id INT,response_time INT); INSERT INTO emergency_response (id,community_id,incident_id,response_time) VALUES (1,1,1,300),(2,1,2,450),(3,3,3,600); CREATE TABLE emergency_incidents (id INT,type TEXT,date DATE); INSERT INTO emergency_incidents (id,type,date) VALUES (1,'Fire','2021-01-01'),(2,'Theft','2021-01-02'),(3,'Assault','2021-01-03'); | SELECT c.name, COUNT(er.incident_id) as total_incidents, AVG(er.response_time) as avg_response_time FROM chicago_communities c JOIN emergency_response er ON c.id = er.community_id GROUP BY c.id; |
Determine the top 3 cities with the highest average claim amount for life insurance policies. | CREATE TABLE claims (claim_id INT,policy_id INT,claim_amount DECIMAL(10,2),city VARCHAR(50),policy_type VARCHAR(50)); CREATE TABLE policies (policy_id INT,policy_holder_id INT,policy_type VARCHAR(50),issue_date DATE); | SELECT c.city, AVG(claim_amount) FROM claims c JOIN policies p ON c.policy_id = p.policy_id WHERE policy_type = 'life' GROUP BY c.city ORDER BY AVG(claim_amount) DESC LIMIT 3; |
What are the IP addresses and threat levels of all threats originating from a specific country? | CREATE TABLE threats (id INT,ip VARCHAR(255),country VARCHAR(255),threat_level INT); INSERT INTO threats (id,ip,country,threat_level) VALUES (1,'192.168.0.1','USA',5); | SELECT ip, threat_level FROM threats WHERE country = 'specific_country'; |
Get the names of all vessels built before 2005 | CREATE TABLE vessels (id INT PRIMARY KEY,name VARCHAR(50),type VARCHAR(50),length FLOAT,year_built INT); | SELECT name FROM vessels WHERE year_built < 2005; |
How many graduate students in the Social Sciences program have published at least one paper? | CREATE TABLE students (id INT,name VARCHAR(50),gender VARCHAR(10),program VARCHAR(50),publications INT); INSERT INTO students (id,name,gender,program,publications) VALUES (1,'Charlie','Non-binary','Social Sciences',1),(2,'Dana','Female','Physics',0),(3,'Eli','Male','Engineering',0); | SELECT COUNT(*) FROM students WHERE program LIKE 'Social%' AND publications > 0; |
How many different types of military vehicles are maintained? | CREATE TABLE vehicles (id INT,type VARCHAR(255),last_maintenance DATE);INSERT INTO vehicles (id,type,last_maintenance) VALUES (1,'Tank','2021-03-01'),(2,'Armored Personnel Carrier','2020-08-15'),(3,'Artillery','2022-01-20'),(4,'Tank','2021-12-05'),(5,'Helicopter','2021-06-10'); | SELECT COUNT(DISTINCT type) as num_types FROM vehicles; |
Find the average production quantity of CBD and THC strains in Oregon and Washington. | CREATE TABLE strain_production (strain_type VARCHAR(10),state VARCHAR(20),production_quantity INT); INSERT INTO strain_production (strain_type,state,production_quantity) VALUES ('CBD','Oregon',100); INSERT INTO strain_production (strain_type,state,production_quantity) VALUES ('THC','Oregon',200); INSERT INTO strain_production (strain_type,state,production_quantity) VALUES ('CBD','Washington',150); INSERT INTO strain_production (strain_type,state,production_quantity) VALUES ('THC','Washington',250); | SELECT strain_type, AVG(production_quantity) FROM strain_production WHERE state IN ('Oregon', 'Washington') GROUP BY strain_type; |
What is the total number of trips for each driver by gender? | CREATE TABLE driver (driver_id INT,name VARCHAR(255),gender VARCHAR(10)); CREATE TABLE trip (trip_id INT,driver_id INT,fare DECIMAL(10,2)); INSERT INTO driver (driver_id,name,gender) VALUES (1,'John Doe','Male'),(2,'Jane Smith','Female'),(3,'Bob Johnson','Male'); INSERT INTO trip (trip_id,driver_id,fare) VALUES (1,1,2.00),(2,1,3.00),(3,2,4.00),(4,3,5.00); | SELECT d.gender, d.driver_id, d.name, COUNT(t.trip_id) AS trip_count FROM driver d JOIN trip t ON d.driver_id = t.driver_id GROUP BY d.driver_id, d.gender; |
What are the top 5 defense contractors in the USA in terms of contract value? | CREATE TABLE defense_contractors (contractor_id INT,contractor_name VARCHAR(255),contract_value FLOAT,country VARCHAR(255)); INSERT INTO defense_contractors (contractor_id,contractor_name,contract_value,country) VALUES (1,'Lockheed Martin',6000000,'USA'),(2,'Boeing',5000000,'USA'),(3,'Raytheon',4000000,'USA'),(4,'Northrop Grumman',3500000,'USA'),(5,'General Dynamics',3000000,'USA'); | SELECT contractor_name, contract_value FROM (SELECT contractor_name, contract_value, RANK() OVER (ORDER BY contract_value DESC) as rnk FROM defense_contractors WHERE country = 'USA') t WHERE rnk <= 5; |
What is the average mental health score for patients belonging to the LGBTQ+ community? | CREATE TABLE patient (id INT,name TEXT,mental_health_score INT,community TEXT); INSERT INTO patient (id,name,mental_health_score,community) VALUES (1,'John Doe',60,'Straight'),(2,'Jane Smith',70,'LGBTQ+'); | SELECT AVG(mental_health_score) FROM patient WHERE community = 'LGBTQ+'; |
What is the maximum health equity metric score achieved by any community health worker in California? | CREATE TABLE health_equity_metrics (id INT,community_health_worker_id INT,score INT); INSERT INTO health_equity_metrics (id,community_health_worker_id,score) VALUES (1,1,80),(2,2,90),(3,3,95),(4,4,70); CREATE TABLE community_health_workers (id INT,name VARCHAR(100),state VARCHAR(50)); INSERT INTO community_health_workers (id,name,state) VALUES (1,'Jane Smith','California'),(2,'Jose Garcia','Texas'),(3,'Sophia Lee','California'),(4,'Ali Ahmed','New York'); | SELECT MAX(score) FROM health_equity_metrics JOIN community_health_workers ON health_equity_metrics.community_health_worker_id = community_health_workers.id WHERE community_health_workers.state = 'California'; |
What is the total coal production by site in the last quarter? | CREATE TABLE site (site_id INT,site_name VARCHAR(50)); INSERT INTO site (site_id,site_name) VALUES (1,'Site A'),(2,'Site B'); CREATE TABLE production (production_id INT,site_id INT,product VARCHAR(10),production_date DATE,quantity INT); INSERT INTO production (production_id,site_id,product,production_date,quantity) VALUES (1,1,'coal','2021-01-01',500),(2,1,'coal','2021-02-01',600),(3,1,'coal','2021-03-01',700),(4,2,'coal','2021-01-01',800),(5,2,'coal','2021-02-01',900),(6,2,'coal','2021-03-01',1000); | SELECT site_name, SUM(quantity) AS total_coal_production FROM production JOIN site ON production.site_id = site.site_id WHERE product = 'coal' AND production_date >= DATEADD(quarter, -1, GETDATE()) GROUP BY site_name; |
What is the total military spending by each country in the Southeast Asia region from 2015 to 2020? | CREATE TABLE MilitarySpending (Year INT,Country VARCHAR(50),Spending FLOAT,Region VARCHAR(50)); INSERT INTO MilitarySpending (Year,Country,Spending,Region) VALUES (2015,'Indonesia',14.5,'Southeast Asia'),(2015,'Malaysia',12.6,'Southeast Asia'),(2016,'Indonesia',15.2,'Southeast Asia'); | SELECT Country, SUM(Spending) as Total_Spending FROM MilitarySpending WHERE Year BETWEEN 2015 AND 2020 AND Region = 'Southeast Asia' GROUP BY Country; |
Calculate the percentage of hotels adopting AI technology in each region | CREATE TABLE hotel_info (hotel_id INT,hotel_name VARCHAR(50),region VARCHAR(50),ai_adoption INT); INSERT INTO hotel_info (hotel_id,hotel_name,region,ai_adoption) VALUES (1,'Hotel A','Region 1',1),(2,'Hotel B','Region 1',0),(3,'Hotel C','Region 2',1),(4,'Hotel D','Region 2',1); | SELECT region, 100.0 * SUM(ai_adoption) / COUNT(*) as adoption_percentage FROM hotel_info GROUP BY region; |
Count the number of Shariah-compliant financial institutions in Asia with more than 5 branches. | CREATE TABLE shariah_compliant_finance (id INT,institution_name VARCHAR(255),country VARCHAR(255),num_branches INT); INSERT INTO shariah_compliant_finance (id,institution_name,country,num_branches) VALUES (1,'Islamic Bank','Indonesia',7),(2,'Shariah Finance Ltd','India',6),(3,'Al-Baraka Bank','Pakistan',3); | SELECT COUNT(*) FROM shariah_compliant_finance WHERE country = 'Asia' AND num_branches > 5; |
How many sustainable material brands were added in the past year? | CREATE TABLE sustainable_material_brands (brand_id INT PRIMARY KEY,brand_name VARCHAR(100),added_date DATE); | SELECT COUNT(*) FROM sustainable_material_brands WHERE added_date >= DATE_SUB(NOW(), INTERVAL 1 YEAR); |
Update the 'sustainability_score' for 'Green Fabrics Inc.' to '90' in the 'Supplier' table | CREATE TABLE Supplier (id INT PRIMARY KEY,name VARCHAR(50),country VARCHAR(50),sustainability_score INT); | UPDATE Supplier SET sustainability_score = 90 WHERE name = 'Green Fabrics Inc.'; |
What is the total CO2 emissions of diesel vehicles per country in the "emissions" table? | CREATE TABLE emissions (id INT,country VARCHAR(255),vehicle_type VARCHAR(255),co2_emissions INT); INSERT INTO emissions (id,country,vehicle_type,co2_emissions) VALUES (1,'USA','Diesel',120); | SELECT country, SUM(co2_emissions) FROM emissions WHERE vehicle_type = 'Diesel' GROUP BY country; |
How many founders with disabilities have received funding? | CREATE TABLE startups (id INT,name VARCHAR(255),founding_year INT,founder_disability BOOLEAN); INSERT INTO startups (id,name,founding_year,founder_disability) VALUES (1,'Delta X',2018,true),(2,'Echo Y',2019,false); CREATE TABLE funding (startup_id INT,amount INT); INSERT INTO funding (startup_id,amount) VALUES (1,750000),(2,1000000); | SELECT COUNT(*) FROM funding INNER JOIN startups ON funding.startup_id = startups.id WHERE startups.founder_disability = true; |
How many open data initiatives were launched by the government of Canada in 2021? | CREATE TABLE open_data_initiatives (initiative_id INT,initiative_date DATE,initiative_country VARCHAR(50)); INSERT INTO open_data_initiatives (initiative_id,initiative_date,initiative_country) VALUES (1,'2021-01-01','Canada'),(2,'2021-02-01','Canada'); | SELECT COUNT(*) FROM open_data_initiatives WHERE initiative_country = 'Canada' AND initiative_date BETWEEN '2021-01-01' AND '2021-12-31'; |
Identify the top 3 fashion trends by customer preference in the last year. | CREATE TABLE Customer_Preferences (customer_id INT,preference_date DATE,fashion_trend VARCHAR(255)); INSERT INTO Customer_Preferences (customer_id,preference_date,fashion_trend) VALUES (1,'2021-01-01','Sustainable'),(2,'2021-01-15','Vintage'),(3,'2021-02-01','Minimalist'),(4,'2021-02-10','Streetwear'),(5,'2021-03-01','Bohemian'),(6,'2021-03-15','Sustainable'),(7,'2021-04-01','Vintage'),(8,'2021-04-10','Minimalist'),(9,'2021-05-01','Sustainable'),(10,'2021-05-15','Vintage'); | SELECT fashion_trend, COUNT(*) AS preference_count FROM Customer_Preferences WHERE preference_date BETWEEN DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR) AND CURRENT_DATE GROUP BY fashion_trend ORDER BY preference_count DESC LIMIT 3; |
What is the total number of satellites launched by India? | CREATE TABLE countries (id INT,name TEXT); CREATE TABLE satellites (id INT,country_id INT,name TEXT,launch_date DATE,manufacturer TEXT); INSERT INTO countries (id,name) VALUES (1,'USA'),(2,'Russia'),(3,'China'),(4,'India'); INSERT INTO satellites (id,country_id,name,launch_date,manufacturer) VALUES (1,1,'StarDragon','2012-05-25','SpaceX'),(2,1,'Falcon','2015-12-21','SpaceX'),(3,2,'Sputnik','1957-10-04','Russia'),(4,3,'ChinaSat 1E','2000-12-05','CAST'),(5,4,'EDUSAT','2004-09-20','ISRO'); | SELECT COUNT(*) FROM satellites WHERE country_id = 4; |
What is the total number of players from Asia? | CREATE TABLE player_stats (id INT,name VARCHAR(50),country VARCHAR(50)); INSERT INTO player_stats (id,name,country) VALUES (1,'John Doe','USA'),(2,'Jane Smith','Canada'),(3,'Maria Garcia','Mexico'),(4,'Li Chen','China'),(5,'Hiroshi Tanaka','Japan'); | SELECT COUNT(*) FROM player_stats WHERE country LIKE 'China%' OR country LIKE 'Japan%' OR country LIKE 'India%' OR country LIKE 'Korea%'; |
What is the total volume of timber production for each year, grouped by year? | CREATE TABLE timber_production(year INT,volume INT); INSERT INTO timber_production(year,volume) VALUES (2018,5000),(2019,5500),(2020,6000); | SELECT year, SUM(volume) FROM timber_production GROUP BY year; |
How many unique strains were available in Colorado in 2020 and 2021? | CREATE TABLE strains (id INT,state VARCHAR(50),year INT,strain VARCHAR(50)); INSERT INTO strains (id,state,year,strain) VALUES (1,'Colorado',2020,'Blue Dream'),(2,'Colorado',2021,'Green Crack'),(3,'California',2020,'Sour Diesel'); | SELECT COUNT(DISTINCT strain) FROM strains WHERE state = 'Colorado' AND (year = 2020 OR year = 2021); |
List all satellites launched by India? | CREATE TABLE Satellites (id INT,name VARCHAR(100),manufacturer VARCHAR(100),launch_country VARCHAR(100),launch_date DATE); INSERT INTO Satellites (id,name,manufacturer,launch_country,launch_date) VALUES (4,'Sat4','SpaceTech','India','2021-01-01'); INSERT INTO Satellites (id,name,manufacturer,launch_country,launch_date) VALUES (5,'Sat5','EuroSpace','India','2022-02-14'); | SELECT name, manufacturer, launch_date FROM Satellites WHERE launch_country = 'India'; |
What is the total budget allocated to public services for each city? | CREATE TABLE City_Budget(City VARCHAR(20),Department VARCHAR(20),Budget INT); INSERT INTO City_Budget(City,Department,Budget) VALUES('Vancouver','Transportation',35000000); INSERT INTO City_Budget(City,Department,Budget) VALUES('Vancouver','Public Services',60000000); INSERT INTO City_Budget(City,Department,Budget) VALUES('Ottawa','Transportation',28000000); INSERT INTO City_Budget(City,Department,Budget) VALUES('Ottawa','Public Services',55000000); | SELECT City, SUM(Budget) FROM City_Budget WHERE Department = 'Public Services' GROUP BY City; |
What was the total budget for rural infrastructure projects in 2020, grouped by country? | CREATE TABLE rural_infrastructure_projects (id INT PRIMARY KEY,country VARCHAR(50),project_name VARCHAR(100),start_date DATE,end_date DATE,budget DECIMAL(10,2)); | SELECT country, SUM(budget) as total_budget FROM rural_infrastructure_projects WHERE YEAR(start_date) = 2020 GROUP BY country; |
Which cities have insufficient disaster funding and low disaster preparedness? | CREATE TABLE DisasterFunding (id INT PRIMARY KEY,city VARCHAR(255),funding FLOAT); CREATE VIEW UnderfundedCities AS SELECT city,funding FROM DisasterFunding WHERE funding < (SELECT AVG(funding) FROM DisasterFunding); CREATE TABLE DisasterPreparedness (id INT PRIMARY KEY,city VARCHAR(255),preparedness INT); | SELECT uc.city, uc.funding, dp.preparedness FROM UnderfundedCities uc JOIN DisasterPreparedness dp ON uc.city = dp.city WHERE dp.preparedness < 50; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.