title: SQL ROW_NUMBER gives error
body: <p>I need to order rows in MySQL and assign a number to each row according to that order. <code>ORDER BY</code> is working as intended but not <code>ROW_NUMBER()</code>.</p>
  
  <p>This works:</p>
  
  <pre><code>USE my_database;
  SELECT
      id
      ,volume
      FROM my_table
      ORDER BY volume;
  </code></pre>
  
  <p>This does not work:</p>
  
  <pre><code>USE my_database;
  SELECT
      id
      ,volume
      ,ROW_NUMBER() over(ORDER BY volume)
      FROM my_table
      ORDER BY volume;
  </code></pre>
  
  <p>I get this error message:</p>
  
  <blockquote>
    <p>SELECT  id  ,volume  ,ROW_NUMBER() over(ORDER BY volume)  FROM my_table  ORDER BY volume    Error Code: 1064. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(ORDER BY volume)  FROM my_table  ORDER BY vol' at line 4  0.000 sec</p>
  </blockquote>
  
  <p>What am I doing wrong and how do I make it work?</p>
  
  <p>I also tried <code>RANK()</code> and <code>DENSE_RANK()</code> which gives the same problem.</p>