What is the significance of using multiple columns in MySQL GROUP BY clause?

MySQLMySQLi Database

By specifying multiple columns in GROUP BY clause we can split the result set into smaller groups. The more columns specified in GROUP BY clause, the smaller the groups will be.

Example

mysql> Select designation, YEAR(Doj), count(*) from employees GROUP BY designation, YEAR(DoJ);

+-------------+-----------+----------+
| designation | YEAR(Doj) | count(*) |
+-------------+-----------+----------+
| Asso.Prof   | 2013      | 1        |
| Asst.Prof   | 2015      | 1        |
| Asst.Prof   | 2016      | 1        |
| Prof        | 2009      | 2        |
| Prof        | 2010      | 1        |
+-------------+-----------+----------+

5 rows in set (0.00 sec)
raja
Published on 19-Feb-2018 11:49:09
Advertisements