我想从计数结果中得到平均值。

SELECT labelname AS Record_Labels, COUNT(title) AS Number_of_CDs_Released FROM CD
JOIN RecordLabel ON labelname = released_by
GROUP BY labelname;

我试过这样做:AVG(COUNT(title)),但没有成功。有人能帮我吗?

最佳答案

可以使用嵌套查询执行以下操作:

select avg(Number_of_CDs_Released) from
(SELECT labelname AS Record_Labels, COUNT(title) AS Number_of_CDs_Released FROM CD
JOIN RecordLabel ON labelname = released_by
GROUP BY labelname) nested;

10-07 21:36