我有一张包含以下数据的表:
trtime:2019-01-31 11:03:33.000 || tr_count:1
trtime:2019-01-31 11:23:33.000 || tr_count:2
trtime:2019-01-31 12:13:33.000 || tr_count:5
trtime:2019-01-31 12:43:33.000 || tr_count:1
我想以这种格式输出:
time_till:2019-01-31 12:00:00.000 || tr_count:3
time_till:2019-01-31 13:00:00.000 || tr_count:6
即每小时合并一次。
谢谢
答案 0 :(得分:1)
您可以将from libcloud.compute.types import Provider
from libcloud.compute.providers import get_driver
driver = get_driver(Provider.EC2)
driver.list_regions()
['ap-northeast-1', 'ap-northeast-2', 'ap-northeast-3', 'ap-south-1', 'ap-southeast-1', 'ap-southeast-2', 'ca-central-1', 'cn-north-1', 'cn-northwest-1', 'eu-central-1', 'eu-west-1', 'eu-west-2', 'eu-west-3', 'sa-east-1', 'us-east-1', 'us-east-2', 'us-gov-west-1', 'us-west-1', 'us-west-2']
与casting
一起使用,以将类型转换为下面的查询
grouping
答案 1 :(得分:0)
WITH TempResult as
(select CONVERT(date, time) myDate, DATEPART(HOUR, time)+1 myHour,count(id) tr_count
from myTable
GROUP BY CONVERT(date, time), DATEPART(HOUR, time))
Select DATEADD(hour,myHour+1,Convert(Datetime, myDate)) time_till,tr_count from TempResult