SQLite count, group and order by count SQLite count, group and order by count sqlite sqlite

SQLite count, group and order by count


SELECT foo, count(bar) FROM mytable GROUP BY bar ORDER BY count(bar) DESC;

The group by statement tells aggregate functions to group the result set by a column. In this case "group by bar" says count the number of fields in the bar column, grouped by the different "types" of bar.

A better explanation is here: http://www.w3schools.com/sql/sql_groupby.asp