上传表格
id category_id
1 1
2 2
3 3
4 1
在评级表中
id upload_id points
1 1 5
2 2 3
3 3 2
4 4 2
5 1 5
我想显示除了id 4之外的评级表中的所有记录,因为id 4是相同的类别id 1
我除了结果
Uploaded_id 1总和为10分
Uploaded_id 2总和为3分
Uploaded_id 3总和为2分
请帮帮我。
提前致谢
Sasikumar
答案 0 :(得分:0)
select upload_id, sum(points)
from rating r,
(select min(id) id from upload group by category_id) a
where a.id = r.upload_id group by upload_id