How do I exclude outliers from an aggregate query?

后端 未结 4 1802
情书的邮戳
情书的邮戳 2021-02-10 09:30

I\'m creating a report comparing total time and volume across units. Here a simplification of the query I\'m using at the moment:

SELECT  m.Unit,
        COUNT(         


        
4条回答
  •  太阳男子
    2021-02-10 10:03

    One way would be to exclude the outliers with a not in clause:

    where  m.ID not in 
           (
           select  top 5 percent ID
           from    main_table 
           order by 
                   TimeInMinutes desc
           )
    

    And another not in clause for the bottom five percent.

提交回复
热议问题