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: How to SELECT the COUNT??

Re: How to SELECT the COUNT??

From: Frans Hovenkamp <Dieze_at_popin.nl>
Date: Tue, 27 Apr 1999 09:45:28 +0200
Message-ID: <7g3pum$ca6$1@zonnetje.NL.net>

Violin heeft geschreven in bericht
<3725d18a.8528533_at_news.twsc.pouchen.com.tw>...
>Hello all,
>I have a select count question.
>If I have a table like this:
>
>EMPNO SAL_TYPE
>--------------------------------
>00001 A
>00002 A
>00003 B
>00004 A
>00005 B
>00006 B
>00007 A
>
>I want to do a select :
>SELECT COUNT(T1.EMPNO) "TYPE_A",
> COUNT(T2.EMPNO) "TYPE_B"
>FROM EMP T1,EMP T2
>WHERE T1.SAL_TYPE = 'A' and
> T2.SAL_TYPE = 'B';
>
>The result like this:
>TYPE_A TYPE_B
>---------------------------------
> 4 3
>
>How to do the SELECT COUNT sql?
>Thanks for your tips.
>
>Violin.
>violin.hsiao_at_mail.pouchen.com.tw

Hi,
Maybe not quite what you are looking for, but this would do (sort of):

select 'type_a',count(t1.empno)
from emp t1
where t1.sal_type = 'A'
union
select 'type_b',count(t2.empno)
from emp t2
where t1.sal_type = 'B'

Frans Hovenkamp Received on Tue Apr 27 1999 - 02:45:28 CDT

Original text of this message

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