Re: problem with distinct not distincting...

From: Merlin Moncure <mmoncure(at)gmail(dot)com>
To: John Beynon <john(at)kyan(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: problem with distinct not distincting...
Date: 2012-10-17 17:59:44
Message-ID: CAHyXU0xM94qiayMDV_pzeAr=ATjqRK5m1WYs3cQz1CvivxDW0w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, Oct 17, 2012 at 5:48 AM, John Beynon <john(at)kyan(dot)com> wrote:
> I have a pretty basic query;
>
> select distinct on (name) name, length(name) from
> drugs
> where customer_id IS NOT NULL
> order by name;
>
> which I'd expect to only return me a single drug name if there are
> duplicates, yet I get
>
> name | length
> ==========
> Roaccutane | 10
> Roaccutane | 10
>
> table encoding is UTF8...
>
> I'm scratching my head!

as a sanity check, try:

select distinct on (name) name, length(name), md5(name) from
drugs
where customer_id IS NOT NULL
order by name;

merlin

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tulio 2012-10-17 18:14:55 Re: allow servers to access to the same data
Previous Message Daniel Serodio (lists) 2012-10-17 17:53:31 Re: allow servers to access to the same data