• If I understood it correctly, you want groups of 63 rows supposing they are consecutives and then select the first row for each group.

    WITH T AS (

    SELECT

    ID,

    PeriodBegin,

    PeriodEnd,

    ROW_NUMBER() OVER(PARTITION BY ID, ((PeriodBegin - 1) / 63) + 1 ORDER BY PeriodBegin) AS rn

    FROM

    #Intervals

    )

    SELECT

    ID,

    PeriodBegin,

    PeriodEnd

    FROM

    T

    WHERE

    rn = 1

    ORDER BY

    ID,

    PeriodBegin;

    GO

    This expression ((PeriodBegin - 1) / 63) + 1 assign an incremental group number (63 rows each group) and the ROW_NUMBER enumerate the rows partition by (ID, grpnum). The rest is to select all rows where rn = 1.

    I am afraid I am taking it too simple.