I am joining 3 tables with this query
SELECT DISTINCT a.number, c.quantity, c.retail_price 
FROM catalog.product `a`
JOIN catalog.product_variation `b` ON a.id = b.product_id
JOIN catalog.price_regular `c` ON b.id = c.product_variation_id
WHERE c.retail_price BETWEEN 5 AND 6 AND a.status_id = 1
ORDER BY a.number, c.retail_price DESC
and I get this result set
number|quantity|retail_price
---------------------
1007  | 288    | 5.750
1007  | 48     | 5.510
1007  | 576    | 5.460
1007  | 96     | 5.240
1007  | 576    | 5.230
1007  | 144    | 5.120
1006  | 200    | 5.760
1006  | 100    | 5.550
1006  | 200    | 5.040
1006  | 500    | 5.010
What I need is the results to only contain the row with the greatest value in the quantity column and also the row with the greatest retail_price. So my result set I need would look like this
number|quantity|retail_price
---------------------
1006  | 500    | 5.010
1007  | 576    | 5.460
I found a few posts on SO but none were helpful when joining multiple tables. I need a sql statement to get the result set specified above
 
     
    