日期:2014-05-18 浏览次数:20676 次
select A.sl_qm ,B.sl_qm ,C.dj_min ( select a.bm_gsjg, a.bm_ck, a.bm_sp, a.mc, a.dj_ls,a.sl_qm from v_zb_kc_draft a left join t_bm_splimit b on a.bm_gsjg = b.bm_gsjg and a.bm_ck = b.bm_ck and a.bm_sp = b.bm_sp and is_kc = 1 Where 1 = 1 And isnull(a.bm_gsjg,'') like 'CYZ' and sl_qm > 0 and a.bm_sp like 'DPZBZD001%' --ORDER BY a.bm_gsjg,a.bm_ck,a.bm_sp ) A left join ( select bm_gsjg, bm_ck, bm_sp, mc, dj_ls, sl_qm from v_zb_kc Where is_kc = 1 And isnull(bm_gsjg,'') like 'CYZ' And isnull(bm_sp,'') like 'DPZBZD001%' --ORDER BY bm_gsjg,bm_ck,bm_sp ) B on A.bm_gsjg=bm_gsjg. and A.bm_ck=B.bm_ck and A.bm_sp=B.bm_sp and A.mc=B.mc ( SELECT t_bm_spdj.bm_sp, t_bm_spdj.dj_ls, t_bm_sp.dj_min FROM t_bm_spdj, t_bm_sp WHERE t_bm_spdj.bm_sp = t_bm_sp.bm and ( t_bm_spdj.bm_sp = 'DPZBZD001' ) and bm_gsjg = '' and bm_ck = '' and bzgg = 0 ) C on A.bm_sp=C.bm_sp ORDER BY a.bm_gsjg,a.bm_ck,a.bm_sp
------解决方案--------------------
select A.sl_qm ,B.sl_qm ,C.dj_min ( select a.bm_gsjg, a.bm_ck, a.bm_sp, a.mc, a.dj_ls,a.sl_qm from v_zb_kc_draft a left join t_bm_splimit b on a.bm_gsjg = b.bm_gsjg and a.bm_ck = b.bm_ck and a.bm_sp = b.bm_sp and is_kc = 1 Where 1 = 1 And isnull(a.bm_gsjg,'') like 'CYZ' and sl_qm > 0 and a.bm_sp like 'DPZBZD001%' --ORDER BY a.bm_gsjg,a.bm_ck,a.bm_sp ) A left join ( select bm_gsjg, bm_ck, bm_sp, mc, dj_ls, sl_qm from v_zb_kc Where is_kc = 1 And isnull(bm_gsjg,'') like 'CYZ' And isnull(bm_sp,'') like 'DPZBZD001%' --ORDER BY bm_gsjg,bm_ck,bm_sp ) B on A.bm_gsjg=bm_gsjg. and A.bm_ck=B.bm_ck and A.bm_sp=B.bm_sp and A.mc=B.mc left join ( SELECT t_bm_spdj.bm_sp, t_bm_spdj.dj_ls, t_bm_sp.dj_min FROM t_bm_spdj, t_bm_sp WHERE t_bm_spdj.bm_sp = t_bm_sp.bm and ( t_bm_spdj.bm_sp = 'DPZBZD001' ) and bm_gsjg = '' and bm_ck = '' and bzgg = 0 ) C on A.bm_sp=C.bm_sp ORDER BY a.bm_gsjg,a.bm_ck,a.bm_sp
------解决方案--------------------
select
a.sl_qm,b.sl_qm,c.dj_min
from
(select a.bm_gsjg, a.bm_ck, a.bm_sp, a.mc, a.dj_ls,a.sl_qm from v_zb_kc_draft a left join t_bm_splimit b on a.bm_gsjg = b.bm_gsjg and a.bm_ck = b.bm_ck and a.bm_sp = b.bm_sp and is_kc = 1 Where 1 = 1 And isnull(a.bm_gsjg,'') like 'CYZ' and sl_qm > 0 and a.bm_sp like 'DPZBZD001%')a
left join
(select bm_gsjg, bm_ck, bm_sp, mc, dj_ls, sl_qm from v_zb_kc Where is_kc = 1 And isnull(bm_gsjg,'') like 'CYZ' And isnull(bm_sp,'') like 'DPZBZD001%')b
on
a.bm_gsjg=b.bm_gsjg,a.bm_ck=b.bm_ck,a.bm_sp=b.bm_sp,a.mc=.mc
left join
(SELECT t_bm_spdj.bm_sp, t_bm_spdj.dj_ls, t_bm_sp.dj_min FROM t_bm_spdj, t_bm_sp WHERE t_bm_spdj.bm_sp = t_bm_sp.bm and ( t_bm_spdj.bm_sp = 'DPZBZD001' )