我有以下表格:
Table 1
Student , Exam_ID
1 1
2 1
3 2
1 2
3 3
2 3
3 4
1 4
Table 2
Exam ID, Mark
(1 , 5)
(2 , 4)
(3 , 4)
(4 , 5)
Table 3
Exam ID, Teacher's review
(1,3)
(2,5)
(3,4)
(4,2)
Table 4
Exam_ID, Start_Time, End_Time
(1,2:00:00,3:50:00)
(2,2:00:00,4:00:00)
(3,3:00:00,5:20:00)
(4,3:00:00,5:00:00)
每个考试由成对的学生解决...我希望能够对每对学生所进行的所有考试的分数,教师评论进行平均,例如:考试2和4由同一对考试学生(3,1)我希望能够平均那些(4,5)= 4.5和教师评论(5,2)= 3.5的2门考试的分数 然后将这些对从最高分到最低分和教师评论进行排名,并能够计算每次考试的开始和结束时间之间的差异,并将其包括在排名中 所以所需的表格如下:
StudentA, StudentB, AverageMark, AverageTeacher'sReview, AverageExamDuration
( 3, 1, 4.5, 3.5, 2:00:00)
等
相关问题:average-multiple-rows-in-a-column-in-access
谢谢
答案 0 :(得分:0)
听起来像是家庭作业,第一次加入的!=可能就是你应该学习的东西。
select A.StudentId as StudentA,
B.StudentId as StudentB,
AVG(Mark) as AvgMark,
AVG(review) as AvgReview,
AVG(DATEDIFF(MINUTE,StartTime,EndTime)) as AvgTime
from StudentToExam A
inner join StudentToExam B on A.ExamId = B.ExamId and A.StudentId != B.StudentId
inner join ExamToMark M on A.ExamId = M.ExamId
inner join ExamToReview R on A.ExamId = R.Review
inner join ExamDuration D on D.ExamId = A.ExamId
GROUP BY A.StudentId, B.StudentId