mysql中并没有直接求中位数的函数,经过一番查找之后,找到了如下方法:
SELECT ((SUBSTRING_INDEX(SUBSTRING_INDEX(group_concat(URINEIODINE order by URINEIODINE), ',', floor(1+((count(URINEIODINE)-1) / 2))), ',', -1)) + (SUBSTRING_INDEX(SUBSTRING_INDEX(group_concat(URINEIODINE order by URINEIODINE), ',', ceiling(1+((count(URINEIODINE)-1) / 2))), ',', -1)))/2 as median FROM bs_lowiodinergn_chld_con_srvy t
但是此方法并不是函数,使用起来有诸多限制。
SELECT ((SUBSTRING_INDEX(SUBSTRING_INDEX(group_concat(URINEIODINE order by URINEIODINE), ',', floor(1+((count(URINEIODINE)-1) / 2))), ',', -1))+(SUBSTRING_INDEX(SUBSTRING_INDEX(group_concat(URINEIODINE order by URINEIODINE), ',', ceiling(1+((count(URINEIODINE)-1) / 2))), ',', -1)))/2as medianFROM bs_lowiodinergn_chld_con_srvy t