Hi Peter,
based on the data you provided this should work (i just use POSITION instead of INDEX):
SELECT Seq, Str,
CASE
WHEN POSITION('a' IN Str) = 0
OR POSITION('a' IN Str) > POSITION('b' IN Str)
OR Str NOT LIKE '%a%b%a%'
THEN POSITION('b' IN Str)
ELSE POSITION('b' IN SUBSTR(Str, POSITION('b' IN Str) + 1)) + POSITION('b' IN Str)
END
FROM T1
Of course your specs are a bit vague :-)
Are following cases possible and what's the expected result?
'aba--aba---b'
'abba---b'
'a-ab-a---b'
This might require recursion or maybe a regular expression in TD14 using REGEXP_INST.
Dieter
Hi Peter,
based on the data you provided this should work (i just use POSITION instead of INDEX):
Of course your specs are a bit vague :-)
Are following cases possible and what's the expected result?
'aba--aba---b'
'abba---b'
'a-ab-a---b'
This might require recursion or maybe a regular expression in TD14 using REGEXP_INST.
Dieter