GROUP BY ignoring an attribute
I normally end up doing something like:
SELECT t1.itemgroup, t1.description, t1.price
FROM table t1,
(SELECT itemgroup, MAX( price ) as price
FROM table
GROUP BY itemgroup) t2
WHERE t1.itemgroup = t2.itemgroup
AND t1.price = t2.price
Use the analytic functions:
SELECT itemgroup, description, price FROM
(select itemgroup, description, price, RANK()
OVER (PARTITION BY itemgroup ORDER BY max(price) DESC) as rank
FROM group by itemgroup,description,price)a
WHERE a.rank = 1
ORDER BY itemgroup;
There's a lot of power in the analytic functions - learning them can help you in a lot of situations.