How to get right side value after comma [message #631761] |
Mon, 19 January 2015 10:10 |
|
cplusplus1
Messages: 58 Registered: October 2012 Location: usa
|
Member |
|
|
select name_full_fomatted from hlth_prof;
returning result:
'Williams MD, Heather Ann'
'Marcada MD, Pamela J'
Doing this to get the value on the left of comma.
ltrim(rtrim(SUBSTR(NAME_FULL_FORMATTED,1,instr(NAME_FULL_FORMATTED,',')-1))) as first_name,
how to get the value after comma which is to right?
Thanks a lot for the helpful info.
|
|
|
|
Re: How to get right side value after comma [message #631764 is a reply to message #631761] |
Mon, 19 January 2015 10:19 |
|
cplusplus1
Messages: 58 Registered: October 2012 Location: usa
|
Member |
|
|
Using this, working thanks.
SELECT SUBSTR('abc,def', INSTR('abc,def',',', -1, 1)+1)
FROM DUAL;
Edited by Lalit : Added code tags
[Updated on: Mon, 19 January 2015 10:39] by Moderator Report message to a moderator
|
|
|
|
Re: How to get right side value after comma [message #631777 is a reply to message #631770] |
Mon, 19 January 2015 11:20 |
|
Michel Cadot
Messages: 68617 Registered: March 2007 Location: Nanterre, France, http://...
|
Senior Member Account Moderator |
|
|
Yes, I didn't say anything as it will then work for any number of commas:
SQL> SELECT SUBSTR('abc,def,ghi', INSTR('abc,def,ghi',',',-1, 1)+1) from dual;
SUB
---
ghi
SQL> SELECT SUBSTR('abc,def,ghi', INSTR('abc,def,ghi',',') + 1) from dual;
SUBSTR(
-------
def,ghi
|
|
|
|
|
|