So I have some data like follows:
ID group timestamp
001 AA 2021-03-23 22:48:34.879
002 XT 2021-03-24 01:18:34.879
002 BB 2021-03-25 22:42:34.879
003 SW 2021-03-25 12:53:34.879
003 Fe 2021-03-25 14:37:34.879
003 AA 2021-03-25 13:26:34.879
And I just want to condense it to the max timestamp
for each ID
and bring on the appropriate Group as well. This means I want every since ID in the table but only once, and the one iteration is the row with the most recent timestamp
Here's what I want it to look like:
ID group timestamp
001 AA 2021-03-23 22:48:34.879
002 BB 2021-03-25 22:42:34.879
003 Fe 2021-03-25 14:37:34.879
I thought this code would work but it really isn't.....
SELECT ID, group, MIN(TIMESTAMP) as last_time
FROM tbl
GROUP BY ID, group