使用标准偏差使用mysql删除异常值 [英] Deleting outliers with mysql using standard deviation
本文介绍了使用标准偏差使用mysql删除异常值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用下面的查询删除异常值(标准误差的1.5倍).
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(snow_mountain)
FROM sv_condition_sw
WHERE lud='2012-11-28' AND res_id=769)
AND lud='2012-11-28'
AND res_id=769
但是会出现此错误:
查询:delete FROM sv_condition_sw WHERE snow_mountain > (SELECT AVG(snow_mountain)+1.5*STDDEV(snow_mountain) FROM sv_condition_sw WHER...
Error Code: 1093
You can't specify target table 'sv_condition_sw' for update in FROM clause
我不知道这意味着什么.
I do not know what it means.
推荐答案
您可以诱使MySQL通过另一个子选择来做到这一点
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
这篇关于使用标准偏差使用mysql删除异常值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文