Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calculating Standard Deviation

Status
Not open for further replies.

Toga

Technical User
Jul 21, 2000
234
US
It appears Sybase does not have a built in function for calulating Standard Deviation. Does anyone have a stored procedure that does this or know the proper SQL to obtain the standard deviation of some data?

We're using Sybase 11, if that matters.
 
Here's what I ended up with.....if anyone else ever needs to do this.

select

(SQRT((sum((MyFieldName - (select convert(dec(10,2),avg(MyFieldName))From MyTableNameWhere MyWhereCriteria and abs(MyFieldName)>0))*(MyFieldName - (select convert(dec(10,2),avg(MyFieldName))From MyTableNameWhere MyWhereCriteria and abs(MyFieldName)>0)))) /(select count(MyFieldName)-1 from MyTableNamewhere MyWhereCriteria))) 'StDev'

from MyTableNameWHERE MyWhereCriteria

It matches exactly with what you get from excel or something like that.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top