I want to enter the following function to count a number of finished tasks from a mysql table in phpmyadmin, but its always returning a none descriptive error:
DELIMITER $$
CREATE FUNCTION `num_completed`(v1 INT)
RETURNS INT
BEGIN
DECLARE icm INT;
SELECT SUM(IF(completed='yes',1,0)) AS completed INTO icm FROM ri_t_course_progress WHERE enrollment_id=v1;
RETURN icm;
END$$
The query itself should be correct. I've tested it and returns the desired result. Anybody know whats wrong?
create function ....mysqland it created the function with no errors.