HAVING
--===========================================[HAVING]=======================================================================
--HAVING clause is used to restrict conditionally the output of a SQL statement,
--by a SQL aggregate function used in your SELECT list of columns.
--This will throw Error because we can't specify criteria in a SQL WHERE clause against a column in the SELECT list for which SQL aggregate function is used
SELECT Title, SUM(EmailPromotion) AS EmailPromoGroup
FROM Person.Contact
Where UM(EmailPromotion)> 100
Group By Title
---Having------
SELECT Title, SUM(EmailPromotion) AS EmailPromoGroup
FROM Person.Contact
Group By Title
HAVING SUM(EmailPromotion)> 100
No comments:
Post a Comment