SELECT DISTINCT
   det_id,
   iteration
FROM
    (SELECT DISTINCT
        detRun.det_id,
        detRun.iteration,
        detInputExp.exp_tag
    FROM detRun
        LEFT JOIN detInputExp
        ON detRun.det_id = detInputExp.det_id
        AND detRun.iteration = detInputExp.iteration
    LEFT JOIN rawExp
        ON detInputExp.exp_tag = rawExp.exp_tag
    LEFT JOIN detResidExp
        ON detRun.det_id = detResidExp.det_id
        AND detRun.iteration = detResidExp.iteration
        AND detInputExp.exp_tag = detResidExp.exp_tag
   WHERE
        detRun.state = 'run'
   GROUP BY
        detRun.det_id,
        detRun.iteration
    HAVING
        COUNT(detResidExp.exp_tag) = COUNT(detInputExp.exp_tag)
    ) AS residdetrun
