数据库
首页 > 数据库> > 关于PGSQL 中jsonb 类型的使用语法示例

关于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' 
 )

 

标签:account,Name,示例,Value,PGSQL,连锁,6030,classificationcode2,jsonb
来源: https://www.cnblogs.com/lrzy/p/16110682.html