As the documentation of LIST()
states:
The ordering of the list values is undefined.
That said, if you use a subquery or common table expression (CTE) that first orders by the GROUP BY
-columns and this column then it will work, however this does mean that you are depending on an implementation artefact which might change with point releases or new versions.
There is an improvement ticket (CORE-2332) in the Firebird tracker for this, but it hasn't been planned for a version. This ticket also contains an example of the workaround:
WITH EDU_EPT AS (
SELECT EEPT2.TARGET_SWE
FROM EDUCATION_EVENT_PR_TRGT EEPT2
WHERE EEPT2.EDUCATION_EVENT_ID = :EDU_EVENT_ID
ORDER BY EEPT2.ORDINAL, EEPT2.ID
)
SELECT LIST('• ' || EEPT.TARGET_SWE, ASCII_CHAR(13) || ASCII_CHAR(10)) || '.'
FROM EDU_EPT EEPT