Index: trunk/ippTools/src/dettool.c
===================================================================
--- trunk/ippTools/src/dettool.c	(revision 14076)
+++ trunk/ippTools/src/dettool.c	(revision 14078)
@@ -5272,48 +5272,9 @@
      */
 
-    // select detRun.det_id
-    // select detRun.iteration
-    // select detRun.det_type
-    // by:
-    // find the current iteration bassed on det_id
-    // find all exp_ids in the current det_id/iteration from detInputExp
-    // find all exp_ids in the current det_id/iteration from detResidExp
-    // compare the counts of exp_ids
-
-    psString query = psStringCopy(
-        "SELECT DISTINCT\n"
-        "   det_id,\n"
-        "   iteration,\n"
-        "   det_type,\n"
-        "   mode,\n"
-        "   workdir,\n"
-        "   camera\n"
-        " FROM\n"
-        "   (SELECT DISTINCT\n"
-        "       detRun.det_id,\n"
-        "       detRun.iteration,\n"
-        "       detRun.det_type,\n"
-        "       detRun.mode,\n"
-        "       detRun.workdir,\n"
-        "       detInputExp.exp_id,\n"
-        "       rawExp.camera\n"
-        "   FROM detRun\n"
-        "   JOIN detInputExp\n"
-        "       USING(det_id, iteration)\n"
-        "   JOIN rawExp\n"
-        "       ON detInputExp.exp_id = rawExp.exp_id\n"
-        "   LEFT JOIN detResidExp\n"
-        "       ON detRun.det_id = detResidExp.det_id\n"
-        "       AND detRun.iteration = detResidExp.iteration\n"
-        "       AND detInputExp.exp_id = detResidExp.exp_id\n"
-        "   WHERE\n"
-        "       detRun.state = 'run'\n"
-        "   GROUP BY\n"
-        "       detRun.det_id,\n"
-        "       detRun.iteration\n"
-        "   HAVING\n"
-        "       COUNT(detResidExp.exp_id) = COUNT(detInputExp.exp_id)\n"
-        " ) AS Foo\n"
-        );
+    psString query = pxDataGet("dettool_todetrunsummary.sql");
+    if (!query) {
+        psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
+        return false;
+    }
 
     // XXX does it make sense to accept any search params?
