instruction stringlengths 0 1.06k | input stringlengths 11 5.3k | response stringlengths 2 4.44k |
|---|---|---|
What is the total number of hours of professional development completed by teachers in each district in the last quarter? | CREATE TABLE TeacherProfessionalDevelopment (TeacherID INT,District VARCHAR(50),Date DATE,Hours INT); INSERT INTO TeacherProfessionalDevelopment (TeacherID,District,Date,Hours) VALUES (1,'Urban Education','2022-01-01',10),(2,'Suburban Education','2022-01-15',15),(3,'Rural Education','2022-02-01',20); | SELECT District, SUM(Hours) FROM TeacherProfessionalDevelopment WHERE Date >= DATEADD(quarter, -1, GETDATE()) GROUP BY District; |
How many workers are employed in each department?' | CREATE TABLE departments_extended (id INT,department TEXT,worker INT); INSERT INTO departments_extended (id,department,worker) VALUES (1,'mining',250),(2,'geology',180),(3,'drilling',200); | SELECT department, SUM(worker) AS total_workers FROM departments_extended GROUP BY department; |
What are the total sales for product 'XYZ123' in Q1 2022? | CREATE TABLE sales (product_id VARCHAR(10),sale_date DATE,revenue DECIMAL(10,2)); INSERT INTO sales (product_id,sale_date,revenue) VALUES ('XYZ123','2022-01-01',500),('XYZ123','2022-01-15',700),('XYZ123','2022-03-03',600); | SELECT SUM(revenue) FROM sales WHERE product_id = 'XYZ123' AND sale_date BETWEEN '2022-01-01' AND '2022-03-31'; |
What is the average session duration for therapy sessions that took place in the therapy_sessions table? | CREATE TABLE therapy_sessions (session_id INT,patient_id INT,therapist_id INT,session_date DATE,session_duration TIME); | SELECT AVG(session_duration) FROM therapy_sessions; |
What is the monthly trend of ethical product sales in the past 2 years? | CREATE TABLE ethical_sales (sale_id int,sale_date date,is_ethical boolean,revenue decimal); | SELECT DATEPART(YEAR, sale_date) AS year, DATEPART(MONTH, sale_date) AS month, SUM(revenue) AS total_revenue FROM ethical_sales WHERE is_ethical = true GROUP BY DATEPART(YEAR, sale_date), DATEPART(MONTH, sale_date) ORDER BY year, month; |
What was the total amount spent on defense contracts in Q1 of 2019? | CREATE TABLE Defense_Contracts (ID INT,Quarter VARCHAR(50),Year INT,Amount INT); INSERT INTO Defense_Contracts (ID,Quarter,Year,Amount) VALUES (1,'Q1',2017,1500000),(2,'Q1',2019,2000000),(3,'Q2',2018,1750000); | SELECT Amount FROM Defense_Contracts WHERE Quarter = 'Q1' AND Year = 2019; |
What is the sum of all claim amounts for policyholders residing in 'Texas'? | CREATE TABLE Policyholders (id INT,state VARCHAR(20)); CREATE TABLE Claims (claim_id INT,policyholder_id INT,amount FLOAT); | SELECT SUM(amount) FROM Claims INNER JOIN Policyholders ON Claims.policyholder_id = Policyholders.id WHERE state = 'Texas'; |
Identify dishes with a price increase of more than 10% since they were added | CREATE TABLE dishes (dish_id INT,dish_name VARCHAR(255),added_date DATE,price DECIMAL(5,2),original_price DECIMAL(5,2)); INSERT INTO dishes (dish_id,dish_name,added_date,price,original_price) VALUES (1,'Margherita Pizza','2022-01-01',14.99,12.99),(2,'Chicken Alfredo','2022-01-01',15.99,15.99),(3,'Caesar Salad','2021-12... | SELECT dish_id, dish_name, price, ROUND((price - original_price) / original_price * 100, 2) as price_increase_percentage FROM dishes WHERE (price - original_price) / original_price * 100 > 10; |
How many artworks were created in each decade of the 20th century? | CREATE TABLE ArtworksDecade (ArtworkID INT,Name VARCHAR(100),Artist VARCHAR(100),Decade INT); | SELECT Decade, COUNT(*) as ArtworksCount FROM (SELECT FLOOR(YearCreated / 10) * 10 as Decade, Name, Artist FROM Artworks WHERE YearCreated BETWEEN 1901 AND 2000) tmp GROUP BY Decade; |
How many biosensors were developed by 'BioTech Sensors'? | CREATE TABLE biosensors (id INT,organization TEXT,biosensor_count INT); INSERT INTO biosensors (id,organization,biosensor_count) VALUES (1,'BioSense',15); INSERT INTO biosensors (id,organization,biosensor_count) VALUES (2,'BioTech Sensors',25); | SELECT biosensor_count FROM biosensors WHERE organization = 'BioTech Sensors'; |
What is the total number of crimes committed in the city of Miami in the year 2020, grouped by crime type? | CREATE TABLE crimes (id INT,city VARCHAR(20),year INT,crime_type VARCHAR(20),number_of_crimes INT); | SELECT crime_type, SUM(number_of_crimes) FROM crimes WHERE city = 'Miami' AND year = 2020 GROUP BY crime_type; |
Update the maintenance status for a specific fleet management record in the "fleet_management" table | CREATE TABLE fleet_management (id INT PRIMARY KEY,vessel_id INT,maintenance_type VARCHAR(255),maintenance_date DATE,is_complete BOOLEAN); | UPDATE fleet_management SET is_complete = false WHERE id = 2; |
Show health equity metric trends in Texas for the past year. | CREATE TABLE health_equity_metrics (id INT,metric_name VARCHAR(50),metric_value INT,date DATE); INSERT INTO health_equity_metrics (id,metric_name,metric_value,date) VALUES (1,'Accessibility Index',85,'2021-01-01'),(2,'Healthcare Quality Score',78,'2021-01-01'); CREATE TABLE regions (id INT,name VARCHAR(50)); INSERT INT... | SELECT metric_name, date, metric_value FROM health_equity_metrics INNER JOIN regions ON health_equity_metrics.date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR) WHERE regions.name = 'Texas'; |
Which player from Africa has the highest score in the 'all_time_high_scores' table? | CREATE TABLE all_time_high_scores (player_id INT,player_name TEXT,score INT,country TEXT); | SELECT player_name, MAX(score) as high_score FROM all_time_high_scores WHERE country = 'Africa' GROUP BY player_name ORDER BY high_score DESC LIMIT 1; |
Delete a case from the 'cases' table | CREATE TABLE cases (case_number INT PRIMARY KEY,case_name VARCHAR(255),date_filed DATE,case_type VARCHAR(255),status VARCHAR(50),victim_id INT,defendant_id INT,program_id INT); | DELETE FROM cases WHERE case_number = 2022004; |
What is the total budget for all policies in each city that were active in the year 2020? | CREATE TABLE Policy (id INT,name VARCHAR(50),city_id INT,start_date DATE,end_date DATE,budget DECIMAL(10,2)); INSERT INTO Policy (id,name,city_id,start_date,end_date,budget) VALUES (19,'PolicyG',1,'2020-01-01','2022-12-31',800000),(20,'PolicyH',1,'2021-01-01','2023-12-31',900000),(21,'PolicyI',2,'2020-01-01','2021-12-3... | SELECT C.name as city_name, SUM(budget) as total_budget FROM Policy P INNER JOIN City C ON P.city_id = C.id WHERE YEAR(start_date) <= 2020 AND YEAR(end_date) >= 2020 GROUP BY C.name; |
What was the total funding received by the cultural center in the year 2019? | CREATE TABLE CenterFunding (id INT,year INT,funding FLOAT); INSERT INTO CenterFunding (id,year,funding) VALUES (1,2017,50000),(2,2018,55000),(3,2019,60000),(4,2020,65000); | SELECT SUM(funding) FROM CenterFunding WHERE year = 2019; |
How many recycling centers are there in each country? | CREATE TABLE Recycling_Centers (country VARCHAR(20),center_type VARCHAR(20)); INSERT INTO Recycling_Centers (country,center_type) VALUES ('US','Glass'),('US','Paper'),('Canada','Glass'),('Mexico','Plastic'); | SELECT country, COUNT(*) FROM Recycling_Centers GROUP BY country; |
Get all aircraft with the engine 'CFM56' | CREATE TABLE aircraft (id INT PRIMARY KEY,model VARCHAR(50),engine VARCHAR(50)); INSERT INTO aircraft (id,model,engine) VALUES (101,'747','CFM56'),(102,'A320','IAE V2500'),(103,'A350','Rolls-Royce Trent XWB'),(104,'787','GE GEnx'),(105,'737','CFM56'); | SELECT * FROM aircraft WHERE engine = 'CFM56'; |
List all the unique research topics that have been published on by faculty members. | CREATE TABLE Publications (PublicationID int,FacultyID int,Topic varchar(50)); INSERT INTO Publications (PublicationID,FacultyID,Topic) VALUES (1,1,'Quantum Mechanics'); INSERT INTO Publications (PublicationID,FacultyID,Topic) VALUES (2,2,'Particle Physics'); CREATE TABLE Faculty (FacultyID int,Name varchar(50)); INSER... | SELECT DISTINCT Publications.Topic FROM Publications; |
What is the average word count of articles that mention 'racial equity'? | CREATE TABLE Articles (id INT,title VARCHAR(255),content TEXT,word_count INT); INSERT INTO Articles (id,title,content,word_count) VALUES (1,'Racial Equity in Education','Racial equity is important in education...',500),(2,'Economic Impact','The economy is a significant...',300),(3,'Racial Equity in Healthcare','Racial ... | SELECT AVG(word_count) as avg_word_count FROM Articles WHERE title LIKE '%racial equity%' OR content LIKE '%racial equity%'; |
What is the average energy rating for each building in a specific location? | CREATE TABLE energy_efficiency (id INT PRIMARY KEY,building_id INT,energy_rating INT); CREATE TABLE buildings (id INT PRIMARY KEY,name VARCHAR(50),location VARCHAR(50)); CREATE TABLE energy_transactions (id INT PRIMARY KEY,building_id INT,source VARCHAR(50),energy_type VARCHAR(50),quantity INT,transaction_date DATE); | SELECT buildings.location, AVG(energy_efficiency.energy_rating) FROM energy_efficiency INNER JOIN buildings ON energy_efficiency.building_id = buildings.id GROUP BY buildings.location; |
What is the total number of excavation sites and associated artifacts for each country? | CREATE TABLE Countries(id INT,name TEXT); INSERT INTO Countries (id,name) VALUES (1,'Country A'); INSERT INTO Countries (id,name) VALUES (2,'Country B'); CREATE TABLE ExcavationSites(id INT,country_id INT,name TEXT,date DATE); INSERT INTO ExcavationSites (id,country_id,name,date) VALUES (1,1,'Site A','2000-01-01'); INS... | SELECT Countries.name, COUNT(ExcavationSites.id) AS site_count, COUNT(Artifacts.id) AS artifact_count FROM Countries LEFT JOIN ExcavationSites ON Countries.id = ExcavationSites.country_id LEFT JOIN Artifacts ON ExcavationSites.id = Artifacts.excavation_site_id GROUP BY Countries.name; |
Compare virtual tour engagement metrics between Asia and Europe. | CREATE TABLE virtual_tours (hotel_id INT,location VARCHAR(20),views INT,clicks INT); | SELECT location, AVG(views) as avg_views, AVG(clicks) as avg_clicks FROM virtual_tours WHERE location IN ('Asia', 'Europe') GROUP BY location |
Delete all virtual tours that took place before January 1, 2022. | CREATE TABLE virtual_tours (tour_id INT,location VARCHAR(50),tour_date DATE); INSERT INTO virtual_tours (tour_id,location,tour_date) VALUES (1,'Paris','2022-01-01'),(2,'Rome','2022-06-15'),(3,'London','2021-12-31'),(4,'Berlin','2022-07-01'); | DELETE FROM virtual_tours WHERE tour_date < '2022-01-01'; |
What is the minimum carbon sequestration achieved in a single year in tropical rainforests, and which forest was it? | CREATE TABLE tropical_rainforests (id INT,name VARCHAR(255),country VARCHAR(255),sequestration INT); INSERT INTO tropical_rainforests (id,name,country,sequestration) VALUES (1,'Tropical Rainforest 1','Brazil',9000),(2,'Tropical Rainforest 2','Brazil',12000),(3,'Tropical Rainforest 3','Brazil',15000); | SELECT name, MIN(sequestration) FROM tropical_rainforests WHERE country = 'Brazil'; |
How many students with mental health disabilities received accommodations in each region of Texas? | CREATE TABLE Students (StudentID INT,DisabilityType TEXT,Region TEXT); INSERT INTO Students (StudentID,DisabilityType,Region) VALUES (1,'VisualImpairment','North'),(2,'HearingImpairment','South'),(3,'MentalHealth','East'); CREATE TABLE Accommodations (StudentID INT,AccommodationID INT); INSERT INTO Accommodations (Stud... | SELECT Region, COUNT(*) as NumStudents FROM Students JOIN Accommodations ON Students.StudentID = Accommodations.StudentID WHERE DisabilityType = 'MentalHealth' AND State = 'Texas' GROUP BY Region; |
Calculate the total amount donated by each donor, sorted by the highest donation amount. | CREATE TABLE donations (donation_id INT,donor_id INT,amount_donated DECIMAL(10,2)); INSERT INTO donations VALUES (1,1,500.00),(2,2,350.00),(3,1,200.00); CREATE TABLE donors (donor_id INT,name TEXT); INSERT INTO donors VALUES (1,'John Doe'),(2,'Jane Smith'); | SELECT donors.name, SUM(donations.amount_donated) AS total_donated FROM donors INNER JOIN donations ON donors.donor_id = donations.donor_id GROUP BY donors.donor_id ORDER BY total_donated DESC; |
What is the average number of satellites launched per year by Russia in the SpaceRadar table? | CREATE TABLE SpaceRadar (id INT,country VARCHAR(50),year INT,satellites INT); INSERT INTO SpaceRadar (id,country,year,satellites) VALUES (1,'USA',2000,10),(2,'China',2005,8),(3,'Russia',1995,12),(4,'Russia',1996,14); | SELECT AVG(satellites) AS avg_satellites_per_year FROM SpaceRadar WHERE country = 'Russia'; |
What is the average financial capability score for customers in each region? | CREATE TABLE financial_capability_data_2 (customer_id INT,score INT,region VARCHAR(20)); INSERT INTO financial_capability_data_2 (customer_id,score,region) VALUES (1,70,'Middle East'),(2,80,'Western Europe'),(3,60,'East Asia'),(4,90,'North America'),(5,75,'Oceania'),(6,65,'South America'),(7,85,'Eastern Europe'); CREAT... | SELECT region, avg_score FROM financial_capability_view_2; |
Find the top 2 regions with the highest total timber volume in 2020. | CREATE TABLE forests (id INT,region VARCHAR(255),volume FLOAT,year INT); INSERT INTO forests (id,region,volume,year) VALUES (1,'North',1200,2020),(2,'South',1500,2020),(3,'East',1800,2020),(4,'West',1000,2020); | SELECT region, SUM(volume) as total_volume FROM forests WHERE year = 2020 GROUP BY region ORDER BY total_volume DESC LIMIT 2; |
Which defense projects have a duration longer than the 75th percentile of all defense project durations? | CREATE TABLE Defense_Project_Timelines (project_id INT,project_name VARCHAR(50),start_date DATE,end_date DATE); INSERT INTO Defense_Project_Timelines (project_id,project_name,start_date,end_date) VALUES (1,'Project X','2019-01-01','2021-12-31'); INSERT INTO Defense_Project_Timelines (project_id,project_name,start_date,... | SELECT project_id, project_name, DATEDIFF('day', start_date, end_date) AS project_duration FROM Defense_Project_Timelines WHERE DATEDIFF('day', start_date, end_date) > PERCENTILE_CONT(0.75) WITHIN GROUP (ORDER BY DATEDIFF('day', start_date, end_date)); |
What is the total number of models, categorized by their type, that have been trained on the 'creative_ai' dataset? | CREATE TABLE creative_ai (model_id INT,model_name VARCHAR(50),model_type VARCHAR(20),dataset_name VARCHAR(50)); INSERT INTO creative_ai (model_id,model_name,model_type,dataset_name) VALUES (1,'GAN','generative','creative_ai'),(2,'VAE','generative','creative_ai'),(3,'CNN','discriminative','creative_ai'); | SELECT model_type, COUNT(*) as total FROM creative_ai WHERE dataset_name = 'creative_ai' GROUP BY model_type; |
Calculate the total R&D investment in biosensors for each country. | CREATE SCHEMA if not exists rnd;CREATE TABLE if not exists rnd.investment (id INT,technology VARCHAR(50),country VARCHAR(50),amount DECIMAL(10,2)); INSERT INTO rnd.investment (id,technology,country,amount) VALUES (1,'BioSensor1','USA',1000000.00),(2,'BioSensor2','USA',1500000.00),(3,'BioSensor3','Canada',500000.00),(4,... | SELECT country, SUM(amount) FROM rnd.investment GROUP BY country; |
What are the names of farmers who have irrigation systems? | CREATE TABLE Farmers (id INT PRIMARY KEY,name VARCHAR(50),age INT,location VARCHAR(50)); CREATE TABLE Irrigation (id INT PRIMARY KEY,system VARCHAR(50),cost FLOAT,installation_date DATE,farm_id INT,FOREIGN KEY (farm_id) REFERENCES Farmers(id)); INSERT INTO Farmers (id,name,age,location) VALUES (1,'Juan Garcia',45,'Texa... | SELECT Farmers.name FROM Farmers INNER JOIN Irrigation ON Farmers.id = Irrigation.farm_id; |
What is the total number of water wells dug in "Latin America" since 2018? | CREATE TABLE water_wells (id INT,project_id INT,location VARCHAR(255),construction_date DATE); INSERT INTO water_wells (id,project_id,location,construction_date) VALUES (1,4001,'Colombia','2019-05-01'); INSERT INTO water_wells (id,project_id,location,construction_date) VALUES (2,4002,'Peru','2018-02-01'); | SELECT COUNT(*) FROM water_wells WHERE location = 'Latin America' AND YEAR(construction_date) >= 2018; |
What is the number of research grants awarded to Latinx and Indigenous graduate students in the last 3 years? | CREATE TABLE research_grants (grant_id INT,student_id INT,grant_amount DECIMAL(10,2),grant_start_date DATE,grant_end_date DATE,student_community VARCHAR(255)); CREATE TABLE students (student_id INT,student_name VARCHAR(255),student_community VARCHAR(255)); | SELECT COUNT(*) FROM research_grants rg INNER JOIN students s ON rg.student_id = s.student_id WHERE rg.grant_start_date >= DATE_SUB(CURRENT_DATE, INTERVAL 3 YEAR) AND s.student_community IN ('Latinx', 'Indigenous'); |
Which suppliers have delivered more than 1000 units of a product in the last week? | CREATE TABLE Suppliers (SupplierID int,SupplierName varchar(50)); CREATE TABLE Products (ProductID int,ProductName varchar(50),SupplierID int); CREATE TABLE Orders (OrderID int,ProductID int,OrderDate date,Units int); INSERT INTO Suppliers VALUES (1,'SupplierA'),(2,'SupplierB'); INSERT INTO Products VALUES (1,'Organic ... | SELECT SupplierName, ProductName, SUM(Units) as TotalUnits FROM Orders o JOIN Products p ON o.ProductID = p.ProductID JOIN Suppliers sp ON p.SupplierID = sp.SupplierID WHERE OrderDate >= DATEADD(week, -1, GETDATE()) GROUP BY SupplierName, ProductName HAVING SUM(Units) > 1000; |
Find the number of HIV cases in Central America in 2018. | CREATE TABLE HIVData (Year INT,Region VARCHAR(20),Cases INT); INSERT INTO HIVData (Year,Region,Cases) VALUES (2016,'South America',5000); INSERT INTO HIVData (Year,Region,Cases) VALUES (2018,'Central America',3000); | SELECT SUM(Cases) FROM HIVData WHERE Region = 'Central America' AND Year = 2018; |
Show AI models with fairness scores below 80. | CREATE TABLE AIModels (model_id INT,model_name VARCHAR(50),fairness_score DECIMAL(3,2)); INSERT INTO AIModels (model_id,model_name,fairness_score) VALUES (1,'ModelA',85.00),(2,'ModelB',78.50),(3,'ModelC',92.75),(4,'ModelD',83.00); | SELECT model_name, fairness_score FROM AIModels WHERE fairness_score < 80; |
What is the average consumer rating for products that are both cruelty-free and vegan? | CREATE TABLE products (product_id INT,product_name TEXT,is_cruelty_free BOOLEAN,is_vegan BOOLEAN,consumer_rating DECIMAL(3,1)); | SELECT AVG(products.consumer_rating) as avg_rating FROM products WHERE products.is_cruelty_free = TRUE AND products.is_vegan = TRUE; |
What is the minimum production for wells in the 'amazon' region in 2023? | CREATE TABLE wells (well_id INT,well_name VARCHAR(50),region VARCHAR(20),production FLOAT,year INT); INSERT INTO wells (well_id,well_name,region,production,year) VALUES (1,'Well A','onshore',100.0,2023); INSERT INTO wells (well_id,well_name,region,production,year) VALUES (2,'Well B','offshore',200.0,2022); INSERT INTO ... | SELECT MIN(production) FROM wells WHERE region = 'amazon' AND year = 2023; |
Find the order details for orders placed on June 3, 2021? | CREATE TABLE orders (id INT PRIMARY KEY,product_id INT,quantity INT,order_date DATE,price DECIMAL(5,2)); INSERT INTO orders (id,product_id,quantity,order_date,price) VALUES (1,1,2,'2021-06-01',29.99),(2,3,1,'2021-06-03',14.99),(3,2,3,'2021-06-05',39.99); | SELECT * FROM orders WHERE order_date = '2021-06-03'; |
What is the total amount of funding for 'Dance' programs in 2022? | CREATE TABLE if not exists program (id INT,name VARCHAR(50),category VARCHAR(50)); CREATE TABLE if not exists funding (id INT,program_id INT,year INT,amount DECIMAL(10,2),source VARCHAR(50)); INSERT INTO program (id,name,category) VALUES (1,'Ballet','Dance'),(2,'Contemporary','Dance'),(3,'Hip Hop','Dance'); INSERT INTO... | SELECT SUM(amount) FROM funding f JOIN program p ON f.program_id = p.id WHERE p.category = 'Dance' AND f.year = 2022; |
Which animal species were involved in the highest number of conservation efforts? | CREATE TABLE conservation_efforts (effort_id INT,effort_name VARCHAR(50));CREATE TABLE conservation_projects (project_id INT,project_name VARCHAR(50));CREATE TABLE project_species (project_id INT,species_id INT); INSERT INTO conservation_efforts (effort_id,effort_name) VALUES (1,'Habitat Restoration'),(2,'Community Edu... | SELECT s.species_name, COUNT(ps.project_id) AS total_projects FROM animal_species s JOIN project_species ps ON s.species_id = ps.species_id GROUP BY s.species_name ORDER BY total_projects DESC; |
List the number of male and female graduate students in the English department | CREATE TABLE Department (id INT,name VARCHAR(255)); INSERT INTO Department (id,name) VALUES (1,'Computer Science'),(2,'Physics'),(3,'English'),(4,'History'); CREATE TABLE Student (id INT,department_id INT,gender VARCHAR(10)); INSERT INTO Student (id,department_id,gender) VALUES (1,1,'Female'),(2,2,'Male'),(3,1,'Non-bin... | SELECT s.gender, COUNT(*) as num_students FROM Student s JOIN Department d ON s.department_id = d.id WHERE d.name = 'English' GROUP BY s.gender; |
What is the distribution of financial capability scores for customers in New York? | CREATE TABLE customers (customer_id INT,name VARCHAR(255),state VARCHAR(255),financial_capability_score INT); | SELECT state, COUNT(*) as count, MIN(financial_capability_score) as min_score, AVG(financial_capability_score) as avg_score, MAX(financial_capability_score) as max_score FROM customers WHERE state = 'New York' GROUP BY state; |
What is the difference in revenue between the top and bottom album for each genre? | CREATE TABLE AlbumRevenue (AlbumID INT,GenreID INT,Revenue DECIMAL(10,2)); INSERT INTO AlbumRevenue (AlbumID,GenreID,Revenue) VALUES (1,1,150000.00),(2,1,125000.00),(3,2,150000.00),(4,2,100000.00),(5,3,100000.00); | SELECT GenreID, MAX(Revenue) - MIN(Revenue) AS RevenueDifference FROM AlbumRevenue GROUP BY GenreID; |
How many teachers have completed the 'Critical Pedagogy' course in 2023? | CREATE TABLE Completions (CompletionID INT,StudentID INT,CourseID INT,CompletionDate DATE); INSERT INTO Completions (CompletionID,StudentID,CourseID,CompletionDate) VALUES (1,1,1,'2023-01-01'),(2,2,2,'2023-01-02'),(3,3,1,'2023-01-03'),(4,5,2,'2023-01-04'); CREATE TABLE Courses (CourseID INT,CourseName VARCHAR(50),Cost ... | SELECT COUNT(*) FROM Completions INNER JOIN Courses ON Completions.CourseID = Courses.CourseID WHERE Courses.CourseName = 'Critical Pedagogy' AND CertificationYear = 2023 AND TargetAudience = 'Teachers'; |
How many tourists visited New Zealand from '2015-01-01' to '2016-12-31', broken down by quarter? | CREATE TABLE destinations (id INT,country TEXT); INSERT INTO destinations (id,country) VALUES (1,'New Zealand'); CREATE TABLE visits (id INT,visit_date DATE,destination_id INT); INSERT INTO visits (id,visit_date,destination_id) VALUES (1,'2015-01-01',1),(2,'2015-07-01',1),(3,'2016-01-01',1); | SELECT DATE_TRUNC('quarter', v.visit_date) AS quarter, COUNT(*) as num_visitors FROM visits v JOIN destinations d ON v.destination_id = d.id WHERE d.country = 'New Zealand' AND v.visit_date BETWEEN '2015-01-01' AND '2016-12-31' GROUP BY quarter; |
Which mental health campaigns were launched in a specific year and their respective budgets? | CREATE TABLE Campaigns (CampaignID INT,Year INT,Budget INT); CREATE TABLE MentalHealthCampaigns (CampaignID INT,CampaignName VARCHAR(50)); | SELECT Campaigns.Year, MentalHealthCampaigns.CampaignName, Campaigns.Budget FROM Campaigns INNER JOIN MentalHealthCampaigns ON Campaigns.CampaignID = MentalHealthCampaigns.CampaignID WHERE Campaigns.Year = 2022; |
Determine the top 2 spacecraft manufacturing countries with the highest average facility count, displaying country names and average facility counts. | CREATE TABLE Spacecraft_Manufacturing (Facility VARCHAR(50),Country VARCHAR(50)); INSERT INTO Spacecraft_Manufacturing (Facility,Country) VALUES ('Facility1','USA'),('Facility2','USA'),('Facility3','USA'),('Facility4','Germany'),('Facility5','France'),('Facility6','France'),('Facility7','Japan'),('Facility8','Japan'),(... | SELECT Country, AVG(1.0*COUNT(*)) as Avg_Facility_Count FROM Spacecraft_Manufacturing GROUP BY Country HAVING COUNT(*) >= ALL (SELECT COUNT(*) as Facility_Count FROM Spacecraft_Manufacturing GROUP BY Country ORDER BY Facility_Count DESC LIMIT 1 OFFSET 1) LIMIT 2; |
Find the chemical_id with the lowest production quantity | CREATE TABLE chemical_production (id INT PRIMARY KEY,chemical_id VARCHAR(10),quantity INT,country VARCHAR(50)); INSERT INTO chemical_production (id,chemical_id,quantity,country) VALUES (1,'XY987',700,'Brazil'),(2,'GH247',600,'India'),(3,'XY987',300,'Australia'),(4,'GH247',500,'India'),(5,'GH247',800,'Brazil'),(6,'XY987... | SELECT chemical_id FROM chemical_production GROUP BY chemical_id ORDER BY SUM(quantity) ASC LIMIT 1; |
Find the number of rural healthcare providers who are specialized in infectious diseases in South Africa and Kenya. | CREATE TABLE healthcare_specialties (name TEXT,location TEXT,specialty TEXT); INSERT INTO healthcare_specialties (name,location,specialty) VALUES ('Provider A','Rural South Africa','Infectious Diseases'),('Provider B','Rural Kenya','Cardiology'); | SELECT location, COUNT(*) as provider_count FROM healthcare_specialties WHERE location LIKE 'Rural%' AND specialty LIKE '%Infectious%' GROUP BY location; |
List all the unique well identifiers from the 'oil_production' table where the oil production for the year 2020 is greater than 10000 | CREATE TABLE oil_production (well_id INT,year INT,oil_volume FLOAT); | SELECT DISTINCT well_id FROM oil_production WHERE year = 2020 AND oil_volume > 10000; |
How many natural disasters were reported in the state of Florida in 2019? | CREATE TABLE natural_disasters (id INT,state VARCHAR(255),year INT,number_of_disasters INT); INSERT INTO natural_disasters (id,state,year,number_of_disasters) VALUES (1,'Florida',2019,50),(2,'California',2019,75); | SELECT SUM(number_of_disasters) FROM natural_disasters WHERE state = 'Florida' AND year = 2019; |
How many unique sustainable clothing items are available in sizes XS, S, and M? | CREATE TABLE sustainable_inventory (id INT,item_name VARCHAR(50),item_size VARCHAR(10),is_sustainable BOOLEAN); INSERT INTO sustainable_inventory (id,item_name,item_size,is_sustainable) VALUES (1,'T-Shirt','XS',TRUE); INSERT INTO sustainable_inventory (id,item_name,item_size,is_sustainable) VALUES (2,'Jeans','M',TRUE);... | SELECT COUNT(DISTINCT item_name) FROM sustainable_inventory WHERE item_size IN ('XS', 'S', 'M') AND is_sustainable = TRUE; |
What is the maximum number of matches played for each game? | CREATE TABLE GameMatches (GameID int,GameName varchar(50),MatchesPlayed int); INSERT INTO GameMatches (GameID,GameName,MatchesPlayed) VALUES (1,'GameA',6000),(2,'GameB',4000),(3,'GameC',3000); | SELECT GameName, MAX(MatchesPlayed) FROM GameMatches GROUP BY GameName; |
List the defense diplomacy events where a representative from the USA spoke about military cooperation with a country in the Asia-Pacific region? | CREATE TABLE Diplomacy (event VARCHAR(255),location VARCHAR(255),speaker VARCHAR(255),topic VARCHAR(255),date DATE); INSERT INTO Diplomacy (event,location,speaker,topic,date) VALUES ('Security Cooperation','Tokyo','John Smith','US-Japan Military Cooperation','2019-04-15'); | SELECT DISTINCT event, location, speaker, topic, date FROM Diplomacy WHERE speaker LIKE '%USA%' AND location LIKE '%Asia-Pacific%' AND topic LIKE '%military cooperation%'; |
Calculate the average playtime for each game | CREATE TABLE games (id INT PRIMARY KEY,player_id INT,game_name VARCHAR(100),last_played TIMESTAMP,playtime INTERVAL); INSERT INTO games VALUES (1,1,'GameA','2021-01-01 12:00:00','02:00:00'),(2,1,'GameB','2021-02-15 14:30:00','01:30:00'),(3,3,'GameA','2021-06-20 09:15:00','03:00:00'),(4,2,'GameA','2021-07-01 10:30:00','... | SELECT game_name, AVG(playtime) AS avg_playtime FROM games GROUP BY game_name; |
Get total mineral extraction in 2021 | CREATE TABLE extraction (id INT PRIMARY KEY,site_id INT,mineral VARCHAR(50),quantity INT,year INT); | SELECT SUM(quantity) FROM extraction WHERE year = 2021; |
How many games have been played each day in the last week? | CREATE TABLE GameSessions (GameSessionID INT,PlayerID INT,GameDate DATE); INSERT INTO GameSessions (GameSessionID,PlayerID,GameDate) VALUES (1,1,'2022-01-01'),(2,2,'2022-01-02'),(3,3,'2022-01-03'),(4,4,'2022-01-04'),(5,5,'2022-01-05'),(6,1,'2022-01-06'),(7,2,'2022-01-06'),(8,3,'2022-01-06'); | SELECT GameDate, COUNT(*) as NumGames FROM GameSessions WHERE GameDate >= CURDATE() - INTERVAL 7 DAY GROUP BY GameDate; |
What was the total cost savings from using renewable energy sources in the UK in Q3 2021? | CREATE TABLE EnergyCosts (energy_cost DECIMAL(10,2),renewable_energy BOOLEAN); | SELECT SUM(energy_cost) FROM EnergyCosts WHERE DATE_FORMAT(energy_cost_date, '%Y-%m-%d') BETWEEN '2021-07-01' AND '2021-09-30' AND renewable_energy = TRUE; |
What is the average number of autonomous driving research papers published in the UK? | CREATE TABLE Research_Papers (year INT,country VARCHAR(50),topic VARCHAR(50),quantity INT); INSERT INTO Research_Papers (year,country,topic,quantity) VALUES (2020,'UK','Autonomous Driving',150); INSERT INTO Research_Papers (year,country,topic,quantity) VALUES (2020,'UK','Autonomous Driving',160); | SELECT AVG(quantity) FROM Research_Papers WHERE year = 2020 AND country = 'UK' AND topic = 'Autonomous Driving'; |
What is the total number of volunteer hours for the sports program? | CREATE TABLE Volunteers (id INT,name VARCHAR(255),contact_info VARCHAR(255)); CREATE TABLE Volunteer_Hours (id INT,volunteer_id INT,program VARCHAR(255),hours INT); INSERT INTO Volunteers (id,name,contact_info) VALUES (1,'Alice Johnson','alicejohnson@example.com'),(2,'Brian Lee','brianlee@example.com'); INSERT INTO Vol... | SELECT SUM(hours) FROM Volunteer_Hours WHERE program = 'Sports'; |
What is the total landfill capacity for European countries? | CREATE TABLE LandfillCapacities (country VARCHAR(50),capacity INT); INSERT INTO LandfillCapacities (country,capacity) VALUES ('Germany',120000),('France',90000),('UK',80000); | SELECT SUM(capacity) FROM LandfillCapacities WHERE country IN ('Germany', 'France', 'UK', 'Italy', 'Spain'); |
Which indigenous communities have the highest number of reported wildlife sightings? | CREATE TABLE wildlife_sightings (id INT,community VARCHAR(255),num_sightings INT); CREATE TABLE indigenous_communities (id INT,name VARCHAR(255),location VARCHAR(255)); | SELECT i.name, w.num_sightings FROM indigenous_communities i JOIN wildlife_sightings w ON i.location = w.community ORDER BY w.num_sightings DESC; |
What is the minimum ticket price for concerts in Brazil? | CREATE TABLE Concerts (id INT,artist VARCHAR(100),location VARCHAR(100),price DECIMAL(5,2)); INSERT INTO Concerts (id,artist,location,price) VALUES (1,'Shakira','Brazil',75.00),(2,'Pitbull','Brazil',85.00); | SELECT MIN(price) FROM Concerts WHERE location = 'Brazil' |
Find the number of safety incidents for each vessel operating in the Gulf of Mexico in the last 3 years. | CREATE TABLE Vessels (id INT,name VARCHAR(50),country VARCHAR(50)); CREATE TABLE SafetyIncidents (id INT,vessel_id INT,incident_type VARCHAR(50),time TIMESTAMP,latitude DECIMAL(9,6),longitude DECIMAL(9,6)); | SELECT V.name, COUNT(SI.id) FROM Vessels V JOIN SafetyIncidents SI ON V.id = SI.vessel_id WHERE SI.time > NOW() - INTERVAL '3 years' AND SI.latitude BETWEEN 15 AND 30 AND SI.longitude BETWEEN -100 AND -85 GROUP BY V.name; |
What was the total cost of Spacecraft X manufacturing? | CREATE TABLE SpacecraftManufacturing(ID INT,SpacecraftName VARCHAR(50),ManufacturingCost FLOAT); | SELECT ManufacturingCost FROM SpacecraftManufacturing WHERE SpacecraftName = 'Spacecraft X'; |
What is the average age of patients with a mental health condition who have been treated in the past year in New York? | CREATE TABLE PatientTreatmentInfo (PatientID INT,Age INT,Condition VARCHAR(50),TreatmentDate DATE,City VARCHAR(50),State VARCHAR(20)); | SELECT AVG(Age) FROM PatientTreatmentInfo WHERE TreatmentDate >= DATE_SUB(CURDATE(), INTERVAL 1 YEAR) AND State = 'New York'; |
Update the waste generation for plastic in the city of Chicago to 2000 grams in the second quarter of 2021. | CREATE TABLE waste_generation (city VARCHAR(255),quarter INT,material_type VARCHAR(255),generation_grams INT); INSERT INTO waste_generation (city,quarter,material_type,generation_grams) VALUES ('Chicago',2,'Plastic',1800); | UPDATE waste_generation SET generation_grams = 2000 WHERE city = 'Chicago' AND quarter = 2 AND material_type = 'Plastic'; |
What is the minimum and maximum dissolved oxygen levels (in mg/L) for aquaculture farms in Brazil, for each year between 2017 and 2022? | CREATE TABLE DissolvedOxygenData (id INT,country VARCHAR(50),year INT,min_oxygen FLOAT,max_oxygen FLOAT); INSERT INTO DissolvedOxygenData (id,country,year,min_oxygen,max_oxygen) VALUES (1,'Brazil',2017,6.5,8.2),(2,'Brazil',2018,6.3,8.4),(3,'Brazil',2019,6.8,8.1),(4,'Brazil',2020,6.6,8.3),(5,'Brazil',2021,6.7,8.2); | SELECT year, MIN(min_oxygen), MAX(max_oxygen) FROM DissolvedOxygenData WHERE country = 'Brazil' GROUP BY year; |
What is the number of patients who received group therapy for depression in clinics located in Texas? | CREATE TABLE clinics (clinic_id INT,clinic_name VARCHAR(50),city VARCHAR(50),state VARCHAR(50)); INSERT INTO clinics (clinic_id,clinic_name,city,state) VALUES (1,'ClinicC','Houston','TX'),(2,'ClinicD','Austin','TX'); CREATE TABLE patients (patient_id INT,patient_name VARCHAR(50),age INT,clinic_id INT,condition_id INT);... | SELECT COUNT(*) FROM patients p JOIN clinics c ON p.clinic_id = c.clinic_id JOIN therapies t ON p.patient_id = t.patient_id JOIN conditions cond ON p.condition_id = cond.condition_id WHERE c.state = 'TX' AND cond.condition_name = 'Depression' AND t.therapy_type = 'Group Therapy'; |
Show military equipment maintenance requests categorized by priority level, for equipment types starting with the letter 'C', in the last 3 months. | CREATE TABLE equipment_maintenance (request_id INT,priority INT,equipment_type VARCHAR(50),request_date DATE); INSERT INTO equipment_maintenance (request_id,priority,equipment_type,request_date) VALUES (1,4,'M1 Abrams','2022-01-01'),(2,5,'C-130 Hercules','2022-02-15'),(3,3,'CH-47 Chinook','2022-03-05'); | SELECT priority, equipment_type, COUNT(*) as num_requests FROM equipment_maintenance WHERE equipment_type LIKE 'C%' AND request_date >= DATE_SUB(CURRENT_DATE, INTERVAL 3 MONTH) GROUP BY priority, equipment_type; |
How many community development initiatives in the 'community_development' table, started in the second half of 2021? | CREATE TABLE community_development (id INT,initiative_name TEXT,location TEXT,start_date DATE); INSERT INTO community_development (id,initiative_name,location,start_date) VALUES (1,'Youth Center','North','2021-05-01'),(2,'Community Garden','South','2020-01-15'),(3,'Senior Center','West','2022-06-15'),(4,'Makerspace','E... | SELECT COUNT(*) FROM community_development WHERE start_date >= '2021-07-01' AND start_date < '2022-01-01'; |
What is the engagement percentage of virtual tours for hotels in 'Tokyo'? | CREATE TABLE VirtualTours (hotel_id INT,city TEXT,engagement_percentage FLOAT); INSERT INTO VirtualTours (hotel_id,city,engagement_percentage) VALUES (1,'Tokyo',25),(2,'Tokyo',30),(3,'Tokyo',20); | SELECT AVG(engagement_percentage) FROM VirtualTours WHERE city = 'Tokyo'; |
What are the names of all the departments that have no recorded vulnerabilities? | CREATE TABLE department (id INT,name VARCHAR(255)); CREATE TABLE department_vulnerabilities (department_id INT,vulnerability_count INT); INSERT INTO department (id,name) VALUES (1,'Finance'),(2,'IT'); INSERT INTO department_vulnerabilities (department_id,vulnerability_count) VALUES (1,2),(2,0); | SELECT name FROM department WHERE id NOT IN (SELECT department_id FROM department_vulnerabilities WHERE vulnerability_count > 0); |
What is the minimum production quantity (in metric tons) for gadolinium, promethium, and ytterbium in the production_data table? | CREATE TABLE production_data (element VARCHAR(20),year INT,quantity FLOAT); INSERT INTO production_data (element,year,quantity) VALUES ('gadolinium',2015,150),('gadolinium',2016,170),('gadolinium',2017,190),('gadolinium',2018,210),('gadolinium',2019,230),('gadolinium',2020,250),('promethium',2015,50),('promethium',2016... | SELECT MIN(quantity) FROM production_data WHERE element IN ('gadolinium', 'promethium', 'ytterbium'); |
Which countries have provided the most military and humanitarian aid in the last 5 years? | CREATE TABLE Military_Aid (id INT,country VARCHAR(50),year INT,military_aid INT); CREATE TABLE Humanitarian_Aid (id INT,country VARCHAR(50),year INT,humanitarian_aid INT); | SELECT m.country, SUM(m.military_aid + h.humanitarian_aid) as total_aid FROM Military_Aid m JOIN Humanitarian_Aid h ON m.country = h.country WHERE m.year BETWEEN (YEAR(CURRENT_DATE) - 5) AND YEAR(CURRENT_DATE) GROUP BY m.country; |
Find the number of students who graduated per year, partitioned by department, in ascending order of graduation year. | CREATE TABLE students (student_id INT,dept_id INT,year INT,graduated BOOLEAN);CREATE TABLE departments (dept_id INT,dept_name VARCHAR(255)); | SELECT dept_name, year, COUNT(student_id) AS num_graduates FROM students s JOIN departments d ON s.dept_id = d.dept_id WHERE graduated = TRUE GROUP BY dept_name, year ORDER BY year ASC; |
Delete all movies with a duration of over 180 minutes directed by men. | CREATE TABLE movies (id INT PRIMARY KEY,title TEXT,duration INT,director TEXT); INSERT INTO movies (id,title,duration,director) VALUES (1,'Movie1',120,'John Doe'),(2,'Movie2',150,'Jane Doe'),(3,'Movie3',240,'Alex Smith'); | DELETE FROM movies WHERE director IN ('John Doe', 'Alex Smith') AND duration > 180; |
What is the maximum budget allocated for defense diplomacy by African Union countries in 2022? | CREATE SCHEMA defense_diplomacy;CREATE TABLE african_union_budget (country VARCHAR(50),budget INT,year INT);INSERT INTO defense_diplomacy.african_union_budget (country,budget,year) VALUES ('Nigeria',5000000,2022),('South Africa',6000000,2022),('Egypt',7000000,2022),('Algeria',4000000,2022),('Morocco',8000000,2022); | SELECT MAX(budget) FROM defense_diplomacy.african_union_budget WHERE year = 2022; |
How many vessels were registered in the Atlantic Ocean in the year 2019? | CREATE TABLE vessels (region TEXT,year INT,registered BOOLEAN); INSERT INTO vessels (region,year,registered) VALUES ('Atlantic Ocean',2019,TRUE),('Atlantic Ocean',2020,TRUE); | SELECT COUNT(*) FROM vessels WHERE region = 'Atlantic Ocean' AND year = 2019 AND registered = TRUE; |
What is the distribution of user activity by hour in the 'activity' schema? | CREATE SCHEMA activity;CREATE TABLE activity.user_activity (user_id INT,activity_hour TIME); | SELECT activity_hour, COUNT(user_id) FROM activity.user_activity GROUP BY activity_hour; |
What is the maximum data usage in gigabytes per month for customers in the state of California? | CREATE TABLE customers_usa (customer_id INT,name VARCHAR(255),state VARCHAR(255)); INSERT INTO customers_usa (customer_id,name,state) VALUES (1,'John Doe','California'),(2,'Jane Smith','New York'); CREATE TABLE data_usage_usa (customer_id INT,monthly_data_usage DECIMAL(10,2)); INSERT INTO data_usage_usa (customer_id,mo... | SELECT MAX(monthly_data_usage) FROM data_usage_usa INNER JOIN customers_usa ON data_usage_usa.customer_id = customers_usa.customer_id WHERE state = 'California'; |
What is the total number of articles published in the "articles" table for the 'investigative' category? | CREATE TABLE articles (id INT PRIMARY KEY,title TEXT,category TEXT,publication_date DATE,author_id INT); | SELECT COUNT(*) FROM articles WHERE category = 'investigative'; |
Identify the top 5 emergency response times for 'Medical' incidents in 'West' region, for the last 3 years, from 'EmergencyResponse' table. | CREATE TABLE EmergencyResponse (id INT,incidentType VARCHAR(20),region VARCHAR(10),responseTime INT,year INT); | SELECT incidentType, region, MIN(responseTime) FROM EmergencyResponse WHERE incidentType = 'Medical' AND region = 'West' AND year BETWEEN (YEAR(CURRENT_DATE) - 3) AND YEAR(CURRENT_DATE) GROUP BY incidentType, region ORDER BY responseTime LIMIT 5; |
Insert records for 3 new subsidies into the 'housing_subsidies' table. | CREATE TABLE housing_subsidies (id INT,policy_name TEXT,start_date DATE,end_date DATE); | INSERT INTO housing_subsidies (id, policy_name, start_date, end_date) VALUES (1, 'Policy 1', '2022-01-01', '2023-12-31'), (2, 'Policy 2', '2022-01-01', '2025-12-31'), (3, 'Policy 3', '2024-01-01', '2026-12-31'); |
Monthly active users of streaming service in Germany? | CREATE TABLE Streaming_Users (user_id INT,country VARCHAR(50),subscription_date DATE,cancelled_date DATE); | SELECT COUNT(DISTINCT user_id) as monthly_active_users FROM Streaming_Users WHERE country = 'Germany' AND cancelled_date > DATE_ADD(subscription_date, INTERVAL 30 DAY); |
Find the number of peacekeeping operations where the Marine Corps and Army participated together from 2015 to 2017. | CREATE TABLE peacekeeping (id INT,operation VARCHAR(50),service1 VARCHAR(10),service2 VARCHAR(10),year INT); INSERT INTO peacekeeping (id,operation,service1,service2,year) VALUES (1,'Op1','Marine Corps','Army',2015); INSERT INTO peacekeeping (id,operation,service1,service2,year) VALUES (2,'Op2','Army','Marine Corps',20... | SELECT COUNT(*) FROM peacekeeping WHERE (service1 = 'Marine Corps' AND service2 = 'Army') OR (service1 = 'Army' AND service2 = 'Marine Corps') AND year BETWEEN 2015 AND 2017; |
How many donors have made a donation to a specific campaign? | CREATE TABLE campaigns (id INT,name TEXT); CREATE TABLE donations (id INT,donor_id INT,campaign_id INT,donation_amount DECIMAL(10,2)); INSERT INTO campaigns (id,name) VALUES (1,'Campaign A'),(2,'Campaign B'); INSERT INTO donations (id,donor_id,campaign_id,donation_amount) VALUES (1,1,1,50.00),(2,2,1,100.00); | SELECT COUNT(DISTINCT donor_id) FROM donations JOIN campaigns ON donations.campaign_id = campaigns.id WHERE campaigns.name = 'Campaign A'; |
What is the total number of funding records for companies with male founders in the EdTech industry? | CREATE TABLE Companies (id INT,name VARCHAR(50),industry VARCHAR(50),country VARCHAR(50),founding_year INT,founder_gender VARCHAR(10)); CREATE TABLE Funding (id INT,company_name VARCHAR(50),funding_amount INT); INSERT INTO Companies (id,name,industry,country,founding_year,founder_gender) VALUES (1,'EduMale','EdTech','U... | SELECT COUNT(*) as funding_records_count FROM Funding INNER JOIN Companies ON Funding.company_name = Companies.name WHERE Companies.industry = 'EdTech' AND Companies.founder_gender = 'Male'; |
What is the average weight of packages shipped to Texas from China in the last month? | CREATE TABLE shipments (id INT,source_country VARCHAR(20),destination_state VARCHAR(20),weight FLOAT,shipping_date DATE); INSERT INTO shipments (id,source_country,destination_state,weight,shipping_date) VALUES (1,'China','Texas',25.3,'2022-01-03'),(2,'China','Texas',34.8,'2022-01-07'); | SELECT AVG(weight) FROM shipments WHERE source_country = 'China' AND destination_state = 'Texas' AND shipping_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 MONTH); |
Delete records of users who have unsubscribed from the newsletter in the last month from the users table | CREATE TABLE users (id INT,name VARCHAR(50),email VARCHAR(50),subscribed_to_newsletter BOOLEAN); | DELETE FROM users WHERE subscribed_to_newsletter = false AND signup_date < DATE_SUB(CURDATE(), INTERVAL 1 MONTH); |
What is the total revenue of organic products sold in the USA in Q1 2022? | CREATE TABLE OrganicProducts (productID int,productName varchar(255),price decimal(10,2),country varchar(255),date datetime); INSERT INTO OrganicProducts VALUES (1,'Apples',1.99,'USA','2022-01-01'); CREATE TABLE Sales (saleID int,productID int,quantity int,date datetime); INSERT INTO Sales VALUES (1,1,50,'2022-01-02'); | SELECT SUM(Op.price * S.quantity) as total_revenue FROM OrganicProducts Op INNER JOIN Sales S ON Op.productID = S.productID WHERE Op.country = 'USA' AND YEAR(S.date) = 2022 AND QUARTER(S.date) = 1; |
What is the distribution of customer sizes in France? | CREATE TABLE customer_sizes (customer_id INT,customer_size TEXT,customer_country TEXT); | SELECT customer_size, COUNT(*) AS customer_count FROM customer_sizes WHERE customer_country = 'France' GROUP BY customer_size |
What is the distribution of grants by size? | CREATE TABLE Grants (GrantID int,GrantSize decimal(10,2)); INSERT INTO Grants (GrantID,GrantSize) VALUES (1,5000.00),(2,10000.00),(3,15000.00); | SELECT GrantSize, COUNT(GrantID) AS GrantCount FROM Grants GROUP BY GrantSize; |
What is the average CO2 emission for each mode of transportation in the EU? | CREATE TABLE co2_emissions (id INT,transportation_mode VARCHAR(255),co2_emission_g_km INT); INSERT INTO co2_emissions (id,transportation_mode,co2_emission_g_km) VALUES (1,'Car',120),(2,'Bus',80),(3,'Train',40),(4,'Plane',150),(5,'Bicycle',0),(6,'Foot',0); | SELECT transportation_mode, AVG(co2_emission_g_km) as avg_co2_emission FROM co2_emissions GROUP BY transportation_mode; |
How many volunteers from Brazil participated in each program, and what was the total number of volunteer hours for each program? | CREATE TABLE Volunteers (VolunteerID INT,VolunteerName TEXT,Country TEXT); INSERT INTO Volunteers (VolunteerID,VolunteerName,Country) VALUES (1,'Marcos Santos','Brazil'),(2,'Sophie Dupont','Canada'); CREATE TABLE VolunteerPrograms (ProgramID INT,ProgramName TEXT); INSERT INTO VolunteerPrograms (ProgramID,ProgramName) V... | SELECT VolunteerPrograms.ProgramName, COUNT(DISTINCT Volunteers.VolunteerID) AS VolunteerCount, SUM(VolunteerAssignments.Hours) AS TotalHours FROM Volunteers INNER JOIN VolunteerAssignments ON Volunteers.VolunteerID = VolunteerAssignments.VolunteerID INNER JOIN VolunteerPrograms ON VolunteerAssignments.ProgramID = Volu... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.