melody
melody

Reputation: 1

how do I find median in sql (code question)

I find answers below: Select round(S.LAT_N,4) mediam 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)

I'm confused at where S come from??

Upvotes: 0

Views: 71

Answers (1)

danblack
danblack

Reputation: 14666

S is an alias of station. The FROM clause is defining station as that alias S. With it defined this way station.{field} isn't valid, only S.{field} is.

Upvotes: 0

Related Questions