Created
September 13, 2018 13:42
-
-
Save chadsten/70f76d3f0891b76df54e8a5abf50911a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT EntryPerson, AVG((DATEDIFF(hh, ReceivedDate_c, DateTimeCreated_c) + CASE WHEN Datepart(dw, ReceivedDate_c) = 7 THEN 1 ELSE 0 END) - DATEDIFF(wk, | |
ReceivedDate_c, DateTimeCreated_c) * 2 - CASE WHEN Datepart(dw, ReceivedDate_c) = 1 THEN 1 ELSE 0 END + - CASE WHEN Datepart(dw, DateTimeCreated_c) | |
= 1 THEN 1 ELSE 0 END) AS Turnaround, CONVERT(DECIMAL(16, 2), 24) AS HoursInDay | |
FROM Epicor10.dbo.OrderHed | |
WHERE (ReceivedDate_c > DATEADD(month, - 3, GETDATE())) AND (ReceivedDate_c <= DateTimeCreated_c) AND (ReceivedDate_c IS NOT NULL) AND | |
(DateTimeCreated_c IS NOT NULL) AND (EntryPerson IN ('amberl', 'kaitlynn', 'cathys', 'jeffo', 'jamesh', 'keeleighc', 'morganp', 'michelled', 'jenellef', 'elviae', 'faitha', | |
'ronniel', 'johnh')) AND (DATEDIFF(dd, ReceivedDate_c, DateTimeCreated_c) < 30) | |
GROUP BY EntryPerson |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think this is wrong for calculating hours. Where you have *2, I think it should be *24. The 2 works if you are just counting days, but you need 24, if you are counting hours.