467,134 Members | 1,058 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,134 developers. It's quick & easy.

count between duration

hi every one

i need a sql query that can sum count column between 2 hours

it's coming like this

date-time | counter | doors | center

2008-12-15 00:05:04 | 1 | 1 | ---
2008-12-15 00:12:32 | 2 | 1 | ---
2008-12-15 00:25:44 | 1 | 1 | ---
2008-12-15 00:32:11 | 1 | 1 | ---
2008-12-15 00:44:16 | 1 | 1 | ---


but i want to gather the table in one group

date-time | counter | doors | center

2008-12-15 01:00 | 50 | 1 | ---

i had been triad this one
SELECT [Date-Time] ,sum([counter]) ,[doors] , [center] FROM [counter_table] where ([Date-Time] between '2008-12-15 00:00' and '2008-12-15 01:00') and ([doors] = '1') order by [Date-Time]
Dec 16 '08 #1
  • viewed: 1741
Share:
1 Reply
ck9663
Expert 2GB
Is it 2 hours based on the value of the first record? or every 2 hours since midnight?

If the first datetime is 1AM, 2 hours is 1-3.

-- CK
Dec 18 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

reply views Thread by Rgemini | last post: by
4 posts views Thread by Matthew Groch | last post: by
6 posts views Thread by Mario Vázquez | last post: by
32 posts views Thread by Ciaran | last post: by
15 posts views Thread by bcpkh | last post: by
3 posts views Thread by Keith Wilby | last post: by
1 post views Thread by Giacomo Catenazzi | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.