如何更正四分位数的查询?

时间:2017-07-09 15:31:59

标签: mysql

我有这样的查询:

select `pelamardoktorrangkuman`.`major` AS `ProgramStudi`,
count(`pelamardoktorrangkuman`.`IPKS2`) AS `N`,
avg(`pelamardoktorrangkuman`.`IPKS2`) AS `Mean`,
min(`pelamardoktorrangkuman`.`IPKS2`) AS `Minimum`,
max(`pelamardoktorrangkuman`.`IPKS2`) AS `Maximum`,
std(`pelamardoktorrangkuman`.`IPKS2`) AS `StDev`,
cast(substring_index(substring_index(group_concat(`pelamardoktorrangkuman`.`IPKS2` 
    order by `pelamardoktorrangkuman`.`IPKS2` ASC separator ','),',',(((0.50) * count(0)) + 1)),',',-(1)) as decimal(18,8)) AS `Median`,
cast(substring_index(substring_index(group_concat(`pelamardoktorrangkuman`.`IPKS2` 
    order by `pelamardoktorrangkuman`.`IPKS2` ASC separator ','),',',(((0.25) * count(0)) + 1)),',',-(1)) as decimal(18,8)) AS `Q1`,
cast(substring_index(substring_index(group_concat(`pelamardoktorrangkuman`.`IPKS2` 
    order by `pelamardoktorrangkuman`.`IPKS2` ASC separator ','),',',(((0.75) * count(0)) + 1)),',',-(1)) as decimal(18,8)) AS `Q3` 
from `pelamardoktorrangkuman` where ((`pelamardoktorrangkuman`.`IPKS2` <> 0) and (`pelamardoktorrangkuman`.`TahunDaftar` = 2012)) group by `pelamardoktorrangkuman`.`major` ;

我想专注于四分位代码。上面的源代码给出了四分位数的错误结果。我试图手动计算四分位数,结果与上面的源代码不同。我能做些什么才能使四分位数得到正确的结果?提前致谢

以下是IPK值表:

enter image description here

以上是源代码的结果:

enter image description here

0 个答案:

没有答案