Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Query Hint

Re: Query Hint

From: Vince <vinnyop_at_yahoo.com>
Date: 12 Feb 2007 07:34:17 -0800
Message-ID: <1171294456.952833.154970@k78g2000cwa.googlegroups.com>


On Feb 11, 11:16 pm, ciccio <cic..._at_ciccio.it> wrote:
> Vince wrote:
> >> I have a ORDERS table as follows:
> [...]
> >> select department, level, count(*) as QUANTITY from orders
> > If the number of levels is fixed a rather simple approach would be:
> > select department,
> > sum(decode(level,1,quantity,0)) as level_1,
> > sum(decode(level,2,quantity,0)) as level_2,
> > ...
> > from orders
> > ...
> > group by department
>
> Yes, but I have to compute also quantity (count(*)) in the same query,
> i.e. I need to know for each department how many orders are at a certain
> step, how many at another step and so on.
>
> How can I modify this query in order to achieve this result?
>
> Thanks.

Just add a similar sum column, but instead of using quantity, use 1. ie. sum(decode(level,1,1,0)) as level_1_count Received on Mon Feb 12 2007 - 09:34:17 CST

Original text of this message

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