기존학습자료/leetcode, hackerrank

해커랭크 - 집계함수

gooreumsea 2023. 6. 25. 05:00

Revising Aggregations - Averages 
https://www.hackerrank.com/challenges/revising-aggregations-the-average-function/problem

SELECT AVG(population)
FROM CITY
WHERE District = "California"

 

 

Revising Aggregations - The Sum Function
https://www.hackerrank.com/challenges/revising-aggregations-sum/problem

SELECT SUM(population)
FROM CITY
WHERE District = "California"

 

 

Revising Aggregations - The Count Function
https://www.hackerrank.com/challenges/revising-aggregations-the-count-function/problem

SELECT COUNT(COUNTRYCODE)
FROM CITY
WHERE POPULATION > 100000

 

 

Weather Observation Station 4
https://www.hackerrank.com/challenges/weather-observation-station-4/problem

SELECT COUNT(CITY) - COUNT(DISTINCT CITY)
FROM STATION

 

 

Top Earners 

https://www.hackerrank.com/challenges/earnings-of-employees/problem

SELECT salary * months AS earnings , COUNT(*)
FROM Employee
GROUP BY earnings
ORDER BY earnings DESC
LIMIT 1

 

 

Japan Population
https://www.hackerrank.com/challenges/japan-population/problem

SELECT SUM(POPULATION)
FROM CITY
WHERE COUNTRYCODE='JPN'

 


Weather Observation Station 13 
https://www.hackerrank.com/challenges/weather-observation-station-13/problem

SELECT TRUNCATE(SUM(LAT_N),4)
FROM STATION
WHERE LAT_N>=38.7880 AND LAT_N<=137.2345

 

 

Weather Observation Station 3
https://www.hackerrank.com/challenges/weather-observation-station-3/problem

SELECT CITY
FROM STATION
WHERE ID%2=0
GROUP BY CITY