Click or drag to resize

SA0033 : [Deprecated]Do not use the GROUP BY clause without an aggregate function

The topic describes the SA0033 analysis rule.

Message

[Deprecated]Do not use the GROUP BY clause without an aggregate function

Description

Consider using DISTINCT option instead of using the GROUP BY clause without using aggregate function, because the DISTINCT option will be faster and will give the same end result. Do not use the GROUP BY clause without an aggregate function.

Note Note

The rule is deprecated in the new SQL Server versions. The execution plan generated by using the GROUP BY is not different than the one of using DISTINCT.

Scope

The rule has a Batch scope and is applied only on the SQL script.

Parameters

Rule has no parameters.

Remarks

The rule does not need Analysis Context or SQL Connection.

Categories

Performance Rules

Additional Information

There is no additional info for this rule.

Example Test Script
 1-- GROUP BY clause used without aggregate function in order to return distinct rows
 2SELECT     ColumnA ,
 3           ColumnB
 4FROM       T
 5GROUP BY   ColumnA ,
 6           ColumnB
 7
 8-- The statement returns equivalent results as the above         
 9SELECT DISTINCT
10           ColumnA ,
11           ColumnB
12FROM       T

Analysis Results

 MessageLineColumn
1SA0033 : [Deprecated]Do not use the GROUP BY clause without an aggregate function.50
See Also

Other Resources