Share via


How to: Sort with ORDER BY

You can sort query results by one or more of the columns in the returned rows by using an ORDER BY clause. You can define an ORDER BY clause by choosing options in the Criteria Details pane.

Note

Your computer might show different names or locations for some of the Visual Studio user interface elements in the following instructions. The Visual Studio edition that you have and the settings that you use determine these elements. For more information, see Customizing Development Settings in Visual Studio.

To sort a query using an ORDER BY clause

  1. Open a query or create a new one.

  2. In the Criteria pane, click the Sort Type column for the row corresponding to the column that you want to use to sort your query results.

  3. Choose Ascending or Descending from the drop-down list.

Note

Clearing the Sort Type entry for a column removes that column from the ORDER BY clause.

Notice that as you work in the Criteria pane, your query's UNION clause changes to match your most recent actions.

Note

When sorting results by more than one column, specify the order in which columns are searched relative to each other by using the Sort Order column. For more information, see How to: Sort Multiple Columns in Queries.

See Also

Other Resources

Sorting and Grouping Query Results

Summarizing Query Results

Designing Queries and Views