Watercooler

SQL error

Tags: Off Topic
+
0 Votes

SQL error

vjsimon
I am having trouble adding the condition to only show those with attendance less than 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;

The above is the code that displays exactly what I want but I cannot add in the condition only. My Attendance(%) is already int right? So using the CAST or CONVERT does not work either. It says it has trouble converting.

Your kind assistance will be greatly appreciated.