select Val,
case when substrb(Val,5,1) = substr(substrb(Val,5,2),1,1)
then substrb(Val,1,5)
else substrb(Val,1,6) end as 先頭,
case when substrb(Val,5,1) = substr(substrb(Val,5,2),1,1)
then substrb(Val,6)
else substrb(Val,7) end as 残り
from (select cast('1234567890' as char(10)) as Val from dual
union select cast('123456あい' as char(10)) from dual
union select cast('12345あい' as char(10)) from dual
union select cast('1234あい' as char(10)) from dual
union select cast('123あい' as char(10)) from dual
union select cast('12あいうえ' as char(10)) from dual
union select cast('1あいうえ' as char(10)) from dual
union select cast('あいうえ' as char(10)) from dual
union select cast('あいうえお' as char(10)) from dual);