Received: from localhost (maia-4.hub.org [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 85A1B9FA0EE for ; Thu, 21 Dec 2006 05:50:31 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-new, port 10024) with ESMTP id 85789-06 for ; Thu, 21 Dec 2006 05:50:17 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from mail.ringways.co.uk (host-80-193-83-141.static.telewest.net [80.193.83.141]) by postgresql.org (Postfix) with ESMTP id AB8949F9FE1 for ; Thu, 21 Dec 2006 05:50:17 -0400 (AST) Received: from eddie.ringways.co.uk ([10.1.1.115]) by mail.ringways.co.uk with esmtp (Exim 4.62) (envelope-from ) id 1GxKW9-0003Nv-3j for pgsql-sql@postgresql.org; Thu, 21 Dec 2006 09:47:28 +0000 From: Gary Stainburn Organization: Ringways Garages Ltd To: pgsql-sql@postgresql.org Subject: Re: join/group/count query. Date: Thu, 21 Dec 2006 09:46:56 +0000 User-Agent: KMail/1.9.5 References: <8C5B026B51B6854CBE88121DBF097A866A4A9D@ehost010-33.exch010.intermedia.net> In-Reply-To: <8C5B026B51B6854CBE88121DBF097A866A4A9D@ehost010-33.exch010.intermedia.net> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200612210946.56643.gary.stainburn@ringways.co.uk> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200612/162 X-Sequence-Number: 27118 On Wednesday 20 December 2006 18:06, Hector Villarreal wrote: > HI in reading this is it possible what was really intended : > Sum(case when o_model = 5 then 1 else NULL end) as KA > That would provide a count of all records meeting that condition. > Otherwise the count( approach will not do that. > Because the else is NULL, count does work. Although I would imagine sum will also work, count more reflects the logic, i.e. the number of times that condition is true -- Gary Stainburn This email does not contain private or confidential material as it may be snooped on by interested government parties for unknown and undisclosed purposes - Regulation of Investigatory Powers Act, 2000