PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCoaches
|Home/Data Manipulation (SQL/Python)/Amazon

Compute unique visitors per department from clicks

Last updated: Mar 29, 2026

Quick Overview

This question evaluates a candidate's skill in data manipulation and deduplication using SQL/Python, specifically mapping hierarchical product metadata to departments and computing unique user counts without double-counting, and is categorized under Data Manipulation (SQL/Python).

  • Medium
  • Amazon
  • Data Manipulation (SQL/Python)
  • Software Engineer

Compute unique visitors per department from clicks

Company: Amazon

Role: Software Engineer

Category: Data Manipulation (SQL/Python)

Difficulty: Medium

Interview Round: Technical Screen

Given tables Products(product_id, department, category, subcategory) where department > category > subcategory form a hierarchy, and ClickLog(user_id, product_id, event_ts) that records user clicks, write SQL to compute the number of unique customers who visited (clicked any product in) a specified department over a given time range. Ensure correct mapping from product_id to its department and avoid double-counting users who clicked multiple products/categories within the same department. Explain your indexing/partitioning strategy for large-scale data and how you would extend the query to return results for all departments.

Quick Answer: This question evaluates a candidate's skill in data manipulation and deduplication using SQL/Python, specifically mapping hierarchical product metadata to departments and computing unique user counts without double-counting, and is categorized under Data Manipulation (SQL/Python).

Related Interview 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)
Amazon logo
Amazon
Sep 6, 2025, 12:00 AM
Software Engineer
Technical Screen
Data Manipulation (SQL/Python)
2
0

Given tables Products(product_id, department, category, subcategory) where department > category > subcategory form a hierarchy, and ClickLog(user_id, product_id, event_ts) that records user clicks, write SQL to compute the number of unique customers who visited (clicked any product in) a specified department over a given time range. Ensure correct mapping from product_id to its department and avoid double-counting users who clicked multiple products/categories within the same department. Explain your indexing/partitioning strategy for large-scale data and how you would extend the query to return results for all departments.

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Data Manipulation (SQL/Python)•More Amazon•More Software Engineer•Amazon Software Engineer•Amazon Data Manipulation (SQL/Python)•Software Engineer Data Manipulation (SQL/Python)
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.