表数据:
需要将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
结果: