Home » SQL & PL/SQL » SQL & PL/SQL » Problem in Sql
Problem in Sql [message #273737] Thu, 11 October 2007 09:28 Go to next message
anilreddy76
Messages: 9
Registered: September 2007
Junior Member
Hi,

I'm having one table with the column name as "description" and it has the following values.

"2BELL","WINDWARD","GLENRIDGE","ALLEN","FF_Fairfield",SD_SanDiego,"SF_Southfield".

I've written the following query to make every thing as lower case and INITCAP of first letter and also the to retrive the characters after "_".

I'm facing one problem here,Query is working fine,but for "2BELL" it is retrieving me as "2bell",I want to display it as "2Bell".

Select INITCAP(lower(trim(substr(data_center.DESCRIPTION, instr(data_center.DESCRIPTION, '_', 1)+1)))) as datacenter from data_center;

Please advise me for any suggestions..

Thanks,
Anil
Re: Problem in Sql [message #273856 is a reply to message #273737] Fri, 12 October 2007 00:42 Go to previous message
dhananjay
Messages: 635
Registered: March 2002
Location: Mumbai
Senior Member
hi,

may be you will find better solutions than this.
with data as 
(select '2bell' name from dual union all
select 'fall' from dual union all
select 'light' from dual
)
select decode(regexp_instr(name,'[0-9]'),1,substr(name,1,1)||initcap(substr(name,2)),
initcap(name)) name from data




regards,
Previous Topic: pl/sql
Next Topic: PL/SQL Cursor question
Goto Forum:
  


Current Time: Sun Dec 04 04:21:41 CST 2016

Total time taken to generate the page: 0.04128 seconds