Skip to main contentSkip to solution

Arrange the following statements in correct order.

(A) HAVING CLAUSE

(B) FROM TABLENAME

(C) GROUP BY

(D) SELECT (AGGREGATE FUNCTION)

Solution

✅ Correct Option: 3

SQL clauses are written in a fixed order: SELECT, then FROM, then GROUP BY, then HAVING.

(D) SELECT (AGGREGATE FUNCTION)

(B) FROM TABLENAME

(C) GROUP BY

(A) HAVING CLAUSE

HAVING filters the groups formed by GROUP BY, so it must come after GROUP BY. A WHERE clause, if used, goes between FROM and GROUP BY because it filters rows before grouping.


Option 4: puts HAVING before GROUP BY, but HAVING can only filter groups that already exist.

Keyboard Shortcuts

  • Left arrow: Previous question
  • Right arrow: Next question
  • S key: Jump to solution
  • Q key: Jump to question