32. Customers Who Bought Every Product
Difficulty: Hard · Topics: Joins, Aggregations, Filtering & Selection
An advanced problem: unlock it to open the statement, sample data and editor. Graded on 3 test cases.
Learn the concepts
- left_semi / left_anti · 4 min read. Keep the rows that have a match, or the rows that do not, without duplicating anything.
- join · 5 min read. Combine DataFrames on a key: inner, left, right and full joins, and the duplicate-key fan-out trap.
- groupBy + agg · 4 min read. Aggregate rows per group: counts, sums, averages, and how count(*) differs from count(col).
PySpark functions you'll practise
- groupBy
- agg
- count
- countDistinct
- join
- left_semi
- filter
- select
- distinct
Related problems
- Monthly Retention by Cohort · Hard · Joins, Aggregations, Dates, Null Handling, Filtering & Selection
- Fill Missing Dates (Calendar Spine) · Hard · Joins, Arrays, Aggregations, Dates, Null Handling, Filtering & Selection
- Price Valid at Order Time (Range Join) · Hard · Joins, Null Handling, Filtering & Selection
- Reconcile Two Sources (Full Outer Join) · Hard · Joins, Null Handling, Conditional Logic, Filtering & Selection
- Employees Earning More than Their Manager · Medium · Joins, Filtering & Selection
Browse
Topics: Window Functions · Joins · Aggregations · Pivot, Unpivot & Rollup · Arrays · Null Handling · Conditional Logic · Dates · Filtering & Selection · Strings · Data Lake · Lakehouse · Streaming · Data Prep for AI · Spark Performance
Difficulty: Easy · Medium · Hard · Learn · All problems · dbt practice