getting different results

Casperov

Registered User.
Local time
Today, 14:08
Joined
Nov 15, 2004
Messages
18
Hello,

I am trying to figure out why I am getting different results, when I run some queries.

The first one I am summing all the positive values with a sum of 7061.13.

SELECT Sum(tblClass.Amount) AS SumOfAmount
FROM tblClass
HAVING (((tblClass.Amount)>0));

The first one I am summing all the negative values with a sum of - 7061.13.

SELECT Sum(tblClass.Amount) AS SumOfAmount
FROM tblClass
HAVING (((tblClass.Amount)<0));

The third query I am summing all the values for a value of -4.9880100050359E-12.

SELECT Sum(tblClass.Amount) AS SumOfAmount
FROM tblClass
HAVING (((tblClass.Amount)<>0));

What am I missing here?

Thanks,
Lee2004
 

Attachments

And never use HAVING whenever you can WHERE instead:

SELECT Sum(tblClass.Amount) AS SumOfAmount
FROM tblClass
WHERE tblClass.Amount>0;

And use FIX and INT instead of the ROUND function and this last function can result in unexpected results (as Microsoft apparently used some hidious accounting based rule for their definition on rounding).

RV
 

Users who are viewing this thread

Back
Top Bottom