Table structure
id (p) | date | id2 (fk) | id3 (fk)
where (p) is primary id and (fk) is foreign key
This query returns a list of latest unique rows
select
max(date) as date1,
id1,
id2
from `table`
group by id1, id2
I would also like to have the second date in a row, which have to be the second highest date
Something like
select
max(date) as date1,
max_second(date) as date2,
id1,
id2
from `table`
group by id1, id2