SSMS results grid aggregates

The feature automatically displays calculations at the bottom of the SSMS results grid. To calculate aggregates, select a range of values in the results grid. You can select values both horizontally and vertically, or select individual cells by pressing and holding Ctrl while clicking the cells you want to select in the grid. If you want to select all values, press Ctrl+A.

Results Grid aggregates

You will see the MAX, MIN, AVG, SUM, COUNT, and DISTINCT functions for these values on the Aggregates panel.

To copy a value from the Aggregates panel, double-click or right-click the value and select Copy on the shortcut menu, or press Ctrl+C.

Working with aggregates in SQL Complete

Function Description
MAX Returns the largest value in a set of the selected values for numeric and date/time values, and the maximum length of the line in a set of char values.
MIN Returns the smallest value in a set of the selected values for numeric and date/time values, and the minimum length of the line in a set of char values.
AVG Calculates the average for numeric values only. Other values are treated as NaN.
SUM Returns the sum of numeric values only. Other values are treated as NaN.
COUNT Returns the number of the selected values.
DISTINCT Returns the number of the selected unique values.

Note

When you execute a query on the server, values with the DISTINCT count and the DISTINCT value on the Aggregates panel may vary because of different comparison algorithms. For instance, case-sensitive comparison is always used for row data with DISTINCT on the Aggregates panel.

Configure the options

With SQL Complete, you can customize the options of the results grid.

To configure the options:

1. Go to the SQL Complete menu and select Options.

2. In the dbForge SQL Complete: Options dialo that opens, switch to Query Result Grid.

3. Under Summary Panel Visibility, select one of the following options:

  • Never: Hides the Aggregates panel on the results grid.
  • Always: Displays the Aggregates panel on the results grid. This option is set by default.
  • When multiple cells are selected: Displays the Aggregates panel when multiple cells are selected in the grid.

4. Optional: Set a limit to the number of characters after a delimiter. The default number is 2.

5. To save changes, click OK.