|
2 | 2 | description: "SELECT - GROUP BY- Transact-SQL" |
3 | 3 | title: "GROUP BY (Transact-SQL) | Microsoft Docs" |
4 | 4 | ms.custom: "" |
5 | | -ms.date: "03/01/2019" |
| 5 | +ms.date: "10/12/2021" |
6 | 6 | ms.prod: sql |
7 | 7 | ms.prod_service: "database-engine, sql-database, synapse-analytics, pdw" |
8 | 8 | ms.reviewer: "" |
@@ -35,6 +35,7 @@ ms.author: mikeray |
35 | 35 | monikerRange: ">=aps-pdw-2016||=azuresqldb-current||=azure-sqldw-latest||>=sql-server-2016||>=sql-server-linux-2017||=azuresqldb-mi-current" |
36 | 36 | --- |
37 | 37 | # SELECT - GROUP BY- Transact-SQL |
| 38 | + |
38 | 39 | [!INCLUDE [sql-asdb-asdbmi-asa-pdw](../../includes/applies-to-version/sql-asdb-asdbmi-asa-pdw.md)] |
39 | 40 |
|
40 | 41 | A SELECT statement clause that divides the query result into groups of rows, usually for the purpose of performing one or more aggregations on each group. The SELECT statement returns one row per group. |
@@ -73,9 +74,10 @@ GROUP BY { |
73 | 74 | -- For backward compatibility only. |
74 | 75 | -- Non-ISO-Compliant Syntax for SQL Server and Azure SQL Database |
75 | 76 | |
76 | | -GROUP BY |
77 | | - [ ALL ] column-expression [ ,...n ] |
78 | | - | column-expression [ ,...n ] [ WITH { CUBE | ROLLUP } ] |
| 77 | +GROUP BY { |
| 78 | + ALL column-expression [ ,...n ] |
| 79 | + | column-expression [ ,...n ] WITH { CUBE | ROLLUP } |
| 80 | + } |
79 | 81 |
|
80 | 82 | ``` |
81 | 83 |
|
@@ -269,18 +271,26 @@ FROM Sales |
269 | 271 | GROUP BY GROUPING SETS ( Country, () ); |
270 | 272 | ``` |
271 | 273 |
|
272 | | -### GROUP BY [ ALL ] column-expression [ ,...n ] |
| 274 | +### GROUP BY ALL column-expression [ ,...n ] |
273 | 275 |
|
274 | 276 | Applies to: SQL Server and Azure SQL Database |
275 | 277 |
|
276 | | -NOTE: This syntax is provided for backward compatibility only. It will be removed in a future version. Avoid using this syntax in new development work, and plan to modify applications that currently use this syntax. |
| 278 | +>[!NOTE] |
| 279 | +>This syntax is provided for backward compatibility only. It will be removed in a future version. Avoid using this syntax in new development work, and plan to modify applications that currently use this syntax. |
277 | 280 |
|
278 | | -Specifies to include all groups in the results regardless of whether they meet the search criteria in the WHERE clause. Groups that don't meet the search criteria have NULL for the aggregation. |
| 281 | +Specifies to include all groups in the results regardless of whether they meet the search criteria in the WHERE clause. Groups that don't meet the search criteria have NULL for the aggregation. |
279 | 282 |
|
280 | 283 | GROUP BY ALL: |
281 | 284 | - Is not supported in queries that access remote tables if there is also a WHERE clause in the query. |
282 | 285 | - Will fail on columns that have the FILESTREAM attribute. |
283 | | - |
| 286 | + |
| 287 | +### GROUP BY column-expression [ ,...n ] WITH { CUBE | ROLLUP } |
| 288 | + |
| 289 | +Applies to: SQL Server and Azure SQL Database |
| 290 | + |
| 291 | +>[!NOTE] |
| 292 | +>This syntax is provided for backward compatibility only. Avoid using this syntax in new development work, and plan to modify applications that currently use this syntax. |
| 293 | +
|
284 | 294 | ### WITH (DISTRIBUTED_AGG) |
285 | 295 | Applies to: [!INCLUDE[ssSDW](../../includes/sssdwfull-md.md)] and [!INCLUDE[ssPDW](../../includes/sspdw-md.md)] |
286 | 296 |
|
|
0 commit comments