Re: JSON query help
Gavin Henry <[email protected]> Thu, 29 Aug 2019 00:37:03 +0100
| Newsgroups | gmane.comp.db.postgresql.novice |
|---|---|
| Message-ID | <CAA8_NKCgfqgyjJ2L4BqHQ7QwLy1JjFoXnzQ_yeYEgppieqAD-w@mail.gmail.com> |
Thanks, that worked! Now I need to go back to basics and SETS:
SELECT
cost_details->'Accounting'->jsonb_object_keys(cost_details->'Accounting')->'BalanceUUID'
AS BalanceUUID,
cost_details->'Accounting'->jsonb_object_keys(cost_details->'Accounting')->'Units'
AS Cost
FROM cdrs
WHERE cost > 0
AND cost_details->'AccountSummary'->'BalanceSummaries' @>
'[{"ID":"B_MONETARY_POSTPAID"}]'
AND cost_details->'AccountSummary'->'BalanceSummaries' @>
json_build_object('UUID',
cost_details->'Accounting'->jsonb_object_keys(cost_details->'Accounting')->'BalanceUUID')::jsonb
limit 1;
ERROR: argument of AND must not return a set
LINE 1: ...ummaries' @> '[{"ID":"B_MONETARY_POSTPAID"}]' AND cost_detai...