Created
June 26, 2013 16:47
-
-
Save rubysolo/5869134 to your computer and use it in GitHub Desktop.
cfd query
This file contains hidden or 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 d.day, s.description, SUM(1) AS count | |
FROM (SELECT current_date - days.day AS day FROM generate_series(0, | |
(SELECT CAST(EXTRACT(epoch FROM NOW() - DATE(MIN(start_date))) / 86400 AS integer) FROM pivotal_tracker_story_histories) | |
,1) AS days(day)) d INNER JOIN pivotal_tracker_story_histories h ON d.day BETWEEN h.start_date AND COALESCE(h.end_date, current_date) | |
INNER JOIN pivotal_tracker_story_statuses s ON s.id = h.status_id | |
GROUP BY d.day, s.description | |
ORDER BY d.day, s.description |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment