查询时的多个平均值

时间:2018-01-26 10:18:14

标签: sql sql-server-2008

我正在查询监控工具后端报告的每日可用性的平均值,问题是当我查询我得到多个平均值时。在示例输出和查询下面:

NodeName| DailyNodeAvailability 
Manila  |    81%     
Subic   |    91%
        |    85%
        |    28%
Laguna  |    85%


SELECT Convert(DateTime,Floor(Cast((DateTime) as Float)),0) AS SummaryDate,
Nodes.Caption AS NodeName,
AVG(DailyNodeAvailability.Availability) AS AVERAGE_of_Availability 

FROM 
Nodes INNER JOIN DailyNodeAvailability ON (Nodes.NodeID = DailyNodeAvailability.NodeID)


WHERE 
( DateTime BETWEEN 43094 AND 43125 )

GROUP BY Convert(DateTime,Floor(Cast((DateTime) as Float)),0), 
Nodes.Caption


ORDER BY SummaryDate ASC

1 个答案:

答案 0 :(得分:0)

似乎在"!Convert(DateTime,Floor(Cast((DateTime)as Float)),0),"上进行分组。 可以为节点名称提供多个值。

尝试仅分组 GROUP BY Nodes.Caption