Numerical calculation problem... [message #761] |
Sat, 02 March 2002 03:05 |
JOHN
Messages: 182 Registered: April 1998
|
Senior Member |
|
|
I have to write an sql statement to come up with a user's current balance. I have customerbalance.previousbalance, customerbalance.currentdebit and customerbalance.currentcredit
Now my problem is that the previousbalance column is written as a (negative) -20.05 if the customer owes money and (positive) 20.05 if say they've overpaid and have a credit. yet the currentdebit (which is the current charges trying to be put on the customers account) is written as a (positive) 20.05. So if the table was to look like this:
previousbalance currentdebit currentcredit
-20.05 20.05 0
then he should now have a balance of 40.10 (not 0.00)
so at first I thought to do abs(previousbalance + currentdebit) but if it's like this:
previousbalance currentdebit currentcredit
20.05 20.05 0.
then now he should have a 0.00 balance and abs() will not work cause it would yield 40.10! Any suggestions are very much wanted/welcome..
|
|
|
|