Calculating the Median with Mysql

后端 未结 7 1736
傲寒
傲寒 2020-12-17 00:38

I\'m having trouble with calculating the median of a list of values, not the average.

I found this article Simple way to calculate median with MySQL

It has a

7条回答
  •  不思量自难忘°
    2020-12-17 01:04

    Simplest ways me and my friend have found out... ENJOY!!

    SELECT count(*) INTO @c from station;
    select ROUND((@c+1)/2) into @final; 
    SELECT round(lat_n,4) from station a where @final-1=(select count(lat_n) from station b where b.lat_n > a.lat_n);
    

提交回复
热议问题