You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select key, value
from jsonb_deep_key_value('{"A": { "B": "C" } }'::jsonb);
key
value
A.B
C
On Queryset
select key, value
from (
select*from tbl
where cond = true
) qs inner join lateral jsonb_deep_key_value(qs.jsonb_col) on true;
key
value
all
deep_values
...
...
For counting
select key, value, count(*) as count
from (
select*from tbl
where cond = true
) qs inner join lateral jsonb_deep_key_value(qs.jsonb_col) on true
group by key, value
order bycount(*) desc;
key
value
count
k.k
v
3
...
...
...
Treat entire queryset as json (including non-json fields)
select key, value, count(*) count
from
(
select*from tbl
where cond
) qs inner join lateral jsonb_deep_key_value(row_to_json(qs)::jsonb) on true
group by key, value
order by count desc
;