Received: from localhost (maia-5.hub.org [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id 631E19FB400 for ; Tue, 26 Jun 2007 05:55:49 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-maia, port 10024) with ESMTP id 05104-03 for ; Tue, 26 Jun 2007 05:55:38 -0300 (ADT) X-Greylist: delayed 00:31:26.256349 by SQLgrey-1.7.5 Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) by postgresql.org (Postfix) with ESMTP id C95DD9FBA4A for ; Tue, 26 Jun 2007 05:55:40 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.3 Received: from mail2.itxmarket.com (fw.itxmarket.com [84.14.136.210]) by svr4.postgresql.org (Postfix) with ESMTP id B17165AF898 for ; Tue, 26 Jun 2007 08:24:08 +0000 (GMT) Received: from icommerce.fr (mich2.itxmarket.com [192.168.2.26]) by mail2.itxmarket.com (Postfix) with ESMTP id D901D61CD0 for ; Tue, 26 Jun 2007 10:24:05 +0200 (CEST) Received: by icommerce.fr (Postfix, from userid 1001) id BBD1F22855; Tue, 26 Jun 2007 10:24:05 +0200 (CEST) Date: Tue, 26 Jun 2007 10:24:05 +0200 From: Michael Landin Hostbaek To: PostgresSQL list Subject: Where clause Message-ID: <20070626082405.GA67974@mich2.itxmarket.com> Mail-Followup-To: Michael Landin Hostbaek , PostgresSQL list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Operating-System: FreeBSD 6.2-STABLE i386 X-PGP-Key: http://www.freebsdcluster.org/~mich/ User-Agent: Mutt/1.5.15 (2007-04-06) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.136 tagged_above=0 required=5 tests=BAYES_50=0.001, FORGED_RCVD_HELO=0.135 X-Spam-Level: X-Archive-Number: 200706/213 X-Sequence-Number: 28703 Hello, I have a table called tracking, with a contactid varchar, click bool, view bool and cid varchar. I would like to put the following into one single query if possible: // Number of clicks select cid,count(distinct contactid) from tracking where click = true group by cid; // Number of views select cid,count(distinct contactid) from tracking where view = true group by cid; I guess I have to put where (click = true or view = true) - and differentiate them in the SELECT target.. ? Many thanks for any input, Mike