micjohnson382
Programmer
This is in continuation of the forum thread328-1421546
select 'ABC.DEF.GHI.JKL.MNO' as MYCOLUMN
,substring(MYCOLUMN from 1 for (position('.' in MYCOLUMN) (named POSDOT1)) - 1) as FIELD1
,substring((substring(MYCOLUMN from POSDOT1 + 1) (named SUB1)) from 1 for (position('.' in SUB1) (named POSDOT2)) - 1) as FIELD2
,substring((substring(SUB1 from POSDOT2 + 1) (named SUB2)) from 1 for (position('.' in SUB2) (named POSDOT3)) - 1) as FIELD3
The above query return first 3 values.
FIELD1 --> ABC
FIELD2 --> DEF
FIELD3 --> GHI
I want to return JKL and MNO also as FIELD4 and FIELD5. I am very new to Teradata and I have tried lot but could not succeeded. Appreciated your help.
select 'ABC.DEF.GHI.JKL.MNO' as MYCOLUMN
,substring(MYCOLUMN from 1 for (position('.' in MYCOLUMN) (named POSDOT1)) - 1) as FIELD1
,substring((substring(MYCOLUMN from POSDOT1 + 1) (named SUB1)) from 1 for (position('.' in SUB1) (named POSDOT2)) - 1) as FIELD2
,substring((substring(SUB1 from POSDOT2 + 1) (named SUB2)) from 1 for (position('.' in SUB2) (named POSDOT3)) - 1) as FIELD3
The above query return first 3 values.
FIELD1 --> ABC
FIELD2 --> DEF
FIELD3 --> GHI
I want to return JKL and MNO also as FIELD4 and FIELD5. I am very new to Teradata and I have tried lot but could not succeeded. Appreciated your help.