I have a MySQL database, it contains a table that contains some data in columns of type varbinary(20)
Don't ask me why - it just is and i need to deal with it.
This data represents the number of modules a student has completed as part of a course. There is also another column called criterias that represents the number of modules that must be completed in order for the course to be marked complete. When I am doing a count of the number of completed courses, I want to count the rows where
completed = criteria AND completed != 0 ( ...oh and where the student is enrolled)
(because in some cases the criteria is 0 so I want to skip any courses where a student has completed 0 of 0 modules).
Additionally for some reason the value of 0 in the varbinary column is 30 (if anyone can offer an explanation for this then great) and so where there are 3 modules that need to be completed the value in the criteria column will be 33
So my SQL query looks like this -
count(CASE WHEN (completed <> 30 AND (completed = criterias) AND enrolled = 'Yes') THEN 1 END) AS Total_Complete
However this count seems to include courses where student has completed 0 of 0 courses so it would appear that my completed <> 30 is not working.