I want to wind up with a set of data that shows the user by the latest timestamp. Here is my SQL
SELECT
t2.unit AS UnitNo,
t1.lname AS Name,
t4.code_id AS ActivityNo,
t5.activity_id AS Active,
t4.call_no AS CallNo,
t4.acn_id AS CallStatusNo,
t2.unit_id AS UnitId,
Max(t5.created) created
FROM user AS t1
Inner Join unit AS t2 ON t1.user_id = t2.user_id
Left Join dispatch AS t3 ON t2.unit_id = t3.unit_id
Left Join incident AS t4 ON t4.incident_id = t3.incident_id
Left Join unit_log AS t5 ON t2.unit_id = t5.unit_id
WHERE
t1.id = 1
GROUP BY
t2.unit,
t1.lname,
t4.code_id,
t5.activity_id,
t4.call_no,
t4.acn_id,
t2.unit_id
ORDER BY created desc
I've included a pic to show what I'm after. What I should end up with are 2 rows. There are 2 users on this system currently, so I should see only one MAX(created) row per user. Even after grouping, I can't get get down past what you see here.