pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Achilleas Mantzios <achill@matrix.gatewaynet.com>
To: Michael Landin Hostbaek <mich@the-lab.org>
To: A. Kretschmer <andreas.kretschmer@schollglas.com>
To: pgsql-sql@postgresql.org
Subject: Re: Where clause
Date: Tue, 26 Jun 2007 13:31:03 +0300
Message-ID: <200706261331.04033.achill@matrix.gatewaynet.com> (raw)
In-Reply-To: <20070626094453.GH67974@mich2.itxmarket.com>
References: <20070626082405.GA67974@mich2.itxmarket.com>
	<20070626090140.GB28610@a-kretschmer.de>
	<20070626094453.GH67974@mich2.itxmarket.com>

Óôéò Ôñßôç 26 Éïýíéïò 2007 12:44, ï/ç Michael Landin Hostbaek Ýãñáøå:
> A. Kretschmer (andreas.kretschmer) writes:
> > *untested*
> >
> > select cid, sum(case when click = true then 1 else 0 end), sum(case when
> > view = true then 1 else 0 end) from ...
>
> Thanks, but I need the DISTINCT contactid - I don't want the same
> contactid counted twice.
>

Something like

SELECT distinct cid,(select count(distinct t1.contactid) from tracking t1 
where t1.view and t1.cid=tglob.cid) as countviews,(select count(distinct 
t2.contactid) from tracking t2 where t2.click and t2.cid=tglob.cid) as 
countclicks from tracking tglob;

?
> Mike
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: explain analyze is your friend

-- 
Achilleas Mantzios



view thread (10+ messages)  latest in thread

Message-ID: <200706261331.04033.achill@matrix.gatewaynet.com>
Permalink:  ../200706261331.04033.achill@matrix.gatewaynet.com/
Also on:    postgresql.org/message-id/200706261331.04033.achill@matrix.gatewaynet.com

 · 

reply

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: achill@matrix.gatewaynet.com, mich@the-lab.org, andreas.kretschmer@schollglas.com
  Subject: Re: Where clause
  In-Reply-To: <200706261331.04033.achill@matrix.gatewaynet.com>

* 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