Groups down outage with duration of Hours/Min

Hello Team,

Getting an error saying SubSequent query not supported. Any help from our team.

SELECT c.Name
	,StartTime.EventTime AS DownTime
	,(
		SELECT TOP 1 EndTime.EventTime
		FROM Orion.Events AS Endtime
		INNER JOIN Orion.Container c ON endtime.NetObjectID = c.ContainerID
		INNER JOIN Orion.Events AS StartTime ON starttime.NetObjectID = c.ContainerID
		WHERE EndTime.EventTime > StartTime.EventTime
			AND EndTime.NetObjectID = StartTime.NetObjectID
			AND EndTime.EventType = 52
			AND EndTime.NetObjectType = 'C'
		ORDER BY EndTime.EventTime
		) AS UpTime
	,MINUTEDIFF(StartTime.EventTime, (
			SELECT TOP 1 EndTime.EventTime
			FROM Orion.Events AS Endtime
			INNER JOIN Orion.Container c ON endtime.NetObjectID = c.ContainerID
			INNER JOIN Orion.Events AS StartTime ON starttime.NetObjectID = c.ContainerID
			WHERE EndTime.EventTime > StartTime.EventTime
				AND EndTime.NetObjectID = StartTime.NetObjectID
				AND EndTime.EventType = 52
				AND EndTime.NetObjectType = 'C'
			ORDER BY EndTime.EventTime
			)) AS MinutesDown
FROM Orion.Events starttime
INNER JOIN Orion.Container c ON starttime.NetObjectID = c.ContainerID
WHERE (StartTime.EventType = 50)
	AND (
		StartTime.EventTime BETWEEN DATETRUNC('day', GETDATE())
			AND DATETRUNC('day', ADDDAY(10, GETDATE()))
		)
ORDER BY StartTime.EventTime DESC


Parents Reply Children
No Data