title: How to use MAX() and COUNT() in Oracle SQL?
body: <p>Suppose i have the following table:</p>
  
  <blockquote>
    <p>transactions(id, type)</p>
    
    <p><code>id</code> - id of the costumer (integer 1...n)<br> <code>type</code> - what they
    bought (like "apple")</p>
  </blockquote>
  
  <p>Note that each row refers to buying only ONE of the given type.</p>
  
  <p>How can I select the id of the costumer who bought the most of a given type (like apple)?</p>
  
  <p>I tried to <code>COUNT()</code> the rows where type = apple for each id, but I cannot use <code>MAX()</code> in that query to select only the first ID.</p>
  
  <p>Thanks </p>