0

Possible Duplicate:
group by range in mysql

I want to count(*) between specific ranges by dividing them into 5 minutes. For example

  • start time 13-03-2012 10:30

  • end time 13-03-2012 10:45

this time range should be splitted into 3 ranges and specifically count them

For Example:

Ranges Count(*)

range 1 5 range 2 7 range 3 11

Community
  • 1
  • 1
cihadakt
  • 3,054
  • 11
  • 37
  • 59

1 Answers1

0

You could create a function, that returns a datset.

Parameters could be starttime, endtime and the number of intervals.

PseudoCode:

declare return @return table --- temp table
for 1 to intervalCount
   calculate start and endtime of interval
   select @c=count(*) from tbl where time between intervalstart and intervallend
   insert into @return (@c)
end for

I hope this gives you an idea. Please tell us which RDBMS you are using.

LuigiEdlCarno
  • 2,410
  • 2
  • 21
  • 37