I have a “messages” table with the following columns:
id(primary Key)usernametimestampcontent
I want to get a list of distinct usernames sorted by their latest message. I get the DISTINCT part but don’t know how to make it return the one with the latest timestamp. I only have this so far.
SELECT DISTINCT username FROM messages
I’d approach this slightly differently: