cancel
Showing results for 
Search instead for 
Did you mean: 

'Sum' doesn't work properly.

former_member197081
Participant
0 Kudos

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 -

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member188011
Active Contributor
0 Kudos

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.