TICKIT-05: Seller Ranking by State Using Window Functions
Track: TICKIT Marketplace • Difficulty: Intermediate • Mastery Points: 150 PTS
Business Problem Scenario
Marketplace partner managers need to identify top-performing ticket sellers within each US state to prioritize broker incentives and detect regional market concentration. You must construct a regional ranking query that computes total gross sales per seller and ranks sellers within their respective state jurisdictions.
Engineering Objective
Write a state-level seller ranking query joining gold.fact_sales s to gold.dim_user_seller u on s.seller_sk = u.user_sk. • Expected Columns: u.state, u.userid AS sellerid, sum(s.pricepaid) AS gross, state_rank • Ranking Logic: - Group by u.state, u.userid. - state_rank = RANK() OVER (PARTITION BY u.state ORDER BY sum(s.pricepaid) DESC) - Order by u.state ASC, state_rank ASC. Key Concepts: - Partitioned Window Ranking: Computing ordinal ranking partitioned across business or geographic territories.
Target Table: gold.fact_sales s (seller_sk BIGINT, pricepaid DECIMAL(10,2)), gold.dim_user_seller u (user_sk BIGINT, userid INT, username STRING, city STRING, state STRING)
Verification & Architecture Insights
Partitioned window ranking pinpoints market leadership and power sellers across regional jurisdictions, informing VIP seller commission incentives.