I have this query:
SELECT
Max(l.created) AS created,
l.unit_id,
l.activity_id AS Active
FROM unit_log AS l
GROUP BY l.unit_id, l.activity_id
What I need and can't seem to get, is the MAX() row per unit_id. I need the unit_id in the query because I am joining to another table. The created column is a timestamp.
Each unit_id will have hundreds of entries. All I'm concerned with is the most recent one per unit. Can someone show me why this isn't working?