码迷,mamicode.com
首页 > 数据库 > 详细

How to calculate Median using MySQL

时间:2019-05-22 23:56:14      阅读:250      评论:0      收藏:0      [点我收藏+]

标签:class   round   ber   sql   mysq   weight   color   median   station   

SET @ROW_NUMBER:=0; 
select round(avg(LAT_N),4) from 
(
select 
@Row_Number := @Row_Number +1 as count_of_group, 
LAT_N ,

(SELECT 
            COUNT(*)
        FROM
            Station 
        ) AS total_of_group

from station

 
order by Lat_N asc
    ) 
    tmp 
    where count_of_group
    between total_of_group / 2.0 AND total_of_group / 2.0 + 1

 

How to calculate Median using MySQL

标签:class   round   ber   sql   mysq   weight   color   median   station   

原文地址:https://www.cnblogs.com/codingyangmao/p/10909193.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!