Skip to content

Instantly share code, notes, and snippets.

@rviscomi
Last active June 2, 2022 18:50
Show Gist options
  • Save rviscomi/2e685d0313f891ef5b50393fdc38f823 to your computer and use it in GitHub Desktop.
Save rviscomi/2e685d0313f891ef5b50393fdc38f823 to your computer and use it in GitHub Desktop.
WITH app_list AS (
SELECT DISTINCT
app
FROM
`httparchive.technologies.2022_05_01_mobile`
WHERE
category IN ('CMS')
), category AS (
SELECT
_TABLE_SUFFIX,
*
FROM
`httparchive.technologies.*`
JOIN
app_list
USING
(app)
WHERE
ENDS_WITH(_TABLE_SUFFIX, 'mobile')
), total AS (
SELECT
_TABLE_SUFFIX,
COUNT(DISTINCT url) AS websites
FROM
category
GROUP BY
_TABLE_SUFFIX
), apps AS (
SELECT
_TABLE_SUFFIX,
app,
COUNT(DISTINCT url) AS websites
FROM
category
GROUP BY
_TABLE_SUFFIX,
app
)
SELECT
REGEXP_REPLACE(_TABLE_SUFFIX, r'(\d{4})_(\d{2})_(\d{2})_.*', r'\1-\2-\3') AS date,
app,
apps.websites AS websites,
total.websites AS total,
apps.websites / total.websites AS pct_share
FROM
apps
JOIN
total
USING
(_TABLE_SUFFIX)
ORDER BY
date DESC,
websites DESC
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment