SELECT DATEPART(hour, TimeStamp) AS Hour
, SUM(cast(Amount as money)) AS Sales
WHERE DATEADD(day, 0, DATEDIFF(day, 0, TimeStamp)) = '07/06/2009'
GROUP BY DATEPART(hour, TimeStamp)
ORDER BY hour
I want it to return a 0 for hours where there are no sales..... This works well, but only returns those hours with actual sales.
instead of cte you can populate a temptable with 24 hours and you juts need to join that table
SELECT i AS Hour
, ISNULL( SUM(cast(Amount as money)),0) AS Sales
LEFT Join @tempTable
Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…