Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> Re: Problem adding a join to a hierarchial query

Re: Problem adding a join to a hierarchial query

From: Adam Donahue <adonahue_at_opsware.com>
Date: Wed, 17 Nov 2004 13:04:46 -0800
Message-ID: <419BBCEE.9010007@opsware.com>


Hmm. See below.

>select
> provider_contract_status_id status_id,
> prev_prov_contract_status_id prev_id,
> level
>from
> provider_contract_status
> start with provider_contract_status_id in (select
>provider_contract_status_id from provider)
> connect by prior prev_prov_contract_status_id = provider_contract_status_id;
>
>status_id prev_id level
>87944200 87825800 1
>87825800 2
>87332200 1
>88249600 88173600 1
>88173600 88169600 2
>88169600 3
>
>I have been asked to create a view showing the above hierarchy as well
>as the corresponding provider_id from the PROVIDER table, like the
>following:
>
>provider_id curr_id prev_id level
>323232 87944200 87825800 1
>323232 87825800 2
>000001 87332200 1
>006400 88249600 88173600 1
>006400 88173600 88169600 2
>006400 88169600 3
>
>
>

select

    p.provider_id,
    pcs.provider_contract_status_id curr_id,     pcs.prev_prod_contract_status_id prev_id,     level
from

    provider left join provider_contract_status on p.provider_contract_status_id = pcs.provider_contract_status_id

    connect by prior pcs.prev_prod_contract_status_id = pcs.provider_contract_status_id

This should work on 9i, no?

Adam

--
http://www.freelists.org/webpage/oracle-l
Received on Wed Nov 17 2004 - 15:07:56 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US