I'm having troubles with a syntax error when trying to create a function in MySQL to convert a decimal grade into a letter grade.
What could be the issue?
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your mySQL server version for the right syntax to use near 'conv(gpa DOUBLE) RETURNS CHAR BEGIN
DECLARE grade CHAR;
SELECT CASE WHEN gp' at line 1
Here is my code:
delimiter $
CREATE FUNCTION conv(gpa DOUBLE)
RETURNS CHAR
BEGIN
DECLARE grade CHAR;
SELECT CASE WHEN gpa BETWEEN 3.5 AND 4.0 THEN 'A'
WHEN gpa BETWEEN 3.0 AND 3.4 THEN 'B'
WHEN gpa BETWEEN 2.5 AND 2.9 THEN 'C'
WHEN gpa BETWEEN 2.0 AND 2.4 THEN 'D'
ELSE 'F'
END INTO grade
RETURN grade;
END $