小编Mar*_*kel的帖子

订购 json_agg 中的特定列

我想对 json_agg 函数中的行进行排序。

我发现了这个: PostgreSQL : select columns inside json_agg

这给了我一个为 json_agg 选择特定列的解决方案,但现在我想给聚合数据一个特定的顺序。“distinct”确实有效,而“order by”则无效。

json_agg(DISTINCT (colA, colB))
Run Code Online (Sandbox Code Playgroud)

这不会:

json_agg(DISTINCT (colA, colB) ORDER BY colA ASC, colB ASC)
Run Code Online (Sandbox Code Playgroud)

有没有办法对聚合数据进行排序?

postgresql postgresql-9.3 json

4
推荐指数
1
解决办法
1万
查看次数

标签 统计

json ×1

postgresql ×1

postgresql-9.3 ×1