Avatar of Pavlo
Pavlo
Flag for Canada

asked on 

How to get date ranges of islands of records? 2

Hello,

I have following data:
ID  Date  Category
1  1/1/2000  1
2  1/2/2000  1
3  1/4/2000  1
4  1/6/2000  2
5  1/8/2000  2
6  1/10/2000 1
7  1/12/2000 1

the result should be:
Category  DateStart  DateEnd
1                1/1/2000   1/4/2000
2                1/5/2000   1/9/2000    
1                1/10/2000   1/12/2000

Briefly, Category 2 (if any records exist with this Category) must fit into interval, not occupied by Category 1

Please help
Thank you
Microsoft SQL ServerMicrosoft SQL Server 2008SQL

Avatar of undefined
Last Comment
Pavlo

8/22/2022 - Mon