diff --git a/include/class.template.php b/include/class.template.php
index ef53d7ed59ff1c404e525f2d903107118b923709..36d9b2f4845d3ca14ad564c9a8c829c11b9ab083 100644
--- a/include/class.template.php
+++ b/include/class.template.php
@@ -28,11 +28,12 @@ class Template {
 
         if(!$id && !($id=$this->getId()))
             return false;
-
+           
         $sql='SELECT tpl.*,count(dept.tpl_id) as depts '
             .' FROM '.EMAIL_TEMPLATE_TABLE.' tpl '
             .' LEFT JOIN '.DEPT_TABLE.' dept USING(tpl_id) '
-            .' WHERE tpl_id='.db_input($id);
+            .' WHERE tpl.tpl_id='.db_input($id)
+            .' GROUP BY tpl.tpl_id';
 
         if(!($res=db_query($sql))|| !db_num_rows($res))
             return false;