Specifies which grouped records are displayed in a SELECT
statement with a GROUP BY clause. After GROUP BY
combines records, HAVING displays any records grouped by the GROUP BY clause that satisfy the conditions of the HAVING clause.
Syntax
SELECT fieldlist
FROM table
WHERE selectcriteria
GROUP BY groupfieldlist
[HAVING groupcriteria]
A SELECT statement containing a HAVING clause has these parts:
Remarks
HAVING is optional.
HAVING is similar to WHERE, which determines which records are selected. After records are grouped with GROUP BY, HAVING determines which records are displayed:
SELECT CategoryID,
Sum(UnitsInStock)
FROM Products
GROUP BY CategoryID
HAVING Sum(UnitsInStock) > 100 And Like "BOS*";
A HAVING clause can contain up to 40 expressions linked by logical operators, such as And and Or.