← PayPal Interview Insights

PayPal·Data Scientist·Technical Phone Screen·Intermediate

Intermediate
Jul 2026

Summary

PayPal data scientist interview that leaned pretty hard into SQL fundamentals, specifically around aggregation and filtering. The question felt deceptively simple at first but there were a few layers they wanted you to work through.

Questions Asked (1)

Q1

Write a query to find merchants with a chargeback rate above 0.5% over the last 30 days using HAVING, and explain why you can't use WHERE for this.

Product Analytics & MetricsTechnical Trade-offsData Modeling
Author's notes

I knew the answer but fumbled explaining the WHERE vs HAVING distinction out loud.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the chargeback rate definition and the data model, then write a SQL query that aggregates chargebacks and transactions per merchant over the last 30 days, filters with HAVING on the computed rate, and finally explain that WHERE cannot be used because it filters rows before aggregation, while the rate is an aggregate that only exists after grouping.

Pro tip: Mention that you'd also check for merchants with zero transactions to avoid division by zero, and consider using a subquery or CTE to make the query more readable and maintainable.

1. Clarify definitions and data model

Ask or state assumptions about how chargebacks and transactions are recorded (e.g., separate tables or flags) and confirm the exact formula for chargeback rate (chargebacks / transactions).

2. Write the aggregation query

Use a GROUP BY on merchant_id, compute SUM(chargebacks) and COUNT(transactions) or SUM(transaction_amount) over the last 30 days, and calculate the rate.

3. Apply HAVING filter

Add a HAVING clause that filters groups where the computed chargeback rate exceeds 0.005 (0.5%).

4. Explain WHERE vs HAVING

Explain that WHERE filters individual rows before grouping and cannot reference aggregate functions like SUM or computed rates, while HAVING filters after grouping.

5. Discuss edge cases and optimizations

Mention handling of merchants with zero transactions, date filtering in WHERE for performance, and possibly using a subquery or CTE for clarity.

Key Points to Mention

  • Chargeback rate formula: chargebacks / transactions (or transaction amount)
  • Use of WHERE to filter date range (last 30 days) before aggregation
  • HAVING clause to filter on aggregate chargeback rate > 0.005
  • WHERE cannot contain aggregate functions because it operates on rows before grouping
  • HAVING operates on groups after aggregation
  • Potential need to handle division by zero or merchants with no transactions

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