glorfindel-SE-Userscripts/hnq-research/2-percentage-of-total-questions-by-site.sql
2018-12-22 18:40:45 +01:00

10 lines
No EOL
374 B
SQL

SELECT RANK() OVER (ORDER BY ROUND(100.0 * temp.questions / t.number_of_questions, 2) DESC),
temp.site, ROUND(100.0 * temp.questions / t.number_of_questions, 2) AS "% of all Q on site"
FROM (
SELECT site,
COUNT(DISTINCT(question)) AS "questions"
FROM snapshots
GROUP BY site
) AS temp
INNER JOIN total_question_count AS t on t.site = temp.site
ORDER BY 3 DESC