Skip to content

Instantly share code, notes, and snippets.

@luckyshot
Last active May 28, 2019 14:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save luckyshot/aec660c5469c7d54dabe057802dacc0c to your computer and use it in GitHub Desktop.
Save luckyshot/aec660c5469c7d54dabe057802dacc0c to your computer and use it in GitHub Desktop.
Computing Average/Median value ignoring outliers/extremes (MySQL)
-- Exclude outliers while trying to get the average
SELECT AVG(price) FROM transactions WHERE ABS(price - (SELECT AVG(price) FROM transactions) < 3*(SELECT stddev(price) from transactions));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment