Skip to main contentSkip to solution

Consider the given query:

________ CustID , COUNT() _____ SALE ________ CustID ____ Count() >1

Fill the following words in the above query in correct order:

A. SELECT

B. FROM

C. GROUP BY

D. HAVING

Solution

✅ Correct Option: 1

SQL clauses must appear in the order SELECT, FROM, GROUP BY, HAVING. The completed query is:

SELECT CustID, COUNT(*) FROM SALE GROUP BY CustID HAVING COUNT(*) > 1

It lists each customer who appears in more than one sale, along with the number of sales.


Option 2: HAVING cannot come before GROUP BY, because it filters the groups that GROUP BY creates.

Extra: WHERE filters rows before grouping, while HAVING filters groups after grouping, which is why a condition on COUNT(*) must go in HAVING.

Keyboard Shortcuts

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