GROUP BY Expression
Function
Groups a table by an expression.
Syntax
SELECT attr_expr_list FROM table_reference GROUP BY groupby_expression [, groupby_expression, ...];
Keywords
groupby_expression: Can be a single field, multiple fields, or an aggregate function, string function, etc.
Precautions
- The table to be grouped must already exist. Otherwise, an error is reported.
- Similar to single-column grouping, the fields appearing in GROUP BY must be included in the fields of attr_expr_list. Expressions support built-in functions, user-defined functions, etc.
Example
Use the substr function to extract a substring of the name field, group by that substring, and return each substring and its corresponding record count.
SELECT substr(name,6),count(name) FROM student GROUP BY substr(name,6);
What is your overall rating for this page?
Thank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot