Using a CTE, rank employees by salary within their department (highest first). Then, join with sales data to aggregate total sales per employee. Finally, use window functions to identify the top-ranked employee per department along with their aggregated sales. Include employees with no sales (show 0).
Sign in to solve
Start Solving