1. Get rid of all advertisements and get unlimited access to documents by upgrading to Premium Membership. Upgrade to Premium Now and also get a Premium Badge!

Need help in hierarchy query for 3 tables

Discussion in 'SQL PL/SQL' started by Shanmugapriya, Jul 19, 2017.

  1. Shanmugapriya

    Shanmugapriya Active Member

    Messages:
    52
    Likes Received:
    0
    Trophy Points:
    130
    Location:
    Bangalore
    Hi,
    I have one hierarchy query for tables exchange_grp and node.
    Second hierarchy query for tables node and node_side.


    SELECT E.P_K, E.I4030_EXCH_GRP_CD, N.P_K, N.I4020_NODE_ID, N.I4020_NODE_CAT, LEVEL
    FROM WORK_REP.EXCHANGE_GRP E, WORK_REP.NODE N
    WHERE E.P_K = N.FK_S_EXGRP_NODE
    AND E.I4030_EXCH_GRP_TYPE = 'SVX'
    START WITH N.P_K IN E.NK_S_EXGRP_NODE
    CONNECT BY NOCYCLE N.P_K = PRIOR N.NK_S_EXGRP_NODE

    and

    SELECT N.P_K, NS.P_K, NS.FK_S_NODE_NSIDE, NS.I4040_SIDE_TYPE, LEVEL
    FROM WORK_REP.NODE N, WORK_REP.NODE_SIDE NS
    WHERE N.P_K = NS.FK_S_NODE_NSIDE
    START WITH NS.P_K IN N.NK_S_NODE_NSIDE
    CONNECT BY NOCYCLE NS.P_K = PRIOR NS.NK_S_NODE_NSIDE


    Can we combine these two queries into one.

    Kindly help. I am not familiar with this.
     
  2. krasnoslobodtsev_si

    krasnoslobodtsev_si Forum Genius

    Messages:
    749
    Likes Received:
    145
    Trophy Points:
    830
    Location:
    Russian Federation
    Hi.
    Provide here scripts for create table and filling of data.
    Try to write a query and bring it here and write what issues have arisen.

    Helpful for studing{connect by,with recursive sub-factoring}:
    HQ
    Example of HQ
     
    Last edited: Jul 19, 2017