下面是我SQL
用来计算两天之间天数的查询
SELECT count(*) as NoofCalls, outside.ReferenceNo, outside.WorkflowType, outside.Department, inside.CompletedDate, outside.CommentResponse, outside.CommentText, outside.CommentUserDisplayName, outside.StepName, outside.Originator, outside.Subject, outside.StartTime, CAST(DATEDIFF(hh, outside.StartTime, inside.CompletedDate) / 24.0 AS decimal(10,5)) AS CompDays
FROM
(
SELECT ReferenceNo, MAX(CommentDate) as CompletedDate
FROM FNCUSTOM.dbo.WorkflowHistory
WHERE WorkflowType IN (@WorkflowType) AND Department IN (@Department) AND Originator IN (@Originator) AND ReferenceNo IN (@Reference_No)
AND (StartTime between @StartDate AND @EndDate)
GROUP BY ReferenceNo
) inside
INNER JOIN FNCUSTOM.dbo.WorkflowHistory outside ON outside.ReferenceNo = inside.ReferenceNo AND outside.CommentDate=inside.CompletedDAte
GROUP BY outside.ReferenceNo, outside.WorkflowType, outside.Department, inside.CompletedDate, outside.CommentResponse, outside.CommentText, outside.CommentUserDisplayName, outside.StepName, outside.Originator, outside.Subject, outside.StartTime
我需要在计算 CompDays 时排除 FRIDAY & SATURDAY。
提前感谢您的帮助。