I have a MySQL function where I have a cast to DECIMAL like this
DECLARE len INT;
SET len = 10;
CAST((COUNT(*) * 1.5) AS DECIMAL(len))
However when I run it I get error
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 'len)
What I want is to use a variable len in AS DECIMAL() expression.