Home  >  Article  >  Database  >  What is the significance of using multiple columns in MySQL GROUP BY clause?

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

王林
王林forward
2023-09-12 12:53:02960browse

在 MySQL GROUP BY 子句中使用多列有何意义?

We can split the result set into smaller groups by specifying multiple columns in the GROUP BY clause. The more columns specified in the GROUP BY clause, the smaller the group.

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)

The above is the detailed content of What is the significance of using multiple columns in MySQL GROUP BY clause?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete