In oracle, I need to find the last two values in a pipe separated column . The data looks like below
MyCol
--------
a|b|c|d
e|f
g
h|i|j
k|l|m|n|o
My output should be as below
MyCol ColA ColB
----------------------------
a|b|c|d c d
e|f e f
g null g
h|i|j i j
k|l|m|n|o n o
For two levels, I am able to write a select query using the REGEX split like below
SELECT REGEXP_SUBSTR(MyCol, '[^|]+', 1,1),REGEXP_SUBSTR(MyCol, '[^|]+', 1,2)
How can i achieve this for multiple levels.