Was looking through Row_number()
function in SQL Server to increment the counter every time the value changes. The issue is that I need it to reset on a change such that the same value can reappear at a later stage and the row_number
still resets and starts from 1 back again when you order it by datetime instead of grouping all the same type together and assigning a rownumber.
For example:
when I do
select
*,
row_number() over (partition by type order by datetime) Order
from
TableA;
I get the below result (instead of the desired output shown above):