You can limit the groups that appear in a query by specifying a condition that applies to groups as a whole a HAVING clause. After the data has been grouped and aggregated, the conditions in the HAVING clause are applied. Only the groups that meet the conditions appear in the query.
For example, you might want to see the average price of all books for each publisher in a titles
table, but only if the average price exceeds $10.00. In that case, you could specify a HAVING clause with a condition such as AVG(price) > 10
.
Note In some instances, you might want to exclude individual rows from groups before applying a condition to groups as a whole. For details, see Using HAVING and WHERE Clauses in the Same Query.
You can create complex conditions for a HAVING clause by using AND and OR to link conditions. For details about using AND and OR in
To specify a condition for a group
The Query Designer automatically creates a HAVING clause in the statement in the SQL pane, such as in the following example:
SELECT pub_id, AVG(price)
FROM titles
GROUP BY pub_id
HAVING (AVG(price) > 10)
Grouping Rows in Query Results | Summarizing and Grouping | Summary and Grouping Behavior in the Query Designer | Using HAVING and WHERE Clauses in the Same Query