GROUP BY

suggest change

Introduction

A SELECT can group rows with GROUP BY. Rows that share the same values in the grouped columns form one group. Every selected column must either appear in the GROUP BY or be used inside an aggregate function. HAVING filters groups after aggregation; it does not define how values are aggregated. ROLLUP, CUBE, and GROUPING SETS are optional extensions of grouping. The bracket syntax below follows SQL Server.

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