Tuesday, June 14, 2011

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
Post a Comment