当前位置:首页> 正文

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

结果:

展开全文阅读

相关内容