title: SQL - When would an empty OVER clause be used?
body: <p>I'm analyzing some code that utilizes empty OVER clauses in the contest of Count().</p>
  
  <p>Example:</p>
  
  <pre><code>SELECT 
          ROW_NUMBER() OVER (ORDER BY Priority DESC) AS RowID,
          CAST((COUNT(*) OVER() / @pagesize) AS Int) AS TotalPages,
  </code></pre>
  
  <p>I'm trying to understand why the empty OVER clause is being used here.</p>
  
  <p>There are other standard select elements below those two lines I listed above, and when I remove the empty OVER clause from the second the TotalPages line, I get errors like this:</p>
  
  <pre><code>Column 'TableA.Priority' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.
  </code></pre>
  
  <p>As soon as I put the OVER() back, the error is gone.</p>
  
  <p>My understanding of the OVER clause is very limited... I feel Like I understand what's going on in the RowID line... but the TotalPages line just baffles me.</p>