哪位大神帮我看看这个语句怎么写的,看半天没懂
select ddzb.f_zlkz,ddzb.f_djh,ddzb.f_ddlx,ddzb.f_rhbm f_chbm,case when ddzb.f_ddlx in ('3','4') then bm.f_bmmc when ddzb.f_ddlx='5' then cs.f_csmc end f_chmc
from tbspddzb ddzb
left join tbbmda bm on ddzb.f_rhbm=bm.f_bmbm
left join tbcsda cs on ddzb.f_rhbm=cs.f_csbm
,tb201211_bcdd bcdd where ddzb.f_djh=bcdd.f_ddh and ddzb.f_ddlx=bcdd.f_ddlx and bcdd.f_bch='201211290004' rhbm on cb.f_djh=rhbm.f_djh and cb.f_ddlx=rhbm.f_ddlx,tb201211_bcdd bcdd,tbspda sp Left join tbsptm tm on sp.f_spbm=tm.f_spbm
and f_zjdw=1
where cb.f_djh=bcdd.f_ddh and cb.f_ddlx=bcdd.f_ddlx and cb.f_spbm=sp.f_spbm and bcdd.f_bch='201211290004'
select ddzb.f_zlkz,ddzb.f_djh,ddzb.f_ddlx,ddzb.f_rhbm f_chbm,case when ddzb.f_ddlx in ('3','4') then bm.f_bmmc when ddzb.f_ddlx='5' then cs.f_csmc end f_chmc
from tbspddzb ddzb
left join tbbmda bm
on ddzb.f_rhbm=bm.f_bmbm
left join tbcsda cs on ddzb.f_rhbm=cs.f_csbm ---此处之前的代码构成了一个”表“ 和逗号之后的tb201211_bcdd做inner join
,tb201211_bcdd bcdd where ddzb.f_djh=bcdd.f_ddh and ddzb.f_ddlx=bcdd.f_ddlx and bcdd.f_bch='201211290004' rhbm --逗号之后到这儿构成一个”表“ rhbm
on cb.f_djh=rhbm.f_djh and cb.f_ddlx=rhbm.f_ddlx,tb201211_bcdd bcdd,tbspda sp --第一个逗号之前的构成一个”表“,此处三表做inner join
Left join tbsptm tm on sp.f_spbm=tm.f_spbm
and f_zjdw=1
where cb.f_djh=bcdd.f_ddh and cb.f_ddlx=bcdd.f_ddlx and cb.f_spbm=sp.f_spbm and bcdd.f_bch='201211290004'