SpinTheMic
Pro

Interview practice question

Customers who bought both A and B

Data Engineering · SQL · Intermediate

Find customers who bought both product A and product B, but never product C.

What a strong answer covers

Your AI report card counts how many of these ideas you cover.

  • Group by customer and use conditional counts per product.
  • HAVING count of A > 0 and B > 0 and C = 0.
  • Single pass over the table.
  • Alternatives: INTERSECT and EXCEPT.
  • Avoid multiple self-joins for performance.
Practise this topic

Start without signing up. Sign in free to get an AI report card on your answer.

See all topics