SSRS图表以小时显示总计

时间:2011-10-02 07:49:16

标签: reporting-services

我有以下数据:

+--------------------------+---------------+
|        Date Time         | Number of Hit |
+--------------------------+---------------+
| 2011-10-03 13:01:00 + 10 |             2 |
| 2011-10-03 13:05:00 + 10 |             3 |
| 2011-10-03 14:01:00 + 10 |             4 |
| 2011-10-03 14:04:00 + 10 |             5 |
+--------------------------+---------------+

我想使用Reporting Services创建一个图表,显示:

13 - 5
14 - 9

基本上我想按小时显示点击次数。有人可以告诉我该怎么做吗?

1 个答案:

答案 0 :(得分:0)

取决于您有什么其他要求,但可能最容易在SQL查询中按小时分组:

SELECT
   DATEADD(hour, DATEDIFF(hour, 0, myDateTimeColumn, 0)) AS TimeByHour,
   SUM(hitCount) as Hits
FROM
   WebRecordsTable
GROUP BY DATEADD(hour, DATEDIFF(hour, 0, myDateTimeColumn, 0))

然后在SSRS中创建一个图表并将Hits字段拖到Values部分。