Received: from smtp-server1.tampabay.rr.com (smtp-server1.cfl.rr.com [65.32.2.68]) by postgresql.org (Postfix) with ESMTP id BCF4F475CF9 for ; Tue, 26 Mar 2002 13:21:23 -0500 (EST) Received: from john (6535131hfc248.tampabay.rr.com [65.35.131.248]) by smtp-server1.tampabay.rr.com (8.12.2/8.12.2) with SMTP id g2QILMTW007207 for ; Tue, 26 Mar 2002 13:21:23 -0500 (EST) Message-ID: <001301c1d4f3$37bd5160$f8832341@john> From: "John Oakes" To: Subject: Possible to do this in one query? Date: Tue, 26 Mar 2002 13:22:41 -0500 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2600.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 X-Archive-Number: 200203/344 X-Sequence-Number: 7219 I have a table with a column that contains fail codes. These codes are 1-9. I need to get a count of each of the codes. Right now I have separate queries: select count(*) from tablename where failcode = '1'; If I use GROUP BY it obviously doesn't get the count for codes that don't exist. I need to have 0 returned though so I have a listing of all 9 fail codes and their total, even if it is zero. I tried UNION like this: select count(*) from tablename where failcode = '1'; UNION select count(*) from tablename where failcode = '2'; etc, but it too excludes the codes that have a count of zero. Right now I have resorted to using 9 separate queries. Is there a way to do this with one? Thank you! John Oakes