所以取12個月出來
select lpad(level,2,0) from dual
connect by level<13
至於怎麼左連接,拿出一個例子來先放到這裏
select * from (select lpad(level,2,0) month from dual
connect by level<13 ) q,
(select SUBSTR(cbrq,0,6) nd ,sum(ygzdl) from v_zsb_bds_yddl a
inner join t_xtwh_bds_jld b
on a.bjbh = b.bdsckbm
inner join t_xtwh_zsdj_jld c
on b.jldbm = c.jldbm
inner join t_xtwh_zsdj_jbxx d
on c.zsdjid = d.billid
where d.billid ='' and SUBSTR(cbrq,0,4) = ''
group by SUBSTR(cbrq,0,6)
order by SUBSTR(cbrq,0,6) ) b
where q.month = SUBSTR(b.nd(+),4,2)
order by q.month