The HAVING clause used because we are not allowed to use WHERE clause after GROUP BY clause. If we want to restrict something in a table then we are using HAVING clause followed by GROUP BY clause.
Group by clause is used to arrange similar data items into set of logical groups. If a column having same values in multiple rows then it will arrange those rows into a group. We can also use group by clause without using group functions.