instruction
stringlengths 0
1.06k
| input
stringlengths 11
5.3k
| response
stringlengths 2
4.44k
|
---|---|---|
What are the top 3 software categories with the highest severity level of vulnerabilities in the last 6 months?
|
CREATE TABLE vulnerabilities (id INT,timestamp TIMESTAMP,software VARCHAR(255),category VARCHAR(255),severity VARCHAR(255)); INSERT INTO vulnerabilities (id,timestamp,software,category,severity) VALUES (1,'2022-01-01 10:00:00','Firefox','browser','high'),(2,'2022-04-02 15:00:00','Windows','OS','medium');
|
SELECT category, MAX(severity) as max_severity, COUNT(*) as vulnerability_count FROM vulnerabilities WHERE timestamp >= DATE_SUB(CURRENT_TIMESTAMP(), INTERVAL 6 MONTH) GROUP BY category ORDER BY max_severity DESC, vulnerability_count DESC LIMIT 3;
|
What is the total number of public transportation trips taken by people from historically underrepresented communities in each year?
|
CREATE TABLE trip (id INT,year INT,gender VARCHAR(10),trips INT,community VARCHAR(255)); INSERT INTO trip (id,year,gender,trips,community) VALUES (1,2018,'Male',50000,'White'),(2,2018,'Female',55000,'African American'),(3,2019,'Male',60000,'Hispanic'),(4,2019,'Female',65000,'Asian'),(5,2020,'Male',70000,'Native American'),(6,2020,'Female',75000,'Pacific Islander'),(7,2021,'Male',80000,'White'),(8,2021,'Female',85000,'African American');
|
SELECT year, SUM(trips) FROM trip WHERE community != 'White' GROUP BY year
|
What is the minimum price of Terbium in Asia?
|
CREATE TABLE terbium_prices (region VARCHAR(255),price DECIMAL(10,2)); INSERT INTO terbium_prices (region,price) VALUES ('China',350.00),('Japan',330.00),('India',370.00);
|
SELECT MIN(price) FROM terbium_prices WHERE region = 'China' OR region = 'Japan' OR region = 'India';
|
Add a new vendor named 'XYZ Defense' to the vendor_contracts table with a vendor_id of 123
|
CREATE TABLE vendor_contracts (vendor_id INT,vendor_name VARCHAR(50),contract_id INT,contract_value DECIMAL(10,2));
|
INSERT INTO vendor_contracts (vendor_id, vendor_name) VALUES (123, 'XYZ Defense');
|
What was the number of unique users who streamed a Japanese artist's songs in 2020?
|
CREATE TABLE Japanese_Streaming (user INT,artist VARCHAR(50),year INT); INSERT INTO Japanese_Streaming (user,artist,year) VALUES (1,'Utada Hikaru',2018),(1,'Perfume',2019),(2,'Utada Hikaru',2020),(2,'Perfume',2020),(3,'Utada Hikaru',2021),(3,'Perfume',2020);
|
SELECT artist, COUNT(DISTINCT user) FROM Japanese_Streaming WHERE year = 2020 GROUP BY artist;
|
What is the total cargo weight transported by vessels from Japan to the US in the last 6 months?
|
CREATE TABLE Ports (id INT,name VARCHAR(50),country VARCHAR(50)); CREATE TABLE CargoTransports (id INT,vessel_id INT,weight INT,transport_time TIMESTAMP,source_port_id INT,destination_port_id INT);
|
SELECT SUM(weight) FROM CargoTransports WHERE transport_time > NOW() - INTERVAL '6 months' AND source_port_id IN (SELECT id FROM Ports WHERE country = 'Japan') AND destination_port_id IN (SELECT id FROM Ports WHERE country = 'US');
|
What is the average salary of workers in the construction industry by region?
|
CREATE TABLE ConstructionSalaries (WorkerID INT,Company VARCHAR(50),Region VARCHAR(50),Salary DECIMAL(10,2)); INSERT INTO ConstructionSalaries (WorkerID,Company,Region,Salary) VALUES (1,'Company A','North America',6000),(2,'Company B','South America',7000),(3,'Company C','Europe',8000);
|
SELECT Region, AVG(Salary) as AvgSalary FROM ConstructionSalaries WHERE Industry = 'Construction' GROUP BY Region;
|
Which students have a mental health score below the average for their grade level?
|
CREATE TABLE student_mental_health (student_id INT,grade_level INT,mental_health_score INT); INSERT INTO student_mental_health (student_id,grade_level,mental_health_score) VALUES (1,6,75),(2,7,80),(3,6,85),(4,7,70),(5,6,70),(6,7,85),(7,6,90);
|
SELECT smh.student_id, smh.grade_level, smh.mental_health_score FROM student_mental_health smh JOIN (SELECT grade_level, AVG(mental_health_score) as avg_mh FROM student_mental_health GROUP BY grade_level) sub ON smh.grade_level = sub.grade_level WHERE smh.mental_health_score < sub.avg_mh;
|
Add a record for the 'Javan Rhino' to the Animals table.
|
CREATE TABLE Animals (id INT,name VARCHAR(255),population INT,status VARCHAR(255));
|
INSERT INTO Animals (id, name, population, status) VALUES (4, 'Javan Rhino', 67, 'Critically Endangered');
|
What is the total number of research grants awarded to faculty members in the College of Health Sciences who identify as African American or Black?
|
CREATE TABLE health_grants (grant_id INT,grant_amount DECIMAL(10,2),grant_recipient VARCHAR(50),recipient_identity VARCHAR(50)); INSERT INTO health_grants (grant_id,grant_amount,grant_recipient,recipient_identity) VALUES (1,35000.00,'Prof. Rivera','Hispanic'),(2,45000.00,'Prof. Thompson','African American'),(3,55000.00,'Prof. Wang','Asian'),(4,65000.00,'Prof. Lopez','Latino'),(5,25000.00,'Prof. Jackson','African American');
|
SELECT COUNT(*) FROM health_grants WHERE grant_recipient LIKE '%College of Health Sciences%' AND recipient_identity IN ('African American', 'Black');
|
What is the average number of likes per post for users in 'CA' region?
|
CREATE TABLE likes (id INT,post_id INT,user_id INT,like_count INT); INSERT INTO likes (id,post_id,user_id,like_count) VALUES (1,1,1,50),(2,2,1,100);
|
SELECT AVG(likes.like_count) FROM posts JOIN likes ON posts.id = likes.post_id JOIN users ON posts.user_id = users.id WHERE users.region = 'CA' GROUP BY posts.id;
|
What is the average depth of all deep-sea volcanoes in the Atlantic Ocean?
|
CREATE TABLE deep_sea_volcanoes (volcano_id INT,location VARCHAR(50),avg_depth FLOAT); INSERT INTO deep_sea_volcanoes (volcano_id,location,avg_depth) VALUES (1,'Pacific Ocean',2000.0),(2,'Atlantic Ocean',1500.0),(3,'Indian Ocean',1800.0);
|
SELECT AVG(avg_depth) FROM deep_sea_volcanoes WHERE location = 'Atlantic Ocean';
|
What is the total number of digital assets issued by companies based in the US, and how many of those are smart contracts?
|
CREATE TABLE Companies (company_id INT,company_name VARCHAR(255),company_country VARCHAR(255)); INSERT INTO Companies (company_id,company_name,company_country) VALUES (1,'Ethereum Foundation','Switzerland'),(2,'ConsenSys','US'),(3,'Cardano Foundation','Switzerland'); CREATE TABLE DigitalAssets (asset_id INT,asset_name VARCHAR(255),company_id INT,is_smart_contract BOOLEAN); INSERT INTO DigitalAssets (asset_id,asset_name,company_id,is_smart_contract) VALUES (1,'ETH',2,false),(2,'DAI',2,true),(3,'ADA',3,false);
|
SELECT SUM(CASE WHEN DigitalAssets.company_country = 'US' THEN 1 ELSE 0 END) AS total_us_assets, SUM(CASE WHEN DigitalAssets.company_country = 'US' AND DigitalAssets.is_smart_contract = true THEN 1 ELSE 0 END) AS us_smart_contracts FROM DigitalAssets INNER JOIN Companies ON DigitalAssets.company_id = Companies.company_id;
|
Identify the average duration of workouts for users who have checked in more than 30 times
|
CREATE TABLE user_workout_durations (user_id INT,duration INT);
|
SELECT AVG(duration) as avg_duration FROM user_workout_durations WHERE user_id IN (SELECT user_id FROM user_check_ins GROUP BY user_id HAVING COUNT(check_in_id) > 30);
|
What are the departments with the highest total salary expenses?
|
CREATE TABLE Employees (EmployeeID INT,Department VARCHAR(20),Salary DECIMAL(10,2));CREATE VIEW DepartmentSalaries AS SELECT Department,SUM(Salary) as TotalSalary FROM Employees GROUP BY Department;
|
SELECT Department FROM DepartmentSalaries WHERE ROW_NUMBER() OVER(ORDER BY TotalSalary DESC) <= 3;
|
What is the minimum response time for emergency calls in each region?
|
CREATE TABLE emergency_calls (id INT,region VARCHAR(10),response_time INT); INSERT INTO emergency_calls (id,region,response_time) VALUES (1,'west',120),(2,'west',150),(3,'east',90);
|
SELECT region, MIN(response_time) FROM emergency_calls GROUP BY region;
|
What is the total budget for community development initiatives per initiative type in the 'community_development' table?
|
CREATE TABLE community_development (initiative_type VARCHAR(255),state VARCHAR(255),initiative_name VARCHAR(255),budget INT); INSERT INTO community_development (initiative_type,state,initiative_name,budget) VALUES ('Youth Center','California','Oakland Youth Hub',200000),('Library','Texas','Austin Public Library',300000);
|
SELECT initiative_type, SUM(budget) FROM community_development GROUP BY initiative_type;
|
What is the average energy consumption (in kWh) of households in Jakarta and Kuala Lumpur?
|
CREATE TABLE household_energy_consumption (household_id INT,city VARCHAR(50),consumption_kwh FLOAT); INSERT INTO household_energy_consumption (household_id,city,consumption_kwh) VALUES (1,'Jakarta',220.3),(2,'Kuala Lumpur',250.9),(3,'Jakarta',270.1),(4,'Kuala Lumpur',230.5),(5,'Jakarta',260.4),(6,'Kuala Lumpur',280.1);
|
SELECT AVG(consumption_kwh) FROM household_energy_consumption WHERE city IN ('Jakarta', 'Kuala Lumpur');
|
Update the location of the shark sighting in the Pacific Ocean
|
CREATE TABLE shark_sightings (id INT PRIMARY KEY,species VARCHAR(255),location VARCHAR(255),sighting_date DATE); INSERT INTO shark_sightings (id,species,location,sighting_date) VALUES (1,'Hammerhead Shark','Pacific Ocean','2023-03-11');
|
UPDATE shark_sightings SET location = 'North Pacific' WHERE sighting_date = '2023-03-11';
|
What is the total number of peacekeeping operations led by women in the last 5 years?
|
CREATE TABLE peacekeeping_ops (id INT,leader VARCHAR(50),start_date DATE); INSERT INTO peacekeeping_ops (id,leader,start_date) VALUES (1,'Major Anya','2018-01-01'); INSERT INTO peacekeeping_ops (id,leader,start_date) VALUES (2,'Colonel Nguyen','2019-01-01'); INSERT INTO peacekeeping_ops (id,leader,start_date) VALUES (3,'Lieutenant Rodriguez','2020-01-01');
|
SELECT COUNT(*) as total_women_led_ops FROM peacekeeping_ops WHERE leader LIKE 'Captain%' OR leader LIKE 'Major%' OR leader LIKE 'Colonel%' OR leader LIKE 'General%' OR leader LIKE 'Lieutenant%' AND start_date >= DATEADD(year, -5, GETDATE());
|
What is the minimum funding received by a biotech startup in the USA?
|
CREATE SCHEMA if not exists biotech;CREATE TABLE if not exists biotech.startups (id INT PRIMARY KEY,name VARCHAR(100),country VARCHAR(50),funding DECIMAL(10,2)); INSERT INTO biotech.startups (id,name,country,funding) VALUES (1,'StartupA','USA',1500000.00),(2,'StartupB','USA',2000000.00),(3,'StartupC','Canada',1200000.00);
|
SELECT MIN(funding) FROM biotech.startups WHERE country = 'USA';
|
What is the total budget of ethical AI and accessibility tech projects?
|
CREATE TABLE grants (grant_id INT,name VARCHAR(50),budget DECIMAL(10,2),project_type VARCHAR(50)); INSERT INTO grants (grant_id,name,budget,project_type) VALUES (1,'Ethical AI Research',400000,'ethical AI'); INSERT INTO grants (grant_id,name,budget,project_type) VALUES (2,'Accessibility Tech Development',600000,'accessibility tech'); INSERT INTO grants (grant_id,name,budget,project_type) VALUES (3,'Digital Divide Education',500000,'digital divide');
|
SELECT SUM(budget) FROM grants WHERE project_type IN ('ethical AI', 'accessibility tech');
|
What is the total budget for transportation projects in Illinois, categorized by project type and funding source?
|
CREATE TABLE Projects (id INT,state VARCHAR(2),project_type VARCHAR(10),funding_source VARCHAR(10),budget INT); INSERT INTO Projects (id,state,project_type,funding_source,budget) VALUES (1,'IL','Road','Federal',1000000),(2,'IL','Rail','State',500000),(3,'IL','Bridge','Local',750000);
|
SELECT project_type, funding_source, SUM(budget) FROM Projects WHERE state = 'IL' GROUP BY project_type, funding_source;
|
What is the average mass of spacecraft manufactured by 'Interstellar Inc.'?
|
CREATE TABLE spacecraft (id INT,name VARCHAR(255),manufacturer VARCHAR(255),mass FLOAT); INSERT INTO spacecraft (id,name,manufacturer,mass) VALUES (1,'Voyager 1','Galactic Pioneers Inc.',770.),(2,'Voyager 2','Galactic Pioneers Inc.',780.),(3,'New Horizons','Space Explorers Ltd.',1010.),(4,'ISS','Interstellar Inc.',420.);
|
SELECT AVG(mass) FROM spacecraft WHERE manufacturer = 'Interstellar Inc.';
|
Update artist's nationality
|
CREATE TABLE Artists (ArtistID INT,Name VARCHAR(100),Nationality VARCHAR(50),BirthYear INT,DeathYear INT);
|
UPDATE Artists SET Nationality = 'German' WHERE ArtistID = 1 AND Name = 'Leonardo da Vinci';
|
Update the name of the product with product_id 102 to 'Gelato' in the 'products' table
|
CREATE TABLE products (product_id INT,name VARCHAR(255),price DECIMAL(5,2));
|
UPDATE products SET name = 'Gelato' WHERE product_id = 102;
|
Get the number of threat intelligence reports submitted in the last 6 months
|
CREATE TABLE threat_intelligence (report_id INT,submission_date DATE);
|
SELECT COUNT(*) FROM threat_intelligence WHERE submission_date >= NOW() - INTERVAL '6 months';
|
What is the average number of artworks in each artist's portfolio?
|
CREATE TABLE ArtistPortfolio (ArtistID INT,ArtID INT); INSERT INTO ArtistPortfolio (ArtistID,ArtID) VALUES (1,1),(1,2),(2,3),(2,4),(3,5),(3,6),(4,7),(5,8),(5,9),(6,10),(6,11),(7,12),(8,13),(8,14),(9,15),(9,16),(10,17),(10,18);
|
SELECT AVG(ArtworksPerArtist) FROM (SELECT ArtistID, COUNT(*) OVER (PARTITION BY ArtistID) as ArtworksPerArtist FROM ArtistPortfolio);
|
List the number of multimodal trips in Seoul involving public transportation and shared e-scooters.
|
CREATE TABLE multimodal_trips (trip_id INT,trip_start_time TIMESTAMP,trip_end_time TIMESTAMP,trip_modes VARCHAR(50)); CREATE VIEW seoul_trips AS SELECT * FROM multimodal_trips WHERE trip_modes LIKE '%public%' AND trip_modes LIKE '%e-scooter%';
|
SELECT COUNT(*) FROM seoul_trips;
|
What is the maximum cost of accommodations for students with a hearing impairment?
|
CREATE TABLE Accommodations(student_id INT,accommodation_id INT,cost DECIMAL(5,2),disability TEXT);
|
SELECT MAX(cost) FROM Accommodations WHERE disability LIKE '%hearing%';
|
What is the total amount of donations made by 'Hope Foundation' to 'Education' projects in 'Africa' after 2015?
|
CREATE TABLE donations (id INT,donor VARCHAR(255),project VARCHAR(255),region VARCHAR(255),amount DECIMAL(10,2),donation_date DATE); INSERT INTO donations (id,donor,project,region,amount,donation_date) VALUES (1,'Hope Foundation','Education','Africa',5000,'2016-01-01');
|
SELECT SUM(amount) FROM donations WHERE donor = 'Hope Foundation' AND project = 'Education' AND region = 'Africa' AND donation_date > '2015-12-31';
|
What is the total number of community health workers by race/ethnicity?
|
CREATE TABLE community_health_workers (worker_id INT,name TEXT,race TEXT); INSERT INTO community_health_workers (worker_id,name,race) VALUES (1,'Alice','Hispanic'),(2,'Bob','Asian'),(3,'Charlie','African American'),(4,'Diana','White');
|
SELECT race, COUNT(*) FROM community_health_workers GROUP BY race;
|
Find the top 2 riskiest regions with the highest average claim amount in Australia, ordered by the total claim amount in descending order.
|
CREATE TABLE Claims (PolicyType VARCHAR(20),ClaimAmount DECIMAL(10,2),Region VARCHAR(50)); INSERT INTO Claims VALUES ('Auto',5000,'New South Wales'); INSERT INTO Claims VALUES ('Home',3000,'New South Wales'); INSERT INTO Claims VALUES ('Auto',4000,'Queensland'); INSERT INTO Claims VALUES ('Home',6000,'Queensland');
|
SELECT Region, AVG(ClaimAmount) AS AvgClaimAmount, SUM(ClaimAmount) AS TotalClaimAmount FROM Claims WHERE Country = 'Australia' GROUP BY Region ORDER BY TotalClaimAmount DESC, AvgClaimAmount DESC LIMIT 2;
|
Count the number of community health workers in the 'CHW_Demographics' table who identify as African American.
|
CREATE TABLE CHW_Demographics (CHW_ID INT,Age INT,Ethnicity VARCHAR(255));
|
SELECT COUNT(*) as CountOfCHW FROM CHW_Demographics WHERE Ethnicity = 'African American';
|
What is the total number of articles written about 'Politics' in the 'news_articles' table?
|
CREATE TABLE news_articles (id INT,title VARCHAR(100),category VARCHAR(30)); INSERT INTO news_articles (id,title,category) VALUES (1,'Political Update','Politics'); INSERT INTO news_articles (id,title,category) VALUES (2,'Sports News','Sports'); INSERT INTO news_articles (id,title,category) VALUES (3,'Movie Review','Entertainment'); INSERT INTO news_articles (id,title,category) VALUES (4,'Political Analysis','Politics');
|
SELECT COUNT(*) FROM news_articles WHERE category = 'Politics';
|
Update the population of the 'Koala' species in the 'animals' table
|
CREATE TABLE animals (id INT PRIMARY KEY,name VARCHAR(50),species VARCHAR(50),population INT);
|
UPDATE animals SET population = 1200 WHERE species = 'Koala';
|
List all the traditional art forms, their origins, and the communities that practice them.
|
CREATE TABLE Arts (id INT,name TEXT,origin TEXT); INSERT INTO Arts (id,name,origin) VALUES (1,'Ukara Paintings','Tanzania'); CREATE TABLE Communities (id INT,art_id INT,name TEXT); INSERT INTO Communities (id,art_id,name) VALUES (1,1,'Kurya Tribe');
|
SELECT A.name, A.origin, C.name FROM Arts A INNER JOIN Communities C ON A.id = C.art_id;
|
Determine the average water usage in cubic meters for the locations 'Chicago' and 'Miami' for the year 2019
|
CREATE TABLE water_usage (id INT PRIMARY KEY,year INT,location VARCHAR(50),usage FLOAT); INSERT INTO water_usage (id,year,location,usage) VALUES (1,2018,'Chicago',1234.56),(2,2019,'Chicago',1567.89),(3,2020,'Chicago',1890.12),(4,2018,'Miami',2234.56),(5,2019,'Miami',2567.89),(6,2020,'Miami',2890.12);
|
SELECT AVG(usage) FROM water_usage WHERE year = 2019 AND location IN ('Chicago', 'Miami');
|
Which size categories in the fashion_trends table are the most popular among customers in the US?
|
CREATE TABLE fashion_trends (id INT PRIMARY KEY,size VARCHAR(10),country VARCHAR(20),popularity INT); INSERT INTO fashion_trends (id,size,country,popularity) VALUES (1,'XS','US',100),(2,'S','US',500),(3,'M','US',700);
|
SELECT size, MAX(popularity) FROM fashion_trends WHERE country = 'US' GROUP BY size;
|
How many startups have a diverse founding team (at least two founders with different genders)?
|
CREATE TABLE startup (id INT,name TEXT,founder_gender TEXT); INSERT INTO startup (id,name,founder_gender) VALUES (1,'Ecobnb','Male'),(2,'Ecobnb','Female'),(3,'Babbel','Male');
|
SELECT COUNT(*) FROM startup JOIN (SELECT startup_id, COUNT(DISTINCT founder_gender) AS gender_count FROM startup GROUP BY startup_id) AS subquery ON startup.id = subquery.startup_id WHERE gender_count > 1;
|
List all sustainable building projects in Texas with a cost greater than $5 million.
|
CREATE TABLE Sustainable_Projects (project_id INT,project_name VARCHAR(50),location VARCHAR(50),cost FLOAT); INSERT INTO Sustainable_Projects VALUES (8888,'Hydroelectric Dam','Texas',12000000);
|
SELECT project_id, project_name, location, cost FROM Sustainable_Projects WHERE location = 'Texas' AND cost > 5000000;
|
List the teams that have not hosted any home games
|
CREATE TABLE sports_teams (team_id INT,team_name VARCHAR(50),stadium VARCHAR(50)); INSERT INTO sports_teams (team_id,team_name,stadium) VALUES (1,'TeamA','StadiumA'),(2,'TeamB','StadiumB'),(3,'TeamC','StadiumC'),(4,'TeamD',NULL);
|
SELECT s.team_name FROM sports_teams s WHERE s.stadium IS NULL;
|
What is the total donation amount per program, ordered by the total donation amount in descending order?
|
CREATE TABLE donors_ext (id INT,name VARCHAR(50),donation_amount DECIMAL(10,2),donation_date DATE,program VARCHAR(50)); INSERT INTO donors_ext (id,name,donation_amount,donation_date,program) VALUES (1,'Alice',500.00,'2022-02-01','Refugee Support'),(2,'Bob',300.00,'2022-03-10','Disaster Response');
|
SELECT program, SUM(donation_amount) AS total_donation, ROW_NUMBER() OVER (ORDER BY SUM(donation_amount) DESC) AS donation_rank FROM donors_ext GROUP BY program ORDER BY donation_rank;
|
Delete records with donation amounts less than $100.00
|
CREATE TABLE Donations (donor_id INT,donation_amount DECIMAL(10,2),donation_date DATE,country VARCHAR(50)); INSERT INTO Donations (donor_id,donation_amount,donation_date,country) VALUES (1,500.00,'2021-09-01','USA'),(2,300.00,'2021-07-15','Canada'),(3,700.00,'2021-10-20','Mexico'),(4,250.00,'2021-06-05','USA'),(5,600.00,'2021-08-30','Canada'),(6,50.00,'2021-05-01','Brazil');
|
DELETE FROM Donations WHERE donation_amount < 100.00;
|
What is the number of reported cases of influenza, grouped by month and region?
|
CREATE TABLE influenza_data (id INT,month TEXT,region TEXT,cases INT); INSERT INTO influenza_data (id,month,region,cases) VALUES (1,'January','Region A',50); INSERT INTO influenza_data (id,month,region,cases) VALUES (2,'February','Region A',75); INSERT INTO influenza_data (id,month,region,cases) VALUES (3,'March','Region B',100);
|
SELECT month, region, SUM(cases) as total_cases FROM influenza_data GROUP BY month, region;
|
What is the total quantity of fish harvested per month for each species at Farm D?
|
CREATE TABLE aquafarms (id INT,name TEXT); INSERT INTO aquafarms (id,name) VALUES (1,'Farm A'),(2,'Farm B'),(3,'Farm C'),(4,'Farm D'); CREATE TABLE harvest_data (aquafarm_id INT,species TEXT,harvested_quantity INT,timestamp TIMESTAMP);
|
SELECT species, EXTRACT(MONTH FROM timestamp) AS month, SUM(harvested_quantity) AS total_harvested FROM harvest_data JOIN aquafarms ON harvest_data.aquafarm_id = aquafarms.id WHERE aquafarm_id = 4 GROUP BY species, month;
|
What is the average age of animals in the habitat preservation program?
|
CREATE TABLE habitat_animals (animal_id INT,age INT); INSERT INTO habitat_animals (animal_id,age) VALUES (1,5),(2,3),(3,7),(4,4);
|
SELECT AVG(age) FROM habitat_animals;
|
How many visitors attended cultural events by age group in the last 5 years?
|
CREATE TABLE event_visitors (id INT,event_name VARCHAR(50),year INT,visitor_age INT,visitor_count INT);
|
SELECT year, FLOOR(visitor_age / 10) * 10 as age_group, SUM(visitor_count) as total_visitors FROM event_visitors WHERE year >= 2017 GROUP BY year, FLOOR(visitor_age / 10);
|
Insert a new record into the 'student_mental_health' table
|
CREATE TABLE student_mental_health (student_id INT PRIMARY KEY,mental_health_score INT,date_recorded DATE);
|
INSERT INTO student_mental_health (student_id, mental_health_score, date_recorded) VALUES (105, 80, '2022-07-01');
|
What is the average depth of mangrove habitats?
|
CREATE TABLE species (id INT,name VARCHAR(255),habitat VARCHAR(255),depth FLOAT); INSERT INTO species (id,name,habitat,depth) VALUES (1,'Clownfish','Coral Reef',20.0); INSERT INTO species (id,name,habitat,depth) VALUES (2,'Blue Whale','Open Ocean',2000.0); INSERT INTO species (id,name,habitat,depth) VALUES (3,'Sea Otter','Kelp Forest',50.0); INSERT INTO species (id,name,habitat,depth) VALUES (4,'Mud Crab','Mangrove',2.0);
|
SELECT AVG(depth) FROM species WHERE habitat = 'Mangrove';
|
Which support programs were offered in a specific region in the past 6 months?
|
CREATE TABLE Regions (RegionID INT,Region VARCHAR(50)); INSERT INTO Regions (RegionID,Region) VALUES (1,'Northeast'); INSERT INTO Regions (RegionID,Region) VALUES (2,'West');
|
SELECT SupportPrograms.ProgramName FROM SupportPrograms INNER JOIN Regions ON SupportPrograms.RegionID = Regions.RegionID WHERE Regions.Region = 'Northeast' AND SupportPrograms.Date BETWEEN DATEADD(month, -6, GETDATE()) AND GETDATE();
|
Identify the number of unique organizations involved in each AI safety sub-field.
|
CREATE TABLE organization (org_id INT,org_name VARCHAR(255)); INSERT INTO organization VALUES (1,'University of Washington'),(2,'Stanford University');CREATE TABLE sub_field (sub_field_id INT,sub_field_name VARCHAR(255)); INSERT INTO sub_field VALUES (1,'AI Safety'),(2,'Explainable AI'),(3,'AI Fairness');CREATE TABLE org_sub_field (org_id INT,sub_field_id INT); INSERT INTO org_sub_field VALUES (1,1),(1,2),(2,1),(2,3);
|
SELECT s.sub_field_name, COUNT(DISTINCT o.org_id) as num_orgs FROM organization o INNER JOIN org_sub_field osf ON o.org_id = osf.org_id INNER JOIN sub_field s ON osf.sub_field_id = s.sub_field_id WHERE s.sub_field_name LIKE '%AI Safety%' GROUP BY s.sub_field_name;
|
List all companies that have not had any investment rounds
|
CREATE TABLE investment_rounds (company_id INT); INSERT INTO investment_rounds (company_id) VALUES (1); INSERT INTO investment_rounds (company_id) VALUES (3);
|
SELECT c.id, c.name FROM company c LEFT JOIN investment_rounds ir ON c.id = ir.company_id WHERE ir.company_id IS NULL;
|
What was the market share for each organization in the South region in Q2 2021?
|
CREATE TABLE market_share (market_id INT,organization_id INT,region VARCHAR(255),quarter INT,year INT,market_share DECIMAL(4,2));
|
SELECT organization_id, SUM(market_share) as total_market_share FROM market_share WHERE region = 'South' AND quarter = 2 AND year = 2021 GROUP BY organization_id;
|
List the top 5 users with the most number of followers in the social_media schema?
|
CREATE TABLE users (id INT,name VARCHAR(50),followers INT); CREATE TABLE posts (user_id INT,post_text VARCHAR(255));
|
SELECT u.name, u.followers FROM users u JOIN (SELECT user_id, MAX(followers) AS max_followers FROM users GROUP BY user_id) f ON u.id = f.user_id ORDER BY u.followers DESC LIMIT 5;
|
Who are the top 3 cultural event organizers with the highest average attendance in Asia in the last year?
|
CREATE TABLE CulturalEvents (event_date DATE,organizer VARCHAR(50),num_attendees INT); INSERT INTO CulturalEvents (event_date,organizer,num_attendees) VALUES ('2021-04-01','Asian Arts Council',1200),('2021-04-02','Asian Arts Council',1500),('2021-04-03','Asian Arts Council',800),('2021-05-01','Asian Heritage Foundation',900),('2021-05-02','Asian Heritage Foundation',1200),('2021-05-03','Asian Heritage Foundation',1500),('2021-06-01','Asian Cultural Society',800),('2021-06-02','Asian Cultural Society',900),('2021-06-03','Asian Cultural Society',1200);
|
SELECT organizer, AVG(num_attendees) FROM CulturalEvents WHERE event_date >= DATEADD(YEAR, -1, GETDATE()) AND organizer IN ('Asian Arts Council', 'Asian Heritage Foundation', 'Asian Cultural Society') GROUP BY organizer ORDER BY AVG(num_attendees) DESC LIMIT 3;
|
List all workers, their roles, and the mining sites they oversee that have a high water consumption rate
|
CREATE TABLE Employees (EmployeeID INT,FirstName VARCHAR(50),LastName VARCHAR(50),JobTitle VARCHAR(50),SupervisesSiteID INT); INSERT INTO Employees (EmployeeID,FirstName,LastName,JobTitle,SupervisesSiteID) VALUES (1,'John','Doe','Site Manager',1),(2,'Jane','Doe','Environmental Manager',2),(3,'Bob','Smith','Resource Manager',3); CREATE TABLE MiningSites (SiteID INT,SiteName VARCHAR(50),Location VARCHAR(50),WaterConsumptionRate INT); INSERT INTO MiningSites (SiteID,SiteName,Location,WaterConsumptionRate) VALUES (1,'Site A','New York',1000),(2,'Site B','Ohio',1200),(3,'Site C','Alberta',1500);
|
SELECT e.FirstName, e.LastName, e.JobTitle, s.SiteName, s.Location, s.WaterConsumptionRate FROM Employees e INNER JOIN MiningSites s ON e.SupervisesSiteID = s.SiteID WHERE s.WaterConsumptionRate > 1200;
|
What is the total value of all transactions involving digital assets with a market capitalization greater than $1 billion?
|
CREATE TABLE digital_assets (asset_id INT,asset_name VARCHAR(255),network VARCHAR(255),market_cap DECIMAL(10,2)); INSERT INTO digital_assets (asset_id,asset_name,network,market_cap) VALUES (1,'ETH','ethereum',2000000000),(2,'USDC','ethereum',500000000),(3,'UNI','ethereum',3000000000),(4,'BTC','bitcoin',6000000000); CREATE TABLE transactions (transaction_id INT,asset_id INT,value DECIMAL(10,2)); INSERT INTO transactions (transaction_id,asset_id,value) VALUES (1,1,100),(2,1,200),(3,2,50),(4,2,75),(5,3,300),(6,3,400),(7,4,5000),(8,4,6000);
|
SELECT SUM(t.value) as total_value FROM digital_assets d JOIN transactions t ON d.asset_id = t.asset_id WHERE d.market_cap > 1000000000;
|
How many rural health clinics are there in Australia and New Zealand that have a patient satisfaction score greater than 85?
|
CREATE TABLE clinics (country VARCHAR(20),clinic_name VARCHAR(50),patient_satisfaction_score INT); INSERT INTO clinics (country,clinic_name,patient_satisfaction_score) VALUES ('Australia','Clinic E',90),('Australia','Clinic F',80),('New Zealand','Clinic G',88),('New Zealand','Clinic H',92);
|
SELECT country, COUNT(*) FROM clinics WHERE patient_satisfaction_score > 85 GROUP BY country;
|
What is the percentage of international tourists in Southeast Asia who spent more than $1000 in 2019?
|
CREATE TABLE SpendingData (Year INT,Country VARCHAR(255),Tourists INT,Spending DECIMAL(10,2)); INSERT INTO SpendingData (Year,Country,Tourists,Spending) VALUES (2019,'Indonesia',12000000,650),(2019,'Malaysia',9000000,800),(2019,'Singapore',7000000,1200),(2019,'Thailand',15000000,900),(2019,'Philippines',8000000,450);
|
SELECT (SUM(CASE WHEN Spending > 1000 THEN 1 ELSE 0 END) * 100.0 / COUNT(*)) AS Percentage FROM SpendingData WHERE Country IN ('Indonesia', 'Malaysia', 'Singapore', 'Thailand', 'Philippines') AND Year = 2019;
|
Which dapps belong to the 'Gaming' category and were developed using Solidity?
|
CREATE TABLE smart_contracts (contract_id INT PRIMARY KEY,contract_name VARCHAR(50),developer_id INT,language VARCHAR(20),FOREIGN KEY (developer_id) REFERENCES developers(developer_id)); INSERT INTO smart_contracts (contract_id,contract_name,developer_id,language) VALUES (1,'Contract1',1,'Solidity'); INSERT INTO smart_contracts (contract_id,contract_name,developer_id,language) VALUES (2,'Contract2',2,'Vyper'); CREATE TABLE dapps (dapp_id INT PRIMARY KEY,dapp_name VARCHAR(50),contract_id INT,category VARCHAR(30),FOREIGN KEY (contract_id) REFERENCES smart_contracts(contract_id)); INSERT INTO dapps (dapp_id,dapp_name,contract_id,category) VALUES (1,'Dapp1',1,'Finance'); INSERT INTO dapps (dapp_id,dapp_name,contract_id,category) VALUES (2,'Dapp2',2,'Gaming');
|
SELECT dapps.dapp_name FROM dapps INNER JOIN smart_contracts ON dapps.contract_id = smart_contracts.contract_id WHERE dapps.category = 'Gaming' AND smart_contracts.language = 'Solidity';
|
What is the name and number of parks and recreation centers in each city?
|
CREATE TABLE cities (id INT,name VARCHAR(255)); CREATE TABLE parks (id INT,city_id INT,name VARCHAR(255),number INT); CREATE TABLE recreation_centers (id INT,city_id INT,name VARCHAR(255),number INT);
|
SELECT c.name, p.number AS park_count, rc.number AS recreation_center_count FROM cities c LEFT JOIN parks p ON c.id = p.city_id LEFT JOIN recreation_centers rc ON c.id = rc.city_id;
|
What is the average energy price for the 'West' region between February 15th and February 21st, 2022?
|
CREATE TABLE energy_prices (id INT,region VARCHAR(50),price FLOAT,date DATE); INSERT INTO energy_prices (id,region,price,date) VALUES (1,'West',60.1,'2022-02-15');
|
SELECT region, AVG(price) AS avg_price FROM energy_prices WHERE date BETWEEN '2022-02-15' AND '2022-02-21' AND region = 'West' GROUP BY region;
|
What is the maximum number of cybersecurity incidents reported in Asian countries in the last 3 years?
|
CREATE TABLE cybersecurity_incidents (region VARCHAR(50),year INT,num_incidents INT); INSERT INTO cybersecurity_incidents (region,year,num_incidents) VALUES ('China',2019,5000),('China',2020,6000),('China',2021,7000),('India',2019,4000),('India',2020,5000),('India',2021,6000); INSERT INTO cybersecurity_incidents (region,year,num_incidents) VALUES ('Indonesia',2019,3000),('Indonesia',2020,4000),('Indonesia',2021,5000); INSERT INTO cybersecurity_incidents (region,year,num_incidents) VALUES ('Japan',2019,2000),('Japan',2020,2500),('Japan',2021,3000);
|
SELECT MAX(num_incidents) FROM cybersecurity_incidents WHERE region IN ('China', 'India', 'Indonesia', 'Japan') AND year BETWEEN 2019 AND 2021;
|
Get the number of sustainable brands from each country.
|
CREATE TABLE SUSTAINABLE_BRANDS (brand_id INT PRIMARY KEY,brand_name VARCHAR(50),country VARCHAR(50),sustainable_practices TEXT); INSERT INTO SUSTAINABLE_BRANDS (brand_id,brand_name,country,sustainable_practices) VALUES (1,'BrandA','USA','Organic cotton,fair trade,recycled materials'),(2,'BrandB','Brazil','Organic materials,fair trade'),(3,'BrandC','USA','Recycled materials'),(4,'BrandD','Brazil','Organic materials,fair trade');
|
SELECT country, COUNT(*) FROM SUSTAINABLE_BRANDS GROUP BY country;
|
What is the total number of workouts in each category?
|
CREATE TABLE Workouts (WorkoutID INT,WorkoutName VARCHAR(20),Category VARCHAR(10)); INSERT INTO Workouts (WorkoutID,WorkoutName,Category) VALUES (1,'Treadmill','Cardio'),(2,'Yoga','Strength'),(3,'Cycling','Cardio'),(4,'Push-ups','Strength'),(5,'Squats','Strength');
|
SELECT Category, COUNT(*) FROM Workouts GROUP BY Category;
|
Find the average CO2 emissions reduction of children's garments made from recycled polyester in the United States.
|
CREATE TABLE emissions (id INT,category VARCHAR(255),subcategory VARCHAR(255),age_group VARCHAR(50),material VARCHAR(50),co2_reduction DECIMAL(10,2),country VARCHAR(50)); INSERT INTO emissions (id,category,subcategory,age_group,material,co2_reduction,country) VALUES (1,'Tops','T-Shirts','Children','Recycled Polyester',2.4,'United States'); INSERT INTO emissions (id,category,subcategory,age_group,material,co2_reduction,country) VALUES (2,'Bottoms','Pants','Children','Recycled Polyester',2.2,'United States');
|
SELECT AVG(co2_reduction) FROM emissions WHERE category IN ('Tops', 'Bottoms') AND age_group = 'Children' AND material = 'Recycled Polyester' AND country = 'United States';
|
List the top 3 decentralized applications by the number of smart contracts deployed in the 'Ethereum' network.
|
CREATE TABLE dapps (dapp_name VARCHAR(20),network VARCHAR(20),smart_contracts INT); INSERT INTO dapps (dapp_name,network,smart_contracts) VALUES ('Uniswap','Ethereum',500),('OpenSea','Ethereum',300),('Compound','Ethereum',400);
|
SELECT dapp_name, network, smart_contracts FROM (SELECT dapp_name, network, smart_contracts, ROW_NUMBER() OVER (PARTITION BY network ORDER BY smart_contracts DESC) as rn FROM dapps) x WHERE rn <= 3 AND network = 'Ethereum';
|
What is the difference in data usage in GB between the current month and the same month last year for each customer?
|
CREATE TABLE monthly_usage (customer_id INT,month DATE,data_usage FLOAT); INSERT INTO monthly_usage VALUES (1,'2022-01-01',100),(1,'2021-01-01',110);
|
SELECT customer_id, LAG(SUM(data_usage)/1024/1024/1024, 12) OVER(PARTITION BY customer_id ORDER BY month) as previous_year_usage_gb, SUM(data_usage)/1024/1024/1024 as current_month_usage_gb FROM monthly_usage WHERE month >= DATEADD(month, -12, GETDATE()) GROUP BY customer_id, month;
|
Update a legal aid organization in the 'organizations' table
|
CREATE TABLE organizations (org_id INT PRIMARY KEY,name VARCHAR(255),location VARCHAR(255),type VARCHAR(255),contact_name VARCHAR(255),contact_email VARCHAR(255),contact_phone VARCHAR(20));
|
UPDATE organizations SET location = 'Los Angeles, CA', type = 'Legal Aid' WHERE name = 'Justice for All';
|
Insert a new solar energy project in Mexico with 25 MW capacity in 2022.
|
CREATE TABLE renewable_projects (name TEXT,country TEXT,technology TEXT,capacity_mw INTEGER,year INTEGER);
|
INSERT INTO renewable_projects (name, country, technology, capacity_mw, year) VALUES ('Project D', 'Mexico', 'Solar', 25, 2022);
|
What is the maximum dissolved oxygen level in the fish_stock_4 table for each species?
|
CREATE TABLE fish_stock_4 (species VARCHAR(255),dissolved_oxygen FLOAT); INSERT INTO fish_stock_4 (species,dissolved_oxygen) VALUES ('Tilapia',6.9),('Catfish',5.9),('Salmon',7.3);
|
SELECT species, MAX(dissolved_oxygen) FROM fish_stock_4 GROUP BY species;
|
How many volunteers joined in Q1 2022 from the state of New York?
|
CREATE TABLE volunteers (volunteer_id INT,volunteer_join_date DATE,state VARCHAR(50));
|
SELECT COUNT(volunteer_id) FROM volunteers WHERE QUARTER(volunteer_join_date) = 1 AND state = 'New York' AND YEAR(volunteer_join_date) = 2022;
|
Insert new artists 'Rosalía' and 'Ozuna' into the artists table.
|
CREATE TABLE artists(artist_id INT,name VARCHAR(50));
|
INSERT INTO artists (name) VALUES ('Rosalía'), ('Ozuna');
|
What is the average time between bus departures for a given route in Chicago?
|
CREATE TABLE bus_routes (route_id INT,city VARCHAR(50),avg_time_between_departures TIME); INSERT INTO bus_routes (route_id,city,avg_time_between_departures) VALUES (1,'Chicago','00:15:00'),(2,'Chicago','00:20:00'),(3,'Chicago','00:10:00');
|
SELECT AVG(avg_time_between_departures) FROM bus_routes WHERE city = 'Chicago';
|
What is the total number of employees working in the 'manufacturing' department across all plants in Germany?
|
CREATE TABLE plants (id INT,name TEXT,country TEXT); INSERT INTO plants (id,name,country) VALUES (1,'PlantA','Germany'),(2,'PlantB','France'); CREATE TABLE employees (id INT,name TEXT,department TEXT,plant_id INT); INSERT INTO employees (id,name,department,plant_id) VALUES (1,'John','manufacturing',1),(2,'Jane','engineering',1),(3,'Peter','manufacturing',2);
|
SELECT COUNT(*) FROM employees INNER JOIN plants ON employees.plant_id = plants.id WHERE employees.department = 'manufacturing' AND plants.country = 'Germany';
|
Which ZIP codes in the US have the highest obesity rates?
|
CREATE TABLE obesity_rates (zip TEXT,rate INT); INSERT INTO obesity_rates (zip,rate) VALUES ('12345',40);
|
SELECT zip, AVG(rate) FROM obesity_rates GROUP BY zip HAVING AVG(rate) >= (SELECT AVG(rate) FROM obesity_rates WHERE zip = '12345') ORDER BY AVG(rate) DESC;
|
What is the total number of eco-certified cultural heritage sites?
|
CREATE TABLE eco_certified_sites (site_id INT,site_name TEXT,city TEXT,eco_certified BOOLEAN); INSERT INTO eco_certified_sites (site_id,site_name,city,eco_certified) VALUES (1,'Eco-Park','Rio de Janeiro',true),(2,'Green Castle','Dublin',true),(3,'Sustainable Museum','Paris',false);
|
SELECT COUNT(*) FROM eco_certified_sites WHERE eco_certified = true;
|
What is the average population size for mammals in the 'animals' table with a size greater than 25 square kilometers?
|
CREATE TABLE animals (id INT,name VARCHAR(50),species VARCHAR(50),population_size INT,size_km FLOAT); INSERT INTO animals (id,name,species,population_size,size_km) VALUES (1,'Bear','Ursidae',450,45.6);
|
SELECT AVG(population_size) FROM animals WHERE size_km > 25 AND species = 'Ursidae';
|
What is the maximum power output of a wind turbine in the 'Midwest' region?
|
CREATE TABLE wind_turbines (id INT,region VARCHAR(20),power_output FLOAT); INSERT INTO wind_turbines (id,region,power_output) VALUES (1,'Midwest',3.4),(2,'South',4.2),(3,'Midwest',5.1),(4,'Northeast',2.9);
|
SELECT MAX(power_output) FROM wind_turbines WHERE region = 'Midwest';
|
What are the maximum and minimum operating depths for deep-sea ROVs?
|
CREATE TABLE rovs (name VARCHAR(255),manufacturer VARCHAR(255),max_depth INT,min_depth INT); INSERT INTO rovs (name,manufacturer,max_depth,min_depth) VALUES ('ROV1','Manufacturer1',6000,500);
|
SELECT MAX(max_depth), MIN(min_depth) FROM rovs
|
What is the average depth of all excavation sites in France?
|
CREATE TABLE excavation_sites (id INT,country VARCHAR(255),depth FLOAT); INSERT INTO excavation_sites (id,country,depth) VALUES (1,'France',4.2),(2,'Spain',3.9),(3,'France',4.5);
|
SELECT AVG(depth) FROM excavation_sites WHERE country = 'France';
|
Identify the salesperson who made the most sales for a specific product, showing the salesperson, product, and sales amount.
|
CREATE TABLE sales_person_data (salesperson VARCHAR(20),product VARCHAR(20),sales_amount DECIMAL(10,2)); INSERT INTO sales_person_data VALUES ('John','Laptop',1200.00),('John','Phone',500.00),('Jane','Phone',300.00),('Jane','Tablet',800.00),('John','Tablet',600.00);
|
SELECT salesperson, product, MAX(sales_amount) AS max_sales FROM sales_person_data GROUP BY product;
|
What is the average cost of projects in the 'energy' table?
|
CREATE TABLE energy (id INT,project_name VARCHAR(50),location VARCHAR(50),cost FLOAT); INSERT INTO energy (id,project_name,location,cost) VALUES (1,'Wind Farm','Region C',15000000.00),(2,'Solar Power Plant','City D',20000000.00),(3,'Geothermal Plant','Area E',18000000.00);
|
SELECT AVG(cost) FROM energy;
|
What is the maximum number of emergency calls received in a single hour in each district?
|
CREATE TABLE districts (id INT,name TEXT);CREATE TABLE emergencies (id INT,district_id INT,date_time DATETIME);
|
SELECT d.name, MAX(HOUR(e.date_time)) as hour, COUNT(e.id) as calls FROM districts d JOIN emergencies e ON d.id = e.district_id GROUP BY d.id, hour;
|
Which countries had the most news articles published about them in the 'world_news' table?
|
CREATE TABLE world_news (id INT,headline VARCHAR(255),source VARCHAR(255),published_date DATE,country VARCHAR(255));
|
SELECT country, COUNT(*) as articles_about_country FROM world_news GROUP BY country ORDER BY articles_about_country DESC;
|
What is the total number of marine species that have been observed in the Southern Ocean?
|
CREATE TABLE species_so (id INT,name TEXT,location TEXT); INSERT INTO species_so (id,name,location) VALUES (1,'Krill','Southern Ocean'); INSERT INTO species_so (id,name,location) VALUES (2,'Seal','Atlantic Ocean');
|
SELECT COUNT(*) FROM species_so WHERE location = 'Southern Ocean';
|
What is the change in fairness score for each model from the first to the last observation?
|
CREATE TABLE ModelFairness (model_name TEXT,fairness_score FLOAT,observation_date DATE); INSERT INTO ModelFairness (model_name,fairness_score,observation_date) VALUES ('ModelA',0.85,'2021-01-01'),('ModelA',0.86,'2021-02-01'),('ModelB',0.90,'2021-01-01'),('ModelB',0.91,'2021-02-01');
|
SELECT model_name, LAG(fairness_score) OVER (PARTITION BY model_name ORDER BY observation_date) lag_score, fairness_score, fairness_score - LAG(fairness_score) OVER (PARTITION BY model_name ORDER BY observation_date) change FROM ModelFairness;
|
What is the sum of goals and assists for all ice hockey players from Russia?
|
CREATE TABLE Players (PlayerID INT PRIMARY KEY,Name VARCHAR(100),Age INT,Sport VARCHAR(50),Country VARCHAR(50)); CREATE TABLE Players_Stats (PlayerID INT,Stat VARCHAR(50),Value INT); INSERT INTO Players_Stats (PlayerID,Stat,Value) VALUES (1,'Goals',10); INSERT INTO Players_Stats (PlayerID,Stat,Value) VALUES (1,'Assists',5); INSERT INTO Players_Stats (PlayerID,Stat,Value) VALUES (2,'Goals',15); INSERT INTO Players_Stats (PlayerID,Stat,Value) VALUES (2,'Assists',8);
|
SELECT SUM(Value) as TotalGoalsAndAssists FROM Players_Stats JOIN Players ON Players.PlayerID = Players_Stats.PlayerID WHERE Players.Sport = 'Ice Hockey' AND Players.Country = 'Russia';
|
What is the average calorie count for items in the organic product line?
|
CREATE TABLE products (product_id INT,product_line VARCHAR(20),calorie_count INT); INSERT INTO products (product_id,product_line,calorie_count) VALUES (1,'organic',150),(2,'conventional',200);
|
SELECT AVG(calorie_count) FROM products WHERE product_line = 'organic';
|
Delete records of users who have not interacted with the explainable AI system in the past month
|
CREATE TABLE interactions (id INT,user_id INT,interaction_date DATE); INSERT INTO interactions (id,user_id,interaction_date) VALUES (1,1001,'2022-02-01'),(2,1002,'2022-02-15'),(3,1003,'2022-02-20'),(4,1001,'2022-02-25'),(5,1004,'2022-03-01'),(6,1003,'2022-02-03');
|
DELETE FROM interactions WHERE interaction_date < NOW() - INTERVAL 1 MONTH;
|
How many pollution incidents were reported in the Southern Ocean in 2019?
|
CREATE TABLE southern_ocean_pollution (report_year INT,incident_count INT); INSERT INTO southern_ocean_pollution (report_year,incident_count) VALUES (2019,3),(2018,4);
|
SELECT SUM(incident_count) FROM southern_ocean_pollution WHERE report_year = 2019;
|
What is the maximum amount of data used in a single day by mobile customers in the 'Europe' region?
|
CREATE TABLE usage (id INT,subscriber_id INT,data_usage DECIMAL(10,2),type VARCHAR(10),region VARCHAR(10),usage_date DATE); INSERT INTO usage (id,subscriber_id,data_usage,type,region,usage_date) VALUES (1,1,12.5,'mobile','Europe','2022-01-01'),(2,2,8.0,'mobile','Europe','2022-01-02'),(3,3,15.0,'broadband','Europe','2022-01-03');
|
SELECT MAX(usage.data_usage) AS max_data_usage FROM usage WHERE usage.type = 'mobile' AND usage.region = 'Europe';
|
Find the intersection of providers who work in 'Obstetrics' and 'Pediatrics' specialties?
|
CREATE TABLE providers (id INT,name TEXT,specialty TEXT); INSERT INTO providers (id,name,specialty) VALUES (1,'Dr. Patel','Obstetrics'),(2,'Dr. Kim','Pediatrics'),(3,'Dr. Garcia','Obstetrics and Pediatrics');
|
SELECT name FROM providers WHERE specialty = 'Obstetrics' INTERSECT SELECT name FROM providers WHERE specialty = 'Pediatrics';
|
What is the total funding received by startups founded by people over the age of 40 in the financial technology industry?
|
CREATE TABLE company (id INT,name TEXT,founder_age INT,industry TEXT); INSERT INTO company (id,name,founder_age,industry) VALUES (1,'FinTech',45,'Financial Technology'); INSERT INTO company (id,name,founder_age,industry) VALUES (2,'BankingInnovations',50,'Financial Technology');
|
SELECT SUM(funding_amount) FROM funding INNER JOIN company ON funding.company_id = company.id WHERE company.founder_age > 40 AND company.industry = 'Financial Technology';
|
Find the number of roads in each state that intersect with an interstate.
|
CREATE TABLE Roads (name TEXT,number TEXT,state TEXT);
|
SELECT state, COUNT(*) FROM Roads WHERE number LIKE 'I-%' GROUP BY state;
|
What is the total area of marine protected areas in the 'marine_protected_areas' table, grouped by region?"
|
CREATE TABLE marine_protected_areas (area_name VARCHAR(50),region VARCHAR(50),area_size INT);
|
SELECT region, SUM(area_size) FROM marine_protected_areas GROUP BY region;
|
List all mining sites located in 'CA' and 'NV' that have recorded environmental impact assessments.
|
CREATE TABLE sites (site_id INT,state VARCHAR(2)); CREATE TABLE environmental_impact_assessments (assessment_id INT,site_id INT,assessment_date DATE);
|
SELECT s.site_id, s.state FROM sites s INNER JOIN environmental_impact_assessments e ON s.site_id = e.site_id WHERE s.state IN ('CA', 'NV');
|
What is the average cultural competency score for community health workers by age group?
|
CREATE TABLE community_health_workers (worker_id INT,age INT,cultural_competency_score INT); INSERT INTO community_health_workers (worker_id,age,cultural_competency_score) VALUES (1,35,80),(2,40,85),(3,45,90);
|
SELECT age_group, AVG(cultural_competency_score) FROM (SELECT CASE WHEN age < 40 THEN 'Under 40' ELSE '40 and over' END AS age_group, cultural_competency_score FROM community_health_workers) AS subquery GROUP BY age_group;
|
List all military equipment maintenance activities performed on aircraft in the Asia-Pacific region in the last 6 months.
|
CREATE TABLE equipment_maintenance (maintenance_id INT,maintenance_date DATE,equipment_type VARCHAR(255),region VARCHAR(255)); INSERT INTO equipment_maintenance (maintenance_id,maintenance_date,equipment_type,region) VALUES (1,'2021-12-31','aircraft','Asia-Pacific'),(2,'2022-04-04','tank','Europe'),(3,'2022-06-15','aircraft','Asia-Pacific');
|
SELECT * FROM equipment_maintenance WHERE equipment_type = 'aircraft' AND region = 'Asia-Pacific' AND maintenance_date >= DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH);
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.