From: | Jeff Eckermann <jeckermann(at)verio(dot)net> |
---|---|
To: | "'Dirk Lutzebaeck'" <lutzeb(at)aeccom(dot)com>, Michael Fork <mfork(at)toledolink(dot)com> |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | RE: counting distinct rows on more than one column |
Date: | 2001-03-28 20:43:26 |
Message-ID: | 08CD1781F85AD4118E0800A0C9B8580B0949E1@NEZU |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
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(at)aeccom(dot)com]
> Sent: Wednesday, March 28, 2001 1:32 PM
> To: Michael Fork
> Cc: pgsql-sql(at)postgresql(dot)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(at)postgresql(dot)org so that your
> message can get through to the mailing list cleanly
From | Date | Subject | |
---|---|---|---|
Next Message | Jim Ballard | 2001-03-28 22:27:09 | Re: RE: counting distinct rows on more than one column |
Previous Message | Stephan Szabo | 2001-03-28 20:00:09 | Re: DELETE FROM fails with error |