Hi All,
I'm trying to filter out my results the top and bottom 2.5 percent records by meeting lengths per contract.
I currently have this query which ID's the top and bottom 2.5% but as a whole and not by Top 2.5 for Contract X and Top 2.5 for Contract Y etc.
, x2 AS
(
SELECT caseref, [contract] FROM
(
SELECT TOP 2.5 PERCENT caseref, [contract] FROM @avgep
ORDER BY DATEDIFF(SECOND, casereceived, CaseEnd)
) AS lowest
UNION ALL
SELECT caseref, [contract] FROM
(
SELECT TOP 2.5 PERCENT caseref , [contract] FROM @avgep
ORDER BY DATEDIFF(SECOND, casereceived, CaseEnd) DESC
) AS highest
)
I imagine a CET is involved but I can't see the wood for the trees at the moment. Any help would be great.