Suppose you want to display Payment mode and number of payments made using that mode more than once, in which sequence will the following commands be written to achieve the result?
(A) HAVING COUNT(*)>1
(B) FROM SALE GROUP BY PaymentMode
(C) SELECT PaymentMode,
(D) Count(PaymentMode)
Suppose you want to display Payment mode and number of payments made using that mode more than once, in which sequence will the following commands be written to achieve the result?
(A) HAVING COUNT(*)>1
(B) FROM SALE GROUP BY PaymentMode
(C) SELECT PaymentMode,
(D) Count(PaymentMode)
Solution
The query must follow the SQL clause order SELECT, FROM, GROUP BY, HAVING. The aggregate belongs in the SELECT list, right after the column name.
(C) SELECT PaymentMode,
(D) Count(PaymentMode)
(B) FROM SALE GROUP BY PaymentMode
(A) HAVING COUNT(*)>1
Option 3: puts COUNT after FROM, which is invalid because it must be part of the SELECT list.
HAVING filters groups, so it always comes after GROUP BY. WHERE filters rows before grouping.
Related questions:
2026: 19 May Shift 1
2026: 18 May Shift 2
2025: 20 May Shift 1
2025: 22 May Shift 1
2026: 18 May Shift 2