Icon View Incident Report

Serious Serious
Reported By: Mario Enriquez
Reported On: 1/21/2016
For: Version 2.21 Build 1
# 4355 SQL STDDEV Function Not Working Correctly with DECIMAL/NUMERIC Columns

I've found a difference between the implementation of the standard deviation function of EDB and a regular spreadsheet.

Here's an example.

Data:

Month Score
----------------------
1 69.13
2 90.22
3 25.31
4 50.40
5 73.59
6 88.68
7 36.77
8 61.86
9 90.95
10 79.13
11 37.13
12 18.12

If I run the follow query on EDB...

SELECT AVG(score), STDDEV(score) FROM Scores

I get this result..

Avg stddev
--------- -------
60.11 260125.431719532

However if same data is calculated through a spreadsheet the result would be the following..

Avg stddev
--------- -------
60.1075 26.0125431719532

CREATE TABLE "Scores"
(
"id_score" GUID COLLATE "UNI" DEFAULT CURRENT_GUID,
"month" INT NOT NULL,
"score" DECIMAL(19,2) NOT NULL,
CONSTRAINT "pk_id_score" PRIMARY KEY ("id_score")
)!

INSERT INTO Scores (month, score) VALUES (1, 69.13)!
INSERT INTO Scores (month, score) VALUES (2, 90.22)!
INSERT INTO Scores (month, score) VALUES (3, 25.31)!
INSERT INTO Scores (month, score) VALUES (4, 50.40)!
INSERT INTO Scores (month, score) VALUES (5, 73.59)!
INSERT INTO Scores (month, score) VALUES (6, 88.68)!
INSERT INTO Scores (month, score) VALUES (7, 36.77)!
INSERT INTO Scores (month, score) VALUES (8, 61.86)!
INSERT INTO Scores (month, score) VALUES (9, 90.95)!
INSERT INTO Scores (month, score) VALUES (10, 79.13)!
INSERT INTO Scores (month, score) VALUES (11, 37.13)!
INSERT INTO Scores (month, score) VALUES (12, 18.12)!

SELECT AVG(score), STDDEV(score) FROM Scores



Comments Comments
The problem was with the way that the internal standard deviation calculations were being made, specifically a typecast from an internal Delphi Currency type to a Double type was causing decimal places to shift.


Resolution Resolution
Fixed Problem on 1/22/2016 in version 2.22 build 1


Products Affected Products Affected
ElevateDB Additional Software and Utilities
ElevateDB DAC Client-Server
ElevateDB DAC Client-Server with Source
ElevateDB DAC Standard
ElevateDB DAC Standard with Source
ElevateDB DAC Trial
ElevateDB LCL Standard with Source
ElevateDB PHP Standard
ElevateDB PHP Standard with Source
ElevateDB PHP Trial
ElevateDB VCL Client-Server
ElevateDB VCL Client-Server with Source
ElevateDB VCL Standard
ElevateDB VCL Standard with Source
ElevateDB VCL Trial

Image