I am having an issue with displaying information properly for reporting.
This is the structure of the raw data in the Table FTB_MHF
Results:
How do you get the results to display this way:
This is the structure of the raw data in the Table FTB_MHF
Code:
DateandTime TagIndex Val
9/1/2013 00:31:15 AM 129 6.2
9/1/2013 00:33:15 AM 130 0
9/1/2013 00:33:15 AM 131 1
9/1/2013 01:33:15 AM 132 0
9/2/2013 01:42:17 AM 129 6.1
9/2/2013 01:42:17 AM 130 0
9/2/2013 10:42:17 AM 131 0
9/2/2013 10:42:17 AM 132 1
SQL:
SELECT DATEADD(hour, DATEDIFF(hour, 0, DateAndTime), 0) AS hour, avg(val) as DHourlyAverage
FROM FTBL_MHF
WHERE (TagIndex IN ('129')) AND (DateAndTime >= CONVERT(DATETIME,
'2013-9-1 00:00:00', 102))
AND (DateAndTime < CONVERT(DATETIME,
'2013-10-1 00:00:00', 102) )
GROUP BY DATEADD(hour, DATEDIFF(hour, 0, DateAndTime), 0)
ORDER BY hour
Results:
Code:
Hour DPHourlyAverage
2013-09-01 00:00:00.000 3.6159331838289899
2013-09-01 01:00:00.000 3.6001444657643638
2013-09-01 02:00:00.000 3.5930899846351751
How do you get the results to display this way:
Code:
Hour of the day
0:00 1:00 2:00 etc...
Date
9/1/2013 3.61 3.60 3.59
9/2/2013
9/3/2013
etc...