I've got a table which looks like:
| id|cat|elems |
|---|---|------|
| 1 | A |[a, b]|
| 1 | B |[b, c]|
| 2 | C |[b, c]|
Where elems
is an array column.
Is there a way I can pivot on the cat
column without hardcoding the values of cat
(so not doing a CASE
/IF
on cat='A'
, etc)?
The desired result would look like:
| id| A | B | C |
|---|------|------|------|
| 1 |[a, b]|[b, c]| NULL |
| 2 | NULL | NULL |[b, c]|