DataGrip 2023.1 Help

Sort

To sort the column data, click the column name. By default, a new ORDER BY query is sent to the database each time you click a column name. You can also sort the data on the client side only. To do that, click the Show Options Menu button (the settings icon) and deselect the Sort via ORDER BY option.

The column sorting is not stacked by default. It means that if you click a column name to sort data by, the sorting based on other columns will be cleared. If you prefer to use the stacked sorting, click a column name while pressing Alt.

stacked sorting

State

Description

No sorting

Indicates that the data is not sorted in this column. The initial state of the sorting marker.

Ascending order

The data is sorted in the ascending order. The number to the right of the marker (1 on the picture) is the sorting level. You can sort by more than one column. In such cases, different columns will have different sorting levels.

Descending order

The data is sorted in the descending order.

To change the default option for stacked sorting, open settings by pressing Control+Alt+S and navigate to Database | Data Editor and Viewer | Data Sorting. Change the value for the Add columns to sorting option.

Also, you can use the ORDER BY filter and sort data in a table by writing a query in the ORDER BY field.

Sort table data with a query

  1. In the ORDER BY field, type your query. The query syntax is the same as in the ORDER BY clause but without the keyword.

  2. Press Enter.

    To reset the filter, click the clear icon (The clear icon), or delete the contents of the row filter field and press Enter.

    To open the filter history, click the arrow icon near the ORDER BY keyword.

    WHERE and ORDER BY fields for sorting
Last modified: 21 June 2023