Design conditions for GROUP BY clauses

The GROUP BY clause in a SELECT statement groups rows that share the same values in one or more columns. It appears after the WHERE clause and before the ORDER BY clause.

You can use GROUP BY with aggregate functions, such as SUM, COUNT, or AVG, to return summarized data. Each group in the result set is represented by a single row.

You can create and manage the GROUP BY clause on the Group By tab of Tabbed Editor. The clause structure is organized into three boxes: Columns, Grouped By, and Expression.

Open Tabbed Editor

To open Tabbed Editor, do one of the following:

  • In the top menu, select Query > Show Tabbed Editor.

  • On the Query toolbar, click Show Tabbed Editor.

Create a GROUP BY clause

1. In the Columns box, select the columns to group data by, then click Add a column. This moves columns to the Grouped By box.

2. To reorder multiple columns, in the Grouped By box, use Move up and Move down.

Tip

To remove a column from the Grouped By box, select it, then click Remove the column.

3. To group by a calculated value, in the Expression box, click Add expression. The expression appears in the Grouped By box.

Add the expression to the GROUP BY clause

4. Optional: To preview the query, click Text in the bottom panel of the Query Builder document.

Note

All columns in the SELECT list must also appear in the GROUP BY clause – unless they’re used only within an aggregate function.