Tags / gaps-and-islands
Creating Time Windows with Alternating Values in T-SQL
SQL Window Functions for Aggregate Calculations with the COALESCE and MAX Approach
Finding the Longest Negative Series in PostgreSQL: A Step-by-Step Solution
Using Window Functions to Identify Long Chains of Repeating Values in Binary Data