別の質問から、スコアを適切に合計するために次のクエリを取得しました。
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
callSign は X125 が行く場所です