title: Understanding the relation between ranking functions, OVER(), GROUP BY?
body: <p>My book says that - </p>
  
  <p><strong>1-</strong> Ranking functions (such as RANK(), DENSE_RANK(), ROW_NUMBER() etc.) need an OVER() clause. </p>
  
  <p>So, the code below is wrong -</p>
  
  <pre><code>select *, RANK()
  from [grant]
  order by Amount desc
  </code></pre>
  
  <p>error - Incorrect syntax near 'RANK', expected 'OVER'.</p>
  
  <p>If I add OVER() after RANK() in above code, i get an error again.
  (Error - The ranking function "RANK" must have an ORDER BY clause.)</p>
  
  <p><strong>2-</strong> Then, my books adds that "Ranking functions need ORDER BY information to appear as an argument in the OVER()". </p>
  
  <pre><code>select *, RANK() OVER(ORDER BY Amount DESC) as GrantRank
  from [grant]
  </code></pre>
  
  <p><strong>My questions are -</strong></p>
  
  <p><strong>1 -</strong> Why do we need to have an OVER() clause with a ranking function ?
  <strong>2 -</strong> Why do we have to remove the order by statement and put it inside the OVER() ?</p>
  
  <p>The book does not explain the logic behind these things ! Please help me to understand it.</p>
  
  <p>Thanks in advance.</p>