Need help in query [message #235308] |
Fri, 04 May 2007 18:44 |
grk28
Messages: 38 Registered: June 2006
|
Member |
|
|
Hi fnrds,
I have a typical requirement which is as follows..
My data is as follows
Id Name
1 JOHN
2 wenDy
3 wendy
My output should be as follows
Id Name
1 John
2 WenDy
3 Wendy
i.e i need to display the name with initial cap irrespective of remaining letters case and if all are in upper case then they need to convert into the lower case.The requirements seems to be strange ..
i have acheived 2& 3 by using
initcap(substr(name,1,1))||substr(name,2)
but i am stuck in converting the first record to John.
Is there any way to get that as well..
Immediate help would be appreciated.
Thanks in Advance
|
|
|
Re: Need help in query [message #235311 is a reply to message #235308] |
Fri, 04 May 2007 19:45 |
g-rz
Messages: 3 Registered: May 2007
|
Junior Member |
|
|
Try this query
select decode(upper(substr(name,2)),substr(name,2),initcap(substr(name,1,1))||substr(lower(name),2),initcap(substr(name,1,1))||substr(name,2 )) as name
I inserted a 4th row with jOHN, i think the result must be John and the query does it.
ORIGINAL NAME
-------- ----
JOHN John
wenDy WenDy
wendy Wendy
jOHN John
|
|
|
|