Quantcast
Channel: THWACK: Unanswered Discussions - Report Lab
Viewing all articles
Browse latest Browse all 813

Report SQL help

$
0
0

All.. I am new to SQL writing and need help with this custom sql that was already written in report writer.

 

Request - To report on sites for the following 30 days where we filter out hours 11pm to 6am mon - friday and all weekends (sat/sun) - so we are only reporting on business hours.

 

Sql is below

 

 

SELECT Nodes.NodeID, Nodes.CustomerID as [Site Number], Nodes.CustomerName AS [Site Name], AVG(FMC_AvailabilityByDays.Availability)
                  AS [Average Availability], ISNULL(FMC_OutagesLast30Days.Outages, 0) AS '# Outages',
                  ISNULL(FMC_OutageDurationLast30Days.TotalOutageDuration, 0) AS 'Total Outage Duration'
FROM     Nodes INNER JOIN
                  FMC_AvailabilityByDays ON Nodes.NodeID = FMC_AvailabilityByDays.NodeID LEFT OUTER JOIN
                  FMC_OutageDurationLast30Days ON Nodes.NodeID = FMC_OutageDurationLast30Days.nodeid LEFT OUTER JOIN
                  FMC_OutagesLast30Days ON Nodes.NodeID = FMC_OutagesLast30Days.NodeID
WHERE (FMC_AvailabilityByDays.datetime BETWEEN DATEADD(day, - 30, DateDiff(dd, 0, getdate())) AND DATEADD(day, - 1, DateDiff(dd, 0, getdate()))) AND
                  ((Nodes.LocationType like '%Clinic%') OR (Nodes.LocationType = 'Dialysis Location')) AND (Nodes.DeviceType = 'Router') AND (Nodes.Application IS NULL) AND
                  (Nodes.UnManaged = 0)

GROUP BY Nodes.CustomerName, Nodes.CustomerID, Nodes.NodeID, FMC_OutageDurationLast30Days.TotalOutageDuration, FMC_OutagesLast30Days.Outages

ORDER BY [Average Availability]


Viewing all articles
Browse latest Browse all 813

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>