On Fri, 28 Mar 2008, Sam Mason <sam(at)samason(dot)me(dot)uk> 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.