Template usage report
Script to dump out stats per template for last 12 months Select d.sitecode, d.DepartmentCode, dep.[Description] as 'Department',d.DocumentTypeName, dt.[Description] as 'DocumentType',t.[Name] as 'Template',Count(d.documentId) as 'NumberDocuments' from Document d with (nolock) inner join Department dep with (nolock) on dep.DepartmentCode = d.DepartmentCode and dep.SiteCode = d.SiteCode inner join DocumentType dt with (nolock) on dt.DocumentTypeName = d.DocumentTypeName and dt.DepartmentCode = d.DepartmentCode and dt.SiteCode = d.SiteCode inner join Template t with (nolock) on t.id = dt.TemplateId where d.DateTimeDictated > '2022-10-01' group by d.sitecode, D.DepartmentCode, dep.[Description], d.DocumentTypeName, dt.[Description], t.[Name] order by d.sitecode, D.DepartmentCode, d.DocumentTypeName Select t.[Name] as 'Template', Count(d.documentId) as 'NumberDocuments' from Document d with (nolock) inner join Department dep with (nolock) on dep.DepartmentCode = d.DepartmentCode and dep.SiteCode = d.SiteCode inner join DocumentType dt with (nolock) on dt.DocumentTypeName = d.DocumentTypeName and dt.DepartmentCode = d.DepartmentCode and dt.SiteCode = d.SiteCode inner join Template t with (nolock) on t.id = dt.TemplateId where d.DateTimeDictated > '2022-10-01' group by t.[name]