Management & CommerceModerateBusiness analyst · SQL test

Which statement about the logical order in which a SELECT query is evaluated is correct?

  1. A. WHERE runs before GROUP BY, HAVING after, so only HAVING sees aggregates
  2. B. HAVING is applied before WHERE, so it can filter rows before grouping
  3. C. A column alias defined in SELECT can always be used in the WHERE clause
  4. D. ORDER BY is applied before GROUP BY, so groups follow the sorted order

Correct answer: A. WHERE runs before GROUP BY, HAVING after, so only HAVING sees aggregates

Logical order: FROM/JOIN → WHERE → GROUP BY → HAVING → SELECT → ORDER BY → LIMIT. WHERE cannot see aggregates or (in standard SQL) SELECT aliases, because they are computed later.

More Operations, Supply Chain & Business Analytics questions

Exams that ask this topic