>
Part | Description |
fieldlist | The name of the field or fields to be retrieved along with any field-name aliases, SQL aggregate functions, selection predicates (ALL, DISTINCT, DISTINCTROW, or TOP), or other SELECT statement options. |
table | The name of the table from which records are retrieved. For more information, see the FROM clause. |
selectcriteria | Selection criteria. If the statement includes a WHERE clause, the Microsoft Jet database engine groups values after applying the WHERE conditions to the records. |
groupfieldlist | The names of up to 10 fields used to group records. The order of the field names in groupfieldlist determines the grouping levels from the highest to the lowest level of grouping. |
groupcriteria | An expression that determines which grouped records to display. |
SELECT CategoryID,Sum(UnitsIn Stock) FROM ProductsA HAVING clause can contain up to 40 expressions linked by logical operators, such as And and Or. See Also GROUP BY Clause, SELECT Statement, SELECT...INTO Statement, SQL Aggregate Functions. Example Some of the following examples assume the existence of a hypothetical Department field in an Employees table. This example selects the job titles in the Production department assigned to more than 50 employees.
GROUP BY CategoryID
HAVING Sum(UnitsIn Stock) > 100 AND LIKE BOS*;
SELECT Title, Count(Title) FROM EmployeesThis example selects departments with more than 100 employees.
WHERE Department = 'Production' GROUP BY Title HAVING Count(Title) > 50;
SELECT Department, Count([Department]) FROM Employees
GROUP BY Department HAVING Count(Department) > 100;