Recursive SQL and information on different level

前端 未结 1 811
星月不相逢
星月不相逢 2021-01-29 13:10

Is it possible to display, in the same query, information concerning different level of recursivity ?

select LEVEL, ae2.CAB, ae2.NIVEAU, ae2.ENTITE, ae2.ENTITE_P         


        
相关标签:
1条回答
  • 2021-01-29 13:25

    Yes, it's possible to use the CONNECT_BY_ROOT operator. For instance, if you wanted the cab of the parent your query would be:

    select connect_by_root cab
          , level, cab, niveau, entite, entite_parent, libelle
       from my_table
      where niveau = 2
      start with cab = 'XXX'
    connect by prior entite_parent = entite
    

    You have to use a new operator for each column you want to select. You won't get information from a "different" level of recursivity using this operator, only from the root. If you want more you'll have to use recursive subquery factoring.

    0 讨论(0)
提交回复
热议问题