SELECT DISTINCT
    warpSkyCellMap.warp_id,
    warpSkyCellMap.skycell_id,
    warpSkyCellMap.tess_id,
    warpSkyCellMap.cam_id,
    rawExp.camera,
    warpRun.workdir
FROM warpRun
JOIN warpSkyCellMap
    USING(warp_id)
JOIN camProcessedExp
    ON warpSkyCellMap.cam_id = camProcessedExp.cam_id
JOIN chipRun
    ON camProcessedExp.chip_id = chipRun.chip_id
JOIN chipProcessedImfile
    ON chipRun.chip_id = chipProcessedImfile.chip_id
JOIN rawExp
    ON chipProcessedImfile.exp_id = rawExp.exp_id
LEFT JOIN warpSkyfile
    ON warpRun.warp_id = warpSkyfile.warp_id
    AND warpSkyCellMap.skycell_id = warpSkyfile.skycell_id
    AND warpSkyCellMap.tess_id = warpSkyfile.tess_id
WHERE
    warpRun.state = 'run'
    AND warpSkyfile.warp_id IS NULL
    AND warpSkyfile.skycell_id IS NULL
    AND warpSkyfile.tess_id IS NULL
    AND warpSkyCellMap.fault = 0

