Date range 如何按5分钟按日期范围分组?

Date range 如何按5分钟按日期范围分组?,date-range,Date Range,可能重复: 我想通过将特定范围划分为5分钟来计算(*)。比如说 开始时间2012年3月13日10:30 结束时间2012年3月13日10:45 此时间范围应划分为3个范围,并具体计算它们 例如: 范围计数(*) 范围15 范围27 范围3 11您可以创建一个返回数据集的函数 参数可以是开始时间、结束时间和间隔数 伪代码: declare return @return table --- temp table for 1 to intervalCount calculate start

可能重复:

我想通过将特定范围划分为5分钟来计算(*)。比如说

  • 开始时间2012年3月13日10:30

  • 结束时间2012年3月13日10:45

此时间范围应划分为3个范围,并具体计算它们

例如:

范围计数(*) 范围15 范围27
范围3 11

您可以创建一个返回数据集的函数

参数可以是开始时间、结束时间和间隔数

伪代码:

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

我希望这能给你一个想法。请告诉我们您正在使用哪些RDBMS

顺便说一下,我想使用TSQL谢谢:)