Skip to content

Instantly share code, notes, and snippets.

@frozenspider
Last active August 29, 2015 13:58
Show Gist options
  • Save frozenspider/10280093 to your computer and use it in GitHub Desktop.
Save frozenspider/10280093 to your computer and use it in GitHub Desktop.
comp-proposal-dao-query3
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