Sorting rows

You can use an ORDER BY clause in the SQL SELECT statement for the DataWindow object to sort the data that is retrieved from the database. If you do this, the DBMS itself does the sorting, and the rows are brought into PocketBuilder already sorted.

However, you might want to sort the rows after they are retrieved. For example, you might want to:

Figure 22-2: Selecting rows for sorting retrieved data

The sample shows the Specify Sort Columns dialog box. At top are instructions to drag and drop items and to double click any items you want to edit. A Source Data area displays the columns that you can drag and drop into  the Columns box at right. In the Columns box you can specify whether to sort in Ascending or Descending order.

StepsTo sort the rows:

  1. Select Rows>Sort from the menu bar.

  2. Drag the columns that you want to sort the rows on to the Columns box, and specify whether you want to sort in ascending or descending order.

    The order of the columns determines the precedence of the sort. To reorder the columns, drag them up or down in the list. To delete a column from the sort columns list, drag the column outside the dialog box.

  3. You can also specify expressions to sort on: for example, if you have two columns, Revenues and Expenses, you can sort on the expression Revenues – Expenses.

    To specify an expression to sort on, double-click a column name in the Columns box, modify the expression in the Modify Expression dialog box, and click OK. You return to the Specify Sort Columns dialog box with the expression displayed.

    You can remove a column or expression from the sorting specification by simply dragging it and releasing it outside the Columns box.

  4. Click OK when you have specified all the sort columns and expressions.