• SQLCJ (7/2/2015)


    It works, Thank you Phil. But still it makes me wonder why did ordering DOJ in ascending order changed the output of the column there ? Can you please elaborate on that ?

    Spelling corrected:-D

    Not much! I found this in BOL:

    If ORDER BY is not specified entire partition is used for a window frame.

    Which implies that if ORDER BY is specified, the entire partition is not used.

    This, I suppose, is happening here.

    If you haven't even tried to resolve your issue, please don't expect the hard-working volunteers here to waste their time providing links to answers which you could easily have found yourself.