RE: SQL Question
Posted in 2000
Topics: SQL Development & Query Writing
Try this:
Select count(case ColA when 'X' Then 'X' ELSE NULL end),
count(case ColA when 'Y' Then 'Y' ELSE NULL end)
From TabA;
The CASE expression was added to IDS in 7.3, I believe... See Informix
Answers Online Documentation page 4-41 of SQL Syntax.
I've not tested this, but appears to be correct syntax.
HTH,
Doug
"Obnoxio The Clown" <obnoxio@hotmail.com> wrote in message
news:8hirpe$ssb$1@news.xmission.com...
>
> select count(*) xcnt from TabA where ColA=X into temp temp1;
> select count(*) ycnt from TabA where ColA=Y into temp temp2;
> select unique xcnt, ycnt from temp1, temp2;>
> ?
>
> From: "COOPER, Joseph" <Joseph.COOPER@sema.co.uk>
> >
> >SELECT colA, count(*)
> >FROM TabA
> >WHERE ColA = X
> >OR ColA = Y
> >GROUP BY ColA> >
> >OR
> >SELECT count(*)
> >FROM TabA
> >WHERE ColA = X
> >OR ColA = Y> >
> >Depending on what you are trying to do
> >
> >
> > > -----Original Message-----
> > > From: Tomasz Baron [mailto:tomasz_baron@banpol.pl]
> > > Sent: 06 June 2000 09:11
> > > To: informix-list@iiug.org
> > > Subject: SQL Question
> > >
> > >
> > > How to combine into a single question something like this:
> > >
> > > select count(*) from TabA where ColA=X;
> > > select count(*) from TabA where ColA=Y;>
>
> ________________________________________________________________________
> Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com
>
select count(*) xcnt from TabA where ColA=X into temp temp1;
select count(*) ycnt from TabA where ColA=Y into temp temp2;
select unique xcnt, ycnt from temp1, temp2;
?
From: "COOPER, Joseph" <Joseph.COOPER@sema.co.uk>
>
>SELECT colA, count(*)
>FROM TabA
>WHERE ColA = X
>OR ColA = Y
>GROUP BY ColA>
>OR
>SELECT count(*)
>FROM TabA
>WHERE ColA = X
>OR ColA = Y>
>Depending on what you are trying to do
>
>
> > -----Original Message-----
> > From: Tomasz Baron [mailto:tomasz_baron@banpol.pl]
> > Sent: 06 June 2000 09:11
> > To: informix-list@iiug.org
> > Subject: SQL Question
> >
> >
> > How to combine into a single question something like this:
> >
> > select count(*) from TabA where ColA=X;
> > select count(*) from TabA where ColA=Y;
________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com