I have a query that returns the average service time within an hour. But i can't get it to group by the hour because the minutes are being returned.
The code that I currently have is:
The issue is it returns it like:
Sep 9 2010 1:41PM | 25
Sep 9 2010 1:40PM | 75
but it should be
Sep 9 2010 1PM | 50
I have been messing with TRIM and CAST and can't figure out how to remove the minutes from the result to get it to group the averages by the HOUR.
Any ideas?
The code that I currently have is:
Code:
Select convert(varchar,[DateTime]),
SUM(CASE WHEN Status = '1' THEN 1 ELSE 0 END)
/cast(count([Status]) as float)*100 as Uptime
FROM [default_bsd_qa_db].[dbo].[SQA_DASH_SYNT_TRAN_LOG] NoLock
WHERE [DateTime] >= DATEADD(hour,-24,GETDATE())
Group By convert(varchar,[DateTime])
order by cast(convert(varchar,[DateTime]) as datetime) desc
The issue is it returns it like:
Sep 9 2010 1:41PM | 25
Sep 9 2010 1:40PM | 75
but it should be
Sep 9 2010 1PM | 50
I have been messing with TRIM and CAST and can't figure out how to remove the minutes from the result to get it to group the averages by the HOUR.
Any ideas?