→ 🚀What's New? Join Us for the Fall Product Launch! Register Now !
‎08-18-2016 06:34 PM
Solved! Go to Solution.
‎08-18-2016 10:55 PM
Select Distinct Top 100000 tblAssets.AssetID,
tblAssets.AssetName,
T1.PowerOnCheck,
T1.PowerOffCheck
From tblAssets
Inner Join tblAssetCustom On tblAssetCustom.AssetID = tblAssets.AssetID
Left Join (Select tblUptime.AssetId,
tblUptime.EventTime,
tblUptime.EventType,
(Select Top 1 DatePart(HOUR, TU1.EventTime) From tblUptime TU1
Where TU1.AssetId = tblUptime.AssetId And TU1.EventTime >= DateAdd(hh, -24,
GetDate()) And DatePart(HOUR, TU1.EventTime) = 5 And TU1.EventType =
1) As PowerOnCheck,
(Select Top 1 DatePart(HOUR, TU2.EventTime) From tblUptime TU2
Where TU2.AssetId = tblUptime.AssetId And TU2.EventTime >= DateAdd(hh, -24,
GetDate()) And DatePart(HOUR, TU2.EventTime) = 7 And TU2.EventType =
2) As PowerOffCheck
From tblUptime
Where tblUptime.EventTime >= DateAdd(hh, -24, GetDate()) And
(tblUptime.EventType = 1 Or tblUptime.EventType = 2)) T1
On T1.AssetId = tblAssets.AssetID
Where tblAssetCustom.State = 1 And tblAssets.Assettype = -1
Order By tblAssets.AssetName
‎08-18-2016 10:55 PM
Select Distinct Top 100000 tblAssets.AssetID,
tblAssets.AssetName,
T1.PowerOnCheck,
T1.PowerOffCheck
From tblAssets
Inner Join tblAssetCustom On tblAssetCustom.AssetID = tblAssets.AssetID
Left Join (Select tblUptime.AssetId,
tblUptime.EventTime,
tblUptime.EventType,
(Select Top 1 DatePart(HOUR, TU1.EventTime) From tblUptime TU1
Where TU1.AssetId = tblUptime.AssetId And TU1.EventTime >= DateAdd(hh, -24,
GetDate()) And DatePart(HOUR, TU1.EventTime) = 5 And TU1.EventType =
1) As PowerOnCheck,
(Select Top 1 DatePart(HOUR, TU2.EventTime) From tblUptime TU2
Where TU2.AssetId = tblUptime.AssetId And TU2.EventTime >= DateAdd(hh, -24,
GetDate()) And DatePart(HOUR, TU2.EventTime) = 7 And TU2.EventType =
2) As PowerOffCheck
From tblUptime
Where tblUptime.EventTime >= DateAdd(hh, -24, GetDate()) And
(tblUptime.EventType = 1 Or tblUptime.EventType = 2)) T1
On T1.AssetId = tblAssets.AssetID
Where tblAssetCustom.State = 1 And tblAssets.Assettype = -1
Order By tblAssets.AssetName
Experience Lansweeper with your own data. Sign up now for a 14-day free trial.
Try Now