title: How to update values from a table using a NTILE function?
body: <p><strong>Abstract:</strong> I am trying to rank these stocks factors by top quintile and bottom quintile to build a long/short portfolio.</p>
  
  <p>Table:</p>
  
  <p><a href="https://i.stack.imgur.com/NkHYD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/NkHYD.png" alt="enter image description here"></a></p>
  
  <p>Desired result:</p>
  
  <p><a href="https://i.stack.imgur.com/ifFNz.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ifFNz.png" alt="enter image description here"></a></p>
  
  <p>Code used:</p>
  
  <pre><code>UPDATE MOMENTUM_Quintile 
  SET [2006-12-30] = NTILE(5) OVER (ORDER BY [2006-12-30] DESC)
  FROM MOMENTUM_Quintile
  </code></pre>
  
  <p>Error message:</p>
  
  <blockquote>
    <p>Msg 4108, Level 15, State 1, Line 7<br>
    Windowed functions can only appear in the SELECT or ORDER BY clauses.</p>
  </blockquote>