SQLblog.net


| Comments

Top 5 Sales Reps in Each Division by Net Sales

Here are 2 t-sql queries written for SQL Server. One selects the Top 5 Sales Reps and the other Top 1 Sales Reps in each division by net sales. I am using the Running Totals database that I created in a previous blog. I create a new table RepNetSales and populate fields SalesDivisionName, SalesRepCode, and NetSales.



Select Top 5 Sales Reps in each division using the "Over" clause



The next query gets the Top 1 Sales Rep for each division





comments powered by Disqus