Skip to content

Instantly share code, notes, and snippets.

@jtarleton
Created January 4, 2013 20:13
Show Gist options
  • Save jtarleton/4455573 to your computer and use it in GitHub Desktop.
Save jtarleton/4455573 to your computer and use it in GitHub Desktop.
Distinct values and their occurances
# Break down values of a table by distinct field with the number of times the value occurs
# (e.g. breakdown of distinct users and the number of successful logins for each user)
SELECT session_user, COUNT( session_user ) AS NumOccurrences
FROM sessions
GROUP BY session_user
ORDER BY NumOccurrences DESC
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment