Search Postgresql Archives

Re: SELECT DISTINCT ON and ORDER BY

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 28 Mar 2008, Sam Mason <sam@xxxxxxxxxxxxx> writes:
> On Fri, Mar 28, 2008 at 01:12:49PM +0100, Stanislav Raskin wrote:
>> The result in this case should be:
>> 
>> id value  order_field
>> 3   10      1
>> 5   12      2
>> 4    5      8

Yet another lame solution:

test=# SELECT max(id) AS id, min(value) AS value, min(weight) AS weight
         FROM tmp
        GROUP BY value
        ORDER BY min(weight);
 id | value | weight
----+-------+--------
  3 |    10 |      1
  5 |    12 |      2
  4 |     5 |      8
(3 rows)


Regards.

-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux