Last active
August 29, 2015 13:58
-
-
Save frozenspider/10280093 to your computer and use it in GitHub Desktop.
comp-proposal-dao-query3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT status_temp.id FROM ( | |
SELECT temp_batch.original_id as id, temp_batch.validation_errors, COUNT(temps_enabled.id), COUNT(temps_disabled.id) | |
FROM comp_proposal_raw_temp_batch temp_batch | |
LEFT OUTER JOIN comp_proposal_raw temps_enabled | |
ON temps_enabled.temp_batch_id = temp_batch.id AND temps_enabled.dont_integrate = 0 | |
LEFT OUTER JOIN comp_proposal_raw temps_disabled | |
ON temps_disabled.temp_batch_id = temp_batch.id AND temps_disabled.dont_integrate = 1 | |
GROUP BY temp_batch.original_id | |
HAVING (COUNT(temps_enabled.id) = 0 AND COUNT(temps_disabled.id) > 0) OR temp_batch.validation_errors > 0 | |
) status_temp |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment