Index: /trunk/ippTools/src/dettool.c
===================================================================
--- /trunk/ippTools/src/dettool.c	(revision 9488)
+++ /trunk/ippTools/src/dettool.c	(revision 9489)
@@ -1725,13 +1725,17 @@
 
     psString query = psStringCopy(
-        "SELECT DISTINCT"
+        "SELECT" 
+        "   det_id,"
+        "   det_type,"
+        "   iteration,"
+        "   camera"
+        " FROM"
+        "(SELECT DISTINCT"
         "   detRun.det_id,"
         "   detRun.det_type,"
         "   detRun.iteration,"
-        "   rawDetrendExp.camera"
-// XXX determine if these fields are truely visible to HAVING without
-// explicitly selecting them
-//        "   rawDetrendExp.imfiles,"
-//        "   detStackedImfile.class_id"
+        "   rawDetrendExp.camera,"
+        "   rawDetrendExp.imfiles,"
+        "   detStackedImfile.class_id"
         " FROM detRun"
         " JOIN detInputExp"
@@ -1757,4 +1761,5 @@
         "   detRun.det_id"
         " HAVING MAX(rawDetrendExp.imfiles) = COUNT(detStackedImfile.class_id)"
+        ") as tonormalizedstat"
         );
 
