select ebalance,sum(ebalance) over(partition by fnbr) as total,fnbr,cdate,
(case when bb=0 then 0 else sum(ebalance) over(partition by fnbr order by cdate
)+bb
end)as gtotal
from mmfclientbalance,
(select sum(ebalance) as bb from mmfclientbalance
where trunc(cdate) = (select max(trunc(cdate))
from mmfclientbalance
where trunc(cdate) < to_date('Dec 19, 2002','Mon dd, yyyy')
AND cid= '10189'AND aNbr = '10000000000000000187'))bbal
WHERE trim(cddate)
BETWEEN to_date('Dec 19, 2002','Mon dd, yyyy') AND to_date('Dec 21, 2002','Mon dd, yyyy')
and cid= '10189'
AND aNbr = '10000000000000000187'



EBALANCE TOTAL FNBR CDAte GTOTAL
---------- ---------- -------- --------- ----------
100000 100000 102 21-DEC-02 300000
300000 700000 103 19-DEC-02 500000
400000 700000 103 21-DEC-02 900000
200000 500000 104 19-DEC-02 400000
300000 500000 104 21-DEC-02 700000



iwant the above qry to return the values as follows that is between 19 and 21 data to be summed up in a cumulated manner
if no data is there in date of that column then it has to forward the previous balance.that is for eg.

for 102 21-dec-02 balance is 100000 no 19 or 20 is there so before this date any record is there with ebalance it has
to forward and summed up thatis i have 18 dec 200000 + 21-dec 100000 to be 300000. next with fnbr for 103 19 dec300000 is
there it has to forward to 20 dec 21 4000000 ihave that is i should get the sum cumulatevely as 10,00,000 for fnbr 103 and so
on how can we write this qry i tried with all analytical functions but iam not getting can u plz tell me.