LINQ mimics Logical Query processingin SQL you have:
8. SELECT
9. DISTINCT
11. TOP
1. FROM
2. ON
3. JOIN
4. WHERE
5. GROUP BY
6. WITH CUBE/ROLLUP
7. HAVING
10. ORDER BY
12. OFFSET/FETCH
But actually it is executed as:
1. FROM
2. ON
3. JOIN
4. WHERE
5. GROUP BY
6. WITH CUBE/ROLLUP
7. HAVING
8. SELECT
9. DISTINCT
10. ORDER BY
11. TOP
12. OFFSET/FETCH
Many people are not aware of this and make simple mistakes, for example:
SELECT col AS alias_name
FROM tab
WHERE aliass_name > 10;
And ask why this is not working. Because they suggest that the order is similar to what they write. LINQbetter on this.
See also Logical Query Processing and BOL :
SELECT
, SELECT. , , . , () , FROM, . , SELECT 8, , , . , ORDER BY. , , .
FROM
ON
JOIN
WHERE
GROUP BY
WITH CUBE or WITH ROLLUP
HAVING
SELECT
DISTINCT
ORDER BY
TOP