I have recursive query which returns some rows from hierarchical model. Kind Of:
files_array := ARRAY
(WITH RECURSIVE files_to_parent AS (
SELECT FileID, Name, ParentID
FROM File
WHERE FileID = file_id
UNION ALL
SELECT F.FileID, F.Name, F.ParentID
FROM files_to_parent ftp, File F
WHERE F.FileID = FTP.ParentID
)
SELECT Name FROM files_to_parent);
How can I reverse the result of the SELECT query?
PS: I cannot order by IDs, id of parent can be more or less then in child.