MySQL: Is it possible to compute MAX( AVG (field) )?
Posted
by Brad
on Stack Overflow
See other posts from Stack Overflow
or by Brad
Published on 2010-04-12T23:31:39Z
Indexed on
2010/04/12
23:32 UTC
Read the original article
Hit count: 268
My current query reads:
SELECT entry_id, user_id, cat_id, AVG( rating ) as avg_rate
FROM entry_rate
WHERE 1
GROUP BY entry_id
cat_id relates to different categories: 1, 2, 3 or 4
Is there a way I can find the maximum average for each user in each category without setting up an additional table? The return could potentially be 4 maximum avg_rate for each user_id
Visit the link below for example:
http://lh5.ggpht.com/_rvDQuhTddnc/S8Os_77qR9I/AAAAAAAAA2M/IPmzNeYjfCA/s800/table1.jpg
© Stack Overflow or respective owner