sql - Substring only if string length > 2 -


i wondering if possible substring if string length > 2?

here sample statement:

select substring(abresc, 1, 2) + '-' + substring(abresc, 3, 5) abresc table

however, fields 2 chars long wondering if possible substring when longer 2 chars?

you use case

select abresc =     case when len(abresc) > 2         substring(abresc, 1, 2) + '-' + substring(abresc, 3, 5)        else  abresc end   table 

Comments

Popular posts from this blog

django - How can I change user group without delete record -

java - Need to add SOAP security token -

java - EclipseLink JPA Object is not a known entity type -