Mockbit/#62
SQLhardGaps islands~22m

FitFlex gym chain tracks member gym attendance through entry card swipes

Problem

FitFlex gym chain tracks member gym attendance through entry card swipes. They want to identify members who maintained consecutive daily attendance streaks of at least 7 days during January 2024, but only count streaks where the member visited for at least 45 minutes each day. For each qualifying member, return their longest streak length, the start date, and end date of that streak. Handle cases where members might have multiple swipes on the same day (count as one visit with total duration), and ignore any days where total visit duration was less than 45 minutes.

Examples

Example 1

Example 2

Constraints
  • Return member_id, longest_streak_days, streak_start_date, streak_end_date
  • Only count streaks of 7+ consecutive days
  • Only count days with 45+ total minutes
  • Handle multiple visits per day by summing duration
  • Order by longest_streak_days DESC, then member_id ASC
Reference solution

Reference solution available after you attempt the question.

Ready to solve it?

Start a session on Mockbit #62. Write your SQL, run it against real data, and get graded on correctness, efficiency, query structure, and business understanding.

Related SQL questions
← Back homemockbit.io/q/62
PrivacyTerms© 2026 Mockbit