I have a purchased database with non-zero-padded alphanumeric golf course "numbers" like ZZ-1, ZZ-2, ZZ-9, ZZ-10...
I need to write a query which will pull the MAX numeric value and MAX when used on a string does not DWIM and sorts ZZ-9 as MAX over ZZ-10.
SELECT MAX( CourseNumber ) AS x
FROM courses
WHERE CourseNumber
RLIKE 'ZZ'
Same problem when only selecting the digits:
SELECT MAX(SUBSTR(CourseNumber, 4)) AS x
FROM courses WHERE CourseNumber RLIKE 'ZZ'
Anyone have a clever way to do this? I was think it must involve SUBSTR but I couldn't think how to make it work.