instruction stringlengths 0 1.06k | input stringlengths 11 5.3k | response stringlengths 2 4.44k |
|---|---|---|
What is the minimum weight of packages shipped from each warehouse, excluding shipments under 10 kg? | CREATE TABLE warehouse (id INT,location VARCHAR(255)); INSERT INTO warehouse (id,location) VALUES (1,'Chicago'),(2,'Houston'); CREATE TABLE packages (id INT,warehouse_id INT,weight FLOAT); INSERT INTO packages (id,warehouse_id,weight) VALUES (1,1,50.3),(2,1,30.1),(3,2,70.0),(4,2,10.0); | SELECT warehouse_id, MIN(weight) as min_weight FROM packages WHERE weight >= 10 GROUP BY warehouse_id; |
Find the top 3 artists with the highest number of streams in the "pop" genre for each year. | CREATE TABLE ArtistStreaming(id INT,artist VARCHAR(20),genre VARCHAR(10),streams INT,year INT); | SELECT artist, genre, year, SUM(streams) AS total_streams FROM ArtistStreaming WHERE genre = 'pop' GROUP BY artist, genre, year HAVING total_streams IN (SELECT DISTINCT total_streams FROM (SELECT genre, year, MAX(SUM(streams)) OVER (PARTITION BY genre) AS total_streams FROM ArtistStreaming WHERE genre = 'pop' GROUP BY genre, year) AS subquery) LIMIT 3; |
Update the "citizen_feedback" table to mark feedback with the ID 34 as "resolved" | CREATE TABLE citizen_feedback (feedback_id INT,feedback_text VARCHAR(255),status VARCHAR(20)); | UPDATE citizen_feedback SET status = 'resolved' WHERE feedback_id = 34; |
What was the minimum freight cost for a single shipment from Argentina in April 2021? | CREATE TABLE argentina_shipments (id INT,freight_cost DECIMAL(10,2),shipment_date DATE); INSERT INTO argentina_shipments (id,freight_cost,shipment_date) VALUES (1,1000.00,'2021-04-01'); INSERT INTO argentina_shipments (id,freight_cost,shipment_date) VALUES (2,1200.00,'2021-04-10'); | SELECT MIN(freight_cost) FROM argentina_shipments WHERE shipment_date >= '2021-04-01' AND shipment_date < '2021-05-01' AND country = 'Argentina'; |
How many building permits were issued in the city of Los Angeles in the first quarter of 2022? | CREATE TABLE building_permits (id INT,city VARCHAR(255),issue_date DATE); | SELECT COUNT(*) FROM building_permits WHERE city = 'Los Angeles' AND issue_date BETWEEN '2022-01-01' AND '2022-03-31'; |
What was the total revenue for each gallery in 2022? | CREATE TABLE GallerySales (Gallery VARCHAR(255),ArtWork VARCHAR(255),Year INT,Revenue DECIMAL(10,2)); INSERT INTO GallerySales (Gallery,ArtWork,Year,Revenue) VALUES ('Gallery A','Artwork 1',2022,500.00),('Gallery A','Artwork 2',2022,400.00),('Gallery B','Artwork 3',2022,750.00),('Gallery B','Artwork 4',2022,1000.00); | SELECT Gallery, SUM(Revenue) as TotalRevenue FROM GallerySales WHERE Year = 2022 GROUP BY Gallery; |
What is the average age of patients who received CBT in the US? | CREATE TABLE patients (id INT,age INT,country VARCHAR(20)); INSERT INTO patients (id,age,country) VALUES (1,30,'USA'),(2,45,'Canada'); CREATE TABLE treatments (id INT,patient_id INT,treatment VARCHAR(20)); INSERT INTO treatments (id,patient_id,treatment) VALUES (1,1,'CBT'),(2,2,'DBT'); | SELECT AVG(patients.age) FROM patients INNER JOIN treatments ON patients.id = treatments.patient_id WHERE treatments.treatment = 'CBT' AND patients.country = 'USA'; |
What is the total number of disability accommodation requests and their approval rates per department in the past year, ordered by the highest approval rate? | CREATE TABLE Disability_Accommodation_Requests (Department VARCHAR(50),Request_Date DATE,Request_Status VARCHAR(10)); INSERT INTO Disability_Accommodation_Requests VALUES ('HR','2021-01-01','Approved'),('IT','2021-02-01','Denied'),('Finance','2021-03-01','Approved'),('HR','2021-04-01','Approved'),('IT','2021-05-01','Approved'); | SELECT Department, COUNT(*) as Total_Requests, AVG(CASE WHEN Request_Status = 'Approved' THEN 1 ELSE 0 END) as Approval_Rate FROM Disability_Accommodation_Requests WHERE Request_Date >= DATEADD(year, -1, GETDATE()) GROUP BY Department ORDER BY Approval_Rate DESC; |
Count the number of wastewater treatment plants in 'WastewaterPlants' table that treat more than 1 million gallons daily. | CREATE TABLE WastewaterPlants (id INT,plant_name TEXT,daily_capacity INT); | SELECT COUNT(*) FROM WastewaterPlants WHERE daily_capacity > 1000000; |
Show the total savings of customers who have a high financial capability score | CREATE TABLE customers (customer_id INT,financial_capability_score INT,savings DECIMAL(10,2)); | SELECT SUM(savings) FROM customers WHERE financial_capability_score > 7; |
What is the total number of articles published in 'The Boston Bugle' that contain the words 'climate change' or 'global warming' in the last two years? | CREATE TABLE the_boston_bugle (title TEXT,publication_date DATE); | SELECT COUNT(*) FROM the_boston_bugle WHERE (lower(title) LIKE '%climate change%' OR lower(title) LIKE '%global warming%') AND publication_date > DATE('now','-2 years'); |
What is the average number of daily active users for each game genre? | CREATE TABLE GameActivity (GameID INT,GameName TEXT,Genre TEXT,DailyActiveUsers INT); INSERT INTO GameActivity (GameID,GameName,Genre,DailyActiveUsers) VALUES (1,'Game X','Racing',10000),(2,'Game Y','RPG',15000),(3,'Game Z','Strategy',12000),(4,'Game W','Racing',8000),(5,'Game V','RPG',13000); | SELECT Genre, AVG(DailyActiveUsers) AS AvgDailyActiveUsers FROM GameActivity GROUP BY Genre; |
What is the total production of 'Coffee' and 'Tea' in 'South America' in 2021? | CREATE TABLE crops (id INT,name TEXT,production INT,year INT,country TEXT); INSERT INTO crops (id,name,production,year,country) VALUES (1,'Coffee',10000,2021,'Brazil'); INSERT INTO crops (id,name,production,year,country) VALUES (2,'Tea',5000,2021,'Argentina'); | SELECT SUM(production) as total_production FROM crops WHERE (name = 'Coffee' OR name = 'Tea') AND year = 2021 AND country IN ('Brazil', 'Argentina'); |
What was the total attendance at events in the 'Dance' category? | CREATE TABLE event_attendance (id INT,event_id INT,attendee_count INT); CREATE TABLE events (id INT,category VARCHAR(10)); INSERT INTO event_attendance (id,event_id,attendee_count) VALUES (1,1,250),(2,2,320),(3,3,175),(4,4,200); INSERT INTO events (id,category) VALUES (1,'Dance'),(2,'Music'),(3,'Theater'),(4,'Dance'); | SELECT SUM(attendee_count) FROM event_attendance JOIN events ON event_attendance.event_id = events.id WHERE events.category = 'Dance'; |
What is the maximum and minimum loan amount for socially responsible lending institutions in Australia? | CREATE TABLE SociallyResponsibleLending (id INT,institution_name VARCHAR(50),country VARCHAR(50),loan_amount FLOAT); INSERT INTO SociallyResponsibleLending (id,institution_name,country,loan_amount) VALUES (1,'Good Earth Lending','Australia',10000),(2,'Green Future Lending','Australia',15000),(3,'Community First Lending','Australia',8000); | SELECT country, MAX(loan_amount) as max_loan_amount, MIN(loan_amount) as min_loan_amount FROM SociallyResponsibleLending WHERE country = 'Australia' GROUP BY country; |
What is the average revenue per product for skincare category in Q1 of 2023? | CREATE TABLE sales (product_id INT,product_name VARCHAR(100),category VARCHAR(50),sale_date DATE,revenue DECIMAL(10,2),region VARCHAR(50)); INSERT INTO sales (product_id,product_name,category,sale_date,revenue,region) VALUES (1,'Cleanser','Skincare','2023-01-02',15.99,'East'),(2,'Toner','Skincare','2023-01-15',20.99,'West'); | SELECT category, EXTRACT(QUARTER FROM sale_date) AS quarter, AVG(revenue) AS avg_revenue_per_product FROM sales WHERE category = 'Skincare' AND EXTRACT(QUARTER FROM sale_date) = 1 GROUP BY category, quarter; |
What is the total cost of spacecraft manufactured by SpaceTech Inc. and Galactic Inc.? | CREATE TABLE SpacecraftManufacturing (company VARCHAR(20),cost INT); INSERT INTO SpacecraftManufacturing (company,cost) VALUES ('SpaceTech Inc.',25000000); INSERT INTO SpacecraftManufacturing (company,cost) VALUES ('Galactic Inc.',30000000); | SELECT SUM(cost) FROM SpacecraftManufacturing WHERE company IN ('SpaceTech Inc.', 'Galactic Inc.'); |
What is the minimum ocean acidity level measured in the Indian Ocean? | CREATE TABLE acidity_measurements_indian (location TEXT,acidity_level REAL); INSERT INTO acidity_measurements_indian (location,acidity_level) VALUES ('Seychelles',7.8),('Maldives',8.0),('Sri Lanka',8.1); | SELECT MIN(acidity_level) FROM acidity_measurements_indian; |
List the top 3 most popular content types in terms of ad impressions. | CREATE TABLE content_types (content_type VARCHAR(50),ad_id INT); INSERT INTO content_types (content_type,ad_id) VALUES ('video',1),('image',2),('text',3),('video',4),('image',5),('text',6); | SELECT content_type, COUNT(*) as impressions FROM content_types JOIN ads ON content_types.ad_id = ads.ad_id GROUP BY content_type ORDER BY impressions DESC LIMIT 3; |
What are the unique transaction types and their counts for all customers from Canada? | CREATE TABLE customer (customer_id INT,first_name VARCHAR(50),last_name VARCHAR(50),country VARCHAR(50)); INSERT INTO customer (customer_id,first_name,last_name,country) VALUES (1,'John','Doe','USA'),(2,'Jane','Smith','Canada'),(3,'Maria','Garcia','Canada'),(4,'David','Lee','USA'); CREATE TABLE transactions (transaction_id INT,customer_id INT,transaction_date DATE,transaction_type VARCHAR(50)); INSERT INTO transactions (transaction_id,customer_id,transaction_date,transaction_type) VALUES (1,1,'2022-01-01','Withdrawal'),(2,1,'2022-01-05','Deposit'),(3,2,'2022-01-07','Withdrawal'),(4,3,'2022-01-09','Transfer'),(5,4,'2022-01-11','Withdrawal'); | SELECT transaction_type, COUNT(*) FROM transactions INNER JOIN customer ON transactions.customer_id = customer.customer_id WHERE customer.country = 'Canada' GROUP BY transaction_type; |
Determine the average investment amount per investment type for each Islamic bank, excluding investments from a specific region. | CREATE TABLE islamic_bank (id INT,bank_name VARCHAR(255)); CREATE TABLE sustainable_investments (id INT,islamic_bank_id INT,investment_type VARCHAR(255),investment_amount DECIMAL(10,2),investor_region VARCHAR(255)); | SELECT i.bank_name, s.investment_type, AVG(s.investment_amount) as avg_investment_amount FROM islamic_bank i JOIN sustainable_investments s ON i.id = s.islamic_bank_id WHERE s.investor_region != 'Middle East' GROUP BY i.bank_name, s.investment_type; |
List the concert venues with a capacity greater than 20,000 that have hosted artists in the 'Pop' genre? | CREATE TABLE Concerts (ConcertID INT,VenueID INT,ArtistID INT,VenueCapacity INT); INSERT INTO Concerts (ConcertID,VenueID,ArtistID,VenueCapacity) VALUES (1,1001,2,25000),(2,1002,4,18000),(3,1003,1,30000),(4,1004,3,22000),(5,1005,2,15000); | SELECT VenueID, VenueCapacity FROM Concerts JOIN Artists ON Concerts.ArtistID = Artists.ArtistID WHERE Genre = 'Pop' AND VenueCapacity > 20000; |
What is the average number of crimes per day in each borough of New York City in 2021? | CREATE TABLE NYCDailyCrimes (Borough VARCHAR(255),Year INT,Crimes INT); INSERT INTO NYCDailyCrimes (Borough,Year,Crimes) VALUES ('Manhattan',2021,100),('Brooklyn',2021,120),('Queens',2021,110),('Bronx',2021,90),('Staten Island',2021,80); | SELECT B.Borough, AVG(DC.Crimes) as AvgCrimesPerDay FROM NYCDailyCrimes DC INNER JOIN Boroughs B ON DC.Borough = B.Borough WHERE DC.Year = 2021 GROUP BY B.Borough; |
Insert a new safety protocol record for a specific manufacturing plant, specifying its effective date and a description. | CREATE TABLE safety_protocols (id INT,plant_id INT,effective_date DATE,description VARCHAR(100)); INSERT INTO manufacturing_plants (id,name) VALUES (1,'Plant A'),(2,'Plant B'); | INSERT INTO safety_protocols (id, plant_id, effective_date, description) VALUES (1, 1, '2022-03-01', 'Wear protective gear at all times'); |
Identify the top 3 countries with the highest union membership density. | CREATE TABLE union_density(country VARCHAR(14),total_members INT,total_workforce INT);INSERT INTO union_density(country,total_members,total_workforce) VALUES ('Canada',4000000,19000000),('United States',15000000,160000000),('Australia',2000000,12000000); | SELECT country, (total_members * 100.0 / total_workforce) AS union_density FROM union_density ORDER BY union_density DESC LIMIT 3; |
List all defense projects with a start date before 2015 and their associated contractors that have not been completed yet, ordered by the start date. | CREATE TABLE defense_projects (id INT,project_name VARCHAR(255),start_date DATE,end_date DATE,contractor VARCHAR(255)); INSERT INTO defense_projects (id,project_name,start_date,end_date,contractor) VALUES (1,'Project A','2010-01-01','2014-12-31','Northrop Grumman'); INSERT INTO defense_projects (id,project_name,start_date,end_date,contractor) VALUES (2,'Project B','2012-01-01',NULL,'Raytheon'); | SELECT project_name, contractor FROM defense_projects WHERE start_date < '2015-01-01' AND end_date IS NULL ORDER BY start_date; |
Delete all Green building projects in South Africa that were implemented before 2019. | CREATE TABLE green_buildings (project_name VARCHAR(50),country VARCHAR(50),implementation_year INT); INSERT INTO green_buildings (project_name,country,implementation_year) VALUES ('ProjectF','South Africa',2020),('ProjectG','South Africa',2019),('ProjectH','South Africa',2021); | DELETE FROM green_buildings WHERE country = 'South Africa' AND implementation_year < 2019; |
What is the total revenue generated by sales of sustainable fashion items? | CREATE TABLE sales (id INT,product VARCHAR(255),date DATE,quantity INT,price DECIMAL(10,2)); CREATE TABLE products (id INT,name VARCHAR(255),category VARCHAR(255),sustainable BOOLEAN); INSERT INTO sales (id,product,date,quantity,price) VALUES (1,'dress','2022-01-01',10,100.00),(2,'dress','2022-02-01',15,120.00),(3,'dress','2022-03-01',20,150.00),(4,'shirt','2022-01-01',5,50.00),(5,'pants','2022-02-01',8,70.00),(6,'jacket','2022-03-01',3,200.00); INSERT INTO products (id,name,category,sustainable) VALUES (1,'dress','clothing',true),(2,'shirt','clothing',false),(3,'pants','clothing',false),(4,'jacket','clothing',true); | SELECT SUM(sales.quantity * sales.price) FROM sales INNER JOIN products ON sales.product = products.name WHERE products.sustainable = true; |
Who are the top 3 actors with the highest number of movies? | CREATE TABLE Actor_Movies (actor VARCHAR(255),movies INT); INSERT INTO Actor_Movies (actor,movies) VALUES ('Actor1',10),('Actor2',12),('Actor3',8),('Actor4',15),('Actor5',11); | SELECT actor FROM Actor_Movies ORDER BY movies DESC LIMIT 3; |
What is the percentage of total ticket sales for classical concerts in the last year? | CREATE TABLE TicketSales (genre VARCHAR(20),sale_date DATE,revenue DECIMAL(5,2)); INSERT INTO TicketSales (genre,sale_date,revenue) VALUES ('Classical','2022-03-12',1200.00),('Jazz','2021-11-28',800.00),('Classical','2022-01-01',1000.00); | SELECT (SUM(CASE WHEN genre = 'Classical' THEN revenue ELSE 0 END) / SUM(revenue)) * 100 FROM TicketSales WHERE sale_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR); |
What is the total installed capacity of solar farms in 'Oregon'? | CREATE TABLE solar_farms (id INT,state VARCHAR(20),capacity FLOAT); INSERT INTO solar_farms (id,state,capacity) VALUES (1,'Oregon',120.5),(2,'Washington',150.2),(3,'Oregon',180.1),(4,'Nevada',200.5); | SELECT SUM(capacity) FROM solar_farms WHERE state = 'Oregon'; |
List concert venues that have hosted artists from both the 'Rock' and 'Jazz' genres? | CREATE TABLE Concerts (ConcertID INT,VenueID INT,ArtistID INT,Genre VARCHAR(10)); INSERT INTO Concerts (ConcertID,VenueID,ArtistID,Genre) VALUES (1,1001,1,'Rock'),(2,1002,2,'Jazz'),(3,1003,3,'Jazz'),(4,1004,4,'Pop'),(5,1005,1,'Rock'),(6,1006,2,'Rock'),(7,1007,3,'Pop'); | SELECT VenueID FROM Concerts WHERE Genre = 'Rock' INTERSECT SELECT VenueID FROM Concerts WHERE Genre = 'Jazz'; |
What is the total billing amount for clients by gender and race? | CREATE TABLE ClientBilling (ClientID INT,ClientName VARCHAR(50),Gender VARCHAR(50),Race VARCHAR(50),BillingAmount DECIMAL(10,2)); INSERT INTO ClientBilling (ClientID,ClientName,Gender,Race,BillingAmount) VALUES (1,'John Doe','Male','White',5000.00),(2,'Jane Doe','Female','Asian',7000.00),(3,'Bob Smith','Male','Black',6000.00),(4,'Alice Johnson','Female','Hispanic',8000.00),(5,'David Williams','Male','White',9000.00); | SELECT Gender, Race, SUM(BillingAmount) AS TotalBillingAmount FROM ClientBilling GROUP BY Gender, Race; |
Add a new marine species 'New Species' discovered in 2022 in the Indian Ocean to the marine_species table. | CREATE TABLE marine_species (id INT,name VARCHAR(50),discovery_date DATE,location VARCHAR(50)); | INSERT INTO marine_species (id, name, discovery_date, location) VALUES (4, 'New Species', '2022-03-02', 'Indian Ocean'); |
How many aircraft were manufactured by each company in the past 5 years? | CREATE TABLE aircraft (aircraft_name VARCHAR(255),manufacturer VARCHAR(255),production_date DATE); INSERT INTO aircraft (aircraft_name,manufacturer,production_date) VALUES ('Air1','Man1','2018-05-12'),('Air2','Man2','2020-12-18'),('Air3','Man1','2019-09-21'),('Air4','Man3','2017-01-03'),('Air5','Man2','2021-06-25'); | SELECT manufacturer, COUNT(*) OVER (PARTITION BY manufacturer) as count FROM aircraft WHERE production_date >= DATEADD(year, -5, CURRENT_DATE) GROUP BY manufacturer ORDER BY count DESC; |
What is the minimum number of lanes on any highway in the state of California? | CREATE TABLE Highways (id INT,name TEXT,state TEXT,lanes INT); INSERT INTO Highways (id,name,state,lanes) VALUES (1,'Interstate 5','California',6); INSERT INTO Highways (id,name,state,lanes) VALUES (2,'Highway 1','California',2); | SELECT MIN(lanes) FROM Highways WHERE state = 'California' |
What is the total number of humanitarian assistance projects in the Middle East with a budget over $5 million? | CREATE TABLE Humanitarian_Assistance (Nation VARCHAR(50),Continent VARCHAR(50),Project VARCHAR(50),Budget DECIMAL(10,2)); INSERT INTO Humanitarian_Assistance (Nation,Continent,Project,Budget) VALUES ('Saudi Arabia','Middle East','Disaster Relief Project',7000000.00),('Israel','Middle East','Refugee Support Project',6000000.00); | SELECT SUM(Budget) FROM Humanitarian_Assistance WHERE Continent = 'Middle East' AND Budget > 5000000; |
What is the average depth of all expeditions led by female researchers? | CREATE TABLE Expeditions(ExpeditionID INT,LeaderName VARCHAR(20),AvgDepth DECIMAL(5,2)); INSERT INTO Expeditions(ExpeditionID,LeaderName,AvgDepth) VALUES (1,'Alice',3500.50),(2,'Bob',4200.30),(3,'Charlie',2100.75),(4,'Dana',5100.90),(5,'Eve',2900.40); | SELECT AVG(AvgDepth) FROM Expeditions WHERE LeaderName IN ('Alice', 'Eve'); |
What is the total budget for community development projects in Africa, grouped by project type and country, and sorted in descending order by total budget? | CREATE TABLE community_development (id INT,country VARCHAR(50),project_type VARCHAR(50),budget INT); INSERT INTO community_development (id,country,project_type,budget) VALUES (1,'Kenya','Community Center',5000000),(2,'Uganda','Park',6000000),(3,'Tanzania','Library',7000000),(4,'Rwanda','Community Garden',8000000); | SELECT project_type, country, SUM(budget) as total_budget FROM community_development GROUP BY project_type, country ORDER BY total_budget DESC; |
How many hotels in each country have adopted AI-powered chatbots for customer support? | CREATE TABLE hotels (hotel_id INT,hotel_name TEXT,country TEXT);CREATE TABLE ai_chatbots (chatbot_id INT,hotel_id INT,installation_date DATE); INSERT INTO hotels (hotel_id,hotel_name,country) VALUES (1,'Hotel X','USA'),(2,'Hotel Y','Canada'); INSERT INTO ai_chatbots (chatbot_id,hotel_id,installation_date) VALUES (1,1,'2021-01-01'),(2,2,'2021-02-01'); | SELECT h.country, COUNT(DISTINCT h.hotel_id) as hotel_count FROM hotels h INNER JOIN ai_chatbots ac ON h.hotel_id = ac.hotel_id GROUP BY h.country; |
What is the total number of eco-tours in Canada and Australia? | CREATE TABLE eco_tours (tour_id INT,location VARCHAR(255),type VARCHAR(255)); INSERT INTO eco_tours (tour_id,location,type) VALUES (1,'Canada Wildlife Tour','eco'),(2,'Australia Rainforest Tour','eco'); | SELECT COUNT(*) FROM eco_tours WHERE location IN ('Canada', 'Australia'); |
What is the maximum installed capacity for solar power projects in the state of New York, grouped by project status? | CREATE TABLE solar_projects (id INT,project_name VARCHAR(255),state VARCHAR(255),project_status VARCHAR(255),installed_capacity INT); | SELECT project_status, MAX(installed_capacity) FROM solar_projects WHERE state = 'New York' GROUP BY project_status; |
Remove the marine conservation law in the Southern Ocean | CREATE TABLE marine_conservation_laws (id INT PRIMARY KEY,law_name VARCHAR(255),region VARCHAR(255)); INSERT INTO marine_conservation_laws (id,law_name,region) VALUES (1,'Southern Ocean Marine Conservation Act','Southern Ocean'); | DELETE FROM marine_conservation_laws WHERE region = 'Southern Ocean'; |
Which customers have purchased the most sustainable fashion items, and what is the total quantity of sustainable items purchased by each customer? | CREATE TABLE PurchaseHistory (CustomerID INT,ProductID INT,Quantity INT,SustainableFlag INT); | SELECT C.CustomerName, SUM(PH.Quantity) AS TotalSustainableItemsPurchased FROM Customers C INNER JOIN PurchaseHistory PH ON C.CustomerID = PH.CustomerID WHERE PH.SustainableFlag = 1 GROUP BY C.CustomerName ORDER BY TotalSustainableItemsPurchased DESC; |
What is the total number of marine species observed in the Indian Ocean and their conservation status? | CREATE TABLE MarineSpecies (species_name VARCHAR(50),species_id INT,region VARCHAR(50),conservation_status VARCHAR(50),PRIMARY KEY(species_name,species_id)); INSERT INTO MarineSpecies (species_name,species_id,region,conservation_status) VALUES ('SpeciesA',1,'Indian Ocean','Vulnerable'),('SpeciesB',2,'Indian Ocean','Endangered'),('SpeciesC',3,'Indian Ocean','Least Concern'); | SELECT COUNT(MarineSpecies.species_name), MarineSpecies.conservation_status FROM MarineSpecies WHERE MarineSpecies.region = 'Indian Ocean' GROUP BY MarineSpecies.conservation_status; |
What is the total amount of organic fertilizer used by farms in California? | CREATE TABLE farms (id INT,name VARCHAR(50),location VARCHAR(50),acres FLOAT,organic_certified BOOLEAN); INSERT INTO farms (id,name,location,acres,organic_certified) VALUES (1,'Anderson Farms','California',120.3,TRUE); INSERT INTO farms (id,name,location,acres,organic_certified) VALUES (2,'Baker Farms','Texas',250.6,FALSE); | SELECT SUM(quantity) as total_organic_fertilizer FROM fertilizers INNER JOIN farms ON fertilizers.farm_id = farms.id WHERE farms.location = 'California' AND farms.organic_certified = TRUE; |
Insert new user with random last_post_at | CREATE TABLE users (id INT,name TEXT,last_post_at TIMESTAMP); | INSERT INTO users (id, name, last_post_at) VALUES (3, 'Eve', DATE_SUB(NOW(), INTERVAL FLOOR(RAND() * 365) DAY)); |
What is the total revenue by city for the first half of 2022? | CREATE TABLE gym_memberships (id INT,member_name VARCHAR(50),start_date DATE,end_date DATE,membership_type VARCHAR(50),price DECIMAL(5,2)); CREATE TABLE gym_locations (id INT,location_name VARCHAR(50),state VARCHAR(50),city VARCHAR(50),members INT); | SELECT city, SUM(price) AS total_revenue FROM gym_memberships JOIN gym_locations ON gym_memberships.location_name = gym_locations.location WHERE start_date BETWEEN '2022-01-01' AND '2022-06-30' GROUP BY city; |
What was the total revenue for the state of California in the first quarter of 2022? | CREATE TABLE sales (id INT,state VARCHAR(50),quarter INT,revenue FLOAT); INSERT INTO sales (id,state,quarter,revenue) VALUES (1,'California',1,25000.0),(2,'California',2,30000.0),(3,'Colorado',1,20000.0),(4,'Colorado',2,22000.0); | SELECT SUM(revenue) FROM sales WHERE state = 'California' AND quarter = 1; |
What is the average CO2 emission of electric vehicles in Nigeria? | CREATE TABLE Electric_Vehicles_Nigeria (Id INT,Vehicle VARCHAR(50),CO2_Emission DECIMAL(5,2)); INSERT INTO Electric_Vehicles_Nigeria (Id,Vehicle,CO2_Emission) VALUES (1,'Hyundai Kona Electric',0.0),(2,'Tesla Model 3',0.0),(3,'Nissan Leaf',0.0); | SELECT AVG(CO2_Emission) FROM Electric_Vehicles_Nigeria; |
How many cruelty-free ingredients are used in total across all products? | CREATE TABLE Product (id INT,productName VARCHAR(50),price DECIMAL(5,2)); INSERT INTO Product (id,productName,price) VALUES (4,'Blush',14.99),(5,'Foundation',29.99),(6,'Lip Liner',16.99); CREATE TABLE Ingredient (id INT,productId INT,ingredient VARCHAR(50),sourceCountry VARCHAR(50),crueltyFree BOOLEAN); INSERT INTO Ingredient (id,productId,ingredient,sourceCountry,crueltyFree) VALUES (6,4,'Shea Butter','Ghana',true),(7,4,'Rosehip Oil','Chile',true),(8,5,'Vitamin E','Argentina',true),(9,5,'Zinc Oxide','Australia',true),(10,6,'Jojoba Oil','Peru',true); | SELECT SUM(I.crueltyFree) as totalCrueltyFreeIngredients FROM Ingredient I; |
How many traditional art forms are being preserved in Europe? | CREATE TABLE ArtForms (ArtFormID INT PRIMARY KEY,Name VARCHAR(100),Origin VARCHAR(50),Status VARCHAR(20)); INSERT INTO ArtForms (ArtFormID,Name,Origin,Status) VALUES (1,'Oil Painting','Europe','Preserved'),(2,'Watercolor','Europe','Preserved'); | SELECT COUNT(*) FROM ArtForms WHERE Origin = 'Europe' AND Status = 'Preserved'; |
Which regions have recycling rates higher than the overall average? | CREATE TABLE recycling_rates (region VARCHAR(50),year INT,recycling_rate FLOAT); INSERT INTO recycling_rates (region,year,recycling_rate) VALUES ('North America',2020,0.35),('South America',2020,0.30),('Europe',2020,0.45),('Asia',2020,0.25),('Africa',2020,0.20); | SELECT region FROM recycling_rates WHERE recycling_rate > (SELECT AVG(recycling_rate) FROM recycling_rates); |
What is the average population of all marine species with a conservation status of 'Endangered'? | CREATE TABLE marine_biodiversity (id INT PRIMARY KEY,species VARCHAR(255),population INT,conservation_status VARCHAR(255)); INSERT INTO marine_biodiversity (id,species,population,conservation_status) VALUES (1,'Clownfish',2000,'Least Concern'),(2,'Sea Turtle',1500,'Endangered'); | SELECT AVG(population) FROM marine_biodiversity WHERE conservation_status = 'Endangered'; |
What is the total quantity of recycled materials used in product manufacturing for each category? | CREATE TABLE products (product_id INT,product_name TEXT,category TEXT,recycled_materials_quantity INT); INSERT INTO products (product_id,product_name,category,recycled_materials_quantity) VALUES (1,'Organic Cotton T-Shirt','Tops',50),(2,'Recycled Plastic Bottle Water Bottle','Drinkware',100); | SELECT category, SUM(recycled_materials_quantity) AS total_quantity FROM products GROUP BY category; |
What is the maximum funding round size for companies founded by immigrants? | CREATE TABLE company (id INT,name TEXT,founding_year INT,founder_immigrant BOOLEAN); INSERT INTO company (id,name,founding_year,founder_immigrant) VALUES (1,'Acme Inc',2010,true); INSERT INTO company (id,name,founding_year,founder_immigrant) VALUES (2,'Beta Corp',2015,false); | SELECT MAX(funding_round_size) FROM investment_rounds INNER JOIN company ON investment_rounds.company_id = company.id WHERE company.founder_immigrant = true; |
What is the total population of Smart Cities that have implemented smart waste management systems and green buildings in India? | CREATE TABLE SmartCities (id INT PRIMARY KEY,name VARCHAR(255),country VARCHAR(255),population INT,founded_date DATE,smart_waste BOOLEAN,green_buildings BOOLEAN); INSERT INTO SmartCities (id,name,country,population,founded_date,smart_waste,green_buildings) VALUES (1,'EcoCity','Germany',500000,'2010-01-01',TRUE,TRUE); | SELECT SUM(population) as total_population FROM SmartCities WHERE country = 'India' AND smart_waste = TRUE AND green_buildings = TRUE; |
What is the maximum weekly wage for each job category in the 'labor_stats' table? | CREATE TABLE labor_stats (id INT,job_category VARCHAR(255),weekly_wage FLOAT); INSERT INTO labor_stats (id,job_category,weekly_wage) VALUES (1,'Engineering',1500.50),(2,'Management',2000.75),(3,'Service',800.00); | SELECT job_category, MAX(weekly_wage) as max_wage FROM labor_stats GROUP BY job_category; |
What is the average donation amount in the 'Donations' table for the 'Health' department? | CREATE TABLE Donations (id INT,department VARCHAR(20),amount FLOAT); INSERT INTO Donations (id,department,amount) VALUES (1,'Animals',500.00),(2,'Health',600.00),(3,'Health',650.00); | SELECT AVG(amount) FROM Donations WHERE department = 'Health' |
What was the total revenue for each restaurant category in 2022? | CREATE TABLE revenue (restaurant_name TEXT,category TEXT,revenue NUMERIC,date DATE); INSERT INTO revenue (restaurant_name,category,revenue,date) VALUES ('ABC Bistro','Italian',5000,'2022-01-01'),('ABC Bistro','Italian',6000,'2022-01-02'),('XYZ Café','Coffee Shop',3000,'2022-01-01'),('XYZ Café','Coffee Shop',3500,'2022-01-02'); | SELECT category, SUM(revenue) as total_revenue FROM revenue GROUP BY category; |
What is the total investment in agricultural innovation in South Asia in the past 3 years? | CREATE TABLE investment (id INT,project TEXT,location TEXT,investment_amount INT,year INT); INSERT INTO investment (id,project,location,investment_amount,year) VALUES (1,'Potato Seed Project','India',200000,2019),(2,'Corn Seed Project','Pakistan',300000,2020),(3,'Rice Seed Project','Bangladesh',150000,2018),(4,'Wheat Seed Project','Sri Lanka',250000,2021); | SELECT SUM(investment_amount) FROM investment WHERE location LIKE 'South%' AND year BETWEEN 2019 AND 2021; |
What is the average water usage per sustainable material? | CREATE TABLE WaterUsage (UsageID INT,Material VARCHAR(50),Water DECIMAL(5,2)); INSERT INTO WaterUsage (UsageID,Material,Water) VALUES (1,'Organic Cotton',2.50),(2,'Hemp',1.80),(3,'Recycled Polyester',3.20); | SELECT Material, AVG(Water) AS AvgWaterUsage FROM WaterUsage GROUP BY Material; |
What is the average precipitation in 'City B' for the year 2022? | CREATE TABLE Climate_Data (id INT,location VARCHAR(100),temperature FLOAT,precipitation FLOAT,date DATE); INSERT INTO Climate_Data (id,location,temperature,precipitation,date) VALUES (2,'City B',20,60,'2022-01-01'); | SELECT AVG(precipitation) FROM Climate_Data WHERE location = 'City B' AND year(date) = 2022; |
What is the total number of military equipment sold by Acme Corp to Country A, grouped by equipment type? | CREATE TABLE military_sales (id INT PRIMARY KEY,seller VARCHAR(255),buyer VARCHAR(255),equipment_type VARCHAR(255),quantity INT); | SELECT equipment_type, SUM(quantity) FROM military_sales WHERE seller = 'Acme Corp' AND buyer = 'Country A' GROUP BY equipment_type; |
How many packages were shipped via ground transportation from each warehouse in Q1 2021? | CREATE TABLE packages (id INT,shipment_type VARCHAR(20),warehouse VARCHAR(20),quarter INT); INSERT INTO packages (id,shipment_type,warehouse,quarter) VALUES (1,'Ground','Atlanta',1),(2,'Air','Dallas',2),(3,'Ground','Atlanta',1); CREATE TABLE warehouses (id INT,name VARCHAR(20)); INSERT INTO warehouses (id,name) VALUES (1,'Atlanta'),(2,'Dallas'); CREATE TABLE shipment_types (id INT,type VARCHAR(20)); INSERT INTO shipment_types (id,type) VALUES (1,'Ground'),(2,'Air'); | SELECT p.warehouse, COUNT(*) FROM packages p JOIN warehouses w ON p.warehouse = w.name JOIN shipment_types st ON p.shipment_type = st.type WHERE st.type = 'Ground' AND p.quarter = 1 GROUP BY p.warehouse; |
Delete all records from the sharks table where the species is 'Great White' | CREATE TABLE sharks (id INT,species VARCHAR(255),weight FLOAT); INSERT INTO sharks (id,species,weight) VALUES (1,'Great White',2000.0),(2,'Hammerhead',150.0); | DELETE FROM sharks WHERE species = 'Great White'; |
What is the minimum fare for a single trip on the 'sydney' schema's ferry system? | CREATE TABLE sydney.ferry_fares (id INT,trip_type VARCHAR,fare DECIMAL); INSERT INTO sydney.ferry_fares (id,trip_type,fare) VALUES (1,'single',5.5),(2,'return',9.5),(3,'weekly',40); | SELECT MIN(fare) FROM sydney.ferry_fares WHERE trip_type = 'single'; |
Delete all records related to decentralized applications that have been banned in Japan. | CREATE TABLE dapps (id INT,name VARCHAR(255),status VARCHAR(255),country VARCHAR(255)); INSERT INTO dapps (id,name,status,country) VALUES (1,'App 1','Banned','Japan'),(2,'App 2','Active','USA'); | DELETE FROM dapps WHERE status = 'Banned' AND country = 'Japan'; |
What is the average temperature and humidity for each crop type in the 'precision_farming' table? | CREATE TABLE precision_farming (id INT,crop VARCHAR(255),acres DECIMAL(10,2),yield DECIMAL(10,2),temperature DECIMAL(5,2),humidity DECIMAL(5,2)); | SELECT crop, AVG(temperature) as avg_temperature, AVG(humidity) as avg_humidity FROM precision_farming GROUP BY crop; |
What is the minimum quantity of a vegan product in the cosmetics category? | CREATE TABLE products (product_id INT,is_vegan BOOLEAN,category VARCHAR(20),quantity INT); INSERT INTO products (product_id,is_vegan,category,quantity) VALUES (1,true,'Cosmetics',10),(2,false,'Food',20),(3,true,'Cosmetics',30); | SELECT MIN(products.quantity) FROM products WHERE products.is_vegan = true AND products.category = 'Cosmetics'; |
Get the number of employees hired each month in the 'HR' department, ordered by hire date. | CREATE TABLE Employees (EmployeeID INT,HireDate DATE,Department VARCHAR(50)); INSERT INTO Employees (EmployeeID,HireDate,Department) VALUES (1,'2021-01-01','HR'),(2,'2021-03-15','HR'),(3,'2021-08-25','IT'),(4,'2021-11-04','HR'),(5,'2021-02-16','Marketing'),(6,'2021-03-01','HR'),(7,'2021-01-10','HR'); | SELECT MONTH(HireDate) AS HireMonth, COUNT(*) FROM Employees WHERE Department = 'HR' GROUP BY HireMonth ORDER BY HireMonth; |
What was the total number of rural infrastructure projects in 2019, by country? | CREATE TABLE rural_infrastructure_projects (id INT PRIMARY KEY,country VARCHAR(50),project_name VARCHAR(100),start_date DATE,end_date DATE); | SELECT country, COUNT(*) as total_projects FROM rural_infrastructure_projects WHERE YEAR(start_date) = 2019 GROUP BY country; |
What is the total number of farms and the total area of land used for farming in each country in the "farms" and "countries" tables? | CREATE TABLE farms (id INT,country_id INT,area FLOAT); CREATE TABLE countries (id INT,name VARCHAR(50)); | SELECT countries.name AS country, COUNT(farms.id) AS num_farms, SUM(farms.area) AS total_area FROM farms INNER JOIN countries ON farms.country_id = countries.id GROUP BY countries.name; |
Who are the top 3 digital asset issuers with the highest total supply? | CREATE TABLE digital_assets (asset_id INT,asset_name VARCHAR(255),asset_type VARCHAR(255),issuer VARCHAR(255),issue_date TIMESTAMP,total_supply DECIMAL(10,2)); CREATE TABLE asset_holders (holder_id INT,asset_id INT,holder_name VARCHAR(255),holdings DECIMAL(10,2),holdings_date TIMESTAMP); | SELECT i.issuer, SUM(a.total_supply) as total_issued FROM digital_assets a JOIN issuers i ON a.issuer = i.issuer_name GROUP BY i.issuer ORDER BY total_issued DESC LIMIT 3; |
What are the sales details for Raytheon's Patriot missile systems in Europe? | CREATE TABLE sales (id INT,supplier_id INT,equipment_id INT,quantity INT,price DECIMAL(10,2),date DATE,PRIMARY KEY(id),FOREIGN KEY (supplier_id) REFERENCES suppliers(id),FOREIGN KEY (equipment_id) REFERENCES equipment(id)); INSERT INTO sales (id,supplier_id,equipment_id,quantity,price,date) VALUES (2,2,2,15,1500000,'2021-02-01'); CREATE TABLE suppliers (id INT,name VARCHAR(50),PRIMARY KEY(id)); INSERT INTO suppliers (id,name) VALUES (2,'Raytheon'); CREATE TABLE equipment (id INT,name VARCHAR(50),PRIMARY KEY(id)); INSERT INTO equipment (id,name) VALUES (2,'Patriot missile system'); CREATE TABLE regions (id INT,name VARCHAR(50),PRIMARY KEY(id)); INSERT INTO regions (id,name) VALUES (2,'Europe'); | SELECT * FROM sales WHERE supplier_id = 2 AND equipment_id = 2 AND region_id = 2; |
Find the latest health equity metric by state. | CREATE TABLE HealthEquityMetrics (HEMId INT,Metric VARCHAR(255),State VARCHAR(50),MetricDate DATE); INSERT INTO HealthEquityMetrics (HEMId,Metric,State,MetricDate) VALUES (1,'Health Equity Index','California','2021-01-01'),(2,'Equity Score','Texas','2021-02-01'),(3,'Health Equity Report','Florida','2021-03-01'); | SELECT State, Metric, MetricDate FROM HealthEquityMetrics WHERE MetricDate = (SELECT MAX(MetricDate) FROM HealthEquityMetrics) AND State = (SELECT State FROM HealthEquityMetrics WHERE MetricDate = (SELECT MAX(MetricDate) FROM HealthEquityMetrics)); |
What is the number of community education programs in the 'community_education' table, grouped by location? | CREATE TABLE community_education (id INT,location VARCHAR(30),program_name VARCHAR(50)); INSERT INTO community_education (id,location,program_name) VALUES (1,'New York','Wildlife Conservation'),(2,'California','Habitat Protection'),(3,'New York','Species Protection'),(4,'Texas','Community Education'); | SELECT location, COUNT(*) FROM community_education GROUP BY location; |
Create a new table 'risk_assessment' with columns 'policyholder_id', 'risk_score' | CREATE TABLE if not exists policyholders (policyholder_id INT PRIMARY KEY,name VARCHAR(255),age INT,gender VARCHAR(10),policy_type VARCHAR(50),premium DECIMAL(10,2)); | CREATE TABLE risk_assessment (policyholder_id INT, risk_score INT, PRIMARY KEY (policyholder_id)); |
List the names and funding amounts for the top 3 biotech startups founded by men, ordered by funding amount in descending order. | CREATE SCHEMA if not exists biotech; CREATE TABLE if not exists biotech.startups (id INT,name VARCHAR(100),founder_gender VARCHAR(10),funding FLOAT); INSERT INTO biotech.startups (id,name,founder_gender,funding) VALUES (1,'StartupA','Female',5000000.0),(2,'StartupB','Male',7000000.0),(3,'StartupC','Female',6000000.0); | SELECT name, funding FROM (SELECT name, funding, ROW_NUMBER() OVER (PARTITION BY founder_gender ORDER BY funding DESC) as rn FROM biotech.startups WHERE founder_gender = 'Male') t WHERE rn <= 3 ORDER BY funding DESC; |
What is the average production cost of organic cotton t-shirts across all factories? | CREATE TABLE Factories (factory_id INT,name VARCHAR(100),location VARCHAR(100)); CREATE TABLE Production (product_id INT,factory_id INT,material VARCHAR(100),cost DECIMAL(5,2)); INSERT INTO Factories VALUES (1,'Factory A','USA'),(2,'Factory B','India'),(3,'Factory C','Bangladesh'); INSERT INTO Production VALUES (1,1,'Organic Cotton',10.50),(2,1,'Polyester',8.00),(3,2,'Organic Cotton',6.00),(4,2,'Hemp',9.50),(5,3,'Organic Cotton',5.00); | SELECT AVG(Production.cost) FROM Production JOIN Factories ON Production.factory_id = Factories.factory_id WHERE Production.material = 'Organic Cotton'; |
Which autonomous taxi had the highest speed on a given date? | CREATE TABLE taxi_speed (id INT,taxi_id INT,taxi_type VARCHAR(20),speed FLOAT,date DATE); INSERT INTO taxi_speed (id,taxi_id,taxi_type,speed,date) VALUES (1,101,'Autonomous',70.5,'2022-02-01'); INSERT INTO taxi_speed (id,taxi_id,taxi_type,speed,date) VALUES (2,102,'Autonomous',72.1,'2022-02-01'); INSERT INTO taxi_speed (id,taxi_id,taxi_type,speed,date) VALUES (3,103,'Conventional',68.7,'2022-02-01'); | SELECT taxi_id, MAX(speed) as max_speed FROM taxi_speed WHERE taxi_type = 'Autonomous' AND date = '2022-02-01' GROUP BY taxi_id ORDER BY max_speed DESC LIMIT 1; |
Calculate the total number of tourists visiting historic sites in India. | CREATE TABLE Tourists (tourist_id INT,tourist_name VARCHAR(50),country VARCHAR(50),visited_historic_site BOOLEAN); INSERT INTO Tourists (tourist_id,tourist_name,country,visited_historic_site) VALUES (1,'Raj Tourist','India',true),(2,'Simran Tourist','India',false),(3,'Amit Tourist','India',true); CREATE TABLE HistoricSites (site_id INT,site_name VARCHAR(50),country VARCHAR(50)); INSERT INTO HistoricSites (site_id,site_name,country) VALUES (1,'Taj Mahal','India'),(2,'Red Fort','India'); | SELECT COUNT(*) FROM Tourists INNER JOIN HistoricSites ON Tourists.country = HistoricSites.country WHERE Tourists.visited_historic_site = true; |
What's the total budget for programs in the environment and human rights categories? | CREATE TABLE Programs (ProgramID INT,ProgramName TEXT,Category TEXT,Budget DECIMAL); INSERT INTO Programs (ProgramID,ProgramName,Category,Budget) VALUES (1,'Climate Change Action','Environment',12000),(2,'Sustainable Agriculture','Environment',18000),(3,'Human Rights Advocacy','Human Rights',22000),(4,'Access to Education','Human Rights',8000); | SELECT SUM(Budget) FROM Programs WHERE Category IN ('Environment', 'Human Rights'); |
What is the percentage of products that are free from artificial fragrances? | CREATE TABLE products (product_id INT PRIMARY KEY,artificial_fragrances BOOLEAN); INSERT INTO products (product_id,artificial_fragrances) VALUES (1,false),(2,true),(3,false),(4,false),(5,true),(6,true); | SELECT (COUNT(*) FILTER (WHERE artificial_fragrances = false)) * 100.0 / COUNT(*) FROM products; |
What is the total number of policies and their combined premium for policyholders living in 'Ontario' who have a car make of 'BMW' or 'Audi'? | CREATE TABLE Policyholders (PolicyholderID INT,Premium DECIMAL(10,2),PolicyholderState VARCHAR(10),CarMake VARCHAR(20)); INSERT INTO Policyholders (PolicyholderID,Premium,PolicyholderState,CarMake) VALUES (1,5000,'Ontario','BMW'),(2,3000,'Quebec','Audi'),(3,1000,'California','Tesla'); | SELECT SUM(Premium), COUNT(*) FROM Policyholders WHERE PolicyholderState = 'Ontario' AND (CarMake = 'BMW' OR CarMake = 'Audi'); |
What is the total budget for community engagement events in Oceania? | CREATE TABLE CommunityEngagement (Event VARCHAR(255),Year INT,Country VARCHAR(255),Budget INT); INSERT INTO CommunityEngagement (Event,Year,Country,Budget) VALUES ('Aboriginal Art Festival',2020,'Australia',100000),('Aboriginal Art Festival',2019,'Australia',120000),('Aboriginal Art Festival',2018,'Australia',150000),('Indigenous Film Festival',2020,'Australia',80000),('Indigenous Film Festival',2019,'Australia',90000),('Indigenous Film Festival',2018,'Australia',70000),('Maori Language Week',2020,'New Zealand',120000),('Maori Language Week',2019,'New Zealand',110000),('Maori Language Week',2018,'New Zealand',130000); | SELECT SUM(Budget) as Total_Budget FROM CommunityEngagement WHERE Country = 'Australia' OR Country = 'New Zealand'; |
What is the average budget allocated for social good research by organizations located in Africa? | CREATE TABLE organizations (id INT,name VARCHAR(255),region VARCHAR(255),budget DECIMAL(10,2)); INSERT INTO organizations (id,name,region,budget) VALUES (1,'African Social Good Initiative','Africa',3000000.00),(2,'Asia Pacific AI Institute','Asia Pacific',5000000.00); | SELECT AVG(budget) FROM organizations WHERE region = 'Africa'; |
Find the total number of visitors who engaged in community events in Australia in the last quarter | CREATE TABLE Community_Events (id INT,country VARCHAR(20),event_date DATE,visitor_count INT); | SELECT SUM(visitor_count) FROM Community_Events WHERE country = 'Australia' AND event_date >= DATE_SUB(CURRENT_DATE, INTERVAL 3 MONTH); |
What was the average donation amount by new donors in Q2 2022? | CREATE TABLE donations (id INT,donor_id INT,amount FLOAT,donation_date DATE); INSERT INTO donations (id,donor_id,amount,donation_date) VALUES (1,3,200,'2022-04-01'); INSERT INTO donations (id,donor_id,amount,donation_date) VALUES (2,4,400,'2022-05-15'); INSERT INTO donors (id,name,industry,first_donation_date DATE) VALUES (3,'Alex Johnson','Retail','2022-04-01'); INSERT INTO donors (id,name,industry,first_donation_date DATE) VALUES (4,'Bella Williams','Healthcare','2022-05-15'); | SELECT AVG(amount) FROM donations d JOIN donors don ON d.donor_id = don.id WHERE first_donation_date BETWEEN '2022-04-01' AND '2022-06-30'; |
What is the maximum and minimum dissolved oxygen level in the Arctic Ocean? | CREATE TABLE ocean_health (id INT,ocean_name VARCHAR(20),dissolved_oxygen DECIMAL(5,2)); INSERT INTO ocean_health (id,ocean_name,dissolved_oxygen) VALUES (1,'Arctic',12.5),(2,'Antarctic',11.2); | SELECT MAX(dissolved_oxygen), MIN(dissolved_oxygen) FROM ocean_health WHERE ocean_name = 'Arctic'; |
How many artifacts were discovered in the 'Tutankhamun's Tomb' excavation site in 2005? | CREATE TABLE ExcavationSites (site_id INT,site_name VARCHAR(50)); CREATE TABLE Artifacts (artifact_id INT,site_id INT,discovered_year INT); INSERT INTO ExcavationSites (site_id,site_name) VALUES (4,'Tutankhamun''s Tomb'); INSERT INTO Artifacts (artifact_id,site_id,discovered_year) VALUES (5,4,2005),(6,4,2003),(7,4,2004),(8,4,2006); | SELECT COUNT(*) FROM Artifacts WHERE site_id = (SELECT site_id FROM ExcavationSites WHERE site_name = 'Tutankhamun''s Tomb') AND discovered_year = 2005; |
Find the average funding for companies with female and Asian founders in the e-commerce sector | CREATE TABLE companies (id INT,industry VARCHAR(255),founding_date DATE); CREATE TABLE founders (id INT,name VARCHAR(255),gender VARCHAR(255),race VARCHAR(255)); CREATE TABLE funding (company_id INT,amount INT); INSERT INTO companies SELECT 1,'e-commerce','2015-01-01'; INSERT INTO founders SELECT 1,'Alice','female','Asian'; INSERT INTO funding SELECT 1,800000; | SELECT AVG(funding.amount) FROM funding JOIN companies ON funding.company_id = companies.id JOIN founders ON companies.id = founders.id WHERE companies.industry = 'e-commerce' AND founders.gender = 'female' AND founders.race = 'Asian'; |
What is the average temperature and humidity for Farm 3? | CREATE TABLE weather_data (id INT,location VARCHAR(50),temperature FLOAT,humidity FLOAT,time TIMESTAMP); INSERT INTO weather_data (id,location,temperature,humidity,time) VALUES (1,'Farm 3',25.0,60.0,'2021-01-01 10:00:00'); | SELECT AVG(temperature), AVG(humidity) FROM weather_data WHERE location = 'Farm 3'; |
Find the average sustainability score of garments, grouped by brand, excluding garments with a score below 5. | CREATE TABLE garments (garment_id INT,brand_id INT,sustainability_score INT); INSERT INTO garments (garment_id,brand_id,sustainability_score) VALUES (1,1,7),(2,1,8),(3,2,6),(4,2,9),(5,3,5),(6,3,10); | SELECT s.brand_id, AVG(g.sustainability_score) AS avg_sustainability_score FROM garments g INNER JOIN brands s ON g.brand_id = s.brand_id WHERE g.sustainability_score >= 5 GROUP BY g.brand_id; |
How many police officers joined the police force in California in Q1 of 2020? | CREATE TABLE police_officers (id INT,name VARCHAR(255),joined_date DATE,state VARCHAR(255)); INSERT INTO police_officers (id,name,joined_date,state) VALUES (1,'John Doe','2020-01-02','California'); | SELECT COUNT(*) FROM police_officers WHERE state = 'California' AND joined_date >= '2020-01-01' AND joined_date < '2020-04-01'; |
Show the total revenue of sustainable cosmetics sold in 2022 | CREATE TABLE sales_data(product_id INT,product_type VARCHAR(20),sale_date DATE,revenue DECIMAL(10,2),sustainable BOOLEAN); INSERT INTO sales_data(product_id,product_type,sale_date,revenue,sustainable) VALUES(1,'Lipstick','2022-01-01',50.00,TRUE),(2,'Blush','2022-01-15',75.00,FALSE); | SELECT SUM(revenue) FROM sales_data WHERE product_type LIKE 'Cosmetics%' AND sustainable = TRUE AND YEAR(sale_date) = 2022; |
How many military equipment maintenance requests were submitted per month in the year 2021? | CREATE TABLE MaintenanceRequests (RequestID int,RequestDate date); INSERT INTO MaintenanceRequests (RequestID,RequestDate) VALUES (1,'2021-01-15'),(2,'2021-03-01'),(3,'2021-04-10'),(4,'2021-07-05'),(5,'2021-11-28'); | SELECT DATE_PART('month', RequestDate) as Month, COUNT(*) as NumberOfRequests FROM MaintenanceRequests WHERE RequestDate BETWEEN '2021-01-01' AND '2021-12-31' GROUP BY Month; |
What is the average age of players who use VR technology, partitioned by platform? | CREATE TABLE players (player_id INT,age INT,platform VARCHAR(10)); INSERT INTO players (player_id,age,platform) VALUES (1,25,'PSVR'),(2,30,'Oculus'),(3,22,'Vive'); CREATE TABLE vr_tech (tech_id INT,platform VARCHAR(10)); INSERT INTO vr_tech (tech_id,platform) VALUES (1,'PSVR'),(2,'Oculus'); | SELECT platform, AVG(age) as avg_age FROM players p JOIN vr_tech v ON p.platform = v.platform GROUP BY platform; |
What is the maximum billing amount for cases handled by attorneys from the 'Los Angeles' office? | CREATE TABLE offices (office_id INT,city TEXT); CREATE TABLE attorneys (attorney_id INT,office_id INT); CREATE TABLE cases (case_id INT,attorney_id INT,billing_amount INT); | SELECT MAX(cases.billing_amount) FROM cases INNER JOIN attorneys ON cases.attorney_id = attorneys.attorney_id INNER JOIN offices ON attorneys.office_id = offices.office_id WHERE offices.city = 'Los Angeles'; |
How many autonomous buses are there in Seattle? | CREATE TABLE if not exists public_transport (id INT,city VARCHAR(20),vehicle_type VARCHAR(20),quantity INT);INSERT INTO public_transport (id,city,vehicle_type,quantity) VALUES (1,'Seattle','autonomous_bus',30),(2,'Seattle','manual_bus',200),(3,'Portland','autonomous_bus',20),(4,'Portland','manual_bus',180); | SELECT SUM(quantity) FROM public_transport WHERE city = 'Seattle' AND vehicle_type = 'autonomous_bus'; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.