SELECT
    detNormalizedStatImfile.*
FROM detRunSummary
JOIN detNormalizedStatImfile
    USING(det_id,iteration)
WHERE
    ((detRunSummary.data_state = 'goto_cleaned'
      AND detNormalizedStatImfile.data_state = 'full')
     OR (detRunSummary.data_state = 'goto_scrubbed'
      AND detNormalizedStatImfile.data_state = 'full')
     OR (detRunSummary.data_state = 'goto_purged'
      AND detNormalizedStatImfile.data_state = 'full')
     OR detNormalizedStatImfile.data_state = 'goto_cleaned'
     OR detNormalizedStatImfile.data_state = 'goto_scrubbed'
     OR detNormalizedStatImfile.data_state = 'goto_purged')

