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 -

## Add comment