Home » SQL & PL/SQL » SQL & PL/SQL » Numerical calculation problem...
Numerical calculation problem... [message #761] Sat, 02 March 2002 03:05 Go to next message
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..
Re: Numerical calculation problem... [message #762 is a reply to message #761] Sat, 02 March 2002 12:47 Go to previous message
JOHN
Messages: 182
Registered: April 1998
Senior Member
I got bye basically reversing the previousbalance with

(-(previousbalance) + currentdebit - currentcredit)

thanks anyway
Previous Topic: Table Space Name
Next Topic: Multi-Selection: Urgent
Goto Forum:
  


Current Time: Thu Mar 28 11:54:34 CDT 2024