Maybe some of you know how to solve my problem (Hana SQL or Python):
I have a column like this:
| id | reason |
|---|---|
| 1 | 1;2;3;5;6;7;8;10;13 |
| 2 | 1;2;4;5;6 |
| 3 | 4;7;8;9 |
| 4 | 1;2;3;10;11;12;13 |
| 5 | 2;4 |
And I would like to split this column into several. But not just by delimiter, in this case it's - ';'. I need to split it to 13 different columns (max number in chain), and for each number, check if it is in a chain and if yes assign it '1', if not '0'.
As the result I would like to see a matrix like this:
| id | reason 1 | reason 2 | reason 3 | reason 4 | ... | reason 12 | reason 13 |
|---|---|---|---|---|---|---|---|
| 1 | 1 | 1 | 1 | 0 | ... | 0 | 1 |
| 2 | 1 | 1 | 0 | 1 | ... | 0 | 0 |
| 3 | 0 | 0 | 0 | 1 | ... | 0 | 0 |
| 4 | 1 | 1 | 1 | 0 | ... | 1 | 1 |
| 5 | 0 | 1 | 0 | 1 | ... | 0 | 0 |
Thanks a lot in advance for your help!
I've tried many functions (for example SUBSTRING_REGEXPR Function), but it always divides chain only by some specific delimiter.