Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase 123»»»

Standard Deviation Expand / Collapse
Author
Message
Posted Thursday, January 27, 2011 9:42 PM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Saturday, June 14, 2014 5:28 PM
Points: 341, Visits: 200
Comments posted to this topic are about the item Standard Deviation


Post #1055069
Posted Friday, January 28, 2011 12:08 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 3:55 PM
Points: 13,357, Visits: 10,222
Nice question, really learned something.
The BOL page doesn't even mention this subject.




How to post forum questions.
Need an answer? No, you need a question.
What’s the deal with Excel & SSIS?

Member of LinkedIn. My blog at LessThanDot.

MCSA SQL Server 2012 - MCSE Business Intelligence
Post #1055112
Posted Friday, January 28, 2011 1:24 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Tuesday, July 22, 2014 2:49 AM
Points: 1,179, Visits: 783
I think the Explanation is bit confusing.

if you give any numeric value to the function without any from clause it will give NULL.
SELECT STDEV(100)

"The STDEV function uses all of the values to calculate the standard deviation. There must be at least two values in the field or the standard deviation will not be calculated and a NULL is returned."

example in my PackageTable the standard deveation of pa_rates column can find using

select stdev(pa_Rates) From Package

for the above Query i will get some result

but if i cange the Query with some where condition,where i will get only one Row (sample) then the stdevp will results the null value

select stdev(pa_Rates) From Package where pa_PackageID = 1

Post #1055141
Posted Friday, January 28, 2011 1:34 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 3:55 PM
Points: 13,357, Visits: 10,222
sharath.chalamgari (1/28/2011)

but if i cange the Query with some where condition,where i will get only one Row (sample) then the stdevp will results the null value

select stdev(pa_Rates) From Package where pa_PackageID = 1



The WHERE clause is executed first, so you are still calculating the variance over 1 row, hence the NULL.




How to post forum questions.
Need an answer? No, you need a question.
What’s the deal with Excel & SSIS?

Member of LinkedIn. My blog at LessThanDot.

MCSA SQL Server 2012 - MCSE Business Intelligence
Post #1055144
Posted Friday, January 28, 2011 1:45 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Tuesday, July 22, 2014 2:49 AM
Points: 1,179, Visits: 783
Koen (da-zero) (1/28/2011)
sharath.chalamgari (1/28/2011)

but if i cange the Query with some where condition,where i will get only one Row (sample) then the stdevp will results the null value

select stdev(pa_Rates) From Package where pa_PackageID = 1



The WHERE clause is executed first, so you are still calculating the variance over 1 row, hence the NULL.


Ya that's what i have explained above.
Post #1055148
Posted Friday, January 28, 2011 1:50 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 3:55 PM
Points: 13,357, Visits: 10,222
sharath.chalamgari (1/28/2011)
Koen (da-zero) (1/28/2011)
sharath.chalamgari (1/28/2011)

but if i cange the Query with some where condition,where i will get only one Row (sample) then the stdevp will results the null value

select stdev(pa_Rates) From Package where pa_PackageID = 1



The WHERE clause is executed first, so you are still calculating the variance over 1 row, hence the NULL.


Ya that's what i have explained above.


Then why is the explanation confusing? I find it pretty clear...




How to post forum questions.
Need an answer? No, you need a question.
What’s the deal with Excel & SSIS?

Member of LinkedIn. My blog at LessThanDot.

MCSA SQL Server 2012 - MCSE Business Intelligence
Post #1055150
Posted Friday, January 28, 2011 2:01 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Monday, July 28, 2014 9:56 PM
Points: 2,270, Visits: 3,781
Thanks for introducing new topic. I had not heard about it before

Mohammed Moinudheen
Post #1055152
Posted Friday, January 28, 2011 2:09 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Friday, July 25, 2014 3:01 AM
Points: 20, Visits: 113
I do not agree that the answer is right.
Think it is supposed to be 0.

the standard deviation σ (sigma) is the square root of the average value of (X − μ)2.

Which means σ = sqrt(((1-1)^2)/1) = 0

Or in other words std. deviation equals sqrt of (population-avarage) sq / number of population values

Please correct me if im wrong on the formula it has been a while since i used my statistics
Post #1055158
Posted Friday, January 28, 2011 2:34 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 3:55 PM
Points: 13,357, Visits: 10,222
mdv 9731 (1/28/2011)
I do not agree that the answer is right.
Think it is supposed to be 0.

the standard deviation σ (sigma) is the square root of the average value of (X − μ)2.

Which means σ = sqrt(((1-1)^2)/1) = 0

Or in other words std. deviation equals sqrt of (population-avarage) sq / number of population values

Please correct me if im wrong on the formula it has been a while since i used my statistics


Even if your statistics say it is 0, SQL Server returns NULL, so the answer is still correct.
You can verify it by running the query in SQL Server Management Studio.




How to post forum questions.
Need an answer? No, you need a question.
What’s the deal with Excel & SSIS?

Member of LinkedIn. My blog at LessThanDot.

MCSA SQL Server 2012 - MCSE Business Intelligence
Post #1055166
Posted Friday, January 28, 2011 2:50 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Friday, July 25, 2014 3:01 AM
Points: 20, Visits: 113
I'm not really going to comment on that answer.
Just happy you are not creating any kind of BI og reporting in our company

I might be wrong but i still question the result.
Even if i know that it doesnt make much practical sence to talk deviation on 1 value.
Post #1055177
« Prev Topic | Next Topic »

Add to briefcase 123»»»

Permissions Expand / Collapse