Activity periods of client 444, pause at most 9 days
Questions like this come up in interviews at Альфа-Банк
Instructions
Split the activity of the client with client_id = 444 in 2025 into periods. An active day is a day on which at least one transaction went through any of the client's accounts (by tx_time). The pause between two consecutive active days is the number of days without transactions between them (between March 3 and March 5 the pause is 1 day, between March 3 and March 4 it is 0). A pause of at most 9 days does not break a period; a pause longer than 9 days starts a new period. Output period_no (the period number: 1, 2, … in time order), period_start and period_end (the first and last active day of the period), active_days (the number of active days in it) and tx_cnt (the number of transactions in it). Sort by period_no.
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.