I have a varchar column. The values are separated using a comma (,).
For example, the column values are as follows:
'P1-101-Part1-This is a part'
'P2-101-Part2-This is a part number 2'
'P3-101-Part1.1-This is a sub part for part 1'
I would like to extract the last value from each column. With respect to the above example, the output should be as follows:
'This is a part'
'This is a part number 2'
'This is a sub part for part 1'
I know that we should use substring function to do this, but I am not sure how I can find out the value after '-' in the reverse direction.
Thanks in advance.
select substr('P1-101-Part1-This is a part',instr('P1-101-Part1-This is a part','-',-1)+1) from dual
answered May 10, 2010 at 04:29 AM