select value, value3, max(date) from mitabla t inner join ( select value, max(date) [date] from mitabla group by value ) t1 on t.value=t1.value and t.date=t1.date group by value, value2, value3