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" question

Re: "GROUP BY" question

From: Steve McDaniels <steve.mcdaniels_at_sierra.com>
Date: Fri, 3 Mar 2000 12:42:59 -0800
Message-ID: <89p8eq$2q8$1@plo.sierra.com>


select
  sum(decode(category,'A',1)) A,
  sum(decode(category,'B',1)) B,
  count(*) A_OR_B
from collection_date
where category in ('A','B')

A B A_OR_B

-------- ------- ---------------------
5           10                  15

"Chen, Baoshan" <Baoshan.Chen_at_garmin.com> wrote in message news:74471DFD03A7D11191E000600852EC6F05A9BC8E_at_DALLAS...
> Sorry for the simple question. How can I get the forth line (A or B)
> using SQL statements?
>
> category count
> A 5
> B 10
> A or B 15
>
> The following statement seems not to work.
>
> select category count(*) from collection_data
> group by category
> having category = 'A' or category = 'B'
>
Received on Fri Mar 03 2000 - 14:42:59 CST

Original text of this message

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