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...
negative regexp
-
if you want to grep anything except foo, use grep -v or negative lookahead
echo -e 'foo\nbar\nboz'|grep -P '^(?!.*foo).*$' bar boz it is just so
beautiful ...
1 month ago
1 comment:
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
Post a Comment