Tuesday, June 2, 2015

SQL Learning

The lexical ordering is:

SELECT [ DISTINCT ]
FROM
WHERE
GROUP BY
HAVING
UNION
ORDER BY

For simplicity, not all SQL clauses are listed. This lexical ordering differs fundamentally from the logical order, i.e. from the order of execution:

FROM
WHERE
GROUP BY
HAVING
SELECT
DISTINCT
UNION
ORDER BY

Now you know why the following occurs:

SELECT A.x + A.y AS z
FROM A
WHERE z = 10 -- z is not available here!

Much more at http://tech.pro/tutorial/1555/10-easy-steps-to-a-complete-understanding-of-sql

An excellent explanation of how B-tree indexes work at http://www.orafaq.com/node/1403

No comments:

Post a Comment