在我的sql查询中,我计算一天中每个小时的订单数量。我的查询如下所示:
SELECT COUNT(dbo.Uputa.ID),{ fn HOUR(dbo.Orders.Date) } AS Hour
FROM Orders
WHERE dbo.Orders.Date BETWEEN 2011-05-01 AND 2011-05-26
GROUP BY { fn HOUR(dbo.Orders.Date) }
ORDER BY Hour
My problem is that the query returns only existing Hours in dbo.Orders.Date.
For example:
Number Hour
12 3
12 5
我想像这样返回所有时间:
Number Hour
0 0
0 1
0 2
12 3
0 4
12 5
...
0 23
有人知道如何做到这一点吗?