Frage

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?

War es hilfreich?

Lösung

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).

Andere Tipps

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.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top