title: What does ORDER BY 5 DESC mean?
body: <pre><code>SELECT Departamentos.Nome_Dep,  
         Funcionarios.Nome AS Funcionario,
         Funcionarios.Salario,
         AVG(Funcionarios.Salario) OVER(PARTITION BY Departamentos.Nome_Dep) "Média por Departamento"
         Salario - AVG(Funcionarios.Salario) OVER(PARTITION BY Departamentos.Nome_Dep) "Diferença de Salário"   FROM Funcionarios
  INNER JOIN Departamentos
      ON Funcionarios.ID_Dep = Departamentos.ID
  ORDER BY 5 DESC
  </code></pre>
  
  <p>The Order By 5 is throwing me off. I've never anything like it. Order By [colunmname] yes, but Order By [number], never seen before. I pulled this off an article. </p>
  
  <p>Note: This is T-SQL.</p>
  
  <p>Source: <a href="http://www.simple-talk.com/sql/learn-sql-server/window-functions-in-sql-server/" rel="noreferrer">Window Functions in SQL Server 2005, 2008, 2012</a></p>