Created
October 6, 2016 13:27
-
-
Save cema-sp/5fc7c22716a3a68c85d6a8022cbfb033 to your computer and use it in GitHub Desktop.
Time series selection
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 | |
d, sum(COALESCE(value,0)) | |
from | |
generate_series('2016-01-01', '2016-10-01', '1 months'::interval) as "d" | |
left join | |
metrics_raw | |
on | |
d = date_trunc('months', metrics_raw.timestamp) | |
where | |
metrics_raw.type is null OR | |
metrics_raw.type = 'TRA' | |
group by d | |
order by d |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment