• + 0 comments

    The spam blocker is getting me because I'm trying to copy and paste the code I used to investigate. I can still share the conclusion though:

    Contrary to what one is taught, it seems not everything in SELECT is executed before ORDER BY. It seems that anytime you derive a column (using CASE, by doing arithmetic, etc.), that column is going to be formed off of the ordered version of the non-derived fields if the field for the ORDER BY clause is non-derived.