title: Find top sales people
body: <p>I want to find Top and botton 10% sales people.How can I do this using SQL 2005 or 2008?</p>
  
  <pre><code>DECLARE @Sales TABLE 
  (
  SalesPersonID varchar(10), TotalSales int
  )
  
  
  INSERT @Sales
  SELECT 1, 200 UNION ALL
  SELECT 2, 300 UNION ALL
  SELECT 7, 300 UNION ALL
  SELECT 4, 100 UNION ALL
  SELECT 5, 600 UNION ALL
  SELECT 5, 600 UNION ALL
  SELECT 2, 200 UNION ALL
  SELECT 5, 620 UNION ALL
  SELECT 4, 611 UNION ALL
  SELECT 3, 650 UNION ALL
  SELECT 7, 611 UNION ALL
  SELECT 9, 650 UNION ALL
  SELECT 3, 555 UNION ALL
  SELECT 9, 755 UNION ALL
  SELECT 8, 650 UNION ALL
  SELECT 3, 620 UNION ALL
  SELECT 5, 633 UNION ALL
  SELECT 6, 720 
  GO
  </code></pre>
  
  <p>Also If i add department, then how can i write same query to find top 10% and bottom 10% in each department? I please want both queries.</p>