首页 > 代码库 > 用SYS_CONNECT_BY_PATH进行层级查询时的排序问题
用SYS_CONNECT_BY_PATH进行层级查询时的排序问题
用SYS_CONNECT_BY_PATH进行层级查询时, 对同一级别的节点进行排序,可以加order SIBLINGS by 子句实现
WITH N2 AS( SELECT n.ID, org."ParentID", n."NodeName", n."Sort" FROM "Organize" org LEFT JOIN "Node" n ON n."ID"=org."NodeID" WHERE n."DeleteTime" IS NULL AND n."RefreshTime" is NULL ORDER BY "ParentID", "Sort" ASC) SELECT "ID", "ParentID", "NodeName", SYS_CONNECT_BY_PATH("ID",‘\‘) ID_PATH, SYS_CONNECT_BY_PATH("NodeName",‘\‘) NAME_PATH, LEVEL, "Sort" FROM N2 START WITH "ParentID"=‘#‘ OR "ParentID" IS NULL CONNECT BY PRIOR "ID"="ParentID" order SIBLINGS by "Sort" ASC
参考文献:https://asktom.oracle.com/pls/apex/f?p=100:11:0::::P11_QUESTION_ID:1154964870586
用SYS_CONNECT_BY_PATH进行层级查询时的排序问题
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。