去掉部分重复

来源:互联网 发布:java中public方法 编辑:程序博客网 时间:2024/06/06 04:13


 select tt.USERID,tt.USERNAME,
 (select unitname from ow_org_uint where unittreecode = substr(tt.unittreecode,1,12)) unit1,
(select unitname from ow_org_uint where unittreecode = substr(tt.unittreecode,1,16)) unit2,
(select unitname from ow_org_uint where unittreecode = substr(tt.unittreecode,1,20) and length(tt.unittreecode)>=20) unit3
 from 
 (select t1.USERID,t1.USERNAME,t3.UNITNAME,t3.unittreecode, DENSE_RANK() OVER(partition by t1.USERID, t1.USERNAME order by t3.UNITNAME) num 
 from ow_org_user t1,ow_org_uint_user t2, ow_org_uint t3 where t1.userid = t2.userid and t2.unitid = t3.unitid and t3.unittreecode 
 like (select unittreecode from ow_org_uint where unitid = '29CA558479AB94D30C5CDFE20E781452')||'%' and iszw='1') tt where tt.num = 1
 
0 0