SQL Language (MOSC)

MOSC Banner

SQL Query to Calculate the Balance from the Debit & Credit.

edited Jul 8, 2010 1:35AM in SQL Language (MOSC) 8 commentsAnswered
 Hi,
This is the o/p for the below SQL Query. We want to calculate the BALANCE from the DEBIT & CREDIT below. What query I should use to get an dditional BALANCE column:

TXN_ACC TRN_DT PROD DEBIT CREDIT
-------------------- ----------- ---- ---------- ----------
001102USD0000148 01-DEC-2008 CHDP 5000
001102USD0000148 02-DEC-2008 CHWL 20263.42
001102USD0000148 02-DEC-2008 BCSA 100
001102USD0000148 02-DEC-2008 TTSA 100
001102USD0000148 02-DEC-2008 CHWL 500000
001102USD0000148 02-DEC-2008 CHDP 1000000
001102USD0000148 03-DEC-2008 DDSA 100
001102USD0000148 03-DEC-2008 DDSA 100

SELECT
A.TXN_ACC,A.TRN_DT,A.PRODUCT_CODE,
DECODE(B.DRCR_IND,'D',A.TXN_AMOUNT,NULL) DEBIT,
DECODE(B.DRCR_IND,'C',A.TXN_AMOUNT,NULL) CREDIT
FROM

Howdy, Stranger!

Log In

To view full details, sign in to My Oracle Support Community.

Register

Don't have a My Oracle Support Community account? Click here to get started.

Category Leaderboard

Top contributors this month

New to My Oracle Support Community? Visit our Welcome Center

MOSC Help Center