我需要平均销售额。但是当我尝试执行我的查询时,我得到了这个错误(再次:() 消息130,第15级,状态1,第2行 无法对包含聚合或子查询的表达式执行聚合函数。
以下是我试图运行的内容
Select SalesMan,
COUNT(CASE WHEN SalesMan IN ('Richard', 'Jose', 'Mendez') AND supCheck IS NOT NULL AND ordered IS NOT NULL THEN AVG(price1+price2+price3+price4+price5) ELSE NULL END)
FROM PixieStick.dbo.SalesInfo
GROUP BY SalesMan
ORDER BY SalesMan ASC
答案 0 :(得分:0)
感谢@T I
Select SalesMan,
AVG(CASE WHEN SalesMan IN ('Richard', 'Jose', 'Mendez') AND supCheck IS NOT NULL AND ordered IS NOT NULL THEN price1+price2+price3+price4+price5 ELSE NULL END)
FROM PixieStick.dbo.SalesInfo
GROUP BY SalesMan
ORDER BY SalesMan ASC