---
title: "Consecutive User Logins - SQL Interview Query 17 | SQL Problem Level \"MEDIUM\""
url: https://daily.dev/posts/consecutive-user-logins---sql-interview-query-17-sql-problem-level-medium--rjxh698h7
source_url: https://www.youtube.com/watch?v=F-gETvj-oN0
type: video:youtube
source: "techTFQ"
published: 2026-05-31T07:43:10.958Z
updated: 2026-05-31T07:51:40.874Z
tags: ["sql", "postgresql", "microsoft-sql-server"]
reading_time: 20
upvotes: 0
comments: 0
language: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Consecutive User Logins - SQL Interview Query 17 | SQL Problem Level "MEDIUM"

**[techTFQ](https://daily.dev/sources/techtfq)** · 20 min read · 0 upvotes · 0 comments

## Summary

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).

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://www.youtube.com/watch?v=F-gETvj-oN0>

---

Tags: [#sql](https://daily.dev/tags/sql), [#postgresql](https://daily.dev/tags/postgresql), [#microsoft-sql-server](https://daily.dev/tags/microsoft-sql-server)

[View this post on daily.dev](https://daily.dev/posts/consecutive-user-logins---sql-interview-query-17-sql-problem-level-medium--rjxh698h7)
