I have table 'EMP' with column 'SerialNumber' and values as S001, S002, S003, S004...till S100. I need the result to display SerialNumber as 001, 002, 003, 004..till 100. How do I write this query?
CodePudding user response:
Here are two ways to do it:
select substr(SerialNumber, 2) as SerialNumber
from emp
OR
select replace(SerialNumber, 'S', '') as SerialNumber
from emp
CodePudding user response:
I would use the function REPLACE:
REPLACE( target_column, bad_string, good_string)
Select REPLACE(SerialNumber, 'S', 'Serial Number ') from EMP;
Check this page for how Replace works.