有一個日期列的例子,但我有一個日期時間列。
您如何計算每天使用日期時間列創建的行數?
示例資料:
ID CreatedDatetime
1 2017-05-21 09:14:41.022 -05:00
2 2017-05-21 07:16:49.026 -05:00
3 2017-05-23 08:18:46.023 -05:00
所需查詢的示例輸出:
Date RowsCreatedOnDate
2017-05-21 2
2017-05-23 1
uj5u.com熱心網友回復:
SELECT cast(CreatedDatetime as Date) as [Date], count(*) As RowsCreatedOnDate
FROM [MyTable]
GROUP BY cast(CreatedDatetime as Date)
看到它在這里作業:
https://dbfiddle.uk/?rdbms=sqlserver_2019&fiddle=d6caf210d264cc1b47e3da0cb8??04589a
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/313294.html
標籤:查询语句
上一篇:確定給定視窗內的連續天數
下一篇:如何從sql列的值中找到總和
