GROUP BY

suggest change

Introduction

Results of a SELECT query can be grouped by one or more columns using the GROUP BY statement: all results with the same value in the grouped columns are aggregated together. This generates a table of partial results, instead of one result. GROUP BY can be used in conjunction with aggregation functions using the HAVING statement to define how non-grouped columns are aggregated.

Syntax

column-expression

| ROLLUP ( <group_by_expression> [ ,…n ] )

| CUBE ( <group_by_expression> [ ,…n ] )

| GROUPING SETS ( [ ,…n ] )

| () –calculates the grand total

} [ ,…n ]

column-expression

| ( column-expression [ ,…n ] )

() –calculates the grand total

| <grouping_set_item>

| ( <grouping_set_item> [ ,…n ] )

<group_by_expression>

| ROLLUP ( <group_by_expression> [ ,…n ] )

| CUBE ( <group_by_expression> [ ,…n ] )

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents