我有一个存储过程,它以10 分钟的间隔计算请求/响应周期的平均持续时间。这很好用,适合我绘制图表的需要。接下来我想做的是计算中值......我怀疑我需要一个子查询,但不知道如何完成这个。
SELECT dateadd(minute, 10 + (datediff(minute, 0, [Started]) / 10) * 10, 0) AS [Time]
,AVG(CASE WHEN Duration is null OR Duration = 0
THEN null ELSE Duration
END) AS [Mean Response Time]
FROM [Application].[Exchange] WITH (NOLOCK)
WHERE [Started] >= '24 Oct 2012' AND [Started] < '25 Oct 2012'
GROUP BY dateadd(minute, 10 + (datediff(minute, 0, [Started]) / 10) * 10, 0)
ORDER BY dateadd(minute, 10 + (datediff(minute, 0, [Started]) / 10) * 10, 0)
谁能建议我可以做到这一点的方法?
1 个回答