Skip to content

Instantly share code, notes, and snippets.

@SerendipityNL
Created January 21, 2020 09:04
Show Gist options
  • Save SerendipityNL/f4f91371034216a72fbadf361d3078c3 to your computer and use it in GitHub Desktop.
Save SerendipityNL/f4f91371034216a72fbadf361d3078c3 to your computer and use it in GitHub Desktop.
To calculate and plot the average amount of queries per pageview per month
-- Upload to https://chart-studio.plot.ly/create
SELECT
`date`,
`amount` / `pageviews` AS `queries_per_page`
FROM
`log_queries`;
SELECT
`date`,
AVG(`amount` / `pageviews`) AS `queries_per_page`
FROM
`log_queries`
GROUP BY
MONTH(`date`), YEAR(`date`)
ORDER BY
`date` ASC;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment