Index: trunk/ippTools/share/disttool_pendingcomponent.sql
===================================================================
--- trunk/ippTools/share/disttool_pendingcomponent.sql	(revision 24682)
+++ trunk/ippTools/share/disttool_pendingcomponent.sql	(revision 24739)
@@ -18,23 +18,9 @@
     rawImfile.magicked
 FROM distRun
-JOIN rawExp ON exp_id = stage_id
-JOIN (                      -- find the last satisfactory chip run 
-                            -- note this requires that a chip run have been completed even when 
-                            -- magic is not required for the run
-    SELECT
-        exp_id,
-        MAX(chip_id) AS chip_id
-    FROM chipRun
-    JOIN distRun ON stage_id = exp_id AND stage = 'raw'
-    WHERE 
-        chipRun.state = 'full'
-        AND chipRun.exp_id = exp_id
-        AND (chipRun.magicked OR distRun.no_magic)
-        GROUP BY exp_id
-    ) AS bestChipRun 
-    USING(exp_id)
+JOIN rawExp ON rawExp.exp_id = stage_id
 JOIN rawImfile USING(exp_id)
+JOIN chipRun ON chipRun.exp_id = rawExp.exp_id and chipRun.magicked
 JOIN chipProcessedImfile
-    USING(exp_id, chip_id, class_id)
+    USING(chip_id, class_id)
 LEFT JOIN distComponent 
     ON distRun.dist_id = distComponent.dist_id 
