select name,firstname,lastname from (
select position('' in name)-1 pos, name,
length(name)-pos rem,
case when pos>0 then
substring(name,1,pos)
else name end as firstname,
case when pos>0 then
substring(name,pos+1,rem)
else null end as lastname
from name_table) x
My coulmn "name" contains value like
Scenario 1:
"Jeeva Sussendran". My query will split it like "Jeeva" as FIRST NAME & "Suseendran" as LASTNAME.
Scenario 2:
"George". Then it will be splited as "Manikandan" as FIRST NAME & will populate NULL for the LAST NAME.
If u need any further more clarifications revert me back.
Regards,
Manikandan A
select name,firstname,lastname from (
select position('' in name)-1 pos, name,
length(name)-pos rem,
case when pos>0 then
substring(name,1,pos)
else name end as firstname,
case when pos>0 then
substring(name,pos+1,rem)
else null end as lastname
from name_table) x
My coulmn "name" contains value like
Scenario 1:
"Jeeva Sussendran". My query will split it like "Jeeva" as FIRST NAME & "Suseendran" as LASTNAME.
Scenario 2:
"George". Then it will be splited as "Manikandan" as FIRST NAME & will populate NULL for the LAST NAME.
If u need any further more clarifications revert me back.
Regards,
Manikandan A