我无法添加条件以仅显示出勤率低于 81 的人..
SELECT Absence.StudentID AS StudentNumber,
Student.NAME AS "Student Name",
Subject.NAME AS "Subject Name",
CONVERT(VARCHAR, 100 - (100 * count(*) / 10)) AS 'Attendance(%)'
FROM Absence,
Subject,
Student,
(
SELECT COUNT(*) AS tot
FROM Absence
) x
WHERE Subject.SubjectCode = Absence.SubjectCode
AND Student.StudentNumber = Absence.StudentID
GROUP BY Absence.StudentID,
Subject.NAME,
Student.NAME;
以上是完全显示我想要的代码,但我不能只添加条件。我的出勤率(%) 已经是 int 了,对吗?所以使用 CAST 或 CONVERT 也不起作用。它说转换有问题。