Re: Count Question
Posted in 1999
Topics: SQL Development & Query Writing, Migration, Import/Export & Data Conversion
Try:
select count(*) bw, id
from emp
where id matches 'BWE*'
group by id
union all
select count(*) bw, id
from emp
where id matches 'BWN*'
group by id
order by 2
HTH,
David
Mark Roach <mroach@bju.IT5_PO> on 01/11/99 12:00:07 PM
Please respond to Mark Roach <mroach@bju.IT5_PO>
To: informix-list@iiug.org
cc: (bcc: David Coburn/ISG/WVUS/WorldVision)
Subject: Re: Count Question
This is a multi-part message in MIME format.
--------------E0E6F5D2A78E83A329DA73AE
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
I'm sorry I did'nt catch the output until after I had replied. I believe
if you
just ORDER BY id it should be close to the output you want. As for the
counts I
still think you'll need 2 select statements.
Mark Roach wrote:
> You will have to use 2 selects, but you could have both in 1 sql.
> Example:
> UNLOAD TO "output1.out"
> SELECT count(*) from employee
> WHERE id IN ("A", "B")>
> UNLOAD TO "output2.out"
> SELECT count(*) from employee
> WHERE id IN ("C", "D")>
> kjacobs@pharmacy.com wrote:
>
> > I have a table that lists employees by an identifier (BWE1, BWN1, BWE2,
or
> > BWN2) See Below for example. What I want like to do is get a count of
all
> > (BWE1 and BWN1) and a count of all (BWE2 and BWN2) employees. I.E. I
just
> > want two results. I have done this using two different querys, but I
would
> > like to make it into one. Does anyone have any clues on how this can
be
> > done?
> >
> > I would like to make these two querys into one.
> >
> > SELECT COUNT(*) bw, id, FROM employee WHERE id IN("BWE1, BWE1") GROUPBY id
> > SELECT COUNT(*) bw, id, FROM employee WHERE id IN("BWE2, BWE2") GROUPBY id
> >
> > EXAMPLE TABLE
> > empnumber, id
> > 1, BWE1
> > 2, BWN1
> > 5, BWE2
> > 6, BWN2
> >
> > -----------== Posted via Deja News, The Discussion Network ==----------
> > http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
>
>
------------------------------------------------------------------------
>
> Mark Roach <mroach@bju.IT5_PO>
> Informix Programmer
> Bob Jones University
>
> Mark Roach
> Informix Programmer <mroach@bju.IT5_PO>
> Bob Jones University
> Netscape Conference Address
> Netscape Conference DLS Server
> Additional Information:
> Last Name Roach
> First Name Mark
> Version 2.1
--------------E0E6F5D2A78E83A329DA73AE
Content-Type: text/x-vcard; charset=us-ascii; name="vcard.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Mark Roach
Content-Disposition: attachment; filename="vcard.vcf"
begin: vcard
fn: Mark Roach
n: Roach;Mark
org: Bob Jones University
email;internet: mroach@bju.IT5_PO
title: Informix Programmer
x-mozilla-cpt: ;0
x-mozilla-html: FALSE
version: 2.1
end: vcard
--------------E0E6F5D2A78E83A329DA73AE--