平均&一起数

时间:2013-11-20 16:07:33

标签: sql-server count average

我以前见过这个问题,但我看到的解决方案对我不起作用。所以我要问我的场景......我一直收到消息130,消息130,等级15,状态1,行2 当我尝试执行查询时,无法对包含聚合或子查询的表达式执行聚合函数。我尝试了几次尝试。这就是我试过的

--Not working
Select Name,
coalesce(COUNT(CASE WHEN CompletedCall IS NULL THEN AVG(CallAttempt) END), 0)
FROM hotwire.calldatabase
GROUP BY Name
ORDER BY Name

--This is also not working
Select Name,
COUNT(CASE WHEN CompletedCall IS NULL THEN AVG(CallAttempt) Else 0 END)
FROM hotwire.calldatabase
GROUP BY Name
ORDER BY Name

--This is also not working
Select Name,
COUNT(CASE WHEN CompletedCall IS NULL THEN AVG(CallAttempt) Else null END)
FROM hotwire.calldatabase
GROUP BY Name
ORDER BY Name

1 个答案:

答案 0 :(得分:1)

根据您的评论:

Select Name, AVG(CallAttemps)
FROM hotwire.calldatabase
WHERE CompletedCall IS NULL
GROUP BY Name
ORDER BY Name