Join three tables with MAX function
问题 I have three tables: student , subject and score . I want to display the details of max(subject_id) of each student. student table student_id student_name exam_date 1 Sharukh 24/06/12 2 Amir 23/06/12 subject table subject_id sub_name 200 Maths 300 English 400 Science score table student_id subject_id score 1 200 50 1 300 20 2 300 10 The result should be: student_id student_name subject_id score 1 Sharukh 300 20 2 Amir 300 10 回答1: Use the MAX function and GROUP BY your other selections. SELECT