instruction stringlengths 0 1.06k | input stringlengths 11 5.3k | response stringlengths 2 4.44k |
|---|---|---|
What is the total size of marine protected areas in the Mediterranean Sea? | CREATE TABLE marine_protected_areas (name VARCHAR(255),area_id INT,depth FLOAT,size INT,country VARCHAR(255)); INSERT INTO marine_protected_areas (name,area_id,depth,size,country) VALUES ('Cinque Terre Marine Protected Area',15,10,3800,'Italy'),('Kornati National Park',16,100,22000,'Croatia'); | SELECT SUM(size) FROM marine_protected_areas WHERE country = 'Mediterranean Sea'; |
What are the top 3 strains sold in 'dispensary_sales' table? | CREATE TABLE dispensary_sales (id INT,strain VARCHAR(255),quantity INT,revenue FLOAT); | SELECT strain, SUM(quantity) as total_quantity FROM dispensary_sales GROUP BY strain ORDER BY total_quantity DESC LIMIT 3; |
What is the maximum number of days spent in space by an astronaut? | CREATE TABLE astronauts(name TEXT,missions INTEGER,days_in_space REAL); INSERT INTO astronauts(name,missions,days_in_space) VALUES('Neil Armstrong',1,265.5),('Buzz Aldrin',1,216.4); | SELECT MAX(days_in_space) FROM astronauts; |
What is the total amount donated by top 5 donors in 2021? | CREATE TABLE Donations (DonorID int,DonationDate date,Amount decimal(10,2)); INSERT INTO Donations (DonorID,DonationDate,Amount) VALUES (1,'2021-01-01',500.00),(2,'2021-02-15',300.00); | SELECT SUM(Amount) as TotalDonation FROM (SELECT DonorID, SUM(Amount) as Amount FROM Donations WHERE YEAR(DonationDate) = 2021 GROUP BY DonorID ORDER BY Amount DESC LIMIT 5) as TopDonors; |
What is the total budget allocated for education programs in the "GovernmentBudget" table, for each department, where the budget was over $100,000? | CREATE TABLE GovernmentBudget (id INT,department VARCHAR(50),program VARCHAR(50),budget DECIMAL(10,2)); INSERT INTO GovernmentBudget (id,department,program,budget) VALUES (1,'Education','Elementary School',50000),(2,'Education','High School',120000),(3,'Education','College',200000),(4,'Healthcare','Hospital',300000); | SELECT department, SUM(budget) as total_budget FROM GovernmentBudget WHERE budget > 100000 AND program LIKE '%Education%' GROUP BY department; |
What is the total number of cybersecurity incidents and their corresponding severity levels, along with the government departments responsible for addressing them in the last 24 months? | CREATE TABLE cybersecurity_incidents (id INT,name VARCHAR(255),severity_level INT,reported_date DATE,department_id INT); CREATE TABLE government_departments (id INT,name VARCHAR(255)); INSERT INTO cybersecurity_incidents (id,name,severity_level,reported_date,department_id) VALUES (1,'Incident A',4,'2022-01-01',101),(2,... | SELECT COUNT(id) as total_incidents, i.severity_level, d.name as department_name FROM cybersecurity_incidents i JOIN government_departments d ON i.department_id = d.id WHERE i.reported_date >= DATE_SUB(CURRENT_DATE, INTERVAL 24 MONTH) GROUP BY i.severity_level, d.name; |
How many 'Social Welfare' initiatives were deleted from the database in Q1 of 2022? | CREATE TABLE DeletedInitiatives (Initiative VARCHAR(50),Department VARCHAR(50),DeleteDate DATE); INSERT INTO DeletedInitiatives (Initiative,Department,DeleteDate) VALUES ('Food Aid Program','Social Welfare','2022-01-18'),('Job Training Program','Social Welfare','2022-03-05'),('Housing Assistance','Social Welfare','2022... | SELECT COUNT(*) FROM DeletedInitiatives WHERE Department = 'Social Welfare' AND DeleteDate >= '2022-01-01' AND DeleteDate < '2022-04-01'; |
What is the average package weight for each warehouse? | CREATE TABLE warehouse_stats (warehouse_id VARCHAR(5),avg_weight DECIMAL(5,2)); INSERT INTO warehouse_stats (warehouse_id,avg_weight) VALUES ('LA',2.5),('NY',3.0),('CH',2.0),('MI',1.5),('AT',4.0); | SELECT warehouse_id, avg_weight FROM warehouse_stats; |
Find the average salary of employees in each department, ranked by the average salary in descending order, and display the top 3 departments. | CREATE TABLE Employees (EmployeeID INT,Salary INT,Department VARCHAR(50)); | SELECT Department, AVG(Salary) AS AvgSalary FROM Employees GROUP BY Department ORDER BY AvgSalary DESC LIMIT 3; |
What is the total number of visitors who attended exhibitions in Tokyo, grouped by year? | CREATE TABLE Exhibitions (id INT,city VARCHAR(255),visitors INT,year INT); INSERT INTO Exhibitions (id,city,visitors,year) VALUES (1,'New York',2500,2018),(2,'Los Angeles',1800,2019),(3,'Chicago',2200,2018),(4,'San Francisco',1500,2019),(5,'Miami',1200,2018),(6,'Tokyo',1900,2018),(7,'Tokyo',2100,2019); | SELECT year, SUM(visitors) FROM Exhibitions WHERE city = 'Tokyo' GROUP BY year; |
Find the number of new museum members per month | CREATE TABLE Members (member_id INT,membership_date DATE); INSERT INTO Members (member_id,membership_date) VALUES (1,'2022-01-01'),(2,'2022-02-15'),(3,'2022-03-05'); | SELECT EXTRACT(MONTH FROM membership_date) as month, COUNT(*) as new_members FROM Members GROUP BY month; |
List all the unique defense contractor names from the contractor_info view. | CREATE VIEW contractor_info AS SELECT contractor_name FROM defense_contracts; | SELECT DISTINCT contractor_name FROM contractor_info; |
What is the total number of autonomous and semi-autonomous vehicles in the 'autonomous_test_vehicles' table? | CREATE TABLE autonomous_test_vehicles (vehicle_id INT,make VARCHAR(50),model VARCHAR(50),autonomy_level INT); | SELECT COUNT(*) FROM autonomous_test_vehicles WHERE autonomy_level IN (1, 2, 3, 4, 5); |
What is the total cost of emergency equipment for each district? | CREATE TABLE emergency_equipment (eid INT,did INT,cost DECIMAL(10,2),PRIMARY KEY(eid),FOREIGN KEY (did) REFERENCES districts(did)); | SELECT d.name, SUM(ee.cost) as total_cost FROM districts d JOIN emergency_equipment ee ON d.did = ee.did GROUP BY d.name; |
Calculate the total carbon pricing revenue for the United States and China. | CREATE TABLE carbon_pricing (id INT,country VARCHAR(255),scheme VARCHAR(255),revenue FLOAT); INSERT INTO carbon_pricing (id,country,scheme,revenue) VALUES (1,'United States','ETS',2000000); INSERT INTO carbon_pricing (id,country,scheme,revenue) VALUES (2,'United States','Carbon Tax',1500000); INSERT INTO carbon_pricing... | SELECT SUM(revenue) FROM carbon_pricing WHERE country IN ('United States', 'China'); |
Delete the 'Seafood Paella' from the 'Dinner' menu | CREATE TABLE Menu (menu_name VARCHAR(20),item_name VARCHAR(30),price DECIMAL(5,2)); INSERT INTO Menu (menu_name,item_name,price) VALUES ('Dinner','Seafood Paella',21.99); | DELETE FROM Menu WHERE menu_name = 'Dinner' AND item_name = 'Seafood Paella'; |
What is the average donation amount per social impact project in H2 2020? | CREATE TABLE donations (donation_id INT,donation_amount DECIMAL(10,2),social_impact_project VARCHAR(255),donation_date DATE); INSERT INTO donations (donation_id,donation_amount,social_impact_project,donation_date) VALUES (1,200,'Education','2020-07-01'),(2,300,'Healthcare','2020-08-05'),(3,150,'Environment','2020-11-15... | SELECT AVG(donation_amount) FROM donations WHERE YEAR(donation_date) = 2020 AND MONTH(donation_date) > 6 GROUP BY social_impact_project; |
What is the total number of AI safety incidents reported in the healthcare sector, and what is the maximum number of incidents reported for a single incident type? | CREATE TABLE AISafety (id INT,incident_sector VARCHAR(50),incident_type VARCHAR(50)); INSERT INTO AISafety (id,incident_sector,incident_type) VALUES (1,'Healthcare','Data Privacy'),(2,'Healthcare','Medical Error'),(3,'Finance','Financial Loss'),(4,'Healthcare','Unintended Consequence'),(5,'Healthcare','System Failure')... | SELECT incident_sector, COUNT(incident_type) as incident_count FROM AISafety WHERE incident_sector = 'Healthcare' GROUP BY incident_sector; SELECT MAX(incident_count) as max_incidents FROM (SELECT incident_sector, COUNT(incident_type) as incident_count FROM AISafety WHERE incident_sector = 'Healthcare' GROUP BY inciden... |
Show the total value of defense contracts for each country in the 'Contracts' table, sorted by the total value in descending order | CREATE TABLE Contracts (id INT,country VARCHAR(255),value FLOAT); | SELECT country, SUM(value) as total_value FROM Contracts GROUP BY country ORDER BY total_value DESC; |
What is the total revenue of cultural heritage preservation projects in Italy? | CREATE TABLE PreservationProjects (id INT,name TEXT,country TEXT,revenue FLOAT); INSERT INTO PreservationProjects (id,name,country,revenue) VALUES (1,'Roman Colosseum Restoration','Italy',5000000),(2,'Florence Museum Renovation','Italy',7000000); | SELECT SUM(revenue) FROM PreservationProjects WHERE country = 'Italy'; |
What is the total quantity of unisex organic cotton hoodies sold in Japan? | CREATE TABLE sales (id INT,category VARCHAR(255),subcategory VARCHAR(255),gender VARCHAR(50),material VARCHAR(50),country VARCHAR(50),quantity INT); INSERT INTO sales (id,category,subcategory,gender,material,country,quantity) VALUES (1,'Tops','Hoodies','Unisex','Organic Cotton','Japan',40); INSERT INTO sales (id,catego... | SELECT SUM(quantity) FROM sales WHERE category = 'Tops' AND subcategory = 'Hoodies' AND gender = 'Unisex' AND material = 'Organic Cotton' AND country = 'Japan'; |
What is the total data usage for the month? | CREATE TABLE data_usage (usage_id INT,data_usage INT,usage_date DATE); | SELECT SUM(data_usage) FROM data_usage WHERE usage_date BETWEEN '2022-01-01' AND '2022-01-31'; |
Identify the garments with the highest selling price, per production region? | CREATE TABLE EthicalFashion.GarmentSales (garment_id INT,selling_price DECIMAL(5,2),production_region VARCHAR(20)); INSERT INTO EthicalFashion.GarmentSales (garment_id,selling_price,production_region) VALUES (1,55.99,'Asia'),(2,44.49,'Africa'),(3,77.50,'South America'); | SELECT garment_id, selling_price, production_region, ROW_NUMBER() OVER (PARTITION BY production_region ORDER BY selling_price DESC) AS rank FROM EthicalFashion.GarmentSales; |
What is the average production output of plants in the 'Manufacturing' department? | CREATE TABLE plants (plant_id INT,plant_name VARCHAR(50),department VARCHAR(50),production_output INT); INSERT INTO plants (plant_id,plant_name,department,production_output) VALUES (1,'PlantA','Manufacturing',500),(2,'PlantB','Engineering',700),(3,'PlantC','Manufacturing',600),(4,'PlantD','Manufacturing',800); | SELECT AVG(production_output) FROM plants WHERE department = 'Manufacturing'; |
Identify the state with the lowest number of mental health parity regulations implemented. | CREATE TABLE MentalHealthParityRegulations (State VARCHAR(20),Year INT,Regulation VARCHAR(100)); INSERT INTO MentalHealthParityRegulations (State,Year,Regulation) VALUES ('California',2018,'Regulation 1'),('California',2019,'Regulation 2'),('Texas',2017,'Regulation A'),('Texas',2018,'Regulation B'),('New York',2017,'Re... | SELECT State, MIN(RegulationCount) AS LowestCount FROM (SELECT State, COUNT(*) AS RegulationCount FROM MentalHealthParityRegulations GROUP BY State) AS RegulationCounts GROUP BY State; |
What is the maximum and minimum CO2 emissions (in tons) per square meter of building area for each city? | CREATE TABLE co2_emissions (building_id INT,building_name VARCHAR(255),city VARCHAR(255),co2_emissions_tons_per_sqm DECIMAL); INSERT INTO co2_emissions (building_id,building_name,city,co2_emissions_tons_per_sqm) VALUES (1,'Green Building 1','NYC',0.5); INSERT INTO co2_emissions (building_id,building_name,city,co2_emiss... | SELECT city, MAX(co2_emissions_tons_per_sqm) as max_co2_emissions_tons_per_sqm, MIN(co2_emissions_tons_per_sqm) as min_co2_emissions_tons_per_sqm FROM co2_emissions GROUP BY city; |
How many circular economy initiatives were implemented by each organization? | CREATE TABLE circular_economy_initiatives (initiative_id INT PRIMARY KEY,organization_id INT,initiative_date DATE); | SELECT organization_id, COUNT(*) FROM circular_economy_initiatives GROUP BY organization_id; |
What is the distribution of hotel ratings for hotels in a given star range? | CREATE TABLE hotel_ratings (hotel_id INT,hotel_name TEXT,country TEXT,stars INT,rating FLOAT); INSERT INTO hotel_ratings (hotel_id,hotel_name,country,stars,rating) VALUES (1,'Hotel Royal','USA',4,8.5),(2,'Hotel Paris','France',5,9.0),(3,'Hotel Tokyo','Japan',4,8.7),(4,'Hotel Rome','Italy',3,7.5),(5,'Hotel Beijing','Chi... | SELECT stars, COUNT(*) as hotel_count, AVG(rating) as avg_rating FROM hotel_ratings WHERE stars BETWEEN 3 AND 5 GROUP BY stars; |
Identify the number of unique cybersecurity strategies for each country in the 'national_security' table. | CREATE TABLE countries (country VARCHAR(255)); INSERT INTO countries (country) VALUES ('USA'),('China'),('Russia'),('India'); CREATE VIEW national_security AS SELECT c.country,n.strategy VARCHAR(255) FROM countries c CROSS JOIN (SELECT 'strategy1' AS strategy UNION ALL SELECT 'strategy2' UNION ALL SELECT 'strategy3') n... | SELECT c.country, COUNT(DISTINCT n.strategy) FROM countries c INNER JOIN national_security n ON c.country = n.country GROUP BY c.country; |
What is the virtual tour engagement rate for each hotel in Mexico, ordered by engagement rate in descending order? | CREATE TABLE virtual_tours (tour_id INT,hotel_name TEXT,country TEXT,engagement_rate FLOAT); INSERT INTO virtual_tours (tour_id,hotel_name,country,engagement_rate) VALUES (1,'Hotel E','Mexico',0.04),(2,'Hotel F','Mexico',0.06),(3,'Hotel G','Mexico',0.05); | SELECT country, hotel_name, engagement_rate FROM virtual_tours WHERE country = 'Mexico' ORDER BY engagement_rate DESC; |
How many of each menu item were sold per day in the past week? | CREATE TABLE menu_item_sales(menu_item VARCHAR(50),sale_date DATE,quantity INT); INSERT INTO menu_item_sales VALUES ('Burger','2022-01-01',50),('Pizza','2022-01-01',30),('Salad','2022-01-01',20),('Burger','2022-01-02',60),('Pizza','2022-01-02',40),('Salad','2022-01-02',30),('Burger','2022-01-03',40),('Pizza','2022-01-0... | SELECT menu_item, sale_date, SUM(quantity) AS total_sold FROM menu_item_sales WHERE sale_date >= CURRENT_DATE - INTERVAL '7 days' GROUP BY menu_item, sale_date ORDER BY sale_date, total_sold DESC; |
What is the minimum donation amount? | CREATE TABLE Donors (DonorID INT,Name TEXT,DonationAmount DECIMAL); | SELECT MIN(DonationAmount) FROM Donors; |
List all green building initiatives in Latin America and the Caribbean? | CREATE TABLE initiatives (id INT,name VARCHAR(50),region VARCHAR(50)); INSERT INTO initiatives (id,name,region) VALUES (1,'Green Building 1','Latin America'),(2,'Smart City Initiative','North America'),(3,'Renewable Energy Project','Asia'),(4,'Green Building 2','Caribbean'); | SELECT * FROM initiatives WHERE region IN ('Latin America', 'Caribbean'); |
What is the maximum spacecraft manufacturing date for each country? | CREATE TABLE Spacecraft_Manufacturers_4 (Country VARCHAR(50),Spacecraft_Name VARCHAR(50),Manufacturing_Date DATE); INSERT INTO Spacecraft_Manufacturers_4 (Country,Spacecraft_Name,Manufacturing_Date) VALUES ('Japan','Kounotori 8','2020-09-10'); INSERT INTO Spacecraft_Manufacturers_4 (Country,Spacecraft_Name,Manufacturin... | SELECT Country, MAX(Manufacturing_Date) as Maximum_Manufacturing_Date FROM Spacecraft_Manufacturers_4 GROUP BY Country; |
What is the total biomass of each marine species in the Arctic? | CREATE TABLE marine_species (species_id INT,species_name VARCHAR(50)); CREATE TABLE biomass_measurements (measurement_id INT,species_id INT,biomass DECIMAL(10,2)); INSERT INTO marine_species (species_id,species_name) VALUES (1,'Polar Cod'),(2,'Greenland Shark'),(3,'Hooded Seal'); INSERT INTO biomass_measurements (measu... | SELECT species_name, SUM(biomass) as total_biomass FROM biomass_measurements JOIN marine_species ON biomass_measurements.species_id = marine_species.species_id GROUP BY species_name; |
What is the total revenue of sustainable material sales? | CREATE TABLE sales (id INT,item_id INT,material VARCHAR(255),revenue DECIMAL(5,2)); INSERT INTO sales (id,item_id,material,revenue) VALUES (1,1,'Organic Cotton',150.00),(2,2,'Recycled Polyester',120.00),(3,3,'Hemp',80.00); | SELECT SUM(revenue) FROM sales WHERE material IN ('Organic Cotton', 'Recycled Polyester', 'Hemp'); |
List the names of all faculty members who have not received a research grant. | CREATE TABLE grant (id INT,faculty_id INT); INSERT INTO grant (id,faculty_id) VALUES (1,1),(2,2),(3,3); CREATE TABLE faculty (id INT,name TEXT); INSERT INTO faculty (id,name) VALUES (1,'Alice'),(2,'Bob'),(3,'Charlie'),(4,'Diana'); | SELECT name FROM faculty WHERE id NOT IN (SELECT faculty_id FROM grant); |
Which art movement has the highest average visitor count? | CREATE TABLE Exhibitions (exhibition_name VARCHAR(255),theme VARCHAR(255),visitor_count INT); INSERT INTO Exhibitions (exhibition_name,theme,visitor_count) VALUES ('Impressionist','Impressionism',2000),('Cubist','Cubism',1500),('Surrealist','Surrealism',1800); | SELECT theme, AVG(visitor_count) as avg_visitor_count FROM Exhibitions GROUP BY theme ORDER BY avg_visitor_count DESC LIMIT 1; |
What is the total number of shared scooters available in Los Angeles on August 15, 2022? | CREATE TABLE shared_scooters(scooter_id INT,availability_status VARCHAR(50),availability_date DATE,city VARCHAR(50)); | SELECT COUNT(*) FROM shared_scooters WHERE availability_status = 'available' AND availability_date = '2022-08-15' AND city = 'Los Angeles'; |
What is the percentage of water recycling for industrial users in Utah? | CREATE TABLE recycling_rates (user_type VARCHAR(10),state VARCHAR(20),recycling_rate FLOAT); | SELECT 100.0 * SUM(CASE WHEN user_type = 'industrial' THEN recycling_rate END) / SUM(recycling_rate) FROM recycling_rates WHERE state = 'Utah'; |
What is the total attendance at events in the 'events' table for each country? | CREATE TABLE events (event_id INT,name VARCHAR(50),type VARCHAR(50),attendance INT,country VARCHAR(50)); INSERT INTO events (event_id,name,type,attendance,country) VALUES (1,'Art Exhibit','Painting',1500,'Spain'); INSERT INTO events (event_id,name,type,attendance,country) VALUES (2,'Theater Performance','Play',850,'Ire... | SELECT country, SUM(attendance) as total_attendance FROM events GROUP BY country; |
What is the total number of visitors to the Museum of Modern Art in New York from January to June 2022? | CREATE TABLE MoMAVisitors (VisitorID int,VisitorName varchar(100),VisitDate date,MuseumName varchar(100)); INSERT INTO MoMAVisitors (VisitorID,VisitorName,VisitDate,MuseumName) VALUES (1,'Visitor A','2022-01-01','Museum of Modern Art'),(2,'Visitor B','2022-03-01','Museum of Modern Art'),(3,'Visitor C','2022-07-01','Mus... | SELECT COUNT(*) FROM MoMAVisitors WHERE MuseumName = 'Museum of Modern Art' AND MONTH(VisitDate) BETWEEN 1 AND 6 AND YEAR(VisitDate) = 2022; |
List all green building certifications and their corresponding year of establishment, ordered by year of establishment in ascending order. | CREATE TABLE green_building_certifications (id INT,name VARCHAR(255),year_established INT); INSERT INTO green_building_certifications (id,name,year_established) VALUES (1,'LEED',1993),(2,'BREEAM',1990),(3,'Green Star',2002); | SELECT * FROM green_building_certifications ORDER BY year_established ASC; |
What is the total incident count for each aircraft model? | CREATE TABLE aircraft (aircraft_id INT,model VARCHAR(100),manufacturer VARCHAR(100)); CREATE TABLE safety_records (record_id INT,aircraft_id INT,incident_count INT); INSERT INTO aircraft (aircraft_id,model,manufacturer) VALUES (1,'Aeromodel X1','AeroCo'); INSERT INTO aircraft (aircraft_id,model,manufacturer) VALUES (2,... | SELECT aircraft.model, SUM(safety_records.incident_count) FROM aircraft INNER JOIN safety_records ON aircraft.aircraft_id = safety_records.aircraft_id GROUP BY aircraft.model; |
Identify the collective bargaining agreements that will expire in the next 6 months, ordered by expiration date. | CREATE TABLE cb_agreements (id INT,union TEXT,employer TEXT,expiration_date DATE); INSERT INTO cb_agreements (id,union,employer,expiration_date) VALUES (1,'AFL-CIO','Tesla','2023-04-01'); INSERT INTO cb_agreements (id,union,employer,expiration_date) VALUES (2,'UAW','Ford','2023-05-15'); | SELECT * FROM cb_agreements WHERE expiration_date BETWEEN CURDATE() AND DATE_ADD(CURDATE(), INTERVAL 6 MONTH) ORDER BY expiration_date; |
What is the difference in square footage between the largest and smallest units in each building, ordered by building type and then by difference? | CREATE TABLE Buildings (building_id INT,name VARCHAR(50),building_type VARCHAR(50));CREATE TABLE Units (unit_id INT,building_id INT,square_footage INT); | SELECT b.building_type, b.name, MAX(u.square_footage) - MIN(u.square_footage) as square_footage_difference FROM Units u JOIN Buildings b ON u.building_id = b.building_id GROUP BY b.building_type, b.name ORDER BY b.building_type, square_footage_difference; |
What is the total budget allocated for policy advocacy initiatives per disability type? | CREATE TABLE AdvocacyByDisability (AdvocacyID INT,AdvocacyName VARCHAR(50),DisabilityType VARCHAR(50),Budget DECIMAL(10,2)); INSERT INTO AdvocacyByDisability (AdvocacyID,AdvocacyName,DisabilityType,Budget) VALUES (1,'Inclusive Education','Physical Disability',25000),(2,'Accessible Employment','Intellectual Disability',... | SELECT DisabilityType, SUM(Budget) as TotalBudget FROM AdvocacyByDisability GROUP BY DisabilityType; |
Find the total rainfall for each crop type in the past 60 days. | CREATE TABLE crop_rainfall_2 (crop_type VARCHAR(255),rainfall DECIMAL(5,2),record_date DATE); INSERT INTO crop_rainfall_2 (crop_type,rainfall,record_date) VALUES ('corn',25.0,'2022-02-01'),('soybeans',30.0,'2022-02-02'),('corn',22.0,'2022-02-03'),('soybeans',28.0,'2022-02-04'); | SELECT c.crop_type, SUM(rainfall) AS total_rainfall FROM crop_rainfall_2 c JOIN (SELECT CURDATE() - INTERVAL 60 DAY AS start_date) d ON c.record_date >= d.start_date GROUP BY c.crop_type; |
What is the total area of all wildlife habitats in the forestry database? | CREATE TABLE habitat (id INT,name VARCHAR(255),area FLOAT); INSERT INTO habitat (id,name,area) VALUES (1,'Habitat1',123.45); INSERT INTO habitat (id,name,area) VALUES (2,'Habitat2',234.56); CREATE TABLE region (id INT,name VARCHAR(255),habitat_id INT); INSERT INTO region (id,name,habitat_id) VALUES (1,'Region1',1); INS... | SELECT SUM(h.area) FROM habitat h JOIN region r ON h.id = r.habitat_id; |
Insert a new record for a hip-hop song streamed in Canada by a user with ID 12345. The revenue generated is $0.99 and the timestamp is 2022-03-01 14:30:00. | CREATE TABLE users (id INT,name VARCHAR(255),email VARCHAR(255)); CREATE TABLE tracks (id INT,title VARCHAR(255),artist VARCHAR(255),genre VARCHAR(255)); CREATE TABLE streams (id INT,track_id INT,user_id INT,region VARCHAR(255),revenue DECIMAL(10,2),timestamp TIMESTAMP); | INSERT INTO streams (id, track_id, user_id, region, revenue, timestamp) VALUES (DEFAULT, (SELECT id FROM tracks WHERE title = 'New Song' AND artist = 'Artist Name'), 12345, 'Canada', 0.99, '2022-03-01 14:30:00'); |
What is the minimum travel time for a specific train route? | CREATE TABLE TrainRoutes (RouteID INT,RouteName VARCHAR(50),TravelTime INT); | SELECT MIN(TravelTime) FROM TrainRoutes WHERE RouteName = 'Circle Line'; |
How many employees in the Environmental department are from historically underrepresented communities? | CREATE TABLE Employees (EmployeeID INT,Department VARCHAR(255),Community VARCHAR(255)); INSERT INTO Employees (EmployeeID,Department,Community) VALUES (1,'Environmental','Historically Underrepresented Community A'),(2,'Environmental','Represented Community'),(3,'Environmental','Historically Underrepresented Community B... | SELECT Department, SUM(CASE WHEN Community IN ('Historically Underrepresented Community A', 'Historically Underrepresented Community B') THEN 1 ELSE 0 END) FROM Employees GROUP BY Department; |
Show the number of explainable AI methodologies published per year. | CREATE TABLE publications (id INT,title TEXT,date DATE,methodology TEXT); CREATE VIEW explainable_ai AS SELECT * FROM publications WHERE methodology IS NOT NULL; | SELECT EXTRACT(YEAR FROM date) as year, COUNT(*) as num_publications FROM explainable_ai GROUP BY year ORDER BY year; |
What was the average energy efficiency rating for buildings in 'City X' over the last 3 years? | CREATE TABLE building_energy_efficiency_history (building_id INT,city VARCHAR(255),rating_year INT,rating FLOAT); INSERT INTO building_energy_efficiency_history (building_id,city,rating_year,rating) VALUES (1,'City X',2019,70),(2,'City X',2020,75),(3,'City X',2021,80),(4,'City Z',2019,85),(5,'City Z',2020,90),(6,'City ... | SELECT AVG(rating) as avg_rating FROM building_energy_efficiency_history WHERE city = 'City X' AND rating_year BETWEEN 2019 AND 2021; |
What is the earliest date a security incident was reported in the 'IncidentReports' table? | CREATE TABLE IncidentReports (id INT,incident_name VARCHAR(50),severity VARCHAR(10),incident_date DATE); INSERT INTO IncidentReports (id,incident_name,severity,incident_date) VALUES (1,'Incident1','High','2021-08-01'),(2,'Incident2','Medium','2021-07-15'),(3,'Incident3','Low','2021-06-01'),(4,'Incident4','High','2021-0... | SELECT MIN(incident_date) as earliest_date FROM IncidentReports; |
Insert new ticket sales records for a game into the TicketSales table. | CREATE TABLE Games (GameID INT,GameName VARCHAR(100),TeamID INT); CREATE TABLE Teams (TeamID INT,TeamName VARCHAR(100),Country VARCHAR(100)); CREATE TABLE TicketSales (SaleID INT,GameID INT,Quantity INT); | INSERT INTO TicketSales (SaleID, GameID, Quantity) SELECT sales.SaleID, games.GameID, sales.Quantity FROM (SELECT 1 AS SaleID, 10 AS GameID, 250 AS Quantity UNION ALL SELECT 2 AS SaleID, 10 AS GameID, 350 AS Quantity) sales JOIN Games games ON sales.GameID = games.GameID; |
What is the average daily return for all stocks in the 'Asia' region, ordered by return in descending order? | CREATE TABLE stocks (id INT,symbol VARCHAR(10),region VARCHAR(20),return DECIMAL(5,4)); INSERT INTO stocks (id,symbol,region,return) VALUES (1,'AAPL','Asia',0.0234); INSERT INTO stocks (id,symbol,region,return) VALUES (2,'GOOG','America',0.0187); INSERT INTO stocks (id,symbol,region,return) VALUES (3,'BABA','Asia',0.01... | SELECT region, AVG(return) as avg_return FROM stocks WHERE region = 'Asia' GROUP BY region ORDER BY avg_return DESC; |
Insert a new company in the e-commerce sector founded by a Latinx individual in 2021, and update the funding records. | CREATE TABLE company (id INT,name TEXT,industry TEXT,founder_ethnicity TEXT,founding_date DATE);CREATE TABLE funding (id INT,company_id INT,amount INT); INSERT INTO company (id,name,industry,founder_ethnicity,founding_date) VALUES (1,'ShopEco','E-commerce','Latinx','2021-05-12'); | INSERT INTO funding (id, company_id, amount) VALUES (1, 1, 750000); |
Calculate the average threat level for the last 30 days | CREATE TABLE threat_intelligence (id INT,threat_level INT,threat_date DATE); INSERT INTO threat_intelligence (id,threat_level,threat_date) VALUES (1,5,'2022-01-01'),(2,3,'2022-01-02'),(3,7,'2022-01-03'); | SELECT AVG(threat_level) FROM threat_intelligence WHERE threat_date >= CURDATE() - INTERVAL 30 DAY; |
List all employees and their corresponding department, sorted by department in ascending order and then by employee ID in ascending order. | CREATE TABLE Employees (EmployeeID INT,Gender VARCHAR(10),Department VARCHAR(20)); INSERT INTO Employees (EmployeeID,Gender,Department) VALUES (1,'Female','IT'),(2,'Male','IT'),(3,'Non-binary','HR'),(4,'Male','Finance'),(5,'Non-binary','IT'),(6,'Genderqueer','IT'),(7,'Male','IT'),(8,'Female','HR'),(9,'Non-binary','Fina... | SELECT EmployeeID, Department FROM Employees ORDER BY Department ASC, EmployeeID ASC; |
What is the total waste generated by small businesses in the last year? | CREATE TABLE WasteGeneration (waste_id INT,business_type VARCHAR(255),waste_amount DECIMAL(10,2),generation_date DATE); INSERT INTO WasteGeneration (waste_id,business_type,waste_amount,generation_date) VALUES (1,'Small Business',500,'2021-01-01'),(2,'Medium Business',800,'2021-01-01'),(3,'Large Business',1200,'2021-01-... | SELECT SUM(waste_amount) FROM WasteGeneration WHERE business_type = 'Small Business' AND generation_date >= DATE_SUB(CURDATE(), INTERVAL 1 YEAR); |
What is the total funding raised by startups founded by individuals from Latin America in the fintech industry? | CREATE TABLE startups(id INT,name TEXT,founder_continent TEXT,founder_industry TEXT); INSERT INTO startups VALUES (1,'Acme Inc','Latin America','Fintech'); INSERT INTO startups VALUES (2,'Beta Corp','Europe','E-commerce'); CREATE TABLE funding_rounds(startup_id INT,amount_raised INT); INSERT INTO funding_rounds VALUES ... | SELECT SUM(funding_rounds.amount_raised) FROM startups INNER JOIN funding_rounds ON startups.id = funding_rounds.startup_id WHERE startups.founder_continent = 'Latin America' AND startups.founder_industry = 'Fintech'; |
What is the average electric vehicle range in Japan over the last 5 years? | CREATE TABLE Vehicle_Range (make VARCHAR(50),model VARCHAR(50),range FLOAT,year INT,country VARCHAR(50)); INSERT INTO Vehicle_Range (make,model,range,year,country) VALUES ('Toyota','Prius Prime',630,2017,'Japan'); INSERT INTO Vehicle_Range (make,model,range,year,country) VALUES ('Nissan','Leaf',530,2018,'Japan'); | SELECT AVG(range) FROM Vehicle_Range WHERE country = 'Japan' AND year BETWEEN 2017 AND 2022; |
Update the amount of investment with strategy_id 3 in the table 'esg_investments' to 4000000. | CREATE TABLE esg_investments (id INT,country VARCHAR(255),amount FLOAT,strategy_id INT); INSERT INTO esg_investments (id,country,amount,strategy_id) VALUES (1,'Argentina',1500000,3),(2,'Argentina',2000000,2); | UPDATE esg_investments SET amount = 4000000 WHERE strategy_id = 3; |
What is the average size of habitats for each animal species? | CREATE TABLE animals (id INT PRIMARY KEY,name VARCHAR(50),species VARCHAR(50),population INT); CREATE TABLE habitats (id INT PRIMARY KEY,name VARCHAR(50),location VARCHAR(50),size FLOAT,animal_id INT); | SELECT animals.species, AVG(habitats.size) AS avg_size FROM animals INNER JOIN habitats ON animals.id = habitats.animal_id GROUP BY animals.species; |
Find the difference in R&D expenditures between two companies, 'Pfizer' and 'Merck'. | CREATE TABLE rd_expenditures (company TEXT,year INT,amount FLOAT); INSERT INTO rd_expenditures (company,year,amount) VALUES ('Pfizer',2020,18000000),('Merck',2020,14000000); | SELECT Pfizer - Merck FROM (SELECT SUM(amount) AS Pfizer FROM rd_expenditures WHERE company = 'Pfizer' AND year = 2020) AS Pfizer_2020, (SELECT SUM(amount) AS Merck FROM rd_expenditures WHERE company = 'Merck' AND year = 2020) AS Merck_2020; |
What is the total cost of wind_farm projects? | CREATE TABLE wind_farm (id INT,name VARCHAR(255),cost FLOAT); INSERT INTO wind_farm (id,name,cost) VALUES (1,'Sample Wind Farm',10000000); | SELECT SUM(cost) FROM wind_farm; |
List the total number of regulatory actions taken in each country | CREATE TABLE RegulatoryActions (country VARCHAR(255),action_date DATE); INSERT INTO RegulatoryActions (country,action_date) VALUES ('USA','2021-01-01'),('USA','2021-03-01'),('China','2021-02-01'); | SELECT country, COUNT(*) as total_actions FROM RegulatoryActions GROUP BY country; |
What is the maximum depth of any marine trench? | CREATE TABLE marine_trenches (name TEXT,depth FLOAT); INSERT INTO marine_trenches (name,depth) VALUES ('Mariana Trench',36000); INSERT INTO marine_trenches (name,depth) VALUES ('Tonga Trench',35000); INSERT INTO marine_trenches (name,depth) VALUES ('Kermadec Trench',32000); | SELECT MAX(depth) FROM marine_trenches; |
How many participants joined each visual arts program by age group? | CREATE TABLE visual_arts_programs (program_id INT PRIMARY KEY,program_name VARCHAR(50),program_type VARCHAR(50),start_date DATE,end_date DATE); CREATE TABLE visual_arts_participants (participant_id INT PRIMARY KEY,participant_name VARCHAR(50),age INT,gender VARCHAR(50),program_id INT,FOREIGN KEY (program_id) REFERENCES... | SELECT visual_arts_programs.program_name, visual_arts_participants.age, COUNT(visual_arts_participants.participant_id) AS total_participants FROM visual_arts_programs INNER JOIN visual_arts_participants ON visual_arts_programs.program_id = visual_arts_participants.program_id GROUP BY visual_arts_programs.program_name, ... |
Which intelligence operations have been conducted in 'CityA' in the INTELLIGENCE_OPERATIONS table? | CREATE TABLE INTELLIGENCE_OPERATIONS (id INT PRIMARY KEY,operation VARCHAR(255),city VARCHAR(255),country VARCHAR(255),year INT); | SELECT operation FROM INTELLIGENCE_OPERATIONS WHERE city = 'CityA' AND year = (SELECT MAX(year) FROM INTELLIGENCE_OPERATIONS WHERE city = 'CityA'); |
What was the most common artifact category per site? | CREATE TABLE excavation_sites (site_id INT,site_name VARCHAR(50),country VARCHAR(50)); INSERT INTO excavation_sites (site_id,site_name,country) VALUES (1,'Site A','USA'); CREATE TABLE artifacts (artifact_id INT,site_id INT,category VARCHAR(50)); | SELECT e.site_name, a.category, COUNT(*) as category_count FROM excavation_sites e JOIN artifacts a ON e.site_id = a.site_id GROUP BY e.site_id, e.site_name, a.category ORDER BY site_id, category_count DESC; |
What is the maximum player score for each game? | CREATE TABLE MaxPlayerScores (player_id INT,game_id INT,player_score INT); INSERT INTO MaxPlayerScores (player_id,game_id,player_score) VALUES (2,1,1800),(4,2,1900),(6,3,1600); | SELECT G.game_name, MAX(MPS.player_score) as max_score FROM MaxPlayerScores MPS JOIN Games G ON MPS.game_id = G.game_id GROUP BY G.game_name; |
What is the total number of indigenous communities in the Arctic regions? | CREATE TABLE IndigenousCommunities (community VARCHAR(255),region VARCHAR(255)); INSERT INTO IndigenousCommunities (community,region) VALUES ('Inuit','Canada'),('Inuit','Greenland'),('Sami','Norway'),('Sami','Sweden'),('Nenets','Russia'); | SELECT region, COUNT(DISTINCT community) as num_communities FROM IndigenousCommunities GROUP BY region; |
What is the average sourcing distance for a given ingredient? | CREATE TABLE ingredients (ingredient_id INT,product_id INT,sourcing_distance FLOAT); INSERT INTO ingredients VALUES (1,1,250.5),(2,1,350.2),(3,2,150.8),(4,2,450.9); | SELECT AVG(sourcing_distance) FROM ingredients WHERE ingredient_id = 1; |
Determine the inventory turnover rate for each ingredient category | CREATE TABLE Ingredients (ingredient_id INT,ingredient_name VARCHAR(255),ingredient_category VARCHAR(255),quantity INT,purchase_price DECIMAL(5,2)); INSERT INTO Ingredients (ingredient_id,ingredient_name,ingredient_category,quantity,purchase_price) VALUES (1,'Chickpeas','Legumes',50,1.25),(2,'Chicken Breast','Poultry',... | SELECT ingredient_category, SUM(quantity) AS total_quantity, AVG(quantity) AS avg_quantity_sold, SUM(quantity) / (SELECT SUM(quantity) * purchase_price FROM Ingredients, Sales WHERE Ingredients.ingredient_id = Sales.ingredient_id GROUP BY Ingredients.ingredient_id) AS inventory_turnover_rate FROM Ingredients, Sales WHE... |
List all climate mitigation initiatives in 'Asia'. | CREATE TABLE initiatives (id INT,initiative_type TEXT,region_id INT); CREATE TABLE regions (id INT,region TEXT); INSERT INTO initiatives (id,initiative_type,region_id) VALUES (1,'Mitigation',1),(2,'Adaptation',2),(3,'Mitigation',3); INSERT INTO regions (id,region) VALUES (1,'Americas'),(2,'Europe'),(3,'Asia'); | SELECT initiatives.initiative_type FROM initiatives INNER JOIN regions ON initiatives.region_id = regions.id WHERE regions.region = 'Asia' AND initiatives.initiative_type = 'Mitigation'; |
What is the earliest date a medical emergency was recorded in the South district? | CREATE TABLE emergency_incidents (id INT,district VARCHAR(20),type VARCHAR(20),date DATE); INSERT INTO emergency_incidents (id,district,type,date) VALUES (1,'Downtown','Fire','2022-01-01'); INSERT INTO emergency_incidents (id,district,type,date) VALUES (2,'Uptown','Medical','2022-01-02'); INSERT INTO emergency_incident... | SELECT MIN(date) FROM emergency_incidents WHERE district = 'South' AND type = 'Medical'; |
What is the total amount of research grants awarded to female faculty members in the Computer Science department? | CREATE TABLE faculty (faculty_id INT,name VARCHAR(50),gender VARCHAR(10),department VARCHAR(50)); INSERT INTO faculty VALUES (1,'John Doe','Male','Computer Science'),(2,'Jane Smith','Female','Computer Science'); CREATE TABLE grants (grant_id INT,faculty_id INT,amount FLOAT); INSERT INTO grants VALUES (1,1,50000),(2,2,7... | SELECT SUM(amount) FROM grants JOIN faculty ON grants.faculty_id = faculty.faculty_id WHERE faculty.gender = 'Female' AND faculty.department = 'Computer Science'; |
How many female engineers are there in the 'engineers' table? | CREATE TABLE engineers (id INT,name VARCHAR(50),age INT,gender VARCHAR(10),department VARCHAR(20)); | SELECT COUNT(*) FROM engineers WHERE gender = 'female'; |
What is the total cost of ingredients for vegan dishes in the sustainable menu? | CREATE TABLE ingredients (id INT,dish_id INT,name TEXT,cost FLOAT,is_vegan BOOLEAN); INSERT INTO ingredients (id,dish_id,name,cost,is_vegan) VALUES (1,1,'Quinoa',2.00,true),(2,1,'Olive Oil',1.50,true),(3,2,'Chickpeas',2.75,true),(4,2,'Coconut Milk',3.00,true),(5,3,'Beef',8.00,false); | SELECT SUM(cost) FROM ingredients WHERE is_vegan = true; |
How many medals were won by each country in the 2020 Olympics? | CREATE TABLE olympic_medals (id INT,country VARCHAR(100),medal VARCHAR(10),olympics BOOLEAN); INSERT INTO olympic_medals (id,country,medal,olympics) VALUES (1,'USA','Gold',true),(2,'China','Silver',true),(3,'Russia','Bronze',true); | SELECT country, COUNT(*) FROM olympic_medals WHERE olympics = true GROUP BY country; |
List all distinct case types that were opened in the 'Northeast' region in 2022. | CREATE TABLE case_details(case_id INT,case_type VARCHAR(20),opened_date DATE,region VARCHAR(20)); INSERT INTO case_details(case_id,case_type,opened_date,region) VALUES (101,'personal_injury','2022-04-15','Northeast'),(102,'divorce','2021-09-28','Northeast'),(103,'civil','2022-02-14','Northeast'),(104,'criminal','2021-0... | SELECT DISTINCT case_type FROM case_details WHERE region = 'Northeast' AND YEAR(opened_date) = 2022; |
List the names and capacities of cargo ships that have never visited 'Port of Tokyo'. | CREATE TABLE cargo_visits (cargo_ship_id INT,port_id INT,visited DATE); CREATE TABLE cargo_ships (id INT,name TEXT,capacity INT); CREATE TABLE ports (id INT,name TEXT); INSERT INTO cargo_visits (cargo_ship_id,port_id,visited) VALUES (1,2,DATE('2022-02-20')),(2,3,DATE('2022-03-05')); INSERT INTO cargo_ships (id,name,cap... | SELECT cargo_ships.name, cargo_ships.capacity FROM cargo_ships LEFT JOIN cargo_visits ON cargo_ships.id = cargo_visits.cargo_ship_id LEFT JOIN ports ON cargo_visits.port_id = ports.id WHERE ports.name IS NULL; |
Update player records to set the name 'Alex Brown' if the Player_ID is 3 in the 'Player' table | CREATE TABLE Player (Player_ID INT,Name VARCHAR(50),Date_Joined DATE); INSERT INTO Player (Player_ID,Name,Date_Joined) VALUES (1,'John Doe','2019-06-15'),(2,'Jane Smith','2020-03-08'),(3,'Alice Johnson','2021-02-22'); | UPDATE Player SET Name = 'Alex Brown' WHERE Player_ID = 3; |
What is the total amount of Shariah-compliant loans issued by each bank in the last quarter? | CREATE TABLE banks (id INT,name TEXT); CREATE TABLE shariah_loans (bank_id INT,amount DECIMAL,date DATE); INSERT INTO banks (id,name) VALUES (1,'Bank A'),(2,'Bank B'); INSERT INTO shariah_loans (bank_id,amount,date) VALUES (1,5000,'2021-01-01'),(1,7000,'2021-04-01'),(2,6000,'2021-03-15'),(2,8000,'2021-07-01'); | SELECT b.name, SUM(sl.amount) as total_loans FROM banks b JOIN shariah_loans sl ON b.id = sl.bank_id WHERE sl.date >= DATE_SUB(CURRENT_DATE, INTERVAL 3 MONTH) GROUP BY b.name; |
What is the total revenue generated from upcycled clothing sales in the US for Q3 2022? | CREATE TABLE Products (productID INT,productName VARCHAR(50),productType VARCHAR(50),price DECIMAL(10,2),upcycled BOOLEAN,country VARCHAR(50)); CREATE TABLE Sales (saleID INT,productID INT,saleDate DATE); | SELECT SUM(P.price) FROM Products P INNER JOIN Sales S ON P.productID = S.productID WHERE P.productType = 'clothing' AND P.upcycled = TRUE AND S.saleDate BETWEEN '2022-07-01' AND '2022-09-30' AND P.country = 'US'; |
What is the maximum amount of a research grant awarded to a department in the College of Science? | CREATE TABLE department (id INT,name VARCHAR(255),college VARCHAR(255));CREATE TABLE grant (id INT,department_id INT,title VARCHAR(255),amount DECIMAL(10,2)); | SELECT MAX(amount) FROM grant g JOIN department d ON g.department_id = d.id WHERE d.college = 'College of Science'; |
What is the total distance traveled for all shipments in the freight forwarding data? | CREATE TABLE RouteDetails (route_id INT,shipment_id INT,distance FLOAT,delivery_date DATE); INSERT INTO RouteDetails (route_id,shipment_id,distance,delivery_date) VALUES (1,1,100,'2022-01-01'),(2,2,200,'2022-02-01'),(3,3,150,'2022-03-01'); | SELECT SUM(distance) as total_distance FROM RouteDetails; |
Calculate the average age of bioprocess engineers in the engineers table | CREATE TABLE engineers (id INT,name VARCHAR(50),age INT,country VARCHAR(50),specialization VARCHAR(50)); INSERT INTO engineers (id,name,age,country,specialization) VALUES (1,'Alice',35,'USA','Bioprocess Engineering'); INSERT INTO engineers (id,name,age,country,specialization) VALUES (2,'Bob',32,'Canada','Bioprocess Eng... | SELECT AVG(age) FROM engineers WHERE specialization = 'Bioprocess Engineering'; |
Which vegetarian menu items generate the most revenue? | CREATE TABLE Sales (SaleID INT,MenuItemID INT,Quantity INT,SaleDate DATETIME); INSERT INTO Sales (SaleID,MenuItemID,Quantity,SaleDate) VALUES (1,1,3,'2022-01-01 10:00:00'); INSERT INTO Sales (SaleID,MenuItemID,Quantity,SaleDate) VALUES (2,2,1,'2022-01-02 12:00:00'); INSERT INTO Sales (SaleID,MenuItemID,Quantity,SaleDat... | SELECT MenuItems.MenuItemName, SUM(MenuItems.Price * Sales.Quantity) as Revenue FROM MenuItems JOIN Sales ON MenuItems.MenuItemID = Sales.MenuItemID WHERE MenuItems.Category = 'Vegetarian' GROUP BY MenuItems.MenuItemName ORDER BY Revenue DESC |
What is the average gas production for wells in Siberia? | CREATE TABLE exploration_data (data_id INT,well_id INT,date DATE,gas_production FLOAT,oil_production FLOAT); INSERT INTO exploration_data (data_id,well_id,date,gas_production,oil_production) VALUES (6,6,'2020-01-01',80.3,250.2),(7,7,'2020-02-15',90.1,300.5),(8,8,'2019-12-10',75.8,275.3); | SELECT well_id, AVG(gas_production) FROM exploration_data WHERE location = 'Siberia' GROUP BY well_id; |
What is the total volume of water used for agricultural purposes in the state of Texas in the past year? | CREATE TABLE water_usage (usage_id INT,usage_type VARCHAR(20),state VARCHAR(20),volume FLOAT,usage_date DATE); INSERT INTO water_usage (usage_id,usage_type,state,volume,usage_date) VALUES (1,'Agriculture','Texas',10000,'2021-01-01'),(2,'Agriculture','Texas',12000,'2021-01-02'); | SELECT SUM(volume) FROM water_usage WHERE usage_type = 'Agriculture' AND state = 'Texas' AND usage_date >= DATEADD(year, -1, CURRENT_DATE); |
How many workers in the supply chain were provided with safety training in 2019, by each country? | CREATE TABLE SupplyChainSafety (safety_training BOOLEAN,country VARCHAR(255),year INT); | SELECT country, COUNT(*) FROM SupplyChainSafety WHERE safety_training = TRUE AND year = 2019 GROUP BY country; |
List all tech companies in 'tech_companies' table located in 'California'. | CREATE TABLE tech_companies (company VARCHAR(50),department VARCHAR(50),employee_name VARCHAR(50),salary INTEGER,company_location VARCHAR(50)); | SELECT company FROM tech_companies WHERE company_location = 'California'; |
Find the total number of grants awarded by the 'Arts and Humanities' department | CREATE TABLE grants (id INT,department VARCHAR(20),amount FLOAT); INSERT INTO grants (id,department,amount) VALUES (1,'Arts and Humanities',50000.0),(2,'Sciences',75000.0); | SELECT SUM(amount) FROM grants WHERE department = 'Arts and Humanities'; |
Show the number of reservations cancelled for each hotel | CREATE TABLE hotel_reservations (reservation_id INT,hotel_id INT,guest_name TEXT,arrival_date DATE,departure_date DATE,num_guests INT,payment_amount FLOAT,is_cancelled BOOLEAN); | SELECT hotel_id, SUM(is_cancelled) FROM hotel_reservations GROUP BY hotel_id; |
How many species are present in the 'arctic_biodiversity' table for each type of habitat in the 'north_arctic' region? | CREATE TABLE arctic_biodiversity (id INTEGER,species_name TEXT,habitat TEXT,region TEXT); CREATE TABLE arctic_regions (id INTEGER,region TEXT); INSERT INTO arctic_regions (id,region) VALUES (1,'north_arctic'),(2,'south_arctic'); | SELECT habitat, COUNT(species_name) as species_count FROM arctic_biodiversity INNER JOIN arctic_regions ON arctic_biodiversity.region = arctic_regions.region WHERE arctic_regions.region = 'north_arctic' GROUP BY habitat; |
List the average salary for each department in the 'UnionMembers' table | CREATE TABLE UnionMembers (id INT,department VARCHAR(50),salary FLOAT); INSERT INTO UnionMembers (id,department,salary) VALUES (1,'Accounting',60000.0),(2,'Marketing',55000.0),(3,'Accounting',65000.0); | SELECT department, AVG(salary) as avg_salary FROM UnionMembers GROUP BY department; |
List the top 5 artists with the most sculptures in their portfolio. | CREATE TABLE Artists (ArtistID INT,ArtistName VARCHAR(100),TotalSculptures INT); INSERT INTO Artists (ArtistID,ArtistName,TotalSculptures) VALUES (1,'Auguste Rodin',500),(2,'Constantin Brancusi',200),(3,'Henry Moore',300),(4,'Barbara Hepworth',150),(5,'Alexander Calder',400); | SELECT ArtistName FROM (SELECT ArtistName, ROW_NUMBER() OVER (ORDER BY TotalSculptures DESC) as rank FROM Artists) AS subquery WHERE rank <= 5; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.