Select latest row for each group from oracle
You can use analytic functions SELECT * FROM (SELECT c.*, rank() over (partition by user_id order by ts desc) rnk FROM comments c) WHERE rnk = 1 Depending on how you want to handle ties (if there can be two rows with the same user_id and ts), you may want to use the row_number or … Read more