Skip to content
Advertisement

Convert 15min to 10min timeseries in SQL Server

I have a timeseries in a 15min format with four different variables. I need to convert this into 10min timeseries format. Due to some constraints, I need to do this in SQL which I agree is probably the worse choice language to do this in. I am convinced however that it is doable.

What I believe needs to be done is to divide each 15min data point into three 5min data point and then add every two 5min data point into a 10min data point. Done manually this gives me the correct results.

Below some sample DDL SQL that shows the initial table:

The end result table:

A sanity check to make sure numbers are correct from start to finish:

Graphically the conversion goes something like this:

  • Left table is the 15min data points
  • Middle table is the 5min data points
  • Right table is the 10min data points

15min to 5min to 10min

I understand the complexity of the request so any help is greatly appreciated !

Advertisement

Answer

Based on what you describe, you can “unpivot” for each of the minutes and then reaggregate:

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement