Scott Abraham
asked on
Microsoft SQL Query sum values over time periods
I have the following data:
Value ReadingTime EntityID ServicePointChannelID
0.273 2017-05-17 00:15:00.000 76058805 1
0.272 2017-05-17 00:30:00.000 76058805 1
0.274 2017-05-17 00:45:00.000 76058805 1
0.274 2017-05-17 01:00:00.000 76058805 1
0.275 2017-05-17 01:15:00.000 76058805 1
0.275 2017-05-17 01:30:00.000 76058805 1
0.278 2017-05-17 01:45:00.000 76058805 1
0.278 2017-05-17 02:00:00.000 76058805 1
I need to sum the value for every hour, so it needs to add the 15 minute interval, 30 minute interval, 45 minute interval, and the hour interval together for an hour value.
In the case of the data above the output would look like:
Value ReadingTime EntityID ServicePointChannelID
1.093 2017-05-17 01:00:00.000 76058805 1
1.106 2017-05-17 02:00:00.000 76058805 1
There will not be missing time periods. These come in every 15 minutes and must be aggregated by hour.
Any help would be appreciated!
Value ReadingTime EntityID ServicePointChannelID
0.273 2017-05-17 00:15:00.000 76058805 1
0.272 2017-05-17 00:30:00.000 76058805 1
0.274 2017-05-17 00:45:00.000 76058805 1
0.274 2017-05-17 01:00:00.000 76058805 1
0.275 2017-05-17 01:15:00.000 76058805 1
0.275 2017-05-17 01:30:00.000 76058805 1
0.278 2017-05-17 01:45:00.000 76058805 1
0.278 2017-05-17 02:00:00.000 76058805 1
I need to sum the value for every hour, so it needs to add the 15 minute interval, 30 minute interval, 45 minute interval, and the hour interval together for an hour value.
In the case of the data above the output would look like:
Value ReadingTime EntityID ServicePointChannelID
1.093 2017-05-17 01:00:00.000 76058805 1
1.106 2017-05-17 02:00:00.000 76058805 1
There will not be missing time periods. These come in every 15 minutes and must be aggregated by hour.
Any help would be appreciated!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER