Last active
November 25, 2015 09:47
-
-
Save exul/8b42cac2c32bf1c9667f to your computer and use it in GitHub Desktop.
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 fundables.id AS project_id, | |
DATE_PART('year', fundables.started_at) AS start_year, | |
DATE_PART('year', fundables.started_at + INTERVAL '1 day' * fundables.duration) AS end_year, | |
ARRAY_AGG(pledges.id) AS pledge_ids | |
FROM fundables | |
INNER JOIN pledges | |
ON pledges.project_id = fundables.id | |
WHERE type = 'Project' | |
AND fundables.successful = 'f' | |
AND DATE_PART('year', fundables.started_at) != DATE_PART('year', fundables.started_at + INTERVAL '1 day' * fundables.duration) | |
GROUP BY fundables.id |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment