У меня есть этот столбец extra , который равен JSONB из таблицы с именем подписчики , а значение для данного подписчика:
{
"valid": "N",
"msisdn": "23490272",
"account_info": [
{
"account_id": 110000616,
"account_cur": "NGN",
"account_type": "C",
"account_class": "ww"
},
{
"account_id": 110000617,
"account_cur": "NGN",
"account_type": "S",
"account_class": "GHCXLA"
},
{
"account_id": 110000618,
"account_cur": "EUR",
"account_type": "S",
"account_class": "ww"
},
{
"account_id": 110000619,
"account_cur": "USD",
"account_type": "C",
"account_class": "ww"
},
{
"account_id": 110000620,
"account_cur": "SAR",
"account_type": "Y",
"account_class": "ww"
},
{
"account_id": 110000621,
"account_cur": "NGN",
"account_type": "Y",
"account_class": "ww"
},
{
"account_id": 110000622,
"account_cur": "NGN",
"account_type": "S",
"account_class": "ww"
},
{
"account_id": 110000623,
"account_cur": "NGN",
"account_type": "S",
"account_class": "ww"
},
{
"account_id": 110000624,
"account_cur": "NGN",
"account_type": "S",
"account_class": "ww"
},
{
"account_id": 110000625,
"account_cur": "NGN",
"account_type": "S",
"account_class": "ww"
},
{
"account_id": 110000626,
"account_cur": "NGN",
"account_type": "S",
"account_class": "ww"
},
{
"account_id": 110000627,
"account_cur": "NGN",
"account_type": "S",
"account_class": "ww"
},
{
"account_id": 110000628,
"account_cur": "NGN",
"account_type": "S",
"account_class": "ww"
},
{
"account_id": 110000629,
"account_cur": "NGN",
"account_type": "S",
"account_class": "ww"
},
{
"account_id": 110000630,
"account_cur": "NGN",
"account_type": "S",
"account_class": "ww"
}
],
"preapprovalId": "1517299109619",
"reservedAmount": 0.0,
"preapprovalStatus": "APPROVED"
}
Я хочу превратить элементы из account_info в столбцы. Я пробовал это:
select extra #>'{account_info,0}'->>'account_id' Account,extra #>'{account_info,0}'->>'account_cur' Currency,extra #>'{account_info,0}'->>'account_type' Account_Type from subscribers s2 where id = 319;
account | currency | account_type
-----------+----------+--------------
110000616 | NGN | C
Как мне получить все элементы?