Created
December 12, 2020 12:54
-
-
Save mleyvaz/a39f716eb2df3a9b25807225cc2fe1c3 to your computer and use it in GitHub Desktop.
Consulta bigQuery
This file contains 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 question_answers_join AS ( | |
SELECT * | |
, GREATEST(1, TIMESTAMP_DIFF(answers.first, creation_date, minute)) minutes_2_answer | |
FROM ( | |
SELECT id, creation_date, title | |
, (SELECT AS STRUCT MIN(creation_date) first, COUNT(*) c | |
FROM `bigquery-public-data.stackoverflow.posts_answers` | |
WHERE a.id=parent_id | |
) answers | |
, SPLIT(tags, '|') tags | |
FROM `bigquery-public-data.stackoverflow.posts_questions` a | |
WHERE EXTRACT(year FROM creation_date) > 2014 | |
) | |
) | |
SELECT COUNT(*) questions, tag | |
, ROUND(EXP(AVG(LOG(minutes_2_answer))), 2) mean_geo_minutes | |
, APPROX_QUANTILES(minutes_2_answer, 100)[SAFE_OFFSET(50)] median | |
FROM question_answers_join, UNNEST(tags) tag | |
WHERE tag IN ('javascript', 'python', 'rust', 'java', 'scala', 'ruby', 'go', 'react', 'c', 'c++') | |
AND answers.c > 0 | |
GROUP BY tag | |
ORDER BY mean_geo_minutes |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment