Hey, I have an issue with an SQL Query. Lets take this example data
itemID catID attrib1 attrib2
1 1 10 5
2 1 10 7
3 1 5 10
4 2 18 15
I want to return the best item for each category (with attrib1 having priority over attrib2)
Obviously, "SELECT catID, MAX(attrib1), MAX(attrib2) FROM test_table GROUP BY catID" doesn't work since it will return 10 & 10 for the 1st cat.
So is there anyway to tell MySQL to select max value from attrib2 row but only consider the ones where attrib1 is also max value ? i.e return the following data
catID attrib1 attrib2
1 10 7
2 18 15