title: Temporary variable assignment / increment in select query
body: <p>In MySQL you are allowed to do something like this</p>
  
  <pre><code>SELECT @n := @n + 1 n,
         first_name, 
         last_name
    FROM table1, (SELECT @n := 0) m
   ORDER BY first_name, last_name
  </code></pre>
  
  <p>*(Codeblock was originally taken from <a href="https://stackoverflow.com/a/16555527/2279200">https://stackoverflow.com/a/16555527/2279200</a>)</p>
  
  <p>Is there any equivalent approach in Oracle or SQL Server</p>
  
  <p>Note: </p>
  
  <ol>
  <li><p>Something similar can be done with <code>update</code> in SQL Server, but I am asking if it can be done with select.</p></li>
  <li><p>Using <code>row_number</code> is not an option, since I want to handle how the values of @n are changing.</p></li>
  <li><p>I am aware that SQL Server disallows having both temp variables and table column in select statement.</p></li>
  </ol>