Question: Show all template type codes and the number of documents using each type.
Schema: create table documents (template_id varchar, PRIMARY KEY (template_id)); create table templates (template_type_code varchar, template_id varchar, PRIMARY KEY (template_type_code))
SQL: select t1.template_type_code, count(*) from templates as t1 join documents as t2 on t1.template_id = t2.template_id group by t1.template_type_code