Link to home
Start Free TrialLog in
Avatar of kmccollum
kmccollumFlag for United States of America

asked on

average datediff values with outliers removed

Here is the select statement, I need to be able to get an average of the ResponseTime with the top outlier removed.

DECLARE	@StartDate AS DATETIME,@EndDate AS DATETIME 

SET @StartDate = '12/01/2013'
SET @EndDate = '12/31/2013'

SELECT
	DATEDIFF(mi,EI.DateOfCall,CA.DateOfAssessment) AS 'ResponseTime',
	CA.AssessmentLocation
FROM EncounterInformation AS EI
LEFT JOIN CrisisAssessment AS CA ON EI.CrisisAssessmentID = CA.CrisisAssessmentID
LEFT JOIN EncounterDispositionMapping AS EDM ON EI.EncounterInformationID = EDM.EncounterInformationID
LEFT JOIN DispositionInformation AS DI ON EDM.DispositionInformationID = DI.DispositionInformationID
WHERE DateOfCall BETWEEN @StartDate AND DATEADD(hh,24,@EndDate)
AND (CA.AssessmentLocation LIKE 'Methodist%')
GROUP BY CA.AssessmentLocation

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Shaun Kline
Shaun Kline
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of kmccollum

ASKER

works great thanks