L3 Q9 Advanced Level
Practice Question

Level 3 - Question 9: Window Functions and Analytics

Scenario

Your sales team wants to see each salesperson's performance ranked within their region, along with running totals of sales.

Task

Write a query using window functions (RANK, ROW_NUMBER, SUM OVER) to display salesperson name, region, sales amount, their rank within the region, and a running total of sales by region.

Sample Schema: sales

salesperson region sales_amount
John East 5000
Mary East 7000
Steve West 6000
Anna West 8000
Tom East 4500