Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: "GROUP BY" question
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