sqlserver 中位数计算方法
来源:互联网 发布:矩阵切换器有什么用 编辑:程序博客网 时间:2024/05/22 17:43
1、一个子集中的中位数
COUNT(x.cashmoneys)为奇数
SELECT x.cashmoneys FROM (select distinct cashmoneys from apprexpense) x, (select distinct cashmoneys from apprexpense) y
GROUP BY x.cashmoneys
HAVING SUM(sign(1-sign(x.cashmoneys-y.cashmoneys)))=(COUNT(x.cashmoneys)+1)/2
COUNT(x.cashmoneys)为偶数
select avg(z.cashmoneys) from
(
SELECT x.cashmoneys FROM (select distinct cashmoneys from apprexpense) x, (select distinct cashmoneys from apprexpense) y
GROUP BY x.cashmoneys
HAVING SUM(sign(1-sign(x.cashmoneys-y.cashmoneys)))=COUNT(x.cashmoneys)/2
or SUM(sign(1-sign(x.cashmoneys-y.cashmoneys)))=(COUNT(x.cashmoneys)/2+1)
) z
2、多个子集中的中位数
COUNT(x.cashmoneys)为奇数
SELECT x.type,x.cashmoneys FROM (select distinct type,cashmoneys from apprexpense) x inner join (select distinct type,cashmoneys from apprexpense) y on x.type=y.type
GROUP BY x.type,x.cashmoneys
HAVING SUM(sign(1-sign(x.cashmoneys-y.cashmoneys)))=(COUNT(x.cashmoneys)+1)/2
- sqlserver 中位数计算方法
- sqlserver中位数
- SQLServer各种日期计算方法
- MYSQL SQLSERVER 日期计算方法
- 计算方法
- 中位数
- 中位数
- 中位数
- 中位数
- 中位数
- 中位数
- 中位数
- 中位数
- 中位数
- 中位数
- 中位数
- 中位数
- 中位数
- 读书笔记(第三讲)primitive type
- linux awk 命令应用
- xp安装补丁后,虚拟机fedora的samba服务连不上问题
- 110915 compareto
- SPRING的初始化方法执行先后顺序
- sqlserver 中位数计算方法
- SQL时间函数收藏
- poj3622_Gourmet Grazers
- 数据结构----关键路径详解(Java)
- 通过request.getContextPath获取绝对路径
- http抓包工具推荐
- Java synchronized是如何工作的
- 策略模式DEMO
- java区分中英文