asked 160k views
2 votes
Which SQL command must be used when you are using a function (like SUM or COUNT) in a Select statement (like COUNT (CustomerID))? Having Select Into Group by Order by

asked
User Pimentel
by
7.9k points

1 Answer

3 votes

Answer:

Having.

Step-by-step explanation:

When we are working with Select statements like COUNT(CustomerID).We should use Having clause because functions like (SUM,COUNT,AVG etc) are aggregate functions and we cannot use where clause with aggregate functions.That's why we use Having clause with aggregate functions.

for example:-

select COUNT(CustomerID),state_of_residence

from Customers

GROUP BY state_of_residence

HAVING COUNT(CustomerID)>10;

answered
User Mikechambers
by
7.4k points