jeremyevans/sequel — pull request #393 by jfirebaugh (2011-11-03 18:34:57+00:00)
Title: Explicitly order by the row number column when using ROW_NUMBER

MSSQL does not guarantee ordering of a result set that uses
ROW_NUMBER unless you explicitly order it.

"These ORDER BY clauses do not determine the order that rows will
be returned from the query. To guarantee absolutely a certain
output order from the query, you must add an explicit query-level
ORDER BY clause" - http://blogs.msdn.com/b/craigfr/archive/2008/03/19/ranking-functions-row-number.aspx

I haven't found it documented for Oracle or DB2, but I wouldn't be
surprised if they behave the same.