Re: SQL help please, it shouldn't be this hard.
Date: Fri, 07 Jan 2000 15:11:42 GMT
Message-ID: <854vn1$q8n$1_at_nnrp1.deja.com>
Hi,
I didn't undertand very good what you want (that must be because I've drunk a lot of beer last night ;), but there's a command that "Calculates and prints summary lines, using various standard computations, on subsets of selected rows"...
Take a look at this site:
http://infoboard.com/packagedoc/oradoc/DOC/server/doc/SP33/ch6a.htm#brea
k
Adriano.
In article <853th9$m9h$3_at_bgtnsc02.worldnet.att.net>,
"zpayne" <jakefound_at_hotmail.com> wrote:
> I'm trying to write a query that for some reason seems harder than it
should
> be.
>
> I have a large group of managers in a hierchy.
> Each employee is stored in an EMP table, with a foreign key to their
> manager.
> The data is stored in a separate table, and is only related to
> non-supervisors.
> Many managers supervise several levels (i.e. they have both
supervisors, and
> non-supervisors reporting to them)
>
> The problem is I am trying to sum up data by each of the supervisors.
> The first levels need to include the data from their direct reports.
I need
> to have the data for the second level supervisors include the first
levels
> that report to them, and the non-supervisors that report to them.
This goes
> on through 5 levels of management.
>
> I have tried something like this with mixed results.
>
> SELECT eee.mgr third, ee.mgr sec, e.mgr first, sum(amt)
> FROM emp eee, emp ee, emp e, data d
> where d.id = e.id
> and e.mgr = ee.id(+)
> and ee.mgr = eee.id(+)
> group by 1,2,3
>
> I'm not sure if I'm on the right track.
>
> Any ideas? Is this possible in one query, or do I need separate
queries for
> each level?
>
> I would appreciate any insight.
>
> TIA
>
>
Sent via Deja.com http://www.deja.com/
Before you buy.
Received on Fri Jan 07 2000 - 16:11:42 CET