sql - Hierarchical Query: Get the direct children count for each node -
i new hierarchical queries , have gone through of posts on it.
i have query improve.
my scenario this:
sample ------- id, name, parent_id
table data follows:
id name parent_id ----------------------- 1 (null) 2 b 1 3 c 2 4 d 1
i want result this:
id name parent_id is_leaf level direct_children_count ------------------------------------------------------------------- 1 (null) 0 1 2 2 b 1 0 2 1 3 c 2 1 3 0 4 d 1 1 2 0
i wrote following query gives columns except direct_children_count
select id, name, parent_id, connect_by_leaf is_leaf, level sample start parent_id = null connect prior id = parent_id
there many posts on how count of children of node(not direct children), not applicable me because
1.i want direct children count.
2.if possible want achieve without using joins.
i have no clue how direct children count column value each of records. there anyway direct_children_count using hierarchical queries?
Comments
Post a Comment