美文网首页
Postgres SQL 构建json对象

Postgres SQL 构建json对象

作者: 杰克_王_ | 来源:发表于2022-12-04 09:32 被阅读0次
select jsonb_agg(data)
from (
  select jsonb_build_object(
    'MobileOperator', MobileOperator, 
    'MobileQCellCore', MobileQCellCore,
    'data', jsonb_agg(jsonb_build_object('UpdateTime', UpdateTime, 'Parvalue', Parvalue,'ProductState', ProductState) order by UpdateTime)) as data
  from ods_tsc_product_info
  where merchantid = 'xxxxxxxx' and productcategory = 'xxxxxxxx'
  group by MobileOperator, MobileQCellCore
) temp

相关文章

网友评论

      本文标题:Postgres SQL 构建json对象

      本文链接:https://www.haomeiwen.com/subject/ztfvfdtx.html