I noticed that Orion is taking the datasets and ordering them descending, taking the top 95 percent and returning the highest number. I'm not sure this is an appropriate way of calculating percentile. The way that I was taught was by Ranked Percentile wherein you order a dataset, separating the set into 100 equal ranks and finding the average of each rank. The 95th rank's average being the 95th percentile, of course. SQL server actually has a built in function for ranking nth'tile results and I've written a quasi-replacement structure for the functions in Orion (with small changes and excluding the max95th)
declare @Percentile as int = 95;
declare @StartDate as datetime = DATEADD(day, -30,getdate());
declare @EndDate as datetime = getdate();
with
I as (Select InterfaceID from Interfaces where FullName like '%Verizon%'),
IT as (select I.InterfaceID, In_Averagebps, Out_Averagebps from InterfaceTraffic inner join I on I.InterfaceID = InterfaceTraffic.InterfaceID where DateTime >= @StartDate AND DateTime <= @EndDate),
IAP as (select NTILE(100) OVER(Partition by interfaceid order by In_Averagebps) AS InPercentile,InterfaceID,In_Averagebps from it),
InAVGpercentile as (select InterfaceID, AVG(In_Averagebps) as InBPS, InPercentile from IAP group by InterfaceID, InPercentile),
OAP as (select NTILE(100) OVER(Partition by interfaceid order by Out_Averagebps) AS OutPercentile,InterfaceID,Out_Averagebps from it),
OutAVGpercentile as (select InterfaceID, AVG(Out_Averagebps) as OutBPS, OutPercentile from OAP group by InterfaceID, OutPercentile)
select * from InAVGpercentile IAP inner join OutAVGpercentile OAP on iap.InterfaceID = oap.InterfaceID and iap.InPercentile = oap.OutPercentile where InPercentile = @Percentile
This code gets all interfaces that has a fullname containing 'Verizon' and returns a table of whichever percentile defined in the @Percentile variable. This code is written to run on 2008 SQL.