Ok, before I open a case I thought I would ask this question here. I am creating a report with a chart and table for max utilization during business hours over several days. I am sure my query may not be optimal but and my sql is very rusty. I have narrowed it down for testing to just one day between 6am and 6pm. The query works great but the chart I am creating with it shows the time between midnight and 11am rather than the 06:00 - 18:00 times in the query. Any suggestions would be greatly appreciated.
SELECT Nodes.Caption AS NodeName,
Interfaces.Caption AS Interface_Caption,
Case InBandwidth
When 0 Then 0
Else (In_Maxbps/inbandwidth) * 100
End AS Recv_Percent_Utilization,
InterfaceTraffic.DateTime AS Date,
Convert(Char,DateTime,108) As Time_of_Day,
Case OutBandwidth
When 0 Then 0
Else (Out_Maxbps/OutBandwidth) * 100
End AS Xmit_Percent_Utilization,
InterfaceTraffic.DateTime AS Date,
Convert(Char,DateTime,108) AS Time_of_Day
FROM
(Nodes INNER JOIN Interfaces ON (Nodes.NodeID = Interfaces.NodeID)) INNER JOIN InterfaceTraffic ON (Interfaces.InterfaceID = InterfaceTraffic.InterfaceID)
WHERE
nodes.city = 'anniston' and nodes.n_main=1 and DATEPART(month, interfacetraffic.datetime) =1 AND (datepart(day,interfacetraffic.datetime) between 5 AND 5) AND datepart(year,interfacetraffic.datetime)=2015 AND (datepart(hour,interfacetraffic.datetime)between 6 AND 18) and
(interfaces.caption like 'serial%')
AND
((
(Case OutBandwidth
When 0 Then 0
Else (Out_Maxbps/OutBandwidth) * 100
End >= 0)
)
OR
(
(Case InBandwidth
When 0 Then 0
Else (In_Maxbps/InBandwidth) * 100
End >= 0)
))
order by 4 asc, 5 asc
Thanks,
Brad Walker