title: Cannot reference subquery column by outer order by
body: <p>The <code>ORDER BY</code> clause below is causing an error. How can I reference the TotalPrice column in <code>ORDER BY</code> clause: </p>
  
  <pre><code>SELECT * FROM
  (
  
  SELECT O.OrderID,
         (SELECT SUM(SubTotal) FROM DB_OrderDetails OD WHERE OD.OrderID = O.OrderID) AS TotalPrice,
         ROW_NUMBER() OVER (ORDER BY TotalPrice) AS RowNum
  
      FROM DB_Orders O
  
  ) Orders
  </code></pre>