I have a table called "Table" and attribute named "History". This history attribute has values like:
1 Finished (30-05-2018);
2 InProgress (25-05-2018); Rejected(26-05-2018); InProgress (28-05-2018); Finished (30-05-2018);
3 InProgress (25-05-2018); Finished (30-05-2018);
I want to split this attribute by the semicolumn (;) and create a new row for every history part. So for the rows in the code/example above it should create 7 rows. I have managed to do this for one row by the code below. The problem is that I want to do this for every row in this table. Here occurs a problem: when I remove the WHERE condition in the WITH I get way to many resultrows and also a lot of NULL values. What am I doing wrong?
WITH DATA AS
( SELECT "WorkID" w,"History" his FROM Table
where "WorkID" = 75671
)
SELECT w, trim(regexp_substr(his, '[^;]+', 1, LEVEL)) his
FROM DATA
CONNECT BY regexp_substr(his , '[^;]+', 1, LEVEL) IS NOT NULL