Last Updated: May 3, 2026
Questions about consecutive records show up frequently in SQL interviews: "find users who were active on 3 or more consecutive days," "identify tracks in a row with the same duration," or "find each user's longest daily streak." These all reduce to the same core challenge: SQL has no built-in way to group rows by consecutive sequence. You need a technique to manufacture that grouping yourself.
This chapter covers four approaches to solving consecutive-record problems.