Skip to content

Instantly share code, notes, and snippets.

@EddyBorja
Created September 2, 2017 23:54
Show Gist options
  • Save EddyBorja/fc1d128561247f3d9fcec8879c51474a to your computer and use it in GitHub Desktop.
Save EddyBorja/fc1d128561247f3d9fcec8879c51474a to your computer and use it in GitHub Desktop.
Example query for sorting an SQL table by average rating
SELECT 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 some_table
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