select dpcode1 as dpcode,dpname1 as dpname from base_custdept where dpcode1>0 and dpcode2=0 and dpcode3=0 and dpcode4=0 union all select dpcode1+dpcode2 as dpcode,dpname1+dpname2 as dpname from base_custdept where dpcode1>0 and dpcode2>0 and dpcode3=0 and dpcode4=0 union all select dpcode1+dpcode2 +dpcode3 as dpcode,dpname1+dpname2+dpname3 as dpname from base_custdept where dpcode1>0 and dpcode2>0 and dpcode3>0 and dpcode4=0 union all select dpcode1+dpcode2 +dpcode3+dpcode4 as dpcode,dpname1+dpname2+dpname3+dpname4 as dpname from base_custdept where dpcode1>0 and dpcode2>0 and dpcode3>0 and dpcode4>0