Solved

average datediff values with outliers removed

Posted on 2014-01-09
2
243 Views
Last Modified: 2014-01-09
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

0
Comment
Question by:kmccollum
2 Comments
 
LVL 26

Accepted Solution

by:
Shaun Kline earned 500 total points
ID: 39768593
Sounds like a good case for using the EXCEPT clause. Basically you include a second query, similar to your original query, that will return the MAX date difference per Location.
0
 

Author Closing Comment

by:kmccollum
ID: 39768737
works great thanks
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Viewers will learn how the fundamental information of how to create a table.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now