T-sql Reset Row number on Field Change

前端 未结 4 942
生来不讨喜
生来不讨喜 2020-12-10 03:58

Similar to a recent post of mine \"t-sql sequential duration\"”, but not exactly the same, I want to reset the row number based on a change in column x (in my case, column \

4条回答
  •  囚心锁ツ
    2020-12-10 04:57

    I had success with this issue by using Rank():

    SELECT RANK() OVER (PARTITION BY who ORDER BY custno, moddate) AS RANK
    

    This returned your desired results. I actually found this post trying to solve the same problem.

提交回复
热议问题