ID POST_ID
1 60
2 457
3 457
4 457
5 25
6 25
最も投票されたリストを取得する方法は次のとおりです。結果は次のようになります。
457
25
60
SELECT post_id
FROM my_table
GROUP BY post_id
ORDER BY COUNT(id) DESC
SELECT post_id, count(post_id) num_votes
FROM your_table
GROUP BY post_id
ORDER BY num_votes DESC
あなたに与える:
+---------+-----------+
| post_id | num_votes |
+---------+-----------+
| 457 | 3 |
| 25 | 2 |
| 60 | 1 |
+---------+-----------+