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: 2 count with criteria

Re: 2 count with criteria

From: Knut Talman <knut.talman_at_mytoys.de>
Date: Tue, 02 Jul 2002 12:38:28 +0200
Message-ID: <3D2182A4.7F3839EE@mytoys.de>


"sit.sit" wrote:
>
> I have one table EV
>
> EV_CODE PK
> EV_STATUS
> EV_CLASS
>
> I want 2 count in the same select:
>
> how many ev_code i have for each ev_class
>
> when ev_status is (A or R )
>
> and when ev_status is C
>
> result like ev_class A/R C
>
> X 58 15
> Y 22 47

select ev_class, sum(decode(ev_status,'A',1,'R',1,0)) "A/R",

                 sum(decode(ev_status,'C',1,0)) C
from ev
group by ev_class;

Hth,

Knut Received on Tue Jul 02 2002 - 05:38:28 CDT

Original text of this message

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