Google
Information Storage and Retrieval: Change Case (SQL Puzzle 19)

Pages

Monday, August 25, 2008

Change Case (SQL Puzzle 19)

Problem:
The values in a column "Location" of your table are as follows:
Location
---------------
asw-qwer-sdf
bnm-sdr
cbn-hyt-opu

Write a query to retun the values as :
Location
-------------
aswQwerSdf
bnmSdr
cbnHytOpu

Solution:

select
location,
substr(location,1,instr(location,'-',1,1)-1)^^replace(initcap(substr(location,instr(location,'-',1,1)+1)),'-','')
from
sales

* replace ^^ by pipes...due to some printing issues pipes are not being displayed...

1 comment:

Anonymous said...

This is almost similar to ur query
select replace(substr(location,1,instr(location,'-')-1)||initcap(substr(location,instr(location,'-'))),'-','') Done from conversion

Cheers
Kartik