What does the following SQL statement do: SELECT Customer, COUNT(Order) FROM Sales GROUP BY Customer HAVING COUNT(Order) >5

  1. Selects the total number of orders from the Sales table, if this number is greater than 5

  2. Selects all customers from table Sales that have made more than 5 orders.

  3. Selects all Customers from the Sales table

  4. None of the above


Correct Option: B
Explanation:

To understand this SQL statement, the user needs to know the basic structure of SQL queries. In this case, the statement selects two fields, Customer and COUNT(Order), from the Sales table. It then groups these fields by Customer and applies a filter using the HAVING clause to only return rows where the count of orders for that customer is greater than 5.

A. This option is incorrect because the statement is not selecting the total number of orders, but rather the count of orders for each customer.

B. This option is correct. The statement is selecting all customers from the Sales table that have made more than 5 orders.

C. This option is incorrect because the statement is not selecting all customers, but rather only those who have made more than 5 orders.

D. This option is incorrect because option B is correct.

Therefore, the answer is: B. Selects all customers from table Sales that have made more than 5 orders.

Find more quizzes: