๐ข ๋ณธ ํฌ์คํ ์ ํ์ฉ๋๋ ๊ธฐ๋ณธ ๋ฌธ์ ๋ฐ ์๋ฃ ์ถ์ฒ๋ HackerRank ์์ ๋ฐํ๋๋ค.
https://www.hackerrank.com
โ ๋ฌธ์
https://www.hackerrank.com/challenges/weather-observation-station-20/problem
A median is defined as a number separating the higher half of a data set from the lower half. Query the median of the Northern Latitudes (LAT_N) from STATION and round your answer to decimal places.
Input Format
The STATION table is described as follows:
where LAT_N is the northern latitude and LONG_W is the western longitude.
โ ํ์ด
SELECT ROUND(LAT_N, 4)
FROM (SELECT LAT_N, PERCENT_RANK() OVER (ORDER BY LAT_N) AS PR
FROM STATION) T1
WHERE T1.PR = 0.5;
PERCENT_RANK()
: ํํฐ์ ๊ฐ๋ณด๋ค ์์ ํํฐ์ ๊ฐ์ ๋ฐฑ๋ถ์จ์ ๋ฐํํ๋ค.
๋ฌธ์ ์์๋ ์ค์๊ฐ์ ์ถ์ถํ๋ผ๊ณ ํ์ผ๋ฏ๋ก ์กฐ๊ฑด์ ์ PERCENT_RANK()= 0.5 .
https://dev.mysql.com/doc/refman/8.0/en/window-function-descriptions.html#function_percent-rank
'Growth ๐ณ > Practice ๐ป' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[Hacker Rank] Weather Observation Station 16 (0) | 2022.08.22 |
---|---|
[Hacker Rank] Weather Observation Station 14 (0) | 2022.08.22 |
[Hacker Rank] The Blunder (0) | 2022.08.20 |
[SQL] ์ฐ์ต๋ฌธ์ (0) | 2022.08.03 |
[ํด์ปค๋ญํฌ] Weather Observation Station 5 (0) | 2022.07.28 |