• Eirikur Eiriksson (7/8/2014)


    No need to complicate things, the only thing needed here is correct window specification for the row_number function.

    😎 ...This brings the cost of execution for this code down to aprox. 5% of the previous code.

    Very well done sir!

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001