Skip to Content

'Sum' doesn't work properly.

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)
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • May 15, 2017 at 06:10 PM

    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.

    Add comment
    10|10000 characters needed characters exceeded