健康一贴灵,专注医药行业管理信息化

关于PGSQL 中jsonb 类型的使用语法示例

数据的存储格式如下:

[{"Name": "进口连锁", "Value": "6030"}]
[{"Name": "非连锁门店", "Value": "3002"}]
[{"Name": "进口连锁", "Value": "6030"}]
[{"Name": "进口连锁", "Value": "6030"}]
[{"Name": "进口连锁", "Value": "6030"}]
[{"Name": "村卫生室", "Value": "2087"}]
[{"Name": "非连锁门店", "Value": "3002"}]
[{"Name": "进口连锁", "Value": "6030"}]
[{"Name": "进口连锁", "Value": "6030"}]
[{"Name": "诊所", "Value": "2081"}]

使用语法:

->顺序号->>‘属性名’
select sum(saleto_total_price) from drug_flowbase where upload_ym='202103' and (from_account_classificationcode2->0->>'Name'='二级商'  or from_account_classificationcode2->0->>'Name'='出口连锁' )and
(to_account_classificationcode2->0->>'Name'='非协议商业'  or 
to_account_classificationcode2->0->>'Name'='进口连锁'  or
 toenttype='3' or 
 toenttype='2' 
 )

 

posted @ 2022-04-07 08:42  一贴灵  阅读(637)  评论(0编辑  收藏  举报
学以致用,效率第一