这是我的SQL代码包含的表:tblstudentdetail和tblstudentinfo
SELECT distinct TblstudentInfo.FirstName +''+ TblstudentInfo.LastName as Name,TblstudentInfo.StudentID,TblstudentInfo.YearID,TblstudentInfo.Dualcredits,TblstudentInfo.DC_Classes,TblstudentInfo.DC_GPA,tblStudentDetail.StatusID,TblstudentInfo.actScore,tblStudentDetail.YearID,tblStudentDetail.TermID,tblStudentDetail.GPA
FROM TblstudentInfo
left join tblStudentDetail on TblstudentInfo.StudentID = tblStudentDetail.StudentID
order by name
结果:
Name StudentID YearID Dualcredits DC_Classes DC_GPA StatusID actScore YearID TermID GPA
Aaron 124 9 NULL NULL NULL 1 17 10 1 2.901
Aaron 124 9 NULL NULL NULL 1 17 10 2 3.171
Aaron 124 9 NULL NULL NULL 1 17 11 1 2.31
Aaron 124 9 NULL NULL NULL 1 17 11 2 3.31
Debbie 2344 7 NULL NULL NULL 1 19 9 1 4.31
Debbie 2344 7 NULL NULL NULL 1 19 10 1 4.31
如何平均平均GPA?我想要这样的结果:
Aaron 124 9 NULL NULL NULL 1 17 2.923
Debbie 2344 7 NULL NULL NULL 1 19 4.31