Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 881361
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T12:14:50+00:00 2026-05-15T12:14:50+00:00

I am trying to eliminate outliers in SQL Server 2008 by standard deviation. I

  • 0

I am trying to eliminate outliers in SQL Server 2008 by standard deviation. I would like only records that contain a value in a specific column within +/- 1 standard deviation of that column’s mean.

How can I accomplish this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T12:14:51+00:00Added an answer on May 15, 2026 at 12:14 pm

    If you are assuming a bell curve distribution of events, then only 68% of values will be within 1 standard deviation away from the mean (95% are covered by 2 standard deviations).

    I would load a variable with the standard deviation of your range (derived using stdev / stdevp sql function) and then select the values that are within the appropriate number of standard deviations.

    declare @stdtest table (colname varchar(20), colvalue int)
    
    insert into @stdtest (colname, colvalue) values ('a', 2)
    insert into @stdtest (colname, colvalue) values ('b', 4)
    insert into @stdtest (colname, colvalue) values ('c', 4)
    insert into @stdtest (colname, colvalue) values ('d', 4)
    insert into @stdtest (colname, colvalue) values ('e', 5)
    insert into @stdtest (colname, colvalue) values ('f', 5)
    insert into @stdtest (colname, colvalue) values ('g', 7)
    insert into @stdtest (colname, colvalue) values ('h', 9)
    
    declare @std decimal
    declare @mean decimal
    declare @lower decimal
    declare @higher decimal
    declare @noofstds int
    
    select @std = STDEV(colvalue), @mean = AVG(colvalue) from @stdtest
    
    --68%
    set @noofstds = 1
    select @lower = @mean - (@noofstds * @std)
    select @higher = @mean + (@noofstds * @std)
    
    select @lower, @higher, * from @stdtest where colvalue between @lower and @higher
    
    --returns rows with a colvalue between 3 and 7 inclusive
    
    --95%
    set @noofstds = 2
    select @lower = @mean - (@noofstds * @std)
    select @higher = @mean + (@noofstds * @std)
    
    select @lower, @higher, * from @stdtest where colvalue between @lower and @higher
    
    --returns rows with a colvalue between 1 and 9 inclusive
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to write a stored procedure in SQL Server that will eliminate some
I'm trying to eliminate the extra bottom margin that both FF and Chrome seem
I am trying to rewrite this messy code, so that I only make one
I am trying to import a svn repository that follows the standard svn convention
I'm trying to eliminate any memory leaks in in my Binary Search tree that
I'm trying to work out some regex that will eliminate all of the special
I am trying to write the code so that i eliminate the duplicate in
Im trying to eliminate two tables from my database. The tables are message_sort_options and
I am trying to eliminate certain strings from a Description field in a table.
I am trying to eliminate replies and retweets in the twitter widget. So far

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.