Show all template ids and number of documents using each template.
create table documents (template_id varchar, PRIMARY KEY (template_id))
select template_id, count(*) from documents group by template_id