PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep

Quick Overview

This question evaluates a candidate's competence with SQL data manipulation and windowing concepts, specifically using ordering and partitioning to compare and rank events within a customer's purchase history.

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

Analyze Customer Purchase Patterns Using SQL Query

Company: DoorDash

Role: Data Scientist

Category: Data Manipulation (SQL/Python)

Difficulty: Medium

Interview Round: Technical Screen

orders +----------+-------------+-------------+------------+------+ | order_id | customer_id | order_value | order_date | city | +----------+-------------+-------------+------------+------+ | 101 | 1 | 120.50 | 2023-07-01 | LA | | 102 | 1 | 80.00 | 2023-07-18 | LA | | 103 | 2 | 200.00 | 2023-07-02 | NY | | 104 | 1 | 75.00 | 2023-08-01 | LA | | 105 | 3 | 50.00 | 2023-07-05 | SF | +----------+-------------+-------------+------------+------+ ##### Scenario E-commerce platform wants detailed insights into customer purchasing patterns over time. ##### Question Write a SQL query that, for every order, returns: 1) order_id, customer_id, order_value, order_date; 2) the previous order_value for the same customer (lag); 3) the rank and percent_rank of the current order_value among that customer’s lifetime orders, ordered by order_date descending. ##### Hints Use LAG, RANK, PERCENT_RANK window functions partitioned by customer_id and ordered by order_date.

Quick Answer: This question evaluates a candidate's competence with SQL data manipulation and windowing concepts, specifically using ordering and partitioning to compare and rank events within a customer's purchase history.

Last updated: Mar 29, 2026

Loading coding console...

PracHub

Master your tech interviews with 8,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

  • Calculate Order Request Metrics - DoorDash (hard)
  • Analyze Restaurant Customer Metrics - DoorDash (medium)
  • Write SQL for monthly spend and ratios - DoorDash (medium)
  • Compute rolling cold-delivery rates with windows - DoorDash (Medium)
  • Write SQL for percent and window changes - DoorDash (Medium)