我如何获得使用此查询发现的以下值的平均值:
SELECT Title, GrossProfit FROM Cinema
ORDER BY GrossProfit DESC
LIMIT 3
我尝试使用 GROUP BY,但它给了我一个错误,我是新手,所以希望得到一些帮助!
谢谢
最佳答案
据推测,您想要的是 grossprofit
的平均值,而不是 title
。如果是这样,使用子查询:
SELECT AVG(GrossProfit)
from (SELECT Title, GrossProfit
FROM Cinema
ORDER BY GrossProfit DESC
LIMIT 3
) c;
关于mysql - 所选值的 SQL 平均值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48520390/