     url,
     parent_id,
     sort,
-    project_id,
     path,
     depth,
     pos,
-    sortpos
+    sortpos,
+    project_id
 FROM
     t
 ORDER BY

            p.url,
            p.parent_id,
            p.sort,
            p.project_id,
            t.path || TO_JSONB(p.id) AS path,
            t.depth + 1 AS depth,
            t.pos || '.' || CAST(p.sort AS text) AS pos,
            t.sortpos || '.' || LPAD(CAST(p.sort AS text), 3, '0') AS sortpos
        FROM
            page p
        INNER JOIN

            url,
            parent_id,
            sort,
            TO_JSONB(id) AS path,
            1 AS depth,
            CAST(sort AS text) AS pos,
            LPAD(CAST(sort AS text), 3, '0') AS sortpos,
            project_id
        FROM
            page
        WHERE
