I want to group it into this format (column VisitNo):
How can I do this using aggregation framework? Can’t find any similar example. I thought maybe to use the $accumulator but don’t know how to do it.
I want an equivalent of sql window function:
select u.RootId, u.VisitDate, count(u.VisitDate) over(partition by u.rootid order by u.visitdate) as VisitNo
From dbo.ProspectiveFollowUp u