Aggregate and GROUP BY conflict with HAVING?
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.