我想对 json_arrayagg() 返回的数组进行排序。我的查询与此类似:-
select A, json_arrayagg(json_obj('X',value1, 'Y',value2)) AS RESULT
FROM (derived table)
GROUP BY A.
Run Code Online (Sandbox Code Playgroud)
我想要的是我希望返回的数组按 value2 排序。我尝试在末尾添加 order by 子句(例如 order by value2:它不起作用)
已尝试在 json_arrayagg() 内部添加 order by ..(例如: json_arrayagg(json_obj() order by value2) 它不起作用。
已尝试使用 group_concat ,但它不可靠,并且不知道为什么它没有返回正确的数据。已检查限制。
请建议我如何解决这个问题?谢谢