---
title: "利用sql树查询获得树上的叶子节点"
author: "fourfire"
date: "2006-12-23T21:08:13Z"
tags: []
slug: "sql"
draft: false
lastmod: "2006-12-23T21:08:13Z"
id: 40441
url: "https://fourfire.iteye.com/blog/40441"
---

如下

sql 代码

 

1. SELECT ond.parentid as id
2. FROM orgnode ond where ond.flag = 1
3. START WITH ond.id=1
4. CONNECT BY PRIOR ond.id = ond.parentid
5. group by ond.parentid
6. having  COUNT(\*)=1