I am aiming to obtain a record set like this
date flag number
01 0 1
02 0 1
03 1 2
04 1 2
05 1 2
06 0 3
07 1 4
08 1 4
I start from the record set with "date" and "flag" only. I am trying to compute the "number" column by using T-SQL ranking and partitioning functions.
A normal ranking would give a result like this:
date flag number
01 0 1
02 0 1
03 1 2
04 1 2
05 1 2
06 0 1
07 1 2
08 1 2
Any suggestion?