尝试获取计数结果集的平均值
我有以下 SQL:(bitemp)
SELECT COUNT (*) AS Count
FROM Table T
WHERE (T.Update_time =
(SELECT MAX (B.Update_time )
FROM Table B
WHERE (B.Id = T.Id))
GROUP BY T.Grouping
现在我得到一个包含很多数字的结果集。我想得到这个列表的平均值。目前,我正在将列表导入Excel并使用其平均功能。但是DB2有一个AVG功能,但我没有让它工作。
我尝试了SELECT AVG(COUNT(*))
和SELECT AVG(*) FROM (theQuery)
。
I have the following SQL:(bitemp)
SELECT COUNT (*) AS Count
FROM Table T
WHERE (T.Update_time =
(SELECT MAX (B.Update_time )
FROM Table B
WHERE (B.Id = T.Id))
GROUP BY T.Grouping
now I am getting a resultset with a lot of numbers. I want to get the average of this list. At the moment, I am importing the list into excel and use its average function. But there is a AVG function for DB2, but I did not get it to work.
I tried SELECT AVG(COUNT(*))
and also SELECT AVG(*) FROM (theQuery)
.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您只需将查询作为子查询:
编辑:我认为这应该是相同的:
You just can put your query as a subquery:
Edit: I think this should be the same: