Sessionize Mobile Banking App Events With Timeouts and Logouts

Last updated: November 29, 2026

Quick Overview

From a log of Capital One mobile app events, assign session numbers per customer where a new session starts after 30 minutes of inactivity or after a logout event, then report each session's start, end, event count, and whether a bill payment happened.

Capital One
Data Manipulation (SQL/Python)
Data Engineer
Capital One
November 29, 2026
Data Engineer
Onsite
Data Manipulation (SQL/Python)
Hard

0

0

0 solved


From a log of Capital One mobile app events, assign session numbers per customer where a new session starts after 30 minutes of inactivity or after a logout event, then report each session's start, end, event count, and whether a bill payment happened.

The Capital One mobile app is a primary servicing channel, and digital analytics teams rebuild sessions from raw event streams to measure things like time to pay a bill. The interviewer is checking LAG plus a running sum to build session ids, and whether you place the logout event in the session it ends rather than the next one.

What the Interviewer Expects
  • Uses LAG on both timestamp and event type
  • Marks a new session on first event, timeout gap, or a previous logout
  • Builds session ids with a cumulative SUM of the new-session flag
  • Keeps the logout in the session it closes
  • Aggregates per session with a conditional flag for bill payment
Key Topics to Cover
sessionization
LAG
running sum
event streams
mobile analytics
How to Approach This
  1. Clarify the schema and expected output format before writing queries.
  2. Use CTEs (WITH clauses) to break complex queries into readable steps.
  3. Consider window functions (ROW_NUMBER, RANK, LAG, LEAD) for ranking and sequential analysis.
  4. Watch for NULLs, duplicates, and edge cases in JOINs and GROUP BY.
  5. For pandas, prefer vectorized operations over row-by-row iteration.
Possible Follow-up Questions
  • How would you cap sessions at four hours even if events keep arriving?
  • How would you handle late-arriving events in a daily batch job?
  • How would you compute median time from session start to bill payment?
  • How would this change if the app emits background and foreground events?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice SQL Problems
Sample Answer
Clarify the Data
  • app_events(customer_id, event_ts, event_type) with types such as login, view_balance, pay_bill, logout.
  • Timeout is strictly more than 30 minutes between consecutive events.
  • The logout ...
Approach
  1. For each event, get the previous event's timestamp and type with LAG.
  2. is_new = 1 when there is no previous event, the gap exceeds 30 minutes, or the previous event was a logout.
  3. Running SUM...

Submit Your Answer
Markdown supported