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 -> Summing hierarchical data SQL

Summing hierarchical data SQL

From: Mike C <michaeljc70_at_hotmail.com>
Date: 4 Oct 2006 11:33:57 -0700
Message-ID: <1159986837.764064.22880@m73g2000cwd.googlegroups.com>


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	    5
Received on Wed Oct 04 2006 - 13:33:57 CDT

Original text of this message

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