Index: trunk/ippTools/share/difftool_inputskyfile.sql
===================================================================
--- trunk/ippTools/share/difftool_inputskyfile.sql	(revision 20973)
+++ trunk/ippTools/share/difftool_inputskyfile.sql	(revision 20976)
@@ -47,5 +47,5 @@
         warpSkyfile.uri,
         warpSkyfile.path_base,
-        0 as template,
+        1 as template,
         rawExp.camera
     FROM diffRun
@@ -85,5 +85,5 @@
         stackSumSkyfile.uri,
         stackSumSkyfile.path_base,
-        1 as template,
+        0 as template,
         rawExp.camera
     FROM diffRun
@@ -92,6 +92,16 @@
     JOIN stackSumSkyfile
         ON  diffInputSkyfile.stack1 = stackSumSkyfile.stack_id
+    JOIN stackInputSkyfile
+        ON diffInputSkyfile.stack1 = stackInputSkyfile.stack_id
+    JOIN warpRun
+        ON stackInputSkyfile.warp_id = warpRun.warp_id
+    JOIN fakeRun
+        USING(fake_id)
+    JOIN camRun
+        USING(cam_id)
+    JOIN chipRun
+        USING(chip_id)
     JOIN rawExp
-        USING(exp_id)
+        ON chipRun.exp_id = rawExp.exp_id
     WHERE
         diffRun.state = 'new'
@@ -114,6 +124,16 @@
     JOIN stackSumSkyfile
         ON  diffInputSkyfile.stack2 = stackSumSkyfile.stack_id
+    JOIN stackInputSkyfile
+        ON diffInputSkyfile.stack2 = stackInputSkyfile.stack_id
+    JOIN warpRun
+        ON stackInputSkyfile.warp_id = warpRun.warp_id
+    JOIN fakeRun
+        USING(fake_id)
+    JOIN camRun
+        USING(cam_id)
+    JOIN chipRun
+        USING(chip_id)
     JOIN rawExp
-        USING(exp_id)
+        ON chipRun.exp_id = rawExp.exp_id
     WHERE
         diffRun.state = 'new'
