Sort Order

  • When a result list should be displayed in a specific order, sorting should take place on the database level and NOT on the client. This is especially important in cases when the list cannot be returned in full but rather in batches of records. Sorting each batch of records separately would not guarantee the sort order between records of different batches.
  • Columns in the sort order list must be specified in the selection list.
  • Prefix each field used in this clause with its table's alias name.
  • Explicitly specify whether sorting should be ascending or descending and do not rely on database defaults.