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.
This conversation is currently closed to new comments.
If you're asking for technical help, please be sure to include all your system info, including operating system, model number, and any other specifics related to the problem. Also please exercise your best judgment when posting in the forums--revealing personal information such as your e-mail address, telephone number, and address is not recommended.
SQL error
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.