Find outliers in Hive - SemanticException
Seems like Hive doesn't let you use avg in a where clause. You can solve this with a subquery.

SELECT id
FROM 
    (SELECT id, AVG(id) as avg_id, STDDEV(id) as stddev_id FROM data)
WHERE id &lt; avg_id + stddev_id AND id &gt; avg_id - stddev_id