Skip to content
Advertisement

Rolling Sum when date is continuous

I’m trying to find how many days people have continuously worked in SQL. I’m thinking a rolling sum might be the solution but don’t know how to work it out.

My sample data is

The designated result should be

If the days are not continuous, the continuous counting will re-start from 1.

Advertisement

Answer

Just another option … Very similar to a Gaps-and-Islands, but without the final aggregation.

Example

Returns

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement