Skip to content

Instantly share code, notes, and snippets.

@a1phanumeric
Created April 5, 2012 08:04
Show Gist options
  • Save a1phanumeric/2308893 to your computer and use it in GitHub Desktop.
Save a1phanumeric/2308893 to your computer and use it in GitHub Desktop.
How to sort by average user rating correctly
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 ORDER BY ci_lower_bound DESC;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment