Sort and group data

Query Builder lets you sort and group data directly in the grid.

Sort data in the grid

There are two ways to retrieve data for sorting.

1. Right-click the required table (or right-click multiple selected tables) in Database Explorer and select Retrieve Data from the shortcut menu. Query Builder will retrieve unsorted data from this table (or multiple tables).

2. If the data is retrieved upon executing a SQL statement, it will be sorted according to the sorting operators used in this statement (e.g. ORDER BY).

To sort data in the grid or to change the sort order, click a column header. Alternatively, right-click a column header and select Sort Ascending or Sort Descending from the shortcut menu.

To assign a secondary sorting, click another column header while holding the SHIFT key. You can set as many sorting columns as you need. To stop sorting on a certain column, click it while holding the CTRL key.

To cancel sorting on current column, select Clear Sorting from the shortcut menu.

The current sort order of a column is indicated by the sort glyph. You can see both the descending and ascending glyphs in the screenshot below. If the column is not sorted, the sort glyph is hidden.

Sorting

Grouping data

To group data by column, click Show Group by Box on the document toolbar. The Group by Box pane will appear above the grid. Drag a column header that you want the data to be grouped by to the pane.

Grouping data by column

Alternatively, right-click the required column header and select Group By This Column from the shortcut menu. The data will be automatically displayed in groups marked with collapsed nodes. The column header will be moved to the Group By Box pane.

You can group data by multiple columns. In this case the grid will display a tree of nested groups that you can expand by clicking the corresponding Group expand icon icons. To collapse the groups, click the corresponding Group collapse icon icons.

Grouping by multiple columns

You can also sort grouped data. To do that, click a column header, or right-click a column header and select Sort Ascending or Sort Descending from the shortcut menu.

Sorting grouped data

To expand or collapse all groups at once, right-click the Group By Box pane, and then select Full Expand or Full Collapse from the shortcut menu.

To cancel grouping by column, drag-and-drop the column header from the Group By Box pane to the grid. Alternatively, right-click the column header, and then select Ungroup from the shortcut menu.

To remove all groupings, right-click the Group By Box pane and select Clear Grouping from the shortcut menu.

Note

Data sorting and filtering can be performed either on the client or on the server side. To learn more about it, refer to Server-side and client-side sorting and filtering.

To learn more about filtering data, refer to Hiding columns and filtering data.

Want to Find out More?

Overview

Overview

Take a quick tour to learn all about the key benefits delivered by dbForge Query Builder for SQL Server.
Request a demo

Request a demo

If you consider employing the Query Builder for your business, request a demo to see it in action.
Ready to start using dbForge Query Builder for SQL Server?