我必须得到我工作的地方学生的期末成绩。
该查询工作得很好,除了如果有一个 0 值,它包括它,这不会发生。如何从查询中排除 0,如果我没记错的话,排除的 0 必须来自查询中的 AVG。
这是我的查询:
SELECT
gbc.StudentID as [Student ID],
per.FirstName + ' ' + per.MiddleName + ' ' + per.LastName as [Student Name],
gbc.ClassID as [Class ID],
cls.Name as [Class Name],
ROUND(SUM(gbc.weightedgrade),0) as [Final Grade]
FROM (SELECT
gg.ClassID,
gg.StudentID,
ga.AssessmentId,
ga.Title ,
AVG(gg.ReceivedPoints * ga.Weight / 100.0) as weightedgrade
FROM GbkAssessments as ga INNER JOIN GbkGrades as gg ON ga.AssessmentID = gg.AssessmentID AND ga.ClassID = gg.ClassID
JOIN Classes as cls on ga.classID = cls.classID JOIN GbkSummary as gbs on ga.classID = gbs.classID
WHERE gg.StudentID = 1201417 and cls.YearID = 251 and gbs.TermID = 1
GROUP BY gg.StudentID, gg.ClassID, ga.AssessmentId, ga.Title) as gbc JOIN Classes as cls on gbc.classID = cls.classID
join Person as Per on Per.PersonID = gbc.StudentID join Person_Student as PS on Per.PersonID = PS.StudentID
GROUP BY gbc.StudentID, gbc.ClassID, cls.Name, per.FirstName, per.LastName, per.MiddleName
ORDER BY gbc.ClassID ASC
我的查询包括一些存在但还没有值的评估中的 0,例如尚未应用的测验,尚未检查的课堂作业。
如何从考虑中删除这些值?是否有 AVGIFNOTNULL 或类似的东西?