troubleshooting Question

Sum value by hour in sql

Avatar of Scott Abraham
Scott AbrahamFlag for United States of America asked on
Microsoft SQL ServerSQL
5 Comments2 Solutions66 ViewsLast Modified:
I have table data that queries like this:
OBJECT      TS      VALUE
1      1/21/19 0:15      12
1      1/21/19 0:30      18
1      1/21/19 0:45      12
1      1/21/19 1:00      18
1      1/21/19 1:15      12
1      1/21/19 1:30      12
1      1/21/19 1:45      18
1      1/21/19 2:00      12
1      1/21/19 2:15      12
1      1/21/19 2:30      18
1      1/21/19 2:45      12
1      1/21/19 3:00      12
1      1/21/19 3:15      18
1      1/21/19 3:30      12
1      1/21/19 3:45      12
1      1/21/19 4:00      18

I want to query it out so it adds all values into an hourly value.  For example the 1:00 hour is a sum of the 00:15,00:30,00:45, and 01:00.

It queries out like this:

OBJECT      TS      VALUE      
1      1/21/19 1:00      18      60
1      1/21/19 2:00      12      54
1      1/21/19 3:00      12      54
1      1/21/19 4:00      18      60

Any help would be appreciated.
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 2 Answers and 5 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros