Which of the following statement will correctly filter products having an average price of 50?
Which of the following statement will correctly filter products having an average price of 50?
Solution
GROUP BY Category puts the rows into one group per category, and HAVING then filters those groups on an aggregate such as AVG(Price). Option 1 is the only statement with valid syntax and the correct clause order: GROUP BY first, then HAVING.
Option 2: WHERE cannot follow GROUP BY, and it cannot use aggregate functions like AVG().
Option 3: HAVING without GROUP BY treats the whole table as one group, so selecting Category on its own is invalid.
Option 4: GROUP BY takes column names, not a condition.
Memory trick: WHERE filters rows before grouping, HAVING filters groups after grouping.
Related questions:
2026: 11 May Shift 2
2025: 20 May Shift 1
2026: 29 May Shift 2