Re: JSON query help

From: Gavin Henry <gavin(dot)henry(at)gmail(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: JSON query help
Date: 2019-08-27 21:26:37
Message-ID: CAA8_NKCE7zdEthiDRPi5xG=wcG8RFe82RocOf8EhGk6t-pFx9g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Got a bit close now:

cgrates=# select
cost_details->'Accounting'->jsonb_object_keys(cost_details->'Accounting')->'BalanceUUID'
as balance from cdrs where cost > 0 limit 1;
-[ RECORD 1 ]-----------------------------------
BalanceUUID | "154419f2-45e0-4629-a203-06034ccb493f"

so I can AND this with cost > 0 AND
cost_details->'AccountSummary'->'BalanceSummaries'
@>'[{"ID":"B_MONETARY_POSTPAID"}]' limit 10;

now I just need to use the first select which returns a SET to loop
through BalanceSummaries to match on BalanceUUID = UUID

Any pointers?

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Gavin Henry 2019-08-28 19:40:04 Re: JSON query help
Previous Message Gavin Henry 2019-08-27 15:30:46 JSON query help