次の3つのテーブルがあります。
student
-------
stnumb
stname
gender
grade
born
subject
-------
subjnumb
subjname
tname
results
-------
stnumb
subjnumb
percent
私は返す必要がありますhighest result and its subject for each student
例:Bob Smith、IPT、92
私が得た2つの最も近い結果は次のとおりです。
SELECT stname
, subjname
, highestmark
FROM (
SELECT MAX(results.percent) as "highestmark"
, student.stname
, subject.subjname
FROM student
, subject
, results
WHERE results.stnumb = student.stnumb
AND results.subjnumb = subject.subjnumb
GROUP BY stname
) maxresult
...と...
SELECT student.stname as Student
, subject.subjname as Subject
, results.percent as Mark
FROM results
JOIN student
ON results.stnumb = student.stnumb
JOIN subject
ON results.subjnumb = subject.subjnumb
ORDER BY stname
誰かが私を正しい方向に向けてくれませんか?私は何日もそれに取り組んできましたが、何の根拠もありません。