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.