Skip to content

Commit 72adca4

Browse files
authored
Create weather_observation_station_20.sql
1 parent cfb84f4 commit 72adca4

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)