PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCoaches

Quick Overview

This question evaluates a candidate's ability to perform SQL and Python data manipulation for event analytics, including cohort retention, aggregation of distinct purchasing users, median-of-daily-events calculations, and hourly time-series grouping.

  • Medium
  • Snapchat
  • Data Manipulation (SQL/Python)
  • Data Scientist

Compute User Retention and Analyze Event Data

Company: Snapchat

Role: Data Scientist

Category: Data Manipulation (SQL/Python)

Difficulty: Medium

Interview Round: Onsite

user_events +---------+---------------------+------------+-------+ | user_id | event_time | event_type | page | +---------+---------------------+------------+-------+ | 101 | 2023-04-01 10:00:00 | click | home | | 101 | 2023-04-02 11:00:00 | purchase | cart | | 102 | 2023-04-01 12:30:00 | click | home | | 103 | 2023-04-03 09:15:00 | impression | deal | | 102 | 2023-04-04 14:20:00 | purchase | cart | +---------+---------------------+------------+-------+ ##### Scenario Data team maintains a user_events fact table tracking every page view, click and purchase. Leadership wants ad-hoc SQL insights. ##### Question Write a query to compute 7-day user retention (inclusive) for users who first visited on '2023-04-01'. Return the top 3 pages by distinct purchasing users last month. Find the median number of daily events per active user in April 2023. In Python, given a Pandas DataFrame identical to user_events, produce an hourly time-series of clicks per page for the past 24 hours. ##### Hints Window functions, CTEs, DATE_DIFF and groupby should all be considered.

Quick Answer: This question evaluates a candidate's ability to perform SQL and Python data manipulation for event analytics, including cohort retention, aggregation of distinct purchasing users, median-of-daily-events calculations, and hourly time-series grouping.

Last updated: Mar 29, 2026

Loading coding console...

PracHub

Master your tech interviews with 7,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.

Related Coding Questions

  • Compute same-day acceptance metrics last week - Snapchat (Medium)
  • Compute CTR and metrics with pandas - Snapchat (Medium)
  • Monitor Friend-Request System for Quality and Abuse - Snapchat (Medium)
  • Compute User Group Stories and Aggregate Story Engagement - Snapchat (Medium)