min([sequence]) over(partition by [group],diff) as min_seq, max([sequence]) over(partition by [group],diff) as max_seq ...