Identify sub-set of records based on date and rules in SQL Server
问题 I have a dataset that looks like this: I need to identify the rows that have Linked set to 1 but ONLY where they are together when sorted by ToDate descending as in the picture. In other words I want to be able to identify these records ( EDITED ): This is a simplified dataset, in fact there will be many more records... The logic that defines whether a record is linked is if the FromDate of a record is within 8 weeks of the ToDate of the preceeding date...but this is testData so may not be