Skip to content

Instantly share code, notes, and snippets.

@laguiar
Last active November 3, 2016 22:48
Show Gist options
  • Save laguiar/22e7df937f3f68bb465612853c1a3088 to your computer and use it in GitHub Desktop.
Save laguiar/22e7df937f3f68bb465612853c1a3088 to your computer and use it in GitHub Desktop.
-- From the Evan Miller's article http://www.evanmiller.org/how-not-to-sort-by-average-rating.html
SELECT widget_id, ((positive + 1.9208) / (positive + negative) -
1.96 * SQRT((positive * negative) / (positive + negative) + 0.9604) /
(positive + negative)) / (1 + 3.8416 / (positive + negative))
AS ci_lower_bound
FROM widgets
WHERE positive + negative > 0
ORDER BY ci_lower_bound DESC;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment