标签:树 sql 末级节点
目标:显示所有末级节点
思路:
根据父节点count数,判断是否有子节点
源码sql
select t."CLASS_CODE",t."CLASS_NAME",t."FATHER_CLASS_CODE",t."CLASS_STATE",t."OP_USER",t."OP_TIME",t."IS_PROJECT",nvl(t2.isParent,0) isParent from FSS_PROJECT_CLASS t LEFT JOIN ( SELECT count(1) isParent,FATHER_CLASS_CODE from FSS_PROJECT_CLASS GROUP BY FATHER_CLASS_CODE ) t2 on t.CLASS_CODE = T2.FATHER_CLASS_CODE;
根据isParent就可以判断所有的末级节点
where isParent=0;
就ok了。
标签:树 sql 末级节点
原文地址:http://zl0828.blog.51cto.com/2242565/1904011