I want to find maximum number in sql server i have values with string part and integer part -


i have values sp-1,sp-2,sp-3.....sp-10,sp-11.

i have maximum number here in sql server

select max(substring(supplementid,4,10)) max_num supreg 

when execute code maximum number 9.

try:

select max(cast(substring(supplementid,4,10) int)) max_num supreg 

or

select max(cast(replace(supplementid,'sp-','') int)) max_num supreg 

Comments

Popular posts from this blog

cron - how to properly run Python script with crontab on every system startup -

elasticsearch - Is the order of operations guaranteed in a bulk update? -

Slow performance first queries on SQL Azure -