我有一个表列,其日期与我公司中的发送订单相对应。格式如下:2019-07-31 09:52:09.427
。
ModDate
2019-07-31 09:48:08.810
2019-07-31 09:48:09.000
2019-07-31 09:48:09.070
2019-07-31 09:48:08.070
2019-07-31 09:48:45.083
2016-09-09 13:13:30.680
2016-09-09 13:15:00.907
2016-09-09 13:27:45.647
2016-09-09 13:32:15.217
2016-09-09 14:32:15.917
2016-09-09 14:32:15.917
我想拥有一个SQL表,该表计算在特定日期发送的订单数量,例如:
Date Number of sent orders
2019-07-31 23
答案 0 :(得分:3)
将count
和cast
datetime
用作date
select cast ( ModDate as date) as d ,count(*) from t
group by cast ( ModDate as date)
答案 1 :(得分:3)
您可以尝试执行此操作,这将为您提供每个不同日期的计数结果。
select distinct cast(ModDate as date) as Date, count(ModDate) as [Count] from table group by cast(ModDate as date)
答案 2 :(得分:2)
您可以使用此查询
SELECT CONVERT(DATE,CreatedDate) as [DateTime], COUNT(*) as [Count]
FROM Orders
GROUP BY CONVERT(DATE,CreatedDate)
答案 3 :(得分:1)
您可以尝试以下方法:
select moddate ,count(*) over (partition by cast (ModDate as date)) from yourtable