DBAsupport.com Forums - Powered by vBulletin
Results 1 to 10 of 11

Thread: How to get all the parents of a given node from a tree in single row?

Threaded View

  1. #6
    Join Date
    Dec 2000
    Location
    Ljubljana, Slovenia
    Posts
    4,439

    Re: How to get all the parents of a given node from a tree in single row?

    Code:
    SELECT MAX(node_company),
           MAX(node_state),
           MAX(node_region),
           MAX(node_district)
    FROM
     (SELECT DECODE(node_level,1,node_name) node_company,
             DECODE(node_level,2,node_name) node_state,
             DECODE(node_level,3,node_name) node_region,
             DECODE(node_level,4,node_name) node_district
      FROM
       (select node_id,node_name,node_level,parent_node_id
        from tree
        start with node_id=1023
        connect by prior parent_node_id=node_id
       )
     );
    The assumption here is that each leaf node you are making the report for is at exactly fourth level, ie, it allways has three parent levels.
    Last edited by jmodic; 09-14-2004 at 11:42 AM.
    Jurij Modic
    ASCII a stupid question, get a stupid ANSI
    24 hours in a day .... 24 beer in a case .... coincidence?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width