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

The dialog boxes and menu commands you see might differ from those described in Help depending on your active settings or edition. To change your settings, choose Import and Export Settings on the Tools menu. For more information, see Visual Studio Settings.

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