Postgres SQL 构建json对象

2022-12-04  本文已影响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
上一篇 下一篇

猜你喜欢

热点阅读