1.我们的组织机构就是这种树形菜单的格式。

.

2.执行sql:

select
( select organization_name from SYS_ORGANIZATION where organization_id =x.organization_id) organization_name,
c.organization_id
from SYS_ORGANIZATION c, (select organization_id from SYS_ORGANIZATION where parent_id = '1') x where x.organization_id = c.organization_id or x.organization_id = c.parent_id start with c.organization_id =x.organization_id
connect by prior c.organization_id = c.parent_id

效果:

3.执行sql:

select organization_name,wmsys.wm_concat(organization_id ) organization_ids from
(select
( select organization_name from SYS_ORGANIZATION where organization_id =x.organization_id) organization_name,
c.organization_id
from SYS_ORGANIZATION c, (select organization_id from SYS_ORGANIZATION where parent_id = '1') x where x.organization_id = c.organization_id or x.organization_id = c.parent_id start with c.organization_id =x.organization_id
connect by prior c.organization_id = c.parent_id ) a group by organization_name

效果:

4.执行sql:

select a.organization_name,count(c.organization_id) sum from
(select organization_name,wmsys.wm_concat(organization_id ) organization_ids from
(select
( select organization_name from SYS_ORGANIZATION where organization_id =x.organization_id) organization_name,
c.organization_id
from SYS_ORGANIZATION c, (select organization_id from SYS_ORGANIZATION where parent_id = '1') x where x.organization_id = c.organization_id or x.organization_id = c.parent_id start with c.organization_id =x.organization_id
connect by prior c.organization_id = c.parent_id ) a group by organization_name ) a left join
(select c.clxxbh,c.organization_id from v_wfxx c left join BIZ_IMPORTANT_PLACES z on c.kkmc = z.place_name left join SYS_ORGANIZATION c on z.place_unit = c.organization_id) c
on instr(a.organization_ids,c.organization_id) > 0 group by a.organization_name

效果:

oracle查询父节点及其下所有子节点的更多相关文章

  1. postgre 查询同表中的,该节点写的所有子节点

    SELECT catalogid, foldername, parentid, folderpath FROM public.ic_catalog; --查询同表中的,该节点写的所有子节点 WITH ...

  2. JQuery/JS插件 jsTree加载树,预先加载,初始化时加载前三级节点,当展开第三级节点时 就加载该节点下的所有子节点

    jsTree加载树, 初始化时 加载前三级节点, 当展开第三级节点时 就加载该节点下的所有子节点 html: <!DOCTYPE html> <html> <head&g ...

  3. SQL查询父节点下的所有子节点(包括子节点下的子节点,无限子节点)

    -->Title:Generating test data -->Author:wufeng4552 -->Date :2009-09-30 08:52:38 set nocount ...

  4. easyui Tree模拟级联勾选cascadeCheck,节点选择,父节点自动选中,节点取消,父节点自动取消选择,节点选择,所有子节点全部选择,节点取消,所有子节点全部取消勾选

    最近项目中用到easyui tree,发现tree控件的cascadeCheck有些坑,不像miniui 的tree控件,级联勾选符合业务需求,所以就自己重新改写了onCheck事件,符合业务需求.网 ...

  5. mysql下如何删除本节点下的所有子节点小记

    在开发过程中,经常会遇到树形结构的数据,在删除某个节点时候其所有的子节点都要被删除,可以使用如下方法: 1.添加记录该节点所有父节点的ID的字段(parent_ids),并用逗号隔开(一定是逗号),如 ...

  6. sqlserver查询指定树形结构的所有子节点

    用标准sql的with实现递归查询(sql2005以上肯定支持,sql2000不清楚是否支持): with subqry(id,name,pid) as ( select id,name,pid fr ...

  7. Extjs4.x Ext.tree.Panel 遍历当前节点下的所有子节点

    Ext.define('WMS.controller.Org', { extend: 'Ext.app.Controller', stores: ['OrgUser', 'OrgTree'], mod ...

  8. MySQL中进行树状所有子节点的查询 . mysql根据父id 查询所有的子id

    在Oracle 中我们知道有一个 Hierarchical Queries 通过CONNECT BY 我们可以方便的查了所有当前节点下的所有子节点.但很遗憾,在MySQL的目前版本中还没有对应的功能. ...

  9. MySQL中进行树状所有子节点的查询

    在Oracle 中我们知道有一个 Hierarchical Queries 通过CONNECT BY 我们可以方便的查了所有当前节点下的所有子节点.但很遗憾,在MySQL的目前版本中还没有对应的功能. ...

随机推荐

  1. jquery判断输入框的字符串是否为空或者空格

    function checkKey(key) { if($.trim(key) == ''){ /** * 输入的字符串为空,空格 */ alert('请输入关键字'); return false; ...

  2. Logback 日志持久化

    Logback是log4j的增强版,比log4j更具灵活,其提供了将日志输出到数据库的功能,本文将介绍如何将指定的日志输出到mysql中. 一.自定义log标志 由于Logback原生的配置会将所有的 ...

  3. 【 js 基础 】为什么 call 比 apply 快?

    这是一个非常有意思的问题. 在看源码的过程中,总会遇到这样的写法: var triggerEvents = function(events, args) { var ev, i = -1, l = e ...

  4. layui数据表格的td模板

    1.常用操作模板 <script type="text/html" id="userbar"> <a class="layui-bt ...

  5. 【代码笔记】iOS-对数组进行排序

    一,代码. - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, ...

  6. Nginx控制并发连接数

    ngx_http_limit_conn_module这个模块用于限制每个定义的key值的连接数,特别是单IP的连接数. 不是所有的连接数都会被计数.一个符合计数要求的连接是整个请求头已经被读取的连接. ...

  7. sql语句查找某一列的值得最大值。

    记录一下:sql语句查找某一列的值得最大值. 1.例如我要查找 表A中a列的最大值: 查找语句可以这么写: "select Max(a) a from A" 2.查找表A中a列中包 ...

  8. Hibernate 注释用法

    注释 到现在为止,你已经看到 Hibernate 如何使用 XML 映射文件来完成从 POJO 到数据库表的数据转换的,反之亦然.Hibernate 注释是无需使用 XML 文件来定义映射的最新方法. ...

  9. 获取本地机器的特征码IP MAC

    using System; using System.Collections.Generic; using System.Text; using System.Net; using System.Ma ...

  10. 处理 Windows 虚拟机的计划内维护通知

    Azure 定期执行更新,以提高虚拟机的主机基础结构的可靠性.性能及安全性. 更新包括如下更改:修补托管环境或升级以及解除硬件授权. 大多数此类更新在执行时不会影响托管的虚拟机. 但是,也会存在更新产 ...