Re: max function
Posted by:
Rick James
Date: October 06, 2009 08:57PM
SELECT *
FROM
( SELECT product,
price
FROM Products
ORDER BY price DESC
) AS x
GROUP BY product;
This should get the top price for each product.
It uses the "feature" that GROUP BY picks the first row of each group. In this case, that is the highest priced item (because of ORDER BY price DESC). If two have the same price, it will pick one at 'random'.
Subject
Written By
Posted
Re: max function
October 06, 2009 08:57PM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.