Tags / gaps-and-islands
Aggregating Length of Time Intervals and Grouping to Fixed Time Grid: A Step-by-Step Solution
SQL Running Total with Cumulative Flag Calculation Using Common Table Expression
Handling Missing Primary Keys for Derived Columns: The LAG/LEAD Puzzle in SQL Server 2012
SQL Query to Calculate Sum of Values for Each User and Date, Treating Consecutive Days as a Single Day
Summing Over Rows Based on Column Value Using PostgreSQL Window Functions