Skip to content

Instantly share code, notes, and snippets.

@GGrassiant
Last active March 18, 2021 14:13
Show Gist options
  • Select an option

  • Save GGrassiant/dae10bf01c12472d6a93363ac4658f60 to your computer and use it in GitHub Desktop.

Select an option

Save GGrassiant/dae10bf01c12472d6a93363ac4658f60 to your computer and use it in GitHub Desktop.
SQL Median Query
Select round(S.LAT_N,4) median
from station S
where (
select count(Lat_N)
from station
where Lat_N < S.LAT_N )
= (
select count(Lat_N)
from station
where Lat_N > S.LAT_N)
-- Select the item that has as many items before than after
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment