Re: How do I write this query?
From: Ralf <db.2.gemini_at_spamgourmet.com>
Date: 16 Jun 2003 22:35:30 -0700
Message-ID: <51a9e702.0306162135.42b6757a_at_posting.google.com>
6 ;
Date: 16 Jun 2003 22:35:30 -0700
Message-ID: <51a9e702.0306162135.42b6757a_at_posting.google.com>
Hello Bliss,
try
SQL> SELECT ac_date DAT 2 ,ac_debit debit 3 ,ac_credit credit 4 ,sum(ac_debit-ac_credit) OVER (ORDER BY ac_date) balance5 FROM t1
6 ;
DAT DEBIT CREDIT BALANCE 01.06.03 10000 6000 4000 02.06.03 2000 1500 4500 05.06.03 20000 15000 9500 07.06.03 30000 0 39500 08.06.03 0 1000 38500;
Analytic functions are cool.
hth
Ralf
> 2nd format
> Date Debit Credit Balance
> 01-Jun-2003 10000 6000 4000 (10000-6000)
> 02-Jun-2003 2000 1500 4500 (4000 i.e. previous
> balance + 2000-1500)
> 05-Jun-2003 20000 15000 9500 (4500+20000-15000)
> 07-Jun-2003 30000 0 39500 (9500+30000-0)
> 08-Jun-2003 0 1000 38500 (39500+0-1000)
>
> How do I write an SQL Query to arrive at the above 2nd format?
>
> Thanks in advance
> Bliss
Received on Tue Jun 17 2003 - 07:35:30 CEST