Now, open the table in Datasheet view. On the Home tab, in the Sort & Filter group, click Advanced and then click Advanced Filter/Sort on the shortcut menu. Add the fields you want, such as FirstName, LastName, and Title, to the grid. Right-click the Field row in the first blank column, click Zoom, and then type the following expression: IIf ([Title] = "Vice President, Sales", 1, IIf ([Title] = "Sales Manager", 2, IIf ([Title] = "Sales Representative", 3, IIf ([Title] = "Inside Sales Coordinator", 4, 5)))) Title is the name of the field that contains the values that are being ranked. The values enclosed in quotation marks are the individual values stored in the field. The numeric value that follows is the rank assigned to it. The preceding expression assigns ranks 1 through 4 to four different titles, and assigns rank 5 to all others. When you perform the sort, the titles not mentioned in this expression are assigned the same rank (5). In the Sort row for the column containing the expression, click Ascending. On the Home tab, in the Sort & Filter group, click Toggle Filter. The IIf function returns the numeric value that corresponds to the value in the Title field. For example, if the value in the Title field is Sales Manager, the number assigned is 2. If there is a value in the Title field not listed as an argument in the function — for example, District Coordinator — it is assigned the number 5. The query then sorts these numbers in ascending order. Sorting records in a table allows you to better understand the data that you are working with. You can discover the largest and smallest values or perhaps the most and least significant features in the layer. Sorting is also an efficient means for organizing your data in alphabetical or sequential order. To sort up to four fields at once
You can press SHIFT and double-click a field name or CTRL+SHIFT+S as a shortcut to opening the Advanced Table Sorting dialog box. To select all adjacent columns, place the pointer over the heading of the leftmost column, then click and hold while dragging to the right. To sort more than four records at once, use the CTRL key to select multiple fields, right-click, then choose to sort in ascending or descending order. The fields are sorted in the order you click them in the table. Tables normally display records in the order they were entered. Instead of working with a table's jumbled record order, you can create a simple query that sorts the table information and presents it in an ordered, easy-to-read display. You can sort records alphabetically, numerically, or chronologically (by date) in ascending (A to Z) or descending (Z to A) order. You can also sort by multiple fieldsfor example, you could sort by LastName and then by FirstName. This lesson will show you how you can use a query to sort information in a table.
TO SORT A QUERY USING MULTIPLE FIELDS:
|