Skip to Content
0

'Sum' doesn't work properly.

May 04, 2017 at 08:16 PM

92

avatar image

We are having a sum aggregation in the SQL query, which gives the summation of a column (decimal). This column (col1) has 3 values - 0, 1, 0.5. When I am doing a sum on col1, it is not resulting the correct output.

Occurrence of the above values as follows -

0 - 2 (count), 0E-16 (SUM) <-- Which I believe is 0

1- 16941 (count), 16794 (SUM) <-- This should be 16941

0.5 - 324 (count), 162 (sum)

Sum(col1) - 17120

Expected - 17103.

I have taken the individual sum and count for all above occurrences (using where clause)

col1 is a calculated column, which converts the data type length of another column (col) from decimal (38,16) to decimal (28,16). Interestingly when I am doing Sum(col), I am getting 17103.

Calculated column -

capture.jpg (140.4 kB)
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Francisco Milán Campos May 15, 2017 at 06:10 PM
0

Hi Deba,

Try setting to 1 (instead of 16) the scale of the calculated column "COL1" and let us know the results.

Best regards,

Francisco.

Share
10 |10000 characters needed characters left characters exceeded