By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,265 Members | 1,343 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,265 IT Pros & Developers. It's quick & easy.

count between duration

P: 6
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
Share this Question
Share on Google+
1 Reply


ck9663
Expert 2.5K+
P: 2,878
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.