From: news.gmane.org <nis@superlativ.dk>
To: pgsql-sql@postgresql.org
Subject: Re: Where clause
Date: Tue, 26 Jun 2007 17:22:26 +0200
Message-ID: <f5ravm$37c$1@sea.gmane.org> (raw)
In-Reply-To: <20070626082405.GA67974@mich2.itxmarket.com>
References: <20070626082405.GA67974@mich2.itxmarket.com>
Michael Landin Hostbaek skrev:
> 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;
Untested, not the cleverest formulation, but something like this should
work:
SELECT * FROM
(
select cid,count(distinct contactid) from tracking where click =
true group by cid
) c1
FULL OUTER JOIN
(
select cid,count(distinct contactid) from tracking where view =
true group by cid
) c2
USING (cid);
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: nis@superlativ.dk
Subject: Re: Where clause
In-Reply-To: <f5ravm$37c$1@sea.gmane.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox