Created
November 8, 2019 04:40
-
-
Save mfridman/7e6e0febdbdacbb236fe5ff44bc87156 to your computer and use it in GitHub Desktop.
finding top comments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WITH votes AS ( | |
SELECT | |
number_id, | |
id, | |
SUM(CAST(plus_one + 1 AS FLOAT)) AS U, | |
SUM(CAST(minus_one + 1 AS FLOAT)) AS D | |
FROM | |
comments | |
GROUP BY | |
id, | |
number_id | |
) | |
SELECT | |
FORMAT('[%s](https://github.com/golang/go/issues/%s)', number_id, number_id), | |
FORMAT('[%s](https://github.com/golang/go/issues/%s#issuecomment-%s)', id, number_id, id), | |
U - 1 AS ๐, | |
D - 1 AS ๐, | |
ABS(0.5 - U / (U + D) - 3.5 * SQRT(U * D / ((U + D) * (U + D) * (U + D + 1)))) + | |
ABS(0.5 - U / (U + D) + 3.5 * SQRT(U * D / ((U + D) * (U + D) * (U + D + 1)))) AS Score | |
FROM | |
votes | |
ORDER BY | |
Score | |
LIMIT 10; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment