postgre数据库json字段取值

student_info为json字段,内容为:
{"gradeId":"6","name":"京津冀","classNo":"3","schoolName":"第一实验小学","parentPhone":"13312345678"}
select
ROW_NUMBER() over(order by a.student_info->>'studentName') as serial_num,
a.student_info->>'name' as student_name,
a.student_info->>'parentPhone' as parent_phone,
a.student_info->>'schoolName' as school_name,
a.student_info->>'classNo' as class_no,
a.order_no order_no,
a.order_status order_status,
a.unit_price unit_price,
a.qty qty,
a.refund_qty refund_qty,
a.total_price total_price,
a.refund_amount refund_amount,
sm_store.name store_name
from sm_order_line a
inner join sm_store on a.store_id = sm_store.id
where a.order_status not in ('已退款','未支付','待支付')
and a.student_info->>'schoolName'='第一实验小学' and a.student_info->>'gradeId'='6' and a.student_info->>'classNo'='1'
posted @ 2020-05-09 16:08  夜阑风雪  阅读(645)  评论(0编辑  收藏  举报