A walkthrough of solving a medium-difficulty SQL interview problem: finding users who logged in for five or more consecutive days. The solution uses dense_rank() as a window function to assign group identifiers to consecutive login dates, then aggregates by user and date group, filtering with a HAVING clause based on the difference between min and max login dates. Implementations are shown for both PostgreSQL (using date arithmetic) and SQL Server (using DATEADD and DATEDIFF functions).

20m watch time
1 Impression