日期:2014-05-17  浏览次数:20671 次

求助oracle查询:
数据表中现有的数据为(见下图):

现在要取出最后一级编码的字段dirProperty值为'02'(制度目录) 的所有父级编码,
查询结果应为下图列表:

也就是不属于“制度目录”的所有同级和上级不需显示。
数据表为kbm_dir,当前的条件是dirProperty='02'
谢谢!

------解决方案--------------------

------解决方案--------------------
用distinct去掉重复的不行吗:

select * from (
select distinct id, title, cod, pid, dirtyp, dirProperty From kbm_dir where trade = '00' 
Start With dirProperty ='02' 
Connect By prior pid = id 
Order Siblings By ord
)order by cod;