select c.setid,
a.tree_name,
a.tree_level,
c.tree_node,
a.effdt,
c.descr
from pstreelevel a,
PSTREENODE b,
ps_tree_node_tbl c
where b.setid = a.setid
and b.tree_name = a.tree_name
and b.effdt = a.effdt
and b.setid = c.setid
and b.tree_node = c.tree_node
and c.effdt =
(select max(d.effdt)
from ps_tree_node_tbl d
where d.setid = c.setid
and d.tree_node = c.tree_node
and d.effdt <= b.effdt)
and b.tree_level_num < a.tree_level_num
and exists (
select 'x' from PSTREENODE d
where d.setid = b.setid
and d.tree_name = b.tree_name
and d.effdt = b.effdt
and d.tree_level_num =
a.tree_level_num
and d.tree_node_num between
b.tree_node_num
and b.tree_node_num_end)
|