count between duration

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • khaled1988
    New Member
    • Aug 2008
    • 6

    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]
  • ck9663
    Recognized Expert Specialist
    • Jun 2007
    • 2878

    #2
    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

    Comment

    Working...