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