Skip to content

Instantly share code, notes, and snippets.

@felipelavinz
Created May 31, 2012 14:19
Show Gist options
  • Save felipelavinz/2843682 to your computer and use it in GitHub Desktop.
Save felipelavinz/2843682 to your computer and use it in GitHub Desktop.
group results by frequency
# originally seen on: http://psoug.org/snippet/Grouping_rows_by_frequency_299.htm
SELECT DISTINCT field_name, COUNT(*) AS num
FROM table_name
GROUP BY field_name
ORDER BY num DESC
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment