In SQL, which clause is used to specify conditions on the rows with GROUP BY clause?
In SQL, which clause is used to specify conditions on the rows with GROUP BY clause?
Solution
✅ Correct Option: 1
The HAVING clause filters groups created by GROUP BY. It is applied after grouping, so it can use aggregate functions such as , or .
Example: SELECT dept, COUNT(*) FROM emp GROUP BY dept HAVING COUNT(*) > 5;
Option 2: WHERE filters individual rows before grouping and cannot use aggregate functions.
Option 3: DISTINCT removes duplicate rows from the output; it does not set conditions.
Option 4: ORDER BY only sorts the result; it does not filter anything.
Related questions:
2025: 16 May Shift 1
2025: 22 May Shift 1
2026: 23 May Shift 1
