Oracle检索12个月

从oracle中检索12个月出来,做报表经常用得到,一个年度的12个月的数据,为了防止他一天的数据也没有。只好用12个月固定的去左连接。
所以取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

你可能感兴趣的:(oracle,sql,C++,c,C#)