Skip to main contentSkip to solution

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

✅ Correct Option: 4

The query must follow the SQL clause order SELECT, FROM, GROUP BY, HAVING. The aggregate Count(PaymentMode)Count(PaymentMode) 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.

Keyboard Shortcuts

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