Home > Database > Mysql Tutorial > body text

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

王林
Release: 2023-09-12 12:53:02
forward
980 people have browsed it

在 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)
Copy after login

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!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!