What is the correct occurrence of following keywords while writing a group by query?
A. GROUP BY
B. HAVING
C. SELECT
D. FROM
What is the correct occurrence of following keywords while writing a group by query?
A. GROUP BY
B. HAVING
C. SELECT
D. FROM
Solution
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 or ), while WHERE filters individual rows before grouping.
Related questions:
2026: 11 May Shift 2
2025: 30 May Shift 2
2025: 15 May Shift 2
2026: 24 May Shift 1
2025: 27 May Shift 2