Question

I have a column which contains a String with numbers like '12345' (no separator or blanks) and I want to split this column to rows for each character:

From:

 COLUMN
 ------------------
 12345

To:

 COLUMN
 ------------------
 1
 2
 3
 4
 5

This Should work in a single select so that I can use it like this:

... AND WHERE SOMECOLUMN NOT LIKE (... THE SELECT ...)

Was it helpful?

Solution

with temp as (select '12456' as str from dual)
select substr(str,level,1)
from temp
connect by level <= length(str);

Result:

1
2
4
5
6
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top