|
Select sum(nvl(a.amt, 0)) amt1,
sum(nvl(b.amt, 0)) amt2,
sum(nvl(a.amt, 0)) - sum(nvl(b.amt, 0)) amt3,
nvl(curbal, 0) amt4,
ORIGINALBAL amt5,
curbal amt6,
endbal amt7,
t.Account,
t.ctrlid,
t.bdglevel,
m.account oriaccount
From t_glbdgctrl t,
t_glrecord a,
t_glrecordbdg b,
(Select Distinct ctrlid, account
From (Select case
when b.amt > 0 then
a.fromctrlid
else
a.toctrlid
end ctrlid,
nvl(b.account, 0) account
From T_PLANMAIN a,
(select * from t_glrecord where dc = -1) b
Where a.billid = b.objectid(+)
And a.vchtypeid = b.vchtypeid(+)
and a.billid = 341923
and a.vchtypeid = 15)) m
Where t.ctrlid = m.ctrlid
And (t.ctrlid = a.ctrlid And a.dc = -1 And a.recid = b.recid(+))
Group By t.Originalbal,
t.Curbal,
t.Endbal,
t.Account,
t.Ctrlid,
t.Bdglevel,
m.Account |
|