We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent cfb84f4 commit 72adca4Copy full SHA for 72adca4
hackerrank_sql_practice/weather_observation_station_20.sql
@@ -0,0 +1,20 @@
1
+/*
2
+A median is defined as a number separating the higher half
3
+of a data set from the lower half. Query the median of the
4
+Northern Latitudes (LAT_N) from STATION and round your answer to decimal places.
5
+
6
+*/
7
8
9
+with ordered as (
10
+select LAT_N from station order by LAT_N desc),
11
12
+total_num as (
13
+select count(LAT_N) as c from station),
14
15
+actual_pos as (
16
+select round(c/2) as x from total_num)
17
18
+select round(LAT_N,4) from (
19
+select LAT_N , row_number() over( order by LAT_N desc) as r from ordered )k
20
+where r = (select x from actual_pos)
0 commit comments