关于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' )
活到老,学到老。