Can anyone help me to resolve this query to get an output with duration the node is down i.e DuratioDown instead of DaysDown????
Here is the Query:
SELECT DATEDIFF(d, T1.DownTime, CURRENT_TIMESTAMP) AS DaysDown, Nodes.Caption, Nodes.IP_Address, T1.DownTime, Nodes.Site, Nodes.Location
FROM
(SELECT
Max(EventTime) AS DownTime, NetObjectID, NetworkNode
FROM Events
WHERE
(EventType = 1) AND (NetObjectType ='N')
GROUP BY NetObjectID, NetworkNode
) AS T1 INNER JOIN Nodes ON T1.NetworkNode = Nodes.NodeID
WHERE
(Nodes.Status = '2' OR Nodes.Status = '0')
ORDER BY DaysDown DESC, Nodes.Caption ASC, T1.DownTime DESC
*****Note****
You may need to remove Nodes.Site because that is a custom property.
Here is a sample of the report:
28 | LXK13E8C6 | 5/13/2011 3:04:53 PM | Tower | ||
19 | xxx.xx.x.xxx | 5/22/2011 9:11:38 AM | Tower | ||
19 | KYKEWESPR2-VIP | 5/22/2011 8:18:25 AM | COT | ||
16 | DTSFKSD01 | 5/25/2011 10:51:40 AM | 33R | ||
15 | NPI43E1F2 | 5/26/2011 10:04:36 AM | |||
10 | HPD110FG0461 | 5/31/2011 4:05:08 PM | |||
10 | HPO110D90461 | 5/31/2011 4:00:56 PM | |||
10 | NPI2E4651 | 5/31/2011 4:29:02 PM | Tower | HP Color LaserJet CP2025dn | |
8 | xxx.xxx.xx.xxx | 6/2/2011 9:50:49 PM | Harlan DVR | ||
8 | Aficio MP 8000 | 6/2/2011 2:01:09 PM | |||
8 | COR/PP & CFC GARRAD CO. 50QLXX5 | 6/2/2011 9:50:26 PM | Danville DVR | 152 PLEASANT RETREAT PLAZA LANCASTER, KY |