I have a table in SQL, The table is like this:
+-------------+---------------+-------------------------+
| quotes_user | email_address | ________Sent_at________ |
+-------------+---------------+-------------------------+
| user1 | email1 | 2012-10-09 12:23:53.253 |
| user1 | email2 | 2012-10-09 12:24:53.253 |
| user2 | email3 | 2012-10-09 13:20:53.253 |
| user2 | email4 | 2012-10-09 11:23:53.253 |
| user3 | email5 | 2012-10-08 10:29:53.253 |
| user3 | email6 | 2012-10-08 14:23:53.253 |
+-------------+---------------+-------------------------+
I want the result to show
+-------------+---------------+-------------------------+
| quotes_user | email_address | ________Sent_at________ |
+-------------+---------------+-------------------------+
| user1 | email2 | 2012-10-09 12:24:53.253 |
| user2 | email3 | 2012-10-09 13:20:53.253 |
| user3 | email6 | 2012-10-08 14:23:53.253 |
+-------------+---------------+-------------------------+
i.e. I want to select List of unique users, and the latest email address associated with them.
Another way to explain the problem would be, that I want to select a field which is not included in any aggregate function or order by clause. I've tried many statements with lots of permutations of Distinct and Order By, Group By etc. to no use.
I'm trying to avoid multiple statements.
Please help me out with this.