Index: trunk/ippTools/share/Makefile.am
===================================================================
--- trunk/ippTools/share/Makefile.am	(revision 32695)
+++ trunk/ippTools/share/Makefile.am	(revision 32696)
@@ -181,4 +181,5 @@
 	disttool_definebyquery_raw_no_magic.sql \
 	disttool_definebyquery_sky.sql \
+	disttool_definebyquery_sky_singlefilter.sql \
 	disttool_definebyquery_stack.sql \
 	disttool_definebyquery_warp.sql \
Index: trunk/ippTools/share/disttool_definebyquery_sky.sql
===================================================================
--- trunk/ippTools/share/disttool_definebyquery_sky.sql	(revision 32695)
+++ trunk/ippTools/share/disttool_definebyquery_sky.sql	(revision 32696)
@@ -22,4 +22,5 @@
 WHERE  distTarget.state = 'enabled'
     AND rcInterest.state = 'enabled'
+    AND distTarget.filter = 'multi'
     AND distRun.dist_id IS NULL
     AND ((staticskyRun.state = 'full') OR (distTarget.clean AND staticskyRun.state = 'cleaned'))
Index: trunk/ippTools/share/disttool_definebyquery_sky_singlefilter.sql
===================================================================
--- trunk/ippTools/share/disttool_definebyquery_sky_singlefilter.sql	(revision 32696)
+++ trunk/ippTools/share/disttool_definebyquery_sky_singlefilter.sql	(revision 32696)
@@ -0,0 +1,28 @@
+SELECT
+    'sky' as stage,
+    staticskyRun.sky_id AS stage_id,
+    CAST(0 AS SIGNED) AS magicked,
+    -- run tag in the form 'sky.$skycell_id.$stack_id'
+    CONCAT_WS('.', 'sky', stackRun.skycell_id, convert(staticskyRun.sky_id, CHAR)) as run_tag,
+    staticskyRun.label,
+    staticskyRun.data_group,
+    distTarget.dist_group,
+    distTarget.target_id,
+    distTarget.clean
+FROM staticskyRun
+JOIN staticskyResult USING(sky_id)
+JOIN staticskyInput USING(sky_id)
+JOIN stackRun using(stack_id)
+JOIN distTarget ON distTarget.stage = 'sky'
+    AND staticskyRun.dist_group = distTarget.dist_group
+JOIN rcInterest USING(target_id)
+LEFT JOIN distRun ON (distRun.stage_id = sky_id)
+    AND distRun.target_id = distTarget.target_id
+    -- JOIN hook %s
+WHERE  distTarget.state = 'enabled'
+    AND rcInterest.state = 'enabled'
+    AND distRun.dist_id IS NULL
+    AND ((staticskyRun.state = 'full') OR (distTarget.clean AND staticskyRun.state = 'cleaned'))
+    AND stackRun.filter = distTarget.filter
+    -- we shouldn't need to check fault. If faulted it shouldn't be full
+    AND (staticskyResult.fault = 0 AND staticskyResult.quality = 0)
Index: trunk/ippTools/src/disttool.c
===================================================================
--- trunk/ippTools/src/disttool.c	(revision 32695)
+++ trunk/ippTools/src/disttool.c	(revision 32696)
@@ -164,4 +164,6 @@
     PXOPT_LOOKUP_STR(dist_group, config->args, "-dist_group", false, false);
 
+    PXOPT_LOOKUP_BOOL(single, config->args, "-singlefilter", false);
+
     if (use_alternate) {
         if (strcmp(stage, "raw")) {
@@ -354,5 +356,9 @@
     } else if (!strcmp(stage, "sky")) {
         magicRunType = "staticskyRun";
-        query = pxDataGet("disttool_definebyquery_sky.sql");
+        if (single) {
+            query = pxDataGet("disttool_definebyquery_sky_singlefilter.sql");
+        } else {
+            query = pxDataGet("disttool_definebyquery_sky.sql");
+        }
         if (!query) {
             psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement");
@@ -411,4 +417,8 @@
     if (!no_magic) {
         psStringAppend(&query, " AND (%s.magicked > 0)", magicRunType);
+    }
+
+    if (!strcmp(stage, "sky") && single) {
+        psStringAppend(&query, "\nGROUP BY sky_id HAVING count(stack_id) = 1");
     }
 
Index: trunk/ippTools/src/disttoolConfig.c
===================================================================
--- trunk/ippTools/src/disttoolConfig.c	(revision 32695)
+++ trunk/ippTools/src/disttoolConfig.c	(revision 32696)
@@ -63,4 +63,5 @@
     psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-label",         0, "select by run label", NULL);
     psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-dist_group",    0, "select by dist_group", NULL);
+    psMetadataAddBool(definebyqueryArgs, PS_LIST_TAIL, "-singlefilter", 0, "select single filter runs (sky stage only)", false);
 
     psMetadataAddU64(definebyqueryArgs, PS_LIST_TAIL, "-limit",  0,  "limit result set to N items", 0);
