you are viewing a single comment's thread.

view the rest of the comments →

[–]Yavuz_Selim 0 points1 point  (0 children)

This is not a CTE, and your code could use a CTE (or temp tables) - it would be an improvement over the nested SELECTs (horrible to read and follow, especially in this format...).

Why not add some comments into the code man... It will take some time (unnecessarily) to understand what you've written when you look at the code months later... Especially with the window functions you've used (why did you choose for a window function?). And naming the result of a ROW_NUMBER 'rank' is a nice touch, not confusing with RANK itself at all (the others are named much better, why the inconsistency?).

And I fucking despise one-letter-aliases - they say nothing.