Question

I have run the StDev function in both MS Access and SQL Server with the same exact data. The two pieces of data 2.32 and 2.32 should result in a StDev of 0, the result which SQL Server generates. MS Acccess generates the following result however... 4.2146848510894E-08. This poses serious issues for my database logic, but I'm not interested on how to fix it but rather if anyone else has run into similar issues and if anyone knows why these calculate different results?

Was it helpful?

Solution

The StDev() function returns a Double value, so you'll have to account for floating-point error if you use those values in expressions that perform comparisons. Specifically, you should never use Double values when checking for exact equality (e.g., myStDevValue=0). Instead you should either check for

  • values that are "close enough" to be considered equal,

or, for the particular case of a Standard Deviation

  • values that are sufficiently larger (or smaller) than a specified fraction of the Mean to be considered significant (or insignificant).

OTHER TIPS

First, make sure that you're using the appropriate data types in both systems.

Second, you're probably running into the same precision issues that MS Excel faces. See this discussion, this MS Support article, and a detailed explanation on Wikipedia.

Why the difference? The two systems are developed to different specifications & requirements.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top