Sorting data from a query

You define a sort in a query to extract data in a specific order.

Before you begin

Add a query to an element.

About this task

A sort can be specified by using the native sort or the IBM Engineering Lifecycle Optimization - Publishing sort. The native sort allows you to enter the sort in the format supported native to the data source. A native sort is interpreted by the data source, while a PUB sort is processed by the product as it extracts data from the data source.

For more information on native sorts, consult the Integrating section of this product documentation. Also consult the product documentation for your data source to find details on the appropriate syntax.

Procedure

  1. Select an element in the template content editor.
  2. In the Properties view, expand Data.
  3. In the Sort property, click the ellipsis (…) button.
    The Sort Editor window displays.
  4. Specify the sort conditions:
    • t_formatting_results

      To use the PUB sort, click the Script tab to add to the sort expression.
      1. Select an attribute from the available attributes column.
      2. Click the >> icon to add the attribute to the selected column.
      3. For the Direction, select Ascending or Descending.
      4. For Sort as, select one of the following values:
        • Number: Sorts the data as numeric values. You can use this value when an attribute is defined as a string in the schema, but the values are all numbers.
        • Text: Sorts the data as string values.
        • No selection: The data is sorted based on the schema definition. The default value is no selection so that the data is sorted by the information that is defined in the schema.
        Note: If you are unsure whether the data contains number or text values, do not select the Sort as value.
        • If you select the wrong sort type, the sort might produce undefined results.
        • If all the values have an identical string prefix followed by a number and you select Number for the Sort as field, the data might sort correctly in some circumstances and not in others.
        In both of these situations, the Sort as value remains deselected.
      5. Click OK.
    • To use a native sort, click the Native tab and enter the sort expression in the Native window. Click OK.

    Whenever possible, use a native sort. The native sort generates document-style reports more quickly than a PUB sort.

  5. Click OK.

Results

The selected sort order is added to the current element.
Note:

Native sort validation is not performed by PUB. Compare the sort with a sort in the data source to verify accuracy.

Important: When using the data source configuration element to dynamically configure a data source at runtime, sorting functionality is not supported. If you define sort clauses on queries that retrieve data from a dynamically configured data source, the data is returned in its natural order from the data source, and the sort clauses are ignored.

What to do next

You can remove the sort expressions by clicking the Remove option that is displayed against each item. To remove all items, click Remove All.