SQL Server : select distinct by one column and by another column value
问题 This is a SQL Server table's data id user_id start_date status_id payment_id ====================================================== 2 4 20-nov-11 1 5 3 5 23-nov-11 1 245 4 5 25-nov-11 1 128 5 6 20-nov-11 1 223 6 6 25-nov-11 2 542 7 4 29-nov-11 2 123 8 4 05-jan-12 2 875 I need to get distinct values by user_id also order by id asc , but only one user_id with highest start_date I need the following output: id user_id start_date status_id payment_id ==============================================