← Instacart Interview Insights

Instacart·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
Jul 2026

Summary

SQL interview at Instacart for a software engineer role. Two related food delivery problems back to back, the second being a harder extension of the first.

Questions Asked (2)

Q1

Write an SQL query to find the percentage of orders where the customer's preferred delivery date matches the order date (same-day orders), rounded to two decimal places.

Data ModelingProduct Analytics & Metrics
Author's notes

Pretty standard aggregation query.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the schema and definitions: identify the orders table, the order date column, and the customer's preferred delivery date column. Then write a query that counts same-day orders (where the two dates match) and divides by the total number of orders, multiplying by 100 and rounding to two decimal places. Use conditional aggregation or a subquery to compute the percentage in a single pass.

Pro tip: Mention that you would confirm whether 'same-day' means the dates match exactly or if time components should be ignored, and whether to include only completed orders or all orders. This shows attention to data quality and business context.

1. Clarify requirements and schema

Ask about the table structure, column names, and any filters (e.g., order status, date range). Confirm the definition of 'same-day' and whether to consider time zones or timestamps.

2. Identify relevant columns

Locate the order date column (e.g., order_date) and the preferred delivery date column (e.g., preferred_delivery_date). Ensure both are in comparable formats (e.g., DATE type).

3. Compute numerator and denominator

Count the number of orders where order_date = preferred_delivery_date (numerator) and the total number of orders (denominator). Use conditional aggregation (SUM(CASE WHEN ... THEN 1 ELSE 0 END)) or subqueries.

4. Calculate percentage and round

Divide the numerator by the denominator, multiply by 100.0 to avoid integer division, and round to two decimal places using ROUND(..., 2).

5. Write and validate the query

Assemble the final SQL query, ensuring proper handling of NULLs and edge cases (e.g., zero orders). Optionally, test with sample data or explain how you would verify the result.

Key Points to Mention

  • Use of conditional aggregation (SUM(CASE WHEN ... THEN 1 ELSE 0 END)) to compute the numerator in a single query.
  • Avoiding integer division by multiplying by 100.0 or casting to float/decimal.
  • Handling NULL values in the date columns (e.g., excluding them or treating as not same-day).
  • Considering whether to filter by order status (e.g., completed orders only) or date range.
  • Using ROUND function to format the result to two decimal places.
  • Potential need to group by time period (e.g., daily percentage) if the question implies a trend, though the base question asks for overall percentage.

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

Q2

Extend the previous query: for each customer, identify their very first order, then compute the percentage of customers whose first order was a same-day delivery.

Data ModelingAlgorithms & Data StructuresProduct Analytics & Metrics
Author's notes

This is where I slowed down.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Use a window function like ROW_NUMBER() partitioned by customer_id and ordered by order_date to identify each customer's first order, then filter to those rows and compute the percentage where the delivery was same-day. Alternatively, use a subquery with MIN(order_date) per customer and join back to the orders table, handling ties if multiple orders share the same date.

Pro tip: Clarify how to handle ties for the first order (e.g., multiple orders on the same day) and whether 'same-day delivery' is a boolean flag or derived from timestamps; this shows attention to data quality and business logic.

1. Identify first order per customer

Use a window function (e.g., ROW_NUMBER() OVER (PARTITION BY customer_id ORDER BY order_date)) or a subquery with MIN(order_date) to select the earliest order for each customer.

2. Determine same-day delivery status

Check if the first order qualifies as same-day delivery, either via a boolean column or by comparing order_date and delivery_date.

3. Compute percentage

Calculate the ratio of customers whose first order was same-day to the total number of customers with at least one order, using COUNT and division.

4. Handle edge cases

Decide how to treat ties (multiple first orders on the same date) and customers with no orders, and mention any assumptions.

Key Points to Mention

  • Use of window functions (ROW_NUMBER, RANK) vs. subqueries for first-order identification
  • Definition of 'same-day delivery' (flag vs. derived from timestamps)
  • Handling ties for first order (e.g., multiple orders on the same day)
  • Ensuring the denominator includes only customers with at least one order
  • Performance considerations for large datasets (e.g., indexing, partitioning)
  • Potential need to group by customer before aggregating

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