We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
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.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Occupations
You are viewing a single comment's thread. Return to all 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 beforeORDER BY
. It seems that anytime you derive a column (usingCASE
, 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 theORDER BY
clause is non-derived.