求一SQL语句.
现有4张表:
studentmain:学生表
student_id,student_name
studentscore:分数表
student_id,test_id,student_score
subjectmain:学科表
subject_id,subject_name
testschedule:考试日程表
test_id,subject_id,test_date,test_type (test_type为考试类型,0表示正式考试,1表示补考.)
现在要求是:查询出 每个学生的每门课程的最近一次考试的分数
如现有以下数据:
student_id student_name
00001 Mary
00002 Jack
student_id test_id student_score
00001 1001 56
00001 1002 78
00001 1003 98
subject_id subject_name
11111 Maths
22222 Chinese
test_id subject_id test_date test_type
1001 11111 2007/1/1 0
1002 11111 2007/2/2 1
1003 22222 2007/3/3 0
1003 22222 2007/4/4 1
那查询出来的数据可不可能是:
student_name subject_name student_score test_type
Mary Maths 78 1
Mary Chinese 98 0
Jack Maths null null
Jack Chinese null null