I have table like this:
type | date | id
-----------------------------
1 | 2012-01-01 | 1
2 | 2012-01-01 | 2
1 | 2012-02-02 | 3
2 | 2012-02-02 | 4
I need to build query that will pick all "up-to-date" distinct values of type ( in this example it will be records with id's 3 and 4). Now i have this solution :
select * from test t1 where date =
(select max(date) from test t2 where t2.type = t1.type ) order by type, date desc
I am embarrassed by the presence of nested select, maybe there is more elegant solution ?