【发布时间】:2017-03-03 08:17:47
【问题描述】:
max(count()) 是不合法的,那么我该如何完成这里所示的贡献计算(以及其他列)
SELECT id,
Avg(time) AS avgSec,
Stdev(time) AS stdevSec,
Count(time) AS cnt,
Avg(time)*Count(time)/max(Count(time)) AS contribution
FROM ...very long and complex query...
【问题讨论】:
-
贡献的公式是什么
-
我不想重复很长很复杂的查询
-
@Prdp
avg * cnt / max(cnt)如sql中所述 -
你有 count(time) 函数,但你没有聚合任何东西,因为你会得到一个计数值。为单个值取最大值是没有意义的。有一个 group by 子句,它可以为您提供预期的结果
标签: sql sql-server