General discussion

  • Creator
  • #2170026

    SQL error


    by 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.

All Comments

  • Author
    • #3042171

      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))

Viewing 0 reply threads