I have a comment table
| comment_id | when_added |
|---|---|
| 10 | 02/23/2022 |
| 21 | 02/23/2022 |
| 10 | 02/24/2022 |
I needed to get the count, comment_id, and the latest when_added
| comment_id | when_added | count |
|---|---|---|
| 10 | 02/24/2022 | 2 |
| 21 | 02/23/2022 | 1 |
I tried this query
SELECT COUNT(*) as count, comment_id, when_added
FROM comment
GROUP BY comment_id, when_added
ORDER BY when_added DESC;
Is there a way to group by only using comment_id?