The problem seems simple but I can't get my head around it, this is for sql server
what I have in a table : What I need as a output .
cksum id cksum id
-2162514679 204 -2162514679 204 1
-2162514679 207 -2162514679 207 1
-2162514679 215 -2162514679 215 1
-2162514679 218 -2162514679 218 1
-2162514679 221 -2162514679 221 1
-2160286363 257 -2160286363 257 2
-2160286363 260 -2160286363 260 2
-2160286363 332 -2160286363 332 2
-2162514679 335 -2162514679 335 3
-2162514679 338 -2162514679 338 3
-2126731931 348 -2126731931 348 4
-2126731931 387 -2126731931 387 4
The table is ordered by id, I need a rank that follows the id column but that groups the cksum, notice that the cksum can return to a previous value yet still have its rank because of the ID (this is the case for the value 2162514679, it apears 5 times at the begining and a second time more bellow and they constitude two different ranks). I've been at it for a couple of hours and it seems really stupid like using a row_number with a partition or using a CTE but nope.... can't find the peice of logic to do this... anyone has the answer?