Analysis Statements - GROUP BY
The syntax of a complete analysis statement is as follows:
SELECT [DISTINCT] (* | expression) [AS alias] [, ...] [GROUP BY expression [, ...] [HAVING predicates]] [ORDER BY expression [ASC | DESC] [, ...]] [LIMIT size OFFSET offset]
Where, GROUP BY indicates grouping by value. The following part describes parameters and examples for the GROUP BY syntax.
Grouping by Field Value
SELECT age GROUP BY age
age |
---|
28 |
32 |
36 |
Grouping by Field Alias
SELECT account_number AS num GROUP BY num
num |
---|
1 |
16 |
13 |
18 |
Grouping by Multiple Fields
SELECT account_number AS num, age GROUP BY num, age
num |
age |
---|---|
1 |
32 |
16 |
36 |
13 |
28 |
18 |
32 |
Using SQL Functions
For details about functions, see Function.
SELECT LENGTH(lastname) AS len, COUNT(*) AS count GROUP BY LENGTH(lastname)
len |
count |
---|---|
4 |
2 |
5 |
2 |
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.