Skip to content
Advertisement

Tag: counter

Microsoft SQL Server Streak Counter

I have data in the following format: ID Period Date 1 1 2020-09-05 1 2 2020-10-01 1 3 2020-10-30 2 2 2020-10-01 2 4 2020-12-05 2 6 2021-02-05 3 1 2020-09-05 I want to calculate a streak grouping by both ID and period. The first date instance for each group should start at one, and if the date in the

Advertisement