Hello,
I've left joined two tables. I now want to retrieve only the latest record(highest punch_id) for EACH username(punch_username). So if after the left join, I have a table with the following:
punch_id punch_username employee_username employee_fullname
1 bob bob Bob Smith
2 steve steve Steve Jacobs
3 steve steve Steve Jacobs
4 janet janet Janet Kye
5 bob bob Bob Smith
6 janet janet Janet Kye
7 steve steve Steve Jacobs
8 bob bob Bob Smith
9 steve steve Steve Jacobs
10 steve steve Steve Jacobs
Using the WHERE clause(I think) I'd like ONLY the following records to be returned:
8 bob bob Bob Smith
10 steve steve Steve Jacobs
6 janet janet Janet Kye
This is a simplified version of my SQL statement(The full statement has fields which are time sensitive which is why I want the latest records):
SELECT time_punch.punch_id, time_punch.punch_username, time_employees.employee_username, time_employees.employee_fullname
FROM time_punch LEFT JOIN time_employees ON time_punch.punch_username=time_employees.employee_username
Is there a way to get the latest record(using punch_id) for each username(using punch_username)?
Thank you!
Peter