Sorry, Campbell, error message numbers are almost universally useless. Especially Oracle ones, IBM
jdbc codes, and, alas MariaDB/MySQL. Although at least that last will give a half-way useful message text.
May I suggest a bit of tidying:
Mostly what I've done is make things not stretch halfway to Mars, but I also prefer to capitalize my keywords to make them more visible. And, incidentally, I would give my usual caution about using upper-case letters in table and column names, but I'll leave it to the MariaDB manual.
Having said that, it looks like there's a (yuck!) stored procedure being created/called here and a VERY complex query. Usually when a query has that many constants in it, I prefer to define a View, myself. It simplifies the actual query and you get a benefit that if your criteria change, you can re-define the View instead of changing program logic.
And what's with the "concat" in the ORDER BY. Why not simply "ORDER BY s.staff_First_Name, s.staff_Last_Name"?
The error message, incidentally, seems to be referencing a "leave2" which isn't even in this query, so I suspect we're not being told everything!