After Hours

General discussion


SQL error

By vjsimon ·
Tags: Off Topic
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.

Thread display: Collapse - | Expand +

All Comments

Collapse -

I think your nesting is wrong on convert line

by robo_dev In reply to SQL error

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

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

Related Discussions

Related Forums