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

Home -> Community -> Usenet -> c.d.o.server -> Re: Please help with hierarchical query

Re: Please help with hierarchical query

From: Mladen Gogala <gogala_at_sbcglobal.net>
Date: Sat, 10 Jul 2004 00:38:47 GMT
Message-ID: <pan.2004.07.10.00.38.45.651223@sbcglobal.net>


On Fri, 09 Jul 2004 12:34:40 -0700, Ronnie wrote:

> Hi,
>
> I have a table with sample records as below
>
> Parent Region Child Region
> ============= ============
> North America USA
> USA CALIFORNIA
> USA CONNECTICUT
> CALIFORNIA ORANGE COUNTY
> CONNECTICUT FAIRFIRLD COUNTY
> FAIRFIELD COUNTY NORWALK
>
> I want to create a flattened table / materialized view such as below
>
>
> Parent Region Child Region
> ============= ============
> North America USA
> North America CALIFORNIA
> North America CONNECTICUT
> North America ORANGE COUNTY
> North America FAIRFIELD COUNTY
> North America NORWALK
> USA CALIFORNIA
> USA CONNECTICUT
> USA ORANGE COUNTY
> USA FAIRLFIELD COUNTY
> USA NORWALK
> CALIFORNIA ORANGE COUNTY
> CONNECTICUT FAIRFIELD COUNTY
> CONNECTICUT NORWALK
> FAIRFIELD COUNTY NORWALK
>
> I am at loss as to how do I write a query to do this. I can do it by
> writing a stored procedure but was thinking whether its poccible using
> connect by in a single query to achieve this.
>
>
> Thanks
> Ron

select parent_region,child_region
from table
connect by prior parent_region=child_region;

-- 
Well-behaved women seldom make history
Received on Fri Jul 09 2004 - 19:38:47 CDT

Original text of this message

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