Skip to main contentSkip to solution

What is the correct occurrence of following keywords while writing a group by query?

A. GROUP BY

B. HAVING

C. SELECT

D. FROM

Solution

✅ Correct Option: 3

A group by query follows the fixed SQL clause order: the columns are chosen, the table is named, rows are grouped, and then the groups are filtered.

C. SELECT: columns or aggregate functions to display

D. FROM: the table to read the data from

A. GROUP BY: groups the rows by the given column

B. HAVING: filters the groups after grouping


Option 1: puts HAVING before GROUP BY, but HAVING filters groups, so the groups must exist first.

HAVING works on grouped results (it can use aggregates like COUNT\text{COUNT} or SUM\text{SUM}), while WHERE filters individual rows before grouping.

Keyboard Shortcuts

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