instruction stringlengths 0 1.06k | input stringlengths 11 5.3k | response stringlengths 2 4.44k |
|---|---|---|
Show the name and number of art performances in each city. | CREATE TABLE CityPerformances (City VARCHAR(20),ArtPerformance VARCHAR(30),Performances INT); INSERT INTO CityPerformances VALUES ('Portland','Hula',2),('Portland','Flamenco',3),('Seattle','Bharatanatyam',1); CREATE VIEW ArtPerformanceCount AS SELECT City,ArtPerformance,COUNT(*) AS Performances FROM CityPerformances GROUP BY City,ArtPerformance; | SELECT v.City, v.ArtPerformance, v.Performances FROM CityPerformances c JOIN ArtPerformanceCount v ON c.City = v.City AND c.ArtPerformance = v.ArtPerformance; |
How many languages in the database are considered endangered? | CREATE TABLE Languages (LanguageID int,LanguageName text,Status text); INSERT INTO Languages (LanguageID,LanguageName,Status) VALUES (1,'Quechua','Endangered'),(2,'Spanish','Safe'),(3,'Mandarin','Safe'); | SELECT COUNT(*) FROM Languages WHERE Status = 'Endangered'; |
List the top 2 most visited museums in France and Italy, ordered by visitor count | CREATE TABLE museums (id INT,name TEXT,country TEXT,visitors INT); INSERT INTO museums (id,name,country,visitors) VALUES (1,'Museum A','Italy',100000),(2,'Museum B','Italy',120000),(3,'Museum C','France',150000),(4,'Museum D','France',180000); | SELECT name, visitors FROM museums WHERE country IN ('Italy', 'France') ORDER BY visitors DESC LIMIT 2; |
Determine the number of unique artists who performed at festivals in both 2019 and 2021. | CREATE TABLE Festival_Artists (festival_id INT,artist_id INT); INSERT INTO Festival_Artists (festival_id,artist_id) VALUES (1,100),(1,200),(3,100),(4,300),(5,100); | SELECT COUNT(DISTINCT artist_id) as unique_artists FROM Festival_Artists fa1 JOIN Festival_Artists fa2 ON fa1.artist_id = fa2.artist_id WHERE YEAR(fa1.festival_date) = 2019 AND YEAR(fa2.festival_date) = 2021; |
Who is the maintenance technician responsible for bus 123? | CREATE TABLE vehicles (vehicle_id INT,type VARCHAR(255),technician_id INT); INSERT INTO vehicles (vehicle_id,type,technician_id) VALUES (123,'Bus',456),(124,'Tram',789); CREATE TABLE technicians (technician_id INT,name VARCHAR(255)); INSERT INTO technicians (technician_id,name) VALUES (456,'John Doe'),(789,'Jane Smith'); | SELECT technicians.name FROM vehicles INNER JOIN technicians ON vehicles.technician_id = technicians.technician_id WHERE vehicle_id = 123; |
What is the average word count for articles in each category, with categories having less than 5 articles removed from consideration? | CREATE TABLE articles (article_id INT,author VARCHAR(50),title VARCHAR(100),category VARCHAR(50),word_count INT,publication_date DATE); CREATE VIEW article_category AS SELECT category,COUNT(article_id) AS articles_in_category FROM articles GROUP BY category; | SELECT category, AVG(word_count) AS avg_word_count FROM articles WHERE category IN (SELECT category FROM article_category HAVING articles_in_category > 4) GROUP BY category; |
What is the total number of volunteers and total volunteer hours for each program category, ordered by the total number of volunteers in descending order? | CREATE TABLE Volunteers (VolunteerID INT,VolunteerName TEXT,Program TEXT); CREATE TABLE VolunteerHours (VolunteerID INT,Hours INT); CREATE TABLE Programs (Program TEXT,Category TEXT); | SELECT P.Category, COUNT(V.VolunteerID) as NumVolunteers, SUM(VH.Hours) as TotalHours FROM Volunteers V JOIN VolunteerHours VH ON V.VolunteerID = VH.VolunteerID JOIN Programs P ON V.Program = P.Program GROUP BY P.Category ORDER BY NumVolunteers DESC; |
What is the total number of security incidents in the 'Unpatched Systems' category in the last month? | CREATE TABLE incident_counts (id INT,category VARCHAR(255),incident_count INT,incident_date DATE); | SELECT SUM(incident_count) FROM incident_counts WHERE category = 'Unpatched Systems' AND incident_date >= DATEADD(month, -1, GETDATE()); |
What are the top 5 most mentioned brands by users from the US and Canada, excluding any mentions from users with less than 100 followers? | CREATE TABLE users (id INT,name VARCHAR(50),followers INT,country VARCHAR(50)); INSERT INTO users (id,name,followers,country) VALUES (1,'Alice',150,'USA'),(2,'Bob',200,'Canada'),(3,'Charlie',50,'USA'),(4,'David',120,'Canada'); CREATE TABLE brand_mentions (user_id INT,brand VARCHAR(50)); INSERT INTO brand_mentions (user_id,brand) VALUES (1,'CocaCola'),(1,'Pepsi'),(1,'Nike'),(2,'CocaCola'),(2,'Adidas'),(3,'Pepsi'),(4,'Nike'),(4,'Adidas'); | SELECT brand FROM (SELECT brand FROM brand_mentions b JOIN users u ON b.user_id = u.id WHERE u.country IN ('USA', 'Canada') AND u.followers >= 100 UNION SELECT brand FROM brand_mentions b JOIN users u ON b.user_id = u.id WHERE u.country = 'USA' AND u.followers >= 100) AS all_mentions GROUP BY brand ORDER BY COUNT(*) DESC LIMIT 5; |
What is the total quantity of 'Local Eggs' sold this month? | CREATE TABLE produce (id INT,name VARCHAR(255),qty_sold INT); INSERT INTO produce (id,name,qty_sold) VALUES (1,'Local Eggs',750),(2,'Organic Milk',600),(3,'Seasonal Fruits',800); CREATE TABLE date (id INT,date DATE); INSERT INTO date (id,date) VALUES (1,'2022-02-01'),(2,'2022-02-08'),(3,'2022-02-15'); | SELECT SUM(qty_sold) AS total_qty_sold FROM produce WHERE name = 'Local Eggs' AND date IN (SELECT date FROM date WHERE date BETWEEN DATE_SUB(NOW(), INTERVAL 1 MONTH) AND NOW()); |
What is the total number of companies in the Technology and Finance sectors? | CREATE TABLE companies (id INT,name TEXT,sector TEXT); INSERT INTO companies (id,name,sector) VALUES (1,'Company A','Technology'),(2,'Company B','Finance'),(3,'Company C','Technology'),(4,'Company D','Healthcare'),(5,'Company E','Finance'); | SELECT COUNT(*) FROM companies WHERE sector IN ('Technology', 'Finance'); |
Which movies were released before 2010 and have a rating higher than 8? | CREATE TABLE Movies (id INT,title VARCHAR(100),release_year INT,rating DECIMAL(3,1)); INSERT INTO Movies (id,title,release_year,rating) VALUES (1,'The Dark Knight',2008,9.0),(2,'Inception',2010,8.8),(3,'Pulp Fiction',1994,8.9); | SELECT title FROM Movies WHERE release_year < 2010 AND rating > 8; |
What is the average cloud cover for farms in the 'Southeast' region with more than 2 records between January 1, 2022 and January 15, 2022? | CREATE TABLE Satellite_Images (id INT,farm_id INT,region VARCHAR(50),date DATE,cloud_cover FLOAT); INSERT INTO Satellite_Images (id,farm_id,region,date,cloud_cover) VALUES (1,1,'Southeast','2022-01-01',0.15); INSERT INTO Satellite_Images (id,farm_id,region,date,cloud_cover) VALUES (2,1,'Southeast','2022-01-02',0.20); INSERT INTO Satellite_Images (id,farm_id,region,date,cloud_cover) VALUES (3,2,'Southeast','2022-01-03',0.10); | SELECT region, AVG(cloud_cover) FROM Satellite_Images WHERE date BETWEEN '2022-01-01' AND '2022-01-15' AND region = 'Southeast' GROUP BY region HAVING COUNT(*) > 2; |
Which countries have the most players preferring sports and simulation genres? | CREATE TABLE PlayerGenre (PlayerID INT,Country VARCHAR(20),Genre VARCHAR(10)); INSERT INTO PlayerGenre (PlayerID,Country,Genre) VALUES (1,'USA','Sports'),(2,'Canada','Simulation'),(3,'Mexico','Sports'),(4,'Germany','Simulation'); | SELECT Country, COUNT(*) FROM PlayerGenre WHERE Genre IN ('Sports', 'Simulation') GROUP BY Country; |
How many electric taxis are there in Beijing, China? | CREATE TABLE electric_taxis (taxi_id INT,taxi_type TEXT,city TEXT,in_service INT); | SELECT COUNT(*) FROM electric_taxis WHERE city = 'Beijing' AND taxi_type = 'electric'; |
What is the total number of security incidents by country for the last year, ordered from highest to lowest? | CREATE TABLE security_incidents (incident_id INT,incident_date DATE,country VARCHAR(50)); INSERT INTO security_incidents (incident_id,incident_date,country) VALUES (1,'2021-11-01','United States'),(2,'2021-11-02','Canada'),(3,'2021-11-03','Mexico'),(4,'2021-11-04','Brazil'),(5,'2021-11-05','United Kingdom'),(6,'2021-11-06','Germany'); | SELECT country, COUNT(incident_id) as total_incidents FROM security_incidents WHERE incident_date >= DATEADD(year, -1, CURRENT_DATE) GROUP BY country ORDER BY total_incidents DESC; |
Which countries have the most sustainable tourism certifications? | CREATE TABLE destinations (destination_id INT,name TEXT,country TEXT); CREATE TABLE certifications (certification_id INT,destination_id INT,name TEXT,year INT); INSERT INTO destinations (destination_id,name,country) VALUES (1,'Great Barrier Reef','Australia'),(2,'Iguazu Falls','Argentina'),(3,'Serengeti','Tanzania'); INSERT INTO certifications (certification_id,destination_id,name,year) VALUES (1,1,'Green Destinations Standard',2018),(2,2,'Biosphere Certificate',2019),(3,3,'Green Globe Certification',2020),(4,1,'Green Key',2017); | SELECT country, COUNT(DISTINCT destination_id) as certifications_count FROM certifications GROUP BY country ORDER BY certifications_count DESC; |
What are the detailed records of workforce development initiatives in factories located in a specific region? | CREATE TABLE factories (factory_id INT,name TEXT,location TEXT); CREATE TABLE initiatives (initiative_id INT,factory_id INT,description TEXT,start_date DATE,end_date DATE); INSERT INTO factories (factory_id,name,location) VALUES (1,'Factory A','City A'),(2,'Factory B','City B'),(3,'Factory C','City C'); INSERT INTO initiatives (initiative_id,factory_id,description,start_date,end_date) VALUES (1,1,'Training program','2021-01-01','2021-12-31'),(2,2,'Internship program','2021-06-01','2021-08-31'),(3,3,'Mentorship program','2021-09-01','2021-12-31'); | SELECT f.name, i.description, i.start_date, i.end_date FROM factories f JOIN initiatives i ON f.factory_id = i.factory_id WHERE f.location = 'City A'; |
Show unique genres for players who have played more than 500 games | CREATE TABLE player_games (player_id INT,genre VARCHAR(10),game VARCHAR(20)); INSERT INTO player_games (player_id,genre,game) VALUES (1,'RPG','Game1'); INSERT INTO player_games (player_id,genre,game) VALUES (1,'RPG','Game2'); INSERT INTO player_games (player_id,genre,game) VALUES (2,'Strategy','Game3'); | SELECT DISTINCT genre FROM player_games WHERE player_id IN (SELECT player_id FROM player_games GROUP BY player_id HAVING COUNT(*) > 500); |
How many museums are in each country in the database? | CREATE TABLE museums (id INT,country VARCHAR(50)); | SELECT country, COUNT(*) FROM museums GROUP BY country; |
What is the sum of donation amounts for organizations in 'United States'? | CREATE TABLE organizations (org_id INT,org_name TEXT,org_country TEXT); INSERT INTO organizations (org_id,org_name,org_country) VALUES (1,'Gates Foundation','United States'); INSERT INTO organizations (org_id,org_name,org_country) VALUES (2,'Greenpeace','Canada'); INSERT INTO organizations (org_id,org_name,org_country) VALUES (3,'WWF','Brazil'); INSERT INTO organizations (org_id,org_name,org_country) VALUES (4,'CRY','India'); INSERT INTO organizations (org_id,org_name,org_country) VALUES (5,'AI for Good','Australia'); INSERT INTO donors (donor_id,donor_name,donation_amount,country,org_id) VALUES (1,'John Doe',500.00,'United States',1); INSERT INTO donors (donor_id,donor_name,donation_amount,country,org_id) VALUES (2,'Jane Smith',300.00,'Canada',2); INSERT INTO donors (donor_id,donor_name,donation_amount,country,org_id) VALUES (3,'Jose Garcia',250.00,'Brazil',3); INSERT INTO donors (donor_id,donor_name,donation_amount,country,org_id) VALUES (4,'Raj Patel',400.00,'India',4); INSERT INTO donors (donor_id,donor_name,donation_amount,country,org_id) VALUES (5,'Emma Jones',600.00,'Australia',5); | SELECT SUM(donation_amount) FROM donors WHERE org_country = 'United States'; |
What is the total plastic waste generation in Germany? | CREATE TABLE WasteGenerationData (country VARCHAR(50),waste_type VARCHAR(50),waste_kg FLOAT); INSERT INTO WasteGenerationData (country,waste_type,waste_kg) VALUES ('Germany','Plastic Waste',3500); | SELECT SUM(waste_kg) FROM WasteGenerationData WHERE country = 'Germany' AND waste_type = 'Plastic Waste'; |
What is the total installed renewable energy capacity for the 'renewable_energy_capacity' table by country? | CREATE TABLE renewable_energy_capacity (country VARCHAR(50),wind_capacity NUMERIC(5,2),solar_capacity NUMERIC(5,2)); INSERT INTO renewable_energy_capacity (country,wind_capacity,solar_capacity) VALUES ('Germany',30.0,20.0),('France',40.0,30.0),('Canada',50.0,40.0); | SELECT SUM(wind_capacity + solar_capacity) FROM renewable_energy_capacity; |
Find the number of destinations with a travel advisory level higher than 3 for each region | CREATE TABLE destinations (id INT,name VARCHAR(50),travel_advisory_level INT,region VARCHAR(50)); INSERT INTO destinations (id,name,travel_advisory_level,region) VALUES (1,'Paris',2,'Europe'),(2,'Rome',4,'Europe'),(3,'Tokyo',1,'Asia'),(4,'New York',5,'North America'),(5,'Cancun',3,'North America'),(6,'Sydney',2,'Australia'),(7,'Cape Town',4,'Africa'); | SELECT region, COUNT(*) FROM destinations WHERE travel_advisory_level > 3 GROUP BY region; |
What is the maximum production budget for films produced in Asia or Africa? | CREATE TABLE Films (film_id INT,title VARCHAR(255),release_date DATE,production_budget INT,production_country VARCHAR(50)); INSERT INTO Films (film_id,title,release_date,production_budget,production_country) VALUES (1,'Movie1','2010-01-01',5000000,'India'),(2,'Movie2','2005-01-01',7000000,'USA'),(3,'Movie3','2010-01-01',3000000,'China'),(4,'Movie4','2015-01-01',8000000,'Nigeria'); | SELECT MAX(production_budget) FROM Films WHERE production_country IN ('Asia', 'Africa'); |
What is the minimum number of peacekeeping personnel contributed by 'egypt' in the 'africa' region? | CREATE TABLE peacekeeping_contributions (country VARCHAR(50),region VARCHAR(50),year INT,personnel INT); INSERT INTO peacekeeping_contributions (country,region,year,personnel) VALUES ('Egypt','Africa',2019,2500),('Egypt','Africa',2020,2300),('Egypt','Africa',2021,2400); | SELECT country, region, MIN(personnel) as min_personnel FROM peacekeeping_contributions WHERE country = 'Egypt' AND region = 'Africa' GROUP BY country, region; |
Who are the tennis players with the most Grand Slam titles? | CREATE TABLE players (id INT,name VARCHAR(50),sport VARCHAR(20),grand_slams INT); INSERT INTO players (id,name,sport,grand_slams) VALUES (1,'Roger Federer','Tennis',20); INSERT INTO players (id,name,sport,grand_slams) VALUES (2,'Serena Williams','Tennis',23); | SELECT name, grand_slams FROM players WHERE sport = 'Tennis' ORDER BY grand_slams DESC; |
Insert new records into the 'crop_health' table with values (1, 'corn', 'healthy', '2022-07-01 10:30:00') | CREATE TABLE crop_health (health_id INT,crop_type VARCHAR(20),health_status VARCHAR(20),timestamp TIMESTAMP); | INSERT INTO crop_health (health_id, crop_type, health_status, timestamp) VALUES (1, 'corn', 'healthy', '2022-07-01 10:30:00'); |
How many mining accidents were reported in African countries in 2019, and what were the causes of those accidents? | CREATE TABLE mining_accidents (id INT,country VARCHAR(255),year INT,cause VARCHAR(255)); | SELECT country, year, cause FROM mining_accidents WHERE country IN ('South Africa', 'Ghana', 'Mali', 'Burkina Faso', 'Niger') AND year = 2019; |
What is the total carbon footprint of each dish in the dinner menu? | CREATE TABLE DinnerMenu (id INT,name VARCHAR(255),carbon_footprint INT); | SELECT name, SUM(carbon_footprint) FROM DinnerMenu GROUP BY name; |
Update the email of the author with id 7 to "[john.doe@example.com](mailto:john.doe@example.com)" in the "authors" table | CREATE TABLE authors (author_id INT,first_name VARCHAR(255),last_name VARCHAR(255),email VARCHAR(255)); | UPDATE authors SET email = '[john.doe@example.com](mailto:john.doe@example.com)' WHERE author_id = 7; |
What is the total amount of waste produced by each mining site in the last quarter of 2021, ordered by the site name? | CREATE TABLE site (site_id INT,site_name VARCHAR(20)); INSERT INTO site (site_id,site_name) VALUES (1,'SiteA'),(2,'SiteB'); CREATE TABLE waste_production (waste_id INT,site_id INT,waste_quantity INT,waste_date DATE); INSERT INTO waste_production (waste_id,site_id,waste_quantity,waste_date) VALUES (1,1,500,'2021-10-01'),(2,1,600,'2021-11-01'),(3,2,400,'2021-10-01'); | SELECT site_id, SUM(waste_quantity) FROM waste_production WHERE waste_date BETWEEN '2021-10-01' AND '2021-12-31' GROUP BY site_id ORDER BY site_name; |
List all safety protocols for chemicals that have a usage_per_month greater than 500 and display the usage_per_month in descending order. | CREATE TABLE chemical_inventory (id INT PRIMARY KEY,chemical_name VARCHAR(255),quantity INT,supplier VARCHAR(255),last_updated TIMESTAMP);CREATE TABLE supplier_info (id INT PRIMARY KEY,supplier_name VARCHAR(255),address VARCHAR(255),country VARCHAR(255));CREATE TABLE chemical_safety_protocols (id INT PRIMARY KEY,chemical_name VARCHAR(255),safety_precautions TEXT,updated_by VARCHAR(255),last_updated TIMESTAMP);CREATE TABLE chemical_usage (id INT PRIMARY KEY,chemical_name VARCHAR(255),usage_per_month DECIMAL(10,2),usage_start_date DATE,usage_end_date DATE); | SELECT cs.chemical_name, cs.safety_precautions, cu.usage_per_month FROM chemical_safety_protocols cs JOIN chemical_usage cu ON cs.chemical_name = cu.chemical_name WHERE cu.usage_per_month > 500 ORDER BY cu.usage_per_month DESC; |
What is the maximum number of military personnel employed by a defense contractor in Canada? | CREATE TABLE MilitaryPersonnel (id INT,contractor VARCHAR(50),country VARCHAR(50),personnel INT); INSERT INTO MilitaryPersonnel (id,contractor,country,personnel) VALUES (1,'Lockheed Martin Canada','Canada',5000),(2,'Babcock Canada','Canada',3000),(3,'CAE','Canada',4000); | SELECT MAX(personnel) FROM MilitaryPersonnel WHERE country = 'Canada'; |
Which menu item has the lowest cost at 'The Vegan Bistro'? | CREATE TABLE Menu (restaurant_name TEXT,menu_item TEXT,item_cost FLOAT); INSERT INTO Menu (restaurant_name,menu_item,item_cost) VALUES ('Urban Plate','Quinoa Salad',9.99),('Organic Greens','Tempeh Stir Fry',12.49),('Fiesta Mex','Veggie Tacos',10.99),('The Vegan Bistro','Lentil Soup',7.99); | SELECT menu_item, MIN(item_cost) FROM Menu WHERE restaurant_name = 'The Vegan Bistro'; |
What is the average economic diversification investment in 'Middle East' from '2019' to '2021'? | CREATE TABLE eco_diversification(id INT,investment TEXT,location TEXT,year INT,amount INT); INSERT INTO eco_diversification (id,investment,location,year,amount) VALUES (1,'Solar Energy Project','Middle East',2019,5000000); | SELECT AVG(amount) FROM eco_diversification WHERE location = 'Middle East' AND year BETWEEN 2019 AND 2021; |
How many IoT devices are connected to vineyards in Italy? | CREATE TABLE IoT_Devices (id INT,device_type VARCHAR(255),location VARCHAR(255)); INSERT INTO IoT_Devices (id,device_type,location) VALUES (1,'Soil Moisture Sensor','Italy Vineyard'),(2,'Temperature Sensor','Italy Vineyard'),(3,'Drone','Italy'); | SELECT COUNT(*) FROM IoT_Devices WHERE location LIKE '%Italy Vineyard%'; |
What is the total revenue generated by action games? | CREATE TABLE Games (GameID INT,GameName VARCHAR(20),Genre VARCHAR(20),Revenue DECIMAL(10,2)); INSERT INTO Games (GameID,GameName,Genre,Revenue) VALUES (1,'Space Explorer','VR',800),(2,'Galactic War','Action',2500),(3,'Mystery Island','Adventure',3000); | SELECT SUM(Revenue) as TotalRevenue FROM Games WHERE Genre = 'Action'; |
What are the names and periods of all excavation sites with more than 50 artifacts? | CREATE TABLE ExcavationSites (site_id INT,site_name TEXT,period TEXT); INSERT INTO ExcavationSites (site_id,site_name,period) VALUES (1,'SiteA','Iron Age'),(2,'SiteB','Bronze Age'); CREATE TABLE Artifacts (artifact_id INT,site_id INT,artifact_name TEXT); INSERT INTO Artifacts (artifact_id,site_id,artifact_name) VALUES (1,1,'Artifact1'),(2,1,'Artifact2'),(3,2,'Artifact3'); | SELECT es.site_name, es.period FROM ExcavationSites es INNER JOIN (SELECT site_id, COUNT(*) as artifact_count FROM Artifacts GROUP BY site_id) art_cnt ON es.site_id = art_cnt.site_id WHERE art_cnt.artifact_count > 50; |
What is the average budget for genetic research projects in 2022? | CREATE SCHEMA if not exists genetics;CREATE TABLE if not exists genetics.research_projects (id INT,year INT,budget FLOAT); INSERT INTO genetics.research_projects (id,year,budget) VALUES (1,2021,1000000.0),(2,2022,1500000.0),(3,2022,800000.0); | SELECT AVG(budget) FROM genetics.research_projects WHERE year = 2022; |
What is the minimum rating of hotels in Europe? | CREATE TABLE hotels (id INT,name TEXT,country TEXT,rating FLOAT); INSERT INTO hotels (id,name,country,rating) VALUES (1,'Hotel A','Europe',4.5),(2,'Hotel B','Europe',3.2),(3,'Hotel C','Europe',4.7); | SELECT MIN(rating) FROM hotels WHERE country = 'Europe'; |
What is the average sale price for garments made of silk? | CREATE TABLE garments (id INT,name VARCHAR(50),material VARCHAR(50),sale_price DECIMAL(5,2)); INSERT INTO garments (id,name,material,sale_price) VALUES (1,'silk_dress','silk',99.99); | SELECT AVG(sale_price) FROM garments WHERE material = 'silk'; |
What is the latest date in the 'pollution_data' table? | CREATE TABLE pollution_data (data_id INT,date DATE,location VARCHAR(255),pollution_level INT); | SELECT MAX(date) FROM pollution_data; |
Update the name of the initiative 'AGRI-INNOVATE 1.0' to 'AGRI-INNOVATE v1' in the 'agricultural_innovation' table. | CREATE TABLE agricultural_innovation (initiative VARCHAR(255),year INT,budget FLOAT); INSERT INTO agricultural_innovation (initiative,year,budget) VALUES ('AGRI-INNOVATE 1.0',2020,5000000),('AGRI-INNOVATE 2.0',2021,6000000); | UPDATE agricultural_innovation SET initiative = 'AGRI-INNOVATE v1' WHERE initiative = 'AGRI-INNOVATE 1.0'; |
How many security incidents were reported in the healthcare sector in 2021? | CREATE TABLE healthcare_sector (year INT,incidents INT); INSERT INTO healthcare_sector (year,incidents) VALUES (2021,1200),(2020,1000),(2019,800),(2018,600),(2017,400); | SELECT incidents FROM healthcare_sector WHERE year = 2021; |
Show the 'carrier_id' and 'carrier_name' of all carriers in the 'freight_forwarding' table | CREATE TABLE freight_forwarding (carrier_id INT,carrier_name VARCHAR(50)); INSERT INTO freight_forwarding (carrier_id,carrier_name) VALUES (1,'FedEx'),(2,'UPS'),(3,'USPS'); | SELECT carrier_id, carrier_name FROM freight_forwarding; |
What is the average carbon footprint of factories in the top 5 most polluting regions? | CREATE TABLE Factories (id INT,region VARCHAR,carbon_footprint INT); CREATE VIEW TopPollutingRegions AS SELECT DISTINCT TOP 5 region FROM Factories ORDER BY carbon_footprint DESC; | SELECT AVG(carbon_footprint) FROM Factories WHERE region IN (SELECT region FROM TopPollutingRegions); |
How many vulnerabilities have been found in the technology sector? | CREATE TABLE vulnerabilities (id INT,sector VARCHAR(255),vulnerability VARCHAR(255)); INSERT INTO vulnerabilities (id,sector,vulnerability) VALUES (1,'technology','SQL injection'),(2,'technology','cross-site scripting'); | SELECT COUNT(*) FROM vulnerabilities WHERE sector = 'technology'; |
What is the distribution of art collections by medium in Los Angeles? | CREATE TABLE Collections (city VARCHAR(20),medium VARCHAR(20),pieces INT); INSERT INTO Collections (city,medium,pieces) VALUES ('Los Angeles','Painting',500),('Los Angeles','Sculpture',300),('Los Angeles','Photography',200),('New York','Painting',700); | SELECT medium, COUNT(*) FROM Collections WHERE city = 'Los Angeles' GROUP BY medium; |
Update the average speed of vessel V004 to 18 knots | vessel_performance(vessel_id,max_speed,average_speed) | UPDATE vessel_performance SET average_speed = 18 WHERE vessel_id = 'V004'; |
Identify the number of unique strains available for sale in each state. | CREATE TABLE strains (strain_name VARCHAR(30),state VARCHAR(20)); INSERT INTO strains (strain_name,state) VALUES ('Strain A','California'); INSERT INTO strains (strain_name,state) VALUES ('Strain B','California'); INSERT INTO strains (strain_name,state) VALUES ('Strain C','California'); INSERT INTO strains (strain_name,state) VALUES ('Strain D','Nevada'); INSERT INTO strains (strain_name,state) VALUES ('Strain E','Nevada'); | SELECT state, COUNT(DISTINCT strain_name) FROM strains GROUP BY state; |
What is the average number of likes on posts by users from the US in the last month? | CREATE TABLE users (id INT,name VARCHAR(50),country VARCHAR(50)); INSERT INTO users (id,name,country) VALUES (1,'John Doe','USA'),(2,'Jane Smith','Canada'); CREATE TABLE posts (id INT,user_id INT,likes INT,timestamp DATETIME); INSERT INTO posts (id,user_id,likes,timestamp) VALUES (1,1,100,'2022-01-01 12:00:00'),(2,1,120,'2022-01-02 14:00:00'),(3,2,50,'2022-01-03 10:00:00'); | SELECT AVG(posts.likes) FROM posts INNER JOIN users ON posts.user_id = users.id WHERE users.country = 'USA' AND posts.timestamp >= DATE_SUB(NOW(), INTERVAL 1 MONTH); |
Insert a new record for a given mammal in the Mammals table | CREATE TABLE Mammals (species VARCHAR(255),region VARCHAR(255),biomass FLOAT); | INSERT INTO Mammals (species, region, biomass) VALUES ('Caribou', 'Canada', 400); |
What is the average number of likes on posts with the hashtag #dogs? | CREATE TABLE posts (id INT,hashtags VARCHAR(50),likes INT); INSERT INTO posts (id,hashtags,likes) VALUES (1,'#dogs,#puppies',100),(2,'#dogs,#pet',200),(3,'#cats',150); | SELECT AVG(posts.likes) as avg_likes FROM posts WHERE posts.hashtags LIKE '%#dogs%'; |
What is the total number of unique users who have streamed Classical music on Amazon Music from the UK in the last 60 days? | CREATE TABLE streams (id INT,user_id INT,song_id INT,platform VARCHAR(20),stream_date DATE,user_country VARCHAR(50)); INSERT INTO streams (id,user_id,song_id,platform,stream_date,user_country) VALUES (1,1,1,'Amazon Music','2022-01-01','UK'),(2,2,2,'Amazon Music','2022-01-02','UK'); | SELECT COUNT(DISTINCT user_id) FROM streams WHERE platform = 'Amazon Music' AND genre = 'Classical' AND user_country = 'UK' AND stream_date >= NOW() - INTERVAL '60 days'; |
Find the number of autonomous driving research papers published in 2021. | CREATE TABLE ResearchPapers (Id INT,Title VARCHAR(255),Year INT,Topic VARCHAR(255)); INSERT INTO ResearchPapers (Id,Title,Year,Topic) VALUES (1,'Paper 1',2021,'Autonomous Driving'),(2,'Paper 2',2022,'Electric Vehicles'),(3,'Paper 3',2020,'Autonomous Driving'); | SELECT COUNT(*) FROM ResearchPapers WHERE Topic = 'Autonomous Driving' AND Year = 2021; |
Update the size data for a specific customer | CREATE TABLE CustomerSizes (CustomerID INT,Size TEXT); INSERT INTO CustomerSizes (CustomerID,Size) VALUES (1,'XS'),(2,'S'),(3,'M'); | UPDATE CustomerSizes SET Size = 'S-M' WHERE CustomerID = 2; |
Delete the 'volunteer_id' column from the 'VolunteerSkills' table. | CREATE TABLE VolunteerSkills (volunteer_id INT,skill VARCHAR(255),experience INT); | ALTER TABLE VolunteerSkills DROP COLUMN volunteer_id; |
Delete the 'facility' record with ID '456' from the 'facilities' table | CREATE TABLE facilities (id INT PRIMARY KEY,name VARCHAR(50),city VARCHAR(50),capacity INT); | DELETE FROM facilities WHERE id = 456; |
What is the total number of vulnerabilities discovered before 2021? | CREATE TABLE schema1.vulnerabilities (id INT,name VARCHAR(255),severity VARCHAR(50),description TEXT,date_discovered DATE,last_observed DATE); INSERT INTO schema1.vulnerabilities (id,name,severity,description,date_discovered,last_observed) VALUES (1,'SQL Injection','Critical','Allows unauthorized access','2021-01-01','2021-02-01'); | SELECT COUNT(*) FROM schema1.vulnerabilities WHERE date_discovered < '2021-01-01'; |
What is the total number of workers by union category in the state of California? | CREATE TABLE unions (id INT,name VARCHAR(255),state VARCHAR(255)); INSERT INTO unions (id,name,state) VALUES (1,'Teamsters','California'); INSERT INTO unions (id,name,state) VALUES (2,'UFCW','California'); | SELECT SUM(workers) FROM (SELECT state, category as unions, COUNT(*) as workers FROM union_data WHERE state = 'California' GROUP BY state, category) as subquery GROUP BY unions; |
What is the total amount of funding for defense diplomacy initiatives in the 'Funding' table, for the 'Asia' and 'Africa' regions combined? | CREATE TABLE Funding (id INT,region VARCHAR(255),amount DECIMAL(10,2)); | SELECT SUM(amount) FROM Funding WHERE region IN ('Asia', 'Africa'); |
Find the total revenue and number of impressions for each advertiser in the advertising schema, in the last quarter. | CREATE TABLE advertisers (id INT,name VARCHAR(50)); CREATE TABLE campaigns (id INT,advertiser_id INT,start_date DATE,end_date DATE); CREATE TABLE ad_performance (campaign_id INT,impressions INT,revenue FLOAT); | SELECT a.name AS advertiser, SUM(ap.revenue) AS total_revenue, SUM(ap.impressions) AS total_impressions FROM ad_performance ap JOIN campaigns c ON ap.campaign_id = c.id JOIN advertisers a ON c.advertiser_id = a.id WHERE ap.start_date >= DATE_SUB(CURRENT_DATE, INTERVAL 3 MONTH) GROUP BY a.name; |
How many rural infrastructure projects were completed in 2019? | CREATE TABLE rural_infrastructure (id INT,year INT,project VARCHAR(50),status VARCHAR(20)); INSERT INTO rural_infrastructure (id,year,project,status) VALUES (1,2018,'Road Construction','In Progress'),(2,2019,'Water Supply','Completed'),(3,2020,'Electrification','Planned'); | SELECT COUNT(*) FROM rural_infrastructure WHERE year = 2019 AND status = 'Completed'; |
Find the total number of research papers published by Dr. Johnson in astrophysics | CREATE TABLE ResearchPapers(ID INT,Author VARCHAR(50),Title VARCHAR(100),ResearchArea VARCHAR(50)); | SELECT COUNT(*) FROM ResearchPapers WHERE Author = 'Dr. Johnson' AND ResearchArea = 'astrophysics'; |
Create a view named 'top_military_powers' | CREATE VIEW top_military_powers AS SELECT country_of_origin,COUNT(equipment_id) AS equipment_count FROM military_equipment GROUP BY country_of_origin ORDER BY equipment_count DESC; | CREATE VIEW top_military_powers AS SELECT country_of_origin, COUNT(equipment_id) AS equipment_count FROM military_equipment GROUP BY country_of_origin ORDER BY equipment_count DESC; |
What is the average budget per program? | CREATE TABLE Programs (id INT,program TEXT,budget DECIMAL(10,2)); INSERT INTO Programs (id,program,budget) VALUES (1,'Feeding the Hungry',5000.00),(2,'Clothing Drive',3000.00),(3,'Education',7000.00); | SELECT program, AVG(budget) FROM Programs GROUP BY program; |
Delete all crime incidents that occurred before 2010-01-01 | CREATE TABLE crime_incidents (id INT PRIMARY KEY,incident_date DATE,incident_type VARCHAR(255)); INSERT INTO crime_incidents (id,incident_date,incident_type) VALUES (1,'2010-01-02','Theft'),(2,'2009-12-31','Assault'),(3,'2010-01-05','Burglary'); | DELETE FROM crime_incidents WHERE incident_date < '2010-01-01'; |
What are the top 3 most common types of security incidents reported by 'Finance' department in the last quarter? | CREATE TABLE incident_types (id integer,incident text,department text,timestamp timestamp); INSERT INTO incident_types (id,incident,department,timestamp) VALUES (1,'Phishing','Finance','2022-04-01 10:00:00'),(2,'Malware','IT','2022-04-02 11:00:00'),(3,'Phishing','Finance','2022-04-03 12:00:00'),(4,'Insider Threat','HR','2022-04-04 13:00:00'),(5,'Phishing','Finance','2022-04-05 14:00:00'); | SELECT incident, COUNT(*) as incident_count FROM incident_types WHERE department = 'Finance' AND timestamp >= DATEADD(quarter, -1, CURRENT_TIMESTAMP) GROUP BY incident ORDER BY incident_count DESC LIMIT 3; |
Which smart city projects in the 'smart_cities' table are located in 'Europe'? | CREATE TABLE smart_cities (project_id INT,location TEXT,region TEXT); INSERT INTO smart_cities (project_id,location,region) VALUES (1,'Berlin','Europe'),(2,'Paris','Europe'),(3,'Rome','Europe'); | SELECT * FROM smart_cities WHERE region = 'Europe'; |
Calculate the number of students with each type of disability, ordered by the number of students with each type of disability in descending order. | CREATE TABLE StudentAccommodations (StudentID INT,StudentName VARCHAR(255),DisabilityType VARCHAR(255),AccommodationType VARCHAR(255),GraduationYear INT); INSERT INTO StudentAccommodations (StudentID,StudentName,DisabilityType,AccommodationType,GraduationYear) VALUES (1,'John Doe','Visual Impairment','Sign Language Interpretation',2018),(2,'Jane Smith','Hearing Impairment','Assistive Listening Devices',NULL),(3,'Michael Johnson','Mobility Impairment','Assistive Technology',2019),(4,'Sara Johnson','Physical Disability','Mobility Assistance',2022),(5,'David Kim','Learning Disability','Assistive Technology',2023); | SELECT DisabilityType, COUNT(*) AS NumberOfStudents FROM StudentAccommodations GROUP BY DisabilityType ORDER BY NumberOfStudents DESC; |
What is the minimum and maximum wind speed in 'WindProjects' table, for each country? | CREATE TABLE WindProjects (project_id INT,country VARCHAR(50),wind_speed INT); | SELECT country, MIN(wind_speed) as min_wind_speed, MAX(wind_speed) as max_wind_speed FROM WindProjects GROUP BY country; |
How many healthcare providers are there in urban and rural areas? | CREATE TABLE healthcare_providers (area VARCHAR(10),provider_count INT); INSERT INTO healthcare_providers (area,provider_count) VALUES ('Urban',500),('Rural',200); | SELECT area, provider_count, NTILE(4) OVER (ORDER BY provider_count) AS tier FROM healthcare_providers; |
What is the total number of visitors to eco-friendly hotels in Berlin? | CREATE TABLE hotels (id INT,name TEXT,city TEXT,is_eco_friendly BOOLEAN,visitors INT); INSERT INTO hotels (id,name,city,is_eco_friendly,visitors) VALUES (1,'Eco Hotel Berlin','Berlin',TRUE,800),(2,'Green Hotel Berlin','Berlin',TRUE,900); | SELECT SUM(visitors) FROM hotels WHERE city = 'Berlin' AND is_eco_friendly = TRUE; |
List all regulatory frameworks for decentralized finance (DeFi) in the United States and their respective enforcement agencies. | CREATE TABLE defi_regulations (regulation_id INT,regulation_name VARCHAR(255),country VARCHAR(50),agency VARCHAR(255)); | SELECT regulation_name, agency FROM defi_regulations WHERE country = 'United States' AND (regulation_name LIKE '%DeFi%' OR regulation_name LIKE '%Decentralized Finance%'); |
What is the total quantity of dish 'Chicken Caesar Salad' sold last month? | CREATE TABLE menus (menu_id INT,name VARCHAR(100),category VARCHAR(50),price DECIMAL(5,2),quantity INT); INSERT INTO menus (menu_id,name,category,price,quantity) VALUES (1,'Chicken Caesar Salad','Salad',12.99,300),(2,'Margherita Pizza','Pizza',9.99,450); | SELECT SUM(quantity) FROM menus WHERE name = 'Chicken Caesar Salad' AND MONTH(order_date) = MONTH(CURRENT_DATE()) - 1; |
What is the average water usage per mine in 2021? | CREATE TABLE water_usage (id INT,mine_id INT,date DATE,usage FLOAT); INSERT INTO water_usage (id,mine_id,date,usage) VALUES (1,1,'2021-01-01',5000.0),(2,2,'2021-01-01',6000.0); | SELECT mine_id, AVG(usage) as avg_water_usage FROM water_usage WHERE date BETWEEN '2021-01-01' AND '2021-12-31' GROUP BY mine_id; |
What is the total quantity of organic fruits and vegetables sold by suppliers in the Northeast region? | CREATE TABLE Suppliers (SupplierID INT,SupplierName VARCHAR(50),Location VARCHAR(50)); INSERT INTO Suppliers (SupplierID,SupplierName,Location) VALUES (1,'Supplier A','Northeast'),(2,'Supplier B','Southeast'); CREATE TABLE Products (ProductID INT,ProductName VARCHAR(50),SupplierID INT,IsOrganic BOOLEAN); INSERT INTO Products (ProductID,ProductName,SupplierID,IsOrganic) VALUES (1,'Apple',1,true),(2,'Carrot',1,true),(3,'Banana',2,true),(4,'Potato',2,false); CREATE TABLE Sales (SaleID INT,ProductID INT,Quantity INT); INSERT INTO Sales (SaleID,ProductID,Quantity) VALUES (1,1,10),(2,2,15),(3,3,8),(4,4,20); | SELECT SUM(Quantity) FROM Sales JOIN Products ON Sales.ProductID = Products.ProductID JOIN Suppliers ON Products.SupplierID = Suppliers.SupplierID WHERE IsOrganic = true AND Suppliers.Location = 'Northeast'; |
What is the average size of dresses sold in the last month? | CREATE TABLE DressSales (id INT,size INT,quantity INT,date DATE); INSERT INTO DressSales (id,size,quantity,date) VALUES (1,8,20,'2022-01-01'),(2,10,15,'2022-01-05'),(3,12,25,'2022-01-10'); | SELECT AVG(size) FROM DressSales WHERE date >= DATE_SUB(CURDATE(), INTERVAL 1 MONTH); |
What is the number of green buildings and their total carbon offsets in each city? | CREATE TABLE green_buildings (building_id INT,building_name VARCHAR(50),city VARCHAR(50),certification_level VARCHAR(50),carbon_offsets FLOAT); INSERT INTO green_buildings (building_id,building_name,city,certification_level,carbon_offsets) VALUES (1,'Green Building 1','CityA','Gold',100.0),(2,'Green Building 2','CityB','Platinum',200.0),(3,'Green Building 3','CityA','Silver',150.0); | SELECT city, COUNT(*), SUM(carbon_offsets) FROM green_buildings GROUP BY city; |
What is the most frequently ordered vegetarian appetizer in the last week? | CREATE TABLE AppetizerMenu(menu_item VARCHAR(50),dish_type VARCHAR(20),price DECIMAL(5,2)); CREATE TABLE Orders(order_id INT,customer_id INT,menu_item VARCHAR(50),order_date DATE); INSERT INTO AppetizerMenu VALUES('Bruschetta','vegetarian',7.99),('Calamari','non-vegetarian',9.99),('Hummus Plate','vegetarian',8.99); INSERT INTO Orders VALUES(1,1,'Bruschetta','2022-01-01'),(2,2,'Calamari','2022-01-02'),(3,1,'Hummus Plate','2022-01-03'),(4,3,'Bruschetta','2022-01-04'),(5,1,'Calamari','2022-01-05'),(6,2,'Bruschetta','2022-01-06'),(7,1,'Hummus Plate','2022-01-07'); | SELECT menu_item, COUNT(*) AS order_count FROM AppetizerMenu JOIN Orders ON AppetizerMenu.menu_item = Orders.menu_item WHERE order_date >= '2022-01-01' AND order_date < '2022-01-08' AND dish_type = 'vegetarian' GROUP BY menu_item ORDER BY order_count DESC LIMIT 1; |
Add new records for public bike-sharing programs in 2023. | CREATE TABLE bike_share (id INT PRIMARY KEY,name VARCHAR(255),location VARCHAR(255),launch_year INT); | INSERT INTO bike_share (name, location, launch_year) VALUES ('Copenhagen Wheels', 'Copenhagen', 2023), ('BIXI Montreal', 'Montreal', 2023), ('Bike Chattanooga', 'Chattanooga', 2023); |
What is the average number of disaster relief supplies sent to each country in the year 2020? | CREATE TABLE disaster_relief_supplies (id INT,destination VARCHAR(255),year INT,quantity INT); | SELECT AVG(quantity) FROM disaster_relief_supplies WHERE year = 2020 GROUP BY destination; |
How many smart contracts have been developed by each developer, and who are they? | CREATE TABLE developers (developer_id INT PRIMARY KEY,name VARCHAR(50),age INT,gender VARCHAR(10),country VARCHAR(50)); 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 developers (developer_id,name,age,gender,country) VALUES (1,'Alice',30,'Female','USA'); INSERT INTO developers (developer_id,name,age,gender,country) VALUES (2,'Bob',35,'Male','Canada'); 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',1,'Solidity'); INSERT INTO smart_contracts (contract_id,contract_name,developer_id,language) VALUES (3,'Contract3',2,'Vyper'); | SELECT developers.name, COUNT(smart_contracts.contract_id) as contract_count FROM developers INNER JOIN smart_contracts ON developers.developer_id = smart_contracts.developer_id GROUP BY developers.name; |
What are the top 5 countries with the most decentralized applications? | CREATE TABLE decentralized_applications (id INT,dapp_name VARCHAR(255),country VARCHAR(255)); INSERT INTO decentralized_applications (id,dapp_name,country) VALUES (1,'Uniswap','United States'),(2,'Aave','Switzerland'),(3,'Compound','United States'),(4,'SushiSwap','Japan'),(5,'Yearn Finance','United States'),(6,'MakerDAO','Singapore'); | SELECT country, COUNT(*) as dapp_count FROM decentralized_applications GROUP BY country ORDER BY dapp_count DESC LIMIT 5; |
What is the average rating of movies by country? | CREATE TABLE Movies (id INT,title VARCHAR(255),country VARCHAR(255),rating DECIMAL(3,2)); INSERT INTO Movies (id,title,country,rating) VALUES (1,'Movie1','USA',8.5),(2,'Movie2','Canada',7.8),(3,'Movie3','Mexico',8.2); | SELECT country, AVG(rating) as avg_rating FROM Movies GROUP BY country; |
What is the total number of volunteer hours contributed by volunteers from India? | CREATE TABLE Volunteers (VolunteerID INT,VolunteerName TEXT,Hours INT,Country TEXT); INSERT INTO Volunteers (VolunteerID,VolunteerName,Hours,Country) VALUES (1,'Rajesh Patel',50,'India'),(2,'Sheetal Patel',75,'India'); | SELECT Country, SUM(Hours) FROM Volunteers WHERE Country = 'India' GROUP BY Country; |
What is the percentage of the population that is obese in each age group in the United States? | CREATE TABLE obesity_rates (id INT,age_group TEXT,obesity_rate DECIMAL(4,2),country TEXT); INSERT INTO obesity_rates (id,age_group,obesity_rate,country) VALUES (1,'0-18',15.3,'United States'),(2,'19-34',27.2,'United States'),(3,'35-49',36.6,'United States'),(4,'50-64',40.2,'United States'),(5,'65+',39.5,'United States'); | SELECT age_group, obesity_rate FROM obesity_rates WHERE country = 'United States'; |
What is the total sales for product 'ProductD' in the first half of 2022? | CREATE TABLE product_sales_2 (product_id VARCHAR(10),sale_date DATE,revenue DECIMAL(10,2)); INSERT INTO product_sales_2 (product_id,sale_date,revenue) VALUES ('ProductD','2022-01-10',500),('ProductD','2022-03-20',700),('ProductD','2022-06-05',600); | SELECT SUM(revenue) FROM product_sales_2 WHERE product_id = 'ProductD' AND sale_date BETWEEN '2022-01-01' AND '2022-06-30'; |
Update the financial wellbeing score of customers who have taken out more than 3 socially responsible loans in the past month. | CREATE TABLE customer_data (id INT PRIMARY KEY,customer_id INT,wellbeing_score INT); CREATE TABLE socially_responsible_loans (id INT PRIMARY KEY,customer_id INT,loan_date DATE); CREATE VIEW recent_loans AS SELECT customer_id FROM socially_responsible_loans WHERE loan_date >= DATE_SUB(CURRENT_DATE,INTERVAL 1 MONTH); CREATE VIEW multiple_loans AS SELECT customer_id FROM recent_loans GROUP BY customer_id HAVING COUNT(*) > 3; | UPDATE customer_data c SET wellbeing_score = 90 WHERE c.customer_id IN (SELECT m.customer_id FROM multiple_loans m); |
List all unique soil_moisture_sensors with their last recorded timestamp. | CREATE TABLE soil_moisture_sensors (id INT,sensor_id INT,moisture DECIMAL(5,2),timestamp TIMESTAMP); INSERT INTO soil_moisture_sensors (id,sensor_id,moisture,timestamp) VALUES (1,1001,45,'2022-01-01 12:00:00'),(2,1002,48,'2022-01-01 13:00:00'),(3,1001,46,'2022-01-01 14:00:00'); | SELECT DISTINCT sensor_id, MAX(timestamp) FROM soil_moisture_sensors GROUP BY sensor_id; |
What is the average age of all employees working in the Mining department? | CREATE TABLE Employees (EmployeeID INT,Name VARCHAR(50),Department VARCHAR(50),Age INT); INSERT INTO Employees (EmployeeID,Name,Department,Age) VALUES (1,'John Doe','Mining',35); INSERT INTO Employees (EmployeeID,Name,Department,Age) VALUES (2,'Jane Smith','Human Resources',28); | SELECT AVG(Age) FROM Employees WHERE Department = 'Mining'; |
Identify the chemical composition, hazard classification, and production date for chemicals used in the production of a product that contains a specific ingredient, and the corresponding supplier names. | CREATE TABLE chemicals (chemical_id INT,chemical_name TEXT,composition TEXT,hazard_classification TEXT); CREATE TABLE product_ingredients (ingredient_id INT,product_code TEXT,chemical_id INT); CREATE TABLE chemical_suppliers (supplier_id INT,chemical_id INT,supplier_name TEXT); INSERT INTO chemicals (chemical_id,chemical_name,composition,hazard_classification) VALUES (1,'Chemical A','H2O,NaCl','Low'),(2,'Chemical B','CO2,H2O','Medium'); INSERT INTO product_ingredients (ingredient_id,product_code,chemical_id) VALUES (1,'P1',1),(2,'P2',2); INSERT INTO chemical_suppliers (supplier_id,chemical_id,supplier_name) VALUES (1,1,'Supplier C'),(2,2,'Supplier D'); | SELECT chemicals.composition, chemicals.hazard_classification, products.production_date, chemical_suppliers.supplier_name FROM chemicals INNER JOIN product_ingredients ON chemicals.chemical_id = product_ingredients.chemical_id INNER JOIN chemical_suppliers ON chemicals.chemical_id = chemical_suppliers.chemical_id INNER JOIN products ON product_ingredients.product_code = products.product_code WHERE product_ingredients.product_code = 'P1'; |
What is the minimum amount of research grants received by a faculty member in the Arts department in the year 2017? | CREATE TABLE Faculty (FacultyID INT,Name VARCHAR(50),Department VARCHAR(50),Gender VARCHAR(10),GrantAmt FLOAT,GrantYear INT); | SELECT MIN(GrantAmt) FROM Faculty WHERE Department = 'Arts' AND GrantYear = 2017; |
How many concerts were held in each city? | CREATE TABLE concert_sales (id INT,artist VARCHAR(100),city VARCHAR(100)); | SELECT city, COUNT(DISTINCT id) FROM concert_sales GROUP BY city; |
List the top 3 busiest subway stations in Tokyo, Japan by total daily entries. | CREATE TABLE subway_stations (station_id INT,station_name TEXT,line TEXT,city TEXT,daily_entries INT); | SELECT station_name, SUM(daily_entries) as total_entries FROM subway_stations WHERE city = 'Tokyo' GROUP BY station_name ORDER BY total_entries DESC LIMIT 3; |
List all mining sites and their corresponding environmental impact scores and locations. | CREATE TABLE Mining_Sites (id INT,site_name VARCHAR(50),location VARCHAR(50),environmental_impact_score INT); INSERT INTO Mining_Sites (id,site_name,location,environmental_impact_score) VALUES (1,'Site A','USA',60),(2,'Site B','Canada',70),(3,'Site C','Mexico',50); | SELECT site_name, location, environmental_impact_score FROM Mining_Sites; |
How many genetic research projects are in Italy? | CREATE SCHEMA genetics; CREATE TABLE genetics.projects (id INT,name VARCHAR(100),country VARCHAR(50)); INSERT INTO genetics.projects (id,name,country) VALUES (1,'ProjectD','Italy'); INSERT INTO genetics.projects (id,name,country) VALUES (2,'ProjectE','Italy'); INSERT INTO genetics.projects (id,name,country) VALUES (3,'ProjectF','Italy'); | SELECT COUNT(*) FROM genetics.projects WHERE country = 'Italy'; |
What is the number of hotels that have adopted AI in each country, for countries with at least 2 AI adoptions, ordered by the most adoptions first? | CREATE TABLE ai_adoptions (adoption_id INT,hotel_name TEXT,country TEXT); INSERT INTO ai_adoptions (adoption_id,hotel_name,country) VALUES (1,'Hotel A','USA'),(2,'Hotel B','Canada'),(3,'Hotel C','USA'),(4,'Hotel D','Mexico'),(5,'Hotel E','USA'),(6,'Hotel F','Canada'); | SELECT country, COUNT(*) as num_adoptions FROM ai_adoptions GROUP BY country HAVING COUNT(*) >= 2 ORDER BY num_adoptions DESC; |
What was the number of likes on posts related to 'climate change' in January 2022? | CREATE TABLE posts (id INT,content TEXT,likes INT,timestamp TIMESTAMP); | SELECT SUM(likes) FROM posts WHERE content LIKE '%climate change%' AND timestamp BETWEEN '2022-01-01 00:00:00' AND '2022-01-31 23:59:59'; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.