|
|
Archives of the TeradataForum
Message Posted: Sun, 03 Jun 2007 @ 21:36:29 GMT
Subj: | | Re: Extracting First,Middle and last Name |
|
From: | | Jinesh P V |
sel substr(FullName,1,FirstOccurance -1 ) as Firstname,
case when SecondOccurance > 0
then substr(Extract2, 1, SecondOccurance -1 )
else ''
end as MiddleName,
case when SecondOccurance > 0
then Extract3
else substr(Extract2, 1, SecondOccurance -1 )
end as LastName
from
(
sel
trim('hello world program') as FullName,
position( ' ' in FullName) as FirstOccurance,
trim(substr(FullName,FirstOccurance + 1)) as Extract2,
position(' ' in Extract2 ) as SecondOccurance,
trim(substr(Extract2 ,SecondOccurance + 1)) as Extract3
)tmp
thanks,
Jinesh P V
| |