title: Find annual MAX and MIN per employee using quarterly data
body: <p>I'm working from a database in SQL server which contains quarterly employee sales quota in USD. The table I'm retrieving my information from contains the following columns:</p>
  
  <ul>
  <li>SalesQuotaKey (PK, int, NOT NULL)</li>
  <li>Employee Key (FK, int, NOT NULL)</li>
  <li>DateKey (FK, int, NOT NULL)</li>
  <li>Calendar Year (smallint, NOT NULL)</li>
  <li>Calendar Quarter (tinyint, NOT NULL)</li>
  <li>SalesAmountQuota (money, NOT NULL)</li>
  <li>Date (datetime, NOT NULL)</li>
  </ul>
  
  <p>The column containing the SalesAmountQuota shows the quarterly quota.</p>
  
  <p>Sample data and expected result for one EmployeeID stated below
      Employeekey Datekey         Year   quarter  SalesAmountquota  Date</p>
  
  <pre><code>1   272 20101229    2010    4   28000,00    2010-12-29 00:00:00.000
  11  272 20110331    2011    1   7000,00 2011-03-31 00:00:00.000
  21  272 20110701    2011    3   91000,00    2011-07-01 00:00:00.000
  31  272 20110929    2011    3   140000,00   2011-09-29 00:00:00.000
  41  272 20111229    2011    4   70000,00    2011-12-29 00:00:00.000
  54  272 20120330    2012    1   154000,00   2012-03-30 00:00:00.000
  68  272 20120630    2012    2   107000,00   2012-06-30 00:00:00.000
  82  272 20120928    2012    3   58000,00    2012-09-28 00:00:00.000
  96  272 20121228    2012    4   263000,00   2012-12-28 00:00:00.000
  113 272 20130330    2013    1   116000,00   2013-03-30 00:00:00.000
  130 272 20130630    2013    2   84000,00    2013-06-30 00:00:00.000
  147 272 20130929    2013    3   187000,00   2013-09-29 00:00:00.000
  </code></pre>
  
  <p>emp key MaxSalesQuota   MinSalesquota</p>
  
  <pre><code> 272    582000,00   28000,00
  </code></pre>
  
  <p>However, I want to create an overview which shows both the <em>highest ever annual</em> sales quotum and <em>lowest ever annual</em> sales quotum ever for each EmployeeID (only for the years where the all four quarterly quota contain a value)  </p>
  
  <p>I managed to find the highest and lowest ever quarterly sales quotum per employee using the below statement but I am having trouble to create a statement that retrieves the highest and lowest annual quotum per employee.
  Anyone who can help me out? Your help is much appreciated. </p>
  
  <pre><code>SELECT A.EmployeeKey,
         MAX(A.SalesAmountQuota) as MaxQuota,
         Min(B.SalesAmountQuota) as MinQuota 
  FROM FactSalesQuota A, FactSalesQuota B
  WHERE A.SalesAmountQuota = B.SalesAmountQuota
  GROUP BY A.EmployeeKey
  ORDER BY A.EmployeeKey
  </code></pre>