Solved

average datediff values with outliers removed

Posted on 2014-01-09
2
245 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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

895 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

15 Experts available now in Live!

Get 1:1 Help Now