Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Summing hierarchical data SQL
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
![]() |
![]() |