pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jeff Eckermann <jeckermann@verio.net>
To: 'Dirk Lutzebaeck' <lutzeb@aeccom.com>
To: Michael Fork <mfork@toledolink.com>
Cc: pgsql-sql@postgresql.org
Subject: RE: counting distinct rows on more than one column
Date: Wed, 28 Mar 2001 14:43:26 -0600
Message-ID: <08CD1781F85AD4118E0800A0C9B8580B0949E1@NEZU> (raw)

I don't think this will necessarily work:

field1 | field2
aa     |  ab
a       |  aab

These are two distinct rows, so should be counted as two.
The proposed method would count them as one.
You can get around this problem by doing:
count (distinct (a || x || b))
where x is some character not found in your data.

> -----Original Message-----
> From:	Dirk Lutzebaeck [SMTP:lutzeb@aeccom.com]
> Sent:	Wednesday, March 28, 2001 1:32 PM
> To:	Michael Fork
> Cc:	pgsql-sql@postgresql.org
> Subject:	Re: counting distinct rows on more than one column
> 
> Michael Fork writes:
>  > In 7.0.3, I believe the following would work:
>  > 
>  > SELECT count(distinct(a || b)) FROM t;
> 
> Great, this works! I don't quite get it why...
> 
> Dirk
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo@postgresql.org so that your
> message can get through to the mailing list cleanly



view thread (8+ messages)  latest in thread

Message-ID: <08CD1781F85AD4118E0800A0C9B8580B0949E1@NEZU>
Permalink:  ../08CD1781F85AD4118E0800A0C9B8580B0949E1@NEZU/
Also on:    postgresql.org/message-id/08CD1781F85AD4118E0800A0C9B8580B0949E1@NEZU

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: jeckermann@verio.net, lutzeb@aeccom.com, mfork@toledolink.com
  Subject: Re: counting distinct rows on more than one column
  In-Reply-To: <08CD1781F85AD4118E0800A0C9B8580B0949E1@NEZU>
  References: <08CD1781F85AD4118E0800A0C9B8580B0949E1@NEZU>

* 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