Column-Based GROUP BY

Function

This statement is used to group a table based on columns.

Syntax

1
2
SELECT attr_expr_list FROM table_reference
  GROUP BY col_name_list;

Keywords

Column-based GROUP BY can be categorized into single-column GROUP BY and multi-column GROUP BY.

Precautions

The to-be-grouped table must exist. Otherwise, an error is reported.

Example

Group the student table according to the score and name fields and return the grouping results.

1
2
SELECT score, count(name) FROM student
  GROUP BY score,name;