Grouping rows by a non-unique name while preserving order and gaps in indexes is a common SQL challenge. This article explains how to solve the 'gaps and islands' problem using PostgreSQL, providing both the gaps and islands method and a more concise range aggregation approach.
Comments