我如何计算两个日期之间的行数。
SELECT Count(DATEDIFF(day, ReceiptDate,GETDATE()))
As TotalDays
From JobDetails
Where Receiptdate Between DATEADD(day, -30, GETDATE()) and DATEADD(day, -90, GETDATE())
AND RepairCompleted='N'
Group By ReceiptDate
例如,我想检查未完成的工作计数30到90天。
答案 0 :(得分:1)
试试这个:
SELECT Count(*) As TotalDays
FROM JobDetails
WHERE Receiptdate >= DATEADD(day, -90, GETDATE())
AND Receiptdate <= DATEADD(day, -30, GETDATE())
AND RepairCompleted='N'