We help IT Professionals succeed at work.
Get Started
Private
Troubleshooting Question

SQL Server Query for detecting, eliminating outliers from data set.

71 Views
Last Modified: 2021-01-01
I am having trouble making a SQL Server query for eliminating outliers in a data set (using median not Std Deviation) and detecting whether the count on either side of the median is even or odd.  For even numbers I will need to use the middle 2 numbers and divide by 2 to be accurate.  Below is the Query I have so far.  I am using SQL Server 2012.

Below code works fine for retrieving quartiles for ALL of the data - with outliers.

Please help!

Select TOP 100 PERCENTILE_CONT(.5) WITHIN GROUP(ORDER BY[" & Metric1 & "] ASC) OVER(PARTITION BY[DieNumber]) As MED" & Metric1 & ", PERCENTILE_CONT(.25) WITHIN GROUP(ORDER BY[" & Metric1 & "] ASC) OVER(PARTITION BY[DieNumber]) As LOWQUART" & Metric1 & ", PERCENTILE_CONT(.75) WITHIN GROUP(ORDER BY[" & Metric1 & "] ASC) OVER(PARTITION BY[DieNumber]) As HIQUART" & Metric1 & " FROM EXTAUTOTABLE WHERE CLD1<>0 And CLD2<>0 And CLD3<>0 And DieNumber=38.11402
Comment
Watch Question
Sr. System Analyst
CERTIFIED EXPERT
Commented:
This problem has been solved!
Unlock 1 Answer and 58 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant

An Experts Exchange subscription includes unlimited access to online courses.

Get Started
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE