instruction stringlengths 0 1.06k | input stringlengths 11 5.3k | response stringlengths 2 4.44k |
|---|---|---|
Insert a new record of budget allocation for the 'Healthcare' department for the year 2024 | CREATE TABLE budget_allocation (department TEXT,year INT,allocation DECIMAL(10,2)); | INSERT INTO budget_allocation (department, year, allocation) VALUES ('Healthcare', 2024, 700000.00); |
What is the difference in population between animals in the 'habitat_preservation' table that are endangered and those that are not? | CREATE TABLE habitat_preservation (id INT,animal_name VARCHAR(50),population INT,endangered_status VARCHAR(50)); | SELECT SUM(CASE WHEN endangered_status = 'Endangered' THEN population ELSE 0 END) - SUM(CASE WHEN endangered_status != 'Endangered' THEN population ELSE 0 END) FROM habitat_preservation; |
What is the average monthly data usage for postpaid mobile customers in the Chicago region? | CREATE TABLE mobile_customers (customer_id INT,plan_type VARCHAR(10),data_usage FLOAT,region VARCHAR(20)); INSERT INTO mobile_customers (customer_id,plan_type,data_usage,region) VALUES (1,'postpaid',3.5,'Chicago'),(2,'prepaid',2.0,'Chicago'); CREATE TABLE regions (region VARCHAR(20),avg_data_usage FLOAT); | SELECT AVG(m.data_usage) FROM mobile_customers m JOIN regions r ON m.region = r.region WHERE m.plan_type = 'postpaid' AND r.region = 'Chicago'; |
What is the total number of military equipment items that need maintenance in the Pacific region? | CREATE TABLE military_equipment (id INT,name VARCHAR(50),status VARCHAR(50),region VARCHAR(50)); INSERT INTO military_equipment (id,name,status,region) VALUES (1,'Tank A','To be maintained','Pacific'),(2,'Helicopter B','Operational','Atlantic'); | SELECT SUM(CASE WHEN region = 'Pacific' AND status = 'To be maintained' THEN 1 ELSE 0 END) as total_maintenance_needed FROM military_equipment; |
Get the total waste generation for 'South America' in 2018 and 2019 from the 'waste_generation' table | CREATE TABLE waste_generation (id INT,country VARCHAR(50),year INT,total_waste_gen FLOAT); | SELECT year, SUM(total_waste_gen) FROM waste_generation WHERE year IN (2018, 2019) AND country = 'South America' GROUP BY year; |
What is the total production of 'Rice' by each farmer in 'Mekong Delta'? | CREATE TABLE Farmers (FarmerID INT,FarmerName TEXT,Location TEXT); INSERT INTO Farmers (FarmerID,FarmerName,Location) VALUES (2,'Nguyen Van A','Mekong Delta'); CREATE TABLE Production (ProductID INT,FarmerID INT,Product TEXT,Quantity INT); INSERT INTO Production (ProductID,FarmerID,Product,Quantity) VALUES (2,2,'Rice',300); | SELECT Farmers.FarmerName, SUM(Production.Quantity) as TotalRiceProduction FROM Farmers INNER JOIN Production ON Farmers.FarmerID = Production.FarmerID WHERE Production.Product = 'Rice' AND Farmers.Location = 'Mekong Delta' GROUP BY Farmers.FarmerName; |
How many community development initiatives have been implemented in the Andean region, and what is the average budget for those initiatives? | CREATE TABLE CommunityDevelopment (InitiativeID INT,Name VARCHAR(50),Location VARCHAR(50),Budget DECIMAL(10,2)); INSERT INTO CommunityDevelopment (InitiativeID,Name,Location,Budget) VALUES (1,'Clean Water Access','Andean Region',50000); INSERT INTO CommunityDevelopment (InitiativeID,Name,Location,Budget) VALUES (2,'Education Center','Andean Region',75000); | SELECT COUNT(*), AVG(Budget) FROM CommunityDevelopment WHERE Location = 'Andean Region'; |
What is the total CO2 emission reduction (in metric tons) for carbon offset programs in the province of Ontario that have a target reduction of at least 50,000 metric tons? | CREATE TABLE on_co2_emission_reduction (id INT,program_id VARCHAR(255),province VARCHAR(255),target_reduction INT,actual_reduction INT); | SELECT SUM(actual_reduction) FROM on_co2_emission_reduction WHERE province = 'Ontario' AND target_reduction >= 50000; |
Which categories received the most funding from donations in 2021? | CREATE TABLE Donations (DonationID int,Amount decimal(10,2),PaymentMethod varchar(50),DonationDate date,Category varchar(50)); INSERT INTO Donations (DonationID,Amount,PaymentMethod,DonationDate,Category) VALUES (1,50.00,'Credit Card','2021-01-01','Education'); | SELECT Category, SUM(Amount) as TotalDonationAmount FROM Donations WHERE YEAR(DonationDate) = 2021 GROUP BY Category ORDER BY TotalDonationAmount DESC; |
List all transactions made by clients in Tokyo on March 15, 2022. | CREATE TABLE transaction (id INT,client_id INT,transaction_date DATE,amount DECIMAL(10,2)); INSERT INTO transaction (id,client_id,transaction_date,amount) VALUES (1,1,'2022-03-15',500.00),(2,3,'2022-03-16',1000.00); | SELECT * FROM transaction WHERE transaction_date = '2022-03-15' AND client_id IN (SELECT id FROM client WHERE address LIKE 'Tokyo%'); |
Find the top 2 countries with the highest total crop yield, along with the total yield for each. | CREATE TABLE crops (country VARCHAR(50),crop_yield INT); INSERT INTO crops (country,crop_yield) VALUES ('US',5000),('China',8000),('India',7000),('Brazil',6000); | SELECT country, SUM(crop_yield) OVER (PARTITION BY country) AS total_yield FROM crops ORDER BY total_yield DESC FETCH FIRST 2 ROWS ONLY; |
What is the total budget spent on policy advocacy efforts for students with hearing impairments from 2018-2020? | CREATE TABLE PolicyAdvocacy (ProgramID INT,ProgramName VARCHAR(50),Year INT,Budget DECIMAL(10,2)); | SELECT SUM(Budget) FROM PolicyAdvocacy WHERE DisabilityType = 'hearing impairment' AND Year BETWEEN 2018 AND 2020; |
How many infectious disease cases were reported in each region in 2020? | CREATE TABLE regions (region_id INT,region_name VARCHAR(50),state_abbr CHAR(2)); INSERT INTO regions VALUES (1,'Northeast','NY'),(2,'Southwest','TX'); CREATE TABLE disease_reports (report_id INT,report_date DATE,region_id INT,disease_name VARCHAR(50),cases INT); INSERT INTO disease_reports VALUES (1,'2020-01-01',1,'COVID-19',100),(2,'2020-01-01',2,'COVID-19',200),(3,'2020-02-01',1,'Flu',50),(4,'2020-02-01',2,'Flu',75); | SELECT r.region_name, YEAR(dr.report_date) AS year, SUM(dr.cases) AS total_cases FROM regions r JOIN disease_reports dr ON r.region_id = dr.region_id WHERE YEAR(dr.report_date) = 2020 GROUP BY r.region_name; |
List the top 2 biosensor technologies by R&D investment in ascending order. | CREATE SCHEMA if not exists biosensor;CREATE TABLE if not exists biosensor.technologies (id INT,name VARCHAR(50),rd_investment DECIMAL(10,2)); INSERT INTO biosensor.technologies (id,name,rd_investment) VALUES (1,'BioSensor1',3000000.00),(2,'BioSensor2',2500000.00),(3,'BioSensor3',2000000.00),(4,'BioSensor4',1500000.00); | SELECT * FROM biosensor.technologies ORDER BY rd_investment ASC LIMIT 2; |
Calculate the percentage of veteran employment in the defense industry by state | CREATE TABLE veteran_employment (state TEXT,veteran_count INT,total_employees INT); INSERT INTO veteran_employment (state,veteran_count,total_employees) VALUES ('California',15000,50000),('Texas',12000,40000),('Florida',10000,35000),('New York',9000,45000),('Virginia',18000,55000); | SELECT state, (veteran_count::FLOAT / total_employees) * 100 AS percentage FROM veteran_employment; |
List the names of all hospitals and their corresponding number of beds in the state of New York for the year 2018. | CREATE TABLE hospitals (name VARCHAR(50),year INT,beds INT); INSERT INTO hospitals (name,year,beds) VALUES ('Hospital A',2018,500); INSERT INTO hospitals (name,year,beds) VALUES ('Hospital B',2018,600); | SELECT name, beds FROM hospitals WHERE year = 2018; |
What is the total number of military personnel involved in peacekeeping operations by country? | CREATE TABLE peacekeeping_operations (operation_id INT,country VARCHAR(50),num_personnel INT); INSERT INTO peacekeeping_operations (operation_id,country,num_personnel) VALUES (1,'Brazil',500),(2,'Canada',700),(3,'Argentina',350); CREATE TABLE countries (country VARCHAR(50),population INT); INSERT INTO countries (country,population) VALUES ('Brazil',210000000),('Canada',38000000),('Argentina',45000000); | SELECT co.country, SUM(pko.num_personnel) as total_personnel FROM peacekeeping_operations pko JOIN countries co ON pko.country = co.country GROUP BY co.country; |
How many security incidents were there per day in the last week for each region? | CREATE TABLE incidents(id INT,region VARCHAR(255),incident_count INT,date DATE); INSERT INTO incidents(id,region,incident_count,date) VALUES (1,'North',20,'2021-09-01'),(2,'South',10,'2021-09-01'),(3,'East',15,'2021-09-01'),(4,'North',25,'2021-09-02'),(5,'South',12,'2021-09-02'),(6,'East',18,'2021-09-02'); | SELECT date, region, SUM(incident_count) as total_incidents FROM incidents WHERE date >= DATE_SUB(CURRENT_DATE(), INTERVAL 1 WEEK) GROUP BY date, region; |
How many food recalls have been issued by the FDA in the past month for items containing allergens? | CREATE TABLE FDARecalls (id INT,recallId INT,item VARCHAR(50),recallDate DATE,containsAllergens BOOLEAN); | SELECT COUNT(*) FROM FDARecalls WHERE containsAllergens = TRUE AND recallDate >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH); |
Delete the exhibition with the lowest number of visitors | CREATE TABLE exhibitions (exhibition_id INT PRIMARY KEY,exhibition_name VARCHAR(255),city VARCHAR(255),visitor_count INT); | DELETE FROM exhibitions WHERE exhibition_id IN (SELECT exhibition_id FROM (SELECT exhibition_id, MIN(visitor_count) as min_visitor_count FROM exhibitions GROUP BY exhibition_id) exhibition_visitor_count WHERE visitor_count = min_visitor_count); |
List the number of workers in factories located in vulnerable regions. | CREATE TABLE Factories (id INT,location VARCHAR,workers INT); CREATE VIEW VulnerableRegions AS SELECT * FROM Regions WHERE risk_level > 3; | SELECT COUNT(Factories.workers) FROM Factories INNER JOIN VulnerableRegions ON Factories.location = VulnerableRegions.region; |
What is the total number of public transportation projects in New York? | CREATE TABLE public_transportation (project_name TEXT,project_type TEXT,project_state TEXT); INSERT INTO public_transportation (project_name,project_type,project_state) VALUES ('PTP1','Subway','New York'),('PTP2','Bus','New York'),('PTP3','Light Rail','New York'),('PTP4','Ferry','New York'); | SELECT COUNT(*) FROM public_transportation WHERE project_state = 'New York' AND project_type = 'Subway' AND project_type = 'Bus' AND project_type = 'Light Rail' AND project_type = 'Ferry'; |
How many volunteers joined in the last 3 months by region? | CREATE TABLE Volunteers (VolunteerID INT,JoinDate DATE,Region VARCHAR(50)); | SELECT COUNT(*) as NumVolunteers, v.Region FROM Volunteers v WHERE v.JoinDate >= DATE_SUB(CURDATE(), INTERVAL 3 MONTH) GROUP BY v.Region; |
Which marine species have been observed in the Indian Ocean? | CREATE TABLE marine_species_observations (id INT,species TEXT,observation_date DATE,region TEXT); INSERT INTO marine_species_observations (id,species,observation_date,region) VALUES (1,'Whale Shark','2021-03-04','Indian Ocean'),(2,'Dolphin','2021-06-17','Mediterranean Sea'),(3,'Turtle','2020-12-29','Caribbean Sea'); | SELECT DISTINCT species FROM marine_species_observations WHERE region = 'Indian Ocean'; |
How many grants were given in each state? | CREATE TABLE Nonprofits (NonprofitID INT,Name VARCHAR(50),City VARCHAR(50),State VARCHAR(2),Zip VARCHAR(10),MissionStatement TEXT); CREATE TABLE Grants (GrantID INT,DonorID INT,NonprofitID INT,GrantAmount DECIMAL(10,2),Date DATE); | SELECT State, COUNT(*) FROM Nonprofits N INNER JOIN Grants G ON N.NonprofitID = G.NonprofitID GROUP BY State; |
Delete records of waste generation in the Americas with generation rate less than 30. | CREATE TABLE WasteGenerationAmericas (id INT,country VARCHAR(50),region VARCHAR(50),generation_rate FLOAT); INSERT INTO WasteGenerationAmericas (id,country,region,generation_rate) VALUES (1,'USA','Americas',35.1),(2,'Mexico','Americas',29.6),(3,'Canada','Americas',37.6); | DELETE FROM WasteGenerationAmericas WHERE region = 'Americas' AND generation_rate < 30; |
Update the equity_index column in the social_equity_trends table for records where the location is 'Atlanta, GA' and the date is after '2022-01-01' to a value of '0.85' | CREATE TABLE social_equity_trends (location VARCHAR(255),equity_index DECIMAL(4,2),date DATE); | WITH cte1 AS (UPDATE social_equity_trends SET equity_index = 0.85 WHERE location = 'Atlanta, GA' AND date > '2022-01-01') SELECT * FROM cte1; |
What is the percentage of international tourists visiting museums in South America compared to North America? | CREATE TABLE south_america_tourists (id INT,country TEXT,museum_visits INT); INSERT INTO south_america_tourists VALUES (1,'Brazil',2000),(2,'Argentina',3000); CREATE TABLE north_america_tourists (id INT,country TEXT,museum_visits INT); INSERT INTO north_america_tourists VALUES (1,'USA',5000),(2,'Canada',4000); | SELECT 100.0 * SUM(museum_visits) / (SELECT SUM(museum_visits) FROM north_america_tourists) FROM south_america_tourists |
Insert new records of media literacy workshops in the USA. | CREATE TABLE media_literacy_workshops (id INT,country VARCHAR(50),city VARCHAR(50),date DATE,attendance INT); | INSERT INTO media_literacy_workshops (id, country, city, date, attendance) VALUES (1, 'USA', 'New York', '2022-06-01', 50), (2, 'USA', 'Los Angeles', '2022-06-15', 75); |
Delete records in the threat_intelligence table where the 'threat_level' is 'High' and 'report_date' is older than 2020-12-31 | CREATE TABLE threat_intelligence (threat_id INT,threat_level VARCHAR(50),report_date DATE); | DELETE FROM threat_intelligence WHERE threat_level = 'High' AND report_date < '2020-12-31'; |
What is the ratio of primary care physicians to specialists in rural areas? | CREATE TABLE physicians_rural (id INTEGER,specialty VARCHAR(255),location VARCHAR(255)); | SELECT (COUNT(*) FILTER (WHERE specialty = 'Primary Care')) / COUNT(*) AS ratio FROM physicians_rural WHERE location LIKE '%rural%'; |
How many female directors have created movies in the database? | CREATE TABLE directors (id INT,name VARCHAR(255),gender VARCHAR(10)); CREATE TABLE movies_directors (movie_id INT,director_id INT); INSERT INTO directors (id,name,gender) VALUES (1,'Director1','Female'),(2,'Director2','Male'),(3,'Director3','Female'); INSERT INTO movies_directors (movie_id,director_id) VALUES (1,1),(1,2),(2,3); | SELECT COUNT(*) FROM directors WHERE gender = 'Female'; |
What is the heaviest spacecraft launched by ISRO? | CREATE TABLE SpacecraftManufacturing (manufacturer VARCHAR(255),spacecraft_name VARCHAR(255),mass FLOAT,launch_date DATE); INSERT INTO SpacecraftManufacturing (manufacturer,spacecraft_name,mass,launch_date) VALUES ('ISRO','Chandrayaan-1',1380,'2008-10-22'),('ISRO','Mangalyaan',1350,'2013-11-05'),('ISRO','GSAT-12',1410,'2011-07-15'); | SELECT spacecraft_name, mass FROM SpacecraftManufacturing WHERE manufacturer = 'ISRO' ORDER BY mass DESC LIMIT 1; |
What is the average monthly mobile data usage for customers in the 'rural' geographic area? | CREATE TABLE customers (customer_id INT,name VARCHAR(50),geographic_area VARCHAR(20)); INSERT INTO customers (customer_id,name,geographic_area) VALUES (1,'John Doe','rural'); CREATE TABLE mobile_data_usage (customer_id INT,month INT,data_usage INT); INSERT INTO mobile_data_usage (customer_id,month,data_usage) VALUES (1,1,1000); | SELECT AVG(data_usage) FROM mobile_data_usage JOIN customers ON mobile_data_usage.customer_id = customers.customer_id WHERE customers.geographic_area = 'rural'; |
Find the top 3 countries with the highest number of esports event participants. | CREATE TABLE Events (EventID INT,Name VARCHAR(100),Country VARCHAR(50),Participants INT); INSERT INTO Events (EventID,Name,Country,Participants) VALUES (1,'Event1','USA',500),(2,'Event2','Canada',400),(3,'Event3','England',600),(4,'Event4','France',300),(5,'Event5','USA',700); | SELECT Country, Participants FROM Events ORDER BY Participants DESC LIMIT 3; |
What is the maximum biomass of fish in the Indian Ocean Fish Farm for each month? | CREATE TABLE indian_ocean_fish_farm (date DATE,biomass FLOAT); | SELECT EXTRACT(MONTH FROM date) AS month, MAX(biomass) AS max_biomass FROM indian_ocean_fish_farm GROUP BY month; |
How many garments in 'FairTradeFashions' collection are not made of synthetic materials? | CREATE TABLE GarmentMaterials (GarmentID INT,SupplierName TEXT,Material TEXT); INSERT INTO GarmentMaterials (GarmentID,SupplierName,Material) VALUES (201,'FairTradeFashions','Cotton'),(202,'FairTradeFashions','Silk'),(203,'FairTradeFashions','Polyester'),(204,'FairTradeFashions','Rayon'),(205,'FairTradeFashions','Wool'); | SELECT COUNT(*) FROM GarmentMaterials WHERE SupplierName = 'FairTradeFashions' AND Material NOT IN ('Polyester', 'Rayon'); |
List the names of athletes who have set a personal best in the weightlifting_records dataset, in descending order by best performance date. | CREATE TABLE weightlifting_records (athlete VARCHAR(50),performance FLOAT,best_date DATE); | SELECT athlete FROM weightlifting_records WHERE performance = (SELECT MAX(performance) FROM weightlifting_records GROUP BY athlete) ORDER BY best_date DESC; |
How many unique IP addresses attempted to exploit vulnerabilities in the last week for the IT department? | CREATE TABLE exploitation_attempts (id INT,ip_address VARCHAR(255),vulnerability_id INT,attempts INT,success BOOLEAN); INSERT INTO exploitation_attempts (id,ip_address,vulnerability_id,attempts,success) VALUES (1,'192.168.1.1',1,5,true),(2,'192.168.1.1',2,3,false),(3,'192.168.2.1',1,10,true); | SELECT COUNT(DISTINCT ip_address) FROM exploitation_attempts WHERE exploitation_attempts.exploitation_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 WEEK) AND department = 'IT'; |
What is the minimum and maximum salary for workers in unions that have collective bargaining agreements? | CREATE TABLE unions (id INT,has_cba BOOLEAN); CREATE TABLE workers (id INT,union_id INT,salary DECIMAL(10,2)); | SELECT MIN(workers.salary), MAX(workers.salary) FROM workers JOIN unions ON workers.union_id = unions.id WHERE unions.has_cba = TRUE; |
Show the number of unique news topics covered by articles in the 'news_articles' table | CREATE TABLE news_articles (article_id INT,author_name VARCHAR(50),title VARCHAR(100),published_date DATE,topic_list VARCHAR(200)); | SELECT COUNT(DISTINCT trim(SPLIT_PART(topic_list, ',', n))) as unique_topics FROM news_articles, generate_series(1, ARRAY_LENGTH(string_to_array(topic_list, ','))) as n(n); |
Which airports and their corresponding lengths are located in California and were constructed before 1970? | CREATE TABLE airports (id INT,name TEXT,location TEXT,length INT,type TEXT,year INT); INSERT INTO airports (id,name,location,length,type,year) VALUES (1,'LAX','Los Angeles,CA',12157,'International',1928); INSERT INTO airports (id,name,location,length,type,year) VALUES (2,'SFO','San Francisco,CA',11381,'International',1927); | SELECT name, location, length FROM airports WHERE location LIKE '%CA%' AND type = 'International' AND year < 1970; |
Update the salary of the 'engineering' department manager to $70,000. | CREATE TABLE departments (id INT,name TEXT,manager TEXT,salary FLOAT); INSERT INTO departments (id,name,manager,salary) VALUES (1,'manufacturing','John Doe',60000.0),(2,'engineering','Mike Johnson',NULL); CREATE TABLE employees (id INT,name TEXT,department TEXT,salary FLOAT); INSERT INTO employees (id,name,department,salary) VALUES (1,'Jane Smith','manufacturing',50000.0),(2,'Mike Johnson','engineering',NULL); | WITH cte AS (UPDATE departments SET salary = 70000.0 WHERE name = 'engineering' AND manager IS NOT NULL RETURNING manager) UPDATE employees SET salary = (SELECT salary FROM cte) WHERE name = (SELECT manager FROM cte); |
What is the maximum water usage per site for Indian mining operations in 2020? | CREATE TABLE EnvironmentalImpact (Site VARCHAR(255),CO2Emissions INT,WaterUsage INT,WasteGeneration INT,ReportDate DATE,Country VARCHAR(255)); | SELECT Site, MAX(WaterUsage) as MaxWaterUsage FROM EnvironmentalImpact WHERE ReportDate BETWEEN '2020-01-01' AND '2020-12-31' AND Country = 'India' GROUP BY Site; |
How many smart contracts were updated in the 'cardano' and 'solana' networks? | CREATE TABLE smart_contracts (contract_id INT,network VARCHAR(255),last_updated DATE); INSERT INTO smart_contracts (contract_id,network,last_updated) VALUES (1,'cardano','2022-01-01'),(2,'solana','2021-12-31'); | SELECT COUNT(*) FROM smart_contracts WHERE network IN ('cardano', 'solana'); |
How many users are there in each country? | CREATE TABLE users (id INT PRIMARY KEY,name VARCHAR(50),age INT,gender VARCHAR(10),location VARCHAR(50)); INSERT INTO users (id,name,age,gender,location) VALUES (1,'Maria',28,'Female','Brazil'); INSERT INTO users (id,name,age,gender,location) VALUES (2,'Joao',35,'Male','Brazil'); INSERT INTO users (id,name,age,gender,location) VALUES (3,'Ahmed',40,'Male','Egypt'); INSERT INTO users (id,name,age,gender,location) VALUES (4,'Sophia',30,'Female','USA'); | SELECT users.location, COUNT(users.id) FROM users GROUP BY users.location; |
Identify bioprocess engineers in specific locations. | CREATE TABLE engineers (id INT,name VARCHAR(50),specialty VARCHAR(50),location VARCHAR(50),years_of_experience INT); | SELECT name FROM engineers WHERE specialty = 'bioprocess' AND location IN ('San Francisco', 'Boston'); |
Who has the highest number of career home runs among players from Japan in Major League Baseball? | CREATE TABLE mlb_players (player_name VARCHAR(100),country VARCHAR(50),home_runs INT); INSERT INTO mlb_players VALUES ('Hideki Matsui','Japan',175),('Ichiro Suzuki','Japan',117),('Masahiro Tanaka','Japan',1),('Shohei Ohtani','Japan',71); | SELECT player_name, home_runs FROM mlb_players WHERE country = 'Japan' ORDER BY home_runs DESC LIMIT 1; |
What is the average capacity of hydroelectric power plants? | CREATE TABLE hydro_plants (name VARCHAR(255),capacity FLOAT); INSERT INTO hydro_plants (name,capacity) VALUES ('Plant1',1200.5),('Plant2',1800.2),('Plant3',2400.9); | SELECT AVG(capacity) FROM hydro_plants; |
How many cannabis plants were cultivated in Oregon in the last quarter and what was their total weight? | CREATE TABLE cultivation (id INT,state TEXT,plant_count INT,plant_weight DECIMAL,cultivation_date DATE); | SELECT state, SUM(plant_weight) as total_weight FROM cultivation WHERE state = 'Oregon' AND cultivation_date >= DATE_SUB(CURRENT_DATE, INTERVAL 3 MONTH) GROUP BY state; |
What is the maximum number of emergency calls received in the "southeast" neighborhood in a single day? | CREATE TABLE daily_emergency_calls (date DATE,neighborhood VARCHAR(20),calls INT); INSERT INTO daily_emergency_calls (date,neighborhood,calls) VALUES ('2022-04-01','southeast',40),('2022-04-02','southeast',45),('2022-04-03','southeast',50); INSERT INTO daily_emergency_calls (date,neighborhood,calls) VALUES ('2022-04-01','northwest',30),('2022-04-02','northwest',35),('2022-04-03','northwest',40); | SELECT MAX(calls) FROM daily_emergency_calls WHERE neighborhood = 'southeast'; |
What is the average warehouse management cost per item for each warehouse in Q3 2021? | CREATE TABLE warehouse_management (item_id INT,warehouse_id INT,cost FLOAT,order_date DATE); | SELECT warehouse_id, AVG(cost/COUNT(*)) as avg_cost_per_item FROM warehouse_management WHERE EXTRACT(MONTH FROM order_date) BETWEEN 7 AND 9 GROUP BY warehouse_id; |
What is the total amount of research grants awarded to faculty members in the last 2 years? | CREATE TABLE faculty (id INT,name TEXT);CREATE TABLE research_grant (id INT,faculty_id INT,amount INT,year INT); | SELECT SUM(rg.amount) FROM research_grant rg WHERE rg.year BETWEEN YEAR(CURRENT_DATE) - 2 AND YEAR(CURRENT_DATE); |
What is the engagement rate and engagement time for the top 2 virtual tours? | CREATE TABLE virtual_tours_top (id INT,engagement_rate FLOAT,engagement_time INT); INSERT INTO virtual_tours_top (id,engagement_rate,engagement_time) VALUES (1,0.15,700),(2,0.13,800); | SELECT id, engagement_rate, engagement_time FROM virtual_tours_top WHERE row_number() OVER (ORDER BY engagement_rate DESC) <= 2; |
What was the total revenue for each concert by city? | CREATE TABLE concerts (city VARCHAR(50),revenue INT); INSERT INTO concerts (city,revenue) VALUES ('New York',50000),('Los Angeles',75000),('Chicago',60000); | SELECT city, SUM(revenue) FROM concerts GROUP BY city; |
Find the number of urban agriculture projects in Asia and Oceania, excluding any common projects between the two regions. | CREATE TABLE UrbanAgriProject (id INT,region VARCHAR(50)); INSERT INTO UrbanAgriProject (id,region) VALUES (1,'Asia'); INSERT INTO UrbanAgriProject (id,region) VALUES (2,'Oceania'); | SELECT COUNT(DISTINCT CASE WHEN region = 'Asia' THEN id END) + COUNT(DISTINCT CASE WHEN region = 'Oceania' THEN id END) - COUNT(DISTINCT CASE WHEN region IN ('Asia', 'Oceania') THEN id END) FROM UrbanAgriProject; |
What is the average production cost of organic cotton garments across all factories in India? | CREATE TABLE factories (factory_id INT,factory_name TEXT,country TEXT); INSERT INTO factories (factory_id,factory_name,country) VALUES (1,'Organic Textile Co','India'),(2,'Eco-Friendly Fashion','India'); CREATE TABLE garments (garment_id INT,garment_name TEXT,production_cost FLOAT,factory_id INT); INSERT INTO garments (garment_id,garment_name,production_cost,factory_id) VALUES (1,'Organic Cotton Tee',15.50,1),(2,'Cotton Tote Bag',8.25,1),(3,'Recycled Polyester Hoodie',28.99,2),(4,'Organic Cotton Dress',22.00,1); | SELECT AVG(g.production_cost) FROM garments g JOIN factories f ON g.factory_id = f.factory_id WHERE f.country = 'India' AND g.garment_name LIKE '%Organic Cotton%'; |
Identify the number of schools and libraries in rural areas, and calculate the ratio. | CREATE TABLE areas (name text,type text); INSERT INTO areas VALUES ('Urban','CityA'),('Suburban','CityB'),('Rural','CityC'),('Rural','CityD'); CREATE TABLE schools (name text,area_type text); INSERT INTO schools VALUES ('School1','Urban'),('School2','Rural'),('School3','Suburban'); CREATE TABLE libraries (name text,area_type text); INSERT INTO libraries VALUES ('Library1','Urban'),('Library2','Rural'),('Library3','Suburban'); | SELECT (SELECT COUNT(*) FROM schools WHERE area_type = 'Rural') / COUNT(DISTINCT area_type) AS rural_school_ratio, (SELECT COUNT(*) FROM libraries WHERE area_type = 'Rural') / COUNT(DISTINCT area_type) AS rural_library_ratio |
Which countries have more than 50 investigative journalists? | CREATE TABLE reporters (id INT,name VARCHAR(50),gender VARCHAR(10),age INT,position VARCHAR(20),country VARCHAR(50)); INSERT INTO reporters (id,name,gender,age,position,country) VALUES (1,'Anna Smith','Female',35,'News Reporter','USA'); INSERT INTO reporters (id,name,gender,age,position,country) VALUES (2,'Mike Johnson','Male',40,'Investigative Journalist','Canada'); INSERT INTO reporters (id,name,gender,age,position,country) VALUES (3,'Sofia Rodriguez','Female',32,'Investigative Journalist','Mexico'); | SELECT country, COUNT(*) FROM reporters WHERE position = 'Investigative Journalist' GROUP BY country HAVING COUNT(*) > 50; |
Find the total waste generation by material type in Sao Paulo in 2020. | CREATE TABLE waste_generation(city VARCHAR(20),material VARCHAR(20),quantity INT); INSERT INTO waste_generation VALUES('Sao Paulo','Plastic',12000),('Sao Paulo','Paper',18000),('Sao Paulo','Glass',8000); | SELECT material, SUM(quantity) as total_waste FROM waste_generation WHERE city = 'Sao Paulo' AND YEAR(event_date) = 2020 GROUP BY material; |
What are the names of graduate students who have published in journals with the highest impact factors? | CREATE TABLE student (id INT,name VARCHAR(50),program VARCHAR(50)); CREATE TABLE publication (id INT,title VARCHAR(100),journal_name VARCHAR(50),impact_factor DECIMAL(3,1)); | SELECT s.name FROM student s JOIN publication p ON s.id IN (SELECT student_id FROM grant WHERE title IN (SELECT title FROM publication WHERE impact_factor = (SELECT MAX(impact_factor) FROM publication))); |
Create a view to show the number of times each menu item has been ordered | CREATE TABLE menu_orders (id INT PRIMARY KEY,menu_item VARCHAR(255),order_count INT); | CREATE VIEW menu_orders_view AS SELECT menu_item, SUM(order_count) as total_orders FROM menu_orders GROUP BY menu_item; |
Delete the records of waste production for the 'South' plant in January 2022. | CREATE TABLE waste_production (plant varchar(20),waste_amount int,date date); | DELETE FROM waste_production WHERE plant = 'South' AND date = '2022-01-01'; |
What is the maximum and minimum value of each digital asset on the Binance Smart Chain? | CREATE TABLE digital_assets_binance (asset_id INT,asset_name VARCHAR(255),network VARCHAR(255)); INSERT INTO digital_assets_binance (asset_id,asset_name,network) VALUES (1,'BNB','Binance Smart Chain'),(2,'CAKE','Binance Smart Chain'); CREATE TABLE binance_transactions (transaction_id INT,asset_id INT,value DECIMAL(10,2)); INSERT INTO binance_transactions (transaction_id,asset_id,value) VALUES (1,1,50),(2,1,150),(3,2,5),(4,1,200); | SELECT d.asset_name, MAX(t.value) as max_value, MIN(t.value) as min_value FROM digital_assets_binance d JOIN binance_transactions t ON d.asset_id = t.asset_id GROUP BY d.asset_name; |
What is the total number of ethics violations in the 'ethics_violations' table? | CREATE TABLE ethics_violations (violation_id INT,story_id INT,description TEXT,violation_date DATE); | SELECT COUNT(*) FROM ethics_violations; |
List all menu items with a price greater than $10.00 | CREATE TABLE menu_items (menu_item_id INT,name VARCHAR(255),description TEXT,price DECIMAL(5,2),category VARCHAR(255),sustainability_rating INT); | SELECT * FROM menu_items WHERE price > 10.00; |
What is the total number of marine conservation initiatives in the Pacific Islands? | CREATE TABLE marine_conservation_initiatives (id INT,name TEXT,location TEXT); INSERT INTO marine_conservation_initiatives (id,name,location) VALUES (1,'Coral Reef Restoration','Pacific Islands'),(2,'Turtle Habitat Protection','Caribbean Sea'),(3,'Plastic Waste Reduction','Indian Ocean'); | SELECT COUNT(*) FROM marine_conservation_initiatives WHERE location = 'Pacific Islands'; |
Identify the top 3 longest tunnels in 'Oceania' and their construction dates, if available. | CREATE TABLE Tunnels (id INT,country VARCHAR(20),continent VARCHAR(20),year INT,length FLOAT); INSERT INTO Tunnels (id,country,continent,year,length) VALUES (1,'Australia','Oceania',2005,100); INSERT INTO Tunnels (id,country,continent,year,length) VALUES (2,'New Zealand','Oceania',2008,120); INSERT INTO Tunnels (id,country,continent,year,length) VALUES (3,'Australia','Oceania',2015,150); | SELECT country, year, length FROM (SELECT country, year, length, RANK() OVER (PARTITION BY continent ORDER BY length DESC) as tunnel_rank FROM Tunnels WHERE continent = 'Oceania') tmp WHERE tunnel_rank <= 3; |
What is the average salary of 'Mechanics' in the 'transportation_union' table? | CREATE TABLE transportation_union (employee_id INT,department VARCHAR(20),salary DECIMAL(10,2)); INSERT INTO transportation_union (employee_id,department,salary) VALUES (1,'Transportation Workers Union',40000.00),(2,'Drivers Union',45000.00),(3,'Mechanics Union',50000.00),(4,'Transportation Workers Union',40000.00); | SELECT AVG(salary) FROM transportation_union WHERE department = 'Mechanics Union'; |
What is the total number of marine trenches in the Southern Ocean? | CREATE TABLE marine_trenches (ocean TEXT,trench TEXT,max_depth INTEGER);INSERT INTO marine_trenches (ocean,trench,max_depth) VALUES ('Pacific','Mariana Trench',10994),('Southern','Southern Antiltic Trench',7235); | SELECT COUNT(*) FROM marine_trenches WHERE ocean = 'Southern'; |
What is the average production capacity for chemical plants that use the 'Traditional Production' method, ordered by capacity? | CREATE TABLE plants (id INT,name TEXT,production_method TEXT,capacity INT); INSERT INTO plants (id,name,production_method,capacity) VALUES (1,'ChemCo','Green Production',500),(2,'EcoChem','Traditional Production',400),(3,'GreenChem','Green Production',600); | SELECT AVG(capacity) AS avg_capacity FROM plants WHERE production_method = 'Traditional Production' ORDER BY capacity; |
What is the distribution of employees by department? | CREATE TABLE Employees (id INT,name VARCHAR(50),department VARCHAR(50)); INSERT INTO Employees (id,name,department) VALUES (1,'John Doe','HR'); INSERT INTO Employees (id,name,department) VALUES (2,'Jane Smith','IT'); INSERT INTO Employees (id,name,department) VALUES (3,'Alice Johnson','Finance'); | SELECT department, COUNT(*) AS total FROM Employees GROUP BY department; |
Delete records for products delivered by 'Farm Fresh' that have more than 650 calories. | CREATE TABLE Products (ProductID INT,SupplierID INT,Calories INT); INSERT INTO Products (ProductID,SupplierID,Calories) VALUES (1,1,500),(2,2,300),(3,1,600); | DELETE FROM Products WHERE ProductID IN (SELECT ProductID FROM (SELECT * FROM Products WHERE SupplierID = (SELECT SupplierID FROM Suppliers WHERE SupplierName = 'Farm Fresh')) AS product_farm_fresh WHERE Calories > 650); |
Which genre has the most songs in the music streaming platform? | CREATE TABLE genres (id INT,genre TEXT); CREATE TABLE songs (id INT,title TEXT,genre_id INT); INSERT INTO genres (id,genre) VALUES (1,'Pop'),(2,'Rock'),(3,'Hip Hop'); INSERT INTO songs (id,title,genre_id) VALUES (1,'Shake it Off',1),(2,'Lose Yourself',3),(3,'Bohemian Rhapsody',2); | SELECT COUNT(*) FROM songs JOIN genres ON songs.genre_id = genres.id GROUP BY genres.genre ORDER BY COUNT(*) DESC LIMIT 1; |
What is the average score of players who joined after 2020-01-01, grouped by their region? | CREATE TABLE players (id INT,join_date DATE,score INT,region VARCHAR(255)); INSERT INTO players (id,join_date,score,region) VALUES (1,'2019-12-31',100,'NA'),(2,'2020-01-02',200,'EU'),(3,'2019-12-30',150,'ASIA'); | SELECT region, AVG(score) FROM players WHERE join_date > '2020-01-01' GROUP BY region; |
How many security incidents were there in the last quarter that involved a user from the HR department accessing a system outside of their approved access list? | CREATE TABLE security_incidents (incident_id INT,incident_date DATE,user_id INT,system_id INT,approved_access BOOLEAN);CREATE TABLE users (user_id INT,user_name VARCHAR(255),department VARCHAR(255));CREATE TABLE systems (system_id INT,system_name VARCHAR(255)); | SELECT COUNT(*) FROM security_incidents si JOIN users u ON si.user_id = u.user_id JOIN systems s ON si.system_id = s.system_id WHERE incident_date >= DATE_SUB(CURRENT_DATE, INTERVAL 3 MONTH) AND approved_access = FALSE AND u.department = 'HR'; |
What is the total impact of social equity programs and dispensaries in the Northeast, considering sales and participants? | CREATE TABLE social_equity_programs (id INT PRIMARY KEY,name TEXT,region TEXT,participants INT); INSERT INTO social_equity_programs (id,name,region,participants) VALUES (1,'Northeast Cannabis Equity','Northeast',150); CREATE TABLE dispensaries (id INT PRIMARY KEY,name TEXT,region TEXT,sales INT); INSERT INTO dispensaries (id,name,region,sales) VALUES (1,'Northeast Dispensary','Northeast',2500); | SELECT dispensaries.name, social_equity_programs.name, SUM(dispensaries.sales * social_equity_programs.participants) as total_impact FROM dispensaries CROSS JOIN social_equity_programs WHERE dispensaries.region = social_equity_programs.region GROUP BY dispensaries.name, social_equity_programs.name; |
Find artists who have had more than 2,000,000 listens and display their average concert ticket sales? | CREATE TABLE Artists (ArtistID INT PRIMARY KEY,ArtistName VARCHAR(100),Age INT,Gender VARCHAR(10),Genre VARCHAR(50)); CREATE TABLE Concerts (ConcertID INT PRIMARY KEY,ConcertName VARCHAR(100),Venue VARCHAR(100),City VARCHAR(50),ArtistID INT,Date DATE,TotalSeats INT,CONSTRAINT FK_Artists FOREIGN KEY (ArtistID) REFERENCES Artists(ArtistID)); CREATE TABLE Tickets (TicketID INT PRIMARY KEY,Purchased DATETIME,ConcertID INT,CONSTRAINT FK_Concerts FOREIGN KEY (ConcertID) REFERENCES Concerts(ConcertID)); CREATE VIEW SoldConcerts AS SELECT ConcertID FROM Concerts WHERE Date < CURDATE() AND (SELECT COUNT(*) FROM Tickets WHERE ConcertID = Concerts.ConcertID) = Concerts.TotalSeats; CREATE VIEW SoldArtists AS SELECT ArtistID FROM Artists INNER JOIN SoldConcerts ON Artists.ArtistID = SoldConcerts.ArtistID; CREATE VIEW ConcertArtists AS SELECT ArtistID,COUNT(DISTINCT ConcertID) as NumberOfConcerts FROM Concerts GROUP BY ArtistID; | SELECT AVG(TotalSeats) as AvgTicketSales FROM Concerts INNER JOIN SoldArtists ON Concerts.ArtistID = SoldArtists.ArtistID WHERE SoldArtists.ArtistID IN (SELECT ArtistID FROM TotalListens WHERE TotalListens > 2000000); |
What is the maximum number of hours worked by a single worker on projects in Sydney, Australia? | CREATE TABLE Workers (Id INT,Name VARCHAR(50),Role VARCHAR(50),HourlyRate DECIMAL(5,2),ProjectId INT,HoursWorked INT); CREATE TABLE Projects (Id INT,Name VARCHAR(50),City VARCHAR(50),StartDate DATE,EndDate DATE,Country VARCHAR(50)); | SELECT MAX(w.HoursWorked) FROM Workers w JOIN Projects p ON w.ProjectId = p.Id WHERE p.City = 'Sydney' AND p.Country = 'Australia'; |
What is the total weight of cargo carried by the captain 'Svetlana Petrova'? | CREATE TABLE ports (id INT,name VARCHAR(50),location VARCHAR(50),un_code VARCHAR(10)); CREATE TABLE vessels (id INT,name VARCHAR(50),type VARCHAR(50),year_built INT,port_id INT); CREATE TABLE captains (id INT,name VARCHAR(50),age INT,license_number VARCHAR(20),vessel_id INT); CREATE TABLE cargo (id INT,description VARCHAR(50),weight FLOAT,port_id INT,vessel_id INT); CREATE VIEW captain_vessel AS SELECT captains.name AS captain_name,vessels.name AS vessel_name FROM captains INNER JOIN vessels ON captains.vessel_id = vessels.id; | SELECT SUM(cargo.weight) AS total_cargo_weight FROM cargo INNER JOIN vessels ON cargo.vessel_id = vessels.id INNER JOIN captains ON vessels.id = captains.vessel_id WHERE captains.name = 'Svetlana Petrova'; |
What is the maximum production capacity of factories in the circular economy sector? | CREATE TABLE Factories (id INT,sector VARCHAR,production_capacity INT); | SELECT MAX(production_capacity) FROM Factories WHERE sector = 'circular economy'; |
What are the names of all the hospitals and the number of beds available in each one in the state of New York? | CREATE TABLE hospitals (id INT,hospital_name VARCHAR(255),state VARCHAR(255),num_beds INT); | SELECT hospital_name, num_beds FROM hospitals WHERE state = 'New York'; |
What is the minimum efficiency achieved by each energy project in a given year? | CREATE TABLE efficiency_stats (id INT PRIMARY KEY,project_id INT,year INT,efficiency FLOAT,FOREIGN KEY (project_id) REFERENCES projects(id)); INSERT INTO efficiency_stats (id,project_id,year,efficiency) VALUES (7,1,2020,0.15),(8,2,2020,0.28); | SELECT project_id, MIN(efficiency) FROM efficiency_stats GROUP BY project_id; |
Find total weight of artifacts from 'african_excavations' > 500g | CREATE TABLE african_excavations (id INT,site_name VARCHAR(50),artifact_name VARCHAR(50),weight INT); | SELECT SUM(weight) FROM african_excavations WHERE weight > 500; |
What is the average water consumption per household in the state of California? | CREATE TABLE households (id INT,state VARCHAR(20),water_consumption FLOAT); INSERT INTO households (id,state,water_consumption) VALUES (1,'California',1200),(2,'Texas',1500),(3,'California',1100); | SELECT AVG(water_consumption) FROM households WHERE state = 'California' |
What is the average delivery time for shipments from China to Europe? | CREATE TABLE DeliveryTimes(id INT,source_country VARCHAR(50),destination_country VARCHAR(50),delivery_time INT); INSERT INTO DeliveryTimes(id,source_country,destination_country,delivery_time) VALUES (1,'China','Germany',10),(2,'China','France',12); | SELECT AVG(delivery_time) FROM DeliveryTimes WHERE source_country = 'China' AND destination_country LIKE '%Europe%'; |
Update the price field in the tours table for the tour with id 5 | CREATE TABLE tours (id INT PRIMARY KEY,name VARCHAR(255),description TEXT,price DECIMAL(5,2),city VARCHAR(255),country VARCHAR(255)); | UPDATE tours SET price = 75.00 WHERE id = 5; |
Which factories have implemented Industry 4.0 technologies, and the number of Industry 4.0 technologies they have implemented. | CREATE TABLE factories (factory_id INT,name TEXT,location TEXT,industry_4_0 TEXT,num_technologies INT); | SELECT factory_id, name, COUNT(industry_4_0) as num_technologies FROM factories WHERE industry_4_0 IS NOT NULL GROUP BY factory_id; |
How many patients have been treated for anxiety or depression in the mental health clinic? | CREATE TABLE patients (patient_id INT,age INT,gender VARCHAR(20),state VARCHAR(20)); INSERT INTO patients (patient_id,age,gender,state) VALUES (1,35,'Female','California'); INSERT INTO patients (patient_id,age,gender,state) VALUES (2,42,'Male','Texas'); CREATE TABLE treatments (treatment_id INT,patient_id INT,condition VARCHAR(50),treatment_date DATE); INSERT INTO treatments (treatment_id,patient_id,condition,treatment_date) VALUES (1,1,'Depression','2021-03-15'); INSERT INTO treatments (treatment_id,patient_id,condition,treatment_date) VALUES (2,2,'Anxiety','2021-03-16'); | SELECT COUNT(DISTINCT patients.patient_id) FROM patients INNER JOIN treatments ON patients.patient_id = treatments.patient_id WHERE treatments.condition = 'Depression' OR treatments.condition = 'Anxiety'; |
What is the total quantity of eco-friendly fabric in stock? | CREATE TABLE fabric_stock (id INT PRIMARY KEY,fabric VARCHAR(20),quantity INT); | SELECT SUM(quantity) FROM fabric_stock WHERE fabric = 'eco-friendly'; |
How many accessible vehicles are there in the 'fleet' table for each type? | CREATE TABLE fleet (id INT,type TEXT,is_accessible BOOLEAN); INSERT INTO fleet (id,type,is_accessible) VALUES (1,'bus',true),(2,'bus',false),(3,'tram',true),(4,'train',false); | SELECT type, COUNT(*) as count FROM fleet WHERE is_accessible = true GROUP BY type; |
What are the names of property owners who co-own a property in Canada? | CREATE TABLE Property (id INT,address VARCHAR(255),city VARCHAR(255),state VARCHAR(255),country VARCHAR(255),price DECIMAL(10,2),size INT,sustainable_practices BOOLEAN,coop_owned BOOLEAN); CREATE TABLE PropertyOwner (id INT,property_id INT,owner_name VARCHAR(255),owner_email VARCHAR(255),owner_phone VARCHAR(20)); CREATE TABLE PropertyCoop (id INT,property_id INT,coop_name VARCHAR(255),coop_membership BOOLEAN); | SELECT DISTINCT PropertyOwner.owner_name FROM PropertyOwner FULL OUTER JOIN PropertyCoop ON PropertyOwner.property_id = PropertyCoop.property_id WHERE PropertyCoop.coop_membership = TRUE AND Property.country = 'Canada'; |
Add a new record of a military innovation project. | CREATE TABLE military_innovation (id INT,project VARCHAR(255),budget INT); | INSERT INTO military_innovation (id, project, budget) VALUES (1, 'Artificial Intelligence in Combat', 10000000); |
Insert a new program called 'Gardening' into the 'programs' table and update the 'volunteers' table to add 5 volunteers to this new program. | CREATE TABLE programs (id INT PRIMARY KEY,name VARCHAR(255)); CREATE TABLE volunteers (id INT PRIMARY KEY,name VARCHAR(255),program_id INT,FOREIGN KEY (program_id) REFERENCES programs(id)); | INSERT INTO programs (name) VALUES ('Gardening'); UPDATE volunteers SET program_id = (SELECT id FROM programs WHERE name = 'Gardening') WHERE id IN (SELECT id FROM (VALUES (1), (2), (3), (4), (5)) as t(id)); |
What is the number of menu items that are vegan and do not contain soy? | CREATE TABLE MenuItems (MenuItemID int,MenuItemName varchar(255),MenuItemType varchar(255),Cost int,DietaryRestrictions varchar(255)); INSERT INTO MenuItems (MenuItemID,MenuItemName,MenuItemType,Cost,DietaryRestrictions) VALUES (1,'Margherita Pizza','Entree',8,'None'),(2,'Spaghetti Bolognese','Entree',9,'None'),(3,'Caprese Salad','Appetizer',7,'Vegan'),(4,'Veggie Burger','Entree',10,'Vegan'),(5,'Garden Salad','Appetizer',5,'Vegan'),(6,'Chickpea Curry','Entree',11,'Vegan'),(7,'Falafel Wrap','Entree',9,'Vegan'),(8,'Tofu Stir Fry','Entree',12,'Vegan'),(9,'Vegan Cheese Pizza','Entree',10,'Vegan'),(10,'Quinoa Salad','Entree',13,'Vegan,Gluten-free'),(11,'Gluten-Free Pasta','Entree',12,'Gluten-free'),(12,'Gluten-Free Pizza','Entree',14,'Gluten-free'),(13,'Gluten-Free Bread','Appetizer',6,'Gluten-free'),(14,'Vegetarian Lasagna','Entree',12,'Vegetarian'),(15,'Mushroom Risotto','Entree',14,'Vegan,No Soy'); | SELECT COUNT(*) FROM MenuItems WHERE DietaryRestrictions = 'Vegan' AND MenuItemName NOT LIKE '%Tofu%'; |
What is the total number of tickets sold for football matches in the '2018' season? | CREATE TABLE football_matches (match_id INT,season INT,tickets_sold INT); INSERT INTO football_matches (match_id,season,tickets_sold) VALUES (1,2018,45000),(2,2018,50000),(3,2017,40000); | SELECT SUM(tickets_sold) FROM football_matches WHERE season = 2018; |
Which manufacturer has the highest average safety rating for electric vehicles? | CREATE TABLE manufacturer_data (manufacturer VARCHAR(10),vehicle_type VARCHAR(10),safety_rating INT); | SELECT manufacturer, AVG(safety_rating) AS avg_safety_rating FROM manufacturer_data WHERE vehicle_type = 'Electric' GROUP BY manufacturer ORDER BY avg_safety_rating DESC LIMIT 1; |
What is the total number of employees from the United States and Canada? | CREATE TABLE Employees (id INT,name VARCHAR(100),country VARCHAR(50)); INSERT INTO Employees (id,name,country) VALUES (1,'John Doe','United States'),(2,'Jane Smith','Canada'); | SELECT COUNT(*) FROM Employees WHERE country IN ('United States', 'Canada'); |
What is the distribution of policy types across different age groups? | CREATE TABLE Policies (PolicyID int,PolicyType varchar(20),PolicyHolderAge int); INSERT INTO Policies (PolicyID,PolicyType,PolicyHolderAge) VALUES (1,'Auto',35),(2,'Home',50),(3,'Auto',25),(4,'Life',40); | SELECT PolicyType, PolicyHolderAge, COUNT(*) OVER (PARTITION BY PolicyType, PolicyHolderAge) as PolicyCount FROM Policies; |
Which cuisine type has the highest average calorie count? | CREATE TABLE dishes (id INT,name VARCHAR(255),cuisine VARCHAR(255),calories INT); INSERT INTO dishes (id,name,cuisine,calories) VALUES (1,'Chicken Tikka Masala','Indian',800),(2,'Pizza Margherita','Italian',600),(3,'Pad Thai','Thai',700),(4,'Beef Empanadas','Argentinian',400),(5,'Sushi Roll','Japanese',300); | SELECT cuisine, AVG(calories) as avg_calories FROM dishes GROUP BY cuisine ORDER BY avg_calories DESC LIMIT 1; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.