← PayPal Interview Insights

PayPal·Data Scientist·Technical Phone Screen·Intermediate

Intermediate
May 2026

Summary

PayPal data scientist interview with a live SQL session on a transactions table. Nothing too crazy but the HAVING clause question tripped me up a bit in the moment.

Questions Asked (3)

Q1

Given a transactions table, write a query that returns each user_id along with the total amount from their successful transactions only.

Product Analytics & MetricsData Modeling
Author's notes

Pretty standard warm-up.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the table schema and the definition of 'successful' transactions. Then write a SQL query that filters for successful transactions, groups by user_id, and sums the amount. Finally, consider edge cases like users with no successful transactions and whether to include them.

Pro tip: Mention that you would confirm the transaction status values (e.g., 'success', 'completed') and consider using a LEFT JOIN from a users table if you need to include all users, even those without successful transactions.

1. Clarify requirements and schema

Ask about the table structure, the column indicating transaction status, and what values represent 'successful'. Confirm whether all users should be included or only those with successful transactions.

2. Filter successful transactions

Use a WHERE clause to select only rows where the status column indicates success (e.g., status = 'success').

3. Aggregate by user

Use GROUP BY user_id and SUM(amount) to calculate the total amount per user.

4. Handle users with no successful transactions

If all users must be included, use a LEFT JOIN from a users table to the aggregated results, and use COALESCE to replace NULL sums with 0.

5. Validate and optimize

Check for edge cases like NULL amounts or duplicate transactions, and consider indexing the status column for performance.

Key Points to Mention

  • Definition of 'successful' transaction (e.g., status = 'success' or 'completed')
  • Use of WHERE clause to filter successful transactions
  • GROUP BY user_id with SUM(amount) for aggregation
  • Handling users with no successful transactions (LEFT JOIN and COALESCE)
  • Potential data quality issues: NULL amounts, duplicate transactions
  • Performance considerations: indexing on status and user_id

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

Q2

Add a classification column to the transactions table that labels each row as 'small', 'medium', or 'large' based on the transaction amount, using a CASE WHEN expression.

Data ModelingProduct Analytics & Metrics
Author's notes

I fumbled the boundary conditions for a second.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the business context and how thresholds for 'small', 'medium', and 'large' are defined (e.g., based on percentiles, fixed amounts, or domain knowledge). Then write a SQL query using a CASE WHEN expression to create the classification column, ensuring the logic is clear and handles edge cases like NULLs or negative amounts.

Pro tip: Mention that thresholds should be data-driven (e.g., using percentiles) and validated with stakeholders to ensure they align with business definitions of transaction size. Also, consider the impact of currency and time on thresholds.

1. Clarify requirements and thresholds

Ask how 'small', 'medium', and 'large' are defined—whether by fixed amounts, percentiles, or business rules—and confirm the expected output format.

2. Explore the data

Check the distribution of transaction amounts, including min, max, and percentiles, to inform threshold selection and identify any data quality issues.

3. Write the CASE WHEN expression

Construct a SQL query that adds a new column using CASE WHEN with the agreed thresholds, ensuring proper ordering of conditions and handling of NULLs.

4. Validate and test

Run the query on a sample, verify the classifications make sense, and check for edge cases like zero or negative amounts.

5. Communicate and iterate

Present the results, explain the rationale for thresholds, and be open to adjusting based on feedback.

Key Points to Mention

  • Use of CASE WHEN for conditional logic
  • Importance of defining thresholds based on business context or data distribution
  • Handling of NULL or negative transaction amounts
  • Consideration of currency conversion if amounts are in multiple currencies
  • Validation of the classification with stakeholders
  • Potential need for dynamic thresholds (e.g., using percentiles) for scalability

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

Q3

Write a query to find users whose total successful transaction amount is greater than 1,000, using a HAVING clause rather than filtering after the fact.

Data ModelingProduct Analytics & Metrics
Author's notes

This is where I blanked for a second.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the schema and defining 'successful transaction' (e.g., status = 'success'). Then write a query that groups by user, sums the transaction amounts, and uses HAVING to filter groups where the sum exceeds 1000, ensuring the filter is applied after aggregation.

Pro tip: Mention that using HAVING is more efficient than filtering in an outer query because it reduces the result set early and leverages the database's aggregation optimizations. Also, consider indexing the status and user_id columns to speed up the query.

1. Clarify requirements and schema

Ask about the table structure, column names, and what constitutes a 'successful' transaction (e.g., status = 'success'). Confirm the threshold and whether it's inclusive.

2. Identify necessary columns and aggregation

Determine that you need user_id, amount, and status. Plan to sum the amount for successful transactions per user.

3. Write the query with GROUP BY and HAVING

Construct a SELECT statement with GROUP BY user_id, SUM(amount) as total, and a HAVING clause filtering total > 1000. Include a WHERE clause to filter successful transactions before aggregation.

4. Optimize and validate

Consider indexes on status and user_id. Explain that HAVING is applied after grouping, so it's efficient. Validate with sample data or edge cases (e.g., users with no successful transactions).

Key Points to Mention

  • Difference between WHERE and HAVING: WHERE filters rows before grouping, HAVING filters groups after aggregation.
  • Importance of filtering successful transactions in WHERE before summing to avoid incorrect totals.
  • Use of GROUP BY user_id to aggregate per user.
  • SUM(amount) with proper handling of NULLs (e.g., COALESCE or ensuring amount is not null).
  • Performance considerations: indexing, avoiding unnecessary columns in SELECT.
  • Potential need to join with a users table if user details are required, but the core query only needs the transactions table.

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