Hi,
I have the following SQL (SQL Server 2005) that I use to calculate the total times for each column:
DECLARE @Param1 DATETIME
DECLARE @Param2 DATETIME
DECLARE @Param3 DATETIME
SET @Param1 = '2009-01-01'
SET @Param2 = '2009-09-09'
SELECT SUM(IdleSec) AS TotalIdleSec,
SUM(ProductionSec) AS TotalProductionSec,
SUM(UplineSec) AS TotalUplineSec,
SUM(DownlineSec) AS TotalDownlineSec,
SUM(UserSec) AS TotalUserSec
FROM Job
WHERE (DateTime >= dbo.FormatDateTime(@Param1, 'yyyy-mm-dd'))
AND
(DateTime < dbo.FormatDateTime(@Param2, 'yyyy-mm-dd'))
GO
This returns a table with 1 row for the items above and works great.
I am a little uncertain how I can return the table with the SUM values per day/week/month i.e.
Sum of all values for each DAY between the range of dates.
Sum of all values for each WEEK between the range of dates.
Sum of all values for each MONTH between the range of dates.
I am sure there is a simple way to do this but uncertain myself. I have seen some tutorials that use the DAY(date) command but I tried and cannot seem to get what I need.
I look forward to your excellent help.
Thanks in advanced.
Paul