我想从上周五12PM到本周五12PM提交所有记录提交给SQL Server用于工资单。我有7天的工作时间,如下图所示,但我需要的是上周五的12PM到本周五的12PM。SQL Server:SELECT上周五下午12点到这个星期五12 PM
SELECT DISTINCT
notifications.requestid,
Max(timestatuschange),
assignedtouser,
Count(requestid) AS Total
FROM
notifications
WHERE
timestatuschange >= Dateadd(day, -7, Getdate())
AND notifications.status = 'Yellow'
OR timestatuschange >= Dateadd(day, -7, Getdate())
AND notifications.status = 'Red'
OR timestatuschange >= Dateadd(day, -7, Getdate())
AND notifications.status = 'Blue'
GROUP BY
requestid,
assignedtouser
的SQL Server版本是你使用? – ughai
Azure SQL Server –
请定义上星期五和这个星期五。通过这个星期五,你的意思是今天如果是星期五和未来的一些点,如果不是星期五? – Hogan