Alright so I'm sure this is probably something really stupid I haven't thought about yet but what I'm trying to due is sort rows by the MAX AVG. Basically I've got a table of records that relate to photos. These photos are rated by visitors and given a value of 1-5. The table columns in question look like this:
photo_id,rating
1,4
1,3
1,1
2,3
2,4
So I thought something like this would work:
Code:
SELECT photo_id FROM table GROUP BY photo_id ORDER BY MAX(AVG(rating)) DESC
Any help would be greatly appreciated.