I have a query that I don\'t really know how to begin with. I\'m hoping someone can help me out with it. I will start by explaining the table
I have a device table with
Something like this might get you started.
select SUM(datediff(second, Begin_dt, End_dt)) as seconds_online
,DATEPART(hour, Begin_dt) as [hour]
from table
where device_status in (1,4,5)
group by DATEPART(hour, Begin_dt)
To format the result you may want to follow this question:
SQL - Seconds to Day, Hour, Minute, Second