• drew.allen (7/2/2015)


    Phil Parkin (7/2/2015)


    drew.allen (7/2/2015)


    If you don't specify the ROWS or RANGE, it uses RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW, so the current row is always the max value in that range with that sort. Try specifying ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING.

    Drew

    Pretty much what I suggested. I did not find these 'defaults' in the documentation though, thanks for posting.

    Yes, I didn't look at your code before I had posted this, and, from the comments, it didn't appear that a definitive answer had been supplied.

    It's under the "General Remarks" at https://msdn.microsoft.com/en-us/library/ms189461.aspx

    Drew

    Thanks. I looked exactly there this morning, but it was pre-coffee and clearly didn't sink in!

    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.