{exp:query sql="SELECT count(exp_category_posts.entry_id) AS count,exp_category_posts.cat_id, exp_categories.cat_name FROM exp_categories, exp_category_posts WHERE exp_category_posts.cat_id = exp_categories.cat_id GROUP BY exp_categories.cat_name"} <a href="{path=weblog/view}C{cat_id}/">{cat_name} a> ({count}) {/exp:query}
Displays a list of categories with an entry count for each category. Alternatively, you can also use this query together with the {exp:weblog:categories} tag, making the query a lot smaller:
{exp:weblog:categories weblog="weblog1"} <a href="{path=weblog/index}">{category_name}a> {exp:query sql="SELECT count(exp_category_posts.entry_id) AS count FROM exp_category_posts WHERE exp_category_posts.cat_id = {category_id} "} ({count} entries) {/exp:query} {/exp:weblog:categories}