← DoorDash Interview Insights

DoorDash·Data Scientist·Technical Phone Screen·Intermediate

Intermediate
May 2026

Summary

DoorDash data science interview focused entirely on SQL, four interconnected parts all built around the same orders schema. The questions escalated nicely from basic aggregation to window functions and percentile logic, which I appreciated, though part four tripped me up more than I expected.

Questions Asked (4)

Q1

For each calendar month, what percentage of that month's total orders were placed by high-frequency customers, defined as customers who placed more than 30 orders in that month?

Product Analytics & MetricsData Modeling
Author's notes

This one is mostly mechanical once you realize you need two layers: first aggregate per (month, customer) to find who clears the 30-order threshold, then join that back to get their share of total orders.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

First, aggregate orders by customer and calendar month to compute each customer's monthly order count, then flag those with more than 30 orders as high-frequency. Finally, for each month, calculate the percentage as the sum of orders from high-frequency customers divided by the total orders in that month, multiplied by 100.

Pro tip: Clarify the definition of 'high-frequency' upfront—specifically, whether it's based on orders placed in that month or a rolling window—and confirm that the denominator includes all orders, not just those from high-frequency customers.

1. Define high-frequency customers

Confirm that high-frequency customers are those with more than 30 orders in a given calendar month, and decide whether to include or exclude incomplete months.

2. Aggregate orders by customer and month

Group the orders data by customer ID and calendar month, then count the number of orders per customer per month.

3. Identify high-frequency customers per month

For each month, flag customers whose order count exceeds 30 as high-frequency.

4. Calculate monthly totals and high-frequency totals

For each month, compute the total number of orders and the total number of orders placed by high-frequency customers.

5. Compute percentage per month

Divide the high-frequency order total by the overall order total for each month and multiply by 100 to get the percentage.

Key Points to Mention

  • Clear definition of high-frequency customers (>30 orders in the month).
  • Handling of edge cases: customers with exactly 30 orders, incomplete months, or missing data.
  • Use of window functions or self-joins to compute per-customer monthly counts.
  • Importance of the denominator: total orders in the month, not total customers.
  • Potential need to filter out test orders or cancellations depending on business context.
  • Presentation of results: monthly trend, possibly with visualization.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q2

Excluding high-frequency customers, find the top spender for each month by total order value. If multiple customers tie for the top, return all of them.

Product Analytics & MetricsData Modeling
Author's notes

The tie-handling is what makes this annoying.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Clarify the definitions of 'high-frequency customers' and 'total order value', then outline a SQL-based approach using CTEs to filter, aggregate, rank, and handle ties. Walk through the logic step-by-step, emphasizing window functions and tie-breaking.

Pro tip: Always confirm the threshold for 'high-frequency' and whether 'total order value' includes discounts, refunds, or delivery fees—these details can significantly impact the analysis and show you think like a business analyst.

1. Clarify Definitions and Assumptions

Ask clarifying questions to define 'high-frequency customers' (e.g., order count > X) and 'total order value' (e.g., sum of order subtotals). Confirm if ties should be broken by any secondary criteria or if all tied customers are returned.

2. Filter Out High-Frequency Customers

Using a subquery or CTE, identify customers whose order frequency exceeds the threshold and exclude them from the analysis.

3. Aggregate Monthly Spend per Customer

Group orders by month and customer, summing the order value to get each customer's total spend per month.

4. Rank Customers Within Each Month

Use a window function like RANK() or DENSE_RANK() partitioned by month and ordered by total spend descending to identify the top spender(s).

5. Select Top Spenders and Handle Ties

Filter to rows where rank = 1, ensuring all tied customers are included. Present the final result with month, customer, and total spend.

Key Points to Mention

  • Use of window functions (RANK, DENSE_RANK) to handle ties correctly.
  • Importance of filtering high-frequency customers before aggregation to avoid skewing results.
  • Handling of date truncation to month (e.g., DATE_TRUNC('month', order_date)).
  • Consideration of order value definition (e.g., subtotal vs. total including fees).
  • Performance optimization: filtering early and using CTEs for readability.
  • Edge cases: months with no orders, customers with zero spend, and ties beyond first place.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q3

Compute the month-over-month change in total sales for a specific restaurant, then generalize the same logic to every restaurant.

Product Analytics & MetricsData Modeling
Author's notes

LAG() over a partition by restaurant ordered by month, pretty standard.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the data model and defining the metric (total sales) and time grain (month). Then write a query that computes month-over-month change for a single restaurant using window functions, and finally generalize it by partitioning by restaurant ID to get the change for every restaurant.

Pro tip: Mention that you would validate the results by checking edge cases like the first month (where there is no previous month) and ensuring that the window function is correctly partitioned and ordered. Also, discuss how you would handle missing months or incomplete data.

1. Clarify requirements and data model

Ask questions to confirm the definition of 'total sales' (e.g., sum of order amounts), the time period, and the table structure. Ensure you understand how restaurants are identified and how sales are recorded.

2. Compute MoM change for one restaurant

Write a SQL query that filters for a specific restaurant, aggregates sales by month, and uses the LAG window function to get the previous month's sales. Then calculate the difference or percentage change.

3. Generalize to all restaurants

Modify the query to remove the filter and add PARTITION BY restaurant_id in the window function. This computes the MoM change for each restaurant independently.

4. Handle edge cases and validate

Address scenarios like the first month (where previous sales is NULL), missing months, and restaurants with no sales in a month. Validate the query with sample data or by checking known values.

5. Optimize and present results

Consider performance implications (e.g., indexing, partitioning) and how to present the results clearly, such as a table with restaurant_id, month, sales, and MoM change.

Key Points to Mention

  • Use of window functions (LAG) to access previous month's sales
  • Partitioning by restaurant_id to generalize the calculation
  • Handling NULL values for the first month or missing data
  • Definition of month-over-month change: absolute difference or percentage change
  • Data aggregation: summing sales per restaurant per month
  • Validation and edge cases: ensuring correct ordering of months and dealing with incomplete data

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q4

Given a query that computes the percentage of customers ordering from bottom-30%-by-sales restaurants, explain what the query does line by line, then rewrite it to produce that percentage broken out per month.

Product Analytics & MetricsData ModelingRoot Cause Analysis
Author's notes

This is where I fumbled.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

First, walk through the query line by line, explaining each clause and its purpose in computing the overall percentage. Then, restructure the query to group by month, ensuring the bottom-30% classification is recalculated per month or kept static as appropriate, and clearly state any assumptions.

Pro tip: Clarify whether the bottom-30% restaurants should be determined globally or per month—this choice significantly impacts the metric and shows you understand business context. Also, mention how you'd handle edge cases like months with insufficient data.

1. Understand the query's goal

Restate the objective: compute the percentage of customers who ordered from restaurants in the bottom 30% by sales. Identify the key tables and metrics involved.

2. Explain line by line

Break down each part: subquery to rank restaurants by sales, filter for bottom 30%, join with orders, count distinct customers, and compute the percentage.

3. Plan the rewrite for monthly breakdown

Decide whether to recompute the bottom 30% per month or use a fixed set. Then, add date truncation to month and group by month, adjusting the percentage calculation accordingly.

4. Write the rewritten query

Construct the SQL with a CTE for monthly restaurant sales, another for bottom 30% per month, and a final aggregation joining orders and customers, grouped by month.

5. Validate and discuss assumptions

Check for correctness, mention potential pitfalls (e.g., ties, incomplete months), and explain how the metric might be interpreted by stakeholders.

Key Points to Mention

  • Use of window functions like NTILE or PERCENT_RANK to identify bottom 30% by sales.
  • Definition of 'customer'—distinct users or total orders? Clarify the denominator.
  • Handling of time zones and date truncation for monthly grouping.
  • Whether bottom 30% is recomputed monthly or fixed; implications for trend analysis.
  • Edge cases: restaurants with zero sales, months with no orders, and ties in sales ranking.
  • Performance considerations: indexing, partitioning, and avoiding repeated subqueries.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.