0
私はPostgreSQLに次のテーブルを持っています。 result
json-fieldのサブフィールドごとにSUMを得る方法はありますか?私はこのような結果必要jsonフィールドから各サブフィールドSUMを取得する方法
┌────┬───────────┬────────────────────────────────────┐
│ id │ parent_id | result │
├────┼───────────┼────────────────────────────────────┤
│ 1 │ 1 | {"step_1":1,"step_2":2,"step_3":3} │
│ 2 │ 1 | {"step_1":5,"step_4":10} │
│ 3 │ 1 | {"step_2":10,"step_3":30} │
│ 4 │ 2 | {"step_1":1,"step_6":50} │
└────┴───────────┴────────────────────────────────────┘
:
9.4+ PostgreSQLの┌───────────┬──────────────────────────────────────────────────┐
│ parent_id | result │
├───────────┼──────────────────────────────────────────────────┤
│ 1 | {"step_1":6,"step_2":12,"step_3":33,"step_4":10} │
│ 2 | {"step_1":1,"step_6":50} │
└───────────┴──────────────────────────────────────────────────┘