Let's say I have a table with 3 columns
USER | MEAL | TIMESTAMP
"user1" | "bagel" | 2022-01-01 8:00:00
"user1" | "sandwich" | 2022-01-01 12:00:00
"user1" | "spaghetti" | 2022-01-01 18:00:00
"user2" | "cereal" | 2022-01-01 9:30:00
"user2" | "soup" | 2022-01-01 12:30:00
"user2" | "pizza" | 2022-01-01 20:00:00
How can I SELECT the most recent MEAL for each USER? My assumption is something like:
SELECT MEAL, USER
FROM MEAL_TABLE
GROUP BY USER
HAVING MAX(TIMESTAMP)
but this doesn't work because MEAL is not aggregated.