title: Select max from calculated column alongside other columns
body: <p>I have a table that has columns ID, FIELD1, FIELD2, all of type NUMBER.</p>
  
  <p>I want to find the MAX of a function on FIELD1 and FIELD2, and display that alongside the ID.</p>
  
  <p>I try</p>
  
  <pre><code>SELECT ID, MAX(SQRT(FIELD1 + FIELD2)) AS CALC
  FROM TABLE;
  </code></pre>
  
  <p>But it returns <code>ORA-00937: not a single-group group function</code>.</p>
  
  <p>I tried the solutions in <a href="https://stackoverflow.com/questions/18886155/not-a-single-group-group-function-with-max-in-select#">this thread</a>, but they have their own errors.</p>
  
  <pre><code>SELECT * FROM (
      SELECT ID, SQRT(FIELD1 + FIELD2) AS CALC,
      RANK() OVER (ORDER BY CALC DESC) AS RANKING
      FROM TABLE
  )
  WHERE RANKING = 1;
  </code></pre>
  
  <p>gives the error</p>
  
  <pre><code>ORA-06553: PLS-306: wrong number or types of arguments in call to
  'OGC_CALC'
  </code></pre>
  
  <p>and so does</p>
  
  <pre><code>SELECT ID, SQRT(FIELD1 + FIELD2) AS CALC
  FROM TABLE
  WHERE CALC = (
      SELECT MAX(CALC)
      FROM TABLE
  );
  </code></pre>
  
  <p>Using Oracle Database 11g Express Edition Release 11.2.0.2.0.</p>
  
  <p>How can I get this to work? Thanks.</p>