Discussion Locked

SQL error

0 helpful
1 reply
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

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.

1 reply

by robo_dev

CONVERT ( data_type [ ( length ) ] , expression [ , style ] )

CONVERT (varchar, (100-(100 * count(*) /10))

This discussion is closed to new replies.