Question:

What will be the sequence of the given SQL clauses to display the Customer Id (CustID) and number of cars purchased if the customer purchased more than 1 car from SALE table?
A. GROUP BY CustID
B. COUNT(*)
C. HAVING COUNT (*) $>$ 1
D. FROM SALE
E. SELECT CustID
Choose the correct answer from the options given below:

Show Hint

To avoid order confusion: write the entire complete SQL query out on scratch paper first, then match each block to its corresponding letter choice!
Updated On: Jun 11, 2026
  • E, A, B, C, D
  • E, A, B, D, C
  • E, B, A, D, C
  • E, B, D, A, C
Show Solution
collegedunia
Verified By Collegedunia

The Correct Option is D

Solution and Explanation


Step 1: Understanding the Question:

The question asks to arrange five SQL clause fragments (A, B, C, D, E) in the correct syntactic sequence to construct a valid SQL query.

Step 2: Constructing the Target Query:

Let us formulate the target query based on the requirement:
- We want to select the Customer Id (CustID) and the count of cars purchased (COUNT(*)). This is represented by:
SELECT CustID (Fragment E) followed by , COUNT(*) (Fragment B).
- Next, we specify the source table:
FROM SALE (Fragment D).
- Next, we group the data by customer identifier:
GROUP BY CustID (Fragment A).
- Finally, we filter the groups to only include customers who bought more than 1 car:
HAVING COUNT(*) > 1 (Fragment C).

Step 3: Finding the Order of Fragments:

- Placing the fragments together in sequence:
1. E: SELECT CustID
2. B: COUNT(*)
3. D: FROM SALE
4. A: GROUP BY CustID
5. C: HAVING COUNT(*) > 1
- This creates the sequence: E, B, D, A, C.
- This matches option (D).

Step 4: Final Answer:

The correct syntactic sequence of writing the query is E, B, D, A, C.
Hence, option (D) is the correct choice.
Was this answer helpful?
0
0