Re: JSON query help

Gavin Henry <[email protected]> Tue, 27 Aug 2019 22:26:37 +0100
Newsgroups gmane.comp.db.postgresql.novice
Message-ID <CAA8_NKCE7zdEthiDRPi5xG=wcG8RFe82RocOf8EhGk6t-pFx9g@mail.gmail.com>
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?