Problems / QUALIFY: First Purchase / Editorial
ROW_NUMBER() OVER (PARTITION BY customer_id ORDER BY purchase_time)
QUALIFY
WHERE
HAVING
withColumn
filter
SQL's filtering clauses map one-to-one onto its evaluation phases: WHERE → rows, HAVING → groups, QUALIFY → window results. Deduplication-by-recency ("latest row per key", "first event per user") is such a common operation that this phase-aware clause pays for itself immediately — and knowing *why* it exists (window functions evaluate late) is the same knowledge that explains why WHERE rn = 1 fails without it.
WHERE rn = 1
Solve QUALIFY: First Purchase yourself →