postgresql中对jsonb的查询及转换

前端之家收集整理的这篇文章主要介绍了postgresql中对jsonb的查询及转换前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

表数据:

需要将strata排除,并且过滤info字段中为{}的数据,将jsonb转换成text,替换“,{,}

sql

select regexp_replace((a.info::jsonb - 'strata')::TEXT,E'[",}]+','','g') as strata,count(a.id) from pt_subjects a where (a.info::jsonb - 'strata')>'{}'::jsonb group by strata order by strata

结果:

原文链接:https://www.f2er.com/postgresql/193721.html

猜你在找的Postgre SQL相关文章