Re: Hierarchical Query Question

From: Carlo Bies <carlo.bies_at_sap-ag.de>
Date: 1997/01/14
Message-ID: <32DC0C42.DF3_at_sap-ag.de>#1/1


Jack R. Sumner Jr. wrote:
>
> Hi. I am having trouble with a hierarchical query and I thought someone
> out there might have run across this before and be able to help.
>
> I need to be able to start at the top of a hierarchy (100 below) and
> perform a sum on a column (say PRICE) in each record. The catch is that
> the summation can only include those records where a flag (represented
> by the ‘*’ below) is set to TRUE.
>
> 100*
> 200* 201*
> 301* 302 303 304*
> 401* 402
>
> In this example starting at 100, I need to sum up the PRICE column for
> 100, 200, 201, 301, 304, & 401.
>
> Any ideas on how to do this with a hierarchical query?
>
> Thank you in advance,
> Jack Sumner (jrsumner_at_ix.netcom.com)

Try this:

select sum(price)
from xy
where flag = '*'
start with n = 100
connect by prior n = p

Carlo Bies Received on Tue Jan 14 1997 - 00:00:00 CET

Original text of this message