Using MAX() in VARCHAR Field Using MAX() in VARCHAR Field oracle oracle

Using MAX() in VARCHAR Field


You get D010 because alphabetically, D010 comes after D0012 or said another way, D01 comes after D00 and therefore anything that is D01x comes after anything that starts D00x.


below code is working for me as per your expectation

select max(to_number(regexp_substr(id, '\d+'))) id from <yourtable>;


this should work

Select MAX(ID) from table where IsNumeric(ID) = 1 ;