读书人

sql 计算标准差?该怎么处理

发布时间: 2012-12-20 09:53:21 作者: rapoo

sql 计算标准差?
现在要计算标准差 http://baike.baidu.com/view/78339.htm

求解sql里怎么计算?是不是有什么公式之类的,
假设表为 a b
其中a为数值 b为日期,我想取出一段时间内的标准差,求解。
[最优解释]
select a ,b from
(select *,[st]=stdev(a)over() from tb where b between .. and ..)
where a>[st]
[其他解释]
不会啊,帮顶~
[其他解释]
STDEV() 这个函数可以 我找到了
[其他解释]
select stdev(a) from tb where b between .. and ..
[其他解释]

引用:
select stdev(a) from tb where b between .. and ..



如果现在希望把 select stdev(a) from tb where b between .. and .. 用于结果判断中怎么办?

就是 希望如 select a ,b from tb where a>( select stdev(a) from tb where b between .. and ..)
这种是一种办法,但是因为在判断条件中加了计算,貌似会重复计算很多次影响效率,请问有什么好的办法?
[其他解释]
select a ,b from
(select *,[st]=stdev(a)over() from tb where b between .. and ..) t
where a>[st]

读书人网 >SQL Server

热点推荐