Created
January 4, 2013 20:13
-
-
Save jtarleton/4455573 to your computer and use it in GitHub Desktop.
Distinct values and their occurances
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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