I have table containing multiple columns and I want to get maximum value from invoice number which consists of alphanumeric value like "AR564". I know I should have numeric column to make this happen but now I have a lot of data and it is difficult to change basic things. So I want to solve problem of getting "AR999" as maximum instead of "AR1000". I have tried doing
SELECT MAX(CAST(SUBSTRING(invoice_number, 4, length(invoice_number)-2) AS UNSIGNED))
FROM table
but getting following error.
IErrorInfo.GetDescription failed with E_Fail (0x80004005)
I am using Microsoft Access database and please someone tell me what is the purpose of "4" in above sql statement.