Index: trunk/ippTools/share/Makefile.am
===================================================================
--- trunk/ippTools/share/Makefile.am	(revision 14078)
+++ trunk/ippTools/share/Makefile.am	(revision 14088)
@@ -13,4 +13,5 @@
 	dettool_find_completed_runs.sql \
 	dettool_raw.sql \
+	dettool_start_new_iteration.sql \
 	dettool_todetrunsummary.sql \
 	dettool_tonormalizedexp.sql \
Index: trunk/ippTools/share/dettool_start_new_iteration.sql
===================================================================
--- trunk/ippTools/share/dettool_start_new_iteration.sql	(revision 14088)
+++ trunk/ippTools/share/dettool_start_new_iteration.sql	(revision 14088)
@@ -0,0 +1,33 @@
+-- select detRun.iteration
+-- select detInputExp.exp_id
+-- select detResidExp.accept
+-- 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
+
+SELECT * FROM
+    (SELECT DISTINCT
+        detRun.det_id AS det_id,
+        detRun.iteration,
+        detInputExp.exp_id,
+        detResidExp.accept
+    FROM detRun
+    JOIN detInputExp
+        ON detRun.det_id = detInputExp.det_id
+        AND detRun.iteration = detInputExp.iteration
+    JOIN detResidExp
+        ON detRun.det_id = detResidExp.det_id
+        AND detRun.iteration = detResidExp.iteration
+        AND detInputExp.exp_id = detResidExp.exp_id
+    WHERE
+        detRun.state = 'run'
+        AND detRun.mode = 'master'
+    GROUP BY
+        detRun.det_id,
+        detRun.iteration,
+        detInputExp.exp_id
+    HAVING
+        COUNT(detResidExp.exp_id) = COUNT(detInputExp.exp_id)
+    ) as Foo
