[SQL] How to get last inserted times from users?

I want to build a SQL query to selected the last inserted time ("end_time") from users.

I have tried this query:

SELECT distinct uid, end_time FROM timesheet_times GROUP by end_time DESC;

But I get many duplicated entries!

Comments

andretenreiro:

Thanks!

It works!

I was complicating the SQL query indeed!

PS: It's necessary to add the GROUP by UID

tommo:

I think the "distinct" doesn't do want you want, it just avoids duplicated rows in the result, i.e. same uid and end_time.

I am no SQL expert, but I guess using the max() function might be easier. This is untested:
SELECT uid, max(end_time) FROM timesheet_times