try this:select top 50 t1.vacancy_pointer, t1.person_pointer, t1.creationdate, t1.type from vacancytransaction t1 join (select vacancy_pointer, person_pointer, max(creationdate) as creationdate from vacancytransaction group by vacancy_pointer, person_pointer ) t2 on t1.vacancy_pointer = t2.vacancy_pointer and t1.person_pointer = t2.person_pointer and t1.creationdate = t2.creationdatewhere t1.vacancy_pointer <> 0 AND t1.person_pointer <> 0order by t1.vacancy_pointer, t1.person_pointer, t1.creationdate
Go with the flow & have fun! Else fight the flow