multiple join HOW to get the following result? I would like to get the following result. I have tried with the following scripts to get TAB1 and TAB2 but I couldn't show up the result like that.

This is my code for TAB1:

select branch_code,ABS(nvl(sum(cr_bal_lcy - dr_bal_lcy), 0)) as A35
         from gltb_gl_bal_daily
        where gl_code in ('620100000',
                          '620230000',
                          '620400000',
                          '620800000',
                          '620910000',
                          '620930000',
                          '621010000',
                          '621020000',
                          '630000000')
          AND trn_dt = &amp;PM_DATE --entry
        group by branch_code  ;  


Resultset:

--------TAB1-------------
id      Amount
-------------------------
1       5791920.396
2       4900
3       103.95
4       4420.265
5       46.2
6       23.1
7       500
8       0.03


and this is script for TAB2:

select branch_code,ABS(nvl(sum(cr_bal_lcy - dr_bal_lcy), 0)) as A35
                 from fcubs1203.gltb_gl_bal_daily
                where gl_code in ('620820000', '630300000')
                  AND trn_dt = &amp;PM_DATE
                  group by branch_code;


Resultset:

--------TAB2-------------
1       593023.5


===> this is the desired result that i would like to show:

--------Result-----------
1       5198896.896  (TAB1.id-TAB2.id)
2       4900
3       103.95
4       4420.265
5       46.2
6       23.1
7       500
8       0.03
Simply join those two queries:

with tab1 as (
  select branch_code,
         ABS(nvl(sum(cr_bal_lcy - dr_bal_lcy), 0)) as A35
  from gltb_gl_bal_daily
  where gl_code in ('620100000','620230000','620400000','620800000',
                    '620910000','620930000','621010000','621020000',
                    '630000000')
    AND trn_dt = &amp;PM_DATE --entry
  group by branch_code  
), tab2 as (
  select branch_code,
         ABS(nvl(sum(cr_bal_lcy - dr_bal_lcy), 0)) as A35
  from fcubs1203.gltb_gl_bal_daily
  where gl_code in ('620820000', '630300000')
  AND trn_dt = &amp;PM_DATE
  group by branch_code
)
select tab1.branch_code, tab1.a35 - coalesce(tab2.a35, 0)
from tab1
  left join tab2 on tab1.branch_code = tab2.branch_code;