SELECT
        stackRun.skycell_id,
        stackRun.tess_id,
        stackRun.stack_id,
        warpSkyfile.warp_id
FROM stackSumSkyfile
JOIN stackRun
        USING(stack_id)
JOIN stackInputSkyfile
        USING(stack_id)
JOIN warpSkyfile
        USING(warp_id,tess_id,skycell_id)
LEFT JOIN diffInputSkyfile
        ON diffInputSkyfile.stack_id = stackRun.stack_id
        OR diffInputSkyfile.warp_id = warpSkyfile.warp_id
WHERE
        stackSumSkyfile.fault = 0
        AND warpSkyfile.fault = 0
        AND stackRun.state = 'stop'
        AND diffInputSkyfile.stack_id IS NULL
        AND diffInputSkyfile.warp_id IS NULL
