PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCoaches

Quick Overview

This question evaluates a candidate's competency in SQL data manipulation, including aggregation over calendar dates, grouping by customer, and handling ties when determining top buyers.

  • Medium
  • Amazon
  • Data Manipulation (SQL/Python)
  • Business Intelligence Engineer

Identify Top-Buying Customers Daily with SQL Query

Company: Amazon

Role: Business Intelligence Engineer

Category: Data Manipulation (SQL/Python)

Difficulty: Medium

Interview Round: Onsite

PRIME +-------------+------------+----------+ | Customer_ID | Start_Date | End_Date | +-------------+------------+----------+ | 1 | 2025-01-01 | 2025-12-31| | 2 | 2025-03-15 | 2025-10-15| +-------------+------------+----------+ ​ ORDERS +-------------+----------+------------+-----------+--------------+ | Customer_ID | Order_ID | Order_Day | Product_ID| Quantity_Sold| +-------------+----------+------------+-----------+--------------+ | 1 | 1001 | 2025-04-01 | P123 | 3 | | 1 | 1002 | 2025-04-01 | P456 | 2 | | 2 | 1003 | 2025-04-01 | P123 | 6 | +-------------+----------+------------+-----------+--------------+ ##### Scenario E-commerce platform wants to identify the top-buying customer(s) for every calendar day based on total quantity sold. ##### Question Write an SQL query that, for each calendar day, returns the Customer_ID with the highest total Quantity_Sold and the corresponding total units. Return all customers in case of a tie. ##### Hint Aggregate by day and customer, then use RANK() or DENSE_RANK() over daily totals to select rank = 1.

Quick Answer: This question evaluates a candidate's competency in SQL data manipulation, including aggregation over calendar dates, grouping by customer, and handling ties when determining top buyers.

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)