Received: from imf07bis.bellsouth.net (mail207.mail.bellsouth.net [205.152.58.147]) by postgresql.org (8.11.3/8.11.4) with ESMTP id fBR5cCm49878 for ; Thu, 27 Dec 2001 00:38:12 -0500 (EST) (envelope-from rwrowell@bellsouth.net) Received: from there ([66.157.170.37]) by imf07bis.bellsouth.net (InterMail vM.5.01.04.00 201-253-122-122-20010827) with SMTP id <20011227053930.DMEM18093.imf07bis.bellsouth.net@there> for ; Thu, 27 Dec 2001 00:39:30 -0500 Content-Type: text/plain; charset="iso-8859-1" From: Richard Rowell To: pgsql-sql@postgresql.org Subject: Multiple counts Date: Wed, 26 Dec 2001 23:36:05 -0600 X-Mailer: KMail [version 1.3.2] MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-Id: <20011227053930.DMEM18093.imf07bis.bellsouth.net@there> X-Archive-Number: 200112/252 X-Sequence-Number: 6074 I have a one-to-many relationship with a table structure like so: create table call( uid serial, store int, ...) create table status( call_uid int, status_uid int, ...) First off, please note that the "call" table will get large ( growing by up to 6k records per week) and the status table will grow linearly with it (n*20 or so). With that in mind, what I am trying for is an efficient query to get a tuple set like so: store number_of_calls number_of_status_where_statusuid_iszero I can get 1&2: select store, count(*) from call group by store; or 1&3: select c.store,count(s.status_uid) from call c, status s where s.call_uid=c.uid and s.status_uid=0 group by c.store But all my lame attempts at getting both in the same query fail. TIA _________________________ Richard Rowell rwrowell@bellsouth.net