We help IT Professionals succeed at work.

Microsoft SQL Query sum values over time periods

159 Views
Last Modified: 2017-05-25
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!
Comment
Watch Question

Senior Developer
CERTIFIED EXPERT
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Sharath SData Engineer
CERTIFIED EXPERT
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Scott AbrahamTechnical Systems Manager

Author

Commented:
That pointed me in the right direction!  Thanks both of you!

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.