Pharma Commercial Analytics Path · Mission 14 of 25Hard

Top product per territory — RANK PARTITION

RANK() OVER (PARTITION BY territory ORDER BY rx_count DESC) — find the top-N within a group. The 'leader-by-segment' pattern is the most common analytical question in pharma commercial: which product wins each territory? Tie handling matters here — the seed has multiple territories where two products tie at #1.

The Brief

You'll practice

RANK windowPARTITION BY territoryTie handling