Avatar of kmccollum
kmccollum
Flag 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

Microsoft SQL Server 2005Microsoft SQL Server

Avatar of undefined
Last Comment
kmccollum

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Shaun Kline

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
kmccollum

ASKER
works great thanks
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes