Friday, March 30, 2012

problem with calculating sum of large nos

hello all
i am calculating sum of very large nos using sum function of SQL. but the final result i get is incorrect. i am using SQL server 2000.
like value of a field(cost) is calculated by multiplying .0018 to other fields (no of units)
the sum of (no of units) is 140374
but when i calculate the sum of (cost) it comes to 273.1600 which is incorrect \.
it shud have been 140374 * .0018
It is really difficult to pinpoint any problem with the information you provide. How does the actual query look like? What datatypes are used in the table?|||just for fun. . . .
Given the table is called UnitTable try this query:

select cast(.0018 as decimal(4,4)) * cast(sum([no of units]) as decimal(14,4)) from UnitsTable

does that give the right answer?

No comments:

Post a Comment