SQL Execution Order

  1. FROM
  2. WHERE
  3. GROUP BY
  4. HAVING
  5. SELECT
  6. ORDER BY

This is the execution order, so if we do SELECT column_id alias , alias only available in ORDER BY.