In general (PostgreSQL like-flavor), we can summarize the SQL coding order as:
SELECT
DISTINCT
FROM
JOIN
WHERE
GROUP BY
HAVING
ORDER BY
LIMIT
Whereas, its execution order will be: