PracHub
QuestionsPremiumLearningGuidesInterview PrepNEWCoaches

Quick Overview

This question evaluates a data scientist's ability to perform time-based aggregations, unit conversion, filtering by user segment, and dimensional segmentation (e.g., device_type) on raw event tables.

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

Calculate Weekly, Monthly Watch Hours for Paid Users

Company: Amazon

Role: Data Scientist

Category: Data Manipulation (SQL/Python)

Difficulty: Medium

Interview Round: Technical Screen

video_view_logs +---------+----------+----------------+------------+------------+ | user_id | video_id | watched_seconds| watch_date | device_type| +---------+----------+----------------+------------+------------+ | 101 | 55 | 360 | 2023-08-14 | mobile | | 102 | 60 | 240 | 2023-08-15 | desktop | | 101 | 58 | 1800 | 2023-08-20 | tablet | | 103 | 55 | 600 | 2023-08-21 | mobile | | 104 | 72 | 900 | 2023-08-22 | smart_tv | ##### Scenario You have a raw event table storing every video view. Product managers need a report of total hours watched per week and per month, segmented by device_type and filtered to paid users only. ##### Question Write an efficient SQL query (or equivalent pandas code) that returns weekly and monthly aggregated watch hours meeting the above conditions. Explain any windowing or date-trunc techniques you use. ##### Hints Convert seconds to hours, DATE_TRUNC or to_period for grouping, filter before aggregation to minimize scan size.

Quick Answer: This question evaluates a data scientist's ability to perform time-based aggregations, unit conversion, filtering by user segment, and dimensional segmentation (e.g., device_type) on raw event tables.

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

  • Find recommended friend pairs by shared songs - Amazon (medium)
  • Find recommended friend pairs by shared listening - Amazon (easy)
  • Write SQL window functions for D7 retention - Amazon (medium)
  • Find daily first-order merchants with SQL - Amazon (Medium)
  • Design student–course data models and SQL - Amazon (Medium)