Tays
2007-05-11 19:49:02 UTC
my tables are
Student ( (pk)student_id, student_name, teacher_id)
Student_Subject ( (pk)student_id, (pk) subject_id, mark)
subject ( (pk)subject_id, subject_name)
Okay I am trying to do a correlative subquery to produce a listing showing the MAXIMUM MARK obtained by each STUDENT (regardless of subject). Output needed, Student_id, student_name, subject_name and maximum mark.
i can get the student_id, student name and the maximum mark for each student, I am having problems just getting the subject_name slotted in.
this is my query so far
SELECT s1.student_id, s1.student_name, (select max(mark) from student_subject
where student_id = s1.Student_id) AS StudentMaxMark
FROM Student AS s1
WHERE EXISTS
(SELECT * FROM sTUDENT_SUBJECT S2
WHERE STUDENT_ID=S1.STUDENT_ID)
GROUP BY s1.student_id, s1.student_name;
everytime I try and get the subject_name involved i get too much output, this again is driving me nuts ta