通过在 GROUP BY 子句中指定多个列,我们可以将结果集拆分为更小的组。 GROUP BY 子句中指定的列越多,组就越小。
示例
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)