Reputation: 125
Starting point:
id levels
11 A,B,C
12 A
13 B,C
How to split and create an array, expected outcome:
id levels
11 A
11 B
11 C
12 A
13 B
13 C
Upvotes: 2
Views: 1603
Reputation: 15893
You can use split:
select id,split(levels,',') as levels yourtable
You can also use UNNEST
SELECT id, levels
FROM yourtable
CROSS JOIN UNNEST(levels) AS levels;
Upvotes: 2