Re: JSON query help - Mailing list pgsql-novice

From Gavin Henry
Subject Re: JSON query help
Date
Msg-id CAA8_NKCE7zdEthiDRPi5xG=wcG8RFe82RocOf8EhGk6t-pFx9g@mail.gmail.com
Whole thread Raw
In response to JSON query help  (Gavin Henry <gavin.henry@gmail.com>)
Responses Re: JSON query help
List 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?



pgsql-novice by date:

Previous
From: Gavin Henry
Date:
Subject: JSON query help
Next
From: Gavin Henry
Date:
Subject: Re: JSON query help