instruction stringlengths 0 1.06k | input stringlengths 11 5.3k | response stringlengths 2 4.44k |
|---|---|---|
Which artists have the highest concert revenue in each city? | CREATE TABLE Concerts (ConcertID INT,Artist VARCHAR(50),City VARCHAR(50),Revenue DECIMAL(10,2)); INSERT INTO Concerts (ConcertID,Artist,City,Revenue) VALUES (1,'Taylor Swift','Los Angeles',500000.00),(2,'BTS','New York',750000.00),(3,'Adele','London',600000.00),(4,'Taylor Swift','Paris',400000.00); | SELECT City, Artist, MAX(Revenue) as MaxRevenue FROM Concerts GROUP BY City, Artist; |
Insert a new record into the 'financial_capability' table for 'FatimaKhan' with a score of 85. | CREATE TABLE financial_capability (id INT,name VARCHAR(20),score INT); INSERT INTO financial_capability (id,name,score) VALUES (1,'JohnDoe',70),(2,'JaneDoe',85),(3,'MikeSmith',90); | INSERT INTO financial_capability (name, score) VALUES ('FatimaKhan', 85); |
Update the ingredient 'Microbeads' to 'Biodegradable Beads' in the Products table. | CREATE TABLE Products (productID INT,productName VARCHAR(50),ingredient VARCHAR(50)); INSERT INTO Products (productID,productName,ingredient) VALUES (1,'Exfoliating Scrub','Microbeads'),(2,'Face Wash','Salicylic Acid'),(3,'Hand Cream','Shea Butter'); | UPDATE Products SET ingredient = 'Biodegradable Beads' WHERE ingredient = 'Microbeads'; |
What is the minimum monthly data usage for prepaid mobile customers in the state of Texas? | CREATE TABLE mobile_subscribers (subscriber_id INT,data_usage FLOAT,state VARCHAR(20),subscription_type VARCHAR(20)); INSERT INTO mobile_subscribers (subscriber_id,data_usage,state,subscription_type) VALUES (1,3.5,'Texas','prepaid'),(2,4.2,'Texas','prepaid'),(3,3.8,'California','postpaid'); | SELECT MIN(data_usage) FROM mobile_subscribers WHERE state = 'Texas' AND subscription_type = 'prepaid'; |
What is the total population of all marine species in the 'MarineLife' table, grouped by their species type? | CREATE TABLE MarineLife (id INT,name VARCHAR(50),species VARCHAR(50),species_type VARCHAR(50),population INT); INSERT INTO MarineLife (id,name,species,species_type,population) VALUES (1,'Sea Dragon','Squid','Cephalopod',1500),(2,'Blue Whale','Whale','Mammal',2000),(3,'Clownfish','Fish','Teleost',500),(4,'Giant Pacific ... | SELECT species_type, SUM(population) FROM MarineLife GROUP BY species_type; |
Update the department of professors named 'Andrew Kim' to 'Mechanical Engineering'. | CREATE TABLE professors (id INT,name VARCHAR(50),gender VARCHAR(10),department VARCHAR(50),research_interest VARCHAR(50),publication_field VARCHAR(50)); INSERT INTO professors (id,name,gender,department,research_interest,publication_field) VALUES (1,'Sophia Rodriguez','Female','Computer Science','Machine Learning','Art... | UPDATE professors SET department = 'Mechanical Engineering' WHERE name = 'Andrew Kim'; |
What is the number of companies in the 'Technology' sector with an ESG score above 80? | CREATE TABLE companies (id INT,name VARCHAR(255),esg_score DECIMAL(3,2),sector VARCHAR(255)); | SELECT COUNT(*) FROM companies WHERE sector = 'Technology' AND esg_score > 80; |
What are the defense spending figures for European countries in 2021? | CREATE TABLE DefenseSpending (Country VARCHAR(255),Spending FLOAT); INSERT INTO DefenseSpending (Country,Spending) VALUES ('United Kingdom',59.2),('Germany',52.8),('France',50.1),('Italy',26.8); | SELECT Spending FROM DefenseSpending WHERE Country IN ('United Kingdom', 'Germany', 'France', 'Italy'); |
What is the distribution of articles by topic in the news_articles table? | CREATE TABLE news_articles (article_id INT PRIMARY KEY,title TEXT,topic TEXT,author TEXT,publication_date DATE); | SELECT topic, COUNT(*) FROM news_articles GROUP BY topic; |
Show details of military satellites and their launch dates | CREATE TABLE military_satellites (id INT,satellite_name VARCHAR(50),type VARCHAR(50),country VARCHAR(50)); CREATE TABLE satellite_launches (id INT,satellite_id INT,launch_date DATE); INSERT INTO military_satellites (id,satellite_name,type,country) VALUES (1,'Milstar-1','Communications','USA'),(2,'GPS-IIR','Navigation',... | SELECT military_satellites.satellite_name, military_satellites.type, satellite_launches.launch_date FROM military_satellites INNER JOIN satellite_launches ON military_satellites.id = satellite_launches.satellite_id; |
List all the menu items that have a 'Halal' certification | CREATE TABLE menu_items (id INT,name VARCHAR(50),category VARCHAR(50),certification VARCHAR(50),price DECIMAL(5,2)); INSERT INTO menu_items (id,name,category,certification,price) VALUES (101,'Beef Shawarma','Middle Eastern','Halal',7.99),(102,'Chicken Tikka Masala','Indian','Halal',10.99),(103,'Veggie Burger','American... | SELECT name FROM menu_items WHERE certification = 'Halal'; |
Insert a new record in the trees table for a Sequoia tree with a diameter of 120 inches | CREATE TABLE trees (id INT PRIMARY KEY,species VARCHAR(255),diameter FLOAT); | INSERT INTO trees (species, diameter) VALUES ('Sequoia', 120); |
Rank the airports in the Southern United States by the number of runways, and display the airport names and their corresponding runway counts. | CREATE TABLE airports (id INT,airport_name VARCHAR(255),location VARCHAR(255),runways INT); INSERT INTO airports (id,airport_name,location,runways) VALUES (1,'Hartsfield-Jackson Atlanta International Airport','Southern United States',5),(2,'Dallas/Fort Worth International Airport','Southern United States',4),(3,'Miami ... | SELECT airport_name, runways, RANK() OVER (ORDER BY runways DESC) AS runway_rank FROM airports WHERE location = 'Southern United States'; |
Calculate monthly revenue by restaurant | CREATE TABLE sales (sale_id INT PRIMARY KEY,restaurant_id INT,sale_date DATE,revenue DECIMAL(10,2)); | SELECT r.restaurant_id, r.restaurant_name, DATEADD(month, DATEDIFF(month, 0, s.sale_date), 0) as month, SUM(s.revenue) as monthly_revenue FROM sales s JOIN restaurants r ON s.restaurant_id = r.restaurant_id GROUP BY r.restaurant_id, r.restaurant_name, DATEADD(month, DATEDIFF(month, 0, s.sale_date), 0) ORDER BY r.restau... |
How many carbon offset projects and green buildings are in Italy? | CREATE TABLE CarbonOffsets (id INT,project_name VARCHAR(50),country VARCHAR(50),co2_reduction INT,year INT); INSERT INTO CarbonOffsets (id,project_name,country,co2_reduction,year) VALUES (3,'Forest Regeneration','Italy',4000,2020); | SELECT COUNT(c.id), COUNT(g.id) FROM CarbonOffsets c INNER JOIN GreenBuildings g ON c.country = g.country WHERE c.country = 'Italy'; |
What is the total cost of all highway projects in the Pacific Northwest that started before 2015? | CREATE TABLE highway_projects (project_id INT,project_name VARCHAR(100),state CHAR(2),start_date DATE,cost FLOAT); INSERT INTO highway_projects VALUES (1,'I-5 Columbia River Bridge Replacement','OR','2014-01-01',1000000000),(2,'SR 520 Bridge Replacement','WA','2012-06-15',1500000000),(3,'I-90 Snoqualmie Pass East','WA'... | SELECT SUM(cost) FROM highway_projects WHERE state IN ('OR', 'WA') AND start_date < '2015-01-01'; |
Update the age of tourists visiting Canada from Mexico in 2022. | CREATE TABLE tourism_data (id INT,country VARCHAR(50),destination VARCHAR(50),arrival_date DATE,age INT); INSERT INTO tourism_data (id,country,destination,arrival_date,age) VALUES (6,'Mexico','Canada','2022-08-15',27),(7,'Mexico','Canada','2022-12-29',32); | UPDATE tourism_data SET age = 28 WHERE country = 'Mexico' AND destination = 'Canada' AND YEAR(arrival_date) = 2022; |
What is the average number of likes on posts related to veganism for users in the United States, for the month of January 2022? | CREATE TABLE posts (id INT,user_id INT,content TEXT,likes INT,post_date DATE); CREATE TABLE users (id INT,country VARCHAR(50)); | SELECT AVG(likes) as avg_likes FROM posts p JOIN users u ON p.user_id = u.id WHERE u.country = 'United States' AND post_date >= '2022-01-01' AND post_date <= '2022-01-31' AND content LIKE '%vegan%'; |
List all the unique IP addresses that have attempted a brute force attack on our systems, along with the total number of attempts made by each IP. | CREATE TABLE brute_force_attacks (ip VARCHAR(255),timestamp TIMESTAMP); CREATE TABLE attack_counts (ip VARCHAR(255),count INT); INSERT INTO brute_force_attacks (ip,timestamp) VALUES ('192.168.1.1','2021-01-01 10:00:00'),('192.168.1.2','2021-01-01 11:00:00'); INSERT INTO attack_counts (ip,count) VALUES ('192.168.1.1',5)... | SELECT ip, COUNT(*) as total_attempts FROM brute_force_attacks INNER JOIN attack_counts ON brute_force_attacks.ip = attack_counts.ip GROUP BY ip; |
Which building permits were issued in the last 30 days? | CREATE TABLE building_permits (permit_id SERIAL PRIMARY KEY,issue_date DATE); INSERT INTO building_permits (issue_date) VALUES ('2022-01-01'),('2022-01-10'),('2022-02-01'); | SELECT permit_id, issue_date FROM building_permits WHERE issue_date >= NOW() - INTERVAL '30 days'; |
List the number of safe AI algorithms designed for autonomous vehicles grouped by their evaluation category. | CREATE TABLE safe_ai_algorithms_av (id INT,algorithm VARCHAR(25),evaluation VARCHAR(25),score FLOAT); INSERT INTO safe_ai_algorithms_av (id,algorithm,evaluation,score) VALUES (1,'AlgorithmJ','Robustness',0.93),(2,'AlgorithmK','Security',0.96),(3,'AlgorithmL','Reliability',0.92),(4,'AlgorithmM','Robustness',0.97); | SELECT evaluation, COUNT(*) as num_algorithms FROM safe_ai_algorithms_av WHERE evaluation IN ('Robustness', 'Security', 'Reliability') GROUP BY evaluation; |
What is the percentage of games played at home for each team? | CREATE TABLE teams (team_id INT,team_name TEXT,city TEXT); CREATE TABLE games (game_id INT,team_id INT,home BOOLEAN); | SELECT t.team_name, (SUM(g.home) * 100.0 / COUNT(g.game_id)) as home_percentage FROM games g JOIN teams t ON g.team_id = t.team_id GROUP BY t.team_name; |
Update the vendor address for 'General Dynamics' to 'Virginia' | CREATE TABLE vendors (id INT,vendor_name VARCHAR(255),vendor_location VARCHAR(255)); INSERT INTO vendors (id,vendor_name,vendor_location) VALUES (1,'General Dynamics','Florida'); INSERT INTO vendors (id,vendor_name,vendor_location) VALUES (2,'Bell','Texas'); INSERT INTO vendors (id,vendor_name,vendor_location) VALUES (... | UPDATE vendors SET vendor_location = 'Virginia' WHERE vendor_name = 'General Dynamics'; |
What is the average heart rate of users aged 25-30, during their yoga workouts? | CREATE TABLE Users (id INT,age INT,gender VARCHAR(10)); INSERT INTO Users (id,age,gender) VALUES (1,27,'Female'),(2,31,'Male'); CREATE TABLE Workouts (id INT,user_id INT,activity VARCHAR(20),duration INT,heart_rate INT); INSERT INTO Workouts (id,user_id,activity,duration,heart_rate) VALUES (1,1,'Yoga',60,80),(2,1,'Runn... | SELECT AVG(heart_rate) FROM Users u JOIN Workouts w ON u.id = w.user_id WHERE u.age BETWEEN 25 AND 30 AND w.activity = 'Yoga'; |
How many reviews were there in each city in August 2021? | CREATE TABLE virtual_tours (tour_id INT,hotel_id INT,num_views INT); INSERT INTO virtual_tours (tour_id,hotel_id,num_views) VALUES (1,1,200),(2,2,150); | SELECT hi.city, COUNT(gr.review_date) AS reviews FROM hotel_reviews gr INNER JOIN hotel_info hi ON gr.hotel_id = hi.hotel_id WHERE gr.review_date BETWEEN '2021-08-01' AND '2021-08-31' GROUP BY hi.city; |
Delete the representative with id 3 | CREATE TABLE representatives (id INT PRIMARY KEY,name VARCHAR(255),district INT,title VARCHAR(255)); INSERT INTO representatives (id,name,district,title) VALUES (1,'John Doe',1,'Councilor'),(2,'Jane Doe',2,'Councilor'),(3,'Alex Doe',3,'Councilor'); | DELETE FROM representatives WHERE id = 3; |
Which decentralized applications were developed by Stellar's development team? | CREATE TABLE decentralized_apps (app_name VARCHAR(255),developer VARCHAR(255)); INSERT INTO decentralized_apps (app_name,developer) VALUES ('StellarPort','Stellar Devs'); INSERT INTO decentralized_apps (app_name,developer) VALUES ('Smartlands','Stellar Devs'); | SELECT app_name FROM decentralized_apps WHERE developer = 'Stellar Devs'; |
What is the total mass of the International Space Station? | CREATE TABLE space_objects (id INT,object_name TEXT,mass FLOAT); INSERT INTO space_objects (id,object_name,mass) VALUES (1,'ISS',419454.0); | SELECT mass FROM space_objects WHERE object_name = 'ISS'; |
List all collaborations between artists of different genres in the last year. | CREATE TABLE Collaborations (CollaborationId INT,Artist1 VARCHAR(255),Genre1 VARCHAR(255),Artist2 VARCHAR(255),Genre2 VARCHAR(255),CollaborationDate DATE); INSERT INTO Collaborations (CollaborationId,Artist1,Genre1,Artist2,Genre2,CollaborationDate) VALUES (1,'Drake','Hip Hop','Ariana Grande','Pop','2021-03-26'),(2,'Pos... | SELECT Artist1, Genre1, Artist2, Genre2 FROM Collaborations WHERE CollaborationDate >= DATE_SUB(CURDATE(), INTERVAL 1 YEAR) AND Genre1 <> Genre2; |
List the number of unique accidents for each vessel in descending order. | CREATE TABLE accidents (id INT,vessel_id INT,accident_type VARCHAR(50),date DATE); INSERT INTO accidents VALUES (1,1,'Collision','2021-03-01'),(2,1,'Grounding','2021-05-05'),(3,2,'Collision','2021-02-20'); | SELECT vessel_id, COUNT(DISTINCT accident_type) AS unique_accidents FROM accidents GROUP BY vessel_id ORDER BY unique_accidents DESC; |
Which cultural programs had the most diverse attendance in H1 2022? | CREATE TABLE Events (event_id INT,event_name VARCHAR(255),attendees INT); INSERT INTO Events (event_id,event_name,attendees) VALUES (1,'Music Festival',800),(2,'Art Exhibition',500),(5,'Theater Performance',350); CREATE TABLE Attendee_Demographics (attendee_id INT,attendee_race VARCHAR(255),event_id INT); INSERT INTO A... | SELECT E.event_name, COUNT(DISTINCT AD.attendee_race) as num_races FROM Events E JOIN Attendee_Demographics AD ON E.event_id = AD.event_id JOIN Event_Dates ED ON E.event_id = ED.event_id WHERE YEAR(ED.event_date) = 2022 AND MONTH(ED.event_date) <= 6 GROUP BY E.event_name ORDER BY num_races DESC; |
Which fair trade certified factories have produced the fewest garments in the last year? | CREATE TABLE FairTradeProduction (id INT,factory_id INT,num_garments INT,production_date DATE); INSERT INTO FairTradeProduction (id,factory_id,num_garments,production_date) VALUES (1,1,100,'2021-01-01'),(2,2,200,'2021-02-01'),(3,3,50,'2021-01-15'),(4,1,150,'2021-03-01'); CREATE TABLE FairTradeFactories (id INT,factory_... | SELECT f.factory_name, SUM(p.num_garments) FROM FairTradeProduction p JOIN FairTradeFactories f ON p.factory_id = f.id GROUP BY p.factory_id ORDER BY SUM(p.num_garments) ASC; |
What is the average ESG score for companies in the agriculture sector in Q2 2021? | CREATE TABLE if not exists companies (company_id INT,sector VARCHAR(50),esg_score DECIMAL(3,2),quarter INT,year INT); INSERT INTO companies (company_id,sector,esg_score,quarter,year) VALUES (4,'Agriculture',7.6,2,2021),(5,'Agriculture',7.8,2,2021),(6,'Agriculture',8.1,2,2021); | SELECT AVG(esg_score) FROM companies WHERE sector = 'Agriculture' AND quarter = 2 AND year = 2021; |
What is the total number of players who have played "Puzzle" games and are from "Africa"? | CREATE TABLE Game (id INT,name VARCHAR(255)); INSERT INTO Game (id,name) VALUES (1,'Puzzle'); CREATE TABLE Player (id INT,country VARCHAR(255)); CREATE TABLE GamePlayer (PlayerId INT,GameId INT); INSERT INTO Player (id,country) VALUES (1,'Nigeria'),(2,'Egypt'),(3,'USA'); INSERT INTO GamePlayer (PlayerId,GameId) VALUES ... | SELECT COUNT(DISTINCT PlayerId) FROM GamePlayer GP JOIN Player P ON GP.PlayerId = P.id WHERE GP.GameId = (SELECT G.id FROM Game G WHERE G.name = 'Puzzle') AND P.country = 'Africa'; |
What is the maximum speed of the autonomous vehicle 'AutoV'? | CREATE TABLE Autonomous_Vehicles (id INT,name TEXT,max_speed FLOAT); INSERT INTO Autonomous_Vehicles (id,name,max_speed) VALUES (1,'AutoV',120.5); INSERT INTO Autonomous_Vehicles (id,name,max_speed) VALUES (2,'AutoW',110.0); | SELECT max_speed FROM Autonomous_Vehicles WHERE name = 'AutoV'; |
What was the total revenue for March 2021? | CREATE TABLE restaurant_revenue (date DATE,revenue FLOAT); INSERT INTO restaurant_revenue (date,revenue) VALUES ('2021-03-01',5000),('2021-03-02',6000),('2021-03-03',7000); | SELECT SUM(revenue) FROM restaurant_revenue WHERE date BETWEEN '2021-03-01' AND '2021-03-31'; |
What is the count of patients who received 'Dialectical Behavior Therapy' in 'clinic_k'? | CREATE TABLE patient_treatment (patient_id INT,treatment_name VARCHAR(50),treatment_center VARCHAR(50)); INSERT INTO patient_treatment (patient_id,treatment_name,treatment_center) VALUES (11,'Dialectical Behavior Therapy','clinic_k'); | SELECT COUNT(*) FROM patient_treatment WHERE treatment_name = 'Dialectical Behavior Therapy' AND treatment_center = 'clinic_k'; |
What is the name and age of the oldest inmate in the prison table? | CREATE TABLE prison (id INT,name TEXT,security_level TEXT,age INT); INSERT INTO prison (id,name,security_level,age) VALUES (1,'John Doe','low_security',65); INSERT INTO prison (id,name,security_level,age) VALUES (2,'Jane Smith','medium_security',55); | SELECT name, age FROM prison ORDER BY age DESC LIMIT 1; |
List all clients from the Socially Responsible Microfinance program and their transaction histories. | CREATE TABLE microfinance_program (client_id INT,program_name VARCHAR(30)); INSERT INTO microfinance_program (client_id,program_name) VALUES (101,'Socially Responsible Microfinance'),(102,'Conventional Microfinance'),(103,'Socially Responsible Microfinance'); CREATE TABLE client_transactions (client_id INT,transaction_... | SELECT * FROM microfinance_program INNER JOIN client_transactions ON microfinance_program.client_id = client_transactions.client_id WHERE program_name = 'Socially Responsible Microfinance'; |
What are the names of the top 2 cities with the most eco-friendly hotels in Spain? | CREATE TABLE Eco_Friendly_Hotels (hotel_id INT,hotel_name VARCHAR(50),city VARCHAR(50),country VARCHAR(50),sustainability_rating FLOAT); INSERT INTO Eco_Friendly_Hotels (hotel_id,hotel_name,city,country,sustainability_rating) VALUES (1,'Eco Hotel Madrid','Madrid','Spain',4.8),(2,'Eco Hotel Barcelona','Barcelona','Spain... | SELECT city, hotel_name FROM Eco_Friendly_Hotels WHERE country = 'Spain' GROUP BY city ORDER BY AVG(sustainability_rating) DESC LIMIT 2; |
Determine the percentage of dishes in the 'Mexican' cuisine category that are vegetarian. | CREATE TABLE dishes (dish_id INT PRIMARY KEY,dish_name VARCHAR(255),cuisine_id INT,dietary_restrictions VARCHAR(255),FOREIGN KEY (cuisine_id) REFERENCES cuisine(cuisine_id)); | SELECT (COUNT(*) * 100.0 / (SELECT COUNT(*) FROM dishes WHERE cuisine_id = (SELECT cuisine_id FROM cuisine WHERE cuisine_name = 'Mexican'))) FROM dishes WHERE cuisine_id = (SELECT cuisine_id FROM cuisine WHERE cuisine_name = 'Mexican') AND dietary_restrictions LIKE '%Vegetarian%'; |
What is the total number of electric and hybrid vehicles sold in Europe in the 'SalesData' database? | CREATE TABLE SalesData (Id INT,Make VARCHAR(50),Model VARCHAR(50),FuelType VARCHAR(50),UnitsSold INT,SalesYear INT); | SELECT SUM(UnitsSold) FROM SalesData WHERE FuelType IN ('Electric', 'Hybrid') AND Country = 'Germany' OR Country = 'France' OR Country = 'UK'; |
What is the number of unique games played by players from South America? | CREATE TABLE players (player_id INT,player_name TEXT,country TEXT); INSERT INTO players VALUES (1,'John Doe','Brazil'),(2,'Jane Smith','Argentina'),(3,'Bob Johnson','Canada'); CREATE TABLE games (game_id INT,game_name TEXT,country TEXT); INSERT INTO games VALUES (1,'Game 1','Brazil'),(2,'Game 2','Colombia'),(3,'Game 3'... | SELECT COUNT(DISTINCT player_games.game_id) FROM player_games JOIN players ON player_games.player_id = players.player_id JOIN games ON player_games.game_id = games.game_id WHERE players.country IN ('Brazil', 'Argentina', 'Colombia'); |
Which digital assets were launched in 2020 and have a value greater than 100? | CREATE TABLE digital_assets (id INT,name TEXT,launch_date DATE,value REAL); INSERT INTO digital_assets (id,name,launch_date,value) VALUES (16,'Asset9','2020-03-15',150); INSERT INTO digital_assets (id,name,launch_date,value) VALUES (17,'Asset10','2020-12-31',75); | SELECT * FROM digital_assets WHERE YEAR(launch_date) = 2020 AND value > 100; |
What is the most common mental health condition treated in Seattle? | CREATE TABLE treatments (id INT PRIMARY KEY,patient_id INT,condition TEXT,city TEXT); INSERT INTO treatments (id,patient_id,condition,city) VALUES (1,1,'Anxiety','Seattle'); INSERT INTO treatments (id,patient_id,condition,city) VALUES (2,2,'Depression','Seattle'); INSERT INTO treatments (id,patient_id,condition,city) V... | SELECT condition, COUNT(*) FROM treatments WHERE city = 'Seattle' GROUP BY condition ORDER BY COUNT(*) DESC LIMIT 1; |
What was the total revenue for all Impressionist art pieces sold in 2020? | CREATE TABLE art_pieces (id INT,style VARCHAR(20),year_sold INT,revenue DECIMAL(10,2)); CREATE VIEW impressionist_sales AS SELECT * FROM art_pieces WHERE style = 'Impressionist'; | SELECT SUM(revenue) FROM impressionist_sales WHERE year_sold = 2020; |
Determine the number of hotels that offer 'gym' facilities in the 'Europe' region. | CREATE TABLE gymhotels (id INT,name VARCHAR(255),region VARCHAR(255),has_gym BOOLEAN); INSERT INTO gymhotels (id,name,region,has_gym) VALUES (1,'Fitness Hotel','Europe',1); INSERT INTO gymhotels (id,name,region,has_gym) VALUES (2,'Relax Hotel','Europe',0); | SELECT COUNT(*) FROM gymhotels WHERE region = 'Europe' AND has_gym = 1; |
List all unique station names from the stations table | CREATE TABLE stations (station_id INTEGER,name TEXT,latitude REAL,longitude REAL); INSERT INTO stations (station_id,name,latitude,longitude) VALUES (1,'Downtown',40.7128,-74.0060); | SELECT DISTINCT name FROM stations; |
What is the total revenue generated from members in the New York region who use the wearable technology devices in the past 6 months? | CREATE TABLE Members (MemberID INT,Region VARCHAR(20),MembershipDate DATE); INSERT INTO Members (MemberID,Region,MembershipDate) VALUES (1,'New York','2021-01-01'); CREATE TABLE WearableTech (DeviceID INT,MemberID INT,UsageDate DATE); INSERT INTO WearableTech (DeviceID,MemberID,UsageDate) VALUES (10,1,'2021-05-15'); CR... | SELECT SUM(Transactions.Amount) FROM Members INNER JOIN WearableTech ON Members.MemberID = WearableTech.MemberID INNER JOIN Transactions ON Members.MemberID = Transactions.MemberID WHERE Members.Region = 'New York' AND Transactions.TransactionDate BETWEEN DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH) AND CURRENT_DATE; |
What is the number of virtual tours in each city? | CREATE TABLE virtual_tours (tour_id INT,city TEXT); INSERT INTO virtual_tours (tour_id,city) VALUES (1,'Tokyo'),(2,'Tokyo'),(3,'Osaka'); | SELECT city, COUNT(*) FROM virtual_tours GROUP BY city; |
What is the average project timeline for commercial projects in California? | CREATE TABLE Project_Timeline (Project_ID INT,Project_Name TEXT,Location TEXT,Timeline INT,Type TEXT); INSERT INTO Project_Timeline (Project_ID,Project_Name,Location,Timeline,Type) VALUES (1,'Green House','California',12,'Residential'),(2,'Eco Office','New York',18,'Commercial'),(3,'Solar Farm','Texas',24,'Commercial')... | SELECT AVG(Timeline) FROM Project_Timeline WHERE Location = 'California' AND Type = 'Commercial'; |
Show the total inventory value for all organic products in the inventory. | CREATE TABLE products (id INT,name TEXT,organic BOOLEAN,price DECIMAL,quantity INT); | SELECT SUM(price * quantity) as total_inventory_value FROM products WHERE organic = TRUE; |
What is the average donation amount by corporations in Q1 2022? | CREATE TABLE Donations (DonationID int,DonorType varchar(50),DonationAmount decimal(10,2),DonationDate date); INSERT INTO Donations (DonationID,DonorType,DonationAmount,DonationDate) VALUES (1,'Corporation',2500,'2022-01-10'); INSERT INTO Donations (DonationID,DonorType,DonationAmount,DonationDate) VALUES (2,'Foundatio... | SELECT AVG(DonationAmount) FROM Donations WHERE DonorType = 'Corporation' AND DonationDate BETWEEN '2022-01-01' AND '2022-03-31'; |
What is the average time spent on the platform per day for each player who has used the platform for more than 2 hours, sorted by the average time in descending order? | CREATE TABLE PlayerUsage (PlayerID INT,Platform VARCHAR(50),UsageTime FLOAT,UsageDate DATE); INSERT INTO PlayerUsage (PlayerID,Platform,UsageTime,UsageDate) VALUES (1,'PS5',240,'2022-08-01'),(2,'Xbox',300,'2022-08-02'),(3,'Nintendo Switch',120,'2022-08-01'); | SELECT PlayerID, AVG(UsageTime) AS AvgTimePerDay, Platform FROM PlayerUsage WHERE UsageTime > 2*60 GROUP BY PlayerID, Platform ORDER BY AvgTimePerDay DESC; |
What cybersecurity strategies were implemented before 2022 and have been updated since then? | CREATE TABLE cyber_strategy_updates (strategy_update_id INT PRIMARY KEY,strategy_name VARCHAR(255),update_date DATE); INSERT INTO cyber_strategy_updates (strategy_update_id,strategy_name,update_date) VALUES (1,'Firewall Implementation','2021-01-05'),(2,'Intrusion Detection System','2020-06-10'),(3,'Penetration Testing'... | SELECT s.strategy_name FROM cyber_strategies s INNER JOIN cyber_strategy_updates u ON s.strategy_name = u.strategy_name WHERE s.implementation_year < 2022 AND u.update_date >= '2022-01-01'; |
What is the average daily transaction count for the last month, split by customer gender and day of the week? | CREATE TABLE transactions (transaction_id INT,customer_id INT,product_id INT,category_id INT,transaction_date DATE,amount DECIMAL(10,2),gender VARCHAR(10)); CREATE TABLE customers (customer_id INT,age INT,name VARCHAR(255)); | SELECT c.gender, DATE_FORMAT(t.transaction_date, '%W') as day_of_week, AVG(COUNT(t.transaction_id)) as avg_daily_transaction_count FROM customers c INNER JOIN transactions t ON c.customer_id = t.customer_id WHERE t.transaction_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH) GROUP BY c.gender, day_of_week; |
Who are the top 5 female photographers with the most works in European galleries? | CREATE TABLE Artists (ArtistID int,ArtistName varchar(50),Gender varchar(10),CountryID int); CREATE TABLE Art (ArtID int,ArtName varchar(50),ArtistID int,ArtType varchar(50),GalleryID int); CREATE TABLE Galleries (GalleryID int,GalleryName varchar(50),CountryID int); | SELECT Artists.ArtistName, COUNT(Art.ArtID) as TotalWorks FROM Artists INNER JOIN Art ON Artists.ArtistID = Art.ArtistID INNER JOIN Galleries ON Art.GalleryID = Galleries.GalleryID WHERE Artists.Gender = 'female' AND Galleries.CountryID IN (SELECT CountryID FROM Countries WHERE Continent = 'Europe') AND Art.ArtType = '... |
How many carbon offset initiatives were started in the 'East' region after 2018-01-01? | CREATE TABLE carbon_offset_initiatives (initiative_id INT,initiative_name VARCHAR(100),location VARCHAR(50),start_date DATE); INSERT INTO carbon_offset_initiatives (initiative_id,initiative_name,location,start_date) VALUES (1,'Carbon Farm 2','East','2017-05-01'); INSERT INTO carbon_offset_initiatives (initiative_id,ini... | SELECT COUNT(*) FROM carbon_offset_initiatives WHERE location = 'East' AND start_date > '2018-01-01'; |
What is the total number of infectious diseases reported in New York in 2019? | CREATE TABLE InfectiousDiseases (DiseaseID INT,State VARCHAR(20),Year INT,Disease VARCHAR(50)); INSERT INTO InfectiousDiseases (DiseaseID,State,Year,Disease) VALUES (1,'New York',2019,'COVID-19'); INSERT INTO InfectiousDiseases (DiseaseID,State,Year,Disease) VALUES (2,'New York',2018,'Influenza'); | SELECT COUNT(*) FROM InfectiousDiseases WHERE State = 'New York' AND Year = 2019; |
What is the total number of marine species found in the Indian ocean? | CREATE TABLE marine_species (species_name TEXT,ocean TEXT); INSERT INTO marine_species (species_name,ocean) VALUES ('Whale Shark','Indian Ocean'),('Olive Ridley Turtle','Indian Ocean'),('Indian Mackerel','Indian Ocean'); | SELECT COUNT(*) FROM marine_species WHERE ocean = 'Indian Ocean'; |
Insert a new record into the health_inspections table with a rating of 95 for 'RestaurantA' on '2022-05-15'? | CREATE TABLE Health_Inspections (Restaurant text,Rating int,InspectionDate date); | INSERT INTO Health_Inspections (Restaurant, Rating, InspectionDate) VALUES ('RestaurantA', 95, '2022-05-15'); |
What explainable AI techniques were applied in the past year for speech recognition tasks, in the Explainable AI database? | CREATE TABLE techniques (id INT,name VARCHAR(255),domain VARCHAR(255),published_date DATE); | SELECT name FROM techniques WHERE domain = 'Speech Recognition' AND YEAR(published_date) = YEAR(CURRENT_DATE()); |
Identify the risk rating trends for organizations in the technology sector over time? | CREATE TABLE OrganizationRisks (OrgID INT,Sector VARCHAR(50),RiskRating INT,Year INT); INSERT INTO OrganizationRisks (OrgID,Sector,RiskRating,Year) VALUES (1,'Technology',3,2018),(2,'Technology',4,2018),(3,'Technology',2,2019),(4,'Technology',3,2019),(5,'Technology',5,2020),(6,'Technology',4,2020); | SELECT Sector, Year, RiskRating, COUNT(*) OVER (PARTITION BY Sector, RiskRating ORDER BY Year) as CountByRiskRating FROM OrganizationRisks WHERE Sector = 'Technology'; |
What is the total claim amount for policyholders in New York with 'Home' policy_type? | INSERT INTO claims (id,policyholder_id,claim_amount,claim_date) VALUES (4,3,3000,'2021-02-03'); INSERT INTO claims (id,policyholder_id,claim_amount,claim_date) VALUES (5,3,1000,'2021-06-18'); | SELECT SUM(claim_amount) FROM claims JOIN policyholders ON claims.policyholder_id = policyholders.id WHERE policyholders.state = 'New York' AND policyholders.policy_type = 'Home'; |
How many green building projects were completed in each city in the 'GreenBuildingProjects' table? | CREATE TABLE GreenBuildingProjects (id INT,city VARCHAR(50),project_status VARCHAR(50)); INSERT INTO GreenBuildingProjects (id,city,project_status) VALUES (1,'NYC','Completed'),(2,'LA','In Progress'),(3,'NYC','Completed'); | SELECT city, COUNT(*) FROM GreenBuildingProjects WHERE project_status = 'Completed' GROUP BY city; |
What is the capacity of landfills in the North American region? | CREATE TABLE landfills (id INT,region_id INT,capacity INT); INSERT INTO landfills (id,region_id,capacity) VALUES (1,3,1000),(2,3,2000),(3,1,500),(4,1,700); CREATE TABLE regions (id INT,name VARCHAR(20)); INSERT INTO regions (id,name) VALUES (1,'North America'),(2,'South America'),(3,'Europe'); | SELECT SUM(landfills.capacity) FROM landfills INNER JOIN regions ON landfills.region_id = regions.id WHERE regions.name = 'North America'; |
In hotel_reviews_table, for the Europe region, update the rating to 1 star lower if the original rating is 5 | CREATE TABLE hotel_reviews (id INT,hotel_id INT,guest_name VARCHAR(50),rating INT,review_date DATE,region VARCHAR(50)); | UPDATE hotel_reviews SET rating = CASE WHEN rating = 5 THEN 4 ELSE rating END WHERE region = 'Europe'; |
Count the number of renewable energy projects in each country by energy source. | CREATE TABLE renewable_projects (project_id INT,project_name VARCHAR(100),country VARCHAR(50),energy_source VARCHAR(50),installed_capacity FLOAT); CREATE TABLE countries (country VARCHAR(50),continent VARCHAR(50)); | SELECT r.energy_source, c.country, COUNT(r.project_id) FROM renewable_projects r INNER JOIN countries c ON r.country = c.country GROUP BY r.energy_source, c.country; |
How many unique customers have purchased size 12 garments in the last 6 months? | CREATE TABLE Customer_Data (Customer_ID INT,Purchase_Date DATE,Item_Size INT); INSERT INTO Customer_Data (Customer_ID,Purchase_Date,Item_Size) VALUES (1,'2022-01-01',12),(2,'2022-02-01',14),(3,'2022-03-01',12),(4,'2022-04-01',16),(5,'2022-05-01',12),(6,'2022-06-01',12); | SELECT COUNT(DISTINCT Customer_ID) FROM Customer_Data WHERE Item_Size = 12 AND Purchase_Date BETWEEN '2022-01-01' AND '2022-06-30'; |
What is the earliest and latest time a bus has departed from a station, for each station, in the last month? | CREATE TABLE bus_stations (id INT,station_id INT,departure_time TIME); INSERT INTO bus_stations (id,station_id,departure_time) VALUES (1,1,'07:00:00'),(2,2,'08:00:00'),(3,1,'18:00:00'); | SELECT MIN(departure_time) as earliest_time, MAX(departure_time) as latest_time, station_id FROM bus_stations WHERE departure_time >= DATEADD(day, -30, GETDATE()) GROUP BY station_id; |
What is the percentage of global coal production by China? | CREATE TABLE annual_production (id INT,country VARCHAR(255),mineral VARCHAR(255),year INT,quantity INT); INSERT INTO annual_production (id,country,mineral,year,quantity) VALUES (1,'China','Coal',2020,3500),(2,'USA','Coal',2020,1200),(3,'India','Coal',2020,2000); | SELECT 100.0 * SUM(CASE WHEN country = 'China' THEN quantity ELSE 0 END) / SUM(quantity) as percentage_of_global_coal_production FROM annual_production WHERE mineral = 'Coal' AND year = 2020; |
What is the total number of public participation events in the healthcare sector in the last 4 years? | CREATE TABLE public_participation_events (id INT,sector VARCHAR(20),year INT); INSERT INTO public_participation_events (id,sector,year) VALUES (1,'justice',2018),(2,'justice',2019),(3,'justice',2020),(4,'healthcare',2018),(5,'healthcare',2019),(6,'healthcare',2020),(7,'healthcare',2021); | SELECT SUM(1) FROM public_participation_events WHERE sector = 'healthcare' AND year BETWEEN (SELECT MAX(year) - 3 FROM public_participation_events) AND MAX(year); |
Which types of vulnerabilities were found in the healthcare sector in the past week? | CREATE TABLE vulnerabilities (id INT,sector VARCHAR(255),vulnerability VARCHAR(255),date DATE); | SELECT DISTINCT vulnerability FROM vulnerabilities WHERE sector = 'healthcare' AND date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 WEEK); |
What is the maximum funding amount for biotech startups located in each state? | CREATE SCHEMA if not exists biotech;USE biotech;CREATE TABLE if not exists startups(id INT,name VARCHAR(255),location VARCHAR(255),funding FLOAT);INSERT INTO startups(id,name,location,funding) VALUES (1,'StartupA','California',15000000.00),(2,'StartupB','New York',20000000.00),(3,'StartupC','California',12000000.00),(4... | SELECT location, MAX(funding) FROM biotech.startups GROUP BY location; |
How many startups have exited via acquisition or IPO in the E-commerce sector? | CREATE TABLE startups(id INT,name TEXT,sector TEXT,exit_strategy TEXT); INSERT INTO startups VALUES(1,'StartupA','E-commerce','Acquisition'); INSERT INTO startups VALUES(2,'StartupB','Tech','IPO'); INSERT INTO startups VALUES(3,'StartupC','E-commerce','Bankruptcy'); INSERT INTO startups VALUES(4,'StartupD','Finance','A... | SELECT COUNT(*) FROM startups WHERE sector = 'E-commerce' AND exit_strategy IN ('Acquisition', 'IPO'); |
Insert data into 'farmers' table | CREATE TABLE farmers (id INT PRIMARY KEY,name VARCHAR(100),age INT,gender VARCHAR(10),location VARCHAR(50)); INSERT INTO farmers (id,name,age,gender,location) VALUES (1,'Jane Doe',35,'Female','Rural Texas'); | INSERT INTO farmers (id, name, age, gender, location) VALUES (2, 'Pedro Alvarez', 42, 'Male', 'Rural Mexico'); |
What is the total number of emergency incidents for each type, ordered by the total? | CREATE TABLE emergency_incidents (id INT,incident_type VARCHAR(255),incident_count INT); INSERT INTO emergency_incidents (id,incident_type,incident_count) VALUES (1,'Medical',300),(2,'Fire',150),(3,'Rescue',200); | SELECT incident_type, SUM(incident_count) as total_incidents FROM emergency_incidents GROUP BY incident_type ORDER BY total_incidents DESC; |
Identify top 5 donors by total donation amount | CREATE TABLE donors (id INT,name VARCHAR(50)); | SELECT d.name, SUM(donations.amount) as total_donations FROM donors d JOIN donations ON d.id = donations.donor_id GROUP BY d.name ORDER BY total_donations DESC LIMIT 5; |
What are the names of the military operations in the 'Military_Operations' table? | CREATE TABLE Military_Operations (id INT,operation VARCHAR(50)); INSERT INTO Military_Operations (id,operation) VALUES (1,'Operation Enduring Freedom'); INSERT INTO Military_Operations (id,operation) VALUES (2,'Operation Iraqi Freedom'); | SELECT DISTINCT operation FROM Military_Operations; |
What is the most common case type in the database? | CREATE TABLE cases (case_id INT,case_type VARCHAR(50)); INSERT INTO cases (case_id,case_type) VALUES (1,'Divorce'),(2,'Bankruptcy'),(3,'Divorce'),(4,'Custody'); | SELECT case_type, COUNT(*) as count FROM cases GROUP BY case_type ORDER BY count DESC LIMIT 1; |
Show the top 3 destinations with the highest percentage of eco-friendly hotels among all hotels in their respective countries. | CREATE TABLE countries (country_id INT,name TEXT,region TEXT); CREATE TABLE hotels (hotel_id INT,name TEXT,country TEXT,stars FLOAT,is_eco_friendly BOOLEAN); | SELECT c.name, COUNT(h.hotel_id) AS total_hotels, SUM(h.is_eco_friendly) AS eco_friendly_hotels, ROUND(SUM(h.is_eco_friendly) * 100.0 / COUNT(h.hotel_id), 2) AS pct_eco_friendly FROM hotels h INNER JOIN countries c ON h.country = c.name GROUP BY c.name ORDER BY pct_eco_friendly DESC, total_hotels DESC LIMIT 3; |
What is the total word count of articles published in 2020? | CREATE TABLE articles (id INT,title VARCHAR(100),content TEXT,publish_date DATE,word_count INT); INSERT INTO articles (id,title,content,publish_date,word_count) VALUES (1,'Article 1','Content 1','2020-01-01',500),(2,'Article 2','Content 2','2020-01-15',700),(3,'Article 3','Content 3','2019-12-31',600); | SELECT SUM(word_count) as total_word_count FROM articles WHERE YEAR(publish_date) = 2020; |
What are the site names, locations, and total number of artifacts for excavation sites with public outreach events? | CREATE TABLE ExcavationSites (SiteID int,SiteName varchar(50),Location varchar(50)); CREATE TABLE PublicOutreach (EventID int,SiteID int,EventType varchar(20)); CREATE TABLE Artifacts (ArtifactID int,SiteID int,Material varchar(20),Description varchar(100)); | SELECT ExcavationSites.SiteName, ExcavationSites.Location, COUNT(Artifacts.ArtifactID) AS TotalArtifacts FROM ExcavationSites INNER JOIN PublicOutreach ON ExcavationSites.SiteID = PublicOutreach.SiteID INNER JOIN Artifacts ON ExcavationSites.SiteID = Artifacts.SiteID WHERE PublicOutreach.EventType = 'event' GROUP BY Ex... |
What is the average word count of blog posts written by authors from Asia and Africa, in the last month? | CREATE TABLE blog_posts (id INT,title VARCHAR(50),word_count INT,author_name VARCHAR(50),author_region VARCHAR(50)); INSERT INTO blog_posts (id,title,word_count,author_name,author_region) VALUES (1,'Post1',500,'John Doe','Asia'),(2,'Post2',700,'Jane Smith','Africa'),(3,'Post3',600,'Bob Johnson','Asia'),(4,'Post4',800,'... | SELECT author_region, AVG(word_count) as avg_word_count FROM blog_posts WHERE author_region IN ('Asia', 'Africa') AND post_date >= NOW() - INTERVAL 30 DAY GROUP BY author_region; |
How many visitors attended each program type in the first half of 2021? | CREATE SCHEMA culture; CREATE TABLE programs (program_id INT,type VARCHAR(255),visitors INT,program_date DATE); INSERT INTO programs (program_id,type,visitors,program_date) VALUES (1,'Exhibition',200,'2021-01-10'),(2,'Workshop',50,'2021-02-12'),(3,'Lecture',100,'2021-03-15'); | SELECT type, COUNT(visitors) as total_visitors FROM programs WHERE program_date < DATEADD(year, 1, '2021-01-01') AND program_date >= '2021-01-01' GROUP BY type; |
What is the minimum number of military innovation projects initiated by ASEAN that involve artificial intelligence (AI) between 2017 and 2022, inclusive? | CREATE TABLE military_innovation_projects(id INT,organization VARCHAR(255),project VARCHAR(255),start_year INT,technology VARCHAR(255)); INSERT INTO military_innovation_projects(id,organization,project,start_year,technology) VALUES (1,'ASEAN','AI in Border Control',2017,'AI'),(2,'AU','Autonomous Underwater Vehicles',20... | SELECT MIN(id) FROM military_innovation_projects WHERE organization = 'ASEAN' AND technology = 'AI' AND start_year BETWEEN 2017 AND 2022; |
What is the total quantity of lumber used in green building projects in Seattle, WA? | CREATE TABLE Materials (Id INT,MaterialName VARCHAR(50),Quantity INT,UnitPrice DECIMAL(5,2),ProjectId INT); CREATE TABLE Projects (Id INT,Name VARCHAR(50),City VARCHAR(50),StartDate DATE,EndDate DATE,Sustainable BOOLEAN,Country VARCHAR(50)); | SELECT SUM(m.Quantity) FROM Materials m JOIN Projects p ON m.ProjectId = p.Id WHERE p.City = 'Seattle' AND p.Country = 'WA' AND p.Sustainable = TRUE AND m.MaterialName = 'Lumber'; |
Update the fare for the 'subway' service to $2.50 on January 1, 2023. | CREATE TABLE fares (service text,date date,fare decimal); INSERT INTO fares (service,date,fare) VALUES ('subway','2023-01-01',2.50),('bus','2023-01-02',1.50); | UPDATE fares SET fare = 2.50 WHERE service = 'subway' AND date = '2023-01-01'; |
List all basketball players who have played for the 'Golden State Warriors' and their total points scored, sorted by the number of games played. | CREATE TABLE players (player_id INT,player_name VARCHAR(255),team_name VARCHAR(255)); INSERT INTO players VALUES (1,'Stephen Curry','Golden State Warriors'); INSERT INTO players VALUES (2,'Kevin Durant','Golden State Warriors'); CREATE TABLE points (player_id INT,points INT,games_played INT); INSERT INTO points VALUES ... | SELECT p.player_name, p.team_name, SUM(pnts.points) as total_points FROM players p INNER JOIN points pnts ON p.player_id = pnts.player_id WHERE p.team_name = 'Golden State Warriors' GROUP BY p.player_id ORDER BY games_played DESC; |
What is the maximum humanitarian assistance provided by Japan? | CREATE TABLE humanitarian_assistance (country VARCHAR(50),amount NUMERIC(10,2)); INSERT INTO humanitarian_assistance (country,amount) VALUES ('Japan',25000000),('USA',50000000),('Germany',15000000),('UK',20000000),('France',22000000); | SELECT MAX(amount) FROM humanitarian_assistance WHERE country = 'Japan'; |
Update the production quantity of Dysprosium in 2018 to 13500 in the 'rare_earth_production' table. | CREATE TABLE rare_earth_production (year INT,element VARCHAR(10),production_quantity FLOAT); INSERT INTO rare_earth_production (year,element,production_quantity) VALUES (2015,'Neodymium',12000),(2016,'Neodymium',15000),(2017,'Neodymium',18000),(2018,'Neodymium',20000),(2019,'Neodymium',22000),(2020,'Neodymium',25000),(... | UPDATE rare_earth_production SET production_quantity = 13500 WHERE element = 'Dysprosium' AND year = 2018; |
Determine the number of marine species sighted in the last year, grouped by ocean basin. | CREATE TABLE marine_sightings (id INT,marine_life_type VARCHAR(255),sighting_date DATE,ocean_basin VARCHAR(255)); INSERT INTO marine_sightings (id,marine_life_type,sighting_date,ocean_basin) VALUES (1,'Coral','2021-01-01','Atlantic'),(2,'Anglerfish','2021-01-01','Pacific'); | SELECT ocean_basin, COUNT(*) FROM marine_sightings WHERE sighting_date > (CURRENT_DATE - INTERVAL '1 year') GROUP BY ocean_basin; |
Find the total number of games and unique genres for each platform. | CREATE TABLE Games (GameID INT,GameName VARCHAR(50),Platform VARCHAR(10),GameGenre VARCHAR(20)); | SELECT Platform, COUNT(DISTINCT GameGenre) AS Unique_Genres, COUNT(*) AS Total_Games FROM Games GROUP BY Platform; |
List all the coaches who have managed both national and club teams. | CREATE TABLE coaches (id INT,name TEXT,type TEXT); CREATE TABLE teams (id INT,name TEXT,type TEXT); | SELECT c.name FROM coaches c INNER JOIN teams t1 ON c.id = t1.coach INNER JOIN teams t2 ON c.id = t2.coach WHERE t1.type = 'national' AND t2.type = 'club'; |
What is the average age of fishing vessels in the Canadian registry? | CREATE TABLE Vessels (VesselID INT,Name TEXT,Type TEXT,YearBuilt INT,Registry TEXT); INSERT INTO Vessels VALUES (1,'Fishing Vessel 1','Fishing',2005,'Canada'),(2,'Fishing Vessel 2','Fishing',2012,'Canada'); | SELECT AVG(YEAR(CURRENT_DATE) - Vessels.YearBuilt) FROM Vessels WHERE Vessels.Registry = 'Canada' AND Vessels.Type = 'Fishing'; |
What is the total energy consumption (in kWh) of green buildings in each state? | CREATE TABLE green_buildings (id INT,building_name VARCHAR(255),state VARCHAR(255),energy_consumption FLOAT); | SELECT state, SUM(energy_consumption) FROM green_buildings GROUP BY state; |
What is the total number of passengers carried by each airline, grouped by the type of aircraft and the airline, for the past year? | CREATE TABLE flights(airline VARCHAR(255),aircraft_type VARCHAR(255),flight_date DATE,passengers INT); | SELECT airline, aircraft_type, SUM(passengers) as Total_Passengers FROM flights WHERE flight_date >= DATE_SUB(CURDATE(), INTERVAL 1 YEAR) GROUP BY airline, aircraft_type; |
What is the maximum, minimum, and average age of volunteers who engaged in programs in the year 2020, and the total number of volunteers in that time period? | CREATE TABLE Volunteers (VolunteerID INT,Name TEXT,Age INT,ProgramID INT,VolunteerDate DATE); INSERT INTO Volunteers VALUES (1,'Alice',25,1,'2020-01-01'),(2,'Bob',30,1,'2020-06-01'),(3,'Charlie',35,2,'2020-06-01'),(4,'David',40,2,'2020-12-31'); | SELECT MIN(Age) as MinAge, MAX(Age) as MaxAge, AVG(Age) as AvgAge, COUNT(*) as NumVolunteers FROM Volunteers WHERE YEAR(VolunteerDate) = 2020; |
What is the average ticket price for baseball games in Chicago and Boston? | CREATE TABLE tickets (ticket_id INT,game_id INT,quantity INT,price DECIMAL(5,2),team VARCHAR(20)); INSERT INTO tickets VALUES (1,1,50,35.99,'Cubs'); INSERT INTO tickets VALUES (2,2,30,29.99,'Red Sox'); | SELECT AVG(tickets.price) FROM tickets WHERE tickets.team IN ('Cubs', 'Red Sox') GROUP BY tickets.team HAVING tickets.team IN ('Cubs', 'Red Sox'); |
What is the total amount of funds donated by each donor for the Nepal earthquake relief campaign? | CREATE TABLE Donors (DonorID int,DonorName varchar(50),DonatedAmount decimal(10,2)); INSERT INTO Donors (DonorID,DonorName,DonatedAmount) VALUES (1,'John Smith',500.00),(2,'Jane Doe',800.00); CREATE TABLE DisasterRelief (CampaignID int,DonorID int,DisasterType varchar(50),DonatedAmount decimal(10,2)); INSERT INTO Disas... | SELECT DonorName, SUM(DonatedAmount) as TotalDonated FROM Donors INNER JOIN DisasterRelief ON Donors.DonorID = DisasterRelief.DonorID WHERE DisasterType = 'Nepal Earthquake' GROUP BY DonorName; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.