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

java - Jasper subreport showing only one entry from the JSON data source when embedded in the Title band -

serialization - Convert Any type in scala to Array[Byte] and back -

SonarQube Plugin for Jenkins does not find SonarQube Scanner executable -