I have some data as follows (just a few example lines here, tablesize > n thousand entries)
timestamp duration
2012-09-30T22:00 10800
2012-10-01T08:00 7200
2012-10-01T15:00 3600
2012-10-01T22:00 10800
2012-10-02T07:00 3600
2012-10-02T14:00 18000
and aim to achieve something like:
date totalDuration
2012-09-30 21600
2012-10-01 32400
and so on.
Durations should be summed up per interval, whereby interval starts at 22:00 each day in this example.
It’s SQL Server 2008.
However, you should note that
2012-09-30T22:00and2012-10-01T22:00should not be in the same “time frame day”.2012-09-30T22:00and2012-10-01T21:59can be in the same day.Compare this to having thresholds like 1-10 and 10-20. Where does 10 belong to?