Select Tree Node
这里用到了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的更多相关文章
- [置顶] ※数据结构※→☆非线性结构(tree)☆============树结点 链式存储结构(tree node list)(十四)
结点: 包括一个数据元素及若干个指向其它子树的分支:例如,A,B,C,D等. 在数据结构的图形表示中,对于数据集合中的每一个数据元素用中间标有元素值的方框表示,一般称之为数据结点,简称结点. 在C语言 ...
- 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 ...
- Python 解LeetCode:671. Second Minimum Node In a Binary Tree
题目在这里,要求一个二叉树的倒数第二个小的值.二叉树的特点是父节点的值会小于子节点的值,父节点要么没有子节点,要不左右孩子节点都有. 分析一下,根据定义,跟节点的值肯定是二叉树中最小的值,剩下的只需要 ...
- 【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 ...
- [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 ...
- LeetCode算法题-Second Minimum Node In a Binary Tree(Java实现)
这是悦乐书的第285次更新,第302篇原创 01 看题和准备 今天介绍的是LeetCode算法题中Easy级别的第153题(顺位题号是671).给定非空的特殊二叉树,其由具有非负值的节点组成,其中该树 ...
- [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 ...
- 671. Second Minimum Node In a Binary Tree
/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode ...
- 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 ...
随机推荐
- compass General 常用api学习[Sass和compass学习笔记]
compass 中一些常用api 包括一些浏览器hack @import "compass/utilities/general" Clearfix Clearfix 是用来清除浮动 ...
- js 类型转换学习
类型转换分为显示转换和隐式转换 参考http://www.cnblogs.com/mizzle/archive/2011/08/12/2135885.html 先事件显示的 通过手动进行类型转换,Ja ...
- 使用tungsten将mysql的数据同步到hadoop
背景 线上有很多的数据库在运行,后台需要一个分析用户行为的数据仓库.目前比较流行的是mysql和hadoop平台. 现在的问题是,如何将线上的mysql数据实时的同步到hadoop中,以供分析.这篇文 ...
- How To Handle a Loss of Confidence in Yourself
Do you feel like you've lost confidence in yourself? Have you had strong self doubts? Perhaps you we ...
- java分享第七天-01(Hashmap和Hashtable的区别&Property)
一.Hashmap和Hashtable的区别 1 主要:Hashtable线程安全,同步,效率相对低下 HashMap线程不安全,非同步,效率相对高 2 父类:Hashtable是Dictionary ...
- day1 初识Linux
linux 基础 1.Linux简介1) 掌握Linux的定义:Linux是一套免费使用和自由传播的类Unix操作系统,是一个基于POSIX和UNIX的多用户.多任务.支持多线程和多CPU的操作系统. ...
- Javascript初学篇章_3(注释/if/switch)
五.javascript的注释 // 单行注释 /* …*/ 多行注释 注:多行注释不能互相嵌套 六.程序流程控制 一.条件语句 if 语法: if(condition) statements1 el ...
- mpstat命令学习
mpstat是一个linux系统实时监控工具,它与vmstat命令类似 mpstat命令监控了cup的一些统计信息且这些信息存放在/proc/stat文件中 mpstat命令多用在多cpu系统中,查看 ...
- 如何用最简单的方法将PCweb改成适合各种设备的web
使web页面自适应设备大小 1)用一个<div>包围<body>的内容 2)该div属性的宽度设为100% (宽度设为100%后,页面会随着设备窗口大小自动改变) 3)高度 ...
- 那些年一起用过的iOS开发利器之Code Pilot
本系列所有工具的简介见:http://www.cnblogs.com/lloydsheng/p/3637606.html 什么是Code Pilot? Code Pilot是一个Xcode的扩充套件, ...