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同事查出来
求指教
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同事查出来
求指教
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货