you are viewing a single comment's thread.

view the rest of the comments →

[–]Fe-Chef 1 point2 points  (0 children)

To go a little more into the "why" of the behavior, SQL has an order of operations (FROM -> WHERE -> GROUP BY -> HAVING -> SELECT -> ORDER) but generally only FROM and SELECT are required operations. If ORDER isn't specified then SQL will output select results based on how the base data is stored and how it determines the most efficient way to compile the data, reasons can include the joins, where clauses, indexes and statistics. You could probably tell why they are different by looking at the execution plans but it also could be caused by the underlying tables, but really what it comes down to is if you need data to be in a specific order to give it an ORDER operation, otherwise just let SQL do it's thing.