How to preserve order of children to appear after their parents
问题 Expected order by replyid: 55, 57, 58, 59, 60, 56 -- So that the entire 1st parent reply and all its children appear BEFORE the 2nd parent reply The following SQL query returns the wrong order of results WITH RECURSIVE t(replyid, replypid, depth, path, reply, replied, reply_userid) AS ( (SELECT replyid, replypid, 0, array[replyid], reply, replied, replies.userid, u.displayname, u.email_address, (SELECT COUNT(*) FROM reply_revs WHERE replyid = replies.replyid) AS reply_revs FROM replies LEFT