title: How to find the product with the maximum discount using SQL on HackerRank
body: <p>I'm having trouble with an SQL problem on <a href="https://en.wikipedia.org/wiki/HackerRank" rel="nofollow noreferrer">HackerRank</a> (so no rank or window functions):</p>
  <pre><code>     Product_Id  Product_Name   Category  Price   Discount  Available
       1           P-1            C-5        720     10       1
       2           P-2            C-1        935     17       1
       3           P-3            C-2        588     19       1
       4           P-4            C-4        619     5        0
       5           P-5            C-1        803     16       1
  </code></pre>
  <p>I want to know which product is on the maximum discount for each category. In the case of multiple products having the same maximum discount within a category, print the product with the minimum product_id.</p>
  <p>Sample Output</p>
  <pre><code>    C-1 2 17
      C-2 3 19
      C-4 4 5
      C-5 1 10
  </code></pre>
  <p>In <em><a href="http://sqlfiddle.com/#!18/1a492d" rel="nofollow noreferrer">this SQL Fiddle</a></em>, I've put here what I've tried so far. I'm not sure how to get the product for the maximum discount. Also, how can I handle if there are multiple products with the same maximum discount?</p>