The usage of SQL GROUP BY clause is, to divide the rows in a table into smaller groups.
The GROUP BY clause is used with the SQL SELECT statement.
The grouping can happen after retrieves the rows from a table.When some rows are retrieved from a grouped result against some condition, that is possible with HAVING clause.
The GROUP BY clause is used with the SELECT statement to make a group of rows based on the values of a specific column or expression. The SQL AGGREGATE function can be used to get summary information for every group and these are applied to individual group.
The WHERE clause is used to retrieve rows based on a certain condition, but it can not be applied to grouped result.
In an SQL statement, suppose you are using GROUP BY, if required you can use HAVING instead of WHERE, after GROUP BY.
SELECT <column_list>
FROM < table name >
WHERE <condition> GROUP BY <columns>
[HAVING] <condition>;