Need a query [message #189889] |
Mon, 28 August 2006 06:13 |
lotus14
Messages: 5 Registered: February 2005
|
Junior Member |
|
|
Hi friends,
I need a query to display the name "Devanand Santhosh Rao" as D.S.Rao.
Please help me.
|
|
|
Re: Need a query [message #189892 is a reply to message #189889] |
Mon, 28 August 2006 06:32 |
gold_oracl
Messages: 129 Registered: July 2006 Location: Westborough, MA
|
Senior Member |
|
|
select substr('Devanand Santhosh Rao',1,1)||'.'||substr('Devanand Santhosh Rao',instr('Devanand Santhosh Rao',' ',1,1)+1,1)||'.'||substr('Devanand Santhosh Rao',instr('Devanand Santhosh Rao',' ',1,2)+1) from dual;
PS: this query not generic one. it will produce accurate result if you have given three word, otherwise not. so change accordingly for requirement
Thanks,
Thangam
|
|
|
Re: Need a query [message #189897 is a reply to message #189889] |
Mon, 28 August 2006 07:06 |
|
ebrian
Messages: 2794 Registered: April 2006
|
Senior Member |
|
|
SQL> select translate(substr(name,1,instr(name,' ',-1)),' abcdefghijklmnopqrstuvwxyz','.') ||
substr(name,instr(name,' ',-1)+1) "Name" from (
select 'Devanand Santhosh Rao' name from dual);
Name
-------
D.S.Rao
|
|
|