When To Use the Order By Clause - (whenever ordering is required)

  • The conclusions of the article* may be a bit misleading:

    1 "We do not require an "order by" clause in a table, which has got a clustered index." 2 "We do not require an "order by" clause for a non-index column in a select statement and both index and non-index column in a select statement."


    The Order By clause itself is indeed optional, and more often than not 1 & 2 may indeed be observed in practice, However: Ordered results are only guaranteed if an order by is included. That is 1 & 2 are reproducible in the scope of the given examples and in many but not necessarily all situations. In other words the behavior represents an implementation artifact rather than a design property and should be kept in mind if considering omitting Order By in any non-trivial application that actually requires specific ordering). {IOW do so at your own risk.}  HTH

    *http://www.sqlservercentral.com/columnists/gvijayakumar/whentousetheorderbyclause.asp

Viewing 0 posts

You must be logged in to reply to this topic. Login to reply