The MAX-ROWS qualifier on a query determines the number of rows returned. The MAX-ROWS calculation is applied before any sorting is applied to the query, causing the results to be random. Consider the following example:
DEFINE QUERY x FOR customer SCROLLING.
OPEN QUERY x FOR EACH customer MAX-R0WS 15.
GET LAST x.
DISPLAY customer.custnum.
REPEAT:
GET PREV x.
DISPLAY customer.custnum.
END.
When this example is run with the OpenEdge sports database, the first record return has custnum 54, and the repeat loop displays other custnums in descending order from there. When this example is run with the sports database migrated to MS SQL Server, the first record returned has custnum 15, and the repeat loop displays values in descending order from there. This difference in results is a caused by the MAX-ROWS being applied prior to the sorting.