I am a newbie with database so I'm seeking your help with this one.
I have a table containing time series data.
2012/01/01 00:10, 10
2012/01/01 00:30, 5
2012/01/01 01:00, 10
2012/01/01 01:40, 10
2012/01/01 02:00, 20
The table is storing interval based data by keeping only the upper limit of the interval. For example the first row represents an interval from [00:00 - 00:10] with a value of 10, second row represents an interval from (00:10 - 00:30] with a value of 5 and the third one represents an interval from (00:30 - 01:00) with a value of 10.
I need an efficient query in Postgres to aggregate hourly data for a structure like the one described above. So the result would be something like this:
2012/01/01 00:00, 2012/01/01 01:00, 25
2012/01/01 01:00, 2012/01/01 02:00, 30
Note that the time-series data is big so any help with indexing this would be much appreciated.
Thanks, dan
2012/01/01 00:10, 10
, are all those values in a single column, or is the comma a column delimiter? Also, are the exact hours (1:00, 2:00, 3:00, etc.) guaranteed to be stored in the time series table, or might it skip over the :00 and have entries such as2012/01/01 03:50
followed by2012/01/01 04:10
?2012/01/01 04:00, 2012/01/01 05:00, 0
? or should that hour just be omitted from the summary?