我有三张桌子..
Student
Id Name
1 vesd
2 Eet
Subject table
Id name
1 Science
2 maths
Marks
Stud_id Sub_id Marks
1 1 20
1 2 30
2 1 40
2 2 50
我需要学生在每个科目中得分的最大分数。
答案 0 :(得分:0)
这是
SELECT student.name, subject.name, MAX(mark)
FROM marks
INNER JOIN student
ON marks.student_id = student.id
INNER JOIN subject
ON marks.subject_id = subject.id
GROUP BY student.name,subject.name;
您可以在此处查看http://sqlfiddle.com/#!9/bcd3d/1