Re: A counter argument about DISTINCT and GROUP BY in PostgreSQL

From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: dterrors(at)hotmail(dot)com
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: A counter argument about DISTINCT and GROUP BY in PostgreSQL
Date: 2008-01-04 16:50:52
Message-ID: 20080104165052.GC16708@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

dterrors(at)hotmail(dot)com wrote:
>
> I've just spent a few hours searching and reading about the postgres
> way of selecting distinct records. I understand the points made about
> the ORDER BY limitation of DISTINCT ON, and the abiguity of GROUP BY,
> but I think there's a (simple, common) case that have been missed in
> the discussion. Here is my sitation:

Did you try putting the DISTINCT ON in a subselect, and the ORDER BY in
an outer select?

--
Alvaro Herrera http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Afewtips.com 2008-01-04 16:51:59 Re: Connect to SQL Server via ODBC from Postgresql
Previous Message Gregory Stark 2008-01-04 16:48:04 Re: A counter argument about DISTINCT and GROUP BY in PostgreSQL