日期:2014-05-17  浏览次数:20573 次

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]