从另一个问题,我得到这个查询来获取我的考试成绩总结了正确:
SELECT callSign,event, SUM(score)
FROM scores LEFT JOIN candidates
ON scores.candidateID=candidates.id
WHERE candidateID IN
(SELECT id
FROM candidates
WHERE assessmentID='1321')
GROUP BY event, callSign
ORDER BY candidateID,event
我得到的,看起来像数据:
callSign event TotalScore
Y209 Bridge 45
Y209 PSA 3
Y209 Team Analyst Exam 40
X125 PSA 1
X125 Team Analyst Exam 38
V023 Amazing Race Planning 37
我需要的是像数据:
callSign Bridge PSA Amazing Race Planning Team Analyst Exam
V023 37
Y209 45 3 40
X125 1 38
表结构
`events`
id event
1 PSA
2 Bridge
30 Stress Board
25 Amazing Race Planning
26 Amazing Race Execution
`scores`
id candidateID event rubric category score comment
1 18 Team Analyst Exam Team Leader Rubric Organizes and Tasks Team Members 3
2 18 Team Analyst Exam Team Leader Rubric Roles and Responsibilities 5
3 18 Team Analyst Exam Team Leader Rubric Backward Planning 5
4 18 Team Analyst Exam Team Leader Rubric Time Management
`candidates`
id firstName middleInitial lastName callSign service rank sex height weight assessmentID currentlyAssessing hired
呼号就是X125会去