Query Column Sorting

When designing a query, it may be desirable to sort the information retrieved for a column in alphabetical or chronological order.

Two sorting options are provided within TDA:

Ascending: Sorts information in ascending order alphabetically or chronologically such as “A to Z” or “7/1/2010 to 12/31/2010” (top to bottom in the grid view of the data).

Descending: Sorts information in reverse chronological or alphabetical order such as “Z to A” or “12/31/2010 to 7/1/2010” (top to bottom in the grid view of the data).

Sorting column information is a simple process and can be completed in a few different ways as shown below.

Sorting via the “Query Columns” area:

1.  Locate the “Query Columns” area of the “Query Builder” window.

2.  Note that at the end of each data field line there is a “Not sorted” blue link available. Select this link to change the sorting option for that particular field.

The sort order for the “Start Date” field has been updated to “Descending”. This means the case start date information will be displayed in reverse chronological order in the query result set (a grid view of the data retrieved from the database).

Note that when the “Descending” sort order was selected, the “Columns Sorting” area of the “Query Builder” window updated automatically to show the “StartDate” column is now being sorted in “Descending” order.

Seeing the column sorting is being displayed in the “Columns Sorting” area, this leads us to the second method for defining column sorting in the next section of this document “Sorting via the Columns Sorting Area”.

Sorting via the “Columns Sorting” Area:

An alternate method to define column sorting aside from selecting the sorting via the “Not sorted” link on the data field itself, is to use the “Columns Sorting” area.

1.  Locate the “Columns Sorting” area.

2.  Select the [Click here to add a new column] link to select the data field you would like to apply sorting against.

The “Start Date” field is now selected and notice the sort order of “Ascending” is automatically applied.

3.  The default sort order of “Ascending” can be updated by selecting the provided blue link and updating the sort order as seen in the following image.

The sort order has now been updated to “Descending”.

The below image shows a sample of the Start Date information being displayed in Descending order:

Note: When applying sorting to multiple columns within a single query (shown in below image), the following rules will apply:

1.  The “CallerCounty” will be sorted in Ascending order first (A to Z)

2.  Next, if multiple occurrences of the same county occur (Adams and Alamosa), the “StartDate” is then sorted by descending (reverse chronological) order.

The following image is an example of how multiple sort definitions apply.