title: Order by Sum Field
body: <p>I try to write a SQL-Statement in X++. It should do something like this:</p>
  
  <pre><code>SELECT 
      Table.field1, SUM(Table.field2) AS SumField
  FROM 
      Table
  WHERE 
      Table.FieldX = Something
  GROUP BY 
      Table.Field1
  ORDER BY 
      SumField;
  </code></pre>
  
  <p>The problem i have in X++ is that it orders the records before calculating the sum of them. I know that i could make a <code>While Select</code> in X++ and order them by code, but that is not the way i want to do it.</p>
  
  <p>Can someone tell me how i could handle this?</p>