Aggregate and GROUP BY conflict with HAVING? I don't know if my logic in my query is incorrect, or if I simply have a syntax error, or both.

For each customer that had more than two orders, I want to list the customerID and the total number of orders placed.  However, this query is producing the following error, (in MS Access 2016)


  The level clause includes a reserved word that is misspelled or missing. or the punctuation is incorrect.


SELECT CustomerID, COUNT(OrderID) AS OrderCount
FROM Order_T;
GROUP BY CustomerID
HAVING(COUNT(OrderID) &gt; 2)


It produces no errors if I remove the HAVING clause, but then doesn't show only customers with more than 2 orders.
You have a semicolon after FROM Order_T. A semicolon is a statement delimiter, it should be at the end of the entire statement:

SELECT CustomerID, COUNT(OrderID) AS OrderCount
FROM Order_T
GROUP BY CustomerID
HAVING(COUNT(OrderID) &gt; 2);  &lt;-- there


I am puzzled about how your query can run without errors if you just remove HAVING, but the semicolon is definitely out of place in the posted code.