小编Man*_*rte的帖子

从 Postgres jsonb 属性获取不同记录的计数和总和

我有这个 Postgres 9.6 表定义:

CREATE TABLE research (
   id int,
   data jsonb
);
Run Code Online (Sandbox Code Playgroud)

并在其中包含以下示例数据

 id |data
 ---|--------------------------------------------------------
 1  |{"name": "Sim Ltd", "sector": "business", "personnel": {"headcount": {"total": 100, "male": 50, "female": 50}}}
 2  |{"name": "EcoSmart", "sector": "business", "personnel": {"headcount": {"total": 500, "male": 460, "female": 40}}} 
 3  |{"name": "HIDN", "sector": "government", "personnel": {"headcount": {"total": 431, "male": 121, "female": 310}}} 
 4  |{"name": "RevDev", "sector": "government", "personnel": {"headcount": {"total": 15, "male": 10, "female": 5}}} 
 5  |{"name": "NEFPAN", "sector": "non-profit", "personnel": {"headcount": {"total": 5, "male": …
Run Code Online (Sandbox Code Playgroud)

postgresql json

2
推荐指数
1
解决办法
9687
查看次数

标签 统计

json ×1

postgresql ×1