-
How to get the substring value from a column with data?
Hi Friends,
How to get the substring value from a column with data?
Example
-------
Names Initials
----- --------
MTOLISI
FERNANDO
MAKGATLISHA SWARTBOOI
SIVENGI
T A
SAMANTHA MARY
I need to populate the initials column by taking the first character from the Names field
My Initials column should be as below
Initials
--------
M
F
MS
S
T A
SM
Thanks Guys,
Kishan
SUROOP B
-
select substr(names,1,1) initials from tablename
-
SELECT
substr(fullnames,1,1)||substr(fullnames,instr(fullnames,' ')+1,1) initials
FROM
names
-
select substr(names,1,1) || substr(names, instr(names,' ')+1,1) from tablename;
You might want to add a decode before the second concatenation to check if there is a space.
-
Decode not necessary. Who cares?
-
translate(initcap(column),
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz',
'ABCDEFGHIJKLMNOPQRSTUVWXYZ')
Will deal with any number of names - but I feel there must be a neater way . . .
Last edited by DaPi; 04-15-2004 at 11:48 AM.
-
DaPi, you so sneaky!
I might use this trick somewhere.
-
Watch out for names like "Hervé Niño 13th" it'll need some adjusting!
-
Or maybe just use the upper to make everything uppercase.
-
Originally posted by oracle_faq
Or maybe just use the upper to make everything uppercase.
How would that help?
Jurij Modic
ASCII a stupid question, get a stupid ANSI
24 hours in a day .... 24 beer in a case .... coincidence?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|