首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > oracle >

start with connect by prior,该怎么解决

2013-09-06 
start with connect by prior SELECT CBD.ID,level levels,(CASE WHEN LEAD(level) OVER(ORDER BY rowNum)

start with connect by prior

 SELECT CBD.ID,
                                                        level levels,
                                                         (CASE WHEN LEAD(level) OVER(ORDER BY rowNum) > level THEN '1' ELSE '0' END) isLeaf
                                                  FROM PRODUCT_TYPE CBD
                                                       where CBD.company_id  is null or CBD.company_id='C4FCAEEF63ED9F03E040860A50826BB5'
                                                       START WITH CBD.ID ='C4FE7B67ED2877A3E040860A5082732F'
                                                       CONNECT BY PRIOR CBD.ID = CBD.PRODUCT_PARENT_TYPE 
                                                   )typeTree
                                                   WHERE  1=1 and typeTree.levels =(


                                                   case when typeTree.isLeaf='0' and typeTree.levels='1'
                                                   then  '1' else   '2'  end
                                                   )
                                                   


同一个表中存在多层父子关系例如 a->b->c->d
查询B节点时 需要把 C 和D同事查出来  
求指教start with connect by prior,该怎么解决
[解决办法]
start with 从B开始不就行了么?
[解决办法]
对啊,start with B 的条件不行吗?

热点排行