Wednesday, March 25, 2009

Increment alphanumeric field with padding of zero on left like 'S0002'

select
        'S' || lpad( cast( mx as text ), 4, '0' )
from (
        select
               max( substr( std_code, 2, 4 ) ) as mx
        from
               mst_standard
     ) as t1

No comments:

Post a Comment