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

Home -> Community -> Usenet -> c.d.o.misc -> Re: Summing hierarchical data SQL

Re: Summing hierarchical data SQL

From: Mike C <michaeljc70_at_hotmail.com>
Date: 5 Oct 2006 10:52:46 -0700
Message-ID: <1160070766.308925.278700@m73g2000cwd.googlegroups.com>

Michel Cadot wrote:

> SQL> select id, name, parent,
> 2 ( select sum(frequency)
> 3 from t t2
> 4 connect by prior id = parent
> 5 start with t2.id = t1.id ) frequency
> 6 from t t1
> 7 /
> ID NAME PARENT FREQUENCY
> ---------- ---------- ---------- ----------
> 1 USA 30
> 2 CA 1 25
> 3 LA 2 10
> 4 SF 2 15
> 5 IL 1 5
> 6 Chicago 5 5
>
> 6 rows selected.
>
> Regards
> Michel Cadot

Thanks- that is exactly what I needed. I was having problems getting my start and connects right. Received on Thu Oct 05 2006 - 12:52:46 CDT

Original text of this message

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