How is it possible to order the array returned by json_arrayagg() in Mysql?
Apparently, there is a hack which might work:
SELECT A, json_arrayagg(json_obj('X',value1, 'Y',value2)) AS RESULT
FROM (SELECT . . .,
ROW_NUMBER() OVER (ORDER BY value2) as seqnum
FROM . . .
. . .
) x
GROUP BY A;
The ROW_NUMBER()
-- apparently -- manages to order the result set, even though ORDER BY
does not work.