02-23-2024 09:21 PM - last edited on 03-31-2024 10:56 AM by Mercedes_O
I need help with a report that shows sleeptime for systems. Something like this:
SELECT
Name AS ‘Computer Name’,
LastWakeTime,
LastSleepTime,
DATEDIFF(MINUTE, LastWakeTime,
LastSleepTime) AS ‘Minutes Asleep’
FROM
Computers
WHERE
LastSleepTime IS NOT NULL AND
LastWakeTime IS NOT NULL
ORDER BY
‘Minutes Asleep’ DESC;
Suggestions are much appreciated.
Solved! Go to Solution.
02-26-2024 05:04 AM
Try this:
Select Top 1000000 tblassets.AssetID,
tblassets.AssetName,
Max(Case
When tblUptime.EventType = 3 Then tblUptime.EventTime
Else Null
End) As start_sleep,
Max(Case
When tblUptime.EventType = 4 Then tblUptime.EventTime
Else Null
End) As end_sleep,
DateDiff(MINUTE, Max(Case
When tblUptime.EventType = 3 Then tblUptime.EventTime
Else Null
End), Max(Case
When tblUptime.EventType = 4 Then tblUptime.EventTime
Else Null
End)) As [Minutes Asleep]
From tblassets
Inner Join tblUptime On tblassets.AssetID = tblUptime.AssetId
Where tblUptime.EventType In (3, 4)
Group By tblassets.AssetID,
tblassets.AssetName
02-26-2024 05:04 AM
Try this:
Select Top 1000000 tblassets.AssetID,
tblassets.AssetName,
Max(Case
When tblUptime.EventType = 3 Then tblUptime.EventTime
Else Null
End) As start_sleep,
Max(Case
When tblUptime.EventType = 4 Then tblUptime.EventTime
Else Null
End) As end_sleep,
DateDiff(MINUTE, Max(Case
When tblUptime.EventType = 3 Then tblUptime.EventTime
Else Null
End), Max(Case
When tblUptime.EventType = 4 Then tblUptime.EventTime
Else Null
End)) As [Minutes Asleep]
From tblassets
Inner Join tblUptime On tblassets.AssetID = tblUptime.AssetId
Where tblUptime.EventType In (3, 4)
Group By tblassets.AssetID,
tblassets.AssetName
02-26-2024 04:03 AM - edited 02-26-2024 04:04 AM
I have read DB documentation:
You have a chance to solve your task.
02-24-2024 03:50 AM
Hmm, I think there are no such attributes.
Experience Lansweeper with your own data. Sign up now for a 14-day free trial.
Try Now