首页 > 开发 > 综合 > 正文

树型结构数据的客户部门SQL显示语句(纯sql语句)

2024-07-21 02:11:56
字体:
来源:转载
供稿:网友
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
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表