instruction
stringlengths 0
1.06k
| input
stringlengths 11
5.3k
| response
stringlengths 2
4.44k
|
---|---|---|
What is the total billing amount for each legal precedent?
|
CREATE TABLE LegalPrecedents (PrecedentID INT,PrecedentName VARCHAR(50),BillingAmount DECIMAL(10,2)); INSERT INTO LegalPrecedents (PrecedentID,PrecedentName,BillingAmount) VALUES (1,'Precedent A',15000.00),(2,'Precedent B',20000.00),(3,'Precedent C',12000.00),(4,'Precedent D',18000.00),(5,'Precedent E',22000.00);
|
SELECT PrecedentName, SUM(BillingAmount) AS TotalBillingAmount FROM LegalPrecedents GROUP BY PrecedentName;
|
What is the average salary of software engineers in the "tech_company" database, excluding those who earn more than $200,000?
|
CREATE TABLE employees (id INT,name VARCHAR(50),department VARCHAR(50),salary DECIMAL(10,2)); INSERT INTO employees (id,name,department,salary) VALUES (1,'John Doe','Software Engineer',150000.00),(2,'Jane Smith','Software Engineer',220000.00);
|
SELECT AVG(salary) FROM employees WHERE department = 'Software Engineer' AND salary < 200000.00;
|
What is the average project cost per state?
|
CREATE TABLE Projects (ProjectID int,State varchar(25),Cost decimal(10,2)); INSERT INTO Projects (ProjectID,State,Cost) VALUES (1,'NY',150000.00),(2,'CA',200000.00),(3,'TX',120000.00);
|
SELECT State, AVG(Cost) AS AvgCostPerState FROM Projects GROUP BY State;
|
How many space missions were led by female astronauts from the US?
|
CREATE TABLE Missions (name VARCHAR(30),astronaut_name VARCHAR(30),astronaut_gender VARCHAR(10),astronaut_nationality VARCHAR(20)); INSERT INTO Missions (name,astronaut_name,astronaut_gender,astronaut_nationality) VALUES ('Mars Exploration','Sally Ride','Female','United States');
|
SELECT COUNT(*) FROM Missions WHERE astronaut_gender = 'Female' AND astronaut_nationality = 'United States';
|
What is the minimum horsepower of hybrid vehicles in the 'GreenCar' database produced after 2015?
|
CREATE TABLE HybridVehicles (Id INT,Make VARCHAR(50),Model VARCHAR(50),Year INT,Horsepower INT);
|
SELECT MIN(Horsepower) FROM HybridVehicles WHERE Year > 2015;
|
Identify the number of farms in each continent practicing agroecology and the average farm size.
|
CREATE TABLE farms (id INT,name TEXT,continent TEXT,size INT,practice TEXT); INSERT INTO farms (id,name,continent,size,practice) VALUES (1,'Smith Farm','South America',10,'Agroecology'); INSERT INTO farms (id,name,continent,size,practice) VALUES (2,'Jones Farm','North America',15,'Conventional'); INSERT INTO farms (id,name,continent,size,practice) VALUES (3,'Brown Farm','South America',20,'Agroecology');
|
SELECT f.continent, COUNT(f.id), AVG(f.size) FROM farms f WHERE f.practice = 'Agroecology' GROUP BY f.continent;
|
What is the total number of volunteers and their average hours served per region this year?
|
CREATE TABLE volunteer_hours (id INT,region VARCHAR(255),hours_served INT); INSERT INTO volunteer_hours (id,region,hours_served) VALUES (1,'Northeast',500),(2,'Southeast',700),(3,'Northwest',600),(4,'Southwest',800),(5,'Northeast',400),(6,'Southeast',900);
|
SELECT region, COUNT(*) AS num_volunteers, AVG(hours_served) AS avg_hours_served FROM volunteer_hours WHERE activity_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR) GROUP BY region;
|
How many publications did each faculty member in the College of Arts and Humanities publish in 2019, ordered alphabetically by faculty member?
|
CREATE TABLE College_of_Arts_and_Humanities (faculty_member VARCHAR(50),publications INT,publication_year INT); INSERT INTO College_of_Arts_and_Humanities (faculty_member,publications,publication_year) VALUES ('Taylor,Emily',3,2019),('Miller,James',2,2019),('Thomas,Laura',5,2019),('Wilson,Susan',4,2019),('Anderson,Michael',1,2019),('Garcia,Maria',6,2019);
|
SELECT faculty_member, publications FROM College_of_Arts_and_Humanities WHERE publication_year = 2019 ORDER BY faculty_member;
|
What is the minimum area of a green building in the 'smart_cities' schema?
|
CREATE TABLE green_buildings (id INT,area FLOAT,city VARCHAR(20),state VARCHAR(20)); INSERT INTO green_buildings (id,area,city,state) VALUES (1,5000.5,'San Francisco','CA'),(2,7000.3,'Los Angeles','CA');
|
SELECT MIN(area) FROM green_buildings;
|
What is the number of policies sold by each agent?
|
CREATE TABLE Agents (AgentID INT,AgentName VARCHAR(255),PolicyID INT); INSERT INTO Agents VALUES (1,'John Smith',1),(2,'Jane Doe',2),(1,'John Smith',3),(2,'Jane Doe',4),(3,'Mike Johnson',5),(3,'Mike Johnson',6); CREATE TABLE Policies (PolicyID INT); INSERT INTO Policies VALUES (1),(2),(3),(4),(5),(6);
|
SELECT a.AgentName, COUNT(p.PolicyID) AS PoliciesSold FROM Agents a JOIN Policies p ON a.PolicyID = p.PolicyID GROUP BY a.AgentName;
|
List the top 5 vendors with the highest defense contract awards in 2022
|
CREATE TABLE defense_contracts (contract_id INT,vendor VARCHAR(255),contract_value DECIMAL(10,2),contract_date DATE);
|
SELECT vendor, SUM(contract_value) as total_contract_value FROM defense_contracts WHERE YEAR(contract_date) = 2022 GROUP BY vendor ORDER BY total_contract_value DESC LIMIT 5;
|
What is the total revenue of organic cotton products?
|
CREATE TABLE OrganicCottonProducts (productID INT,revenue FLOAT); INSERT INTO OrganicCottonProducts (productID,revenue) VALUES (1,100.00),(2,150.00);
|
SELECT SUM(revenue) FROM OrganicCottonProducts;
|
Update the 'description' of the record with an id of 3 in the 'digital_divide' table to 'Limited digital literacy and skills among older adults'
|
CREATE TABLE digital_divide (id INT PRIMARY KEY,problem VARCHAR(50),description TEXT); INSERT INTO digital_divide (id,problem,description) VALUES (1,'Lack of internet access','High-speed internet unavailable in many rural areas'),(2,'Expensive devices','Cost of devices is a barrier for low-income households'),(3,'Literacy and skills','Limited computer literacy and digital skills');
|
UPDATE digital_divide SET description = 'Limited digital literacy and skills among older adults' WHERE id = 3;
|
What was the average viewership for TV shows, by day of the week and country?
|
CREATE TABLE InternationalTVShows (title VARCHAR(255),country VARCHAR(255),viewership FLOAT,air_date DATE); INSERT INTO InternationalTVShows (title,country,viewership,air_date) VALUES ('TVShowX','USA',25000,'2022-01-01'),('TVShowY','Canada',30000,'2022-01-02'),('TVShowZ','Mexico',20000,'2022-01-03');
|
SELECT country, DATE_PART('dow', air_date) as day_of_week, AVG(viewership) FROM InternationalTVShows GROUP BY country, day_of_week;
|
Which countries have experienced a decrease in peacekeeping operation casualties from 2020 to 2021?
|
CREATE TABLE PeacekeepingCasualties (Country VARCHAR(50),Year INT,Casualties INT); INSERT INTO PeacekeepingCasualties (Country,Year,Casualties) VALUES ('USA',2020,50),('USA',2021,40),('China',2020,30),('China',2021,35),('France',2020,20),('France',2021,18);
|
SELECT Country FROM (SELECT Country, Year, Casualties, LAG(Casualties) OVER (PARTITION BY Country ORDER BY Year) AS PreviousYearCasualties FROM PeacekeepingCasualties) AS Subquery WHERE Subquery.Country = Subquery.Country AND Subquery.Casualties < Subquery.PreviousYearCasualties;
|
What is the minimum response time for each type of emergency incident and crime report?
|
CREATE TABLE emergency_incidents (id INT,incident_type VARCHAR(255),response_time INT); INSERT INTO emergency_incidents (id,incident_type,response_time) VALUES (1,'Medical Emergency',10),(2,'Fire',8),(3,'Traffic Accident',12); CREATE TABLE crime_reports (id INT,report_type VARCHAR(255),response_time INT); INSERT INTO crime_reports (id,report_type,response_time) VALUES (1,'Theft',20),(2,'Vandalism',15),(3,'Assault',18);
|
SELECT incident_type, MIN(response_time) as min_response_time FROM emergency_incidents GROUP BY incident_type UNION SELECT report_type, MIN(response_time) as min_response_time FROM crime_reports GROUP BY report_type;
|
Show the total budget allocated for each category.
|
CREATE TABLE budget (category TEXT,amount INTEGER); INSERT INTO budget (category,amount) VALUES ('national security',15000),('intelligence operations',10000),('cybersecurity',12000);
|
SELECT category, SUM(amount) FROM budget GROUP BY category
|
How many clinical trials were approved for each country in 2020?
|
CREATE TABLE clinical_trials (trial_id INT,country VARCHAR(255),approval_date DATE);
|
SELECT country, COUNT(*) as num_trials FROM clinical_trials WHERE YEAR(approval_date) = 2020 GROUP BY country;
|
List all legal organizations that provide services related to access to justice
|
CREATE TABLE legal_organizations (org_id INT,org_name VARCHAR(255),PRIMARY KEY (org_id)); INSERT INTO legal_organizations (org_id,org_name) VALUES (1,'Access Now'),(2,'Legal Aid Society'),(3,'Justice for Migrants');
|
SELECT org_name FROM legal_organizations WHERE org_name LIKE '%access to justice%';
|
What is the distribution of token holdings for the smart contract with the address '0xAbCdEfGhIjKlMnOpQrStUvWxYz01' on the Ethereum blockchain?
|
CREATE TABLE ether_tokens (token_id INT,contract_address VARCHAR(42),holder_address VARCHAR(42),balance INT);
|
SELECT holder_address, SUM(balance) FROM ether_tokens WHERE contract_address = '0xAbCdEfGhIjKlMnOpQrStUvWxYz01' GROUP BY holder_address ORDER BY SUM(balance) DESC;
|
Find the total number of artifacts excavated from each country.
|
CREATE TABLE excavation_sites (id INT,name VARCHAR(255),country VARCHAR(255)); CREATE TABLE artifacts (id INT,excavation_site_id INT,year INT,type VARCHAR(255));
|
SELECT country, COUNT(a.id) as artifact_count FROM excavation_sites es JOIN artifacts a ON es.id = a.excavation_site_id GROUP BY country;
|
Which dams have a higher hazard potential rating than the median rating in the dams inventory?
|
CREATE TABLE dams_inventory (id INT,dam_name VARCHAR(255),hazard_potential_rating INT); INSERT INTO dams_inventory (id,dam_name,hazard_potential_rating) VALUES (1,'Smith Dam',12),(2,'Johnson Dam',15),(3,'Williams Dam',8),(4,'Brown Dam',18),(5,'Davis Dam',9);
|
SELECT dam_name, hazard_potential_rating FROM dams_inventory WHERE hazard_potential_rating > (SELECT AVG(hazard_potential_rating) FROM dams_inventory) ORDER BY hazard_potential_rating DESC;
|
Get player's VR sessions and total playtime
|
CREATE TABLE players (player_id INT,name VARCHAR(100)); CREATE TABLE vr_sessions (session_id INT,player_id INT,duration INT);
|
SELECT p.name, COUNT(s.session_id) AS sessions_count, SUM(s.duration) AS total_playtime_seconds FROM players p JOIN vr_sessions s ON p.player_id = s.player_id GROUP BY p.name;
|
What is the total number of passengers that used public transportation in Chicago during Q1 of 2022?
|
CREATE TABLE public_transportation(transport_id INT,passengers INT,transport_type VARCHAR(50),usage_date DATE,city VARCHAR(50)); CREATE VIEW q1_2022 AS SELECT * FROM public_transportation WHERE usage_date BETWEEN '2022-01-01' AND '2022-03-31';
|
SELECT SUM(passengers) FROM q1_2022 WHERE city = 'Chicago';
|
Which threats have been reported most frequently in each region over the past year?
|
CREATE TABLE IF NOT EXISTS threat_intelligence (threat_id INT,threat_type VARCHAR(50),reported_date DATE,severity INT,target_region VARCHAR(50));
|
SELECT target_region, threat_type, COUNT(*) as num_reports, RANK() OVER (PARTITION BY target_region ORDER BY COUNT(*) DESC) as rank FROM threat_intelligence WHERE reported_date >= '2021-01-01' GROUP BY target_region, threat_type;
|
Which fields have had a decrease in soil moisture in the past week?
|
CREATE TABLE field (id INT,name VARCHAR(20)); CREATE TABLE soil_moisture (id INT,field_id INT,value INT,timestamp TIMESTAMP);
|
SELECT f.name FROM field f INNER JOIN soil_moisture sm1 ON f.id = sm1.field_id INNER JOIN soil_moisture sm2 ON f.id = sm2.field_id AND sm2.timestamp = sm1.timestamp - INTERVAL '1 day' WHERE sm1.value > sm2.value;
|
Find the average rating and total reviews for each game in the 'Games' table
|
CREATE TABLE Games (game_id INT,game_name VARCHAR(100),rating DECIMAL(3,2),reviews INT); INSERT INTO Games (game_id,game_name,rating,reviews) VALUES (1,'GameA',4.5,1500),(2,'GameB',3.8,850),(3,'GameC',4.2,1200);
|
SELECT game_name, AVG(rating) AS avg_rating, SUM(reviews) AS total_reviews FROM Games GROUP BY game_name;
|
How many size 14 garments were sold in Canada in the last month?
|
CREATE TABLE sales (id INT,garment_id INT,size INT,sale_date DATE,country VARCHAR(50)); INSERT INTO sales (id,garment_id,size,sale_date,country) VALUES (1,1007,14,'2021-04-15','Canada');
|
SELECT COUNT(*) FROM sales WHERE size = 14 AND country = 'Canada' AND sale_date >= DATEADD(month, -1, GETDATE());
|
Identify the top 5 best-selling skincare products in the USA?
|
CREATE TABLE Skincare_Sales_USA(Product_Name VARCHAR(30),Product_Type VARCHAR(20),Sales DECIMAL(10,2)); INSERT INTO Skincare_Sales_USA(Product_Name,Product_Type,Sales) VALUES('Product A','Moisturizer',2000),('Product B','Cleanser',1500),('Product C','Toner',1200),('Product D','Exfoliant',1800),('Product E','Serum',2500),('Product F','Moisturizer',3000),('Product G','Cleanser',2000),('Product H','Toner',1700),('Product I','Exfoliant',1600),('Product J','Serum',2200);
|
SELECT Product_Name, Sales FROM Skincare_Sales_USA WHERE Country = 'USA' ORDER BY Sales DESC LIMIT 5;
|
Delete all ingredients associated with the food product with id 1
|
CREATE TABLE ingredients (id INT PRIMARY KEY,product_id INT,name TEXT,quantity REAL);
|
DELETE FROM ingredients WHERE product_id = 1;
|
Find all marine species that have been observed in either the Arctic or the Atlantic regions
|
CREATE TABLE marine_species (name TEXT,region TEXT); INSERT INTO marine_species (name,region) VALUES ('Species1','Arctic'); INSERT INTO marine_species (name,region) VALUES ('Species2','Atlantic');
|
SELECT DISTINCT name FROM marine_species WHERE region IN ('Arctic', 'Atlantic');
|
List all decentralized applications (dApps) and their respective total transaction volume for Q2 2021, ordered by the dApps with the highest transaction volume in Q2 2021.
|
CREATE TABLE DApps (dapp_id INT,dapp_name VARCHAR(255),transaction_volume DECIMAL(18,2)); INSERT INTO DApps (dapp_id,dapp_name,transaction_volume) VALUES (1,'Uniswap',123456.78),(2,'SushiSwap',23456.78),(3,'Aave',34567.89),(4,'Compound',45678.90),(5,'Yearn Finance',56789.01);
|
SELECT dapp_name, transaction_volume FROM (SELECT dapp_name, transaction_volume, RANK() OVER (ORDER BY transaction_volume DESC) as rank FROM DApps WHERE DApps.transaction_date BETWEEN '2021-04-01' AND '2021-06-30') AS ranked_dapps ORDER BY rank;
|
What is the number of volunteers and total volunteer hours for each city, sorted by the number of volunteers in descending order?
|
CREATE TABLE Volunteers (VolunteerID INT,VolunteerName TEXT,City TEXT); CREATE TABLE VolunteerHours (VolunteerID INT,Hours INT);
|
SELECT V.City, COUNT(V.VolunteerID) as NumVolunteers, SUM(VH.Hours) as TotalHours FROM Volunteers V JOIN VolunteerHours VH ON V.VolunteerID = VH.VolunteerID GROUP BY V.City ORDER BY NumVolunteers DESC;
|
Find the number of songs released by artists from Asia in the last 5 years.
|
CREATE TABLE artists (artist_id INT,artist_name TEXT,country TEXT); INSERT INTO artists (artist_id,artist_name,country) VALUES (1,'Artist 1','China'),(2,'Artist 2','Japan'),(3,'Artist 3','USA'); CREATE TABLE songs (song_id INT,title TEXT,release_date DATE,artist_id INT); INSERT INTO songs (song_id,title,release_date,artist_id) VALUES (1,'Song 1','2018-01-01',1),(2,'Song 2','2019-06-15',2),(3,'Song 3','2020-12-25',3);
|
SELECT COUNT(songs.song_id) FROM songs JOIN artists ON songs.artist_id = artists.artist_id WHERE artists.country = 'China' OR artists.country = 'Japan' AND songs.release_date >= DATE_SUB(CURDATE(), INTERVAL 5 YEAR);
|
What is the average donation amount per month, per donor for the past year, and which donor has the highest average donation amount in this period?
|
CREATE TABLE Donors (DonorID INT,DonorName VARCHAR(255)); CREATE TABLE Donations (DonationID INT,DonorID INT,DonationAmount DECIMAL(10,2),DonationDate DATE);
|
SELECT DonorID, DonorName, AVG(DonationAmount) AS AvgDonation, RANK() OVER (ORDER BY AVG(DonationAmount) DESC) AS DonorRank FROM Donors JOIN Donations ON Donors.DonorID = Donations.DonorID WHERE DonationDate >= DATEADD(YEAR, -1, CURRENT_DATE) GROUP BY DonorID, DonorName, YEAR(DonationDate), MONTH(DonationDate) ORDER BY DonorRank;
|
What is the minimum daily water consumption for the water treatment plant with ID 9 in the state of Colorado in 2023?
|
CREATE TABLE water_treatment_plant (plant_id INT,state VARCHAR(50),year INT,month INT,day INT,water_consumption FLOAT); INSERT INTO water_treatment_plant (plant_id,state,year,month,day,water_consumption) VALUES (9,'Colorado',2023,1,1,12345.6),(9,'Colorado',2023,1,2,23456.7),(9,'Colorado',2023,1,3,34567.8);
|
SELECT MIN(water_consumption) as min_water_consumption FROM water_treatment_plant WHERE plant_id = 9 AND state = 'Colorado' AND year = 2023;
|
Show the average digital divide index for countries in Central America, the Caribbean, and the Baltic states.
|
CREATE TABLE digital_divide (country_name VARCHAR(50),region VARCHAR(20),divide_index DECIMAL(5,2));INSERT INTO digital_divide (country_name,region,divide_index) VALUES ('Costa Rica','Central America',0.25),('Cuba','Caribbean',0.30),('Estonia','Baltic states',0.55),('Latvia','Baltic states',0.45);
|
SELECT AVG(divide_index) FROM digital_divide WHERE region IN ('Central America', 'Caribbean', 'Baltic states');
|
Show all electric vehicles and their prices
|
CREATE TABLE electric_vehicles (id INT PRIMARY KEY,manufacturer VARCHAR(255),model VARCHAR(255),year INT,price FLOAT,type VARCHAR(255));
|
SELECT * FROM electric_vehicles WHERE type = 'Electric';
|
What is the average rating of hotels in 'Africa' that have been reviewed more than 30 times?
|
CREATE TABLE hotels (hotel_id INT,hotel_name VARCHAR(255),rating DECIMAL(2,1),country VARCHAR(255)); INSERT INTO hotels (hotel_id,hotel_name,rating,country) VALUES (1,'Hotel Cairo',4.1,'Egypt'),(2,'Hotel Cape Town',4.6,'South Africa'),(3,'Hotel Marrakech',4.8,'Morocco');
|
SELECT AVG(rating) FROM (SELECT rating FROM hotels WHERE country = 'Africa' GROUP BY rating HAVING COUNT(*) > 30) AS subquery;
|
What is the CO2 emission reduction target for the fashion industry in 2030?
|
CREATE TABLE industry_emission_targets (industry_name VARCHAR(50),year INT,co2_emission_target DECIMAL(10,2));
|
SELECT co2_emission_target AS co2_emission_reduction_target_2030 FROM industry_emission_targets WHERE industry_name = 'Fashion' AND year = 2030;
|
Display the number of urban agriculture projects and their respective types for each organization.
|
CREATE TABLE orgs (id INT,name TEXT); INSERT INTO orgs (id,name) VALUES (1,'Seeds of Hope'); INSERT INTO orgs (id,name) VALUES (2,'Green Urban'); INSERT INTO orgs (id,name) VALUES (3,'Harvest Together'); CREATE TABLE projects (id INT,org_id INT,name TEXT,type TEXT); INSERT INTO projects (id,org_id,name,type) VALUES (1,1,'Community Garden','Urban Agriculture'); INSERT INTO projects (id,org_id,name,type) VALUES (2,1,'Cooking Classes','Food Justice'); INSERT INTO projects (id,org_id,name,type) VALUES (3,3,'Food Co-op','Urban Agriculture');
|
SELECT o.name, p.type, COUNT(p.id) FROM orgs o JOIN projects p ON o.id = p.org_id WHERE o.name IN ('Seeds of Hope', 'Green Urban', 'Harvest Together') GROUP BY o.name, p.type;
|
What is the average safety score for models developed in Asia?
|
CREATE TABLE ai_models (model_id INT,name TEXT,country TEXT,safety_score FLOAT); INSERT INTO ai_models (model_id,name,country,safety_score) VALUES (1,'ModelA','India',0.85),(2,'ModelB','China',0.90),(3,'ModelC','US',0.75),(4,'ModelD','Germany',0.95),(5,'ModelE','France',0.92),(6,'ModelF','Japan',0.88);
|
SELECT AVG(safety_score) FROM ai_models WHERE country IN ('India', 'China', 'Japan');
|
What is the total workout duration for a specific member last week?
|
CREATE TABLE Workouts (WorkoutID INT,MemberID INT,WorkoutDate DATE,Duration INT); INSERT INTO Workouts (WorkoutID,MemberID,WorkoutDate,Duration) VALUES (1,1,'2022-01-01',60); INSERT INTO Workouts (WorkoutID,MemberID,WorkoutDate,Duration) VALUES (2,1,'2022-01-03',90);
|
SELECT SUM(Duration) FROM Workouts WHERE MemberID = 1 AND WorkoutDate BETWEEN DATE_SUB(CURRENT_DATE, INTERVAL 7 DAY) AND CURRENT_DATE;
|
List all drugs approved for orphan diseases in the year 2018.
|
CREATE TABLE drug_approvals (id INT,drug VARCHAR(255),indication VARCHAR(255),approval_date DATE); INSERT INTO drug_approvals (id,drug,indication,approval_date) VALUES (1,'DrugC','Orphan Disease','2018-04-25'); INSERT INTO drug_approvals (id,drug,indication,approval_date) VALUES (2,'DrugD','Cardiovascular','2017-11-10');
|
SELECT drug FROM drug_approvals WHERE indication = 'Orphan Disease' AND approval_date BETWEEN '2018-01-01' AND '2018-12-31';
|
What is the total number of hotels and attractions in Japan?
|
CREATE TABLE hotels (id INT,city VARCHAR(20)); INSERT INTO hotels (id,city) VALUES (1,'Tokyo'),(2,'Osaka'),(3,'Kyoto'); CREATE TABLE attractions (id INT,name VARCHAR(50),city VARCHAR(20)); INSERT INTO attractions (id,name,city) VALUES (1,'Palace','Tokyo'),(2,'Castle','Osaka'),(3,'Shrine','Kyoto');
|
SELECT COUNT(*) FROM hotels UNION ALL SELECT COUNT(*) FROM attractions;
|
List all mining operations that have a high environmental impact score in the state of São Paulo, Brazil?
|
CREATE TABLE mining_operations (id INT,name VARCHAR(50),location VARCHAR(50),environmental_impact_score INT); INSERT INTO mining_operations (id,name,location,environmental_impact_score) VALUES (1,'Mining Operation 1','São Paulo,Brazil',80),(2,'Mining Operation 2','São Paulo,Brazil',20);
|
SELECT * FROM mining_operations WHERE environmental_impact_score >= 50 AND location LIKE '%São Paulo, Brazil%';
|
What is the average duration of restorative justice programs for youth offenders?
|
CREATE TABLE youth_programs (id INT,program VARCHAR(20),duration INT); INSERT INTO youth_programs (id,program,duration) VALUES (1,'Youth Restorative Circles',75); INSERT INTO youth_programs (id,program,duration) VALUES (2,'Youth Community Conferencing',90);
|
SELECT AVG(duration) FROM youth_programs WHERE program LIKE 'Youth%';
|
Determine the number of military equipment maintenance requests in H2 2022
|
CREATE TABLE military_equipment_maintenance (request_id INT,request_date DATE); INSERT INTO military_equipment_maintenance (request_id,request_date) VALUES (1,'2022-07-01'),(2,'2022-12-31');
|
SELECT COUNT(*) FROM military_equipment_maintenance WHERE request_date >= '2022-07-01' AND request_date < '2023-01-01';
|
What is the maximum number of defense diplomacy events conducted by France in 2018 and 2019?
|
CREATE TABLE defense_diplomacy (country VARCHAR(50),year INT,event_count INT); INSERT INTO defense_diplomacy (country,year,event_count) VALUES ('France',2018,5),('France',2018,6),('France',2019,7),('France',2019,8);
|
SELECT MAX(event_count) FROM defense_diplomacy WHERE country = 'France' AND year IN (2018, 2019);
|
How many vessels were inspected in each region for maritime law compliance, along with the inspection dates?
|
CREATE TABLE vessels (region VARCHAR(50),inspection_date DATE); INSERT INTO vessels VALUES ('Region 1','2021-01-01'),('Region 1','2021-02-01'),('Region 2','2021-01-01');
|
SELECT region, COUNT(*) as inspections, MIN(inspection_date) as first_inspection, MAX(inspection_date) as last_inspection FROM vessels GROUP BY region;
|
Who are the top 3 cities with the most male investigative journalists in the 'reporters' table?
|
CREATE TABLE reporters (id INT,name VARCHAR(50),gender VARCHAR(10),age INT,role VARCHAR(20),city VARCHAR(30));
|
SELECT city, COUNT(*) as count FROM reporters WHERE gender = 'male' AND role = 'investigative_journalist' GROUP BY city ORDER BY count DESC LIMIT 3;
|
Which marine species are found in the Pacific Ocean?
|
CREATE TABLE marine_species_location (id INT,species_id INT,location TEXT,PRIMARY KEY (id,species_id),FOREIGN KEY (species_id) REFERENCES marine_species(id)); INSERT INTO marine_species_location (id,species_id,location) VALUES (1,1,'Atlantic Ocean'),(2,2,'Pacific Ocean'),(3,3,'Indian Ocean');
|
SELECT marine_species.species_name FROM marine_species INNER JOIN marine_species_location ON marine_species.id = marine_species_location.species_id WHERE marine_species_location.location = 'Pacific Ocean';
|
Delete all the data from 'autonomous_vehicles' table
|
CREATE TABLE autonomous_vehicles (id INT PRIMARY KEY,manufacturer VARCHAR(255),model VARCHAR(255),year INT,type VARCHAR(255));
|
WITH deleted_data AS (DELETE FROM autonomous_vehicles RETURNING *) SELECT * FROM deleted_data;
|
What is the maximum soil moisture level in California vineyards, based on satellite imagery analysis?
|
CREATE TABLE soil_moisture (location VARCHAR(255),date DATE,moisture FLOAT); INSERT INTO soil_moisture (location,date,moisture) VALUES ('California Vineyard 1','2021-05-01',0.35),('California Vineyard 1','2021-05-02',0.36),('California Vineyard 2','2021-05-01',0.40);
|
SELECT MAX(moisture) FROM soil_moisture WHERE location LIKE '%California Vineyard%';
|
Which lifelong learning courses have the most students aged 50 or older?
|
CREATE TABLE courses (course_id INT,course_name TEXT,course_level TEXT); CREATE TABLE enrollments (enrollment_id INT,student_id INT,course_id INT,enrollment_date DATE,student_age INT); INSERT INTO courses VALUES (1,'Introduction to Programming','beginner'),(2,'Data Science Fundamentals','beginner'),(3,'Advanced Machine Learning','intermediate'); INSERT INTO enrollments VALUES (1,1,1,'2022-01-01',55),(2,2,1,'2022-01-02',22),(3,3,2,'2022-01-03',30),(4,4,2,'2022-01-04',52),(5,5,3,'2022-01-05',28);
|
SELECT c.course_name, COUNT(e.student_id) FROM courses c INNER JOIN enrollments e ON c.course_id = e.course_id WHERE e.student_age >= 50 GROUP BY c.course_name ORDER BY COUNT(e.student_id) DESC;
|
How many electric vehicles were sold in the United States by quarter in 2021?
|
CREATE TABLE Sales (Id INT,VehicleId INT,Quantity INT,SaleDate DATE); CREATE TABLE ElectricVehicles (Id INT,Name VARCHAR(100),Type VARCHAR(50)); INSERT INTO Sales (Id,VehicleId,Quantity,SaleDate) VALUES (1,1,500,'2021-01-01'); INSERT INTO Sales (Id,VehicleId,Quantity,SaleDate) VALUES (2,2,600,'2021-04-01'); INSERT INTO ElectricVehicles (Id,Name,Type) VALUES (1,'Model S','Electric'); INSERT INTO ElectricVehicles (Id,Name,Type) VALUES (2,'Leaf','Electric');
|
SELECT DATE_TRUNC('quarter', SaleDate) AS Quarter, COUNT(*) FROM Sales INNER JOIN ElectricVehicles ON Sales.VehicleId = ElectricVehicles.Id WHERE Type = 'Electric' AND EXTRACT(YEAR FROM SaleDate) = 2021 GROUP BY Quarter;
|
What is the total number of satellites in a stable orbit around Mars, with altitude between 300km to 500km?
|
CREATE TABLE mars_satellites (id INT,name VARCHAR(50),type VARCHAR(50),altitude INT,status VARCHAR(50)); INSERT INTO mars_satellites (id,name,type,altitude,status) VALUES (1,'Sat1','Communication',400,'Stable'),(2,'Sat2','Navigation',350,'Stable'),(3,'Sat3','Observation',520,'Unstable');
|
SELECT COUNT(*) FROM mars_satellites WHERE altitude BETWEEN 300 AND 500 AND status = 'Stable';
|
Which farmers have less than 5 years of experience in the agriculture database?
|
CREATE TABLE Farmers (id INT,name VARCHAR,location VARCHAR,years_of_experience INT); INSERT INTO Farmers (id,name,location,years_of_experience) VALUES (1,'Nur Afiqah','Singapore',2),(2,'Max Schmidt','Berlin',4),(3,'Anastasia Kuznetsova','Moscow',6),(4,'Jacob Nielsen','Oslo',8),(5,'Carla Moraes','Sao Paulo',10);
|
SELECT name FROM Farmers WHERE years_of_experience < 5;
|
How many packages were shipped from 'east' region warehouses in January 2022?
|
CREATE TABLE warehouse_monthly_stats (warehouse_id INT,month INT,packages_shipped INT); INSERT INTO warehouse_monthly_stats (warehouse_id,month,packages_shipped) VALUES (1,1,400),(2,1,300),(1,2,450),(2,2,350);
|
SELECT SUM(packages_shipped) FROM warehouse_monthly_stats WHERE warehouse_id IN (SELECT id FROM warehouses WHERE region = 'east') AND month = 1;
|
What is the average safety score for all creative AI applications in the Asia-Pacific region?
|
CREATE TABLE creative_ai_apps (app_id INT,app_name TEXT,region TEXT,safety_score FLOAT); INSERT INTO creative_ai_apps (app_id,app_name,region,safety_score) VALUES (1,'AI Painter','Asia-Pacific',0.85),(2,'AI Music Composer','Europe',0.92),(3,'AI Writer','Asia-Pacific',0.88);
|
SELECT AVG(safety_score) FROM creative_ai_apps WHERE region = 'Asia-Pacific';
|
What is the total assets value for customers in the financial services industry who have assets greater than 250000?
|
CREATE TABLE customers (id INT,name VARCHAR(255),industry VARCHAR(255),assets DECIMAL(10,2)); INSERT INTO customers (id,name,industry,assets) VALUES (1,'John Doe','Financial Services',150000.00),(2,'Jane Smith','Financial Services',200000.00),(3,'Alice Johnson','Financial Services',250000.00),(4,'Bob Brown','Financial Services',300000.00),(5,'Charlie Davis','Retail',50000.00),(6,'Diana Green','Healthcare',75000.00);
|
SELECT SUM(assets) FROM customers WHERE industry = 'Financial Services' AND assets > 250000.00;
|
Find the percentage of citizens in 'CityM' who are dissatisfied with the public transportation service in 2021.
|
CREATE TABLE CityM_Satis (ID INT,Year INT,Satisfaction VARCHAR(10)); INSERT INTO CityM_Satis (ID,Year,Satisfaction) VALUES (1,2021,'Satisfied'),(2,2021,'Neutral'),(3,2021,'Dissatisfied'),(4,2021,'Dissatisfied'),(5,2021,'Satisfied');
|
SELECT 100.0 * COUNT(CASE WHEN Satisfaction = 'Dissatisfied' THEN 1 END) / COUNT(*) FROM CityM_Satis WHERE Year = 2021;
|
How many volunteers are there in each age group?
|
CREATE TABLE Volunteers (AgeGroup VARCHAR(20),VolunteerID INT); INSERT INTO Volunteers (AgeGroup,VolunteerID) VALUES ('18-25',100),('26-35',200),('36-45',300),('46-55',400),('56-65',500);
|
SELECT AgeGroup, COUNT(VolunteerID) as NumVolunteers FROM Volunteers GROUP BY AgeGroup;
|
List all market approvals, including those without any drugs approved, for a specific region in the 'market_approvals' and 'drugs' tables?
|
CREATE TABLE market_approvals (market_approval_id INT,region_id INT,approval_date DATE); CREATE TABLE drugs (drug_id INT,drug_name TEXT,market_approval_id INT); INSERT INTO market_approvals (market_approval_id,region_id,approval_date) VALUES (1,1,'2020-01-01'),(2,2,'2019-05-05');
|
SELECT ma.approval_date, COALESCE(COUNT(d.drug_id), 0) AS drug_count FROM market_approvals ma LEFT JOIN drugs d ON ma.market_approval_id = d.market_approval_id WHERE ma.region_id = 1 GROUP BY ma.approval_date;
|
What is the average heart rate of members aged 25-30?
|
CREATE TABLE member_demographics (member_id INT,age INT,heart_rate INT); INSERT INTO member_demographics (member_id,age,heart_rate) VALUES (1,27,80),(2,32,75),(3,26,85),(4,28,90),(5,31,70);
|
SELECT AVG(heart_rate) FROM member_demographics WHERE age BETWEEN 25 AND 30;
|
What is the total number of unique digital assets on the Polygon network, and what is the average market capitalization (in USD) of these assets?
|
CREATE TABLE polygon_assets (asset_id INT,asset_name VARCHAR(255),total_supply INT,current_price FLOAT);
|
SELECT COUNT(DISTINCT asset_name) as unique_assets, AVG(total_supply * current_price) as avg_market_cap FROM polygon_assets;
|
Show data from customer_size view
|
CREATE TABLE customer_size (id INT PRIMARY KEY,size VARCHAR(10),customer_count INT); INSERT INTO customer_size (id,size,customer_count) VALUES (1,'XS',500),(2,'S',800),(3,'M',1200),(4,'L',1500); CREATE VIEW customer_size_view AS SELECT size,customer_count FROM customer_size;
|
SELECT * FROM customer_size_view;
|
What was the average number of eco-tourists in Africa in 2020 and 2021?
|
CREATE TABLE eco_tourists (id INT,continent VARCHAR(50),country VARCHAR(50),eco_visitors INT,year INT); INSERT INTO eco_tourists (id,continent,country,eco_visitors,year) VALUES (1,'Africa','Kenya',1500,2020),(2,'Africa','Tanzania',1800,2020),(3,'Africa','Kenya',1700,2021),(4,'Africa','Tanzania',2000,2021);
|
SELECT continent, AVG(eco_visitors) FROM eco_tourists WHERE continent = 'Africa' AND year IN (2020, 2021) GROUP BY continent;
|
Update the expiration dates of all dairy products imported from Europe in the past week.
|
CREATE TABLE Customs (id INT,importId INT,item VARCHAR(50),weight FLOAT,region VARCHAR(50),importDate DATE,expirationDate DATE);
|
UPDATE Customs SET expirationDate = DATE_ADD(importDate, INTERVAL 30 DAY) WHERE item LIKE '%dairy%' AND region = 'Europe' AND importDate >= DATE_SUB(CURRENT_DATE, INTERVAL 1 WEEK);
|
What is the total number of volunteers in rural areas?
|
CREATE TABLE programs (id INT,name VARCHAR(50),location VARCHAR(50)); CREATE TABLE volunteers (id INT,name VARCHAR(50),program_id INT,location VARCHAR(50)); INSERT INTO programs (id,name,location) VALUES (1,'Health','Urban'),(2,'Education','Rural'); INSERT INTO volunteers (id,name,program_id,location) VALUES (1,'Alice',1,'Urban'),(2,'Bob',1,'Urban'),(3,'Charlie',2,'Rural');
|
SELECT COUNT(v.id) FROM volunteers v INNER JOIN programs p ON v.program_id = p.id WHERE p.location = 'Rural';
|
Which ocean floor mapping projects and marine life research stations are not located in the same regions?
|
CREATE TABLE ocean_floor_mapping_projects (id INT,name VARCHAR(255),region VARCHAR(255)); CREATE TABLE marine_life_research_stations (id INT,name VARCHAR(255),region VARCHAR(255));
|
SELECT o.name, m.name FROM ocean_floor_mapping_projects o LEFT JOIN marine_life_research_stations m ON o.region = m.region WHERE m.region IS NULL;
|
How many movies have been directed by women from Latin America in the last 10 years?
|
CREATE TABLE movies (id INT,title VARCHAR(255),release_year INT,director VARCHAR(255),region VARCHAR(255)); INSERT INTO movies (id,title,release_year,director,region) VALUES (1,'Roma',2018,'Alfonso Cuarón','Mexico'),(2,'The Queen of Versailles',2012,'Lauren Greenfield','USA'),(3,'Y Tu Mamá También',2001,'Alfonso Cuarón','Mexico'),(4,'The Chambermaid',2018,'Lila Avilés','Mexico');
|
SELECT COUNT(*) FROM movies WHERE director IN ('Women from Latin America') AND release_year >= 2011;
|
Add a new community center in 'City 2' to the 'community_centers' table.
|
CREATE TABLE cities (id INT,name VARCHAR(255)); INSERT INTO cities (id,name) VALUES (1,'City 1'),(2,'City 2'); CREATE TABLE community_centers (id INT,name VARCHAR(255),city_id INT);
|
INSERT INTO community_centers (id, name, city_id) VALUES (1, 'Community Center 1', 2);
|
Which traditional art forms are not represented in any heritage sites?
|
CREATE TABLE TraditionalArtForms (id INT,name VARCHAR(50)); CREATE TABLE ArtPieces (id INT,art_form_id INT,site_id INT); CREATE TABLE HeritageSites (id INT,name VARCHAR(50),site_id INT);
|
SELECT TAF.name FROM TraditionalArtForms TAF LEFT JOIN ArtPieces AP ON TAF.id = AP.art_form_id LEFT JOIN HeritageSites HS ON AP.site_id = HS.id WHERE HS.id IS NULL;
|
Which social good technology organizations in the environmental sector have received the least funding in the past 3 years?
|
CREATE TABLE org_funding_env (org_name TEXT,funding_amount INT,funding_year INT,sector TEXT); INSERT INTO org_funding_env (org_name,funding_amount,funding_year,sector) VALUES ('SocialTech6',50000,2020,'environment'),('SocialTech7',70000,2019,'environment'),('SocialTech8',60000,2018,'environment'),('SocialTech9',80000,2021,'environment'),('SocialTech10',90000,2017,'environment');
|
SELECT org_name, MIN(funding_amount) FROM org_funding_env WHERE sector = 'environment' AND funding_year BETWEEN 2018 AND 2020 GROUP BY org_name;
|
Calculate the average temperature for the last 3 days for 'field13'.
|
CREATE TABLE field13 (date DATE,temperature FLOAT); INSERT INTO field13 (date,temperature) VALUES ('2021-11-20',12.2),('2021-11-21',13.1),('2021-11-22',14.3);
|
SELECT AVG(temperature) FROM field13 WHERE date >= (CURRENT_DATE - INTERVAL '3 days');
|
What is the minimum severity score of vulnerabilities in the 'Europe' region?
|
CREATE TABLE vulnerabilities (id INT,vulnerability_name VARCHAR(255),region VARCHAR(255),severity_score INT); INSERT INTO vulnerabilities (id,vulnerability_name,region,severity_score) VALUES (1,'SQL Injection','Africa',8),(2,'Cross-Site Scripting','Europe',6);
|
SELECT MIN(severity_score) FROM vulnerabilities WHERE region = 'Europe';
|
What is the total number of hospital beds in rural areas of New Mexico, with less than 20 beds per hospital?
|
CREATE TABLE hospital_beds (hospital_id INT,name VARCHAR(50),location VARCHAR(20),num_of_beds INT); INSERT INTO hospital_beds (hospital_id,name,location,num_of_beds) VALUES (1,'Rural Hospital A','New Mexico',15); INSERT INTO hospital_beds (hospital_id,name,location,num_of_beds) VALUES (2,'Rural Hospital B','New Mexico',25); INSERT INTO hospital_beds (hospital_id,name,location,num_of_beds) VALUES (3,'Urban Hospital A','California',30);
|
SELECT location, COUNT(*) FROM hospital_beds WHERE num_of_beds < 20 AND location = 'New Mexico' GROUP BY location;
|
Which natural ingredients are used in more than one cosmetic product?
|
CREATE TABLE product_ingredients (product_id INT,ingredient_name TEXT,natural BOOLEAN); INSERT INTO product_ingredients (product_id,ingredient_name,natural) VALUES (1,'Water',TRUE),(1,'Mica',TRUE),(2,'Water',TRUE),(2,'Mica',TRUE),(2,'Carmine',FALSE),(3,'Water',TRUE),(3,'Silica',TRUE),(3,'Fragrance',FALSE),(4,'Water',TRUE),(4,'Shea Butter',TRUE),(5,'Glycerin',TRUE),(5,'Jojoba Oil',TRUE),(6,'Water',TRUE),(6,'Coconut Oil',TRUE),(6,'Vitamin E',TRUE);
|
SELECT ingredient_name, natural, COUNT(*) as product_count FROM product_ingredients WHERE natural = TRUE GROUP BY ingredient_name HAVING COUNT(*) > 1;
|
What are the top 5 players in the NHL based on career goals scored?
|
CREATE TABLE Players (PlayerID INT,PlayerName VARCHAR(50),Goals INT); INSERT INTO Players (PlayerID,PlayerName,Goals) VALUES (1,'Gretzky',894),(2,'Lemieux',690),(3,'Howe',786);
|
SELECT PlayerName, Goals FROM Players ORDER BY Goals DESC LIMIT 5
|
What is the average renewable energy capacity per plant?
|
CREATE TABLE renewable_energy_plant (plant_id INT,country_id INT,capacity FLOAT); INSERT INTO renewable_energy_plant VALUES (1,1,500),(2,1,700),(3,2,1200),(4,3,800);
|
SELECT AVG(capacity) as avg_capacity FROM renewable_energy_plant;
|
Find the second lowest safety rating in the creative_ai table.
|
CREATE TABLE creative_ai (app_id INT,app_name TEXT,safety_rating REAL); INSERT INTO creative_ai VALUES (1,'Dalle',4.3,'USA'),(2,'GTP-3',4.5,'Canada'),(3,'Midjourney',4.7,'Australia');
|
SELECT safety_rating FROM (SELECT safety_rating, ROW_NUMBER() OVER (ORDER BY safety_rating) as row_num FROM creative_ai) subquery WHERE row_num = 2;
|
Update the 'mayor_name' column in the 'city_info' table for the city 'Denver', CO to 'Janet Van Der Laan'
|
CREATE TABLE city_info (id INT,city VARCHAR(50),state VARCHAR(2),mayor_name VARCHAR(50));
|
UPDATE city_info SET mayor_name = 'Janet Van Der Laan' WHERE city = 'Denver' AND state = 'CO';
|
How many bridges were constructed each year in the Northeast region of the US since 2010?
|
CREATE TABLE Bridges (Bridge_ID INT,Bridge_Name VARCHAR(255),Construction_Year INT,Location VARCHAR(255));
|
SELECT Construction_Year, COUNT(*) FROM Bridges WHERE Location LIKE '%Northeast%' AND Construction_Year >= 2010 GROUP BY Construction_Year;
|
Show the sum of investment amounts for startups founded by 'Jane Doe'
|
CREATE TABLE company (id INT,name TEXT,founding_year INT,founder_name TEXT); INSERT INTO company (id,name,founding_year,founder_name) VALUES (1,'Acme Inc',2010,'Jane Doe'); INSERT INTO company (id,name,founding_year,founder_name) VALUES (2,'Brick Co',2012,'John Smith');
|
SELECT SUM(investment_amount) FROM investment_rounds ir INNER JOIN company c ON ir.company_id = c.id WHERE c.founder_name = 'Jane Doe';
|
What is the minimum donation amount from India?
|
CREATE TABLE Donors (DonorID INT,DonorName TEXT,DonationAmount DECIMAL(10,2),Country TEXT);
|
SELECT MIN(DonationAmount) FROM Donors WHERE Country = 'India';
|
What is the average depth of all marine trenches?
|
CREATE TABLE marine_trenches (name TEXT,location TEXT,max_depth INTEGER);INSERT INTO marine_trenches (name,location,max_depth) VALUES ('Mariana Trench','Pacific Ocean',10994);
|
SELECT AVG(max_depth) FROM marine_trenches;
|
What is the number of students who received accommodations by disability type and gender?
|
CREATE TABLE disability_accommodations (student_id INT,disability_type VARCHAR(50),gender VARCHAR(50)); INSERT INTO disability_accommodations (student_id,disability_type,gender) VALUES (1,'Physical','Female');
|
SELECT disability_type, gender, COUNT(*) as total_students FROM disability_accommodations GROUP BY disability_type, gender;
|
What is the maximum waste generation for mining operations in South America?
|
CREATE TABLE MiningOperations (OperationID INT,MineName VARCHAR(50),Location VARCHAR(50),WasteGeneration INT); INSERT INTO MiningOperations (OperationID,MineName,Location,WasteGeneration) VALUES (1,'Crystal Mine','Canada',200),(2,'Diamond Mine','Australia',220),(3,'Gold Mine','South Africa',250);
|
SELECT MAX(WasteGeneration) FROM MiningOperations WHERE Location LIKE 'South%';
|
Display the average number of volunteers per organization, including those with no volunteers, for mission areas Social Services and Disaster Relief.
|
CREATE TABLE organizations (id INT,name VARCHAR(100),mission_area VARCHAR(50),state VARCHAR(50)); CREATE TABLE volunteers (id INT,organization_id INT,hours DECIMAL(5,2)); INSERT INTO organizations VALUES (1,'Organization D','Social Services',NULL); INSERT INTO organizations VALUES (2,'Organization E','Disaster Relief',NULL); INSERT INTO volunteers VALUES (1,1,20); INSERT INTO volunteers VALUES (2,1,15);
|
SELECT o.mission_area, AVG(v.id) as avg_volunteers FROM organizations o LEFT JOIN volunteers v ON o.id = v.organization_id WHERE o.mission_area IN ('Social Services', 'Disaster Relief') GROUP BY o.mission_area;
|
What is the minimum flight speed for Airbus A380 aircraft?
|
CREATE TABLE Flight_Data (flight_date DATE,aircraft_model VARCHAR(255),flight_speed INTEGER); INSERT INTO Flight_Data (flight_date,aircraft_model,flight_speed) VALUES ('2020-01-01','Boeing 737',450),('2020-02-01','Boeing 737',500),('2020-03-01','Airbus A380',550),('2020-04-01','Boeing 747',600),('2020-05-01','Airbus A380',400);
|
SELECT MIN(flight_speed) AS min_flight_speed FROM Flight_Data WHERE aircraft_model = 'Airbus A380';
|
What is the total number of volunteers in India who have completed more than 10 hours of service?
|
CREATE TABLE volunteers (volunteer_id int,hours_served int,country varchar(50)); INSERT INTO volunteers (volunteer_id,hours_served,country) VALUES (1,12,'India'),(2,5,'India'),(3,20,'India');
|
SELECT COUNT(volunteer_id) FROM volunteers WHERE country = 'India' GROUP BY volunteer_id HAVING hours_served > 10;
|
Which exhibition had the lowest number of visitors on a weekend?
|
CREATE TABLE attendance (visitor_id INT,exhibition_name VARCHAR(255),visit_date DATE); INSERT INTO attendance (visitor_id,exhibition_name,visit_date) VALUES (123,'Expressionism','2022-01-08'),(456,'Expressionism','2022-01-09'),(789,'Cubism','2022-01-08'),(111,'Cubism','2022-01-09'),(222,'Futurism','2022-01-08'),(333,'Futurism','2022-01-09');
|
SELECT exhibition_name, MIN(visit_date) AS min_weekend_visit FROM attendance WHERE EXTRACT(DAY FROM visit_date) BETWEEN 6 AND 7 GROUP BY exhibition_name;
|
List all countries with their respective number of podcasts and the total duration of those podcasts.
|
CREATE TABLE podcasts (id INT,name VARCHAR(255),country VARCHAR(255),duration INT); INSERT INTO podcasts (id,name,country,duration) VALUES (1,'Podcast1','USA',100),(2,'Podcast2','UK',200);
|
SELECT country, COUNT(*) as num_podcasts, SUM(duration) as total_duration FROM podcasts GROUP BY country;
|
What is the number of union membership applications submitted per month in 2022?
|
CREATE TABLE Applications (Id INT,ApplicationDate DATE); INSERT INTO Applications (Id,ApplicationDate) VALUES (1,'2022-01-01'),(2,'2022-02-15'),(3,'2022-03-05'),(4,'2022-04-20');
|
SELECT MONTH(ApplicationDate) as Month, COUNT(*) as TotalApplications FROM Applications WHERE YEAR(ApplicationDate) = 2022 GROUP BY Month;
|
What is the maximum volume of ocean acidification in the Southern Ocean over the last 10 years?
|
CREATE TABLE ocean_acidification (year INT,region VARCHAR(255),volume FLOAT);INSERT INTO ocean_acidification (year,region,volume) VALUES (2011,'Southern Ocean',2500),(2012,'Southern Ocean',2600),(2013,'Southern Ocean',2800),(2014,'Southern Ocean',3000),(2015,'Southern Ocean',3200),(2016,'Southern Ocean',3500),(2017,'Southern Ocean',3700),(2018,'Southern Ocean',4000),(2019,'Southern Ocean',4200),(2020,'Southern Ocean',4500);
|
SELECT MAX(volume) FROM ocean_acidification WHERE region = 'Southern Ocean' AND year BETWEEN 2011 AND 2020;
|
Find the average billing rate for attorneys in 'billing' table, excluding attorneys with less than 10 hours billed
|
CREATE TABLE billing (attorney_id INT,client_id INT,hours_billed INT,billing_rate DECIMAL(5,2));
|
SELECT AVG(billing_rate) FROM billing WHERE hours_billed >= 10;
|
What is the maximum research grant amount awarded to faculty members in the Engineering department?
|
CREATE TABLE grants (id INT,faculty_id INT,title VARCHAR(100),amount DECIMAL(10,2)); INSERT INTO grants (id,faculty_id,title,amount) VALUES (1,1,'Research Grant 1',100000),(2,2,'Research Grant 2',120000),(3,3,'Research Grant 3',150000); CREATE TABLE faculty (id INT,name VARCHAR(50),department VARCHAR(50)); INSERT INTO faculty (id,name,department) VALUES (1,'Fiona','Engineering'),(2,'Gabriel','Computer Science'),(3,'Heidi','Humanities');
|
SELECT MAX(g.amount) FROM grants g JOIN faculty f ON g.faculty_id = f.id WHERE f.department = 'Engineering';
|
Show the number of users in Sydney and Cape Town who used public transportation at least once in the last month.
|
CREATE TABLE sydney_usage (user_id INT,last_used DATE); CREATE TABLE cape_town_usage (user_id INT,last_used DATE); INSERT INTO sydney_usage (user_id,last_used) VALUES (1,'2022-01-15'),(2,'2022-02-10'),(3,'2022-03-01'),(4,'2022-01-20'); INSERT INTO cape_town_usage (user_id,last_used) VALUES (5,'2022-02-25'),(6,'2022-03-15'),(7,'2022-01-05'),(8,'2022-02-20');
|
SELECT COUNT(*) FROM sydney_usage WHERE last_used >= DATEADD(month, -1, GETDATE()) UNION ALL SELECT COUNT(*) FROM cape_town_usage WHERE last_used >= DATEADD(month, -1, GETDATE());
|
What is the total distance covered by all runners in the 2019 marathon?
|
CREATE TABLE runners (id INT,name TEXT,distance FLOAT,marathon INT); INSERT INTO runners (id,name,distance,marathon) VALUES (1,'John Doe',42.2,2019),(2,'Jane Smith',40.5,2019),(3,'Alberto Rodriguez',38.7,2019);
|
SELECT SUM(distance) FROM runners WHERE marathon = 2019;
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.