Skip to content

Instantly share code, notes, and snippets.

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 sinabahram/1f59668c849c78d138445c266f1032c0 to your computer and use it in GitHub Desktop.
Save sinabahram/1f59668c849c78d138445c266f1032c0 to your computer and use it in GitHub Desktop.
SQL to Return Rows within 95th Percentile
SELECT CAST(SUBSTRING_INDEX(SUBSTRING_INDEX(GROUP_CONCAT(field_name ORDER BY field_name SEPARATOR ','),  ',', 95/100 * COUNT(*) + 1), ',', -1) AS DECIMAL) AS `95th Per` FROM table_name;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment