Last post Nov 24, 2016 02:54 AM by wmec
Nov 23, 2016 09:53 AM|acmedeepak|LINK
Hi,In my query I am using SUM and CAST methods to retrieve a calculated data from DB but the problem is, I get a wrong output. I get some extra number comparing to the existing data. My query is:
select SUM(Qty)as TotalQty, cast(SUM(Qty*Cost) as decimal(14,2)) as Total from IC_Inventory_T where Invy_Num = 'INV918'
But the total which is coming is not accurate though. The value is 29044.00 where it should be 28949.48. The value that returns is not accurate. Can anyone help me in this.
Nov 24, 2016 02:54 AM|wmec|LINK
select SUM(Qty)as TotalQty, cast(SUM(CAST(Qty as decimal(14,4))*cast(Cost as decimal(14,4))) as decimal(14,2)) as Total from IC_Inventory_T where Invy_Num = 'INV918'
You can define relevant columns as Decimal(16,4).