Hi,
I am looking for a SQL query to get the 95th percentile data for the last month on 1 interface. I did some searching on here, but the only working query i could find was per node id see below:
- DECLARE @StartDate DateTime
- DECLARE @EndDate DateTime
-
- SET @StartDate = CAST((ROUND(CAST(GetDate() - 7 AS FLOAT), 0, 1)) as datetime)
- SET @EndDate = GetDate()
-
- SELECT Interfaces.InterfaceId,
- Nodes.Caption AS NodeName,
- Nodes.VendorIcon AS Vendor_Icon,
- Interfaces.Caption AS Interface_Caption,
- Interfaces.InterfaceIcon AS Interface_Icon,
- Maxbps_In95,
- Maxbps_Out95,
- CASE WHEN Maxbps_In95 > Maxbps_Out95 THEN Maxbps_In95 ELSE Maxbps_Out95 END AS Maxbps_95
- FROM dbo.Nodes
- INNER JOIN dbo.Interfaces
- ON (dbo.Nodes.NodeID = dbo.Interfaces.NodeID)
- INNER JOIN
- (
- ----------------
- SELECT InterfaceID, dbo.GetInBps95th(AA.InterfaceID, @StartDate, @EndDate) AS Maxbps_In95
- FROM (
- SELECT DISTINCT A.InterfaceID
- FROM dbo.InterfaceTraffic A
- WHERE A.DateTime >= @StartDate AND A.DateTime <= @EndDate
- ) AS AA
- ---------------------
- ) as RESULT_IN
- ON (dbo.Interfaces.InterfaceID = RESULT_IN.InterfaceID)
- INNER JOIN
- (
- ----------------
- SELECT InterfaceID, dbo.GetOutBps95th(AA.InterfaceID, @StartDate, @EndDate) AS Maxbps_Out95
- FROM (
- SELECT DISTINCT A.InterfaceID
- FROM dbo.InterfaceTraffic A
- WHERE A.DateTime >= @StartDate AND A.DateTime <= @EndDate
- ) AS AA
- ---------------------
- ) as RESULT_OUT
- ON (dbo.Interfaces.InterfaceID = RESULT_OUT.InterfaceID)
- WHERE dbo.Nodes.NodeID = '44'
-
- ORDER BY NodeName, Interface_Caption
But can this query be adjusted so it will only show 1 interface, so sort on interface ID ?
Thanks in advance.