Let's say I have a table :
| id | array_col |
|---|---|
| 101 | [{"system": "x", "value": "1"}, {"system": "y", "value": "2"},{"system": "z", "value": "3"}] |
Where array_col basically contains an array of structures
0: {"system": "x", "value": "1"}
1: {"system": "y", "value": "2"}
2: {"system": "z", "value": "3"}
I need the output like the following table:
| id | system | value |
|---|---|---|
| 101 | x | 1 |
| 101 | y | 2 |
| 101 | z | 3 |
Right now I'm trying to use explode in sub queries (Since can't have multiple explode in a single select statement, and then joining them based on id. But that is giving me an output where each system is showing for each value, so instead of 3 i'm getting 9 results.
| id | system | value |
|---|---|---|
| 101 | x | 1 |
| 101 | x | 2 |
| 101 | x | 3 |
| 101 | y | 1 |
| 101 | y | 2 |
| 101 | y | 3 |
| 101 | z | 1 |
| 101 | z | 2 |
| 101 | z | 3 |
Help me get the output with 3 rows, instead of 9.