这里用到了Oracle的一个树形结构查询函数select *  from record START WITH A.TREE_NODE IN ('COST_CTR_10053')
CONNECT BY PRIOR A.TREE_NODE_NUM = A.PARENT_NODE_NUM.查出指定节点下的所以子节点然后连接leaf表,选出所有的叶子。

/* Formatted on 11/7/2015 11:05:57 PM (QP5 v5.267.14150.38573) */
SELECT B.RANGE_FROM
FROM PSTREELEAF B,
( SELECT DISTINCT A.SETID,
A.SETCNTRLVALUE,
A.TREE_NAME,
A.EFFDT,
A.TREE_NODE_NUM
FROM PSTREENODE A,
(SELECT A.SETID,
A.SETCNTRLVALUE,
A.TREE_NAME,
A.EFFDT
FROM PSTREEDEFN A
WHERE A.SETID = 'SHARE'
AND A.SETCNTRLVALUE = ' '
AND A.TREE_NAME = 'PLD_LOC_COMBO'
AND A.EFFDT =
(SELECT MAX (B.EFFDT)
FROM PSTREEDEFN B
WHERE A.SETID = B.SETID
AND A.SETCNTRLVALUE = B.SETCNTRLVALUE
AND A.TREE_NAME = B.TREE_NAME
AND B.EFF_STATUS = 'A'
AND B.EFFDT <= SYSDATE)) DEFN
WHERE A.SETID = DEFN.SETID
AND A.SETCNTRLVALUE = DEFN.SETCNTRLVALUE
AND A.TREE_NAME = DEFN.TREE_NAME
AND A.EFFDT = DEFN.EFFDT
START WITH A.TREE_NODE IN ('COST_CTR_10053')
CONNECT BY PRIOR A.TREE_NODE_NUM = A.PARENT_NODE_NUM) SA
WHERE SA.SETID = B.SETID
AND SA.SETCNTRLVALUE = B.SETCNTRLVALUE
AND SA.TREE_NAME = B.TREE_NAME
AND SA.EFFDT = B.EFFDT
AND SA.TREE_NODE_NUM = B.TREE_NODE_NUM

************************************************************************************************************************************************

SELECT P2.*
FROM
(SELECT A.SETID ,
A.SETCNTRLVALUE ,
A.TREE_NAME ,
A.EFFDT
FROM PSTREEDEFN A
WHERE A.SETID = 'SHARE'
AND A.SETCNTRLVALUE = ' '
AND A.TREE_NAME = 'PLD_LOC_COMBO'
AND A.EFFDT =
(SELECT MAX (B.EFFDT)
FROM PSTREEDEFN B
WHERE A.SETID = B.SETID
AND A.SETCNTRLVALUE = B.SETCNTRLVALUE
AND A.TREE_NAME = B.TREE_NAME
AND B.EFF_STATUS = 'A'
AND B.EFFDT <= SYSDATE)) P,
PSTREENODE P1 ,
PSTREELEAF P2
WHERE P1.SETID = P.SETID
AND P1.SETCNTRLVALUE = P.SETCNTRLVALUE
AND P1.TREE_NAME = P.TREE_NAME
AND P1.EFFDT = P.EFFDT
AND P1.TREE_NODE = 'COST_CTR_10053'
AND P2.SETID = P1.SETID
AND P2.SETCNTRLVALUE = P1.SETCNTRLVALUE
AND P2.TREE_NAME = P1.TREE_NAME
AND P2.EFFDT = P1.EFFDT
-- AND P2.TREE_NODE_NUM BETWEEN P1.TREE_NODE_NUM AND P1.TREE_NODE_NUM_END
AND P2.TREE_NODE_NUM = P1.TREE_NODE_NUM

AND (
( NVL(LENGTH(REPLACE(TRANSLATE('143','0123456789.',' '),' ','')), 0) <> 0 AND '143' BETWEEN P2.RANGE_FROM AND P2.RANGE_TO)
OR
( NVL(LENGTH(REPLACE(TRANSLATE('143','0123456789.',' '),' ','')), 0) = 0 AND '143' BETWEEN P2.RANGE_FROM AND P2.RANGE_TO AND LENGTH('143') BETWEEN LENGTH(P2.RANGE_FROM) AND LENGTH(P2.RANGE_TO))
)

Select Tree Node的更多相关文章

  1. [置顶] ※数据结构※→☆非线性结构(tree)☆============树结点 链式存储结构(tree node list)(十四)

    结点: 包括一个数据元素及若干个指向其它子树的分支:例如,A,B,C,D等. 在数据结构的图形表示中,对于数据集合中的每一个数据元素用中间标有元素值的方框表示,一般称之为数据结点,简称结点. 在C语言 ...

  2. Data Structure Binary Tree: Print ancestors of a given binary tree node without recursion

    http://www.geeksforgeeks.org/print-ancestors-of-a-given-binary-tree-node-without-recursion/ #include ...

  3. Python 解LeetCode:671. Second Minimum Node In a Binary Tree

    题目在这里,要求一个二叉树的倒数第二个小的值.二叉树的特点是父节点的值会小于子节点的值,父节点要么没有子节点,要不左右孩子节点都有. 分析一下,根据定义,跟节点的值肯定是二叉树中最小的值,剩下的只需要 ...

  4. 【easy】671. Second Minimum Node In a Binary Tree

    Given a non-empty special binary tree consisting of nodes with the non-negative value, where each no ...

  5. [Swift]LeetCode671. 二叉树中第二小的节点 | Second Minimum Node In a Binary Tree

    Given a non-empty special binary tree consisting of nodes with the non-negative value, where each no ...

  6. LeetCode算法题-Second Minimum Node In a Binary Tree(Java实现)

    这是悦乐书的第285次更新,第302篇原创 01 看题和准备 今天介绍的是LeetCode算法题中Easy级别的第153题(顺位题号是671).给定非空的特殊二叉树,其由具有非负值的节点组成,其中该树 ...

  7. [LeetCode&Python] Problem 671. Second Minimum Node In a Binary Tree

    Given a non-empty special binary tree consisting of nodes with the non-negative value, where each no ...

  8. 671. Second Minimum Node In a Binary Tree

    /** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode ...

  9. Lintcode: Insert Node in a Binary Search Tree

    Given a binary search tree and a new tree node, insert the node into the tree. You should keep the t ...

随机推荐

  1. KVO 键值观察者

    KVO(键值观察者) //监听的创建 -(id)initChildren:(Person *)person { self = [super init]; if (self != nil) { //拥有 ...

  2. StringTemplate初步使用

    例子1: private static void test_1(String[] args) throws Exception { ST hello = new ST("Hello, < ...

  3. ZeroMQ接口函数之 :zmq_recvmsg – 从一个socket上接收一个消息帧

    ZeroMQ 官方地址 :http://api.zeromq.org/4-1:zmq-recvmsg zmq_recvmsg(3)         ØMQ Manual - ØMQ/4.1.0 Nam ...

  4. 细读cow.osg

    细读cow.osg 转自:http://www.cnblogs.com/mumuliang/archive/2010/06/03/1873543.html 对,就是那只著名的奶牛. //Group节点 ...

  5. 关于history的Linux命令行

    1.使用 HISTTIMEFORMAT 显示时间戳当你从命令行执行 history 命令后,通常只会显示已执行命令的序号和命令本身.如果你想要查看命令历史的时间戳,那么可以执行: # export H ...

  6. iOS开发之GCD

    GCD,全称Grand Central Dispath,是苹果开发的一种支持并行操作的机制.它的主要部件是一个FIFO队列和一个线程池,前者用来添加任务,后者用来执行任务. GCD中的FIFO队列称为 ...

  7. 手把手教你编写Logstash插件

    使用过Logstash的朋友都知道,它强大的插件生态几乎覆盖了所有的开源框架.从基本的http.tcp.udp.file,到强大的kafa.redis.ganglia,还有丰富的解析工具,比如date ...

  8. 配合 APP 调用 JS 的一次尝试

    项目初衷 最初的场景是用户在对购物车的操作中,由于用户对购物车的每次操作(包括选择,调整数量)都需要计算商品的促销和分组的情况,而这段逻辑的计算都需要调用后端的接口,那么瓶颈来了: 请求时间长--一次 ...

  9. python学习道路(day7note)(subprocess模块,面向对象)

    1.subprocess模块   因为方法较多我就写在code里面了,后面有注释 #!/usr/bin/env python #_*_coding:utf-8_*_ #linux 上调用python脚 ...

  10. https://blog.helong.info/blog/2015/03/13/jump_consistent_hash/

    转载请说明出处:http://blog.csdn.net/cywosp/article/details/23397179     一致性哈希算法在1997年由麻省理工学院提出的一种分布式哈希(DHT) ...