postgres max integer in an alphanumeric column

select max(to_number(substring(COLUMNNAME from ‘([0-9].*)’),’99999′)) from TABLENAME

removes letters from a mixed column … can be used for generating a new id

Leave Comment