我的意思是Title是这样的:说我有100行。一列是review_id
。然后,我想要Group By
review_id
。然后,我想count
每组行,然后Sort By
。
示例结果:20行review_id 132,17行review_id
434行,8行review_id
22 - (这是按降序排序)
我该怎么做?以下是参与的球员:
列中名为vote
且review_id
的表格。它与一个名为reviews
的表结合,review_id
作为其唯一键。
答案 0 :(得分:1)
SELECT COUNT(a.review_id) as total, a.review_id
FROM vote a
INNER JOIN reviews b
ON a.review_id = b.review_id
GROUP BY a.review_id
ORDER BY total ASC
答案 1 :(得分:0)
select
count(vote.review_id)
from vote, review
where
vote.review_id = review.review_id
group by
vote.review_id