SQL HAVING Clause
THE HAVING Clause is used in conjunction with the group by clause to apply conditions on aggregate functions.
The Having clause is always used after the group by clause.
Syntax:Â Â Â Â
        SELECT  column1 , aggregate_function(column2)                                                                                                    FROM tablename                                                                                         GROUP BY column1                                                                                       HAVING condition(s)                                                                                      ORDER BY column1;Â
Let’s understand the having clause with an example. For demonstration purposes, we will be using the table emp.
     Table Emp
Example:
  Objective: In this example, we will count the number of employees in each department where the count is greater than             10 .
           SELECT Department , COUNT(Ecode) as [TotalCount] FROM Tbl_Emp
                            GROUP BY Department                                                                                     HAVING COUNT(Ecode)>10
                                ORDER BY Department;
  Output: