title: SELECT TOP record for each year
body: <p>I am trying to recap on my sql skill, now I am trying to run a simple query on northwinddb to show me the top customer for each year, but as soon as I use the TOP function only 1 record gets display no matter on what I partition by, This is my T-SQL code</p>
  
  <pre><code>SELECT DISTINCT TOP 1 C.CompanyName
  , YEAR(O.OrderDate) AS Year
  , SUM(Quantity) OVER(PARTITION BY C.CompanyName, YEAR(O.OrderDate)) AS Total
  FROM Customers C JOIN Orders O
      ON C.CustomerID = O.CustomerID JOIN [Order Details] OD
      ON O.OrderID = OD.OrderID
  </code></pre>