title: How to use partition by and order by in over function?
body: <p>I'm using SQL Server 2008 R2.</p>
  
  <p>I'm trying to write a query showing the following:</p>
  
  <pre><code>select productname, unitprice,categoryid, sum(unitprice) 
  over (partition by categoryid order by unitprice desc) As PriceSum
  from Products
  </code></pre>
  
  <p>I want the outcome to order products by their unit price, while partitioning the products by their categories. I'm getting this error: <code>Incorrect syntax near 'order'.</code>
  What am I doing wrong?</p>