17. Weather Observation 20 hacker rank my sql
Weather Observation 20
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.
Solution in My SQL
SELECT ROUND(S1.LAT_N, 4)
FROM STATION AS S1
WHERE (SELECT ROUND(COUNT(S1.ID)/2) — 1
FROM STATION) =
(SELECT COUNT(S2.ID)
FROM STATION AS S2
WHERE S2.LAT_N > S1.LAT_N);
No comments