Longest streak of active days: 'Казань', mass, Apr–Jun 2025
Instructions
A client's active day is a calendar day on which at least one transaction went through any of the client's accounts (by tx_time). For each client from the city 'Казань' with segment 'mass' who had at least one active day in the period April 1, 2025 to June 30, 2025 inclusive, find the longest streak of consecutive active days within this period (calendar days with no gaps; several transactions on one day count as one day): streak_days is its length in days, streak_start is its first day (if several streaks have the maximum length, the earliest one). Output client_id, streak_days, streak_start. Sort by streak_days descending, then client_id ascending.
Hints
Each next one is more detailed and costs more
Query
Result
Click Run to see the query result, or Check to submit your solution.
Dataset schema
Table relationships
- N:1Many-to-one
accounts.→client_id clients.id - N:1Many-to-one
transactions.→account_id accounts.id
Table data
Select a table in the diagram or list to view its rows.