Hi,
COL employes FORMAT A80
WITH cte AS (SELECT employee_id,first_name,last_name,hire_date
FROM employees WHERE employee_id BETWEEN 100 AND 120
ORDER BY last_name)
SELECT JSON_OBJECTAGG(KEY 'employes' VALUE
JSON_OBJECT(KEY 'id' VALUE employee_id,
KEY 'prenom' VALUE first_name,
KEY 'nom' VALUE last_name,
KEY 'embauche' VALUE TO_CHAR(hire_date,'YYYY-MM-DD')))
AS employes
FROM cte;
returns a correct JSON but not ordered.
Replacing by the name of columns of the CTE the result is ordered.
I don't know why?
Best regards