title: SQL: not a single group function .... not a GROUP BY expression
body: <p>I have a number of tables detailing a shop's customers and sales, etc.</p>
  
  <p>I want to find the minimum sale price; i.e. a single result returned by the SQL expression.</p>
  
  <p>In order for the result to make sense I also want to join the customer_sale table with the customer table (so that the customer in question will also have his/her name returned). </p>
  
  <p>Using the following code</p>
  
  <pre><code>SELECT CUST_ORDER.CUST_ID, CUSTOMER.FNAME, CUSTOMER.LNAME, MIN(SALE_PRICE)
  FROM CUST_ORDER
  INNER JOIN CUSTOMER
  ON CUST_ORDER.CUST_ID = CUSTOMER.CUST_ID
  GROUP BY CUST_ORDER.CUST_ID
  HAVING MIN(SALE_PRICE) = (SELECT MIN(SALE_PRICE) FROM CUST_ORDER GROUP BY CUST_ID)
  </code></pre>
  
  <p>in Oracle 11g throws the following error:</p>
  
  <blockquote>
    <p>ERROR at line 1:  ORA-00979: not a GROUP BY expression</p>
  </blockquote>
  
  <p>Which makes sense as it is only to return a single result.</p>
  
  <p>However deleting the GROUP BY clauses causes the dbms to throw the following error:</p>
  
  <pre><code>SELECT CUST_ORDER.CUST_ID, CUSTOMER.FNAME, CUSTOMER.LNAME, MIN(SALE_PRICE)
  FROM CUST_ORDER
  INNER JOIN CUSTOMER
  ON CUST_ORDER.CUST_ID=CUSTOMER.CUST_ID
  HAVING MIN(SALE_PRICE) = (SELECT MIN(SALE_PRICE) FROM CUST_ORDER)
  </code></pre>
  
  <blockquote>
    <p>ERROR at line 1:  ORA-00937: not a single-group group function</p>
  </blockquote>
  
  <p>Is there some additional nesting that I have to do for the statement to execute correctly?</p>