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 -> Re: group by problem!!!

Re: group by problem!!!

From: Thomas Kyte <tkyte_at_us.oracle.com>
Date: 17 Aug 2001 08:27:14 -0700
Message-ID: <9ljd4i0f3d@drn.newsguy.com>


In article <3B7CD7B9.20CBCE8A_at_ratp.fr>, gil says...
>
>i'd like to obtain on the same line of my sql select query:
>
>select sector,count(event) closed,count(event) all_events
>from table
>group by sector
>
>but all_events is for all events of course (no where clause on the
>status) and closed is only for events with status 'C'
>
>i did it with a union select but i obtain 2 lines...
>
>how can i do ???
>
>thanks
>
>

select sector,

       sum( decode( status, 'C', 1, '0 ) ) closed, 
       count(event) all_events

  from table
 group by sector
/
--
Thomas Kyte (tkyte@us.oracle.com)             http://asktom.oracle.com/ 
Expert one on one Oracle, programming techniques and solutions for Oracle.
http://www.amazon.com/exec/obidos/ASIN/1861004826/  
Opinions are mine and do not necessarily reflect those of Oracle Corp 
Received on Fri Aug 17 2001 - 10:27:14 CDT

Original text of this message

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