SQL (SELECT DISTINCT ON)

Dec 07, 2009 13:58

Выборка уникальных значений с сортировкой по выбранному полю.

SELECT * FROM (
SELECT DISTINCT ON (field1) field1, time_field FROM table
) as tbl
ORDER BY time_field DESC

sql

Previous post Next post
Up