← Uber Interview Insights

Uber·Data Scientist·Technical Phone Screen·Intermediate

Intermediate
May 2026

Summary

Uber data scientist interview with a heavy SQL and pandas focus, all centered around a single user events table. Five questions total, ranging from basic window functions to rolling averages. Nothing too wild but the breadth in one session was a bit much.

Questions Asked (5)

Q1

For each user, write a SQL query to return the first product they purchased along with the purchase timestamp.

Product Analytics & MetricsAlgorithms & Data Structures
Author's notes

Pretty standard first-purchase problem.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Use a window function like ROW_NUMBER() partitioned by user_id and ordered by purchase timestamp ascending, then filter to the first row per user. Alternatively, use a correlated subquery or join with a subquery that finds the minimum timestamp per user. Ensure the query handles ties and returns exactly one product per user.

Pro tip: Mention that if there are ties (same timestamp), you need a tiebreaker like the smallest product_id or transaction_id to ensure deterministic results. Also, clarify that 'first' means earliest timestamp, not first inserted row.

1. Understand the data and requirements

Identify the relevant table(s) and columns: user_id, product_id, purchase_timestamp. Clarify that 'first product' means the product with the earliest purchase timestamp for each user.

2. Choose an approach

Decide between using a window function (ROW_NUMBER, RANK, DENSE_RANK) or a subquery with MIN(timestamp). Window functions are often more efficient and easier to extend.

3. Write the query

For window function: SELECT user_id, product_id, purchase_timestamp FROM (SELECT *, ROW_NUMBER() OVER (PARTITION BY user_id ORDER BY purchase_timestamp ASC) AS rn FROM purchases) t WHERE rn = 1. For subquery: SELECT p.user_id, p.product_id, p.purchase_timestamp FROM purchases p JOIN (SELECT user_id, MIN(purchase_timestamp) AS min_ts FROM purchases GROUP BY user_id) m ON p.user_id = m.user_id AND p.purchase_timestamp = m.min_ts.

4. Handle ties and edge cases

If multiple products share the same earliest timestamp, decide on a tiebreaker (e.g., smallest product_id) and incorporate it into the ORDER BY or join condition. Also consider users with no purchases (they won't appear).

5. Validate and optimize

Check that the query returns one row per user. Consider indexing on (user_id, purchase_timestamp) for performance. Test with sample data including ties and nulls.

Key Points to Mention

  • Use of window functions (ROW_NUMBER, RANK, DENSE_RANK) for top-1 per group
  • Alternative approach using GROUP BY and JOIN with MIN(timestamp)
  • Importance of tie-breaking logic when timestamps are identical
  • Performance considerations: indexing, avoiding full table scans
  • Handling of users with no purchases (excluded from result)
  • Clarifying that 'first' refers to earliest timestamp, not insertion order

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

Q2

Write a SQL query to count how many distinct users made at least two purchases on the same calendar day.

Product Analytics & MetricsData Modeling
Author's notes

Blanked for a second on how to structure this.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

First, aggregate purchases by user and calendar day to count daily transactions per user. Then filter to users with at least two purchases on any day, and finally count the distinct users who meet this condition.

Pro tip: Clarify how to handle time zones and whether 'same calendar day' refers to UTC or local time, as this can significantly affect results in global apps like Uber.

1. Understand the data and requirements

Identify the relevant tables (e.g., purchases, users) and columns (user_id, purchase_date). Clarify the definition of 'calendar day' and any time zone considerations.

2. Aggregate purchases per user per day

Group the purchase data by user_id and the calendar day (using DATE() or equivalent) and count the number of purchases for each group.

3. Filter for users with at least two purchases

Apply a HAVING clause to keep only groups where the purchase count is >= 2.

4. Count distinct users

Use COUNT(DISTINCT user_id) on the filtered result to get the number of unique users who made at least two purchases on the same day.

Key Points to Mention

  • Use of GROUP BY with user_id and date to aggregate purchases.
  • Applying HAVING COUNT(*) >= 2 to filter groups.
  • Using COUNT(DISTINCT user_id) to get the final count.
  • Handling of date/time functions (e.g., DATE(), CAST) to extract calendar day.
  • Consideration of time zones and data partitioning for large datasets.
  • Potential need to exclude refunds or cancelled transactions if applicable.

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

Q3

Find the top 3 products by total number of purchases using SQL.

Product Analytics & Metrics
Author's notes

Easiest one in the set.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the schema and defining 'purchase' (e.g., completed orders, distinct transactions). Then write a SQL query that joins the purchases table to the products table, groups by product, counts purchases, orders descending, and limits to 3. Also discuss handling ties and data quality issues.

Pro tip: Mention that at a company like Uber, you'd likely need to consider time windows (e.g., last 30 days) and possibly segment by city or user cohort to make the metric actionable. Also, be prepared to discuss how you'd handle ties for third place.

1. Clarify requirements and schema

Ask about the table structure, what constitutes a purchase (e.g., order status, refunds), and whether 'top' means all-time or a specific period. Confirm if ties should be included or broken arbitrarily.

2. Write the core SQL query

Use a JOIN between purchases and products, GROUP BY product, COUNT(*) or COUNT(DISTINCT order_id), ORDER BY count DESC, and LIMIT 3. Ensure you handle NULLs and duplicates appropriately.

3. Address edge cases and ties

Discuss how to handle ties for third place (e.g., using RANK() or DENSE_RANK() in a subquery) and how to exclude cancelled or refunded orders.

4. Optimize and scale

Mention indexing on foreign keys, partitioning by date if needed, and using approximate algorithms (e.g., HyperLogLog) for large-scale distinct counts if performance is a concern.

5. Interpret and communicate results

Explain how you'd present the top 3 products, possibly with additional context like revenue or trend over time, and how this insight could drive business decisions.

Key Points to Mention

  • Definition of a 'purchase' (e.g., completed orders, distinct transactions)
  • Handling ties for the third position using window functions
  • Filtering out cancelled, refunded, or test orders
  • Time window consideration (e.g., last quarter, all-time)
  • Performance optimization for large datasets (indexes, partitioning)
  • Business context: why top products matter for Uber (e.g., Uber Eats, promotions)

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

Q4

Calculate a 7-day rolling average of total daily purchases across all users in SQL.

Product Analytics & MetricsAlgorithms & Data Structures
Author's notes

This one actually tripped me up more than I expected.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the table schema and the definition of 'total daily purchases'. Then write a SQL query that aggregates daily purchases, and use a window function to compute the 7-day rolling average over the daily totals.

Pro tip: Mention that you would handle missing dates by generating a date series to ensure the rolling window is based on calendar days, not just days with purchases. Also, discuss the choice between ROWS and RANGE in the window frame.

1. Clarify requirements and schema

Ask about the table structure (e.g., purchases table with user_id, purchase_date, amount) and confirm that 'total daily purchases' means the sum of purchase amounts per day. Also clarify the date range and whether to include days with zero purchases.

2. Aggregate daily totals

Write a subquery or CTE that groups by date and sums the purchase amounts to get total daily purchases.

3. Compute rolling average

Use a window function with AVG over an ORDER BY date and a frame of ROWS BETWEEN 6 PRECEDING AND CURRENT ROW to calculate the 7-day rolling average.

4. Handle missing dates (optional)

If there are gaps in dates, generate a complete date series and left join the daily totals to ensure the rolling window covers consecutive calendar days.

5. Finalize and validate

Select the date and rolling average, and consider ordering by date. Validate the query with sample data or edge cases.

Key Points to Mention

  • Use of window functions (AVG OVER) for rolling calculations
  • Defining the window frame correctly (ROWS BETWEEN 6 PRECEDING AND CURRENT ROW)
  • Handling missing dates to ensure accurate rolling averages
  • Aggregating daily totals before applying the window function
  • Performance considerations (e.g., indexing on date column)
  • Difference between ROWS and RANGE in window frames

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

Q5

Using pandas, compute daily active users from the same dataset, defined as the count of unique user IDs per date.

Product Analytics & MetricsData Modeling
Author's notes

Switching from SQL to pandas mid-interview felt a little abrupt.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the dataset structure and the definition of daily active users (unique user IDs per date). Then, use pandas groupby on the date column and apply nunique on the user ID column to compute the metric, ensuring the date column is in datetime format.

Pro tip: Mention that you would validate the result by checking for missing values and considering timezone handling, as Uber operates globally and date boundaries can affect daily active user counts.

1. Clarify requirements and data

Confirm the dataset columns (e.g., user_id, date) and the definition of daily active users. Ask about timezone considerations and whether the date is already in the correct format.

2. Preprocess the data

Convert the date column to datetime if needed, handle missing values, and ensure user IDs are consistent (e.g., no leading/trailing spaces).

3. Compute daily active users

Use df.groupby('date')['user_id'].nunique() to count unique user IDs per date. Alternatively, use drop_duplicates() before grouping for efficiency.

4. Validate and interpret results

Check for anomalies such as zero counts or spikes, and consider plotting the trend to ensure the metric makes sense. Discuss any assumptions made.

Key Points to Mention

  • Use of groupby with nunique for counting unique values
  • Handling datetime conversion and potential timezone issues
  • Efficiency considerations for large datasets (e.g., using drop_duplicates or value_counts)
  • Validation of results (e.g., checking for missing dates or outliers)
  • Definition of 'active user' and potential edge cases (e.g., multiple sessions per day)
  • Scalability and alternative approaches (e.g., using SQL or distributed computing if data is huge)

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