Multiple choice technology databases

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 the Sales table

  3. Both of them above

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

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

The HAVING clause filters groups created by GROUP BY. Here, GROUP BY Customer groups the sales records by customer, and HAVING COUNT(Order) > 5 filters these groups to only include customers who have more than 5 orders. The other options incorrectly describe the query's behavior.