先说一下表结构:提示用START WITH .... CONNECT BY ....

解决方案 »

  1.   

    举个例子:
    select Cow , Bull, LPAD(' ', 6 * (LEVEL = 1)) || offsprint as offspring, sex, birthdate
    from breeding
    start with offsprint = 'DELLA'
    connect by offspring = PRIOR Cow;使用Connect by时各子句的顺序为:
    select
    from
    where
    start with
    connect by
    order by
    prior使报表的顺序变为从根到叶(如果prior列为父辈)或从叶到根(如果prior列为后代)。
    where子句可以从树中排除个体,但不排除他们的子孙(或者祖先)
    connect by中的条件消除个体和它所有的子孙(或祖先)
    connect by不能与where子句中的表连接一起使用。