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 7814227
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T05:08:05+00:00 2026-06-02T05:08:05+00:00

I’m working on a problem of finding mean processing times. I’m trying to eliminate

  • 0

I’m working on a problem of finding mean processing times. I’m trying to eliminate outlier data by essentially performing a average on only the best 80% of the data.

I am struggling trying to adapt existing Top N per Group solutions to perform averaging per group. Using SQL Server 2008.

Here is a sample of what the table looks like:

    OpID  |  ProcessMin  |  Datestamp
    2     |  234         |  2012-01-26 09:07:29.000
    2     |  222         |  2012-01-26 10:04:22.000
    3     |  127         |  2012-01-26 11:09:51.000
    3     |  134         |  2012-01-26 05:02:11.000
    3     |  566         |  2012-01-26 05:27:31.000
    4     |  234         |  2012-01-26 04:08:41.000

I want it to take the lowest 80% of the ProcessMin for each OpID, and take the average of that array. Any help would be appreciated!

* UPDATE *

Given the following table:

OpID  ProcessMin   Datestamp
602   33           46:54.0
602   36           38:59.0
602   37           18:45.0
602   39           22:01.0
602   41           36:43.0
602   42           33:00.0
602   49           03:48.0
602   51           22:08.0
602   69           39:15.0
602   105          59:56.0
603   13           34:07.0
603   18           07:17.0
603   31           57:07.0
603   39           01:52.0
603   39           01:02.0
603   40           40:10.0
603   46           22:56.0
603   47           11:03.0
603   48           40:13.0
603   56           25:01.0

I would expect this output:

OptID   ProcessMin
602     41
603     34.125

Notice that since there are 10 data points for each OpID, it would only average the lowest 8 values (80%).

  • 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-06-02T05:08:10+00:00Added an answer on June 2, 2026 at 5:08 am

    You can use ntile

    select OpID,
           avg(ProcessMin) as ProcessMin
    from
      (
        select OpID,
               ProcessMin,
               ntile(5) over(partition by OpID order by ProcessMin) as nt
        from YourTable
      ) as T
    where nt <= 4
    group by OpID
    

    SE-Data

    If ProcessMin is an integer you can do avg(cast(ProcessMin as float)) as ProcessMin to get the decimal average value.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I want use html5's new tag to play a wav file (currently only supported
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am currently running into a problem where an element is coming back from
I want to construct a data frame in an Rcpp function, but when I

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.