I need a MySql query to do the following:
Select all the items in a table, group them by a type, order them by count type and also sum all the count.
This is what I’ve done so far:
select type, count(*) as cnt from $tbl_name group by type order by count(*) desc;
This only gives me the count for each group. What should I add so that this code will also show the total count (sum the counts from every group).
Note that the first row will be the rolled up total sum.
ROLLUP reference