Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Summing hierarchical data SQL
If I have a table or query that returns hierarchical data, how can I
sum it? There are counts only at the lowest level and I want to roll
it up to the parent levels. Here is an example:
Level ID Name Parent Frequency 1 1 USA NULL 2 2 CA 1 3 3 LA 2 10 3 4 SF 2 15 2 5 IL 1 3 6 Chicago 5 5
I want to get this:
Level ID Name Parent Frequency 1 1 USA NULL 30 2 2 CA 1 25 3 3 LA 2 10 3 4 SF 2 15 2 5 IL 1 5 3 6 Chicago 5 5Received on Wed Oct 04 2006 - 13:33:57 CDT