Why can the order of the output be different when a WHERE clause is used?
If the table in DB2Everyplace has an index over one of the fields, If you use a WHERE clause the, the order of the output may be sorted by the index.
For a query with WHERE clause, since there is index on one of the columns, the record retrieving is performed by index searching. For another query without the where clause, the data file is returned sequentially. To some extent, the later scenario for the resultset order depends or when the record was inserted.
If you want to ensure a consistent order of the resultset on a column, you can always use ORDER BY syntax to sort the resultset.
Rate this page:
Copyright and trademark information
IBM, the IBM logo and ibm.com are trademarks of International Business Machines Corp., registered in many jurisdictions worldwide. Other product and service names might be trademarks of IBM or other companies. A current list of IBM trademarks is available on the Web at "Copyright and trademark information" at www.ibm.com/legal/copytrade.shtml.