Skip to content

Instantly share code, notes, and snippets.

@hipertracker
Created August 23, 2018 09:46
Show Gist options
  • Select an option

  • Save hipertracker/49ab9dcaacf40bd4152873586287712d to your computer and use it in GitHub Desktop.

Select an option

Save hipertracker/49ab9dcaacf40bd4152873586287712d to your computer and use it in GitHub Desktop.
SQL for Django
SELECT SUM(pageview) AS pageview__sum, substring(url from '^/[^/]+/') AS category
FROM portal_tracker
GROUP BY substring(url from '^/[^/]+/')
HAVING substring(url from '^/[^/]+/') IS NOT NULL
ORDER BY pageview__sum DESC;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment