Re: Selecting exactly one row for each column value

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Florian Weimer <fweimer(at)bfk(dot)de>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Selecting exactly one row for each column value
Date: 2007-03-06 15:32:35
Message-ID: 4736.1173195155@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Florian Weimer <fweimer(at)bfk(dot)de> writes:
> For each value in the first column, I need one (and only one) matching
> row from the table. A possible solution is:

SELECT DISTINCT ON would do it, if you don't mind a non-portable solution.

regards, tom lane

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Rodrigo De León 2007-03-06 15:37:03 Re: [SQL] Time of executed query
Previous Message A. Kretschmer 2007-03-06 15:17:19 Re: Selecting exactly one row for each column value