This function would be to return the last two "955 12 " or to return the number without the last two digits " 955 12".
The value passed to function can vary by at least 3 characters and at most 11
DELIMITER $$
DROP FUNCTION IF EXISTS subInteiro $$
CREATE FUNCTION subInteiro(nCOD INT, nIncio INT, nFim INT) RETURNS VARCHAR(500)
DETERMINISTIC
BEGIN
DECLARE lvl VARCHAR(500);
SET lvl = SUBSTRING(CAST(nCOD AS CHAR), nIncio, CHAR_LENGTH(CAST(nCOD AS CHAR)) - nFim ) ;
RETURN (lvl);
END $$
DELIMITER ;
I'm doing these tests
SELECT subInteiro(4518486299,-2,2); # return 47
SELECT subInteiro(201,-2,2); # return 0
In the first example it was for returns 99 and in the second 01