Retrieving the last record in each group There is a table messages that contains data as shown below: Id Name Other_Columns ------------------------- 1 A A_data_1 2 A A_data_2 3 A A_data_3 4 B B_data_1 5 B B_data_2 6 C C_data_1 If I run a query select * from messages group by name, I will get the result as: 1 A A_data_1 4 B B_data_1 6 C C_data_1 What query will return the following result? 3 A A_data_3 5 B B_data_2 6 C C_data_1 That is, the
undefined
How can I SELECT rows with MAX(Column value), DISTINCT by another column in SQL? My table is: id home datetime player resource ---|-----|------------|--------|--------- 1 | 10 | 04/03/2009 | john | 399 2 | 11 | 04/03/2009 | juliet | 244 5 | 12 | 04/03/2009 | borat | 555 3 | 10 | 03/03/2009 | john | 300 4 | 11 | 03/03/2009 | juliet | 200 6 | 12 | 03/03/2009 | borat | 500 7 | 13 | 24/12/2008 |