员工时间日志:计算“ Clock-In”和“ Clock-Out”时间戳之间的时间。 SSRS

时间:2019-02-11 21:32:16

标签: ssrs-2012

选择所有雇员后,此查询将不会仅返回每个雇员的计算。我只尝试返回“ Clock-In”和“ Clock-Out”之间的时间的结果。任何帮助将不胜感激!

SELECT DISTINCT i.SerialNumber, it.Name AS EmployeeName, cs.Value AS 
StepValue, cs.ModifiedOnUtc AS TimeStamp, CASE WHEN cs.Value = 'Clocked-In' 
THEN NULL WHEN cs.Value <> 'Clocked-In' THEN (CASE WHEN LAG(cs.Value, 1, 0) 
OVER (ORDER BY it.Name, cs.modifiedonserverutc) 
<> 'Clocked-In' THEN NULL WHEN LAG(cs.Value, 1, 0) OVER (ORDER BY it.name, 
cs.ModifiedOnUtc) = 'Clocked-in' THEN DATEDIFF(minute, LAG(cs.ModifiedOnUtc, 
1, 0) OVER (ORDER BY it.name, cs.ModifiedOnUtc), cs.ModifiedOnUtc) ELSE NULL 
END) END AS MinutesWorked

0 个答案:

没有答案