Skip to Content
-3

Determine default sort order

How do we determine the default Sort order of an open SQL select query for a table having secondary indexes. Usually an extraction is sorted by primary key. Is there a function available in ABAP/HANA to determine this order?

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    Jul 13, 2017 at 05:10 AM

    There is no default sort order on relational databases. There is no concept of sort order for relational databases. If you do

    DATA myinternaltable TYPE standard table of mytable.
    SELECT * FROM mytable INTO TABLE myinternaltable 

    The order of records in myinternaltable is undefined. If you want an order, you must define it in you SELECT statement or you internal table, using ORDER BY, and TYPE SORTED TABLE, respectively. You absolutely cannot rely on the order of the records as read from the database.

    Add comment
    10|10000 characters needed characters exceeded