Skip to content

Instantly share code, notes, and snippets.

@rohannog
Created August 11, 2011 09:03
Show Gist options
  • Save rohannog/1139201 to your computer and use it in GitHub Desktop.
Save rohannog/1139201 to your computer and use it in GitHub Desktop.
Grouping by domains in MySQL
SELECT
SUBSTRING( REPLACE( REPLACE( URL, 'https://', ''), 'http://', ''), 1, LOCATE('/', REPLACE(REPLACE(URL, 'https://', ''), 'http://', '')) - 1) as domain,
COUNT(*)
FROM urlData
GROUP BY domain
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment