Start here. This is the direct spoken answer to practice first.
Why this question matters
Taking MAX(timestamp) finds a value, not necessarily the rest of the row, and ties can return several candidates. A latest-per-group query needs both group membership and a deterministic definition of latest.
I commonly assign ROW_NUMBER within each parent group, order newest first, and keep row number one. PARTITION BY UserId restarts numbering for each user; ORDER BY CreatedAt DESC, Id DESC defines a deterministic winner when timestamps tie. This returns the complete selected row without joining back on MAX(CreatedAt), which can duplicate results when several rows share the maximum timestamp.