到目前为止我的查询是
SELECT callSign,event,rubric,score
FROM scores LEFT JOIN candidates
ON scores.candidateID=candidates.id
WHERE candidateID IN
(SELECT id
FROM candidates
WHERE assessmentID='1321')
ORDER BY candidateID,event
它返回一个数据集,如:
callSign event score
V021 Amazing Race Planning 5
V021 Amazing Race Planning 3
V021 Amazing Race Planning 5
V021 Individual Analyst Exam 3
V021 PSA 5
V021 Team Analyst Exam 5
V021 Team Analyst Exam 5
V021 Team Analyst Exam 3
V021 Team Analyst Exam 5
V022 PSA 1
V022 Team Tech Exam 5
V022 Team Tech Exam 3
我正在寻找的是每个候选人将每个事件的分数相加,所以它看起来像:
callSign event score
V021 Amazing Race Planning 13
V021 Individual Analyst Exam 3
V021 PSA 5
V021 Team Analyst Exam 18
V022 PSA 1
V022 Team Tech Exam 8
我确定我需要某种和的组合,SUM()
但GROUP BY
我似乎无法弄清楚。然后我需要ORDER BY
所有类别中得分最高的候选人
注意:有多个候选人