Deleting outliers with mysql using standard deviation

前端 未结 1 1796
鱼传尺愫
鱼传尺愫 2021-01-07 15:59

I use the query below to delete outliers (1.5 times the sd).

DELETE FROM sv_condition_sw 
WHERE snow_mountain > (
    SELECT AVG(snow_mountain)+1.5*STDDEV         


        
相关标签:
1条回答
  • 2021-01-07 16:34

    You can trick MySQL to do this with another subselect

    DELETE FROM sv_condition_sw 
    WHERE snow_mountain > (select * from (SELECT AVG(snow_mountain)+1.5*STDDEV(snow_mountain) 
                                          FROM sv_condition_sw 
                                          WHERE lud='2012-11-28' 
                                          AND res_id=769) x)
     AND lud='2012-11-28' AND res_id=769
    
    0 讨论(0)
提交回复
热议问题