Re: SQL Question
Posted in 2000
En Tom va escriure el dia 6 Jun 2000, a les 10:59:
>
> I want two counts in one statement with two different where filters!!!
>
> Maybe it looks alike this:
>
> SELECT a.count(*), b.count(*) from TabA a, TabA b where
> a.ColA=X and b.ColB=Y
>
> but.. this is not the right one.
>
> "COOPER, Joseph" <Joseph.COOPER@sema.co.uk> wrote in message
> news:8hiko7$k39$1@news.xmission.com...
> >
> > 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;> > >
> > >
> > >
> > > Thanks for all answers
> > >
> > >
> > >
> >
> >
> ___________________________________________________________________________
> > This email is confidential and intended solely for the use of the
> > individual to whom it is addressed. Any views or opinions presented are
> > solely those of the author and do not necessarily represent those of
> > Sema Group.
> > If you are not the intended recipient, be advised that you have received
> this
> > email in error and that any use, dissemination, forwarding, printing, or
> > copying of this email is strictly prohibited.
> >
> > If you have received this email in error please notify the Sema Group
> > Helpdesk by telephone on +44 (0) 121 627 5600.
> >
> ___________________________________________________________________________
> >
>
>
Try:
select
(select count(*) from table_a where col_a=condition_a ) val_a,
(select count(*) from table_a where col_a=condition_b) val_b
from systables
where tabid = 1
I hope this help you.
---------------------------------------
Isidre PONS ROCA
BASE - Gesti' d'Ingressos Locals
(Diputacio de Tarragona)
Servei de Sistemes de Informacio
Av President Lluis Companys 12-C
43005 - Tarragona
SPAIN
Tel # +34 977 236731
Fax # +34 977 227302
http://www.altanet.org
ipons@dtgna.altanet.org
---------------------------------------