Xref: alice comp.databases.oracle.misc:54234
Path: alice!news-feed.fnsi.net!news.maxwell.syr.edu!logbridge.uoregon.edu!news.nero.net!news.uidaho.edu!sea-feed.news.verio.net!news.sierra.com!not-for-mail
From: "Steve McDaniels" <steve.mcdaniels@sierra.com>
Newsgroups: comp.databases.oracle.misc
Subject: Re: "GROUP BY" question
Date: Fri, 3 Mar 2000 12:42:59 -0800
Organization: Sierra On-Line, Inc.
Lines: 29
Message-ID: <89p8eq$2q8$1@plo.sierra.com>
References: <74471DFD03A7D11191E000600852EC6F05A9BC8E@DALLAS>
X-Trace: plo.sierra.com 952116506 2888 209.67.71.100 (3 Mar 2000 20:48:26 GMT)
X-Complaints-To: usenet@plo.sierra.com
NNTP-Posting-Date: 3 Mar 2000 20:48:26 GMT
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.00.2919.6700
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6700

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@garmin.com> wrote in message
news:74471DFD03A7D11191E000600852EC6F05A9BC8E@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'
>


