CoderZone.org

Category: >> mySQL >> Grouping rows by frequency Bookmark and Share

<< lastnext >>

Snippet Name: Grouping rows by frequency

Description: Handy little query that groups rows by frequency.

Comment: (none)

Author: CoderZone
Language: MYSQL
Highlight Mode: MYSQL
Last Modified: March 01st, 2009

SELECT DISTINCT field_name, COUNT(*) AS num 
FROM table_name 
GROUP BY field_name 
ORDER BY num DESC
 
There haven't been any comments added for this snippet yet. You may add one if you like.  Add a comment 
© coderzone.org | users online: 23