Table of Contents
MySQL Group By Clause:
The GROUP BY clause groups the rows in the result table by columns that have the same values, so that each group is reduced to a single row. The GROUP BY column does not have to be in the SELECT clause. Each column is separated by a comma.
MySQL Group By Syntax:
SELECT column_name (s) FROM table1 WHERE condn GROUP BY col_name (s) |
MySQL Having Clause:
The HAVING clause is very similar to the WHERE clause in that it consists of one or more conditions that define which rows are included in a result set.
MySQL Having Clause Syntax:
SELECT column_name (s) FROM table1 WHERE condn GROUP BY col_name (s) HAVING condn |
MySQL Group By and Having Clause Example:
Sample Table:


MySQL Group By on Sample Table:

MySQL Having Clause on Sample Table:

Comments (No)