SQL Tutorial: Identifying 'Power Purchasers' Using Two-Level GROUP BY Logic
A DEV Community article breaks down a hard-rated SQL interview problem tagged to Apple, focused on identifying 'power purchasers' in an app store dataset. A power purchaser is defined as a customer who made at least three in-app purchases in each of April, May, and June 2023. The solution requires two rounds of grouping: first by user and month to count qualifying months, then by user to confirm all three months are met. A HAVING clause is used instead of WHERE, since the filter depends on aggregated counts rather than raw row values. The final query joins results back to the users and purchases tables to return each qualifying user's ID, email, and total spending for the period.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.


Discussion (0)
Log in to join the discussion and vote.
Log in