Index: /trunk/ippMonitor/def/autocode.php
===================================================================
--- /trunk/ippMonitor/def/autocode.php	(revision 29484)
+++ /trunk/ippMonitor/def/autocode.php	(revision 29485)
@@ -25,5 +25,5 @@
 $restricted = 0;
 
-// define restrictiosn to the queries
+// define restrictions to the queries
 // ** TABLE RESTRICTIONS **
 
@@ -33,4 +33,7 @@
   }
 }
+
+// Add GROUP BY statements if any
+// ** GROUP RESTRICTIONS **
 
 // get the result table count
Index: /trunk/ippMonitor/scripts/generate
===================================================================
--- /trunk/ippMonitor/scripts/generate	(revision 29484)
+++ /trunk/ippMonitor/scripts/generate	(revision 29485)
@@ -227,4 +227,9 @@
         }
 
+        # fill in GROUP BY
+        if ($line =~ m|// \*\* GROUP RESTRICTIONS \*\*|) {
+            &write_group_by;
+        }
+
         # fill in table restricts
         if ($line =~ m|// \*\* BUTTON RESTRICTIONS \*\*|) {
@@ -331,4 +336,9 @@
         print FILE "\$WHERE = check_restrict ('$value', \$WHERE, 'max', 1.0);\n";
     }
+    # print FILE "\$WHERE = check_ordering ('$GROUPS', \$WHERE);\n";
+}
+
+# Generate GROUP BY statement if any 
+sub write_group_by {
     print FILE "\$WHERE = check_ordering ('$GROUPS', \$WHERE);\n";
 }
