Skip to Content
0
Oct 05, 2016 at 06:14 PM

Rounding bug in Query when doing aggregate function?

24 Views

Hi, I have this query:

SELECT T1.[ItemCode], T1.[ItemName], T1.[AvgPrice], SUM(T0.[InQty]-T0.[OutQty]) as 'NetQty', SUM(T2.[TransValue]) as 'Amount'

FROM OIVL T0 INNER JOIN OITM T1 ON T0.ItemCode = T1.ItemCode

INNER JOIN IVL1 T2 ON T0.[TransSeq] = T2.[TransSeq]

WHERE (T0.[DocDate] >= '[%1]'/*i:FromDate*/ OR '[%1]'/*i:FromDate*/ ='') AND (T0.[DocDate] <= '[%2]'/*i:ToDate*/ OR '[%2]' = '')

GROUP BY T1.[ItemCode], T1.[ItemName],T1.[AvgPrice] order by T1.itemcode

If I run this, the "Amount" field is rounded (ie. no decimal points). I know it because I compare it with running it directly on SQL Management Studio.

The rounding doesn't happen if I don't use SUM and GROUP BY.

Is this a bug? If not, how to solve/change the setting?

Thanks