The ORDER BY clause is used to sort resulting data in ascending or descending order. With dbForge Query Builder for SQL Server, you can create an ORDER BY clause in the SELECT statement based on columns or expressions.
To work with ORDER BY clauses, open the Tabbed Editor by clicking Show Tabbed Editor on the Query toolbar or Query menu.
The Order By tab of the Tabbed Editor displays the ORDER BY clause divided into three panes: Columns, Ordered By, and Expression.
To create an ORDER BY clause
1. In the Columns pane, select the column(s) based on which data will be ordered by and click Add Column. This will move columns to the Ordered By pane.
2. For multiple columns: In the Ordered By pane, use Move Up and Move Down to change the order of columns.
By default, data is sorted in descending order. To change the sorting order, click Sort Ascending.
To exclude the column from the list, select it and then click Remove Column.
3. In the Expression field, enter the expression by which the data from the returned query will be sorted. Then, click Add Expression.
4. Switch to the Text view to preview the SQL statement.