So, I have a piece of simple SQL like:
select
REGEXP_SUBSTR (randomcol, '[^|]+', 1, 2)
||'|'|| REGEXP_SUBSTR (randomcol, '[^|]+', 1, 3)
||'|'|| REGEXP_SUBSTR (randomcol, '[^|]+', 1, 4)
from table1 where ADDTL_DETAIL_INFO is not null and module_key='01-07-2016 00:00:00/2212/ 1';
The idea is to get the pipe separated values present in the randomcol column where the value present is:
~custom|HELLO1||HELLO3
So I need the values like HELLO1,whitespace (as there is no value between the second pipe and the third pipe) and HELLO3.
But when I ran the above query it returns as:
HELLO1|HELLO3|
and the white space is gone. I need this white space to retain. So what am I doing wrong here?