Let there be a table data with two columns
| id | parts |
|---|---|
| 1 | {"1": 1, "2": 0, "3": 2, "4": 0, "5": 0} |
| 2 | NULL |
| 3 | {"6": 1, "7": 0} |
| 4 | {"3": 1} |
| 5 | null |
Column id is integer type and column parts can have JSON expressions, empty cells (NULL) as well as JSON nulls.
The question is fairly simple: how does one find the sum of all values in each cell in parts, leaving only not null cells. The final result should be:
| id | sum_parts |
|---|---|
| 1 | 3 |
| 3 | 1 |
| 4 | 1 |