What is the difference between HAVING and WHERE Clause in SQL Server?
Check here for more details : https://www.c-sharpcorner.com/article/difference-between-having-and-where-clause-in-sql-server/
A HAVING clause is like a WHERE clause, but applies only to groups as a whole (that is, to the rows in the result set representing groups), whereas the WHERE clause applies to individual rows. A query can contain both a WHERE clause and a HAVING clause.